Source Code Cross Referenced for AddNewColumnWindow.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 java.awt.GridLayout;
004:        import java.awt.event.ActionEvent;
005:        import java.awt.event.ActionListener;
006:        import java.util.ArrayList;
007:        import java.util.List;
008:        import javax.swing.BoxLayout;
009:        import javax.swing.JCheckBox;
010:        import javax.swing.JComboBox;
011:        import javax.swing.JDialog;
012:        import javax.swing.JLabel;
013:        import javax.swing.JOptionPane;
014:        import javax.swing.JPanel;
015:        import javax.swing.JTextField;
016:        import org.dbbrowser.db.engine.exception.DBEngineException;
017:        import org.dbbrowser.db.engine.model.ColumnInfo;
018:        import org.dbbrowser.db.engine.model.DBTable;
019:        import org.dbbrowser.ui.panel.ButtonsPanel;
020:        import org.dbbrowser.ui.widget.Button;
021:        import infrastructure.internationalization.InternationalizationManager;
022:
023:        public class AddNewColumnWindow implements  ActionListener {
024:            private static final String TITLE = InternationalizationManager
025:                    .getInstance().getMessage("dbbrowser-ui",
026:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
027:
028:            private String ADD_NEW_COLUMN_LABEL = InternationalizationManager
029:                    .getInstance().getMessage("dbbrowser-ui",
030:                            "dbbrowser-ui-add-new-record-window-add-label",
031:                            null);
032:            private UIControllerForUpdates uiControllerForUpdates = null;
033:            private DBTable dbTable = null;
034:
035:            private JPanel mainPanel = new JPanel();
036:            private JDialog dialog = null;
037:            private ButtonsPanel buttonsPanel = null;
038:
039:            private JPanel panelForData = new JPanel();
040:            private JTextField fieldForColumnName = new JTextField();
041:            private JTextField fieldForColumnSize = new JTextField();
042:            private JComboBox comboBoxForDataType = null;
043:            private JCheckBox checkBoxForNullableNature = new JCheckBox();
044:
045:            public AddNewColumnWindow(
046:                    UIControllerForUpdates uiControllerForUpdates,
047:                    DBTable dbTable) {
048:                this .uiControllerForUpdates = uiControllerForUpdates;
049:                this .dbTable = dbTable;
050:
051:                initialize();
052:            }
053:
054:            public void actionPerformed(ActionEvent e) {
055:                if (ADD_NEW_COLUMN_LABEL.equals(e.getActionCommand())) {
056:                    //Get the column type name
057:                    String columnTypeName = this .comboBoxForDataType
058:                            .getSelectedItem().toString();
059:
060:                    //Validate the values entered by the user
061:                    String columnName = this .fieldForColumnName.getText();
062:                    if (columnName == null || columnName.length() == 0) {
063:                        String COLUMN_NAME_INCORRECT_MESSAGE = InternationalizationManager
064:                                .getInstance()
065:                                .getMessage(
066:                                        "dbbrowser-ui",
067:                                        "dbbrowser-ui-add-new-record-window-wrong-column-name-error-message-label",
068:                                        null);
069:                        JOptionPane.showMessageDialog(null,
070:                                COLUMN_NAME_INCORRECT_MESSAGE, TITLE,
071:                                JOptionPane.ERROR_MESSAGE);
072:                    } else {
073:                        String columnDisplaySize = this .fieldForColumnSize
074:                                .getText();
075:                        if (columnDisplaySize == null
076:                                || columnDisplaySize.length() == 0) {
077:                            String COLUMN_SIZE_INCORRECT_MESSAGE = InternationalizationManager
078:                                    .getInstance()
079:                                    .getMessage(
080:                                            "dbbrowser-ui",
081:                                            "dbbrowser-ui-add-new-record-window-wrong-column-size-error-message-label",
082:                                            null);
083:                            JOptionPane.showMessageDialog(null,
084:                                    COLUMN_SIZE_INCORRECT_MESSAGE, TITLE,
085:                                    JOptionPane.ERROR_MESSAGE);
086:                        } else {
087:                            try {
088:                                int size = Integer.parseInt(columnDisplaySize);
089:
090:                                //Validation complete
091:
092:                                //Get nullable nature
093:                                boolean nullable = this .checkBoxForNullableNature
094:                                        .isSelected();
095:                                String nullableString = ColumnInfo.COLUMN_NOT_NULLABLE;
096:                                if (nullable) {
097:                                    nullableString = ColumnInfo.COLUMN_NULLABLE;
098:                                }
099:
100:                                //Build the column info
101:                                ColumnInfo ci = new ColumnInfo(columnName,
102:                                        columnTypeName, null,
103:                                        new Integer(size), nullableString,
104:                                        Boolean.FALSE, Boolean.FALSE,
105:                                        Boolean.FALSE, null);
106:
107:                                //Add the column
108:                                try {
109:                                    this .uiControllerForUpdates.addNewColumn(
110:                                            this .dbTable.getSchemaName(),
111:                                            this .dbTable.getTableName(), ci);
112:                                    this .dialog.pack();
113:                                    this .dialog.dispose();
114:                                    this .dialog = null;
115:                                } catch (DBEngineException exc) {
116:                                    String errorMessage = InternationalizationManager
117:                                            .getInstance()
118:                                            .getMessage(
119:                                                    "dbbrowser-ui",
120:                                                    "dbbrowser-ui-dbbrowser-window-sql-failed",
121:                                                    null);
122:                                    JOptionPane.showMessageDialog(null,
123:                                            errorMessage + " - "
124:                                                    + exc.getMessage(), TITLE,
125:                                            JOptionPane.ERROR_MESSAGE);
126:                                }
127:                            } catch (NumberFormatException exc) {
128:                                String COLUMN_SIZE_INCORRECT_MESSAGE = InternationalizationManager
129:                                        .getInstance()
130:                                        .getMessage(
131:                                                "dbbrowser-ui",
132:                                                "dbbrowser-ui-add-new-record-window-wrong-column-size-error-message-label",
133:                                                null);
134:                                JOptionPane.showMessageDialog(null,
135:                                        COLUMN_SIZE_INCORRECT_MESSAGE, TITLE,
136:                                        JOptionPane.ERROR_MESSAGE);
137:                            }
138:                        }
139:                    }
140:                }
141:            }
142:
143:            public void show() {
144:                this .dialog.setVisible(true);
145:            }
146:
147:            private void initialize() {
148:                //Setup the dialog
149:                this .dialog = new JDialog();
150:                this .dialog.setTitle(TITLE);
151:                this .dialog.setModal(true);
152:
153:                //Setup the frame
154:                this .dialog.setSize(500, 200);
155:                this .dialog.setLocationRelativeTo(null);
156:                this .dialog.getContentPane().add(this .mainPanel);
157:
158:                //Build the list of buttons
159:                List listOfButtons = new ArrayList();
160:                Button addNewColumnButton = new Button(ADD_NEW_COLUMN_LABEL,
161:                        this , ADD_NEW_COLUMN_LABEL, null, Boolean.FALSE);
162:                listOfButtons.add(addNewColumnButton);
163:
164:                //Setup the navigation panel
165:                buttonsPanel = new ButtonsPanel(listOfButtons);
166:
167:                //Set up the textfields and labels
168:                this .panelForData.setLayout(new GridLayout(4, 2));
169:
170:                String COLUMN_NAME_LABEL = InternationalizationManager
171:                        .getInstance()
172:                        .getMessage(
173:                                "dbbrowser-ui",
174:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-column-name",
175:                                null);
176:                String COLUMN_SIZE_LABEL = InternationalizationManager
177:                        .getInstance()
178:                        .getMessage(
179:                                "dbbrowser-ui",
180:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-size",
181:                                null);
182:                String COLUMN_TYPE_LABEL = InternationalizationManager
183:                        .getInstance()
184:                        .getMessage(
185:                                "dbbrowser-ui",
186:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-data-type",
187:                                null);
188:                String COLUMN__NULLABLE_LABEL = InternationalizationManager
189:                        .getInstance()
190:                        .getMessage(
191:                                "dbbrowser-ui",
192:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-nullable",
193:                                null);
194:
195:                JLabel labelForColumnName = new JLabel(COLUMN_NAME_LABEL);
196:                JLabel labelForColumnSize = new JLabel(COLUMN_SIZE_LABEL);
197:                JLabel labelForColumnType = new JLabel(COLUMN_TYPE_LABEL);
198:                JLabel labelForNullableNature = new JLabel(
199:                        COLUMN__NULLABLE_LABEL);
200:
201:                //Build the list of column types
202:                String[] dataTypes = new String[] {
203:                        ColumnInfo.COLUMN_TYPE_VARCHAR,
204:                        ColumnInfo.COLUMN_TYPE_DATE,
205:                        ColumnInfo.COLUMN_TYPE_DATE_TIME,
206:                        ColumnInfo.COLUMN_TYPE_NUMBER };
207:                this .comboBoxForDataType = new JComboBox(dataTypes);
208:                this .comboBoxForDataType.setEditable(false);
209:
210:                this .panelForData.add(labelForColumnName);
211:                this .panelForData.add(fieldForColumnName);
212:                this .panelForData.add(labelForColumnSize);
213:                this .panelForData.add(fieldForColumnSize);
214:                this .panelForData.add(labelForColumnType);
215:                this .panelForData.add(comboBoxForDataType);
216:                this .panelForData.add(labelForNullableNature);
217:                this .panelForData.add(checkBoxForNullableNature);
218:
219:                //Add the buttons panel
220:                this .mainPanel.setLayout(new BoxLayout(this.mainPanel,
221:                        BoxLayout.PAGE_AXIS));
222:                this.mainPanel.add(this.panelForData);
223:                this.mainPanel.add(this.buttonsPanel);
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.