Source Code Cross Referenced for OperationTable.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.renderer.ComboBoxRenderer;
045:        import org.netbeans.modules.jmx.mbeanwizard.tablemodel.MBeanOperationTableModel;
046:        import java.awt.BorderLayout;
047:        import java.awt.Dimension;
048:        import java.awt.event.ActionEvent;
049:        import java.awt.event.ActionListener;
050:        import javax.swing.JButton;
051:        import javax.swing.JTable;
052:        import javax.swing.table.AbstractTableModel;
053:        import javax.swing.JComboBox;
054:        import javax.swing.JPanel;
055:        import javax.swing.JTextField;
056:        import javax.swing.table.TableCellEditor;
057:        import javax.swing.table.TableCellRenderer;
058:        import javax.swing.JDialog;
059:        import javax.swing.ListSelectionModel;
060:        import javax.swing.table.TableColumn;
061:        import javax.swing.table.TableColumnModel;
062:        import org.netbeans.modules.jmx.FireEvent;
063:        import org.netbeans.modules.jmx.WizardHelpers;
064:        import org.netbeans.modules.jmx.mbeanwizard.listener.OperationTextFieldKeyListener;
065:        import org.netbeans.modules.jmx.mbeanwizard.popup.OperationExceptionPopup;
066:        import org.netbeans.modules.jmx.mbeanwizard.popup.OperationParameterPopup;
067:        import org.netbeans.modules.jmx.mbeanwizard.editor.JComboBoxCellEditor;
068:        import org.netbeans.modules.jmx.mbeanwizard.editor.OperationParameterPanelEditor;
069:        import org.netbeans.modules.jmx.mbeanwizard.editor.OperationExceptionPanelEditor;
070:        import org.netbeans.modules.jmx.mbeanwizard.editor.JTextFieldCellEditor;
071:        import org.netbeans.modules.jmx.mbeanwizard.renderer.OperationParameterPanelRenderer;
072:        import org.netbeans.modules.jmx.mbeanwizard.renderer.OperationExceptionPanelRenderer;
073:        import org.netbeans.modules.jmx.mbeanwizard.tablemodel.MBeanAttributeTableModel;
074:
075:        /**
076:         * Class responsible for the operation table in the Method and Attribute Panel
077:         *
078:         */
079:        public class OperationTable extends JTable {
080:
081:            /*******************************************************************/
082:            // here we use raw model calls (i.e getValueAt and setValueAt) to
083:            // access the model data because the inheritance pattern
084:            // makes it hard to type these calls and to use the object model
085:            /********************************************************************/
086:
087:            private JTextField nameField;
088:            private JTextField descriptionField;
089:            private JComboBox typeBox;
090:
091:            protected JPanel ancestorPanel = null;
092:            private FireEvent wiz = null;
093:
094:            private JDialog currentPopup = null;
095:
096:            /**
097:             * Constructor
098:             * @param ancestorPanel the parent dialog's panel
099:             * @param model the table model for this table
100:             * @param wiz a wizard panel
101:             */
102:            public OperationTable(JPanel ancestorPanel,
103:                    AbstractTableModel model, FireEvent wiz) {
104:                super (model);
105:                this .ancestorPanel = ancestorPanel;
106:                this .wiz = wiz;
107:
108:                this .setRowHeight(25);
109:                this .setPreferredScrollableViewportSize(new Dimension(500, 70));
110:                this .setRowSelectionAllowed(true);
111:                this .setColumnSelectionAllowed(false);
112:                this .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
113:            }
114:
115:            /**
116:             * Returns the cell editor for the table according to the column
117:             * @param row the row to be considered
118:             * @param column the column to be considered
119:             * @return TableCellEditor the cell editor
120:             */
121:            public TableCellEditor getCellEditor(int row, int column) {
122:
123:                final MBeanOperationTableModel model = (MBeanOperationTableModel) this 
124:                        .getModel();
125:
126:                if (row >= getRowCount())
127:                    return null;
128:
129:                if (column == 0) { // operation name
130:                    final JTextField nameField = new JTextField();
131:                    String o = (String) getModel().getValueAt(row, column);
132:                    nameField.setText(o);
133:                    nameField
134:                            .addKeyListener(new OperationTextFieldKeyListener());
135:                    /* OLD
136:                    nameField.addKeyListener(new KeyListener() {
137:                        public void keyPressed(KeyEvent e) {}
138:                        public void keyReleased(KeyEvent e) {}
139:                        public void keyTyped(KeyEvent e) {
140:                            String txt = nameField.getText();
141:                            int selectionStart = nameField.getSelectionStart();
142:                            int selectionEnd = nameField.getSelectionEnd();
143:                            char typedKey = e.getKeyChar();
144:                            boolean acceptedKey = false;
145:                            if (selectionStart == 0) {
146:                                acceptedKey = Character.isJavaIdentifierStart(typedKey);
147:                            } else {
148:                                acceptedKey = Character.isJavaIdentifierPart(typedKey);
149:                            }
150:                            if (acceptedKey) {
151:                                if ((typedKey != KeyEvent.VK_BACK_SPACE) &&
152:                                        (typedKey != KeyEvent.VK_DELETE)) {
153:                                    txt = txt.substring(0, selectionStart) +
154:                                            typedKey +
155:                                            txt.substring(selectionEnd);
156:                                } else if (typedKey == KeyEvent.VK_DELETE) {
157:                                    txt = txt.substring(0, selectionStart) +
158:                                            txt.substring(selectionEnd);
159:                                } else {
160:                                    txt = txt.substring(0, selectionStart) +
161:                                            txt.substring(selectionEnd);
162:                                }
163:                            } else {
164:                                getToolkit().beep();
165:                            }
166:                            //txt = WizardHelpers.capitalizeFirstLetter(txt);
167:                            nameField.setText(txt);
168:                            if ((typedKey == KeyEvent.VK_BACK_SPACE) ||
169:                                    (typedKey == KeyEvent.VK_DELETE))
170:                                nameField.setCaretPosition(selectionStart);
171:                            else {
172:                                if (acceptedKey) {
173:                                    nameField.setCaretPosition(selectionStart + 1);
174:                                } else {
175:                                    nameField.setCaretPosition(selectionStart);
176:                                }
177:                            }
178:                            
179:                            e.consume();
180:                        }
181:                    });
182:                     */
183:                    return new JTextFieldCellEditor(nameField, this );
184:                } else {
185:                    if (column == 1) { //operation return type
186:                        JComboBox typeBox = WizardHelpers
187:                                .instanciateRetTypeJComboBox();
188:                        typeBox.setName("methTypeBox");// NOI18N
189:                        Object o = getModel().getValueAt(row, column);
190:                        typeBox.setSelectedItem(o);
191:                        return new JComboBoxCellEditor(typeBox, this );
192:                    } else {
193:                        if (column == 2) { //parameter panel
194:                            final JTextField paramField = new JTextField();
195:                            paramField.setEditable(false);
196:                            paramField.setName("methParamTextField");// NOI18N
197:                            JButton paramButton = new JButton(
198:                                    WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
199:                            paramButton.setName("methAddParamButton");// NOI18N
200:                            paramButton.setMargin(new java.awt.Insets(2, 2, 2,
201:                                    2));
202:                            final int editedRow = row;
203:                            paramButton.addActionListener(new ActionListener() {
204:                                public void actionPerformed(ActionEvent evt) {
205:                                    OperationParameterPopup methParamPopup = new OperationParameterPopup(
206:                                            ancestorPanel, model, paramField,
207:                                            editedRow, wiz);
208:                                }
209:                            });
210:
211:                            JPanel panel = new JPanel(new BorderLayout());
212:                            panel.setName("methParamColJPanel");// NOI18N
213:                            panel.add(paramField, BorderLayout.CENTER);
214:                            panel.add(paramButton, BorderLayout.EAST);
215:
216:                            OperationParameterPanelEditor operationParamEditor = new OperationParameterPanelEditor(
217:                                    model, panel, paramField, editedRow);
218:
219:                            //TODO Edit OperationParameterPanelEditor
220:                            //return new OperationParameterPanelEditor(panel, 
221:                            //paramField, paramButton);
222:                            return operationParamEditor;
223:                        } else {
224:                            if (column == 3) { //operation exceptions
225:                                final JTextField excepField = new JTextField();
226:                                excepField.setEditable(false);
227:                                excepField.setName("methExcepTextField");// NOI18N
228:                                JButton excepButton = new JButton(
229:                                        WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
230:                                excepButton.setName("methAddExcepJButton");// NOI18N
231:                                excepButton.setMargin(new java.awt.Insets(2, 2,
232:                                        2, 2));
233:                                final int editedRow = row;
234:                                excepButton
235:                                        .addActionListener(new ActionListener() {
236:                                            public void actionPerformed(
237:                                                    ActionEvent evt) {
238:                                                OperationExceptionPopup opExceptionPopup = new OperationExceptionPopup(
239:                                                        ancestorPanel, model,
240:                                                        excepField, editedRow);
241:                                            }
242:                                        });
243:
244:                                JPanel panel = new JPanel(new BorderLayout());
245:                                panel.add(excepField, BorderLayout.CENTER);
246:                                panel.add(excepButton, BorderLayout.EAST);
247:
248:                                OperationExceptionPanelEditor methExcepEditor = new OperationExceptionPanelEditor(
249:                                        model, panel, excepField, row);
250:
251:                                //TODO Edit OperationExceptionPanelEditor
252:                                //return new OperationExceptionPanelEditor(panel, 
253:                                //excepField, excepButton);
254:                                return methExcepEditor;
255:                            } else {
256:                                if (column == 4) {//operation description
257:                                    JTextField descrField = new JTextField();
258:                                    String o = (String) getModel().getValueAt(
259:                                            row, column);
260:                                    descrField.setText(o);
261:                                    return new JTextFieldCellEditor(descrField,
262:                                            this );
263:                                }
264:                            }
265:                        }
266:                    }
267:                    return super .getCellEditor(row, column);
268:                }
269:            }
270:
271:            /**
272:             * Returns the cell renderer for the table according to the column
273:             * @param row the row to be considered
274:             * @param column the column to be considered
275:             * @return TableCellRenderer the cell renderer
276:             */
277:            public TableCellRenderer getCellRenderer(int row, int column) {
278:
279:                if (row >= getRowCount())
280:                    return null;
281:
282:                if (column == 1) {
283:                    JComboBox retTypeBox = WizardHelpers
284:                            .instanciateRetTypeJComboBox();
285:                    return new ComboBoxRenderer(retTypeBox, true, true);
286:                } else {
287:                    if (column == 2) {
288:                        JTextField paramField = new JTextField();
289:                        paramField.setEditable(false);
290:                        paramField.setName("methParamTextField");// NOI18N
291:                        JButton paramButton = new JButton(
292:                                WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
293:                        paramButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
294:
295:                        JPanel panel = new JPanel(new BorderLayout());
296:                        panel.add(paramField, BorderLayout.CENTER);
297:                        panel.add(paramButton, BorderLayout.EAST);
298:                        return new OperationParameterPanelRenderer(panel,
299:                                paramField);
300:                    } else {
301:                        if (column == 3) {
302:                            JTextField excepField = new JTextField();
303:                            excepField.setEditable(false);
304:                            excepField.setName("methExcepTextField");// NOI18N
305:                            JButton excepButton = new JButton(
306:                                    WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
307:                            excepButton.setMargin(new java.awt.Insets(2, 2, 2,
308:                                    2));
309:
310:                            JPanel panel = new JPanel(new BorderLayout());
311:                            panel.add(excepField, BorderLayout.CENTER);
312:                            panel.add(excepButton, BorderLayout.EAST);
313:                            return new OperationExceptionPanelRenderer(panel,
314:                                    excepField);
315:                        }
316:                    }
317:                }
318:                return super .getCellRenderer(row, column);
319:            }
320:
321:            /**
322:             * Returns the wizard panel of the parent dialog
323:             * @return FireEvent
324:             */
325:            public FireEvent getWiz() {
326:
327:                return this.wiz;
328:            }
329:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.