• R/O
  • SSH

JdbcAcsess2: Commit

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


Commit MetaInfo

Revision28c38ec4338b06dff5fe1aa3d56b0e94289aaa58 (tree)
Time2012-05-04 00:21:18
Authorshimakazuro
Commitershimakazuro

Log Message

いろいろ

Change Summary

Incremental Difference

diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/main/Config.java
--- a/src/jdbcacsess2/main/Config.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/main/Config.java Fri May 04 00:21:18 2012 +0900
@@ -124,7 +124,7 @@
124124
125125 this.entityManager = new EntityManager(CONFIG_JDBCURL, USER, PASS);
126126 Jdbcacsess2.loggerActiveObjects.setLevel(Level.WARNING);
127- // Jdbcacsess2.loggerActiveObjects.setLevel(Level.FINE);
127+ Jdbcacsess2.loggerActiveObjects.setLevel(Level.FINE);
128128
129129 migrate();
130130 Jdbcacsess2.logger.info("Migrate end");
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/main/JPanelSql.java
--- a/src/jdbcacsess2/main/JPanelSql.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/main/JPanelSql.java Fri May 04 00:21:18 2012 +0900
@@ -16,6 +16,8 @@
1616 package jdbcacsess2.main;
1717
1818 import java.awt.BorderLayout;
19+import java.awt.Color;
20+import java.awt.Component;
1921 import java.awt.Dimension;
2022 import java.awt.Font;
2123 import java.awt.event.ItemEvent;
@@ -26,6 +28,7 @@
2628 import javax.swing.JButton;
2729 import javax.swing.JCheckBox;
2830 import javax.swing.JComboBox;
31+import javax.swing.JLabel;
2932 import javax.swing.JOptionPane;
3033 import javax.swing.JPanel;
3134 import javax.swing.JScrollPane;
@@ -40,6 +43,7 @@
4043 import javax.swing.SwingUtilities;
4144 import javax.swing.event.ChangeEvent;
4245 import javax.swing.event.ChangeListener;
46+import javax.swing.table.DefaultTableCellRenderer;
4347
4448 import jdbcacsess2.main.icon.IconImage;
4549 import jdbcacsess2.sqlService.ColumnAttributeResult;
@@ -47,6 +51,7 @@
4751 import jdbcacsess2.sqlService.DataBaseConnectionListener;
4852 import jdbcacsess2.sqlService.DataBaseTransactionListener;
4953 import jdbcacsess2.sqlService.PropertyResultSetTableModel;
54+import jdbcacsess2.sqlService.Result;
5055 import jdbcacsess2.sqlService.ResultsTableModel;
5156 import jdbcacsess2.sqlService.SqlExecuteTask;
5257 import jdbcacsess2.sqlService.SqlExecutedListener;
@@ -381,7 +386,7 @@
381386 @Override
382387 public void run() {
383388 Object[] options = {
384- "はい、後続のSQL実行を中断", "いいえ、以降の全エラーを無視"
389+ "はい、後続のSQL実行を中断", "いいえ、以降の全エラーを無視"
385390 };
386391 int n = JOptionPane.showOptionDialog(null,
387392 "残りのSQL実行は中断しますか?",
@@ -433,7 +438,7 @@
433438 * @see jdbcacsess2.sqlService.SqlExecutedListener#resultDetail(int, java.util.List)
434439 */
435440 @Override
436- public void resultDetail(int seq, List<Object> detail) {
441+ public void resultDetail(int seq, List<Result> detail) {
437442 }
438443
439444 /*
@@ -471,6 +476,33 @@
471476 });
472477 }
473478
479+ class TableRenderer extends DefaultTableCellRenderer {
480+
481+ @Override
482+ public Component getTableCellRendererComponent(JTable table, Object value,
483+ boolean isSelected, boolean hasFocus,
484+ int row, int column) {
485+ Result r = (Result) value;
486+ if (r.nulldata && !hasFocus) {
487+ setBackground(Color.ORANGE);
488+ } else {
489+ setBackground(null);
490+ }
491+ if (r.error && !hasFocus) {
492+ setBackground(Color.PINK);
493+ }
494+
495+ if (r.num) {
496+ setHorizontalAlignment(JLabel.RIGHT);
497+ } else {
498+ setHorizontalAlignment(JLabel.LEFT);
499+ }
500+
501+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
502+ return this;
503+ }
504+ }
505+
474506 // -------------------------------------------------------------------------
475507 // -------------------------------------------------------------------------
476508 // -------------------------------------------------------------------------
@@ -608,6 +640,8 @@
608640 FontZoom.setMouseWheel(jTable);
609641 resultsTableColumnFit = new TableColumnFit(jTable);
610642 jTable.setModel(new ResultsTableModel());
643+
644+ jTable.setDefaultRenderer(Object.class, new TableRenderer());
611645 }
612646 return jTable;
613647 }
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/main/MainController.java
--- a/src/jdbcacsess2/main/MainController.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/main/MainController.java Fri May 04 00:21:18 2012 +0900
@@ -176,8 +176,8 @@
176176 SqlAsyncExecute sqlAsyncExecute =
177177 new SqlAsyncExecute(sql,
178178 ((SentenceSeparator) jPanelSql.getJComboBoxSentenceSeparator()
179- .getSelectedItem()).getRegVal(),
180- config.optionValues);
179+ .getSelectedItem()).getRegVal(),
180+ config.optionValues);
181181 if (sqlAsyncExecute.isDuplxSelect()) {
182182 ShowDialog.warningMessage("複数のSELECT文は実行出来ません", "複数のSELECT文");
183183 jPanelSql.getJToggleButtonExecution().setSelected(false);
@@ -794,6 +794,7 @@
794794 this.config = config;
795795
796796 view = new MainView();
797+ ShowDialog.setJFrame(view);
797798
798799 histryTableModel = new HistryTableModel(config);
799800
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/main/ShowDialog.java
--- a/src/jdbcacsess2/main/ShowDialog.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/main/ShowDialog.java Fri May 04 00:21:18 2012 +0900
@@ -19,6 +19,7 @@
1919 import java.sql.SQLException;
2020 import java.util.logging.Level;
2121
22+import javax.swing.JFrame;
2223 import javax.swing.JOptionPane;
2324 import javax.swing.SwingUtilities;
2425
@@ -30,6 +31,11 @@
3031 */
3132 public class ShowDialog {
3233
34+ private static JFrame appjframe;
35+
36+ public static void setJFrame(JFrame jframe) {
37+ appjframe = jframe;
38+ }
3339 /**
3440 * 例外発生時のメッセージ出力。画面表示とログ出力を行います。画面表示は、SwingUtilities. invokeLaterを使用しEDTで実行されます。
3541 *
@@ -51,7 +57,7 @@
5157 // EDT以外で呼ばれる事も想定し、EDTで実行する。
5258 SwingUtilities.invokeLater(new Runnable() {
5359 public void run() {
54- JOptionPane.showMessageDialog(null, msg, "ERRORが発生しました", JOptionPane.ERROR_MESSAGE);
60+ JOptionPane.showMessageDialog(appjframe, msg, "ERRORが発生しました", JOptionPane.ERROR_MESSAGE);
5561 }
5662 });
5763 } catch (Throwable e) {
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/ColumnAttributeResult.java
--- a/src/jdbcacsess2/sqlService/ColumnAttributeResult.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/ColumnAttributeResult.java Fri May 04 00:21:18 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 */
@@ -19,6 +19,9 @@
1919 import java.sql.SQLException;
2020 import java.util.ArrayList;
2121 import java.util.List;
22+import java.util.logging.Level;
23+
24+import jdbcacsess2.main.Jdbcacsess2;
2225
2326 /**
2427 * java.sql.ResultSetMetaData の主要項目を、取り扱いやすいようにインスタンス変数で管理します。
@@ -38,7 +41,7 @@
3841 * @throws ClassNotFoundException
3942 */
4043 static public List<ColumnAttributeResult> convColumnAttributeResult(ResultSetMetaData rsmd) throws SQLException,
41- ClassNotFoundException {
44+ ClassNotFoundException {
4245
4346 int cnt = rsmd.getColumnCount();
4447
@@ -63,12 +66,6 @@
6366
6467 columnClassName = rsmd.getColumnClassName(column);
6568
66- try {
67- columnClass = Class.forName(columnClassName, true, rsmd.getClass().getClassLoader());
68- } catch (Exception e) {
69- // TODO ここで、いろいろなデータ型に対応するCLASSを決定する
70- }
71-
7269 columnDisplaySize = rsmd.getColumnDisplaySize(column);
7370
7471 columnLabel = rsmd.getColumnLabel(column);
@@ -97,31 +94,42 @@
9794 readOnly = rsmd.isReadOnly(column);
9895 searchable = rsmd.isSearchable(column);
9996 writable = rsmd.isWritable(column);
97+
98+ try {
99+ columnClass = Class.forName(columnClassName, true, rsmd.getClass().getClassLoader());
100+ } catch (Exception e) {
101+ // TODO ここで、いろいろなデータ型に対応するCLASSを決定する
102+ Jdbcacsess2.logger.log(Level.SEVERE,
103+ "未対応クラス:" + columnClassName + " " + columnName + "は、Objectで処理続行します",
104+ e);
105+ columnClass = Object.class;
106+ }
107+
100108 }
101109
102110 private Class<?> columnClass;
103- private String columnClassName;
104- private int columnDisplaySize;
105- private String columnLabel;
106- private String columnName;
107- private ConstSqlTypes columnType;
111+ private final String columnClassName;
112+ private final int columnDisplaySize;
113+ private final String columnLabel;
114+ private final String columnName;
115+ private final ConstSqlTypes columnType;
108116 private String columnTypeName;
109- private int precision;
110- private int scale;
117+ private final int precision;
118+ private final int scale;
111119 private boolean signed;
112120
113- private String catalogName;
114- private String schemaName;
115- private String tableName;
121+ private final String catalogName;
122+ private final String schemaName;
123+ private final String tableName;
116124
117- private boolean autoIncrement;
118- private boolean caseSensitive;
119- private boolean currency;
120- private boolean definitelyWritable;
121- private int nullable;
122- private boolean readOnly;
123- private boolean searchable;
124- private boolean writable;
125+ private final boolean autoIncrement;
126+ private final boolean caseSensitive;
127+ private final boolean currency;
128+ private final boolean definitelyWritable;
129+ private final int nullable;
130+ private final boolean readOnly;
131+ private final boolean searchable;
132+ private final boolean writable;
125133 /**
126134 * Java クラスの完全指定されたクラスを返します。JDBCのgetColumnClassNameをclass化したものです。
127135 *
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/Result.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdbcacsess2/sqlService/Result.java Fri May 04 00:21:18 2012 +0900
@@ -0,0 +1,88 @@
1+/*
2+ * Copyright 2012 Kazuhiro Shimada
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.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+package jdbcacsess2.sqlService;
18+
19+import java.sql.Clob;
20+import java.sql.SQLException;
21+
22+
23+/**
24+ * 検索結果
25+ *
26+ * @author sima
27+ *
28+ */
29+public class Result {
30+
31+ private final Object data;
32+ private final Class<?> cls;
33+ private String cache;
34+
35+ public boolean num;
36+ public boolean error;
37+ public final boolean nulldata;
38+
39+
40+ public Result(ColumnAttributeResult columnAttributeResult,Object data) {
41+ this.data = data;
42+ nulldata = (data == null);
43+ cls = columnAttributeResult.getColumnClass();
44+
45+ if (nulldata) {
46+ cache = "#null#";
47+ return;
48+ }
49+
50+ if (java.lang.String.class.isAssignableFrom(cls)) {
51+ cache = data.toString();
52+ return;
53+ }
54+ if (java.util.Date.class.isAssignableFrom(cls)) {
55+ cache = data.toString();
56+ return;
57+ }
58+ if (java.lang.Number.class.isAssignableFrom(cls)) {
59+ num = true;
60+ cache = data.toString();
61+ return;
62+ }
63+ if (Clob.class.isAssignableFrom(cls)) {
64+ try {
65+ cache = ((Clob) data).getSubString(0, (int) ((Clob) data).length());
66+ } catch (SQLException e) {
67+ error = true;
68+ cache = "";
69+ }
70+ return;
71+ }
72+ cache = "#unknown#";
73+ return;
74+ }
75+
76+ @Override
77+ public String toString() {
78+ return cache;
79+ }
80+
81+ public String toQoteString() {
82+ if (num) {
83+ return cache;
84+ }
85+ return '"' + cache + '"';
86+ }
87+
88+}
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/ResultsTableModel.java
--- a/src/jdbcacsess2/sqlService/ResultsTableModel.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/ResultsTableModel.java Fri May 04 00:21:18 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 */
@@ -35,8 +35,8 @@
3535
3636 private static final long serialVersionUID = -4605343361563115844L;
3737
38- private List<ColumnAttributeResult> headerList = Collections.synchronizedList(new ArrayList<ColumnAttributeResult>());
39- private List<List<Object>> detailList = Collections.synchronizedList(new ArrayList<List<Object>>());
38+ private final List<ColumnAttributeResult> headerList = Collections.synchronizedList(new ArrayList<ColumnAttributeResult>());
39+ private final List<List<Result>> detailList = Collections.synchronizedList(new ArrayList<List<Result>>());
4040
4141 volatile private boolean tableEditable = false;
4242
@@ -108,7 +108,7 @@
108108 * @see jdbcacsess.sql2.SqlExecutedListener#result(int, java.util.ArrayList)
109109 */
110110 @Override
111- public void resultDetail(final int seq, final List<Object> results) {
111+ public void resultDetail(final int seq, final List<Result> results) {
112112 SwingUtilities.invokeLater(new Runnable() {
113113 public void run() {
114114 detailList.add(results);
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/SqlAsyncExecute.java
--- a/src/jdbcacsess2/sqlService/SqlAsyncExecute.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/SqlAsyncExecute.java Fri May 04 00:21:18 2012 +0900
@@ -379,9 +379,9 @@
379379 Jdbcacsess2.logger.info(" (task)canceled.");
380380 break;
381381 }
382- ArrayList<Object> results = new ArrayList<Object>(columnCnt);
382+ ArrayList<Result> results = new ArrayList<Result>(columnCnt);
383383 for (int i = 1; i <= columnCnt; i++) {
384- results.add(resultSet.getObject(i));
384+ results.add(new Result(list.get(i - 1), resultSet.getObject(i)));
385385 }
386386
387387 rowCnt++;
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/SqlExecutedListener.java
--- a/src/jdbcacsess2/sqlService/SqlExecutedListener.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/SqlExecutedListener.java Fri May 04 00:21:18 2012 +0900
@@ -61,7 +61,7 @@
6161 * @param detail
6262 * 検索結果リスト
6363 */
64- public void resultDetail(int seq, List<Object> detail);
64+ public void resultDetail(int seq, List<Result> detail);
6565
6666 /**
6767 * 結果取得件数が大量になった為、結果の取得が中断した事を通知します。
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/history/ExecHistory.java
--- a/src/jdbcacsess2/sqlService/history/ExecHistory.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/history/ExecHistory.java Fri May 04 00:21:18 2012 +0900
@@ -1,25 +1,27 @@
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 */
1616 package jdbcacsess2.sqlService.history;
1717
18+import java.sql.Types;
1819 import java.util.Date;
1920
2021 import net.java.ao.Entity;
2122 import net.java.ao.Preload;
2223 import net.java.ao.schema.NotNull;
24+import net.java.ao.schema.SQLType;
2325
2426 @Preload
2527 public interface ExecHistory extends Entity {
@@ -55,6 +57,7 @@
5557
5658 void setSqlCommand(String sqlCommand);
5759
60+ @SQLType(value = Types.CLOB)
5861 String getSqlText();
5962
6063 void setSqlText(String sqlText);
diff -r 1369d1926897 -r 28c38ec4338b src/jdbcacsess2/sqlService/history/Record.java
--- a/src/jdbcacsess2/sqlService/history/Record.java Fri Apr 20 22:49:05 2012 +0900
+++ b/src/jdbcacsess2/sqlService/history/Record.java Fri May 04 00:21:18 2012 +0900
@@ -25,6 +25,7 @@
2525 import jdbcacsess2.main.Config;
2626 import jdbcacsess2.main.ShowDialog;
2727 import jdbcacsess2.sqlService.ColumnAttributeResult;
28+import jdbcacsess2.sqlService.Result;
2829 import jdbcacsess2.sqlService.SqlExecuteTask;
2930 import jdbcacsess2.sqlService.SqlExecutedListener;
3031 import jdbcacsess2.sqlService.history.ExecHistory.ResultStatus;
@@ -170,7 +171,7 @@
170171 * @see jdbcacsess2.sqlService.SqlExecutedListener#resultDetail(int, java.util.List)
171172 */
172173 @Override
173- public void resultDetail(int seq, List<Object> detail) {
174+ public void resultDetail(int seq, List<Result> detail) {
174175 }
175176
176177 /* (非 Javadoc)
Show on old repository browser