Source Code Cross Referenced for PreferencesPanel.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » 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 » DBBrowser » org.dbbrowser.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui;
002:
003:        import infrastructure.internationalization.InternationalizationManager;
004:        import infrastructure.propertymanager.PropertyManagementException;
005:        import infrastructure.propertymanager.PropertyManager;
006:        import java.awt.GridLayout;
007:        import java.awt.Window;
008:        import java.awt.event.ActionEvent;
009:        import java.awt.event.ActionListener;
010:        import java.util.ArrayList;
011:        import java.util.List;
012:        import javax.swing.BorderFactory;
013:        import javax.swing.BoxLayout;
014:        import javax.swing.Icon;
015:        import javax.swing.ImageIcon;
016:        import javax.swing.JCheckBox;
017:        import javax.swing.JLabel;
018:        import javax.swing.JOptionPane;
019:        import javax.swing.JPanel;
020:        import javax.swing.JTextField;
021:        import javax.swing.SwingUtilities;
022:
023:        import org.dbbrowser.ui.panel.ButtonsPanel;
024:        import org.dbbrowser.ui.widget.Button;
025:
026:        public class PreferencesPanel extends JPanel implements  ActionListener {
027:            private static final String TITLE = InternationalizationManager
028:                    .getInstance().getMessage("dbbrowser-ui",
029:                            "dbbrowser-ui-dbbrowser-window-title-label", null);
030:
031:            private static final String RECORDS_PER_PAGE_LABEL = InternationalizationManager
032:                    .getInstance()
033:                    .getMessage(
034:                            "dbbrowser-ui",
035:                            "dbbrowser-ui-preferences-window-records-per-page-label",
036:                            null);
037:            private static final String AUTO_COMMIT_LABEL = InternationalizationManager
038:                    .getInstance()
039:                    .getMessage(
040:                            "dbbrowser-ui",
041:                            "dbbrowser-ui-preferences-window-auto-commit-label",
042:                            null);
043:            private static final String SHOW_SQL_LOG_LABEL = InternationalizationManager
044:                    .getInstance()
045:                    .getMessage(
046:                            "dbbrowser-ui",
047:                            "dbbrowser-ui-preferences-window-show-sql-log-label",
048:                            null);
049:            private static final String SORT_COLUMNS_LABEL = InternationalizationManager
050:                    .getInstance().getMessage("dbbrowser-ui",
051:                            "dbbrowser-ui-preferences-window-sort-columns",
052:                            null);
053:            private static final String SAVE_CHANGES_BUTTON_LABEL = InternationalizationManager
054:                    .getInstance()
055:                    .getMessage(
056:                            "dbbrowser-ui",
057:                            "dbbrowser-ui-new-connections-details-panel-save-changes-button-label",
058:                            null);
059:            private static final String SAVE_CHANGES_ICON_FILENAME = PropertyManager
060:                    .getInstance()
061:                    .getProperty(
062:                            "dbbrowser-ui-view-record-window-update-record-icon");
063:            private static final String SQL_STATEMENT_TERMINATOR = InternationalizationManager
064:                    .getInstance()
065:                    .getMessage(
066:                            "dbbrowser-ui",
067:                            "dbbrowser-ui-preferences-window-sql-statement-terminator-label",
068:                            null);
069:
070:            private Icon iconForSaveChanges = new ImageIcon(
071:                    SAVE_CHANGES_ICON_FILENAME);
072:            private JTextField textFieldForRecordsPerPage = new JTextField("");
073:            private JTextField textFieldForSQLStatementTerminator = new JTextField(
074:                    "");
075:            private JCheckBox checkBoxForAutoCommit = new JCheckBox();
076:            private JCheckBox checkBoxForShowSQL = new JCheckBox();
077:            private JCheckBox checkBoxForSortColumns = new JCheckBox();
078:
079:            public PreferencesPanel() {
080:                initialize();
081:            }
082:
083:            public void actionPerformed(ActionEvent e) {
084:                String recordsPerPageString = this .textFieldForRecordsPerPage
085:                        .getText();
086:
087:                try {
088:                    int recordsPerPage = Integer.parseInt(recordsPerPageString);
089:                    PropertyManager.getInstance().setProperty(
090:                            "dbbrowser-ui-browser-window-paging-size",
091:                            "" + recordsPerPage);
092:                    PropertyManager.getInstance().setProperty(
093:                            "dbbrowser-sql-statement-terminator",
094:                            this .textFieldForSQLStatementTerminator.getText());
095:
096:                    if (checkBoxForAutoCommit.isSelected()) {
097:                        PropertyManager.getInstance().setProperty(
098:                                "dbbrowser-auto-commit", "true");
099:                    } else {
100:                        PropertyManager.getInstance().setProperty(
101:                                "dbbrowser-auto-commit", "false");
102:                    }
103:
104:                    if (checkBoxForShowSQL.isSelected()) {
105:                        PropertyManager.getInstance().setProperty(
106:                                "dbbrowser-ui-dbbrowser-window-show-sql-log",
107:                                "true");
108:                    } else {
109:                        PropertyManager.getInstance().setProperty(
110:                                "dbbrowser-ui-dbbrowser-window-show-sql-log",
111:                                "false");
112:                    }
113:
114:                    if (checkBoxForSortColumns.isSelected()) {
115:                        PropertyManager.getInstance().setProperty(
116:                                "dbbrowser-ui-sort-columns-in-table", "true");
117:                    } else {
118:                        PropertyManager.getInstance().setProperty(
119:                                "dbbrowser-ui-sort-columns-in-table", "false");
120:                    }
121:                } catch (NumberFormatException exc) {
122:                    String errorMessage = InternationalizationManager
123:                            .getInstance()
124:                            .getMessage(
125:                                    "dbbrowser-ui",
126:                                    "dbbrowser-ui-preferences-window-not-a-number-error-message-label",
127:                                    null);
128:                    JOptionPane.showMessageDialog(null, errorMessage, TITLE,
129:                            JOptionPane.ERROR_MESSAGE);
130:                } catch (PropertyManagementException exc) {
131:                    String errorMessage = InternationalizationManager
132:                            .getInstance()
133:                            .getMessage(
134:                                    "dbbrowser-ui",
135:                                    "dbbrowser-ui-dbbrowser-window-save-property-failed-message",
136:                                    null);
137:                    JOptionPane.showMessageDialog(null, errorMessage, TITLE,
138:                            JOptionPane.ERROR_MESSAGE);
139:                }
140:
141:                //Close this window
142:                Window window = SwingUtilities.getWindowAncestor(this );
143:                if (window != null) {
144:                    window.dispose();
145:                    window.hide();
146:                }
147:            }
148:
149:            private void initialize() {
150:                //Setup the dialog
151:                this .setLayout(new BoxLayout(this , BoxLayout.PAGE_AXIS));
152:
153:                //Build the widgets
154:                JLabel labelForRecordsPerPage = new JLabel(
155:                        RECORDS_PER_PAGE_LABEL);
156:                JLabel labelForAutoCommit = new JLabel(AUTO_COMMIT_LABEL);
157:                JLabel labelForShowSQLInLog = new JLabel(SHOW_SQL_LOG_LABEL);
158:                JLabel labelForSortColumns = new JLabel(SORT_COLUMNS_LABEL);
159:                JLabel labelForSQLStatementTerminator = new JLabel(
160:                        SQL_STATEMENT_TERMINATOR);
161:
162:                JPanel panel = new JPanel();
163:                String panelTitle = InternationalizationManager
164:                        .getInstance()
165:                        .getMessage(
166:                                "dbbrowser-ui",
167:                                "dbbrowser-ui-preferences-window-preferences-panel-title",
168:                                null);
169:                panel.setBorder(BorderFactory.createTitledBorder(panelTitle));
170:                panel.setLayout(new GridLayout(5, 2));
171:                panel.add(labelForRecordsPerPage);
172:                panel.add(textFieldForRecordsPerPage);
173:                panel.add(labelForAutoCommit);
174:                panel.add(checkBoxForAutoCommit);
175:                panel.add(labelForShowSQLInLog);
176:                panel.add(checkBoxForShowSQL);
177:                panel.add(labelForSortColumns);
178:                panel.add(checkBoxForSortColumns);
179:                panel.add(labelForSQLStatementTerminator);
180:                panel.add(textFieldForSQLStatementTerminator);
181:
182:                //Set the values from the properties file
183:                textFieldForRecordsPerPage.setText(PropertyManager
184:                        .getInstance().getProperty(
185:                                "dbbrowser-ui-browser-window-paging-size"));
186:                textFieldForSQLStatementTerminator.setText(PropertyManager
187:                        .getInstance().getProperty(
188:                                "dbbrowser-sql-statement-terminator"));
189:
190:                String autoCommitFlag = PropertyManager.getInstance()
191:                        .getProperty("dbbrowser-auto-commit");
192:                if ("true".equals(autoCommitFlag)) {
193:                    checkBoxForAutoCommit.setSelected(true);
194:                }
195:
196:                String showSQLLog = PropertyManager.getInstance().getProperty(
197:                        "dbbrowser-ui-dbbrowser-window-show-sql-log");
198:                if ("true".equals(showSQLLog)) {
199:                    checkBoxForShowSQL.setSelected(true);
200:                }
201:
202:                String sortColumns = PropertyManager.getInstance().getProperty(
203:                        "dbbrowser-ui-sort-columns-in-table");
204:                if ("true".equals(sortColumns)) {
205:                    checkBoxForSortColumns.setSelected(true);
206:                }
207:
208:                //Add the panel
209:                this .add(panel);
210:
211:                //Build the list of buttons for the navigation buttons panel
212:                List listOfButtons = new ArrayList();
213:                Button firstRecordButton = new Button(
214:                        SAVE_CHANGES_BUTTON_LABEL, this ,
215:                        SAVE_CHANGES_BUTTON_LABEL, iconForSaveChanges,
216:                        Boolean.FALSE);
217:                listOfButtons.add(firstRecordButton);
218:
219:                //Setup the navigation panel
220:                ButtonsPanel butonsPanel = new ButtonsPanel(listOfButtons);
221:                this.add(butonsPanel);
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.