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:
042: package org.netbeans.modules.jmx.actions.dialog;
043:
044: import java.awt.BorderLayout;
045: import javax.swing.JButton;
046: import javax.swing.JComboBox;
047: import javax.swing.JPanel;
048: import javax.swing.JTextField;
049: import javax.swing.table.AbstractTableModel;
050: import javax.swing.table.TableCellRenderer;
051: import org.netbeans.modules.jmx.FireEvent;
052: import org.netbeans.modules.jmx.WizardConstants;
053: import org.netbeans.modules.jmx.WizardHelpers;
054: import org.netbeans.modules.jmx.mbeanwizard.renderer.ComboBoxRenderer;
055: import org.netbeans.modules.jmx.mbeanwizard.renderer.TextFieldRenderer;
056: import org.netbeans.modules.jmx.mbeanwizard.table.OperationTable;
057: import org.netbeans.modules.jmx.mbeanwizard.renderer.OperationParameterPanelRenderer;
058: import org.netbeans.modules.jmx.mbeanwizard.renderer.OperationExceptionPanelRenderer;
059:
060: /**
061: * Class responsible for the operation table shown when you use Add Operations...
062: * popup action in the contextual management menu.
063: * @author tl156378
064: */
065: public class AddOperationTable extends OperationTable {
066:
067: /**
068: * Constructor
069: * @param model the table model of this table
070: * @param wiz the wizard panel
071: * @param ancestorPanel <CODE>JPanel</CODE>
072: */
073: public AddOperationTable(JPanel ancestorPanel,
074: AbstractTableModel model, FireEvent wiz) {
075: super (ancestorPanel, model, wiz);
076: }
077:
078: /**
079: * Returns the cell renderer for the table according to the column
080: * @param row the row to be considered
081: * @param column the column to be considered
082: * @return TableCellRenderer the cell renderer
083: */
084: @Override
085: public TableCellRenderer getCellRenderer(int row, int column) {
086: AddMBeanOperationTableModel addOpModel = (AddMBeanOperationTableModel) this
087: .getModel();
088: int firstEditable = addOpModel.getFirstEditable();
089:
090: if (row < firstEditable) {
091: switch (column) {
092: case AddMBeanOperationTableModel.IDX_METH_NAME:
093: return new TextFieldRenderer(new JTextField(), true,
094: false);
095: case AddMBeanOperationTableModel.IDX_METH_TYPE:
096: return new TextFieldRenderer(new JTextField(), true,
097: false);
098: case AddMBeanOperationTableModel.IDX_METH_PARAM:
099: JTextField paramField = new JTextField();
100: paramField.setEditable(false);
101: paramField.setName("methParamTextField"); // NOI18N
102: JButton paramButton = new JButton(
103: WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
104: paramButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
105: paramButton.setEnabled(false);
106: JPanel panel = new JPanel(new BorderLayout());
107: panel.add(paramField, BorderLayout.CENTER);
108: panel.add(paramButton, BorderLayout.EAST);
109: return new OperationParameterPanelRenderer(panel,
110: paramField);
111: case AddMBeanOperationTableModel.IDX_METH_EXCEPTION:
112: JTextField excepField = new JTextField();
113: excepField.setEditable(false);
114: excepField.setName("methExcepTextField"); // NOI18N
115: JButton excepButton = new JButton(
116: WizardConstants.MBEAN_POPUP_EDIT_BUTTON);
117: excepButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
118: excepButton.setEnabled(false);
119: JPanel excepPanel = new JPanel(new BorderLayout());
120: excepPanel.add(excepField, BorderLayout.CENTER);
121: excepPanel.add(excepButton, BorderLayout.EAST);
122: return new OperationExceptionPanelRenderer(excepPanel,
123: excepField);
124: case AddMBeanOperationTableModel.IDX_METH_DESCRIPTION:
125: return new TextFieldRenderer(new JTextField(), true,
126: false);
127: default:
128: return super.getCellRenderer(row, column);
129: }
130: }
131:
132: return super.getCellRenderer(row, column);
133: }
134: }
|