Source Code Cross Referenced for BasePropertiesPanel.java in  » IDE-Netbeans » db » org » netbeans » modules » db » mysql » 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 » IDE Netbeans » db » org.netbeans.modules.db.mysql.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BasePropertiesPanel.java
003:         *
004:         * Created on February 15, 2008, 12:59 PM
005:         */
006:
007:        package org.netbeans.modules.db.mysql.ui;
008:
009:        import java.awt.Color;
010:        import java.awt.Dialog;
011:        import javax.swing.SwingUtilities;
012:        import javax.swing.UIManager;
013:        import javax.swing.event.DocumentListener;
014:        import org.netbeans.api.db.explorer.DatabaseException;
015:        import org.netbeans.modules.db.mysql.MySQLOptions;
016:        import org.netbeans.modules.db.mysql.ServerInstance;
017:        import org.netbeans.modules.db.mysql.ServerNodeProvider;
018:        import org.netbeans.modules.db.mysql.Utils;
019:        import org.openide.DialogDescriptor;
020:        import org.openide.DialogDisplayer;
021:        import org.openide.util.NbBundle;
022:
023:        /**
024:         *
025:         * @author  David Van Couvering
026:         */
027:        public class BasePropertiesPanel extends javax.swing.JPanel {
028:            MySQLOptions options = MySQLOptions.getDefault();
029:            DialogDescriptor descriptor;
030:            private Color nbErrorForeground;
031:
032:            private DocumentListener docListener = new DocumentListener() {
033:
034:                public void removeUpdate(javax.swing.event.DocumentEvent e) {
035:                    validatePanel();
036:                }
037:
038:                public void insertUpdate(javax.swing.event.DocumentEvent e) {
039:                    validatePanel();
040:                }
041:
042:                public void changedUpdate(javax.swing.event.DocumentEvent e) {
043:                    validatePanel();
044:                }
045:
046:            };
047:
048:            public void validatePanel() {
049:                if (descriptor == null) {
050:                    return;
051:                }
052:
053:                String error = null;
054:
055:                if (getHost() == null || getHost().equals("")) {
056:                    error = NbBundle.getMessage(BasePropertiesPanel.class,
057:                            "BasePropertiesPanel.MSG_SpecifyHost");
058:                }
059:                if (getUser() == null || getUser().equals("")) {
060:                    error = NbBundle.getMessage(BasePropertiesPanel.class,
061:                            "BasePropertiesPanel.MSG_SpecifyUser");
062:                }
063:
064:                if (error != null) {
065:                    messageLabel.setText(error);
066:                    descriptor.setValid(false);
067:                } else {
068:                    messageLabel.setText(" "); // NOI18N
069:                    descriptor.setValid(true);
070:                }
071:            }
072:
073:            /** Creates new form BasePropertiesPanel */
074:            public BasePropertiesPanel(ServerInstance server) {
075:                nbErrorForeground = UIManager.getColor("nb.errorForeground"); //NOI18N
076:                if (nbErrorForeground == null) {
077:                    //nbErrorForeground = new Color(89, 79, 191); // RGB suggested by Bruce in #28466
078:                    nbErrorForeground = new Color(255, 0, 0); // RGB suggested by jdinga in #65358
079:                }
080:
081:                initComponents();
082:                this .setBackground(getBackground());
083:                messageLabel.setBackground(getBackground());
084:
085:                txtUser.getDocument().addDocumentListener(docListener);
086:                txtHost.getDocument().addDocumentListener(docListener);
087:
088:                String user = server.getUser();
089:                if (user == null || user.equals("")) {
090:                    user = MySQLOptions.getDefaultAdminUser();
091:                }
092:                txtUser.setText(user);
093:
094:                String host = server.getHost();
095:                if (host == null || host.equals("")) {
096:                    host = MySQLOptions.getDefaultHost();
097:                }
098:                txtHost.setText(host);
099:
100:                String port = server.getPort();
101:                if (port == null || port.equals("")) {
102:                    port = MySQLOptions.getDefaultPort();
103:                }
104:                txtPort.setText(port);
105:
106:                txtPassword.setText(server.getPassword());
107:                chkSavePassword.setSelected(server.isSavePassword());
108:            }
109:
110:            String getHost() {
111:                return txtHost.getText().trim();
112:            }
113:
114:            String getPassword() {
115:                return new String(txtPassword.getPassword()).trim();
116:            }
117:
118:            String getPort() {
119:                return txtPort.getText().trim();
120:            }
121:
122:            String getUser() {
123:                return txtUser.getText().trim();
124:            }
125:
126:            boolean getSavePassword() {
127:                return chkSavePassword.isSelected();
128:            }
129:
130:            void setDialogDescriptor(DialogDescriptor desc) {
131:                this .descriptor = desc;
132:                validatePanel();
133:            }
134:
135:            /** This method is called from within the constructor to
136:             * initialize the form.
137:             * WARNING: Do NOT modify this code. The content of this method is
138:             * always regenerated by the Form Editor.
139:             */
140:            @SuppressWarnings("unchecked")
141:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
142:            private void initComponents() {
143:
144:                jLabel1 = new javax.swing.JLabel();
145:                jLabel2 = new javax.swing.JLabel();
146:                jLabel3 = new javax.swing.JLabel();
147:                jLabel4 = new javax.swing.JLabel();
148:                chkSavePassword = new javax.swing.JCheckBox();
149:                txtHost = new javax.swing.JTextField();
150:                txtPort = new javax.swing.JTextField();
151:                txtUser = new javax.swing.JTextField();
152:                txtPassword = new javax.swing.JPasswordField();
153:                messageLabel = new javax.swing.JLabel();
154:
155:                setAutoscrolls(true);
156:
157:                jLabel1.setLabelFor(txtHost);
158:                jLabel1.setText(org.openide.util.NbBundle.getMessage(
159:                        BasePropertiesPanel.class,
160:                        "BasePropertiesPanel.jLabel1.text")); // NOI18N
161:
162:                jLabel2.setLabelFor(txtPort);
163:                jLabel2.setText(org.openide.util.NbBundle.getMessage(
164:                        BasePropertiesPanel.class,
165:                        "BasePropertiesPanel.jLabel2.text")); // NOI18N
166:
167:                jLabel3.setLabelFor(txtUser);
168:                jLabel3.setText(org.openide.util.NbBundle.getMessage(
169:                        BasePropertiesPanel.class,
170:                        "BasePropertiesPanel.jLabel3.text")); // NOI18N
171:
172:                jLabel4.setLabelFor(txtPassword);
173:                jLabel4.setText(org.openide.util.NbBundle.getMessage(
174:                        BasePropertiesPanel.class,
175:                        "BasePropertiesPanel.jLabel4.text")); // NOI18N
176:
177:                chkSavePassword.setText(org.openide.util.NbBundle.getMessage(
178:                        BasePropertiesPanel.class,
179:                        "BasePropertiesPanel.chkSavePassword.text")); // NOI18N
180:
181:                txtHost.setText(org.openide.util.NbBundle.getMessage(
182:                        BasePropertiesPanel.class,
183:                        "BasePropertiesPanel.txtHost.text")); // NOI18N
184:                txtHost.addActionListener(new java.awt.event.ActionListener() {
185:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
186:                        txtHostActionPerformed(evt);
187:                    }
188:                });
189:
190:                txtPort.setText(org.openide.util.NbBundle.getMessage(
191:                        BasePropertiesPanel.class,
192:                        "BasePropertiesPanel.txtPort.text")); // NOI18N
193:
194:                txtUser.setText(org.openide.util.NbBundle.getMessage(
195:                        BasePropertiesPanel.class,
196:                        "BasePropertiesPanel.txtUser.text")); // NOI18N
197:
198:                messageLabel.setForeground(new java.awt.Color(255, 0, 51));
199:                messageLabel.setText(org.openide.util.NbBundle.getMessage(
200:                        BasePropertiesPanel.class,
201:                        "BasePropertiesPanel.messageLabel.text")); // NOI18N
202:
203:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
204:                        this );
205:                this .setLayout(layout);
206:                layout
207:                        .setHorizontalGroup(layout
208:                                .createParallelGroup(
209:                                        org.jdesktop.layout.GroupLayout.LEADING)
210:                                .add(
211:                                        layout
212:                                                .createSequentialGroup()
213:                                                .add(
214:                                                        layout
215:                                                                .createParallelGroup(
216:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
217:                                                                .add(
218:                                                                        layout
219:                                                                                .createSequentialGroup()
220:                                                                                .add(
221:                                                                                        52,
222:                                                                                        52,
223:                                                                                        52)
224:                                                                                .add(
225:                                                                                        chkSavePassword))
226:                                                                .add(
227:                                                                        layout
228:                                                                                .createSequentialGroup()
229:                                                                                .addContainerGap()
230:                                                                                .add(
231:                                                                                        layout
232:                                                                                                .createParallelGroup(
233:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
234:                                                                                                .add(
235:                                                                                                        jLabel1)
236:                                                                                                .add(
237:                                                                                                        jLabel2)
238:                                                                                                .add(
239:                                                                                                        jLabel3)
240:                                                                                                .add(
241:                                                                                                        jLabel4))
242:                                                                                .addPreferredGap(
243:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
244:                                                                                .add(
245:                                                                                        layout
246:                                                                                                .createParallelGroup(
247:                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING)
248:                                                                                                .add(
249:                                                                                                        txtPassword,
250:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
251:                                                                                                        216,
252:                                                                                                        Short.MAX_VALUE)
253:                                                                                                .add(
254:                                                                                                        txtHost,
255:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
256:                                                                                                        216,
257:                                                                                                        Short.MAX_VALUE)
258:                                                                                                .add(
259:                                                                                                        txtPort,
260:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
261:                                                                                                        216,
262:                                                                                                        Short.MAX_VALUE)
263:                                                                                                .add(
264:                                                                                                        txtUser,
265:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
266:                                                                                                        216,
267:                                                                                                        Short.MAX_VALUE)))
268:                                                                .add(
269:                                                                        layout
270:                                                                                .createSequentialGroup()
271:                                                                                .addContainerGap()
272:                                                                                .add(
273:                                                                                        messageLabel,
274:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
275:                                                                                        386,
276:                                                                                        Short.MAX_VALUE)))
277:                                                .addContainerGap()));
278:                layout
279:                        .setVerticalGroup(layout
280:                                .createParallelGroup(
281:                                        org.jdesktop.layout.GroupLayout.LEADING)
282:                                .add(
283:                                        layout
284:                                                .createSequentialGroup()
285:                                                .addContainerGap()
286:                                                .add(
287:                                                        layout
288:                                                                .createParallelGroup(
289:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
290:                                                                .add(
291:                                                                        layout
292:                                                                                .createSequentialGroup()
293:                                                                                .add(
294:                                                                                        jLabel1)
295:                                                                                .addPreferredGap(
296:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
297:                                                                                .add(
298:                                                                                        jLabel2)
299:                                                                                .add(
300:                                                                                        11,
301:                                                                                        11,
302:                                                                                        11)
303:                                                                                .add(
304:                                                                                        jLabel3))
305:                                                                .add(
306:                                                                        layout
307:                                                                                .createSequentialGroup()
308:                                                                                .addPreferredGap(
309:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
310:                                                                                .add(
311:                                                                                        txtHost,
312:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
313:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
314:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
315:                                                                                .addPreferredGap(
316:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
317:                                                                                .add(
318:                                                                                        txtPort,
319:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
320:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
321:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
322:                                                                                .addPreferredGap(
323:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
324:                                                                                .add(
325:                                                                                        txtUser,
326:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
327:                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
328:                                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
329:                                                .addPreferredGap(
330:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
331:                                                .add(
332:                                                        layout
333:                                                                .createParallelGroup(
334:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
335:                                                                .add(jLabel4)
336:                                                                .add(
337:                                                                        txtPassword,
338:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
339:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
340:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
341:                                                .addPreferredGap(
342:                                                        org.jdesktop.layout.LayoutStyle.UNRELATED)
343:                                                .add(chkSavePassword)
344:                                                .addPreferredGap(
345:                                                        org.jdesktop.layout.LayoutStyle.UNRELATED)
346:                                                .add(messageLabel)
347:                                                .addContainerGap(
348:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
349:                                                        Short.MAX_VALUE)));
350:
351:                layout.linkSize(new java.awt.Component[] { jLabel1, jLabel2,
352:                        jLabel3, jLabel4, txtHost, txtPort, txtUser },
353:                        org.jdesktop.layout.GroupLayout.VERTICAL);
354:
355:            }// </editor-fold>//GEN-END:initComponents
356:
357:            private void txtHostActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtHostActionPerformed
358:            // TODO add your handling code here:
359:            }//GEN-LAST:event_txtHostActionPerformed
360:
361:            // Variables declaration - do not modify//GEN-BEGIN:variables
362:            private javax.swing.JCheckBox chkSavePassword;
363:            private javax.swing.JLabel jLabel1;
364:            private javax.swing.JLabel jLabel2;
365:            private javax.swing.JLabel jLabel3;
366:            private javax.swing.JLabel jLabel4;
367:            private javax.swing.JLabel messageLabel;
368:            private javax.swing.JTextField txtHost;
369:            private javax.swing.JPasswordField txtPassword;
370:            private javax.swing.JTextField txtPort;
371:            private javax.swing.JTextField txtUser;
372:            // End of variables declaration//GEN-END:variables
373:
374:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.