Source Code Cross Referenced for Preferences.java in  » Database-Client » PKLite-SQL-Client » com » pk » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » PKLite SQL Client » com.pk 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Aug 1, 2004
003:         *
004:         */
005:        package com.pk;
006:
007:        import java.awt.BorderLayout;
008:        import java.awt.ScrollPane;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.awt.event.KeyEvent;
012:
013:        import java.util.List;
014:
015:        import javax.swing.AbstractAction;
016:        import javax.swing.JButton;
017:        import javax.swing.JDialog;
018:        import javax.swing.JPanel;
019:        import javax.swing.JScrollPane;
020:        import javax.swing.JSplitPane;
021:        import javax.swing.JTree;
022:        import javax.swing.KeyStroke;
023:        import javax.swing.LookAndFeel;
024:        import javax.swing.event.TreeSelectionEvent;
025:        import javax.swing.event.TreeSelectionListener;
026:        import javax.swing.tree.DefaultMutableTreeNode;
027:
028:        import com.pk.preferences.ExportPanel;
029:        import com.pk.preferences.GeneralPanel;
030:        import com.pk.preferences.PropertiesPanel;
031:
032:        /**
033:         * @author Chris Taylor
034:         *
035:         */
036:        public class Preferences extends JPanel implements 
037:                TreeSelectionListener, ActionListener {
038:            /**
039:             * 
040:             */
041:            private static final long serialVersionUID = 7690494394227269192L;
042:            public static int WIDTH = 340;
043:            public static int HEIGHT = 570;
044:
045:            private JSplitPane jSplitPane = null;
046:            private JTree jTree = null;
047:            private Config config = null;
048:            private PropertiesPanel propertiesPanel = null;
049:            private ExportPanel exportPanel = null;
050:            private GeneralPanel generalPanel = null;
051:            private DefaultMutableTreeNode topDatasourceNode = null;
052:            private DefaultMutableTreeNode topNode = null;
053:            private DefaultMutableTreeNode exportPrefencesNode = null;
054:            private DefaultMutableTreeNode generalPrefencesNode = null;
055:            private JDialog jDialog = null;
056:            private ConnectionConfig selConnectionConfig;
057:            private JButton saveButton;
058:            private JButton closeButton;
059:
060:            private class CloseAction extends AbstractAction {
061:
062:                /**
063:                 * 
064:                 */
065:                private static final long serialVersionUID = 8735012374912583312L;
066:
067:                /* (non-Javadoc)
068:                 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
069:                 */
070:                public void actionPerformed(ActionEvent arg0) {
071:                    jDialog.dispose();
072:                }
073:            }
074:
075:            /**
076:             * This is the default constructor
077:             */
078:            public Preferences() {
079:                super ();
080:                CloseAction closeAction = new CloseAction();
081:                getInputMap()
082:                        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
083:                                "ESCAPE");
084:                getActionMap().put("ESCAPE", closeAction);
085:
086:            }
087:
088:            /**
089:             * This method initializes this
090:             * 
091:             * @return void
092:             */
093:            public void initialize() {
094:                this .setSize(Preferences.HEIGHT, Preferences.WIDTH);
095:                this .setLayout(new java.awt.BorderLayout());
096:                this .add(getJSplitPane(), java.awt.BorderLayout.CENTER);
097:                JPanel tmp = new JPanel();
098:                saveButton = new JButton("Save");
099:                saveButton.addActionListener(this );
100:                closeButton = new JButton("Close");
101:                closeButton.addActionListener(this );
102:                tmp.add(saveButton);
103:                tmp.add(closeButton);
104:                this .add(tmp, BorderLayout.SOUTH);
105:
106:            }
107:
108:            /**
109:             * This method initializes jContentPane
110:             * 
111:             * @return javax.swing.JPanel
112:             */
113:            //	private javax.swing.JPanel getJContentPane() {
114:            //		if(jContentPane == null) {
115:            //			jContentPane = new javax.swing.JPanel();
116:            //			jContentPane.setLayout(new java.awt.BorderLayout());
117:            //			jContentPane.add(getJSplitPane(), java.awt.BorderLayout.CENTER);
118:            //		}
119:            //		return jContentPane;
120:            //	}
121:            /**
122:             * This method initializes jSplitPane	
123:             * 	
124:             * @return javax.swing.JSplitPane	
125:             */
126:            private JSplitPane getJSplitPane() {
127:                if (jSplitPane == null) {
128:                    jSplitPane = new JSplitPane();
129:                    ScrollPane tmp = new ScrollPane();
130:                    tmp.add(getJTree());
131:                    jSplitPane.setLeftComponent(tmp);
132:                    propertiesPanel = new PropertiesPanel(this );
133:                    jSplitPane.setRightComponent(propertiesPanel);
134:                    jSplitPane.setDividerLocation(165);
135:                }
136:                return jSplitPane;
137:            }
138:
139:            /**
140:             * This method initializes jTree	
141:             * 	
142:             * @return javax.swing.JTree	
143:             */
144:            private JTree getJTree() {
145:                if (jTree == null) {
146:                    topNode = new DefaultMutableTreeNode("Config");
147:                    generalPrefencesNode = new DefaultMutableTreeNode("General");
148:                    topNode.add(generalPrefencesNode);
149:                    exportPrefencesNode = new DefaultMutableTreeNode("Export");
150:                    topNode.add(exportPrefencesNode);
151:                    topDatasourceNode = new DefaultMutableTreeNode(
152:                            "Datasources");
153:                    topNode.add(topDatasourceNode);
154:
155:                    DefaultMutableTreeNode tmp2 = null;
156:                    List configs = config.getConnections();
157:                    int size = configs.size();
158:                    for (int x = 0; x < size; x++) {
159:                        tmp2 = new DefaultMutableTreeNode(configs.get(x));
160:                        topDatasourceNode.add(tmp2);
161:                    }
162:                    jTree = new JTree(topNode);
163:                    jTree.addTreeSelectionListener(this );
164:                }
165:                return jTree;
166:            }
167:
168:            /**
169:             * @return Returns the configs.
170:             */
171:            public Config getConfig() {
172:                return config;
173:            }
174:
175:            /**
176:             * @param configs The configs to set.
177:             */
178:            public void setConfig(Config argConfig) {
179:                this .config = argConfig;
180:            }
181:
182:            /* (non-Javadoc)
183:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
184:             */
185:            public void actionPerformed(ActionEvent actionEvent) {
186:                Object source = actionEvent.getSource();
187:                if (source == saveButton) {
188:                    if (jSplitPane.getRightComponent() == propertiesPanel) {
189:
190:                        if (selConnectionConfig != null) {
191:                            selConnectionConfig
192:                                    .setDatabaseDialectName((String) propertiesPanel
193:                                            .getTxtDialect().getSelectedItem());
194:                            selConnectionConfig.setDriver(propertiesPanel
195:                                    .getTxtDriver().getText());
196:                            selConnectionConfig.setName(propertiesPanel
197:                                    .getTxtName().getText());
198:                            selConnectionConfig.setUrl(propertiesPanel
199:                                    .getTxtURL().getText());
200:
201:                        }
202:
203:                        config.writeFile();
204:
205:                        config.orderConnections();
206:                        jTree = null;
207:                        jTree = getJTree();
208:                        jTree.expandPath(jTree.getPathForRow(3));
209:                        JScrollPane scrollPane = new JScrollPane(jTree);
210:                        getJSplitPane().setLeftComponent(scrollPane);
211:
212:                    } else if (jSplitPane.getRightComponent() == exportPanel) {
213:                        config.setExportDelimiterChar(exportPanel
214:                                .getTxtExportDelimiter().getText());
215:                        config.setEncloseByChar(exportPanel.getTxtEncloseBy()
216:                                .getText());
217:                        config.setBorderColor(exportPanel.getBorderColor()
218:                                .getText());
219:                        config.setHeaderColor(exportPanel.getHeaderColor()
220:                                .getText());
221:                        config.setAltRowColor(exportPanel.getAltRowColor()
222:                                .getText());
223:                        config.setUseCdata(exportPanel.getUseCdata()
224:                                .isSelected());
225:                        config.writeFile();
226:                    } else if (jSplitPane.getRightComponent() == generalPanel) {
227:                        config.setSelectedLookAndFeel((LookAndFeel) config
228:                                .getLookandFeels().get(
229:                                        generalPanel.getLookAndFeelComboBox()
230:                                                .getSelectedIndex()));
231:                        config.setHistoryMode(generalPanel
232:                                .getSelectedHistoryMode());
233:                        config.writeFile();
234:                    }
235:                } else if (source == propertiesPanel.getNewButton()) {
236:                    selConnectionConfig = new ConnectionConfig();
237:                    config.addConnectionConfig(selConnectionConfig);
238:                    selConnectionConfig.setName("NewConfig");
239:                    topDatasourceNode.add(new DefaultMutableTreeNode(
240:                            selConnectionConfig));
241:                    propertiesPanel.getTxtDialect().setSelectedItem(
242:                            selConnectionConfig.getDatabaseDialectName());
243:                    propertiesPanel.getTxtDriver().setText(
244:                            selConnectionConfig.getDriver());
245:                    propertiesPanel.getTxtName().setText(
246:                            selConnectionConfig.getName());
247:                    propertiesPanel.getTxtURL().setText(
248:                            selConnectionConfig.getUrl());
249:                } else if (source == propertiesPanel.getRemoveButton()) {
250:                    config.removeConnection(selConnectionConfig);
251:                    config.writeFile();
252:                    propertiesPanel.getTxtDialect().setSelectedItem("");
253:                    propertiesPanel.getTxtDriver().setText("");
254:                    propertiesPanel.getTxtName().setText("");
255:                    propertiesPanel.getTxtURL().setText("");
256:                    jTree = null;
257:                    jTree = getJTree();
258:                    JScrollPane scrollPane = new JScrollPane(jTree);
259:                    jTree.expandPath(jTree.getPathForRow(3));
260:                    getJSplitPane().setLeftComponent(scrollPane);
261:                } else if (source == closeButton) {
262:                    jDialog.setVisible(false);
263:                }
264:            }
265:
266:            /* (non-Javadoc)
267:             * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
268:             */
269:            public void valueChanged(TreeSelectionEvent arg0) {
270:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree
271:                        .getLastSelectedPathComponent();
272:                Object tmp = node.getUserObject();
273:                if (tmp instanceof  ConnectionConfig) {
274:                    if (jSplitPane.getRightComponent() != propertiesPanel) {
275:                        jSplitPane.setRightComponent(propertiesPanel);
276:                    }
277:                    selConnectionConfig = (ConnectionConfig) tmp;
278:                    propertiesPanel.getTxtDialect().setSelectedItem(
279:                            selConnectionConfig.getDatabaseDialectName());
280:                    propertiesPanel.getTxtDriver().setText(
281:                            selConnectionConfig.getDriver());
282:                    propertiesPanel.getTxtName().setText(
283:                            selConnectionConfig.getName());
284:                    propertiesPanel.getTxtURL().setText(
285:                            selConnectionConfig.getUrl());
286:                } else if (node == exportPrefencesNode) {
287:                    if (exportPanel == null) {
288:                        exportPanel = new ExportPanel(this );
289:                    }
290:                    if (jSplitPane.getRightComponent() != exportPanel) {
291:                        jSplitPane.setRightComponent(exportPanel);
292:                        exportPanel.getTxtExportDelimiter().setText(
293:                                config.getExportDelimiterChar());
294:                        exportPanel.getTxtEncloseBy().setText(
295:                                config.getEncloseByChar());
296:                        exportPanel.getBorderColor().setText(
297:                                config.getBorderColor());
298:                        exportPanel.getHeaderColor().setText(
299:                                config.getHeaderColor());
300:                        exportPanel.getAltRowColor().setText(
301:                                config.getAltRowColor());
302:                        exportPanel.getUseCdata().setSelected(
303:                                config.isUseCdata());
304:                    }
305:
306:                } else if (node == generalPrefencesNode) {
307:                    if (generalPanel == null) {
308:                        generalPanel = new GeneralPanel(this );
309:                        generalPanel.setLookandFeels(config);
310:
311:                    }
312:                    generalPanel
313:                            .setSelectedHistoryMode(config.getHistoryMode());
314:                    generalPanel.getLookAndFeelComboBox().setSelectedItem(
315:                            config.getSelectedLookAndFeel().getName());
316:                    jSplitPane.setRightComponent(generalPanel);
317:                }
318:
319:            }
320:
321:            /**
322:             * @param dialog The jDialog to set.
323:             */
324:            public void setJDialog(JDialog dialog) {
325:                jDialog = dialog;
326:            }
327:        } //  @jve:decl-index=0:visual-constraint="65,28"
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.