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


001:        package org.dbbrowser.ui.panel.dbbrowserwindow;
002:
003:        import infrastructure.internationalization.InternationalizationManager;
004:        import infrastructure.propertymanager.PropertyManager;
005:        import java.awt.event.ActionEvent;
006:        import java.awt.event.ActionListener;
007:        import java.util.ArrayList;
008:        import java.util.List;
009:        import javax.swing.*;
010:        import javax.swing.table.AbstractTableModel;
011:        import org.dbbrowser.db.engine.exception.DBEngineException;
012:        import org.dbbrowser.db.engine.model.ColumnInfo;
013:        import org.dbbrowser.db.engine.model.DBTable;
014:        import org.dbbrowser.ui.AddNewColumnWindow;
015:        import org.dbbrowser.ui.UIControllerForQueries;
016:        import org.dbbrowser.ui.UIControllerForUpdates;
017:        import org.dbbrowser.ui.panel.ButtonsPanel;
018:        import org.dbbrowser.ui.widget.Button;
019:        import org.dbbrowser.ui.widget.Table;
020:
021:        public class ColumnDetailsPanel extends JPanel implements 
022:                ActionListener {
023:            private static final long serialVersionUID = UIControllerForQueries.version;
024:
025:            private String addNewRecordIconFileName = PropertyManager
026:                    .getInstance()
027:                    .getProperty(
028:                            "dbbrowser-ui-dbbrowser-window-add-new-record-icon");
029:            private String deleteRecordIconFileName = PropertyManager
030:                    .getInstance().getProperty(
031:                            "dbbrowser-ui-dbbrowser-window-delete-record-icon");
032:
033:            private Icon iconForAddNewRecordButton = new ImageIcon(
034:                    addNewRecordIconFileName);
035:            private Icon iconForDeleteRecordButton = new ImageIcon(
036:                    deleteRecordIconFileName);
037:
038:            private static final String TITLE = InternationalizationManager
039:                    .getInstance().getMessage("dbbrowser-ui",
040:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
041:            private static final String ADD_NEW_COLUMN_BUTTON_LABEL = InternationalizationManager
042:                    .getInstance()
043:                    .getMessage(
044:                            "dbbrowser-ui",
045:                            "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-add-new-column-button-label",
046:                            null);;
047:            private static final String REMOVE_COLUMN_BUTTON_LABEL = InternationalizationManager
048:                    .getInstance()
049:                    .getMessage(
050:                            "dbbrowser-ui",
051:                            "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-remove-column-button-label",
052:                            null);;
053:
054:            private UIControllerForQueries uiControllerForQueries = null;
055:            private UIControllerForUpdates uiControllerForUpdates = null;
056:
057:            private List listOfColumnInfos = null;
058:            private Table tableForColumnInfos = null;
059:            private ButtonsPanel buttonsPanel = null;
060:
061:            private DBTable dbTableOfColumnDetails = null;
062:
063:            public ColumnDetailsPanel(
064:                    UIControllerForQueries uiControllerForQueries,
065:                    UIControllerForUpdates uiControllerForUpdates) {
066:                this .uiControllerForQueries = uiControllerForQueries;
067:                this .uiControllerForUpdates = uiControllerForUpdates;
068:            }
069:
070:            private void initialize() {
071:                //Set the table for data
072:                this .setLayout(new BoxLayout(this , BoxLayout.PAGE_AXIS));
073:
074:                //Add the table
075:                this .tableForColumnInfos = new Table(
076:                        this .uiControllerForQueries,
077:                        this .uiControllerForUpdates);
078:                this .add(tableForColumnInfos);
079:
080:                //Set the buttons panel
081:                Button addNewColumnButton = new Button(
082:                        ADD_NEW_COLUMN_BUTTON_LABEL, this ,
083:                        ADD_NEW_COLUMN_BUTTON_LABEL, iconForAddNewRecordButton,
084:                        Boolean.TRUE);
085:                Button removeColumnButton = new Button(
086:                        REMOVE_COLUMN_BUTTON_LABEL, this ,
087:                        REMOVE_COLUMN_BUTTON_LABEL, iconForDeleteRecordButton,
088:                        Boolean.FALSE);
089:                List listOfButtons = new ArrayList();
090:                listOfButtons.add(addNewColumnButton);
091:                listOfButtons.add(removeColumnButton);
092:                buttonsPanel = new ButtonsPanel(listOfButtons);
093:
094:                this .add(buttonsPanel);
095:            }
096:
097:            public void initializeTable(DBTable dbTableOfColumnDetails) {
098:                //If the buttons panel has not been set, set it up
099:                if (this .tableForColumnInfos == null) {
100:                    initialize();
101:                }
102:
103:                //Initialize table
104:                this .dbTableOfColumnDetails = dbTableOfColumnDetails;
105:
106:                //Set the title of the panel
107:                this .tableForColumnInfos.setBorder(BorderFactory
108:                        .createTitledBorder(dbTableOfColumnDetails
109:                                .getTableName()));
110:
111:                //Build the table
112:                this .listOfColumnInfos = dbTableOfColumnDetails
113:                        .getListOfColumnInfos();
114:                this .tableForColumnInfos
115:                        .initializeTable(new ColumnInfoTableModel());
116:            }
117:
118:            public void actionPerformed(ActionEvent e) {
119:                //Add a new column
120:                if (ADD_NEW_COLUMN_BUTTON_LABEL.equals(e.getActionCommand())) {
121:                    AddNewColumnWindow addNewColumnWindow = new AddNewColumnWindow(
122:                            this .uiControllerForUpdates,
123:                            this .dbTableOfColumnDetails);
124:                    addNewColumnWindow.show();
125:                }
126:
127:                //Remove the selected column
128:                if (REMOVE_COLUMN_BUTTON_LABEL.equals(e.getActionCommand())) {
129:                    if ((this .tableForColumnInfos.getSelectedRow() != null)
130:                            && (this .tableForColumnInfos.getSelectedRow()
131:                                    .intValue() != -1)) {
132:                        String removeColumnConfirmationMessage = InternationalizationManager
133:                                .getInstance()
134:                                .getMessage(
135:                                        "dbbrowser-ui",
136:                                        "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-remove-column-confirmation-message",
137:                                        null);
138:                        ;
139:                        int ans = JOptionPane.showConfirmDialog(null,
140:                                removeColumnConfirmationMessage, TITLE,
141:                                JOptionPane.OK_CANCEL_OPTION,
142:                                JOptionPane.QUESTION_MESSAGE);
143:
144:                        if (ans == 0) {
145:                            try {
146:                                //Get the selected column
147:                                int selectedRow = this .tableForColumnInfos
148:                                        .getSelectedRow().intValue();
149:
150:                                if (selectedRow != -1) {
151:                                    //Drop the column
152:                                    ColumnInfo ci = (ColumnInfo) this .listOfColumnInfos
153:                                            .get(selectedRow);
154:                                    this .uiControllerForUpdates.dropColumn(
155:                                            dbTableOfColumnDetails
156:                                                    .getSchemaName(),
157:                                            dbTableOfColumnDetails
158:                                                    .getTableName(), ci);
159:
160:                                    //Update the UI
161:                                    this .listOfColumnInfos
162:                                            .remove(this .tableForColumnInfos
163:                                                    .getSelectedRow());
164:                                    this .tableForColumnInfos.update();
165:                                }
166:                            } catch (DBEngineException exc) {
167:                                String errorMessage = InternationalizationManager
168:                                        .getInstance()
169:                                        .getMessage(
170:                                                "dbbrowser-ui",
171:                                                "dbbrowser-ui-dbbrowser-window-sql-failed",
172:                                                null);
173:                                JOptionPane
174:                                        .showMessageDialog(null, errorMessage
175:                                                + " - " + exc.getMessage(),
176:                                                TITLE,
177:                                                JOptionPane.ERROR_MESSAGE);
178:                            }
179:                        }
180:                    } else {
181:                        //No column has been selected
182:                        String errorMessage = InternationalizationManager
183:                                .getInstance()
184:                                .getMessage(
185:                                        "dbbrowser-ui",
186:                                        "dbbrowser-ui-dbbrowser-browser-tab-column-details-delete-column-no-column-selected-message",
187:                                        null);
188:                        JOptionPane.showMessageDialog(null, errorMessage,
189:                                TITLE, JOptionPane.ERROR_MESSAGE);
190:                    }
191:                }
192:            }
193:
194:            /**
195:             * Private class representing the model for columns in the table
196:             * @author amangat
197:             */
198:            private class ColumnInfoTableModel extends AbstractTableModel {
199:                private static final long serialVersionUID = 1l;
200:
201:                private String COLUMN_NULLABLE_LABEL = InternationalizationManager
202:                        .getInstance()
203:                        .getMessage(
204:                                "dbbrowser-ui",
205:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-nullable-true",
206:                                null);;
207:                private String COLUMN_NOT_NULLABLE_LABEL = InternationalizationManager
208:                        .getInstance()
209:                        .getMessage(
210:                                "dbbrowser-ui",
211:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-nullable-false",
212:                                null);;
213:                private String COLUMN_NULLABLE_NATURE_UNKNOWN = InternationalizationManager
214:                        .getInstance()
215:                        .getMessage(
216:                                "dbbrowser-ui",
217:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-nullable-unknown",
218:                                null);;
219:
220:                private String COLUMN_NAME_STRING_LABEL = InternationalizationManager
221:                        .getInstance()
222:                        .getMessage(
223:                                "dbbrowser-ui",
224:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-column-name",
225:                                null);;
226:                private String DATA_TYPE_STRING_LABEL = InternationalizationManager
227:                        .getInstance()
228:                        .getMessage(
229:                                "dbbrowser-ui",
230:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-data-type",
231:                                null);;
232:                private String COLUMN_SIZE_STRING_LABEL = InternationalizationManager
233:                        .getInstance()
234:                        .getMessage(
235:                                "dbbrowser-ui",
236:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-size",
237:                                null);;
238:                private String NULLABLE_STRING_LABEL = InternationalizationManager
239:                        .getInstance()
240:                        .getMessage(
241:                                "dbbrowser-ui",
242:                                "dbbrowser-ui-dbbrowser-browser-tab-column-details-panel-nullable",
243:                                null);;
244:
245:                private String[] listOfColumnInfoHeaders = new String[] {
246:                        "    ", COLUMN_NAME_STRING_LABEL,
247:                        DATA_TYPE_STRING_LABEL, COLUMN_SIZE_STRING_LABEL,
248:                        NULLABLE_STRING_LABEL };
249:
250:                public String getColumnName(int col) {
251:                    return listOfColumnInfoHeaders[col];
252:                }
253:
254:                public int getRowCount() {
255:                    return listOfColumnInfos.size();
256:                }
257:
258:                public int getColumnCount() {
259:                    return listOfColumnInfoHeaders.length;
260:                }
261:
262:                public Object getValueAt(int row, int col) {
263:                    String cellValue = null;
264:
265:                    if (col == 0) {
266:                        return "" + (row + 1);
267:                    } else {
268:                        ColumnInfo columnInfo = (ColumnInfo) listOfColumnInfos
269:                                .get(row);
270:
271:                        switch (col) {
272:                        case 1: {
273:                            cellValue = columnInfo.getColumnName();
274:                            break;
275:                        }
276:                        case 2: {
277:                            cellValue = columnInfo.getColumnTypeName();
278:                            break;
279:                        }
280:                        case 3: {
281:                            cellValue = columnInfo.getColumnDisplaySize()
282:                                    .intValue()
283:                                    + "";
284:                            break;
285:                        }
286:                        case 4: {
287:                            String nullableNature = columnInfo
288:                                    .getNullableNature();
289:                            if (ColumnInfo.COLUMN_NULLABLE
290:                                    .equals(nullableNature)) {
291:                                cellValue = COLUMN_NULLABLE_LABEL;
292:                            }
293:                            if (ColumnInfo.COLUMN_NOT_NULLABLE
294:                                    .equals(nullableNature)) {
295:                                cellValue = COLUMN_NOT_NULLABLE_LABEL;
296:                            }
297:                            if (ColumnInfo.COLUMN_NULLABLE_NATURE_UNKNOWN
298:                                    .equals(nullableNature)) {
299:                                cellValue = COLUMN_NULLABLE_NATURE_UNKNOWN;
300:                            }
301:
302:                            break;
303:                        }
304:                        }
305:                    }
306:
307:                    return cellValue;
308:                }
309:            }
310:
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.