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.mbeanwizard.tablemodel;
043:
044: import java.util.ArrayList;
045: import org.openide.util.NbBundle;
046: import org.netbeans.modules.jmx.WizardConstants;
047: import org.netbeans.modules.jmx.MBeanOperationParameter;
048: import org.netbeans.modules.jmx.MBeanOperationException;
049: import org.netbeans.modules.jmx.mbeanwizard.MBeanWrapperOperation;
050: import org.netbeans.modules.jmx.MBeanOperation;
051:
052: /**
053: *
054: * @author an156382
055: */
056: public class MBeanWrapperOperationTableModel extends
057: MBeanOperationTableModel {
058:
059: //other idx inherited
060: public static final int IDX_METH_SELECTION = 0;
061: private int firstEditableRow = 0;
062:
063: /** Creates a new instance of MBeanWrapperOperationTableModel */
064: public MBeanWrapperOperationTableModel() {
065: super ();
066:
067: bundle = NbBundle.getBundle(MBeanOperationTableModel.class);
068:
069: data = new ArrayList();
070:
071: columnNames = new String[6];
072:
073: String ss = bundle.getString("LBL_MethodSelected");// NOI18N
074: String sn = bundle.getString("LBL_MethodName");// NOI18N
075: String st = bundle.getString("LBL_MethodReturnType");// NOI18N
076: String sp = bundle.getString("LBL_MethodParamType");// NOI18N
077: String se = bundle.getString("LBL_MethodExceptionType");// NOI18N
078: String sd = bundle.getString("LBL_MethodDescription");// NOI18N
079:
080: columnNames[IDX_METH_SELECTION] = ss;
081: columnNames[super .IDX_METH_NAME + 1] = sn;
082: columnNames[super .IDX_METH_TYPE + 1] = st;
083: columnNames[super .IDX_METH_PARAM + 1] = sp;
084: columnNames[super .IDX_METH_EXCEPTION + 1] = se;
085: columnNames[super .IDX_METH_DESCRIPTION + 1] = sd;
086: }
087:
088: /**
089: * Overriden method from superclass
090: */
091: public Object getValueAt(int row, int col) {
092: MBeanWrapperOperation oper = (MBeanWrapperOperation) data
093: .get(row);
094: switch (col) {
095: case 0:
096: return oper.isSelected();
097: case 1:
098: return oper.getName();
099: case 2:
100: return oper.getReturnTypeName();
101: case 3:
102: return oper.getParametersList();
103: case 4:
104: return oper.getExceptionsList();
105: case 5:
106: return oper.getDescription();
107: default:
108: System.out.println("Error getValueAt " + // NOI18N
109: "MBeanWrapperOperationTableModel " + col);// NOI18N
110: break;
111: }
112: return null;
113: }
114:
115: /**
116: * Overriden method from superclass
117: */
118: public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
119: if (rowIndex < this .size()) {
120: MBeanWrapperOperation oper = (MBeanWrapperOperation) data
121: .get(rowIndex);
122: switch (columnIndex) {
123: case 0:
124: oper.setSelected((Boolean) aValue);
125: break;
126: case 1:
127: oper.setName((String) aValue);
128: break;
129: case 2:
130: oper.setReturnTypeName((String) aValue);
131: break;
132: case 3: //do nothing (already saved by the popup)
133: break;
134: case 4: //do nothing (already saved by the popup)
135: break;
136: case 5:
137: oper.setDescription((String) aValue);
138: break;
139: default:
140: System.out.println("Error setValueAt "
141: + // NOI18N
142: "MBeanWrapperOperationTableModel "
143: + columnIndex);// NOI18N
144: break;
145: }
146: }
147: }
148:
149: public void addRow(MBeanOperation op) {
150: MBeanWrapperOperation mbo = new MBeanWrapperOperation(true, op
151: .getName(), op.getReturnTypeName(), op
152: .getParametersList(), op.getExceptionsList(), op
153: .getDescription());
154: data.add(mbo);
155:
156: //table is informed about the change to update the view
157: this .fireTableDataChanged();
158: }
159:
160: public void addRow() {
161: MBeanOperation op = createNewOperation();
162: MBeanWrapperOperation mbwo = new MBeanWrapperOperation(true, op
163: .getName(), op.getReturnTypeName(), op
164: .getParametersList(), op.getExceptionsList(), op
165: .getDescription());
166: data.add(mbwo);
167:
168: //table is informed about the change to update the view
169: this .fireTableDataChanged();
170: }
171:
172: /**
173: * Returns the operation at index index
174: * @return MBeanWrapperOperation the operation at index index
175: */
176: public MBeanWrapperOperation getWrapperOperation(int index) {
177: return (MBeanWrapperOperation) data.get(index);
178: }
179:
180: public int getFirstEditableRow() {
181: return this .firstEditableRow;
182: }
183:
184: public void setFirstEditableRow(int firstEditableRow) {
185: this.firstEditableRow = firstEditableRow;
186: }
187: }
|