• R/O
  • SSH

JdbcAcsess2: Commit

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


Commit MetaInfo

Revision8a79cfa3ab0c347c725f6a964ba5ee5267b5c856 (tree)
Time2012-03-09 00:45:52
Authorshimakazuro
Commitershimakazuro

Log Message

Font保存とconfigテーブル正規化

Change Summary

Incremental Difference

diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/connect/ConnectController.java
--- a/src/jdbcacsess2/connect/ConnectController.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectController.java Fri Mar 09 00:45:52 2012 +0900
@@ -60,6 +60,7 @@
6060 import jdbcacsess2.sqlService.DataBaseListener;
6161 import jdbcacsess2.sqlService.DataBaseTransactionListener;
6262 import net.java.ao.DBParam;
63+import net.java.ao.Query;
6364
6465 @SuppressWarnings("serial")
6566 public class ConnectController {
@@ -254,7 +255,7 @@
254255 public void windowClosing(WindowEvent e) {
255256 // component保存
256257 try {
257- ConfigViewConnect configViewConnect = config.getConfigWindow(ConnectView.ConfigViewConnect.class);
258+ ConfigViewConnect configViewConnect = config.getEntity(ConnectView.ConfigViewConnect.class);
258259 view.collectViewConnect(configViewConnect);
259260 configViewConnect.save();
260261 } catch (SQLException ex) {
@@ -271,7 +272,7 @@
271272 public void actionPerformed(ActionEvent e) {
272273 // component保存
273274 try {
274- ConfigViewConnect configViewConnect = config.getConfigWindow(ConnectView.ConfigViewConnect.class);
275+ ConfigViewConnect configViewConnect = config.getEntity(ConnectView.ConfigViewConnect.class);
275276 view.collectViewConnect(configViewConnect);
276277 configViewConnect.save();
277278 } catch (SQLException ex) {
@@ -364,23 +365,25 @@
364365 connectTableModel.save(rowSave);
365366 }
366367
367- ConfigConnect row[] = config.getConfigConnect();
368+ ConfigConnect row[] =
369+ config.getEntityManager().find(ConfigConnect.class,
370+ Query.select().where(ConfigConnect.CONNECTNAME + "=?",
371+ view.getJTextFieldConnectName()
372+ .getText()));
368373 ConfigConnect connectedConfigConnect = null;
369- for (int i = 0; i < row.length; i++) {
370- if (row[i].getConnectName().equals(view.getJTextFieldConnectName().getText())) {
371- Date lastConnectdate = new Date();
372- row[i].setLastConnectdate(lastConnectdate);
373- row[i].save();
374- connectedConfigConnect = row[i];
375- break;
376- }
374+ for (ConfigConnect element : row) {
375+ Date lastConnectdate = new Date();
376+ element.setLastConnectdate(lastConnectdate);
377+ element.save();
378+ connectedConfigConnect = element;
379+ break;
377380 }
378381
379382 // component保存
380- ConfigViewConnect configViewConnect = config.getConfigWindow(ConnectView.ConfigViewConnect.class);
383+ ConfigViewConnect configViewConnect = config.getEntity(ConnectView.ConfigViewConnect.class);
381384 view.collectViewConnect(configViewConnect);
382385 if (connectedConfigConnect != null) {
383- configViewConnect.setConfigConnect(connectedConfigConnect);
386+ configViewConnect.setConnect(connectedConfigConnect);
384387 }
385388 configViewConnect.save();
386389
@@ -399,14 +402,12 @@
399402 }
400403
401404 @Override
402- public void dataBaseConnectionClosing(
403- DataBaseConnection dataBaseConnection) {
405+ public void dataBaseConnectionClosing(DataBaseConnection dataBaseConnection) {
404406 dataBaseConnection.removeConnectionlisteners(this);
405407 }
406408
407409 @Override
408- public void dataBaseConnectionClosed(
409- DataBaseConnection dataBaseConnection) {
410+ public void dataBaseConnectionClosed(DataBaseConnection dataBaseConnection) {
410411 }
411412 }
412413
@@ -607,10 +608,12 @@
607608 });
608609
609610 // モデル構築
610- view.getJComboBoxDBMS().setModel(new DefaultComboBoxModel<ConfigDbms>(config.getConfigDbms()));
611+ ConfigDbms[] d = config.getEntityManager().find(ConfigDbms.class, Query.select().order(ConfigDbms.DBMSNAME));
612+ view.getJComboBoxDBMS().setModel(new DefaultComboBoxModel<ConfigDbms>(d));
611613 view.getJComboBoxDBMS().setSelectedItem(null);
612614
613- connectTableModel = new ConnectTableModel(config);
615+ ConfigConnect[] e = config.getEntityManager().find(ConfigConnect.class, Query.select());
616+ connectTableModel = new ConnectTableModel(config, e);
614617 view.getJTableConnect().setModel(connectTableModel);
615618 view.getJTableConnect().getRowSorter().toggleSortOrder(0);
616619
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/connect/ConnectTableModel.java
--- a/src/jdbcacsess2/connect/ConnectTableModel.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectTableModel.java Fri Mar 09 00:45:52 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 */
@@ -29,13 +29,13 @@
2929 private static final long serialVersionUID = 6824005336951869877L;
3030
3131 private static final String header[] = { "name", "user", "server", "DBname", "last connect" };
32- private List<ConfigConnect> connectList;
32+ private final List<ConfigConnect> connectList;
3333
34- private Config config;
34+ private final Config config;
3535
36- public ConnectTableModel(Config config) throws SQLException {
36+ public ConnectTableModel(Config config, ConfigConnect[] connectListArray) throws SQLException {
3737 this.config = config;
38- connectList = new ArrayList<ConfigConnect>(Arrays.asList(config.getConfigConnect()));
38+ this.connectList = new ArrayList<ConfigConnect>(Arrays.asList(connectListArray));
3939 }
4040
4141 @Override
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/connect/ConnectView.java
--- a/src/jdbcacsess2/connect/ConnectView.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/connect/ConnectView.java Fri Mar 09 00:45:52 2012 +0900
@@ -44,8 +44,15 @@
4444 import javax.swing.border.BevelBorder;
4545 import javax.swing.border.TitledBorder;
4646
47+import jdbcacsess2.main.GuiDivider;
48+import jdbcacsess2.main.GuiDivider.DividerGenerator;
49+import jdbcacsess2.main.GuiFont;
50+import jdbcacsess2.main.GuiFont.FontGenerator;
51+import jdbcacsess2.main.GuiWindow;
52+import jdbcacsess2.main.GuiWindow.WindowGenerator;
4753 import jdbcacsess2.main.JmyTable;
4854 import net.java.ao.Entity;
55+import net.java.ao.Generator;
4956 import net.java.ao.Preload;
5057
5158 public class ConnectView extends JDialog {
@@ -59,33 +66,25 @@
5966 */
6067 @Preload
6168 public interface ConfigViewConnect extends Entity {
62- int getWidth();
63-
64- void setWidth(int width);
65-
66- int getHeight();
67-
68- void setHeight(int height);
69-
70- int getX();
71-
72- void setX(int X);
7369
74- int getY();
75-
76- void setY(int Y);
77-
78- int getDividerLocation();
70+ @Generator(WindowGenerator.class)
71+ GuiWindow getWindow();
72+ void setWindow(GuiWindow guiWindow);
7973
80- void setDividerLocation(int dividerLocation);
81-
82- int getLastDividerLocation();
74+ @Generator(DividerGenerator.class)
75+ GuiDivider getDivider();
76+ void setDivider(GuiDivider guiDivider);
8377
84- void setLastDividerLocation(int lastDividerLocation);
78+ @Generator(DividerGenerator.class)
79+ GuiDivider getLastDivider();
80+ void setLastDivider(GuiDivider guiDivider);
8581
86- ConfigConnect getConfigConnect();
82+ @Generator(FontGenerator.class)
83+ GuiFont getFontList();
84+ void setFontList(GuiFont guiFont);
8785
88- void setConfigConnect(ConfigConnect configConnect);
86+ ConfigConnect getConnect();
87+ void setConnect(ConfigConnect configConnect);
8988
9089 }
9190
@@ -97,13 +96,25 @@
9796 * @throws SQLException
9897 */
9998 public void collectViewConnect(ConfigViewConnect c) throws SQLException {
100- c.setWidth(getWidth());
101- c.setHeight(getHeight());
10299 Point p = getLocationOnScreen();
103- c.setX(p.x);
104- c.setY(p.y);
105- c.setDividerLocation(jSplitPane.getDividerLocation());
106- c.setLastDividerLocation(jSplitPane.getLastDividerLocation());
100+ GuiWindow guiWindow = c.getWindow();
101+ guiWindow.setWidth(getWidth());
102+ guiWindow.setHeight(getHeight());
103+ guiWindow.setX(p.x);
104+ guiWindow.setY(p.y);
105+ guiWindow.save();
106+
107+ GuiDivider guiDivider = c.getDivider();
108+ guiDivider.setLocation(jSplitPane.getDividerLocation());
109+ guiDivider.save();
110+
111+ GuiDivider configLastDivider = c.getLastDivider();
112+ configLastDivider.setLocation(jSplitPane.getLastDividerLocation());
113+ configLastDivider.save();
114+
115+ GuiFont guiFont = c.getFontList();
116+ guiFont.setFont(jTableConnect.getFont());
117+ guiFont.save();
107118 }
108119
109120 /**
@@ -114,19 +125,27 @@
114125 * @throws SQLException
115126 */
116127 public void setViewConnect(final ConfigViewConnect c) throws SQLException {
117- jSplitPane.setDividerLocation(c.getDividerLocation());
118- jSplitPane.setLastDividerLocation(c.getLastDividerLocation());
119128
120- ConfigConnect configConnect = c.getConfigConnect();
129+ jSplitPane.setDividerLocation(c.getDivider().getLocation());
130+ jSplitPane.setLastDividerLocation(c.getLastDivider().getLocation());
131+
132+ ConfigConnect configConnect = c.getConnect();
121133 if (configConnect != null) {
122- int i = ((ConnectTableModel) jTableConnect.getModel()).getRowIndex(c.getConfigConnect());
134+ int i = ((ConnectTableModel)
135+ jTableConnect.getModel()).getRowIndex(c.getConnect());
123136 if (i != -1) {
124- i = jTableConnect.convertRowIndexToView(i);
137+ i =
138+ jTableConnect.convertRowIndexToView(i);
125139 jTableConnect.getSelectionModel().setSelectionInterval(i, i);
126140 }
127141 }
128- setLocation(c.getX(), c.getY());
129- setSize(c.getWidth(), c.getHeight());
142+
143+ GuiWindow guiWindow = c.getWindow();
144+ setLocation(guiWindow.getX(), guiWindow.getY());
145+ setSize(guiWindow.getWidth(), guiWindow.getHeight());
146+
147+ GuiFont guiFont = c.getFontList();
148+ jTableConnect.setFont(guiFont.getFont());
130149
131150 }
132151
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/Config.java
--- a/src/jdbcacsess2/main/Config.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/main/Config.java Fri Mar 09 00:45:52 2012 +0900
@@ -22,7 +22,6 @@
2222 import java.util.Collections;
2323 import java.util.Enumeration;
2424 import java.util.HashMap;
25-import java.util.Iterator;
2625 import java.util.Map;
2726 import java.util.Properties;
2827 import java.util.logging.ConsoleHandler;
@@ -43,11 +42,11 @@
4342 public class Config {
4443
4544 private static final String CONFIG_DIR = System.getProperty("user.home") + System.getProperty("file.separator")
46- + ".jdbcacsess2";
45+ + ".jdbcacsess2";
4746
4847 private static final String CONFIG_DB = "config.derby";
4948 private static final String CONFIG_JDBCURL = "jdbc:derby:" + CONFIG_DIR + System.getProperty("file.separator")
50- + CONFIG_DB + ";create=true";
49+ + CONFIG_DB + ";create=true";
5150 private static final String CONFIG_JDBCCLASS = "org.apache.derby.jdbc.EmbeddedDriver";
5251 private static final String USER = "";
5352 private static final String PASS = "";
@@ -101,13 +100,12 @@
101100 ArrayList<String> aList = Collections.list(extracted(prop));
102101 Collections.sort(aList);
103102
104- for (Iterator<String> iterator = aList.iterator(); iterator.hasNext();) {
105- String string = iterator.next();
103+ for (String string : aList) {
106104 Jdbcacsess2.logger.fine(string + ":" + System.getProperty(string));
107105 }
108106 } else {
109107 Jdbcacsess2.logger.info(System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name")
110- + " " + System.getProperty("java.vm.version"));
108+ + " " + System.getProperty("java.vm.version"));
111109 Jdbcacsess2.logger.info(System.getProperty("java.home"));
112110 Jdbcacsess2.logger.info(System.getProperty("java.class.path"));
113111 Jdbcacsess2.logger.info(System.getProperty("java.library.path"));
@@ -122,6 +120,7 @@
122120 // Jdbcacsess2.loggerActiveObjects.setLevel(Level.FINE);
123121
124122 migrate();
123+ Jdbcacsess2.logger.info("Migrate end");
125124 setUpConfigDbms();
126125
127126 Jdbcacsess2.logger.info("Config end");
@@ -143,27 +142,10 @@
143142 ConfigConnect.class,
144143 ConnectView.ConfigViewConnect.class,
145144 MainView.ConfigViewMain.class,
146- ExecHistory.class);
147- }
148-
149- /**
150- * {@link ConfigDbms#DBMSNAME}カラム順のDBMSの一覧
151- *
152- * @return {@link ConfigDbms}の配列
153- * @throws SQLException
154- */
155- public ConfigDbms[] getConfigDbms() throws SQLException {
156- return getEntityManager().find(ConfigDbms.class, Query.select().order(ConfigDbms.DBMSNAME));
157- }
158-
159- /**
160- * {@link ConfigConnect#CONNECTNAME}カラム順の接続情報の一覧
161- *
162- * @return {@link ConfigConnect}の配列
163- * @throws SQLException
164- */
165- public ConfigConnect[] getConfigConnect() throws SQLException {
166- return getEntityManager().find(ConfigConnect.class, Query.select());
145+ ExecHistory.class,
146+ GuiFont.class,
147+ GuiWindow.class,
148+ GuiDivider.class);
167149 }
168150
169151 /**
@@ -189,16 +171,16 @@
189171 }
190172
191173 /**
192- * component属性を保管するテーブル検索し、先頭1件だけに絞る。
174+ * テーブル検索し、先頭1件だけに絞る。存在しない場合は初期値行を生成し返却します。
193175 *
194176 * @param <T>
195177 * @param <K>
196178 * @param type
197- * 検索対象componentのテーブルクラス
179+ * 検索対象のテーブルクラス
198180 * @return データが存在しない時は、 {@link EntityManager#create(Class, net.java.ao.DBParam...)} を実行し空行を取得します。
199181 * @throws SQLException
200182 */
201- public <T extends RawEntity<K>, K> T getConfigWindow(Class<T> type) throws SQLException {
183+ public <T extends RawEntity<K>, K> T getEntity(Class<T> type) throws SQLException {
202184 T[] e = getEntityManager().find(type);
203185 if (e.length != 0) {
204186 return e[0];
@@ -211,99 +193,99 @@
211193 */
212194 private void setUpConfigDbms() throws SQLException {
213195 String[] colnames = {
214- ConfigDbms.DBMSNAME, ConfigDbms.SUBPROTOCOL, ConfigDbms.SUBNAME, ConfigDbms.DRIVERCLASS,
215- ConfigDbms.URLOPTION
196+ ConfigDbms.DBMSNAME, ConfigDbms.SUBPROTOCOL, ConfigDbms.SUBNAME, ConfigDbms.DRIVERCLASS,
197+ ConfigDbms.URLOPTION
216198 };
217199 String[][] rows = {
218- {
219- "PostgreSQL", "postgresql", "//%HostName%%PortNumber%/%DataBaseName%",
220- "org.postgresql.Driver", ""
221- },
222- {
223- "MySQL", "mysql", "//%HostName%%PortNumber%/%DataBaseName%", "org.gjt.mm.mysql.Driver", ""
224- },
225- {
226- "MySQL(com)", "mysql", "//%HostName%%PortNumber%/%DataBaseName%", "com.mysql.jdbc.Driver",
227- ""
228- },
229- {
230- "HSQL", "hsqldb:hsql", "//%HostName%%PortNumber%/%DataBaseName%", "org.hsqldb.jdbcDriver",
231- ""
232- },
233- {
234- "Oracle(TYPE4:Pure Java)", "oracle:thin", "@%HostName%%PortNumber%:%DataBaseName%",
235- "oracle.jdbc.driver.OracleDriver", ""
236- },
237- {
238- "Oracle(TYPE2:NET)", "oracle:oci", "@%DataBaseName%", "oracle.jdbc.driver.OracleDriver",
239- ""
240- },
241- {
242- "Oracle(TYPE2:NET8)", "oracle:oci8", "@%DataBaseName%", "oracle.jdbc.driver.OracleDriver",
243- ""
244- },
245- {
246- "DB2(TYPE4:Universal)", "db2", "//%HostName%%PortNumber%/%DataBaseName%",
247- "com.ibm.db2.jcc.DB2Driver", ""
248- },
249- {
250- "DB2(TYPE2:Universal)", "db2", "%DataBaseName%", "com.ibm.db2.jcc.DB2Driver", ""
251- },
252- {
253- "DB2(TYPE2:App)", "db2", "%DataBaseName%", "COM.ibm.db2.jdbc.app.DB2Driver", ""
254- },
255- {
256- "DB2(TYPE3:Net)", "db2", "//%HostName%%PortNumber%/%DataBaseName%",
257- "COM.ibm.db2.jdbc.net.DB2Driver", ""
258- },
259- {
260- "SQL Server", "sqlserver", "//%HostName%%PortNumber%;databaseName=%DataBaseName%",
261- "com.microsoft.sqlserver.jdbc.SQLServerDriver", ""
262- },
263- {
264- "SQL Server(2000)", "microsoft:sqlserver",
265- "//%HostName%%PortNumber%;databaseName=%DataBaseName%",
266- "com.microsoft.jdbc.sqlserver.SQLServerDriver", ""
267- },
268- {
269- "Derby(Embedded)", "derby", "%DataBaseName%", "org.apache.derby.jdbc.EmbeddedDriver", ""
270- },
271- {
272- "Derby(Client)", "derby", "%DataBaseName%", "org.apache.derby.jdbc.ClientDriver", ""
273- },
274- {
275- "SQLite", "sqlite", "/%DataBaseName%", "org.sqlite.JDBC", ""
276- },
277- {
278- "Firebird", "firebirdsql", "//%HostName%%PortNumber%/%DataBaseName%",
279- "org.firebirdsql.jdbc.FBDriver", ""
280- },
281- {
282- "Symfoware", "symford", "//%HostName%%PortNumber%/%DataBaseName%",
283- "com.fujitsu.symfoware.jdbc.SYMDriver", ""
284- },
285- {
286- "HiRDB", "hitachi:hirdb", "//DBID=%PortNumberRAW%,DBHOST=%HostName%",
287- "JP.co.Hitachi.soft.HiRDB.JDBC.HiRDBDriver", ""
288- },
289- {
290- "ODBC(TYPE1)", "odbc", "%DataBaseName%", "sun.jdbc.odbc.JdbcOdbcDriver", ""
291- },
292- {
293- "free format", "", "", "", ""
294- }
200+ {
201+ "PostgreSQL", "postgresql", "//%HostName%%PortNumber%/%DataBaseName%",
202+ "org.postgresql.Driver", ""
203+ },
204+ {
205+ "MySQL", "mysql", "//%HostName%%PortNumber%/%DataBaseName%", "org.gjt.mm.mysql.Driver", ""
206+ },
207+ {
208+ "MySQL(com)", "mysql", "//%HostName%%PortNumber%/%DataBaseName%", "com.mysql.jdbc.Driver",
209+ ""
210+ },
211+ {
212+ "HSQL", "hsqldb:hsql", "//%HostName%%PortNumber%/%DataBaseName%", "org.hsqldb.jdbcDriver",
213+ ""
214+ },
215+ {
216+ "Oracle(TYPE4:Pure Java)", "oracle:thin", "@%HostName%%PortNumber%:%DataBaseName%",
217+ "oracle.jdbc.driver.OracleDriver", ""
218+ },
219+ {
220+ "Oracle(TYPE2:NET)", "oracle:oci", "@%DataBaseName%", "oracle.jdbc.driver.OracleDriver",
221+ ""
222+ },
223+ {
224+ "Oracle(TYPE2:NET8)", "oracle:oci8", "@%DataBaseName%", "oracle.jdbc.driver.OracleDriver",
225+ ""
226+ },
227+ {
228+ "DB2(TYPE4:Universal)", "db2", "//%HostName%%PortNumber%/%DataBaseName%",
229+ "com.ibm.db2.jcc.DB2Driver", ""
230+ },
231+ {
232+ "DB2(TYPE2:Universal)", "db2", "%DataBaseName%", "com.ibm.db2.jcc.DB2Driver", ""
233+ },
234+ {
235+ "DB2(TYPE2:App)", "db2", "%DataBaseName%", "COM.ibm.db2.jdbc.app.DB2Driver", ""
236+ },
237+ {
238+ "DB2(TYPE3:Net)", "db2", "//%HostName%%PortNumber%/%DataBaseName%",
239+ "COM.ibm.db2.jdbc.net.DB2Driver", ""
240+ },
241+ {
242+ "SQL Server", "sqlserver", "//%HostName%%PortNumber%;databaseName=%DataBaseName%",
243+ "com.microsoft.sqlserver.jdbc.SQLServerDriver", ""
244+ },
245+ {
246+ "SQL Server(2000)", "microsoft:sqlserver",
247+ "//%HostName%%PortNumber%;databaseName=%DataBaseName%",
248+ "com.microsoft.jdbc.sqlserver.SQLServerDriver", ""
249+ },
250+ {
251+ "Derby(Embedded)", "derby", "%DataBaseName%", "org.apache.derby.jdbc.EmbeddedDriver", ""
252+ },
253+ {
254+ "Derby(Client)", "derby", "%DataBaseName%", "org.apache.derby.jdbc.ClientDriver", ""
255+ },
256+ {
257+ "SQLite", "sqlite", "/%DataBaseName%", "org.sqlite.JDBC", ""
258+ },
259+ {
260+ "Firebird", "firebirdsql", "//%HostName%%PortNumber%/%DataBaseName%",
261+ "org.firebirdsql.jdbc.FBDriver", ""
262+ },
263+ {
264+ "Symfoware", "symford", "//%HostName%%PortNumber%/%DataBaseName%",
265+ "com.fujitsu.symfoware.jdbc.SYMDriver", ""
266+ },
267+ {
268+ "HiRDB", "hitachi:hirdb", "//DBID=%PortNumberRAW%,DBHOST=%HostName%",
269+ "JP.co.Hitachi.soft.HiRDB.JDBC.HiRDBDriver", ""
270+ },
271+ {
272+ "ODBC(TYPE1)", "odbc", "%DataBaseName%", "sun.jdbc.odbc.JdbcOdbcDriver", ""
273+ },
274+ {
275+ "free format", "", "", "", ""
276+ }
295277 };
296278
297- for (int i = 0; i < rows.length; i++) {
279+ for (String[] row : rows) {
298280 ConfigDbms[] dbms = getEntityManager().find(ConfigDbms.class,
299- Query.select().where(ConfigDbms.DBMSNAME + "=?", rows[i][0]));
281+ Query.select().where(ConfigDbms.DBMSNAME + "=?", row[0]));
300282 if (dbms.length == 0) {
301283 Map<String, Object> m = new HashMap<String, Object>();
302284 for (int j = 0; j < colnames.length; j++) {
303- m.put(colnames[j], rows[i][j]);
285+ m.put(colnames[j], row[j]);
304286 }
305287 getEntityManager().create(ConfigDbms.class, m);
306- Jdbcacsess2.logger.info("not exists:" + rows[i][0]);
288+ Jdbcacsess2.logger.info("not exists:" + row[0]);
307289 }
308290 }
309291 }
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/GuiDivider.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdbcacsess2/main/GuiDivider.java Fri Mar 09 00:45:52 2012 +0900
@@ -0,0 +1,54 @@
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.main;
18+
19+import java.sql.SQLException;
20+
21+import net.java.ao.Entity;
22+import net.java.ao.EntityManager;
23+import net.java.ao.Preload;
24+import net.java.ao.ValueGenerator;
25+
26+/**
27+ * @author sima
28+ *
29+ */
30+@Preload
31+public interface GuiDivider extends Entity {
32+
33+ int getLocation();
34+
35+ void setLocation(int location);
36+
37+ public class DividerGenerator implements ValueGenerator<GuiDivider> {
38+ /*
39+ * (非 Javadoc)
40+ *
41+ * @see net.java.ao.ValueGenerator#generateValue(net.java.ao.EntityManager)
42+ */
43+ @Override
44+ public GuiDivider generateValue(EntityManager manager) {
45+ try {
46+ return manager.create(GuiDivider.class);
47+ } catch (SQLException e) {
48+ ShowDialog.errorMessage(e);
49+ }
50+ return null;
51+ }
52+ }
53+
54+}
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/GuiFont.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdbcacsess2/main/GuiFont.java Fri Mar 09 00:45:52 2012 +0900
@@ -0,0 +1,115 @@
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.main;
18+
19+import java.awt.Font;
20+import java.sql.SQLException;
21+
22+import jdbcacsess2.main.GuiFont.GuiFontImpl;
23+import net.java.ao.Entity;
24+import net.java.ao.EntityManager;
25+import net.java.ao.Implementation;
26+import net.java.ao.Preload;
27+import net.java.ao.ValueGenerator;
28+import net.java.ao.schema.Ignore;
29+
30+/**
31+ * @author sima
32+ *
33+ */
34+@Implementation(GuiFontImpl.class)
35+@Preload
36+public interface GuiFont extends Entity {
37+
38+ public enum Style {
39+ PLAIN(Font.PLAIN), BOLD(Font.BOLD), ITALIC(Font.ITALIC), BOLD_ITALIC(Font.BOLD + Font.ITALIC);
40+
41+ private final int style;
42+
43+ public int getValue() {
44+ return style;
45+ }
46+
47+ private Style(int style) {
48+ this.style = style;
49+ }
50+
51+ public static Style searchStyle(int value) {
52+ for (Style i : Style.values()) {
53+ if (i.getValue() == value) {
54+ return i;
55+ }
56+ }
57+ return null;
58+ }
59+ }
60+
61+ String getName();
62+
63+ void setName(String name);
64+
65+ Style getStyle();
66+
67+ void setStyle(Style style);
68+
69+ int getSize();
70+
71+ void setSize(int size);
72+
73+ @Ignore
74+ void setFont(Font font);
75+
76+ @Ignore
77+ Font getFont();
78+
79+ public class FontGenerator implements ValueGenerator<GuiFont> {
80+ /*
81+ * (非 Javadoc)
82+ *
83+ * @see net.java.ao.ValueGenerator#generateValue(net.java.ao.EntityManager)
84+ */
85+ @Override
86+ public GuiFont generateValue(EntityManager manager) {
87+ try {
88+ return manager.create(GuiFont.class);
89+ } catch (SQLException e) {
90+ ShowDialog.errorMessage(e);
91+ }
92+ return null;
93+ }
94+ }
95+
96+ public class GuiFontImpl {
97+ private final GuiFont guiFont;
98+
99+ public GuiFontImpl(GuiFont guiFont) {
100+ this.guiFont = guiFont;
101+ }
102+
103+ public Font getFont() {
104+ return new Font(guiFont.getName(), guiFont.getStyle().getValue(), guiFont.getSize());
105+ }
106+
107+ public void setFont(Font font) {
108+ guiFont.setName(font.getFontName());
109+ guiFont.setStyle(Style.searchStyle(font.getStyle()));
110+ guiFont.setSize(font.getSize());
111+ }
112+
113+ }
114+
115+}
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/GuiWindow.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdbcacsess2/main/GuiWindow.java Fri Mar 09 00:45:52 2012 +0900
@@ -0,0 +1,66 @@
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.main;
18+
19+import java.sql.SQLException;
20+
21+import net.java.ao.Entity;
22+import net.java.ao.EntityManager;
23+import net.java.ao.Preload;
24+import net.java.ao.ValueGenerator;
25+
26+/**
27+ * @author sima
28+ *
29+ */
30+@Preload
31+public interface GuiWindow extends Entity {
32+
33+ int getWidth();
34+
35+ void setWidth(int width);
36+
37+ int getHeight();
38+
39+ void setHeight(int height);
40+
41+ int getX();
42+
43+ void setX(int X);
44+
45+ int getY();
46+
47+ void setY(int Y);
48+
49+ public class WindowGenerator implements ValueGenerator<GuiWindow> {
50+ /*
51+ * (非 Javadoc)
52+ *
53+ * @see net.java.ao.ValueGenerator#generateValue(net.java.ao.EntityManager)
54+ */
55+ @Override
56+ public GuiWindow generateValue(EntityManager manager) {
57+ try {
58+ return manager.create(GuiWindow.class);
59+ } catch (SQLException e) {
60+ ShowDialog.errorMessage(e);
61+ }
62+ return null;
63+ }
64+ }
65+
66+}
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/MainController.java
--- a/src/jdbcacsess2/main/MainController.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/main/MainController.java Fri Mar 09 00:45:52 2012 +0900
@@ -315,7 +315,7 @@
315315 public void windowClosing(WindowEvent e) {
316316 Jdbcacsess2.logger.info("application termination start:" + e);
317317 try {
318- ConfigViewMain row = config.getConfigWindow(MainView.ConfigViewMain.class);
318+ ConfigViewMain row = config.getEntity(MainView.ConfigViewMain.class);
319319 view.collectViewMain(row);
320320 row.save();
321321 config.close();
diff -r d98e0a9215bf -r 8a79cfa3ab0c src/jdbcacsess2/main/MainView.java
--- a/src/jdbcacsess2/main/MainView.java Mon Mar 05 00:32:06 2012 +0900
+++ b/src/jdbcacsess2/main/MainView.java Fri Mar 09 00:45:52 2012 +0900
@@ -31,8 +31,12 @@
3131 import javax.swing.table.JTableHeader;
3232 import javax.swing.table.TableColumnModel;
3333
34+import jdbcacsess2.main.GuiDivider.DividerGenerator;
35+import jdbcacsess2.main.GuiFont.FontGenerator;
36+import jdbcacsess2.main.GuiWindow.WindowGenerator;
3437 import jdbcacsess2.main.icon.IconImage;
3538 import net.java.ao.Entity;
39+import net.java.ao.Generator;
3640 import net.java.ao.Preload;
3741
3842 public class MainView extends JFrame {
@@ -48,64 +52,63 @@
4852 */
4953 @Preload
5054 public interface ConfigViewMain extends Entity {
51- Integer getWidth();
52-
53- void setWidth(Integer width);
54-
55- Integer getHeight();
56-
57- void setHeight(Integer height);
58-
59- Integer getX();
60-
61- void setX(Integer X);
62-
63- Integer getY();
64-
65- void setY(Integer Y);
66-
67- Integer getTreeDividerLocation();
68-
69- void setTreeDividerLocation(Integer treeDividerLocation);
55+ @Generator(WindowGenerator.class)
56+ GuiWindow getWindow();
57+ void setWindow(GuiWindow guiWindow);
7058
71- Integer getTreeLastDividerLocation();
72-
73- void setTreeLastDividerLocation(Integer treeLastDividerLocation);
74-
75- Integer getDBObjectsDividerLocation();
76-
77- void setDBObjectsDividerLocation(Integer dbobjectsDividerLocation);
78-
79- Integer getDBObjectsLastDividerLocation();
59+ // Tree
60+ @Generator(FontGenerator.class)
61+ GuiFont getTreeFont();
62+ void setTreeFont(GuiFont guiFont);
8063
81- void setDBObjectsLastDividerLocation(Integer dbobjectsLastDividerLocation);
82-
83- Integer getTableDividerLocation();
84-
85- void setTableDividerLocation(Integer tableDividerLocation);
64+ @Generator(DividerGenerator.class)
65+ GuiDivider getTreeDivider();
66+ void setTreeDivider(GuiDivider guiDivider);
8667
87- Integer getTableLastDividerLocation();
68+ @Generator(DividerGenerator.class)
69+ GuiDivider getTreeLastDivider();
70+ void setTreeLastDivider(GuiDivider guiDivider);
8871
89- void setTableLastDividerLocation(Integer tableLastDividerLocation);
72+ @Generator(DividerGenerator.class)
73+ GuiDivider getDBObjectsDivider();
74+ void setDBObjectsDivider(GuiDivider guiDivider);
9075
76+ @Generator(DividerGenerator.class)
77+ GuiDivider getDBObjectsLastDivider();
78+ void setDBObjectsLastDivider(GuiDivider guiDivider);
79+
80+ // Table
81+ @Generator(FontGenerator.class)
82+ GuiFont getTableFont();
83+ void setTableFont(GuiFont guiFont);
84+
85+ @Generator(DividerGenerator.class)
86+ GuiDivider getTableDivider();
87+ void setTableDivider(GuiDivider guiDivider);
88+
89+ @Generator(DividerGenerator.class)
90+ GuiDivider getTableLastDivider();
91+ void setTableLastDivider(GuiDivider guiDivider);
92+
93+ // Sql
94+ @Generator(FontGenerator.class)
95+ GuiFont getSqlFont();
96+ void setSqlFont(GuiFont guiFont);
97+
98+ // Other
9199 boolean getAutoCommit();
92-
93100 void setAutoCommit(boolean autoCommit);
94101
95102 Integer getTreeTableColumnWidth0();
96-
97103 void setTreeTableColumnWidth0(Integer treeTableColumnWidth0);
98104
99105 Integer getTreeTableColumnWidth1();
100-
101106 void setTreeTableColumnWidth1(Integer treeTableColumnWidth1);
102107
103108 Integer getTreeTableColumnWidth2();
104-
105109 void setTreeTableColumnWidth2(Integer treeTableColumnWidth2);
106110
107111 Integer getTreeTableColumnWidth3();
108-
109112 void setTreeTableColumnWidth3(Integer treeTableColumnWidth3);
110113
111114 }
@@ -129,22 +132,41 @@
129132 * component属性を格納する為のConfigViewMain。
130133 */
131134 public void collectViewMain(ConfigViewMain c) {
132- c.setWidth(getWidth());
133- c.setHeight(getHeight());
134135 Point p = getLocationOnScreen();
135- c.setX(p.x);
136- c.setY(p.y);
136+ GuiWindow guiWindow = c.getWindow();
137+ guiWindow.setWidth(getWidth());
138+ guiWindow.setHeight(getHeight());
139+ guiWindow.setX(p.x);
140+ guiWindow.setY(p.y);
141+ guiWindow.save();
142+
143+ GuiDivider guiDivider;
144+ GuiFont guiFont;
137145
138146 // JPanelSession 関連
139147 JPanelSession jPanelSession = getCurrentJPanelSession();
140148 if (jPanelSession == null) {
141149 return;
142150 }
143- c.setTreeDividerLocation(jPanelSession.getJSplitPaneTree().getDividerLocation());
144- c.setTreeLastDividerLocation(jPanelSession.getJSplitPaneTree().getLastDividerLocation());
151+ guiFont = c.getTreeFont();
152+ guiFont.setFont(jPanelSession.getJXTreetableDBObjects().getFont());
153+ guiFont.save();
145154
146- c.setDBObjectsDividerLocation(jPanelSession.getJSplitPaneDBObjects().getDividerLocation());
147- c.setDBObjectsLastDividerLocation(jPanelSession.getJSplitPaneDBObjects().getLastDividerLocation());
155+ guiDivider = c.getTreeDivider();
156+ guiDivider.setLocation(jPanelSession.getJSplitPaneTree().getDividerLocation());
157+ guiDivider.save();
158+
159+ guiDivider = c.getTreeLastDivider();
160+ guiDivider.setLocation(jPanelSession.getJSplitPaneTree().getLastDividerLocation());
161+ guiDivider.save();
162+
163+ guiDivider = c.getDBObjectsDivider();
164+ guiDivider.setLocation(jPanelSession.getJSplitPaneDBObjects().getDividerLocation());
165+ guiDivider.save();
166+
167+ guiDivider = c.getDBObjectsLastDivider();
168+ guiDivider.setLocation(jPanelSession.getJSplitPaneDBObjects().getLastDividerLocation());
169+ guiDivider.save();
148170
149171 // JPanelSession の TableColumnModel 関連
150172 TableColumnModel model = getTableColumnModel(jPanelSession);
@@ -162,8 +184,22 @@
162184 if (jPanelSql == null) {
163185 return;
164186 }
165- c.setTableDividerLocation(jPanelSql.getJSplitPaneTable().getDividerLocation());
166- c.setTableLastDividerLocation(jPanelSql.getJSplitPaneTable().getLastDividerLocation());
187+
188+ guiFont = c.getSqlFont();
189+ guiFont.setFont(jPanelSql.getRSyntaxTextAreaSql().getFont());
190+ guiFont.save();
191+
192+ guiFont = c.getTableFont();
193+ guiFont.setFont(jPanelSql.getJTable().getFont());
194+ guiFont.save();
195+
196+ guiDivider = c.getTableDivider();
197+ guiDivider.setLocation(jPanelSql.getJSplitPaneTable().getDividerLocation());
198+ guiDivider.save();
199+
200+ guiDivider = c.getTableLastDivider();
201+ guiDivider.setLocation(jPanelSql.getJSplitPaneTable().getLastDividerLocation());
202+ guiDivider.save();
167203 c.setAutoCommit(jPanelSql.getJCheckBoxAutoCommit().isSelected());
168204
169205 }
@@ -176,8 +212,11 @@
176212 */
177213 public void setViewMain(ConfigViewMain c) {
178214 if (c != null) {
179- setSize(c.getWidth(), c.getHeight());
180- setLocation(c.getX(), c.getY());
215+ GuiWindow guiWindow = c.getWindow();
216+ if (guiWindow != null) {
217+ setSize(guiWindow.getWidth(), guiWindow.getHeight());
218+ setLocation(guiWindow.getX(), guiWindow.getY());
219+ }
181220 }
182221 }
183222
@@ -191,14 +230,24 @@
191230 */
192231 public void setViewMainPanelSesion(JPanelSession jPanelSession, ConfigViewMain c) {
193232 if (c != null) {
194- jPanelSession.getJSplitPaneTree().setDividerLocation(c.getTreeDividerLocation());
195- jPanelSession.getJSplitPaneTree().setLastDividerLocation(c.getTreeLastDividerLocation());
233+ if (c.getTreeDivider() != null) {
234+ jPanelSession.getJSplitPaneTree().setDividerLocation(c.getTreeDivider().getLocation());
235+ }
236+ if (c.getTreeLastDivider() != null) {
237+ jPanelSession.getJSplitPaneTree().setLastDividerLocation(c.getTreeLastDivider().getLocation());
238+ }
196239
197- if (c.getDBObjectsDividerLocation() != null) {
198- jPanelSession.getJSplitPaneDBObjects().setDividerLocation(c.getDBObjectsDividerLocation());
240+ if (c.getDBObjectsDivider() != null) {
241+ jPanelSession.getJSplitPaneDBObjects().setDividerLocation(c.getDBObjectsDivider().getLocation());
199242 }
200- if (c.getDBObjectsLastDividerLocation() != null) {
201- jPanelSession.getJSplitPaneDBObjects().setLastDividerLocation(c.getDBObjectsLastDividerLocation());
243+ if (c.getDBObjectsLastDivider() != null) {
244+ jPanelSession.getJSplitPaneDBObjects()
245+ .setLastDividerLocation(c.getDBObjectsLastDivider().getLocation());
246+ }
247+ GuiFont guiFont;
248+ guiFont = c.getTreeFont();
249+ if(guiFont!=null){
250+ jPanelSession.getJXTreetableDBObjects().setFont(guiFont.getFont());
202251 }
203252 }
204253 }
@@ -213,9 +262,23 @@
213262 */
214263 public void setViewMainPanelSql(JPanelSql jPanelSql, ConfigViewMain c) {
215264 if (c != null) {
216- jPanelSql.getJSplitPaneTable().setDividerLocation(c.getTableDividerLocation());
217- jPanelSql.getJSplitPaneTable().setLastDividerLocation(c.getTableLastDividerLocation());
265+ if (c.getTableDivider() != null) {
266+ jPanelSql.getJSplitPaneTable().setDividerLocation(c.getTableDivider().getLocation());
267+ }
268+ if (c.getTableLastDivider() != null) {
269+ jPanelSql.getJSplitPaneTable().setLastDividerLocation(c.getTableLastDivider().getLocation());
270+ }
218271 jPanelSql.getJCheckBoxAutoCommit().setSelected(c.getAutoCommit());
272+
273+ GuiFont guiFont;
274+ guiFont = c.getSqlFont();
275+ if (guiFont != null) {
276+ jPanelSql.getRSyntaxTextAreaSql().setFont(guiFont.getFont());
277+ }
278+ guiFont = c.getTableFont();
279+ if (guiFont != null) {
280+ jPanelSql.getJTable().setFont(guiFont.getFont());
281+ }
219282 }
220283 }
221284
Show on old repository browser