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


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 2004-2005 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.jmx.mbeanwizard;
042:
043:        import javax.swing.JPanel;
044:        import javax.swing.JScrollPane;
045:        import javax.swing.JButton;
046:        import java.awt.BorderLayout;
047:        import java.awt.FlowLayout;
048:        import java.util.ResourceBundle;
049:        import org.openide.util.NbBundle;
050:        import org.netbeans.modules.jmx.WizardConstants;
051:        import org.netbeans.modules.jmx.GenericWizardPanel;
052:
053:        import org.openide.WizardDescriptor;
054:        import org.openide.util.HelpCtx;
055:
056:        import java.awt.Component;
057:        import javax.swing.JCheckBox;
058:        import javax.swing.JLabel;
059:        import javax.swing.event.*;
060:
061:        import org.netbeans.modules.jmx.mbeanwizard.listener.AddTableRowListener;
062:        import org.netbeans.modules.jmx.mbeanwizard.listener.RemTableRowListener;
063:        import org.netbeans.modules.jmx.MBeanNotification;
064:
065:        import org.netbeans.modules.jmx.mbeanwizard.tablemodel.MBeanNotificationTableModel;
066:        import org.openide.awt.Mnemonics;
067:        import org.netbeans.modules.jmx.mbeanwizard.table.NotificationTable;
068:
069:        /**
070:         *
071:         * MBean notification panel class: Manages the notifications the user wants the
072:         * mbean to emit
073:         *
074:         */
075:        public class MBeanNotificationPanel extends JPanel {
076:            private boolean DEBUG = false;
077:
078:            private NotificationTable notificationTable;
079:            private MBeanNotificationTableModel notificationModel;
080:            private NotificationsWizardPanel wiz;
081:
082:            private JCheckBox implNotifEmitCheckBox;
083:            private JCheckBox genDelegationCheckBox;
084:            private JCheckBox genSeqNbCheckBox;
085:            private JLabel notifTableLabel;
086:            private JButton notifAddJButton;
087:            private JButton notifRemJButton;
088:
089:            private JPanel ancestorPanel = null;
090:
091:            private ResourceBundle bundle;
092:
093:            /**
094:             * MBean Notification Panel constructor
095:             * @param wiz a wizard panel
096:             */
097:            public MBeanNotificationPanel(NotificationsWizardPanel wiz) {
098:                super (new BorderLayout());
099:                this .wiz = wiz;
100:
101:                this .ancestorPanel = this ;
102:
103:                bundle = NbBundle.getBundle(MBeanNotificationPanel.class);
104:
105:                initComponents();
106:
107:                // set names
108:                implNotifEmitCheckBox.setName("implNotifEmitCheckBox");
109:                genDelegationCheckBox.setName("genDelegationCheckBox");
110:                genSeqNbCheckBox.setName("genSeqNbCheckBox");
111:
112:                String str = bundle.getString("LBL_Notification_Panel");// NOI18N
113:                setName(str);
114:
115:                //init state
116:                updateState();
117:
118:                getAccessibleContext().setAccessibleDescription(
119:                        bundle.getString("ACCESS_PANEL"));// NOI18N
120:            }
121:
122:            private void initJTable() {
123:
124:                notificationModel = new MBeanNotificationTableModel();
125:                notificationTable = new NotificationTable(ancestorPanel,
126:                        notificationModel);
127:                notificationTable.setName("notificationTable");// NOI18N
128:            }
129:
130:            void updateState() {
131:                boolean implSelected = implNotifEmitCheckBox.isSelected();
132:                genDelegationCheckBox.setEnabled(implSelected);
133:                genSeqNbCheckBox.setEnabled(implSelected);
134:                notifTableLabel.setEnabled(implSelected);
135:                notificationTable.setEnabled(implSelected);
136:                notifAddJButton.setEnabled(implSelected);
137:                if (implSelected && (notificationModel.getRowCount() > 0))
138:                    notifRemJButton.setEnabled(true);
139:                else if (!implSelected) {
140:                    notifRemJButton.setEnabled(false);
141:                    if (notificationTable.isEditing())
142:                        notificationTable.getCellEditor().stopCellEditing();
143:                }
144:            }
145:
146:            private JPanel initSelectionPanel() {
147:                java.awt.GridBagConstraints gridBagConstraints;
148:
149:                implNotifEmitCheckBox = new JCheckBox();
150:                genDelegationCheckBox = new JCheckBox();
151:                genSeqNbCheckBox = new JCheckBox();
152:                notifTableLabel = new JLabel();
153:                JPanel selectionPanel = new JPanel();
154:
155:                selectionPanel.setLayout(new java.awt.GridBagLayout());
156:
157:                implNotifEmitCheckBox
158:                        .addActionListener(new java.awt.event.ActionListener() {
159:                            public void actionPerformed(
160:                                    java.awt.event.ActionEvent evt) {
161:                                updateState();
162:                            }
163:                        });
164:
165:                gridBagConstraints = new java.awt.GridBagConstraints();
166:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
167:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
168:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
169:                gridBagConstraints.weightx = 1.0;
170:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 0);
171:                selectionPanel.add(implNotifEmitCheckBox, gridBagConstraints);
172:
173:                gridBagConstraints = new java.awt.GridBagConstraints();
174:                gridBagConstraints.gridx = 0;
175:                gridBagConstraints.gridy = 1;
176:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
177:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
178:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
179:                gridBagConstraints.weightx = 1.0;
180:                gridBagConstraints.insets = new java.awt.Insets(5, 21, 0, 0);
181:                selectionPanel.add(genDelegationCheckBox, gridBagConstraints);
182:
183:                gridBagConstraints = new java.awt.GridBagConstraints();
184:                gridBagConstraints.gridx = 0;
185:                gridBagConstraints.gridy = 2;
186:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
187:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
188:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
189:                gridBagConstraints.weightx = 1.0;
190:                gridBagConstraints.insets = new java.awt.Insets(5, 21, 0, 0);
191:                selectionPanel.add(genSeqNbCheckBox, gridBagConstraints);
192:
193:                gridBagConstraints = new java.awt.GridBagConstraints();
194:                gridBagConstraints.gridx = 0;
195:                gridBagConstraints.gridy = 3;
196:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
197:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
198:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
199:                gridBagConstraints.weightx = 1.0;
200:                gridBagConstraints.insets = new java.awt.Insets(11, 0, 5, 0);
201:                selectionPanel.add(notifTableLabel, gridBagConstraints);
202:                notifTableLabel.setLabelFor(notificationTable);
203:
204:                return selectionPanel;
205:            }
206:
207:            private void initComponents() {
208:                initJTable();
209:                JPanel selectionPanel = initSelectionPanel();
210:
211:                Mnemonics.setLocalizedText(implNotifEmitCheckBox, bundle
212:                        .getString("LBL_ImplementNotifEmitter"));//NOI18N
213:                Mnemonics.setLocalizedText(genDelegationCheckBox, bundle
214:                        .getString("LBL_GenBroadcasterDelegation"));//NOI18N
215:                Mnemonics.setLocalizedText(genSeqNbCheckBox, bundle
216:                        .getString("LBL_GenSeqNumberField"));//NOI18N
217:                Mnemonics.setLocalizedText(notifTableLabel, bundle
218:                        .getString("LBL_Notifications"));//NOI18N
219:
220:                // defines a scrolol panel for the JTabel
221:                JScrollPane notifJTableScrollPanel = new JScrollPane(
222:                        notificationTable);
223:
224:                notifAddJButton = new JButton();
225:                Mnemonics.setLocalizedText(notifAddJButton, bundle
226:                        .getString("BUTTON_add_notification"));//NOI18N
227:                notifRemJButton = new JButton();
228:                Mnemonics.setLocalizedText(notifRemJButton, bundle
229:                        .getString("BUTTON_rem_notification"));//NOI18N
230:
231:                notifAddJButton.setName("notifAddJButton");// NOI18N
232:                notifRemJButton.setName("notifRemJButton");// NOI18N
233:
234:                //remove button should first be disabled
235:                notifRemJButton.setEnabled(false);
236:
237:                notifAddJButton.addActionListener(new AddTableRowListener(
238:                        notificationTable, notificationModel, notifRemJButton));
239:                notifRemJButton.addActionListener(new RemTableRowListener(
240:                        notificationTable, notificationModel, notifRemJButton));
241:
242:                // adds the buttons to this panel
243:                JPanel notifJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
244:                notifJPanel.add(notifAddJButton);
245:                notifJPanel.add(notifRemJButton);
246:
247:                add(selectionPanel, BorderLayout.NORTH);
248:                add(notifJTableScrollPanel, BorderLayout.CENTER);
249:                add(notifJPanel, BorderLayout.SOUTH);
250:
251:                //Accessibility
252:                implNotifEmitCheckBox.getAccessibleContext().setAccessibleName(
253:                        bundle.getString("ACCESS_IMPL_NOTIF_EMITTER")); // NOI18N
254:                implNotifEmitCheckBox
255:                        .getAccessibleContext()
256:                        .setAccessibleDescription(
257:                                bundle
258:                                        .getString("ACCESS_IMPL_NOTIF_EMITTER_DESCRIPTION")); // NOI18N
259:                genDelegationCheckBox.getAccessibleContext().setAccessibleName(
260:                        bundle.getString("ACCESS_GEN_DELEG_BROADCAST")); // NOI18N
261:                genDelegationCheckBox
262:                        .getAccessibleContext()
263:                        .setAccessibleDescription(
264:                                bundle
265:                                        .getString("ACCESS_GEN_DELEG_BROADCAST_DESCRIPTION")); // NOI18N
266:                genSeqNbCheckBox.getAccessibleContext().setAccessibleName(
267:                        bundle.getString("ACCESS_GEN_SEQ_NUMBER")); // NOI18N
268:                genSeqNbCheckBox
269:                        .getAccessibleContext()
270:                        .setAccessibleDescription(
271:                                bundle
272:                                        .getString("ACCESS_GEN_SEQ_NUMBER_DESCRIPTION")); // NOI18N
273:                notifRemJButton.getAccessibleContext().setAccessibleName(
274:                        bundle.getString("ACCESS_REMOVE_NOTIFICATION")); // NOI18N
275:                notifRemJButton
276:                        .getAccessibleContext()
277:                        .setAccessibleDescription(
278:                                bundle
279:                                        .getString("ACCESS_REMOVE_NOTIFICATION_DESCRIPTION"));// NOI18N
280:                notifAddJButton.getAccessibleContext().setAccessibleName(
281:                        bundle.getString("ACCESS_ADD_NOTIFICATION"));// NOI18N
282:                notifAddJButton
283:                        .getAccessibleContext()
284:                        .setAccessibleDescription(
285:                                bundle
286:                                        .getString("ACCESS_ADD_NOTIFICATION_DESCRIPTION"));// NOI18N
287:                notificationTable.getAccessibleContext().setAccessibleName(
288:                        bundle.getString("ACCESS_NOTIFICATION_TABLE"));// NOI18N
289:                notificationTable
290:                        .getAccessibleContext()
291:                        .setAccessibleDescription(
292:                                bundle
293:                                        .getString("ACCESS_NOTIFICATION_TABLE_DESCRIPTION"));// NOI18N
294:
295:            }
296:
297:            /**
298:             * Returns the notification table model
299:             * @return MBeanNotificationTableModel
300:             */
301:            public MBeanNotificationTableModel getNotificationModel() {
302:                return notificationModel;
303:            }
304:
305:            /**
306:             * Method which sets the default type value to the notification type
307:             * @param defaultTypeValue the default value to set
308:             */
309:            public void setDefaultTypeValue(String defaultTypeValue) {
310:                notificationModel.setDefaultTypeValue(defaultTypeValue);
311:            }
312:
313:            /**
314:             * The inner class which defines the wizard panel
315:             * descriptor with user data
316:             */
317:            public static class NotificationsWizardPanel extends
318:                    GenericWizardPanel implements 
319:                    org.openide.WizardDescriptor.FinishablePanel {
320:                private MBeanNotificationPanel panel = null;
321:
322:                /**
323:                 * Implementation of the FinishablePanel Interface; provides the Finish
324:                 * Button to be always enabled
325:                 * @return finish true if the panel can be the last one and enables 
326:                 * the finish button
327:                 */
328:                public boolean isFinishPanel() {
329:                    return true;
330:                }
331:
332:                /**
333:                 * Method returning the corresponding panel; here the 
334:                 * MBeanNotificationPanel
335:                 * @return Component the panel
336:                 */
337:                public Component getComponent() {
338:                    return getPanel();
339:                }
340:
341:                private MBeanNotificationPanel getPanel() {
342:                    if (panel == null) {
343:                        panel = new MBeanNotificationPanel(this );
344:                    }
345:
346:                    return panel;
347:                }
348:
349:                /**
350:                 * Method which reads the in the model already contained data
351:                 * @param settings an object containing the contents of the 
352:                 * notification table
353:                 */
354:                public void readSettings(Object settings) {
355:                    WizardDescriptor wiz = (WizardDescriptor) settings;
356:                    String mbeanName = (String) wiz
357:                            .getProperty(WizardConstants.PROP_MBEAN_NAME);
358:                    String mbeanPackageName = (String) wiz
359:                            .getProperty(WizardConstants.PROP_MBEAN_PACKAGE_NAME);
360:                    String defaultTypeValue = "";// NOI18N
361:                    if ((mbeanPackageName != null) && (mbeanName != null)) {
362:                        if (mbeanPackageName.equals("")) {// NOI18N
363:                            defaultTypeValue = mbeanName + "." + "type";// NOI18N
364:                        } else {
365:                            defaultTypeValue = mbeanPackageName + "."
366:                                    + mbeanName + "."// NOI18N
367:                                    + "type";// NOI18N
368:                        }
369:                    }
370:                    defaultTypeValue = defaultTypeValue.toLowerCase();
371:                    getPanel().setDefaultTypeValue(defaultTypeValue);
372:
373:                    // update state
374:                    Boolean implNotifEmit = (Boolean) wiz
375:                            .getProperty(WizardConstants.PROP_IMPL_NOTIF_EMITTER);
376:                    if (implNotifEmit == null)
377:                        implNotifEmit = false;
378:                    getPanel().setImplNotifEmit(implNotifEmit);
379:                    Boolean genBroadDeleg = (Boolean) wiz
380:                            .getProperty(WizardConstants.PROP_GEN_BROADCAST_DELEGATION);
381:                    if (genBroadDeleg == null)
382:                        genBroadDeleg = false;
383:                    getPanel().setGenBroadcasterDelegation(genBroadDeleg);
384:                    Boolean genSeqNumber = (Boolean) wiz
385:                            .getProperty(WizardConstants.PROP_GEN_SEQ_NUMBER);
386:                    if (genSeqNumber == null)
387:                        genSeqNumber = false;
388:                    getPanel().setGenSeqNb(genSeqNumber);
389:                    getPanel().updateState();
390:                }
391:
392:                /**
393:                 * Method called to store information from the GUI into the wizard map
394:                 * @param settings the object containing the data to store
395:                 */
396:                public void storeSettings(Object settings) {
397:                    WizardDescriptor wiz = (WizardDescriptor) settings;
398:
399:                    //stores all values from the table in the model even with keyboard
400:                    //navigation
401:                    //the if block avoids the problem that the last entry is not taken
402:                    //i.e we only do that if we are on the description TEXT field, not 
403:                    //on the popup cell
404:                    if (getPanel().notificationTable.getEditingColumn() == MBeanNotificationTableModel.IDX_NOTIF_DESCRIPTION)
405:                        getPanel().notificationTable
406:                                .editingStopped(new ChangeEvent(this ));
407:
408:                    wiz.putProperty(WizardConstants.PROP_IMPL_NOTIF_EMITTER,
409:                            getPanel().isImplNotifEmit());
410:                    wiz.putProperty(
411:                            WizardConstants.PROP_GEN_BROADCAST_DELEGATION,
412:                            getPanel().genBroadcasterDelegation());
413:                    wiz.putProperty(WizardConstants.PROP_GEN_SEQ_NUMBER,
414:                            getPanel().genSeqNb());
415:
416:                    // read the content of attributes table
417:                    MBeanNotificationTableModel aModel = getPanel().notificationModel;
418:                    int nbNotifs = aModel.size();
419:
420:                    wiz.putProperty(WizardConstants.PROP_NOTIF_NB, new Integer(
421:                            nbNotifs).toString());
422:
423:                    for (int i = 0; i < nbNotifs; i++) {
424:                        //the current notification 
425:                        MBeanNotification currentNotif = aModel
426:                                .getNotification(i);
427:                        wiz.putProperty(WizardConstants.PROP_NOTIF_CLASS + i,
428:                                currentNotif.getNotificationClass());
429:
430:                        wiz.putProperty(WizardConstants.PROP_NOTIF_DESCR + i,
431:                                currentNotif.getNotificationDescription());
432:
433:                        wiz.putProperty(WizardConstants.PROP_NOTIF_TYPE + i,
434:                                currentNotif.getNotificationTypeClasses());
435:                    }
436:                }
437:
438:                /**
439:                 * Returns the current help context
440:                 * @return HelpCtxt
441:                 */
442:                public HelpCtx getHelp() {
443:                    return new HelpCtx("jmx_instrumenting_app");// NOI18N
444:                }
445:            }
446:
447:            public boolean isImplNotifEmit() {
448:                return implNotifEmitCheckBox.isSelected();
449:            }
450:
451:            public boolean genBroadcasterDelegation() {
452:                return genDelegationCheckBox.isSelected();
453:            }
454:
455:            public boolean genSeqNb() {
456:                return genSeqNbCheckBox.isSelected();
457:            }
458:
459:            public void setImplNotifEmit(boolean state) {
460:                implNotifEmitCheckBox.setSelected(state);
461:            }
462:
463:            public void setGenBroadcasterDelegation(boolean state) {
464:                genDelegationCheckBox.setSelected(state);
465:            }
466:
467:            public void setGenSeqNb(boolean state) {
468:                genSeqNbCheckBox.setSelected(state);
469:            }
470:
471:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.