• R/O
  • SSH

JdbcAcsess2: Commit

全てを再実装したJdbcAcsessです。


Commit MetaInfo

Revisiond6e8529e67c61478f37821c002dfb6b39dad15a1 (tree)
Time2012-02-13 22:02:37
Authorshimakazuro
Commitershimakazuro

Log Message

jdialogの2回目以降で何故かマイナス位置に移動してしまうバグの仮対応

Change Summary

Incremental Difference

diff -r dd9202ce25dd -r d6e8529e67c6 src/jdbcacsess2/connect/ConnectController.java
--- a/src/jdbcacsess2/connect/ConnectController.java Sun Feb 12 23:34:27 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectController.java Mon Feb 13 22:02:37 2012 +0900
@@ -1,15 +1,15 @@
11 /*
22 * Copyright 2011 Kazuhiro Shimada
33 *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
10- * Unless required by applicable law or agreed to in writing, software
10+ * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
@@ -71,7 +71,7 @@
7171 /**
7272 * データベースコネクション及びデータトランザクションを通知するリスナーの登録要求リスト
7373 */
74- private List<DataBaseListener> requestListeners = new CopyOnWriteArrayList<DataBaseListener>(); // @jve:decl-index=0:
74+ private final List<DataBaseListener> requestListeners = new CopyOnWriteArrayList<DataBaseListener>(); // @jve:decl-index=0:
7575 /**
7676 * 接続画面のダイアログ
7777 */
@@ -84,7 +84,7 @@
8484 /**
8585 * 接続先一覧の選択に連動して、接続詳細情報を表示する
8686 */
87- private ListSelectionListener selectionConnectList = new ListSelectionListener() {
87+ private final ListSelectionListener selectionConnectList = new ListSelectionListener() {
8888 @Override
8989 public void valueChanged(ListSelectionEvent e) {
9090 Jdbcacsess2.logger.finer(e.toString());
@@ -111,7 +111,6 @@
111111 view.getJTextFieldClassName().setText(row.getClassName());
112112 view.getJTextAreaDriverFile().setText(row.getDriverFile());
113113 view.getJTextFieldUrlOption().setText(row.getUrlOption());
114-
115114 }
116115 };
117116
@@ -172,12 +171,12 @@
172171 }
173172 }
174173
175- private JdbcUrlChnageListener changeJdbcUrl = new JdbcUrlChnageListener();
174+ private final JdbcUrlChnageListener changeJdbcUrl = new JdbcUrlChnageListener();
176175
177176 /**
178177 * DBMSの選択に連動してクラス名を変更する
179178 */
180- private ItemListener changeDbms = new ItemListener() {
179+ private final ItemListener changeDbms = new ItemListener() {
181180 @Override
182181 public void itemStateChanged(ItemEvent e) {
183182 if (e.getStateChange() != ItemEvent.SELECTED) {
@@ -197,7 +196,7 @@
197196 /**
198197 * ドライバファイルの参照アクション
199198 */
200- private Action actionFileChoose = new AbstractAction() {
199+ private final Action actionFileChoose = new AbstractAction() {
201200 @Override
202201 public void actionPerformed(ActionEvent e) {
203202 final JFileChooser jFileChooser = new JFileChooser();
@@ -250,7 +249,7 @@
250249 /**
251250 * ボタン以外のシステムウィンドウクローズイベント
252251 */
253- private WindowAdapter windowClosing = new WindowAdapter() {
252+ private final WindowAdapter windowClosing = new WindowAdapter() {
254253 @Override
255254 public void windowClosing(WindowEvent e) {
256255 // component保存
@@ -267,7 +266,7 @@
267266 /**
268267 * 閉じるアクション
269268 */
270- private Action actionClose = new AbstractAction() {
269+ private final Action actionClose = new AbstractAction() {
271270 @Override
272271 public void actionPerformed(ActionEvent e) {
273272 // component保存
@@ -286,7 +285,7 @@
286285 /**
287286 * ダブルクリック接続アクション
288287 */
289- private MouseListener connectClickMouseListener = new MouseAdapter() {
288+ private final MouseListener connectClickMouseListener = new MouseAdapter() {
290289 @Override
291290 public void mouseClicked(MouseEvent me) {
292291 if (me.getClickCount() == 2) {
@@ -297,7 +296,7 @@
297296 /**
298297 * 接続アクション
299298 */
300- private Action actionConnect = new AbstractAction() {
299+ private final Action actionConnect = new AbstractAction() {
301300 @Override
302301 public void actionPerformed(ActionEvent e) {
303302 try {
@@ -321,7 +320,7 @@
321320 *
322321 */
323322 private class DbOpen extends SwingWorker<Object, Object> implements DataBaseConnectionListener {
324- private DataBaseConnection dbc;
323+ private final DataBaseConnection dbc;
325324
326325 DbOpen(DataBaseConnection dbc) {
327326 this.dbc = dbc;
@@ -331,14 +330,14 @@
331330
332331 @Override
333332 public Object doInBackground() {
334- for (DataBaseListener listener : requestListeners) {
335- // 登録要求のあったリスナーを全て登録する。
336- if (listener instanceof DataBaseConnectionListener)
337- dbc.addConnectionListener((DataBaseConnectionListener) listener);
338- if (listener instanceof DataBaseTransactionListener)
339- dbc.addTransactionListener((DataBaseTransactionListener) listener);
340- }
341- dbc.addConnectionListener(this);
333+ for (DataBaseListener listener : requestListeners) {
334+ // 登録要求のあったリスナーを全て登録する。
335+ if (listener instanceof DataBaseConnectionListener)
336+ dbc.addConnectionListener((DataBaseConnectionListener) listener);
337+ if (listener instanceof DataBaseTransactionListener)
338+ dbc.addTransactionListener((DataBaseTransactionListener) listener);
339+ }
340+ dbc.addConnectionListener(this);
342341 try {
343342 dbc.open();
344343 } catch (Exception ex) {
@@ -401,29 +400,29 @@
401400
402401 @Override
403402 public void dataBaseConnectionClosing(
404- DataBaseConnection dataBaseConnection) {
403+ DataBaseConnection dataBaseConnection) {
405404 dataBaseConnection.removeConnectionlisteners(this);
406405 }
407406
408407 @Override
409408 public void dataBaseConnectionClosed(
410- DataBaseConnection dataBaseConnection) {
409+ DataBaseConnection dataBaseConnection) {
411410 }
412411 }
413412
414413 /**
415414 * 接続テストアクション
416415 */
417- private Action actionConnectTest = new AbstractAction() {
416+ private final Action actionConnectTest = new AbstractAction() {
418417 @Override
419418 public void actionPerformed(ActionEvent e) {
420419 try {
421420 DataBaseConnection dbc = new DataBaseConnection(view.getJTextAreaURL().getText(),
422- view.getJTextFieldUser().getText(),
423- new String(view.getJPasswordFieldPassword().getPassword()),
424- view.getJTextFieldClassName().getText(),
425- DataBaseConnection.splitPath(view.getJTextAreaDriverFile().getText()),
426- view.getJTextFieldConnectName().getText());
421+ view.getJTextFieldUser().getText(),
422+ new String(view.getJPasswordFieldPassword().getPassword()),
423+ view.getJTextFieldClassName().getText(),
424+ DataBaseConnection.splitPath(view.getJTextAreaDriverFile().getText()),
425+ view.getJTextFieldConnectName().getText());
427426 new DbTestOpen(dbc).execute();
428427
429428 } catch (Exception ex) {
@@ -439,7 +438,7 @@
439438 *
440439 */
441440 private class DbTestOpen extends SwingWorker<Object, Object> implements DataBaseConnectionListener {
442- private DataBaseConnection dbc;
441+ private final DataBaseConnection dbc;
443442
444443 DbTestOpen(DataBaseConnection dbc) {
445444 this.dbc = dbc;
@@ -471,7 +470,7 @@
471470 @Override
472471 public void run() {
473472 ShowDialog.infomationMessage(view, "url[" + dbc.getUrl() + "]に、\n" + "user[" + dbc.getUser()
474- + "]で接続成功しました。", "接続テストに成功しました");
473+ + "]で接続成功しました。", "接続テストに成功しました");
475474
476475 if (view.getJCheckBoxAutosave().isSelected()) {
477476 try {
@@ -501,14 +500,14 @@
501500 /**
502501 * 新規保存アクション
503502 */
504- private Action actionNewSave = new AbstractAction() {
503+ private final Action actionNewSave = new AbstractAction() {
505504 @Override
506505 public void actionPerformed(ActionEvent e) {
507506 try {
508507 DBParam dbParam = new DBParam(ConfigConnect.CONNECTNAME,
509- view.getJTextFieldConnectName().getText());
508+ view.getJTextFieldConnectName().getText());
510509 ConfigConnect configConnect = config.getEntityManager().create(ConfigConnect.class,
511- dbParam);
510+ dbParam);
512511 collectInputData(configConnect);
513512 connectTableModel.append(configConnect);
514513 } catch (SQLException e1) {
@@ -523,7 +522,7 @@
523522 /**
524523 * 上書き保存アクション
525524 */
526- private Action actionSave = new AbstractAction() {
525+ private final Action actionSave = new AbstractAction() {
527526 @Override
528527 public void actionPerformed(ActionEvent e) {
529528 ConfigConnect configConnect = view.getSelectedConfigConnect();
@@ -534,11 +533,11 @@
534533 connectTableModel.update(configConnect);
535534 }
536535 };
537-
536+
538537 /**
539538 * 接続削除アクション
540539 */
541- private Action actionRemove = new AbstractAction() {
540+ private final Action actionRemove = new AbstractAction() {
542541 @Override
543542 public void actionPerformed(ActionEvent e) {
544543 ConfigConnect configConnect = view.getSelectedConfigConnect();
@@ -616,7 +615,7 @@
616615 view.getJTableConnect().getRowSorter().toggleSortOrder(0);
617616
618617 // GUIのコンポーネント属性を復元
619- ConfigViewConnect[] c = config.getEntityManager().find(ConnectView.ConfigViewConnect.class);
618+ final ConfigViewConnect[] c = config.getEntityManager().find(ConnectView.ConfigViewConnect.class);
620619 if (c.length != 0) {
621620 view.setViewConnect(c[0]);
622621 }
diff -r dd9202ce25dd -r d6e8529e67c6 src/jdbcacsess2/connect/ConnectView.java
--- a/src/jdbcacsess2/connect/ConnectView.java Sun Feb 12 23:34:27 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectView.java Mon Feb 13 22:02:37 2012 +0900
@@ -39,6 +39,7 @@
3939 import javax.swing.JSplitPane;
4040 import javax.swing.JTextArea;
4141 import javax.swing.JTextField;
42+import javax.swing.SwingUtilities;
4243 import javax.swing.WindowConstants;
4344 import javax.swing.border.BevelBorder;
4445 import javax.swing.border.TitledBorder;
@@ -111,9 +112,7 @@
111112 * 復元するConfigViewConnect
112113 * @throws SQLException
113114 */
114- public void setViewConnect(ConfigViewConnect c) throws SQLException {
115- setSize(c.getWidth(), c.getHeight());
116- setLocation(c.getX(), c.getY());
115+ public void setViewConnect(final ConfigViewConnect c) throws SQLException {
117116 jSplitPane.setDividerLocation(c.getDividerLocation());
118117 jSplitPane.setLastDividerLocation(c.getLastDividerLocation());
119118
@@ -125,6 +124,17 @@
125124 jTableConnect.getSelectionModel().setSelectionInterval(i, i);
126125 }
127126 }
127+ setSize(c.getWidth(), c.getHeight());
128+
129+ // setVisibleの中で、何故かx,y=(-6,-23)へ移動してしまう。
130+ // とりあえず、画面移動がsetVisibleの後に行われることを期待してEDTへスレッドキューイング。
131+ // 時々、ダメだけどかなりましになった。
132+ SwingUtilities.invokeLater(new Runnable() {
133+ @Override
134+ public void run() {
135+ setLocation(c.getX(), c.getY());
136+ }
137+ });
128138 }
129139
130140 /**
@@ -208,12 +218,14 @@
208218 *
209219 */
210220 private void initialize() {
221+ // どうも、Linux java7 でバグってないか?
222+ this.setLocationByPlatform(false);
223+
211224 this.setSize(new Dimension(500, 550));
212225 this.setModal(true);
213226 this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
214227 this.setTitle("データベース接続");
215228 this.setContentPane(getJPanel());
216-
217229 }
218230
219231 /**
diff -r dd9202ce25dd -r d6e8529e67c6 src/jdbcacsess2/main/MainController.java
--- a/src/jdbcacsess2/main/MainController.java Sun Feb 12 23:34:27 2012 +0900
+++ b/src/jdbcacsess2/main/MainController.java Mon Feb 13 22:02:37 2012 +0900
@@ -173,7 +173,7 @@
173173 }
174174
175175 SqlAsyncExecute sqlAsyncExecute = new SqlAsyncExecute(sql,
176- ((SentenceSeparator) jPanelSql.getJComboBoxSentenceSeparator().getSelectedItem()).getRegVal());
176+ ((SentenceSeparator) jPanelSql.getJComboBoxSentenceSeparator().getSelectedItem()).getRegVal());
177177 if (sqlAsyncExecute.isDuplxSelect()) {
178178 ShowDialog.warningMessage("複数のSELECT文は実行出来ません", "複数のSELECT文");
179179 jPanelSql.getJToggleButtonExecution().setSelected(false);
@@ -186,10 +186,10 @@
186186
187187 try {
188188 sqlAsyncExecute.addSqlExcutedListener(new Record(config,
189- jPanelSql.getDataBaseConnection().getConnectName(),
190- jPanelSql.getDataBaseConnection().getUrl(),
191- jPanelSql.getDataBaseConnection().getUser(),
192- histryTableModel));
189+ jPanelSql.getDataBaseConnection().getConnectName(),
190+ jPanelSql.getDataBaseConnection().getUrl(),
191+ jPanelSql.getDataBaseConnection().getUser(),
192+ histryTableModel));
193193 // sql実行
194194 sqlAsyncExecute.executeAsync(jPanelSql.getDataBaseConnection());
195195
@@ -381,7 +381,7 @@
381381 // SQL実行履歴のフィルタをjtableのオブジェクト単位に作成
382382 TableRowSorter<HistryTableModel> sorter = new TableRowSorter<HistryTableModel>(histryTableModel);
383383 sorter.setRowFilter(RowFilter.regexFilter("^" + dbc.getConnectName() + "$",
384- HistryTableModel.FILTERCLOUMN));
384+ HistryTableModel.FILTERCLOUMN));
385385
386386 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
387387 sortKeys.add(new RowSorter.SortKey(0, SortOrder.DESCENDING));
@@ -400,7 +400,7 @@
400400 jPanelSession.getJTabbedPaneSql().add(jPanelHIstory, "History", 0);
401401
402402 jPanelSession.jLabelStatus.setText("NAME=" + dbc.getConnectName() + " " + "URL=" + dbc.getUrl()
403- + " " + "USER=" + dbc.getUser());
403+ + " " + "USER=" + dbc.getUser());
404404
405405 // SQLパネルの表示
406406 try {
@@ -490,9 +490,9 @@
490490
491491 Keymap keymap = jPanelSql.getRSyntaxTextAreaSql().getKeymap();
492492 keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK),
493- actionExecutionShortcut);
493+ actionExecutionShortcut);
494494 keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_DOWN_MASK),
495- actionCodeAssistDisplay);
495+ actionCodeAssistDisplay);
496496
497497 // セル移動のショートカットを登録する
498498 JTableShortcut.setJTableShortcut(jPanelSql.getJTable());
@@ -711,7 +711,7 @@
711711 }
712712
713713 TreePath tp = view.getCurrentJPanelSession().getJXTreetableDBObjects().getPathForLocation(e.getX(),
714- e.getY());
714+ e.getY());
715715 if (tp == null) {
716716 return;
717717 }
Show on old repository browser