updateName();
}
public void updateName() {
name = tfName.getText();
if (name.equals("")) name = null;
actionListener.actionPerformed(new ActionEvent(pane, 1, (name==null) ? resources.getString("UnnamedMapper") : name));
}
});
table.addSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
int r = table.getSelectedRow();
if (r==-1) {
del.setEnabled(false);
up.setEnabled(false);
down.setEnabled(false);
return;
}
del.setEnabled(true);
Expression e = (Expression)table.tableModel.expressions.get(r);
if (e.value instanceof Interval) {
up.setEnabled((r>0) && (((Expression)table.tableModel.expressions.get(r-1)).value instanceof Interval));
down.setEnabled(r<table.tableModel.expressions.size()-1);
} else {
up.setEnabled(false);
down.setEnabled(false);
}
}
});
newv.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Long key = null;
for (int k = 0; k < Integer.MAX_VALUE; k++) {
key = new Long(k);
if (map.get(key)==null) break;
}
map.put(key, createNewValue());
int r = 0;
for (Iterator it = map.keySet().iterator(); it.hasNext(); r++) {
if (it.next().equals(key)) break;
}
table.tableModel.update(0,map.size()+intervals.size()-1);
table.tableModel.fireTableRowsInserted(r,r);
table.setRowSelectionInterval(r,r);
}
});
newi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
intervals.add(new Interval(false,0,false,createNewValue()));
int r = map.size()+intervals.size()-1;
table.tableModel.fireTableRowsInserted(r,r);
table.tableModel.update(0,r);
table.setRowSelectionInterval(r,r);
}
});
del.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int r = table.getSelectedRow();
if (r<0) return;
Expression exp = (Expression)table.tableModel.expressions.get(r);
if (r<map.size()) {
map.remove(exp.value);
table.tableModel.fireTableRowsDeleted(r,r);
table.tableModel.update(0,map.size()+intervals.size()-1);
return;
}
intervals.remove(exp.value);
table.tableModel.fireTableRowsDeleted(r,r);
table.tableModel.update(0,map.size()+intervals.size()-1);
}
});
up.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int r = table.getSelectedRow();
int i = r - map.size();
if ((i<1) || (i>=intervals.size())) return;
Object o = intervals.get(i-1);
Object p = intervals.get(i);
intervals.set(i-1,p);
intervals.set(i,o);
table.tableModel.update(r-1,r);
table.setRowSelectionInterval(r-1,r-1);
}
});
down.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int r = table.getSelectedRow();
int i = r - map.size();
if ((i<0) || (i>=intervals.size()-1)) return;
Object o = intervals.get(i);
Object p = intervals.get(i+1);
intervals.set(i,p);
intervals.set(i+1,o);
table.tableModel.update(r,r+1);
table.setRowSelectionInterval(r+1,r+1);
}
});
if (listener!=null) ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionListener.actionPerformed(new ActionEvent(pane, 2,""));
}
});
return pane;
}