Source Code Cross Referenced for NotificationTable.java in  » IDE-Netbeans » jmx » org » netbeans » modules » jmx » mbeanwizard » table » 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.table 
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.table;
042:
043:        import org.netbeans.modules.jmx.WizardConstants;
044:        import org.netbeans.modules.jmx.mbeanwizard.editor.JComboBoxCellEditor;
045:        import javax.swing.JTable;
046:        import javax.swing.table.AbstractTableModel;
047:        import javax.swing.JComboBox;
048:        import javax.swing.JTextField;
049:        import javax.swing.table.TableCellEditor;
050:        import org.netbeans.modules.jmx.mbeanwizard.tablemodel.MBeanNotificationTableModel;
051:        import org.netbeans.modules.jmx.mbeanwizard.editor.JTextFieldCellEditor;
052:        import org.netbeans.modules.jmx.mbeanwizard.renderer.ComboBoxRenderer;
053:        import java.awt.BorderLayout;
054:        import java.awt.Dimension;
055:        import java.awt.event.ActionEvent;
056:        import java.awt.event.ActionListener;
057:        import java.awt.event.ItemEvent;
058:        import java.awt.event.ItemListener;
059:        import java.util.ArrayList;
060:        import javax.swing.JButton;
061:        import javax.swing.JPanel;
062:        import javax.swing.ListSelectionModel;
063:        import javax.swing.SwingUtilities;
064:        import javax.swing.table.TableCellRenderer;
065:        import org.netbeans.modules.jmx.mbeanwizard.editor.NotificationPanelEditor;
066:        import org.netbeans.modules.jmx.MBeanNotificationType;
067:        import org.netbeans.modules.jmx.mbeanwizard.popup.NotificationTypePopup;
068:        import org.netbeans.modules.jmx.mbeanwizard.renderer.NotificationPanelRenderer;
069:
070:        /**
071:         * Class responsible for the notification table in the Notification Panel
072:         *
073:         */
074:        public class NotificationTable extends JTable {
075:
076:            /*******************************************************************/
077:            // here we use raw model calls (i.e getValueAt and setValueAt) to
078:            // access the model data because the inheritance pattern
079:            // makes it hard to type these calls and to use the object model
080:            /********************************************************************/
081:
082:            private JPanel ancestorPanel = null;
083:
084:            /**
085:             * Constructor
086:             * @param ancestorPanel the parent panel
087:             * @param model the table model of this table
088:             */
089:            public NotificationTable(JPanel ancestorPanel,
090:                    AbstractTableModel model) {
091:                super (model);
092:                this .setRowHeight(25);
093:                this .setPreferredScrollableViewportSize(new Dimension(500, 70));
094:                this .setRowSelectionAllowed(true);
095:                this .setColumnSelectionAllowed(false);
096:                this .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
097:                this .ancestorPanel = ancestorPanel;
098:            }
099:
100:            /**
101:             * Returns the cell editor for the table according to the column
102:             * @param row the row to be considered
103:             * @param column the column to be considered
104:             * @return TableCellEditor the cell editor
105:             */
106:            public TableCellEditor getCellEditor(final int row, int column) {
107:
108:                if (row >= getRowCount())
109:                    return null;
110:
111:                final JTable table = this ;
112:                final MBeanNotificationTableModel model = (MBeanNotificationTableModel) this 
113:                        .getModel();
114:
115:                if (column == 0) {
116:                    JComboBox nameField = new JComboBox();
117:                    nameField.addItem(WizardConstants.NOTIFICATION);
118:                    nameField
119:                            .addItem(WizardConstants.ATTRIBUTECHANGE_NOTIFICATION);
120:                    nameField.setName("notifClassBox");// NOI18N
121:                    nameField.setEditable(true);
122:                    nameField.setEnabled(true);
123:                    Object o = getModel().getValueAt(row, column);
124:                    nameField.setSelectedItem(o);
125:                    final org.netbeans.modules.jmx.MBeanNotification notif = (org.netbeans.modules.jmx.MBeanNotification) model
126:                            .getNotification(row);
127:                    nameField.addItemListener(new ItemListener() {
128:                        private String notifType;
129:
130:                        public void itemStateChanged(ItemEvent evt) {
131:                            if (evt.getStateChange() == evt.DESELECTED)
132:                                notifType = evt.getItem().toString();
133:                            else {
134:                                ArrayList<MBeanNotificationType> array = new ArrayList<MBeanNotificationType>();
135:
136:                                if (evt
137:                                        .getItem()
138:                                        .toString()
139:                                        .equals(
140:                                                WizardConstants.ATTRIBUTECHANGE_NOTIFICATION)) {
141:                                    array
142:                                            .add(new MBeanNotificationType(
143:                                                    WizardConstants.NOTIF_TYPE_ATTRIBUTE_CHANGE));
144:                                    notif.setNotificationTypeList(array);
145:                                } else if (notifType
146:                                        .equals(WizardConstants.ATTRIBUTECHANGE_NOTIFICATION)) {
147:                                    notif.setNotificationTypeList(array);
148:                                }
149:                                SwingUtilities.invokeLater(new Runnable() {
150:                                    public void run() {
151:                                        model.fireTableDataChanged();
152:                                    }
153:                                });
154:                            }
155:                        }
156:                    });
157:
158:                    return new JComboBoxCellEditor(nameField, this );
159:                } else {
160:                    if (column == 1) {
161:                        JTextField descrField = new JTextField();
162:                        String o = ((String) getModel().getValueAt(row, column));
163:                        descrField.setText(o);
164:                        return new JTextFieldCellEditor(descrField, this );
165:                    } else {
166:                        if (column == 2) {
167:                            final JTextField typeField = new JTextField();
168:                            typeField.setEditable(false);
169:                            typeField.setName("typeTextField");// NOI18N
170:                            JButton typeButton = new JButton(
171:                                    WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
172:                            typeButton.setName("notifTypePopupJButton");// NOI18N
173:                            typeButton
174:                                    .setMargin(new java.awt.Insets(2, 2, 2, 2));
175:                            typeButton.addActionListener(new ActionListener() {
176:                                public void actionPerformed(ActionEvent evt) {
177:                                    NotificationTypePopup notifPopup = new NotificationTypePopup(
178:                                            ancestorPanel, model, typeField,
179:                                            row);
180:                                }
181:                            });
182:
183:                            //gets all the notification types of the current 
184:                            //notification
185:                            ArrayList<MBeanNotificationType> notifType = (ArrayList<MBeanNotificationType>) getModel()
186:                                    .getValueAt(row, column);
187:
188:                            // if the notif type list size contains only one element 
189:                            // and this
190:                            // element is Attribute Change the button and the textfield
191:                            // are disabled
192:                            if ((notifType.size() == 1)
193:                                    && (notifType.get(0).getNotificationType()
194:                                            .equals(WizardConstants.NOTIF_TYPE_ATTRIBUTE_CHANGE))) {
195:                                typeButton.setEnabled(false);
196:                                typeField.setEditable(false);
197:                            }
198:
199:                            JPanel panel = new JPanel(new BorderLayout());
200:                            panel.add(typeField, BorderLayout.CENTER);
201:                            panel.add(typeButton, BorderLayout.EAST);
202:                            return new NotificationPanelEditor(model, panel,
203:                                    typeField, typeButton, row);
204:                        }
205:                    }
206:                    return super .getCellEditor(row, column);
207:                }
208:            }
209:
210:            /**
211:             * Returns the cell renderer for the table according to the column
212:             * @param row the row to be considered
213:             * @param column the column to be considered
214:             * @return TableCellRenderer the cell renderer
215:             */
216:            public TableCellRenderer getCellRenderer(int row, int column) {
217:
218:                if (row >= getRowCount())
219:                    return null;
220:
221:                if (column == 0) {
222:                    JComboBox nameField = new JComboBox();
223:                    nameField.addItem(getModel().getValueAt(row, column));
224:                    return new ComboBoxRenderer(nameField, true, true);
225:                } else {
226:                    if (column == 2) {
227:                        JTextField typeField = new JTextField();
228:                        typeField.setEditable(false);
229:                        typeField.setName("typeTextField");// NOI18N
230:                        JButton typeButton = new JButton(
231:                                WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
232:                        typeButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
233:
234:                        //gets all the notification types of the current notification
235:                        ArrayList<MBeanNotificationType> notifType = (ArrayList<MBeanNotificationType>) getModel()
236:                                .getValueAt(row, column);
237:
238:                        // if the notif type list size contains only one element 
239:                        // and this
240:                        // element is Attribute Change the button and the textfield 
241:                        // are disabled
242:                        if ((notifType.size() == 1)
243:                                && (notifType.get(0).getNotificationType()
244:                                        .equals(WizardConstants.NOTIF_TYPE_ATTRIBUTE_CHANGE))) {
245:                            typeButton.setEnabled(false);
246:                            typeField.setEditable(false);
247:                        }
248:
249:                        JPanel panel = new JPanel(new BorderLayout());
250:                        panel.add(typeField, BorderLayout.CENTER);
251:                        panel.add(typeButton, BorderLayout.EAST);
252:                        return new NotificationPanelRenderer(panel, typeField);
253:                    }
254:                }
255:                return super.getCellRenderer(row, column);
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.