01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.ideaplugin.frames.table;
20:
21: import org.apache.ideaplugin.bean.OperationObj;
22:
23: import javax.swing.table.AbstractTableModel;
24: import java.util.HashMap;
25: import java.util.Iterator;
26:
27: /**
28: * Author: Deepal Jayasinghe
29: * Date: Sep 22, 2005
30: * Time: 11:57:24 AM
31: */
32: public class ArchiveTableModel extends AbstractTableModel {
33:
34: final String[] columnNames = { "Operation Name", "Return Value",
35: "Parameters ", "Select" };
36: Object[][] datvalue;
37: private HashMap datobjs;
38:
39: public ArchiveTableModel(HashMap dataobject) {
40: int size = dataobject.size();
41: datvalue = new Object[size][4];
42: Iterator itr = dataobject.values().iterator();
43: int count = 0;
44: while (itr.hasNext()) {
45: OperationObj operationObj = (OperationObj) itr.next();
46: datvalue[count][0] = operationObj.getOpName();
47: datvalue[count][1] = operationObj.getReturnValue();
48: datvalue[count][2] = operationObj.getParameters();
49: datvalue[count][3] = operationObj.getSelect();
50: count++;
51: }
52: this .datobjs = dataobject;
53: }
54:
55: public int getColumnCount() {
56: return columnNames.length;
57: }
58:
59: public int getRowCount() {
60: return datvalue.length;
61: }
62:
63: public String getColumnName(int col) {
64: return columnNames[col];
65: }
66:
67: public Object getValueAt(int row, int col) {
68: return datvalue[row][col];
69: }
70:
71: public Class getColumnClass(int c) {
72: return getValueAt(0, c).getClass();
73: }
74:
75: public boolean isCellEditable(int row, int col) {
76: return col >= 3;
77: }
78:
79: public void setValueAt(Object value, int row, int col) {
80: OperationObj obj = (OperationObj) datobjs
81: .get(getValueAt(row, 0));
82: if (col == 3) {
83: obj.setSelect((Boolean) value);
84: }
85:
86: if (datvalue[0][col] instanceof Integer) {
87: try {
88: datvalue[row][col] = new Integer((String) value);
89: } catch (NumberFormatException e) {
90: System.out.println("Error");
91: }
92: } else {
93: datvalue[row][col] = value;
94: }
95: // obj.printMe();
96: }
97: }
|