📄 listpropertytable.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.gui;
import edu.udo.cs.yale.operator.Operator;
import edu.udo.cs.yale.operator.parameter.ParameterType;
import edu.udo.cs.yale.operator.parameter.ParameterTypeList;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.table.DefaultTableModel;
/** For ParameterTypeList the parameter values are parameter lists themselves. Hence,
* the key must be editable, too (not only the value). That is what this implementation of
* PropertyTable is good for. */
public class ListPropertyTable extends PropertyTable {
private List parameterList;
private ParameterTypeList type;
private Operator operator;
public ListPropertyTable(ParameterTypeList type, List parameterList, Operator operator) {
super(new String[] { type.getKey(), type.getValueType().getKey() });
this.type = type;
this.parameterList = parameterList;
this.operator = operator;
updateTableData(parameterList.size());
Iterator i = parameterList.iterator();
int j = 0;
while (i.hasNext()) {
Object[] keyValue = (Object[])i.next();
getDefaultModel().setValueAt(keyValue[0], j, 0);
getDefaultModel().setValueAt(keyValue[1], j, 1);
j++;
}
updateEditorsAndRenderers();
}
public void addRow() {
((DefaultTableModel)getModel()).addRow(new Object[] {"", type.getValueType().getDefaultValue() });
updateEditorsAndRenderers();
}
public void removeSelected() {
int[] selectedRow = getSelectedRows();
for (int i = selectedRow.length-1; i >= 0; i--) {
getDefaultModel().removeRow(selectedRow[i]);
}
}
public void getParameterList(List list) {
list.clear();
for (int i = 0; i < getDefaultModel().getRowCount(); i++) {
list.add(new Object[] { getDefaultModel().getValueAt(i, 0),
getDefaultModel().getValueAt(i, 1)});
}
}
public Operator getOperator(int row) {
return operator;
}
public ParameterType getParameterType(int row) {
return type.getValueType();
}
public boolean isCellEditable(int row, int col) {
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -