Source Code Cross Referenced for DBConstraintsPanel.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.logging.Log;
005:        import infrastructure.propertymanager.PropertyManager;
006:
007:        import java.awt.BorderLayout;
008:        import java.awt.Component;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.event.ActionListener;
011:        import java.util.ArrayList;
012:        import java.util.List;
013:        import javax.swing.BoxLayout;
014:        import javax.swing.Icon;
015:        import javax.swing.ImageIcon;
016:        import javax.swing.JLabel;
017:        import javax.swing.JOptionPane;
018:        import javax.swing.JPanel;
019:        import javax.swing.JTabbedPane;
020:        import javax.swing.SwingConstants;
021:        import javax.swing.event.ChangeEvent;
022:        import javax.swing.event.ChangeListener;
023:        import org.dbbrowser.db.engine.exception.DBEngineException;
024:        import org.dbbrowser.db.engine.model.DBTable;
025:        import org.dbbrowser.drivermanager.ConnectionInfo;
026:        import org.dbbrowser.ui.UIControllerForQueries;
027:        import org.dbbrowser.ui.UIControllerForUpdates;
028:        import org.dbbrowser.ui.helper.DBTableDataTableModel;
029:        import org.dbbrowser.ui.panel.ButtonsPanel;
030:        import org.dbbrowser.ui.widget.Button;
031:        import org.dbbrowser.ui.widget.Table;
032:
033:        public class DBConstraintsPanel extends JPanel implements 
034:                ActionListener, ChangeListener {
035:            private static final long serialVersionUID = UIControllerForQueries.version;
036:
037:            private String addNewRecordIconFileName = PropertyManager
038:                    .getInstance()
039:                    .getProperty(
040:                            "dbbrowser-ui-dbbrowser-window-add-new-record-icon");
041:            private String deleteRecordIconFileName = PropertyManager
042:                    .getInstance().getProperty(
043:                            "dbbrowser-ui-dbbrowser-window-delete-record-icon");
044:
045:            private Icon iconForAddNewRecordButton = new ImageIcon(
046:                    addNewRecordIconFileName);
047:            private Icon iconForDeleteRecordButton = new ImageIcon(
048:                    deleteRecordIconFileName);
049:
050:            private static final String TITLE = InternationalizationManager
051:                    .getInstance().getMessage("dbbrowser-ui",
052:                            "dbbrowser-ui-dbbrowser-window-title-label", null);;
053:            private static final String ADD_NEW_CONSTRAINT_BUTTON_LABEL = InternationalizationManager
054:                    .getInstance()
055:                    .getMessage(
056:                            "dbbrowser-ui",
057:                            "dbbrowser-ui-dbbrowser-constraints-tab-add-new-constraint-button-label",
058:                            null);;
059:            private static final String REMOVE_CONSTRAINT_BUTTON_LABEL = InternationalizationManager
060:                    .getInstance()
061:                    .getMessage(
062:                            "dbbrowser-ui",
063:                            "dbbrowser-ui-dbbrowser-constraints-tab-remove-constraint-button-label",
064:                            null);;
065:
066:            private UIControllerForQueries uiControllerForQueries = null;
067:            private UIControllerForUpdates uiControllerForUpdates = null;
068:
069:            private Table tableForConstraints = null;
070:            private ButtonsPanel buttonsPanel = null;
071:
072:            private boolean constraintsSetupCompleted = false;
073:
074:            public DBConstraintsPanel(
075:                    UIControllerForQueries uiControllerForQueries,
076:                    UIControllerForUpdates uiControllerForUpdates) {
077:                this .uiControllerForQueries = uiControllerForQueries;
078:                this .uiControllerForUpdates = uiControllerForUpdates;
079:                initialize();
080:            }
081:
082:            public void refresh() {
083:                showConstraints();
084:            }
085:
086:            public void stateChanged(ChangeEvent e) {
087:                //Setup indexes only if this panel has been selected
088:                Object source = e.getSource();
089:                if ((source != null) && (source instanceof  JTabbedPane)) {
090:                    //Get the selected tab
091:                    JTabbedPane pane = (JTabbedPane) source;
092:                    Component selectedComponent = pane.getSelectedComponent();
093:                    if ((selectedComponent != null)
094:                            && (selectedComponent instanceof  DBConstraintsPanel)) {
095:                        //If indexes have not been retrieved, retrieve them and cache them
096:                        if (!constraintsSetupCompleted) {
097:                            showConstraints();
098:                        }
099:                    }
100:                }
101:            }
102:
103:            private void showConstraints() {
104:                try {
105:                    //Remove existing panels
106:                    if (this .tableForConstraints != null) {
107:                        this .remove(this .tableForConstraints);
108:                        this .remove(this .buttonsPanel);
109:                    }
110:
111:                    DBTable dbTableOfConstraints = this .uiControllerForQueries
112:                            .listConstraints();
113:
114:                    //Add the table
115:                    this .tableForConstraints = new Table(
116:                            this .uiControllerForQueries,
117:                            this .uiControllerForUpdates);
118:                    this .add(tableForConstraints);
119:
120:                    //Set the buttons panel
121:                    Button addNewIndexButton = new Button(
122:                            ADD_NEW_CONSTRAINT_BUTTON_LABEL, this ,
123:                            ADD_NEW_CONSTRAINT_BUTTON_LABEL,
124:                            iconForAddNewRecordButton, Boolean.TRUE);
125:                    Button removeIndexButton = new Button(
126:                            REMOVE_CONSTRAINT_BUTTON_LABEL, this ,
127:                            REMOVE_CONSTRAINT_BUTTON_LABEL,
128:                            iconForDeleteRecordButton, Boolean.FALSE);
129:                    List listOfButtons = new ArrayList();
130:                    listOfButtons.add(addNewIndexButton);
131:                    listOfButtons.add(removeIndexButton);
132:                    buttonsPanel = new ButtonsPanel(listOfButtons);
133:
134:                    this .add(buttonsPanel);
135:
136:                    //Initialize table
137:                    this .initializeTable(dbTableOfConstraints);
138:                    this .constraintsSetupCompleted = true;
139:                } catch (DBEngineException exc) {
140:                    Log.getInstance()
141:                            .fatalMessage(
142:                                    exc.getClass().getName() + " - "
143:                                            + exc.getMessage(),
144:                                    BrowserPanel.class.getName());
145:                    String sqlFailedLabel = InternationalizationManager
146:                            .getInstance().getMessage("dbbrowser-ui",
147:                                    "dbbrowser-ui-dbbrowser-window-sql-failed",
148:                                    null);
149:                    JOptionPane.showMessageDialog(null, sqlFailedLabel + " - "
150:                            + exc.getMessage(), TITLE,
151:                            JOptionPane.ERROR_MESSAGE);
152:                } catch (UnsupportedOperationException exc) {
153:                    ConnectionInfo ci = this .uiControllerForQueries
154:                            .getConnectionInfo();
155:                    String[] dbmsTypes = new String[] { ci.getDBMSType() };
156:                    String featureSupportedByDBMSLabel = InternationalizationManager
157:                            .getInstance()
158:                            .getMessage(
159:                                    "dbbrowser-ui",
160:                                    "dbbrowser-ui-dbbrowser-feature-not-supported-error-message",
161:                                    dbmsTypes);
162:                    JLabel label = new JLabel(featureSupportedByDBMSLabel);
163:                    label.setHorizontalAlignment(SwingConstants.CENTER);
164:                    this .setLayout(new BorderLayout());
165:                    this .add(label);
166:                }
167:            }
168:
169:            private void initialize() {
170:                //Set the table for data
171:                this .setLayout(new BoxLayout(this , BoxLayout.PAGE_AXIS));
172:            }
173:
174:            public void initializeTable(DBTable dbTableOfSequences) {
175:                this .tableForConstraints
176:                        .initializeTable(new DBTableDataTableModel(
177:                                dbTableOfSequences));
178:            }
179:
180:            public void actionPerformed(ActionEvent e) {
181:                //Add a new constraint
182:                if (ADD_NEW_CONSTRAINT_BUTTON_LABEL
183:                        .equals(e.getActionCommand())) {
184:                    String UNIMPLEMENTED_FEATURE_MESSAGE = InternationalizationManager
185:                            .getInstance()
186:                            .getMessage(
187:                                    "dbbrowser-ui",
188:                                    "dbbrowser-ui-dbbrowser-unimplemented-feature",
189:                                    null);
190:                    JOptionPane.showMessageDialog(null,
191:                            UNIMPLEMENTED_FEATURE_MESSAGE, TITLE,
192:                            JOptionPane.INFORMATION_MESSAGE);
193:                }
194:
195:                //Remove the selected constraint
196:                if (REMOVE_CONSTRAINT_BUTTON_LABEL.equals(e.getActionCommand())) {
197:                    String UNIMPLEMENTED_FEATURE_MESSAGE = InternationalizationManager
198:                            .getInstance()
199:                            .getMessage(
200:                                    "dbbrowser-ui",
201:                                    "dbbrowser-ui-dbbrowser-unimplemented-feature",
202:                                    null);
203:                    JOptionPane.showMessageDialog(null,
204:                            UNIMPLEMENTED_FEATURE_MESSAGE, TITLE,
205:                            JOptionPane.INFORMATION_MESSAGE);
206:                }
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.