全てを再実装したJdbcAcsessです。
Revision | d6e8529e67c61478f37821c002dfb6b39dad15a1 (tree) |
---|---|
Time | 2012-02-13 22:02:37 |
Author | shimakazuro |
Commiter | shimakazuro |
jdialogの2回目以降で何故かマイナス位置に移動してしまうバグの仮対応
@@ -1,15 +1,15 @@ | ||
1 | 1 | /* |
2 | 2 | * Copyright 2011 Kazuhiro Shimada |
3 | 3 | * |
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. | |
6 | 6 | * You may obtain a copy of the License at |
7 | 7 | * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | 9 | * |
10 | - * Unless required by applicable law or agreed to in writing, software | |
10 | + * Unless required by applicable law or agreed to in writing, software | |
11 | 11 | * 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. | |
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
@@ -71,7 +71,7 @@ | ||
71 | 71 | /** |
72 | 72 | * データベースコネクション及びデータトランザクションを通知するリスナーの登録要求リスト |
73 | 73 | */ |
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: | |
75 | 75 | /** |
76 | 76 | * 接続画面のダイアログ |
77 | 77 | */ |
@@ -84,7 +84,7 @@ | ||
84 | 84 | /** |
85 | 85 | * 接続先一覧の選択に連動して、接続詳細情報を表示する |
86 | 86 | */ |
87 | - private ListSelectionListener selectionConnectList = new ListSelectionListener() { | |
87 | + private final ListSelectionListener selectionConnectList = new ListSelectionListener() { | |
88 | 88 | @Override |
89 | 89 | public void valueChanged(ListSelectionEvent e) { |
90 | 90 | Jdbcacsess2.logger.finer(e.toString()); |
@@ -111,7 +111,6 @@ | ||
111 | 111 | view.getJTextFieldClassName().setText(row.getClassName()); |
112 | 112 | view.getJTextAreaDriverFile().setText(row.getDriverFile()); |
113 | 113 | view.getJTextFieldUrlOption().setText(row.getUrlOption()); |
114 | - | |
115 | 114 | } |
116 | 115 | }; |
117 | 116 |
@@ -172,12 +171,12 @@ | ||
172 | 171 | } |
173 | 172 | } |
174 | 173 | |
175 | - private JdbcUrlChnageListener changeJdbcUrl = new JdbcUrlChnageListener(); | |
174 | + private final JdbcUrlChnageListener changeJdbcUrl = new JdbcUrlChnageListener(); | |
176 | 175 | |
177 | 176 | /** |
178 | 177 | * DBMSの選択に連動してクラス名を変更する |
179 | 178 | */ |
180 | - private ItemListener changeDbms = new ItemListener() { | |
179 | + private final ItemListener changeDbms = new ItemListener() { | |
181 | 180 | @Override |
182 | 181 | public void itemStateChanged(ItemEvent e) { |
183 | 182 | if (e.getStateChange() != ItemEvent.SELECTED) { |
@@ -197,7 +196,7 @@ | ||
197 | 196 | /** |
198 | 197 | * ドライバファイルの参照アクション |
199 | 198 | */ |
200 | - private Action actionFileChoose = new AbstractAction() { | |
199 | + private final Action actionFileChoose = new AbstractAction() { | |
201 | 200 | @Override |
202 | 201 | public void actionPerformed(ActionEvent e) { |
203 | 202 | final JFileChooser jFileChooser = new JFileChooser(); |
@@ -250,7 +249,7 @@ | ||
250 | 249 | /** |
251 | 250 | * ボタン以外のシステムウィンドウクローズイベント |
252 | 251 | */ |
253 | - private WindowAdapter windowClosing = new WindowAdapter() { | |
252 | + private final WindowAdapter windowClosing = new WindowAdapter() { | |
254 | 253 | @Override |
255 | 254 | public void windowClosing(WindowEvent e) { |
256 | 255 | // component保存 |
@@ -267,7 +266,7 @@ | ||
267 | 266 | /** |
268 | 267 | * 閉じるアクション |
269 | 268 | */ |
270 | - private Action actionClose = new AbstractAction() { | |
269 | + private final Action actionClose = new AbstractAction() { | |
271 | 270 | @Override |
272 | 271 | public void actionPerformed(ActionEvent e) { |
273 | 272 | // component保存 |
@@ -286,7 +285,7 @@ | ||
286 | 285 | /** |
287 | 286 | * ダブルクリック接続アクション |
288 | 287 | */ |
289 | - private MouseListener connectClickMouseListener = new MouseAdapter() { | |
288 | + private final MouseListener connectClickMouseListener = new MouseAdapter() { | |
290 | 289 | @Override |
291 | 290 | public void mouseClicked(MouseEvent me) { |
292 | 291 | if (me.getClickCount() == 2) { |
@@ -297,7 +296,7 @@ | ||
297 | 296 | /** |
298 | 297 | * 接続アクション |
299 | 298 | */ |
300 | - private Action actionConnect = new AbstractAction() { | |
299 | + private final Action actionConnect = new AbstractAction() { | |
301 | 300 | @Override |
302 | 301 | public void actionPerformed(ActionEvent e) { |
303 | 302 | try { |
@@ -321,7 +320,7 @@ | ||
321 | 320 | * |
322 | 321 | */ |
323 | 322 | private class DbOpen extends SwingWorker<Object, Object> implements DataBaseConnectionListener { |
324 | - private DataBaseConnection dbc; | |
323 | + private final DataBaseConnection dbc; | |
325 | 324 | |
326 | 325 | DbOpen(DataBaseConnection dbc) { |
327 | 326 | this.dbc = dbc; |
@@ -331,14 +330,14 @@ | ||
331 | 330 | |
332 | 331 | @Override |
333 | 332 | 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); | |
342 | 341 | try { |
343 | 342 | dbc.open(); |
344 | 343 | } catch (Exception ex) { |
@@ -401,29 +400,29 @@ | ||
401 | 400 | |
402 | 401 | @Override |
403 | 402 | public void dataBaseConnectionClosing( |
404 | - DataBaseConnection dataBaseConnection) { | |
403 | + DataBaseConnection dataBaseConnection) { | |
405 | 404 | dataBaseConnection.removeConnectionlisteners(this); |
406 | 405 | } |
407 | 406 | |
408 | 407 | @Override |
409 | 408 | public void dataBaseConnectionClosed( |
410 | - DataBaseConnection dataBaseConnection) { | |
409 | + DataBaseConnection dataBaseConnection) { | |
411 | 410 | } |
412 | 411 | } |
413 | 412 | |
414 | 413 | /** |
415 | 414 | * 接続テストアクション |
416 | 415 | */ |
417 | - private Action actionConnectTest = new AbstractAction() { | |
416 | + private final Action actionConnectTest = new AbstractAction() { | |
418 | 417 | @Override |
419 | 418 | public void actionPerformed(ActionEvent e) { |
420 | 419 | try { |
421 | 420 | 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()); | |
427 | 426 | new DbTestOpen(dbc).execute(); |
428 | 427 | |
429 | 428 | } catch (Exception ex) { |
@@ -439,7 +438,7 @@ | ||
439 | 438 | * |
440 | 439 | */ |
441 | 440 | private class DbTestOpen extends SwingWorker<Object, Object> implements DataBaseConnectionListener { |
442 | - private DataBaseConnection dbc; | |
441 | + private final DataBaseConnection dbc; | |
443 | 442 | |
444 | 443 | DbTestOpen(DataBaseConnection dbc) { |
445 | 444 | this.dbc = dbc; |
@@ -471,7 +470,7 @@ | ||
471 | 470 | @Override |
472 | 471 | public void run() { |
473 | 472 | ShowDialog.infomationMessage(view, "url[" + dbc.getUrl() + "]に、\n" + "user[" + dbc.getUser() |
474 | - + "]で接続成功しました。", "接続テストに成功しました"); | |
473 | + + "]で接続成功しました。", "接続テストに成功しました"); | |
475 | 474 | |
476 | 475 | if (view.getJCheckBoxAutosave().isSelected()) { |
477 | 476 | try { |
@@ -501,14 +500,14 @@ | ||
501 | 500 | /** |
502 | 501 | * 新規保存アクション |
503 | 502 | */ |
504 | - private Action actionNewSave = new AbstractAction() { | |
503 | + private final Action actionNewSave = new AbstractAction() { | |
505 | 504 | @Override |
506 | 505 | public void actionPerformed(ActionEvent e) { |
507 | 506 | try { |
508 | 507 | DBParam dbParam = new DBParam(ConfigConnect.CONNECTNAME, |
509 | - view.getJTextFieldConnectName().getText()); | |
508 | + view.getJTextFieldConnectName().getText()); | |
510 | 509 | ConfigConnect configConnect = config.getEntityManager().create(ConfigConnect.class, |
511 | - dbParam); | |
510 | + dbParam); | |
512 | 511 | collectInputData(configConnect); |
513 | 512 | connectTableModel.append(configConnect); |
514 | 513 | } catch (SQLException e1) { |
@@ -523,7 +522,7 @@ | ||
523 | 522 | /** |
524 | 523 | * 上書き保存アクション |
525 | 524 | */ |
526 | - private Action actionSave = new AbstractAction() { | |
525 | + private final Action actionSave = new AbstractAction() { | |
527 | 526 | @Override |
528 | 527 | public void actionPerformed(ActionEvent e) { |
529 | 528 | ConfigConnect configConnect = view.getSelectedConfigConnect(); |
@@ -534,11 +533,11 @@ | ||
534 | 533 | connectTableModel.update(configConnect); |
535 | 534 | } |
536 | 535 | }; |
537 | - | |
536 | + | |
538 | 537 | /** |
539 | 538 | * 接続削除アクション |
540 | 539 | */ |
541 | - private Action actionRemove = new AbstractAction() { | |
540 | + private final Action actionRemove = new AbstractAction() { | |
542 | 541 | @Override |
543 | 542 | public void actionPerformed(ActionEvent e) { |
544 | 543 | ConfigConnect configConnect = view.getSelectedConfigConnect(); |
@@ -616,7 +615,7 @@ | ||
616 | 615 | view.getJTableConnect().getRowSorter().toggleSortOrder(0); |
617 | 616 | |
618 | 617 | // GUIのコンポーネント属性を復元 |
619 | - ConfigViewConnect[] c = config.getEntityManager().find(ConnectView.ConfigViewConnect.class); | |
618 | + final ConfigViewConnect[] c = config.getEntityManager().find(ConnectView.ConfigViewConnect.class); | |
620 | 619 | if (c.length != 0) { |
621 | 620 | view.setViewConnect(c[0]); |
622 | 621 | } |
@@ -39,6 +39,7 @@ | ||
39 | 39 | import javax.swing.JSplitPane; |
40 | 40 | import javax.swing.JTextArea; |
41 | 41 | import javax.swing.JTextField; |
42 | +import javax.swing.SwingUtilities; | |
42 | 43 | import javax.swing.WindowConstants; |
43 | 44 | import javax.swing.border.BevelBorder; |
44 | 45 | import javax.swing.border.TitledBorder; |
@@ -111,9 +112,7 @@ | ||
111 | 112 | * 復元するConfigViewConnect |
112 | 113 | * @throws SQLException |
113 | 114 | */ |
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 { | |
117 | 116 | jSplitPane.setDividerLocation(c.getDividerLocation()); |
118 | 117 | jSplitPane.setLastDividerLocation(c.getLastDividerLocation()); |
119 | 118 |
@@ -125,6 +124,17 @@ | ||
125 | 124 | jTableConnect.getSelectionModel().setSelectionInterval(i, i); |
126 | 125 | } |
127 | 126 | } |
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 | + }); | |
128 | 138 | } |
129 | 139 | |
130 | 140 | /** |
@@ -208,12 +218,14 @@ | ||
208 | 218 | * |
209 | 219 | */ |
210 | 220 | private void initialize() { |
221 | + // どうも、Linux java7 でバグってないか? | |
222 | + this.setLocationByPlatform(false); | |
223 | + | |
211 | 224 | this.setSize(new Dimension(500, 550)); |
212 | 225 | this.setModal(true); |
213 | 226 | this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
214 | 227 | this.setTitle("データベース接続"); |
215 | 228 | this.setContentPane(getJPanel()); |
216 | - | |
217 | 229 | } |
218 | 230 | |
219 | 231 | /** |
@@ -173,7 +173,7 @@ | ||
173 | 173 | } |
174 | 174 | |
175 | 175 | SqlAsyncExecute sqlAsyncExecute = new SqlAsyncExecute(sql, |
176 | - ((SentenceSeparator) jPanelSql.getJComboBoxSentenceSeparator().getSelectedItem()).getRegVal()); | |
176 | + ((SentenceSeparator) jPanelSql.getJComboBoxSentenceSeparator().getSelectedItem()).getRegVal()); | |
177 | 177 | if (sqlAsyncExecute.isDuplxSelect()) { |
178 | 178 | ShowDialog.warningMessage("複数のSELECT文は実行出来ません", "複数のSELECT文"); |
179 | 179 | jPanelSql.getJToggleButtonExecution().setSelected(false); |
@@ -186,10 +186,10 @@ | ||
186 | 186 | |
187 | 187 | try { |
188 | 188 | 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)); | |
193 | 193 | // sql実行 |
194 | 194 | sqlAsyncExecute.executeAsync(jPanelSql.getDataBaseConnection()); |
195 | 195 |
@@ -381,7 +381,7 @@ | ||
381 | 381 | // SQL実行履歴のフィルタをjtableのオブジェクト単位に作成 |
382 | 382 | TableRowSorter<HistryTableModel> sorter = new TableRowSorter<HistryTableModel>(histryTableModel); |
383 | 383 | sorter.setRowFilter(RowFilter.regexFilter("^" + dbc.getConnectName() + "$", |
384 | - HistryTableModel.FILTERCLOUMN)); | |
384 | + HistryTableModel.FILTERCLOUMN)); | |
385 | 385 | |
386 | 386 | List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(); |
387 | 387 | sortKeys.add(new RowSorter.SortKey(0, SortOrder.DESCENDING)); |
@@ -400,7 +400,7 @@ | ||
400 | 400 | jPanelSession.getJTabbedPaneSql().add(jPanelHIstory, "History", 0); |
401 | 401 | |
402 | 402 | jPanelSession.jLabelStatus.setText("NAME=" + dbc.getConnectName() + " " + "URL=" + dbc.getUrl() |
403 | - + " " + "USER=" + dbc.getUser()); | |
403 | + + " " + "USER=" + dbc.getUser()); | |
404 | 404 | |
405 | 405 | // SQLパネルの表示 |
406 | 406 | try { |
@@ -490,9 +490,9 @@ | ||
490 | 490 | |
491 | 491 | Keymap keymap = jPanelSql.getRSyntaxTextAreaSql().getKeymap(); |
492 | 492 | keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), |
493 | - actionExecutionShortcut); | |
493 | + actionExecutionShortcut); | |
494 | 494 | keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_DOWN_MASK), |
495 | - actionCodeAssistDisplay); | |
495 | + actionCodeAssistDisplay); | |
496 | 496 | |
497 | 497 | // セル移動のショートカットを登録する |
498 | 498 | JTableShortcut.setJTableShortcut(jPanelSql.getJTable()); |
@@ -711,7 +711,7 @@ | ||
711 | 711 | } |
712 | 712 | |
713 | 713 | TreePath tp = view.getCurrentJPanelSession().getJXTreetableDBObjects().getPathForLocation(e.getX(), |
714 | - e.getY()); | |
714 | + e.getY()); | |
715 | 715 | if (tp == null) { |
716 | 716 | return; |
717 | 717 | } |