// SOURCE PANE
filteredSourceTree = new FilteredSourceTree(new SourceTree(sourcePool), resources.getString("KnownSources"));
for (Iterator it = Run.plugins.iterator(); it.hasNext();) {
Plugin p = (Plugin) it.next();
Object[][] tab = p.getDataSourceIcons();
if (tab != null) {
SourceTree.addSourceIcons(tab);
}
}
lAlias = new JLabel(resources.getStringValue("Alias"));
tfAlias = new JTextField();
GridBagPanel sourcePane = new GridBagPanel();
sourcePane.addOnCurrentRow(filteredSourceTree, 5, true, true, true);
sourcePane.addOnCurrentRow(lAlias);
sourcePane.addOnCurrentRow(tfAlias, 4, true, false, true);
sourcePane.addOnCurrentRow(new ExpressionPanel(filteredSourceTree.getSourceTree()), 5, true, false, true);
tfAlias.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
updateAlias();
}
public void insertUpdate(DocumentEvent e) {
updateAlias();
}
public void removeUpdate(DocumentEvent e) {
updateAlias();
}
private void updateAlias() {
if (!tfAlias.isEnabled()) {
return;
}
Object o = filteredSourceTree.getSelectedSourceOrCollection();
if (o instanceof DataSource) {
DataInfo di = ((DataSource) o).getInformation();
String alias = tfAlias.getText();
if (alias.equals("")) {
alias = null;
}
if (di != null) {
String oldAlias = di.alias;
if (((oldAlias == null) && (alias != null)) || ((oldAlias != null) && (alias == null))
|| ((oldAlias != null) && (!oldAlias.equals(alias)))) {
di.alias = alias;
((DataSource) o).notifyListenersForInfoChange(di);
tfAlias.getDocument().removeDocumentListener(this);
TreeNode tn = (TreeNode) ( filteredSourceTree.getSourceTree().getSelectionPath().getLastPathComponent());
((DefaultTreeModel) ( filteredSourceTree.getSourceTree().getModel())).nodeChanged(tn);
tfAlias.getDocument().addDocumentListener(this);
tfAlias.requestFocus();
}
}
}
}
});
filteredSourceTree.getSourceTree().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
Object o = filteredSourceTree.getSelectedSourceOrCollection();
filteredSourceTree.getSourceTree().removeTreeSelectionListener(this);
if ((o instanceof DataSource) && e.isAddedPath()) {
tfAlias.setEnabled(true);
lAlias.setEnabled(true);
tfAlias.setEditable(true);
String alias = DataInfo.getAlias(o);
tfAlias.setText(alias == null ? "" : alias);
tfAlias.requestFocus();
} else {
tfAlias.setEnabled(false);
lAlias.setEnabled(false);
tfAlias.setEditable(false);
tfAlias.setText("");
}
filteredSourceTree.getSourceTree().addTreeSelectionListener(this);
}
});
// wait for a selection
tfAlias.setEnabled(false);
tfAlias.setEditable(false);
lAlias.setEnabled(false);
addElement(sourcePane, resources.getStringValue("sources"));
// SHAPE PANE
shapesListModel = new ShapeListModel();
// Add shape creators
for (Iterator it = Run.plugins.iterator(); it.hasNext();) {
Plugin p = (Plugin) it.next();
List shapeCreators = p.getShapeCreators();
if (shapeCreators != null){
for (int i=0;i<shapeCreators.size();i++){
shapesListModel.addShapeCreator( (ShapeCreator)shapeCreators.get(i));
}
}