• R/O
  • SSH

JdbcAcsess2: Commit

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


Commit MetaInfo

Revisione366c0f78aa8af0fe694fd4e9a63bd219395ffd7 (tree)
Time2012-03-04 12:45:48
Authorshimakazuro
Commitershimakazuro

Log Message

Fontズーム汎用化

Change Summary

Incremental Difference

diff -r b6558ad47c50 -r e366c0f78aa8 src/jdbcacsess2/main/FontZoomByMouseWheel.java
--- a/src/jdbcacsess2/main/FontZoomByMouseWheel.java Sun Mar 04 12:13:41 2012 +0900
+++ b/src/jdbcacsess2/main/FontZoomByMouseWheel.java Sun Mar 04 12:45:48 2012 +0900
@@ -43,7 +43,6 @@
4343 }
4444 if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
4545 component.addMouseWheelListener(mouseWheelListener);
46- Jdbcacsess2.logger.fine("font=" + component.getFont());
4746 press = true;
4847 }
4948 }
@@ -52,7 +51,6 @@
5251 public void keyReleased(KeyEvent e) {
5352 if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
5453 component.removeMouseWheelListener(mouseWheelListener);
55- Jdbcacsess2.logger.fine("font=" + component.getFont());
5654 press = false;
5755 }
5856 }
@@ -83,8 +81,9 @@
8381
8482 Font font = component.getFont();
8583 float size = font.getSize() + e.getWheelRotation();
86-
87- component.setFont(font.deriveFont(size));
84+ if (4 < size && size < 30) {
85+ component.setFont(font.deriveFont(size));
86+ }
8887 e.consume();
8988 }
9089 };
diff -r b6558ad47c50 -r e366c0f78aa8 src/jdbcacsess2/main/JPanelHIstory.java
--- a/src/jdbcacsess2/main/JPanelHIstory.java Sun Mar 04 12:13:41 2012 +0900
+++ b/src/jdbcacsess2/main/JPanelHIstory.java Sun Mar 04 12:45:48 2012 +0900
@@ -44,6 +44,7 @@
4444 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
4545 table.setCellSelectionEnabled(true);
4646 scrollPane.setViewportView(table);
47+ new FontZoomByMouseWheel(table);
4748
4849 JToolBar toolBar = new JToolBar();
4950 add(toolBar, BorderLayout.NORTH);
diff -r b6558ad47c50 -r e366c0f78aa8 src/jdbcacsess2/main/JPanelSql.java
--- a/src/jdbcacsess2/main/JPanelSql.java Sun Mar 04 12:13:41 2012 +0900
+++ b/src/jdbcacsess2/main/JPanelSql.java Sun Mar 04 12:45:48 2012 +0900
@@ -59,803 +59,804 @@
5959 public class JPanelSql extends JPanel implements SqlExecutedListener, DataBaseConnectionListener,
6060 DataBaseTransactionListener {
6161
62- // -------------------------------------------------------------------------
63- // -------------------------------------------------------------------------
64- // -------------------------------------------------------------------------
65-
66- final static private int TABBEDPANEL_INDEX_DATA = 0;
67- final static private int TABBEDPANEL_INDEX_LOG = 1;
68- final static private int TABBEDPANEL_INDEX_RS = 2;
69-
70- private DataBaseConnection dataBaseConnection; // @jve:decl-index=0:
71-
72- /*
73- * (非 Javadoc)
74- *
75- * @see
76- * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionOpened
77- * (jdbcacsess2.sqlService.DataBaseConnection)
78- */
79- @Override
80- public void dataBaseConnectionOpened(DataBaseConnection dataBaseConnection) {
81- this.dataBaseConnection = dataBaseConnection;
82-
83- SwingUtilities.invokeLater(new Runnable() {
84- @Override
85- public void run() {
86- writeGuiLog("connection opened");
87-
88- // dbコネクションの autocommit を、画面設定から取得して設定する。
89- boolean flg = getJCheckBoxAutoCommit().isSelected();
90- try {
91- getDataBaseConnection().setAutoCommit(flg);
92-
93- getJToggleButtonExecution().setEnabled(true);
94- getJButtonContinue().setEnabled(false);
95- getJCheckBoxAutoCommit().setEnabled(true);
96- getJToggleButtonConnection().setSelected(true);
97- } catch (Exception e) {
98- ShowDialog.errorMessage(e);
99- }
100- }
101- });
102-
103- }
104-
105- /*
106- * (非 Javadoc)
107- *
108- * @see
109- * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionClosing
110- * ()
111- */
112- @Override
113- public void dataBaseConnectionClosing(DataBaseConnection dataBaseConnection) {
114- SwingUtilities.invokeLater(new Runnable() {
115- @Override
116- public void run() {
117- getJToggleButtonExecution().setEnabled(false);
118- getJButtonContinue().setEnabled(false);
119- getJCheckBoxAutoCommit().setEnabled(false);
120- getJButtonCommit().setEnabled(false);
121- getJButtonRollback().setEnabled(false);
122- getJToggleButtonConnection().setSelected(false);
123- }
124- });
125- }
126-
127- /*
128- * (非 Javadoc)
129- *
130- * @see
131- * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionClosed
132- * ()
133- */
134- @Override
135- public void dataBaseConnectionClosed(DataBaseConnection dataBaseConnection) {
136- SwingUtilities.invokeLater(new Runnable() {
137- @Override
138- public void run() {
139- writeGuiLog("connection closed");
140- }
141- });
142- }
143-
144- /**
145- * @return dataBaseConnection
146- */
147- DataBaseConnection getDataBaseConnection() {
148- return dataBaseConnection;
149- }
150-
151- /*
152- * (非 Javadoc)
153- *
154- * @see
155- * jdbcacsess2.sqlService.DataBaseTransactionListener#autoCommitChange(boolean
156- * )
157- */
158- @Override
159- public void autoCommitChange(DataBaseConnection dataBaseConnection, final boolean autoCommit) {
160- SwingUtilities.invokeLater(new Runnable() {
161- @Override
162- public void run() {
163- writeGuiLog("autocommit[" + autoCommit + "]");
164- }
165- });
166- }
167-
168- /*
169- * (非 Javadoc)
170- *
171- * @see jdbcacsess2.sqlService.DataBaseTransactionListener#commitEnd()
172- */
173- @Override
174- public void commitEnd(DataBaseConnection dataBaseConnection) {
175- SwingUtilities.invokeLater(new Runnable() {
176- @Override
177- public void run() {
178- getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
179- writeGuiLog("commit end");
180- }
181- });
182- }
183-
184- /*
185- * (非 Javadoc)
186- *
187- * @see jdbcacsess2.sqlService.DataBaseTransactionListener#rollbackEnd()
188- */
189- @Override
190- public void rollbackEnd(DataBaseConnection dataBaseConnection) {
191- SwingUtilities.invokeLater(new Runnable() {
192- @Override
193- public void run() {
194- getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
195- writeGuiLog("rollback end");
196- }
197- });
198- }
199-
200- /**
201- * SQLパネルログへ出力
202- *
203- * @param message
204- * 出力文字列
205- */
206- private void writeGuiLog(String message) {
207- int i;
208- for (i = message.length(); 0 < i; i--) {
209- String s = message.substring(i - 1, i);
210- if (!s.equals("\n")) {
211- break;
212- }
213- }
214-
215- getJTextAreaLog().append(message.substring(0, i));
216- getJTextAreaLog().append("\n");
217- getJTextAreaLog().setCaretPosition(getJTextAreaLog().getText().length());
218- }
219-
220- //
221- /**
222- * 文字列を挿入します。改行文字が含まれている場合、インデントされます。
223- *
224- * @param str
225- * 挿入したい文字列
226- */
227- public void insertStringPreviousCaret(String str) {
228- if (str.equals("")) {
229- return;
230- }
231- rSyntaxTextAreaSql.replaceRange(addIndent(str),
232- rSyntaxTextAreaSql.getSelectionStart(),
233- rSyntaxTextAreaSql.getSelectionEnd());
234-
235- rSyntaxTextAreaSql.requestFocus();
236- }
237-
238- /**
239- * 改行文字があったら、現在行の左端からの位置をインデント文字数として、空白インデント処理する
240- *
241- * @param editot
242- * 挿入文字列
243- * @return インデント挿入後の文字列
244- */
245- private String addIndent(String editor) {
246-
247- // 先頭からのキャレット位置 - 現在行の先頭キャレット位置 で、現在行内でのキャレットオフセットを取得
248- int x = rSyntaxTextAreaSql.getCaretPosition() - rSyntaxTextAreaSql.getLineStartOffsetOfCurrentLine();
249-
250- // indent用に左空白文字列を作成する
251- StringBuilder indent = new StringBuilder();
252- for (int i = 0; i < x; i++) {
253- indent.append(' ');
254- }
255-
256- // indent後の文字列を作成
257- StringBuilder buf = new StringBuilder();
258- for (int i = 0; i < editor.length(); i++) {
259- char c = editor.charAt(i);
260- buf.append(c);
261- if (c == '\n') {
262- // 改行の後にはインデントを挿入する
263- buf.append(indent);
264- }
265- }
266- return buf.toString();
267- }
268-
269- /**
270- * 実行結果を受け取り、ボタンの制御を行う。
271- */
272- private SqlExecuteTask sqlExecuteTask; // @jve:decl-index=0:
273-
274- public void taskWakuUp() {
275- sqlExecuteTask.taskWakeUp();
276- }
277-
278- public void taskCancel() {
279- sqlExecuteTask.taskCancel();
280- }
281-
282- /**
283- *
284- */
285- private TableColumnFit resultsTableColumnFit;
286- /**
287- * 実行を開始したSQL情報
288- */
289- private SqlExecuteSentence sqlExecuteSentenceLast; // @jve:decl-index=0:
290- /**
291- * 例外発生時に処理を継続するか
292- */
293- private boolean exceptionContinue;
294- /*
295- * (非 Javadoc)
296- *
297- * @see
298- * jdbcacsess2.sqlService.SqlExecutedListener#taskAccept(jdbcacsess2.sqlService
299- * .SqlExecuteTask)
300- */
301- @Override
302- public void taskAccept(SqlExecuteTask sqlExecuteTask) {
303- this.sqlExecuteTask = sqlExecuteTask;
304- exceptionContinue = false;
305-
306- SwingUtilities.invokeLater(new Runnable() {
307- public void run() {
308- getJToggleButtonExecution().setEnabled(false);
309- getJToggleButtonExecution().setSelected(true);
310- getJButtonContinue().setEnabled(false);
311- getJToggleButtonConnection().setEnabled(false);
312- }
313- });
314- }
315-
316- /*
317- * (非 Javadoc)
318- *
319- * @see
320- * jdbcacsess2.sqlService.SqlExecutedListener#executBegin(jdbcacsess2.sqlService
321- * .SqlExecuteSentencies.SqlExecuteSentence)
322- */
323- @Override
324- public void executBegin(final SqlExecuteSentence sqlExecuteSentence) {
325- sqlExecuteSentenceLast = sqlExecuteSentence;
326-
327- SwingUtilities.invokeLater(new Runnable() {
328- public void run() {
329-
330- if (sqlExecuteSentence.getSqlCommand().toUpperCase().equals("SELECT")) {
331- // カラム自動調整を有効にする
332- resultsTableColumnFit.setEnableAutoFit(true);
333-
334- getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_DATA);
335- } else {
336- getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
337- }
338-
339- writeGuiLog("\nstart sql\n"
340- + sqlExecuteSentence.getSqlSentence());
341- }
342- });
343- }
344-
345- /*
346- * (非 Javadoc)
347- *
348- * @see jdbcacsess2.sqlService.SqlExecutedListener#executNormalFinish(int)
349- */
350- @Override
351- public void executNormalFinish(final int rowCnt) {
352- // sqlExecuteSentenceLast は、SwingUtilities.invokeLaterの外から
353- // どんどん更新されるので、画面出力に必要な情報はEDTキューイング前に作成しておく
354- final String counrMessage = countmsg();
355-
356- SwingUtilities.invokeLater(new Runnable() {
357- public void run() {
358- getJToggleButtonExecution().setEnabled(true);
359- writeGuiLog("normal end sql" + counrMessage + " "
360- + Integer.toString(rowCnt) + " row " + sqlExecuteTask.getExecutionTime()
361- + "ms");
362- }
363- });
364- }
365-
366- /*
367- * (非 Javadoc)
368- *
369- * @see
370- * jdbcacsess2.sqlService.SqlExecutedListener#executeException(java.lang
371- * .Throwable)
372- */
373- @Override
374- public void executeException(final Throwable t) {
375- // sqlExecuteSentenceLast は、SwingUtilities.invokeLaterの外から
376- // どんどん更新されるので、画面出力に必要な情報はEDTキューイング前に作成しておく
377- final String counrMessage = countmsg();
378-
379- SwingUtilities.invokeLater(new Runnable() {
380- public void run() {
381- getJToggleButtonExecution().setEnabled(true);
382- writeGuiLog("abnormal end " + counrMessage + "\n "
383- + t.getLocalizedMessage());
384- }
385- });
386- ShowDialog.errorMessage(t);
387-
388- int zan = sqlExecuteTask.getCnt() - sqlExecuteSentenceLast.getSentenceCount();
389- if (!exceptionContinue && zan > 0) {
390- try {
391- SwingUtilities.invokeAndWait(new Runnable() {
392- @Override
393- public void run() {
394- Object[] options = { "はい、後続のSQL実行を中断", "いいえ、以降の全エラーを無視" };
395- int n = JOptionPane.showOptionDialog(null,
396- "残りのSQL実行は中断しますか?",
397- "まだ実行予定のSQLが残ってます",
398- JOptionPane.YES_NO_OPTION,
399- JOptionPane.QUESTION_MESSAGE,
400- null,
401- options,
402- options[0]);
403- if (n == JOptionPane.NO_OPTION) {
404- exceptionContinue = true;
405- } else {
406- taskCancel();
407- }
408- }
409- });
410- } catch (InvocationTargetException e) {
411- ShowDialog.errorMessage(e);
412- e.printStackTrace();
413- } catch (InterruptedException e) {
414- Thread.currentThread().interrupt();
415- }
416- }
417- }
418-
419- private String countmsg() {
420- return "[" + sqlExecuteSentenceLast.getSentenceCount() + "/" + sqlExecuteTask.getCnt() + "]";
421- }
422-
423- /*
424- * (非 Javadoc)
425- *
426- * @see
427- * jdbcacsess2.sqlService.SqlExecutedListener#resultHeader(java.util.List)
428- */
429- @Override
430- public void resultHeader(final List<ColumnAttributeResult> header) {
431- final PropertyResultSetTableModel dataModel = new PropertyResultSetTableModel(header);
432- SwingUtilities.invokeLater(new Runnable() {
433- @Override
434- public void run() {
435- getJTableResultSet().setModel(dataModel);
436- }
437- });
438- }
439-
440- /*
441- * (非 Javadoc)
442- *
443- * @see jdbcacsess2.sqlService.SqlExecutedListener#resultDetail(int,
444- * java.util.List)
445- */
446- @Override
447- public void resultDetail(int seq, List<Object> detail) {
448- }
62+ // -------------------------------------------------------------------------
63+ // -------------------------------------------------------------------------
64+ // -------------------------------------------------------------------------
44965
450- /*
451- * (非 Javadoc)
452- *
453- * @see jdbcacsess2.sqlService.SqlExecutedListener#statusContinue(int)
454- */
455- @Override
456- public void statusContinue(final int seqNo) {
457- SwingUtilities.invokeLater(new Runnable() {
458- public void run() {
459- getJToggleButtonExecution().setEnabled(true);
460- getJButtonContinue().setEnabled(true);
461- getJToggleButtonConnection().setEnabled(false);
462-
463- writeGuiLog("data cotinue now " + Integer.toString(seqNo) + " row");
464- }
465- });
466- }
467-
468- /*
469- * (非 Javadoc)
470- *
471- * @see jdbcacsess2.sqlService.SqlExecutedListener#executeAllEnd()
472- */
473- @Override
474- public void executeAllEnd() {
475- SwingUtilities.invokeLater(new Runnable() {
476- public void run() {
477- getJToggleButtonExecution().setEnabled(true);
478- getJToggleButtonExecution().setSelected(false);
479- getJButtonContinue().setEnabled(false);
480- getJToggleButtonConnection().setEnabled(true);
481- }
482- });
483- }
484-
485- // -------------------------------------------------------------------------
486- // -------------------------------------------------------------------------
487- // -------------------------------------------------------------------------
488-
489- private static final long serialVersionUID = 1L;
490- private JSplitPane jSplitPaneTable = null;
491- private RTextScrollPane rTextScrollPaneSql = null;
492- private RSyntaxTextArea rSyntaxTextAreaSql = null;
493- private JTabbedPane jTabbedPaneResult = null;
494- private JScrollPane jScrollPane = null;
495- private JTable jTable = null;
496- private JScrollPane jScrollPaneLog = null;
497- private JTextArea jTextAreaLog = null;
498- private JToolBar jJToolBarBar = null;
499- private JButton jButtonContinue = null;
500- private JCheckBox jCheckBoxAutoCommit = null;
501- private JButton jButtonCommit = null;
502- private JButton jButtonRollback = null;
503-
504- private JToggleButton jToggleButtonExecution = null;
505- private JToggleButton jToggleButtonConnection = null;
506- private JScrollPane jScrollPane1 = null;
507- private JTable jTableResultSet = null;
508- private JComboBox<SentenceSeparator> jComboBoxSentenceSeparator = null;
509-
510- /**
511- * This is the default constructor
512- */
513- public JPanelSql() {
514- super();
515- initialize();
516- }
517-
518- /**
519- * This method initializes this
520- *
521- * @return void
522- */
523- private void initialize() {
524- this.setLayout(new BorderLayout());
525- this.add(getJSplitPaneTable(), java.awt.BorderLayout.CENTER);
526- this.add(getJJToolBarBar(), java.awt.BorderLayout.NORTH);
527- }
528-
529- /**
530- * This method initializes jSplitPaneTable
531- *
532- * @return javax.swing.JSplitPane
533- */
534- JSplitPane getJSplitPaneTable() {
535- if (jSplitPaneTable == null) {
536- jSplitPaneTable = new JSplitPane();
537- jSplitPaneTable.setOrientation(JSplitPane.VERTICAL_SPLIT);
538- jSplitPaneTable.setDividerLocation(200);
539- jSplitPaneTable.setDividerSize(10);
540- jSplitPaneTable.setOneTouchExpandable(true);
541- jSplitPaneTable.setTopComponent(getRTextScrollPaneSql());
542- jSplitPaneTable.setBottomComponent(getJTabbedPaneResult());
543- }
544- return jSplitPaneTable;
545- }
546-
547- /**
548- * This method initializes jScrollPane1
549- *
550- * @return javax.swing.JScrollPane
551- */
552- private RTextScrollPane getRTextScrollPaneSql() {
553- if (rTextScrollPaneSql == null) {
554- rTextScrollPaneSql = new RTextScrollPane();
555- rTextScrollPaneSql.setViewportView(getRSyntaxTextAreaSql());
556- }
557- return rTextScrollPaneSql;
558- }
559-
560- /**
561- * This method initializes jEditorPaneSql
562- *
563- * @return javax.swing.JEditorPane
564- */
565- RSyntaxTextArea getRSyntaxTextAreaSql() {
566- if (rSyntaxTextAreaSql == null) {
567- rSyntaxTextAreaSql = new RSyntaxTextArea();
568- rSyntaxTextAreaSql.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
569- rSyntaxTextAreaSql.setAntiAliasingEnabled(true);
570- }
571- return rSyntaxTextAreaSql;
572- }
573-
574- /**
575- * This method initializes jTabbedPaneResult
576- *
577- * @return javax.swing.JTabbedPane
578- */
579- JTabbedPane getJTabbedPaneResult() {
580- if (jTabbedPaneResult == null) {
581- jTabbedPaneResult = new JTabbedPane();
582- jTabbedPaneResult.setTabPlacement(SwingConstants.LEFT);
583- jTabbedPaneResult.add(getJScrollPane(), "data", TABBEDPANEL_INDEX_DATA);
584- jTabbedPaneResult.add(getJScrollPaneLog(), "log", TABBEDPANEL_INDEX_LOG);
585- jTabbedPaneResult.add(getJScrollPane1(), "RS", TABBEDPANEL_INDEX_RS);
586- }
587- return jTabbedPaneResult;
588- }
589-
590- /**
591- * This method initializes jScrollPane
592- *
593- * @return javax.swing.JScrollPane
594- */
595- private JScrollPane getJScrollPane() {
596- if (jScrollPane == null) {
597- jScrollPane = new JScrollPane();
598- jScrollPane.setViewportView(getJTable());
599- }
600- return jScrollPane;
601- }
602-
603- /**
604- * This method initializes jTable
605- *
606- * @return javax.swing.JTable
607- */
608- JTable getJTable() {
609- if (jTable == null) {
610- jTable = new JTable();
611- jTable.setIntercellSpacing(new Dimension(3, 2));
612- jTable.setAutoCreateRowSorter(true);
613- jTable.setCellSelectionEnabled(true);
614- jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
615- Font font = jTable.getFont();
616- jTable.setFont(new Font(Font.MONOSPACED, font.getStyle(), font.getSize()));
617-
618- new FontZoomByMouseWheel(jTable);
619- resultsTableColumnFit = new TableColumnFit(jTable);
620- jTable.setModel(new ResultsTableModel());
621- }
622- return jTable;
623- }
624-
625- /**
626- * This method initializes jJToolBarBar
627- *
628- * @return javax.swing.JToolBar
629- */
630- private JToolBar getJJToolBarBar() {
631- if (jJToolBarBar == null) {
632- jJToolBarBar = new JToolBar();
633- jJToolBarBar.add(getJToggleButtonExecution());
634- jJToolBarBar.add(getJButtonContinue());
635- jJToolBarBar.add(getJCheckBoxAutoCommit());
636- jJToolBarBar.add(getJButtonCommit());
637- jJToolBarBar.add(getJButtonRollback());
638- jJToolBarBar.add(getJToggleButtonConnection());
639- jJToolBarBar.add(getJComboBoxSentenceSeparator());
640- }
641- return jJToolBarBar;
642- }
66+ final static private int TABBEDPANEL_INDEX_DATA = 0;
67+ final static private int TABBEDPANEL_INDEX_LOG = 1;
68+ final static private int TABBEDPANEL_INDEX_RS = 2;
64369
644- /**
645- * This method initializes jToggleButtonExecution
646- *
647- * @return javax.swing.JButton
648- */
649- JToggleButton getJToggleButtonExecution() {
650- if (jToggleButtonExecution == null) {
651- jToggleButtonExecution = new JToggleButton(IconImage.EXECUTE.getValue(), false);
652- jToggleButtonExecution.setText("Execute");
653- jToggleButtonExecution.setEnabled(false);
654- jToggleButtonExecution.addChangeListener(new ChangeListener() {
655- // pressedicon selectedicon では、うまく制御できないので、自前で制御する
656- @Override
657- public void stateChanged(ChangeEvent e) {
658- JToggleButton b = (JToggleButton) e.getSource();
659- if (b.isSelected()) {
660- b.setIcon(IconImage.STOP.getValue());
661- } else {
662- b.setIcon(IconImage.EXECUTE.getValue());
663- }
664- }
665- });
666- }
667- return jToggleButtonExecution;
668- }
669-
670- /**
671- * This method initializes jButtonContinue
672- *
673- * @return javax.swing.JButton
674- */
675- JButton getJButtonContinue() {
676- if (jButtonContinue == null) {
677- jButtonContinue = new JButton(IconImage.GO_DOWN.getValue());
678- jButtonContinue.setEnabled(false);
679- jButtonContinue.setText("Continue");
680- }
681- return jButtonContinue;
682- }
683-
684- /**
685- * This method initializes jCheckBoxAutoCommit
686- *
687- * @return javax.swing.JCheckBox
688- */
689- JCheckBox getJCheckBoxAutoCommit() {
690- if (jCheckBoxAutoCommit == null) {
691- jCheckBoxAutoCommit = new JCheckBox();
692- jCheckBoxAutoCommit.setText("AutoCommit");
693- jCheckBoxAutoCommit.setEnabled(false);
694- jCheckBoxAutoCommit.addItemListener(new ItemListener() {
695- @Override
696- public void itemStateChanged(ItemEvent e) {
697- boolean flg = jCheckBoxAutoCommit.isSelected();
698- getJButtonCommit().setEnabled(!flg);
699- getJButtonRollback().setEnabled(!flg);
700- Jdbcacsess2.logger.fine("autocomit:" + flg);
701-
702- if (getDataBaseConnection() == null) {
703- return;
704- }
705- try {
706- getDataBaseConnection().setAutoCommit(flg);
707- } catch (Exception ex) {
708- ShowDialog.errorMessage(ex);
709- }
710- }
711- });
712- jCheckBoxAutoCommit.setSelected(true);
713- }
714- return jCheckBoxAutoCommit;
715- }
716-
717- /**
718- * This method initializes jButtonCommit
719- *
720- * @return javax.swing.JButton
721- */
722- JButton getJButtonCommit() {
723- if (jButtonCommit == null) {
724- jButtonCommit = new JButton(IconImage.COMMIT.getValue());
725- jButtonCommit.setText("Commit");
726- jButtonCommit.setEnabled(false);
727- }
728- return jButtonCommit;
729- }
730-
731- /**
732- * This method initializes jButtonRollback
733- *
734- * @return javax.swing.JButton
735- */
736- JButton getJButtonRollback() {
737- if (jButtonRollback == null) {
738- jButtonRollback = new JButton(IconImage.ROLLBACK.getValue());
739- jButtonRollback.setText("Rollback");
740- jButtonRollback.setEnabled(false);
741- }
742- return jButtonRollback;
743- }
70+ private DataBaseConnection dataBaseConnection; // @jve:decl-index=0:
74471
745- /**
746- * This method initializes jScrollPaneLog
747- *
748- * @return javax.swing.JScrollPane
749- */
750- private JScrollPane getJScrollPaneLog() {
751- if (jScrollPaneLog == null) {
752- jScrollPaneLog = new JScrollPane();
753- jScrollPaneLog.setViewportView(getJTextAreaLog());
754- }
755- return jScrollPaneLog;
756- }
757-
758- /**
759- * This method initializes jTextAreaLog
760- *
761- * @return javax.swing.JTextArea
762- */
763- JTextArea getJTextAreaLog() {
764- if (jTextAreaLog == null) {
765- jTextAreaLog = new JTextArea();
766- jTextAreaLog.setEditable(false);
767- jTextAreaLog.setLineWrap(false);
768- jTextAreaLog.setOpaque(false);
769- }
770- return jTextAreaLog;
771- }
772-
773- /**
774- * This method initializes jToggleButtonConnection
775- *
776- * @return javax.swing.JToggleButton
777- */
778- JToggleButton getJToggleButtonConnection() {
779- if (jToggleButtonConnection == null) {
780- jToggleButtonConnection = new JToggleButton(IconImage.DISCONNECT.getValue());
781- jToggleButtonConnection.setText("session");
782- jToggleButtonConnection.addChangeListener(new ChangeListener() {
783- // pressedicon selectedicon では、うまく制御できないので、自前で制御する
784- @Override
785- public void stateChanged(ChangeEvent e) {
786- JToggleButton b = (JToggleButton) e.getSource();
787- if (b.isSelected()) {
788- b.setIcon(IconImage.CONNECT.getValue());
789- } else {
790- b.setIcon(IconImage.DISCONNECT.getValue());
791- }
792- }
793- });
794- }
795- return jToggleButtonConnection;
796- }
72+ /*
73+ * (非 Javadoc)
74+ *
75+ * @see
76+ * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionOpened
77+ * (jdbcacsess2.sqlService.DataBaseConnection)
78+ */
79+ @Override
80+ public void dataBaseConnectionOpened(DataBaseConnection dataBaseConnection) {
81+ this.dataBaseConnection = dataBaseConnection;
79782
798- /**
799- * This method initializes jScrollPane1
800- *
801- * @return javax.swing.JScrollPane
802- */
803- private JScrollPane getJScrollPane1() {
804- if (jScrollPane1 == null) {
805- jScrollPane1 = new JScrollPane();
806- jScrollPane1.setViewportView(getJTableResultSet());
807- }
808- return jScrollPane1;
809- }
810-
811- /**
812- * This method initializes jTableResultSet
813- *
814- * @return javax.swing.JTable
815- */
816- private JTable getJTableResultSet() {
817- if (jTableResultSet == null) {
818- jTableResultSet = new JmyTable();
819- }
820- return jTableResultSet;
821- }
83+ SwingUtilities.invokeLater(new Runnable() {
84+ @Override
85+ public void run() {
86+ writeGuiLog("connection opened");
82287
823- /**
824- * This method initializes jComboBoxSentenceSeparator
825- *
826- * @return javax.swing.JComboBox
827- */
828- JComboBox<SentenceSeparator> getJComboBoxSentenceSeparator() {
829- if (jComboBoxSentenceSeparator == null) {
830- jComboBoxSentenceSeparator = new JComboBox<SentenceSeparator>();
831- jComboBoxSentenceSeparator.setEditable(true);
832- jComboBoxSentenceSeparator.addItem(new SentenceSeparator(";", ";\\s*\\n?"));
833- jComboBoxSentenceSeparator.addItem(new SentenceSeparator("/", "\\n+\\s*/\\s*\\n?"));
834- jComboBoxSentenceSeparator.addItem(new SentenceSeparator("//", "\\n+?\\s*//\\s*\\n?"));
835- jComboBoxSentenceSeparator.addItem(new SentenceSeparator("GO", "\\n+\\s*[Gg][Oo]\\s*\\n?"));
836- }
837- return jComboBoxSentenceSeparator;
838- }
88+ // dbコネクションの autocommit を、画面設定から取得して設定する。
89+ boolean flg = getJCheckBoxAutoCommit().isSelected();
90+ try {
91+ getDataBaseConnection().setAutoCommit(flg);
83992
840- public static class SentenceSeparator {
841- private final String guiVal;
842- private final String regVal;
843-
844- SentenceSeparator(String guiVal, String regVal) {
845- this.guiVal = guiVal;
846- this.regVal = regVal;
847- }
93+ getJToggleButtonExecution().setEnabled(true);
94+ getJButtonContinue().setEnabled(false);
95+ getJCheckBoxAutoCommit().setEnabled(true);
96+ getJToggleButtonConnection().setSelected(true);
97+ } catch (Exception e) {
98+ ShowDialog.errorMessage(e);
99+ }
100+ }
101+ });
848102
849- @Override
850- public String toString() {
851- return guiVal;
852- }
103+ }
853104
854- /**
855- * @return regVal
856- */
857- public String getRegVal() {
858- return regVal;
859- }
860- }
105+ /*
106+ * (非 Javadoc)
107+ *
108+ * @see
109+ * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionClosing
110+ * ()
111+ */
112+ @Override
113+ public void dataBaseConnectionClosing(DataBaseConnection dataBaseConnection) {
114+ SwingUtilities.invokeLater(new Runnable() {
115+ @Override
116+ public void run() {
117+ getJToggleButtonExecution().setEnabled(false);
118+ getJButtonContinue().setEnabled(false);
119+ getJCheckBoxAutoCommit().setEnabled(false);
120+ getJButtonCommit().setEnabled(false);
121+ getJButtonRollback().setEnabled(false);
122+ getJToggleButtonConnection().setSelected(false);
123+ }
124+ });
125+ }
126+
127+ /*
128+ * (非 Javadoc)
129+ *
130+ * @see
131+ * jdbcacsess2.sqlService.DataBaseConnectionListener#dataBaseConnectionClosed
132+ * ()
133+ */
134+ @Override
135+ public void dataBaseConnectionClosed(DataBaseConnection dataBaseConnection) {
136+ SwingUtilities.invokeLater(new Runnable() {
137+ @Override
138+ public void run() {
139+ writeGuiLog("connection closed");
140+ }
141+ });
142+ }
143+
144+ /**
145+ * @return dataBaseConnection
146+ */
147+ DataBaseConnection getDataBaseConnection() {
148+ return dataBaseConnection;
149+ }
150+
151+ /*
152+ * (非 Javadoc)
153+ *
154+ * @see
155+ * jdbcacsess2.sqlService.DataBaseTransactionListener#autoCommitChange(boolean
156+ * )
157+ */
158+ @Override
159+ public void autoCommitChange(DataBaseConnection dataBaseConnection, final boolean autoCommit) {
160+ SwingUtilities.invokeLater(new Runnable() {
161+ @Override
162+ public void run() {
163+ writeGuiLog("autocommit[" + autoCommit + "]");
164+ }
165+ });
166+ }
167+
168+ /*
169+ * (非 Javadoc)
170+ *
171+ * @see jdbcacsess2.sqlService.DataBaseTransactionListener#commitEnd()
172+ */
173+ @Override
174+ public void commitEnd(DataBaseConnection dataBaseConnection) {
175+ SwingUtilities.invokeLater(new Runnable() {
176+ @Override
177+ public void run() {
178+ getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
179+ writeGuiLog("commit end");
180+ }
181+ });
182+ }
183+
184+ /*
185+ * (非 Javadoc)
186+ *
187+ * @see jdbcacsess2.sqlService.DataBaseTransactionListener#rollbackEnd()
188+ */
189+ @Override
190+ public void rollbackEnd(DataBaseConnection dataBaseConnection) {
191+ SwingUtilities.invokeLater(new Runnable() {
192+ @Override
193+ public void run() {
194+ getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
195+ writeGuiLog("rollback end");
196+ }
197+ });
198+ }
199+
200+ /**
201+ * SQLパネルログへ出力
202+ *
203+ * @param message
204+ * 出力文字列
205+ */
206+ private void writeGuiLog(String message) {
207+ int i;
208+ for (i = message.length(); 0 < i; i--) {
209+ String s = message.substring(i - 1, i);
210+ if (!s.equals("\n")) {
211+ break;
212+ }
213+ }
214+
215+ getJTextAreaLog().append(message.substring(0, i));
216+ getJTextAreaLog().append("\n");
217+ getJTextAreaLog().setCaretPosition(getJTextAreaLog().getText().length());
218+ }
219+
220+ //
221+ /**
222+ * 文字列を挿入します。改行文字が含まれている場合、インデントされます。
223+ *
224+ * @param str
225+ * 挿入したい文字列
226+ */
227+ public void insertStringPreviousCaret(String str) {
228+ if (str.equals("")) {
229+ return;
230+ }
231+ rSyntaxTextAreaSql.replaceRange(addIndent(str),
232+ rSyntaxTextAreaSql.getSelectionStart(),
233+ rSyntaxTextAreaSql.getSelectionEnd());
234+
235+ rSyntaxTextAreaSql.requestFocus();
236+ }
237+
238+ /**
239+ * 改行文字があったら、現在行の左端からの位置をインデント文字数として、空白インデント処理する
240+ *
241+ * @param editot
242+ * 挿入文字列
243+ * @return インデント挿入後の文字列
244+ */
245+ private String addIndent(String editor) {
246+
247+ // 先頭からのキャレット位置 - 現在行の先頭キャレット位置 で、現在行内でのキャレットオフセットを取得
248+ int x = rSyntaxTextAreaSql.getCaretPosition() - rSyntaxTextAreaSql.getLineStartOffsetOfCurrentLine();
249+
250+ // indent用に左空白文字列を作成する
251+ StringBuilder indent = new StringBuilder();
252+ for (int i = 0; i < x; i++) {
253+ indent.append(' ');
254+ }
255+
256+ // indent後の文字列を作成
257+ StringBuilder buf = new StringBuilder();
258+ for (int i = 0; i < editor.length(); i++) {
259+ char c = editor.charAt(i);
260+ buf.append(c);
261+ if (c == '\n') {
262+ // 改行の後にはインデントを挿入する
263+ buf.append(indent);
264+ }
265+ }
266+ return buf.toString();
267+ }
268+
269+ /**
270+ * 実行結果を受け取り、ボタンの制御を行う。
271+ */
272+ private SqlExecuteTask sqlExecuteTask; // @jve:decl-index=0:
273+
274+ public void taskWakuUp() {
275+ sqlExecuteTask.taskWakeUp();
276+ }
277+
278+ public void taskCancel() {
279+ sqlExecuteTask.taskCancel();
280+ }
281+
282+ /**
283+ *
284+ */
285+ private TableColumnFit resultsTableColumnFit;
286+ /**
287+ * 実行を開始したSQL情報
288+ */
289+ private SqlExecuteSentence sqlExecuteSentenceLast; // @jve:decl-index=0:
290+ /**
291+ * 例外発生時に処理を継続するか
292+ */
293+ private boolean exceptionContinue;
294+ /*
295+ * (非 Javadoc)
296+ *
297+ * @see
298+ * jdbcacsess2.sqlService.SqlExecutedListener#taskAccept(jdbcacsess2.sqlService
299+ * .SqlExecuteTask)
300+ */
301+ @Override
302+ public void taskAccept(SqlExecuteTask sqlExecuteTask) {
303+ this.sqlExecuteTask = sqlExecuteTask;
304+ exceptionContinue = false;
305+
306+ SwingUtilities.invokeLater(new Runnable() {
307+ public void run() {
308+ getJToggleButtonExecution().setEnabled(false);
309+ getJToggleButtonExecution().setSelected(true);
310+ getJButtonContinue().setEnabled(false);
311+ getJToggleButtonConnection().setEnabled(false);
312+ }
313+ });
314+ }
315+
316+ /*
317+ * (非 Javadoc)
318+ *
319+ * @see
320+ * jdbcacsess2.sqlService.SqlExecutedListener#executBegin(jdbcacsess2.sqlService
321+ * .SqlExecuteSentencies.SqlExecuteSentence)
322+ */
323+ @Override
324+ public void executBegin(final SqlExecuteSentence sqlExecuteSentence) {
325+ sqlExecuteSentenceLast = sqlExecuteSentence;
326+
327+ SwingUtilities.invokeLater(new Runnable() {
328+ public void run() {
329+
330+ if (sqlExecuteSentence.getSqlCommand().toUpperCase().equals("SELECT")) {
331+ // カラム自動調整を有効にする
332+ resultsTableColumnFit.setEnableAutoFit(true);
333+
334+ getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_DATA);
335+ } else {
336+ getJTabbedPaneResult().setSelectedIndex(TABBEDPANEL_INDEX_LOG);
337+ }
338+
339+ writeGuiLog("\nstart sql\n"
340+ + sqlExecuteSentence.getSqlSentence());
341+ }
342+ });
343+ }
344+
345+ /*
346+ * (非 Javadoc)
347+ *
348+ * @see jdbcacsess2.sqlService.SqlExecutedListener#executNormalFinish(int)
349+ */
350+ @Override
351+ public void executNormalFinish(final int rowCnt) {
352+ // sqlExecuteSentenceLast は、SwingUtilities.invokeLaterの外から
353+ // どんどん更新されるので、画面出力に必要な情報はEDTキューイング前に作成しておく
354+ final String counrMessage = countmsg();
355+
356+ SwingUtilities.invokeLater(new Runnable() {
357+ public void run() {
358+ getJToggleButtonExecution().setEnabled(true);
359+ writeGuiLog("normal end sql" + counrMessage + " "
360+ + Integer.toString(rowCnt) + " row " + sqlExecuteTask.getExecutionTime()
361+ + "ms");
362+ }
363+ });
364+ }
365+
366+ /*
367+ * (非 Javadoc)
368+ *
369+ * @see
370+ * jdbcacsess2.sqlService.SqlExecutedListener#executeException(java.lang
371+ * .Throwable)
372+ */
373+ @Override
374+ public void executeException(final Throwable t) {
375+ // sqlExecuteSentenceLast は、SwingUtilities.invokeLaterの外から
376+ // どんどん更新されるので、画面出力に必要な情報はEDTキューイング前に作成しておく
377+ final String counrMessage = countmsg();
378+
379+ SwingUtilities.invokeLater(new Runnable() {
380+ public void run() {
381+ getJToggleButtonExecution().setEnabled(true);
382+ writeGuiLog("abnormal end " + counrMessage + "\n "
383+ + t.getLocalizedMessage());
384+ }
385+ });
386+ ShowDialog.errorMessage(t);
387+
388+ int zan = sqlExecuteTask.getCnt() - sqlExecuteSentenceLast.getSentenceCount();
389+ if (!exceptionContinue && zan > 0) {
390+ try {
391+ SwingUtilities.invokeAndWait(new Runnable() {
392+ @Override
393+ public void run() {
394+ Object[] options = { "はい、後続のSQL実行を中断", "いいえ、以降の全エラーを無視" };
395+ int n = JOptionPane.showOptionDialog(null,
396+ "残りのSQL実行は中断しますか?",
397+ "まだ実行予定のSQLが残ってます",
398+ JOptionPane.YES_NO_OPTION,
399+ JOptionPane.QUESTION_MESSAGE,
400+ null,
401+ options,
402+ options[0]);
403+ if (n == JOptionPane.NO_OPTION) {
404+ exceptionContinue = true;
405+ } else {
406+ taskCancel();
407+ }
408+ }
409+ });
410+ } catch (InvocationTargetException e) {
411+ ShowDialog.errorMessage(e);
412+ e.printStackTrace();
413+ } catch (InterruptedException e) {
414+ Thread.currentThread().interrupt();
415+ }
416+ }
417+ }
418+
419+ private String countmsg() {
420+ return "[" + sqlExecuteSentenceLast.getSentenceCount() + "/" + sqlExecuteTask.getCnt() + "]";
421+ }
422+
423+ /*
424+ * (非 Javadoc)
425+ *
426+ * @see
427+ * jdbcacsess2.sqlService.SqlExecutedListener#resultHeader(java.util.List)
428+ */
429+ @Override
430+ public void resultHeader(final List<ColumnAttributeResult> header) {
431+ final PropertyResultSetTableModel dataModel = new PropertyResultSetTableModel(header);
432+ SwingUtilities.invokeLater(new Runnable() {
433+ @Override
434+ public void run() {
435+ getJTableResultSet().setModel(dataModel);
436+ }
437+ });
438+ }
439+
440+ /*
441+ * (非 Javadoc)
442+ *
443+ * @see jdbcacsess2.sqlService.SqlExecutedListener#resultDetail(int,
444+ * java.util.List)
445+ */
446+ @Override
447+ public void resultDetail(int seq, List<Object> detail) {
448+ }
449+
450+ /*
451+ * (非 Javadoc)
452+ *
453+ * @see jdbcacsess2.sqlService.SqlExecutedListener#statusContinue(int)
454+ */
455+ @Override
456+ public void statusContinue(final int seqNo) {
457+ SwingUtilities.invokeLater(new Runnable() {
458+ public void run() {
459+ getJToggleButtonExecution().setEnabled(true);
460+ getJButtonContinue().setEnabled(true);
461+ getJToggleButtonConnection().setEnabled(false);
462+
463+ writeGuiLog("data cotinue now " + Integer.toString(seqNo) + " row");
464+ }
465+ });
466+ }
467+
468+ /*
469+ * (非 Javadoc)
470+ *
471+ * @see jdbcacsess2.sqlService.SqlExecutedListener#executeAllEnd()
472+ */
473+ @Override
474+ public void executeAllEnd() {
475+ SwingUtilities.invokeLater(new Runnable() {
476+ public void run() {
477+ getJToggleButtonExecution().setEnabled(true);
478+ getJToggleButtonExecution().setSelected(false);
479+ getJButtonContinue().setEnabled(false);
480+ getJToggleButtonConnection().setEnabled(true);
481+ }
482+ });
483+ }
484+
485+ // -------------------------------------------------------------------------
486+ // -------------------------------------------------------------------------
487+ // -------------------------------------------------------------------------
488+
489+ private static final long serialVersionUID = 1L;
490+ private JSplitPane jSplitPaneTable = null;
491+ private RTextScrollPane rTextScrollPaneSql = null;
492+ private RSyntaxTextArea rSyntaxTextAreaSql = null;
493+ private JTabbedPane jTabbedPaneResult = null;
494+ private JScrollPane jScrollPane = null;
495+ private JTable jTable = null;
496+ private JScrollPane jScrollPaneLog = null;
497+ private JTextArea jTextAreaLog = null;
498+ private JToolBar jJToolBarBar = null;
499+ private JButton jButtonContinue = null;
500+ private JCheckBox jCheckBoxAutoCommit = null;
501+ private JButton jButtonCommit = null;
502+ private JButton jButtonRollback = null;
503+
504+ private JToggleButton jToggleButtonExecution = null;
505+ private JToggleButton jToggleButtonConnection = null;
506+ private JScrollPane jScrollPane1 = null;
507+ private JTable jTableResultSet = null;
508+ private JComboBox<SentenceSeparator> jComboBoxSentenceSeparator = null;
509+
510+ /**
511+ * This is the default constructor
512+ */
513+ public JPanelSql() {
514+ super();
515+ initialize();
516+ }
517+
518+ /**
519+ * This method initializes this
520+ *
521+ * @return void
522+ */
523+ private void initialize() {
524+ this.setLayout(new BorderLayout());
525+ this.add(getJSplitPaneTable(), java.awt.BorderLayout.CENTER);
526+ this.add(getJJToolBarBar(), java.awt.BorderLayout.NORTH);
527+ }
528+
529+ /**
530+ * This method initializes jSplitPaneTable
531+ *
532+ * @return javax.swing.JSplitPane
533+ */
534+ JSplitPane getJSplitPaneTable() {
535+ if (jSplitPaneTable == null) {
536+ jSplitPaneTable = new JSplitPane();
537+ jSplitPaneTable.setOrientation(JSplitPane.VERTICAL_SPLIT);
538+ jSplitPaneTable.setDividerLocation(200);
539+ jSplitPaneTable.setDividerSize(10);
540+ jSplitPaneTable.setOneTouchExpandable(true);
541+ jSplitPaneTable.setTopComponent(getRTextScrollPaneSql());
542+ jSplitPaneTable.setBottomComponent(getJTabbedPaneResult());
543+ }
544+ return jSplitPaneTable;
545+ }
546+
547+ /**
548+ * This method initializes jScrollPane1
549+ *
550+ * @return javax.swing.JScrollPane
551+ */
552+ private RTextScrollPane getRTextScrollPaneSql() {
553+ if (rTextScrollPaneSql == null) {
554+ rTextScrollPaneSql = new RTextScrollPane();
555+ rTextScrollPaneSql.setViewportView(getRSyntaxTextAreaSql());
556+ }
557+ return rTextScrollPaneSql;
558+ }
559+
560+ /**
561+ * This method initializes jEditorPaneSql
562+ *
563+ * @return javax.swing.JEditorPane
564+ */
565+ RSyntaxTextArea getRSyntaxTextAreaSql() {
566+ if (rSyntaxTextAreaSql == null) {
567+ rSyntaxTextAreaSql = new RSyntaxTextArea();
568+ rSyntaxTextAreaSql.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
569+ rSyntaxTextAreaSql.setAntiAliasingEnabled(true);
570+ new FontZoomByMouseWheel(rSyntaxTextAreaSql);
571+ }
572+ return rSyntaxTextAreaSql;
573+ }
574+
575+ /**
576+ * This method initializes jTabbedPaneResult
577+ *
578+ * @return javax.swing.JTabbedPane
579+ */
580+ JTabbedPane getJTabbedPaneResult() {
581+ if (jTabbedPaneResult == null) {
582+ jTabbedPaneResult = new JTabbedPane();
583+ jTabbedPaneResult.setTabPlacement(SwingConstants.LEFT);
584+ jTabbedPaneResult.add(getJScrollPane(), "data", TABBEDPANEL_INDEX_DATA);
585+ jTabbedPaneResult.add(getJScrollPaneLog(), "log", TABBEDPANEL_INDEX_LOG);
586+ jTabbedPaneResult.add(getJScrollPane1(), "RS", TABBEDPANEL_INDEX_RS);
587+ }
588+ return jTabbedPaneResult;
589+ }
590+
591+ /**
592+ * This method initializes jScrollPane
593+ *
594+ * @return javax.swing.JScrollPane
595+ */
596+ private JScrollPane getJScrollPane() {
597+ if (jScrollPane == null) {
598+ jScrollPane = new JScrollPane();
599+ jScrollPane.setViewportView(getJTable());
600+ }
601+ return jScrollPane;
602+ }
603+
604+ /**
605+ * This method initializes jTable
606+ *
607+ * @return javax.swing.JTable
608+ */
609+ JTable getJTable() {
610+ if (jTable == null) {
611+ jTable = new JTable();
612+ jTable.setIntercellSpacing(new Dimension(3, 2));
613+ jTable.setAutoCreateRowSorter(true);
614+ jTable.setCellSelectionEnabled(true);
615+ jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
616+ Font font = jTable.getFont();
617+ jTable.setFont(new Font(Font.MONOSPACED, font.getStyle(), font.getSize()));
618+
619+ new FontZoomByMouseWheel(jTable);
620+ resultsTableColumnFit = new TableColumnFit(jTable);
621+ jTable.setModel(new ResultsTableModel());
622+ }
623+ return jTable;
624+ }
625+
626+ /**
627+ * This method initializes jJToolBarBar
628+ *
629+ * @return javax.swing.JToolBar
630+ */
631+ private JToolBar getJJToolBarBar() {
632+ if (jJToolBarBar == null) {
633+ jJToolBarBar = new JToolBar();
634+ jJToolBarBar.add(getJToggleButtonExecution());
635+ jJToolBarBar.add(getJButtonContinue());
636+ jJToolBarBar.add(getJCheckBoxAutoCommit());
637+ jJToolBarBar.add(getJButtonCommit());
638+ jJToolBarBar.add(getJButtonRollback());
639+ jJToolBarBar.add(getJToggleButtonConnection());
640+ jJToolBarBar.add(getJComboBoxSentenceSeparator());
641+ }
642+ return jJToolBarBar;
643+ }
644+
645+ /**
646+ * This method initializes jToggleButtonExecution
647+ *
648+ * @return javax.swing.JButton
649+ */
650+ JToggleButton getJToggleButtonExecution() {
651+ if (jToggleButtonExecution == null) {
652+ jToggleButtonExecution = new JToggleButton(IconImage.EXECUTE.getValue(), false);
653+ jToggleButtonExecution.setText("Execute");
654+ jToggleButtonExecution.setEnabled(false);
655+ jToggleButtonExecution.addChangeListener(new ChangeListener() {
656+ // pressedicon selectedicon では、うまく制御できないので、自前で制御する
657+ @Override
658+ public void stateChanged(ChangeEvent e) {
659+ JToggleButton b = (JToggleButton) e.getSource();
660+ if (b.isSelected()) {
661+ b.setIcon(IconImage.STOP.getValue());
662+ } else {
663+ b.setIcon(IconImage.EXECUTE.getValue());
664+ }
665+ }
666+ });
667+ }
668+ return jToggleButtonExecution;
669+ }
670+
671+ /**
672+ * This method initializes jButtonContinue
673+ *
674+ * @return javax.swing.JButton
675+ */
676+ JButton getJButtonContinue() {
677+ if (jButtonContinue == null) {
678+ jButtonContinue = new JButton(IconImage.GO_DOWN.getValue());
679+ jButtonContinue.setEnabled(false);
680+ jButtonContinue.setText("Continue");
681+ }
682+ return jButtonContinue;
683+ }
684+
685+ /**
686+ * This method initializes jCheckBoxAutoCommit
687+ *
688+ * @return javax.swing.JCheckBox
689+ */
690+ JCheckBox getJCheckBoxAutoCommit() {
691+ if (jCheckBoxAutoCommit == null) {
692+ jCheckBoxAutoCommit = new JCheckBox();
693+ jCheckBoxAutoCommit.setText("AutoCommit");
694+ jCheckBoxAutoCommit.setEnabled(false);
695+ jCheckBoxAutoCommit.addItemListener(new ItemListener() {
696+ @Override
697+ public void itemStateChanged(ItemEvent e) {
698+ boolean flg = jCheckBoxAutoCommit.isSelected();
699+ getJButtonCommit().setEnabled(!flg);
700+ getJButtonRollback().setEnabled(!flg);
701+ Jdbcacsess2.logger.fine("autocomit:" + flg);
702+
703+ if (getDataBaseConnection() == null) {
704+ return;
705+ }
706+ try {
707+ getDataBaseConnection().setAutoCommit(flg);
708+ } catch (Exception ex) {
709+ ShowDialog.errorMessage(ex);
710+ }
711+ }
712+ });
713+ jCheckBoxAutoCommit.setSelected(true);
714+ }
715+ return jCheckBoxAutoCommit;
716+ }
717+
718+ /**
719+ * This method initializes jButtonCommit
720+ *
721+ * @return javax.swing.JButton
722+ */
723+ JButton getJButtonCommit() {
724+ if (jButtonCommit == null) {
725+ jButtonCommit = new JButton(IconImage.COMMIT.getValue());
726+ jButtonCommit.setText("Commit");
727+ jButtonCommit.setEnabled(false);
728+ }
729+ return jButtonCommit;
730+ }
731+
732+ /**
733+ * This method initializes jButtonRollback
734+ *
735+ * @return javax.swing.JButton
736+ */
737+ JButton getJButtonRollback() {
738+ if (jButtonRollback == null) {
739+ jButtonRollback = new JButton(IconImage.ROLLBACK.getValue());
740+ jButtonRollback.setText("Rollback");
741+ jButtonRollback.setEnabled(false);
742+ }
743+ return jButtonRollback;
744+ }
745+
746+ /**
747+ * This method initializes jScrollPaneLog
748+ *
749+ * @return javax.swing.JScrollPane
750+ */
751+ private JScrollPane getJScrollPaneLog() {
752+ if (jScrollPaneLog == null) {
753+ jScrollPaneLog = new JScrollPane();
754+ jScrollPaneLog.setViewportView(getJTextAreaLog());
755+ }
756+ return jScrollPaneLog;
757+ }
758+
759+ /**
760+ * This method initializes jTextAreaLog
761+ *
762+ * @return javax.swing.JTextArea
763+ */
764+ JTextArea getJTextAreaLog() {
765+ if (jTextAreaLog == null) {
766+ jTextAreaLog = new JTextArea();
767+ jTextAreaLog.setEditable(false);
768+ jTextAreaLog.setLineWrap(false);
769+ jTextAreaLog.setOpaque(false);
770+ }
771+ return jTextAreaLog;
772+ }
773+
774+ /**
775+ * This method initializes jToggleButtonConnection
776+ *
777+ * @return javax.swing.JToggleButton
778+ */
779+ JToggleButton getJToggleButtonConnection() {
780+ if (jToggleButtonConnection == null) {
781+ jToggleButtonConnection = new JToggleButton(IconImage.DISCONNECT.getValue());
782+ jToggleButtonConnection.setText("session");
783+ jToggleButtonConnection.addChangeListener(new ChangeListener() {
784+ // pressedicon selectedicon では、うまく制御できないので、自前で制御する
785+ @Override
786+ public void stateChanged(ChangeEvent e) {
787+ JToggleButton b = (JToggleButton) e.getSource();
788+ if (b.isSelected()) {
789+ b.setIcon(IconImage.CONNECT.getValue());
790+ } else {
791+ b.setIcon(IconImage.DISCONNECT.getValue());
792+ }
793+ }
794+ });
795+ }
796+ return jToggleButtonConnection;
797+ }
798+
799+ /**
800+ * This method initializes jScrollPane1
801+ *
802+ * @return javax.swing.JScrollPane
803+ */
804+ private JScrollPane getJScrollPane1() {
805+ if (jScrollPane1 == null) {
806+ jScrollPane1 = new JScrollPane();
807+ jScrollPane1.setViewportView(getJTableResultSet());
808+ }
809+ return jScrollPane1;
810+ }
811+
812+ /**
813+ * This method initializes jTableResultSet
814+ *
815+ * @return javax.swing.JTable
816+ */
817+ private JTable getJTableResultSet() {
818+ if (jTableResultSet == null) {
819+ jTableResultSet = new JmyTable();
820+ }
821+ return jTableResultSet;
822+ }
823+
824+ /**
825+ * This method initializes jComboBoxSentenceSeparator
826+ *
827+ * @return javax.swing.JComboBox
828+ */
829+ JComboBox<SentenceSeparator> getJComboBoxSentenceSeparator() {
830+ if (jComboBoxSentenceSeparator == null) {
831+ jComboBoxSentenceSeparator = new JComboBox<SentenceSeparator>();
832+ jComboBoxSentenceSeparator.setEditable(true);
833+ jComboBoxSentenceSeparator.addItem(new SentenceSeparator(";", ";\\s*\\n?"));
834+ jComboBoxSentenceSeparator.addItem(new SentenceSeparator("/", "\\n+\\s*/\\s*\\n?"));
835+ jComboBoxSentenceSeparator.addItem(new SentenceSeparator("//", "\\n+?\\s*//\\s*\\n?"));
836+ jComboBoxSentenceSeparator.addItem(new SentenceSeparator("GO", "\\n+\\s*[Gg][Oo]\\s*\\n?"));
837+ }
838+ return jComboBoxSentenceSeparator;
839+ }
840+
841+ public static class SentenceSeparator {
842+ private final String guiVal;
843+ private final String regVal;
844+
845+ SentenceSeparator(String guiVal, String regVal) {
846+ this.guiVal = guiVal;
847+ this.regVal = regVal;
848+ }
849+
850+ @Override
851+ public String toString() {
852+ return guiVal;
853+ }
854+
855+ /**
856+ * @return regVal
857+ */
858+ public String getRegVal() {
859+ return regVal;
860+ }
861+ }
861862 }
diff -r b6558ad47c50 -r e366c0f78aa8 src/jdbcacsess2/main/TableColumnFit.java
--- a/src/jdbcacsess2/main/TableColumnFit.java Sun Mar 04 12:13:41 2012 +0900
+++ b/src/jdbcacsess2/main/TableColumnFit.java Sun Mar 04 12:45:48 2012 +0900
@@ -267,8 +267,6 @@
267267 */
268268 @Override
269269 public void propertyChange(PropertyChangeEvent evt) {
270- Jdbcacsess2.logger.fine(evt.getPropertyName());
271-
272270 setPreferredWidthFromHeader();
273271 for (int row = 0; row < jTable.getModel().getRowCount(); row++) {
274272 setPreferredWidthFromRoW(row);
Show on old repository browser