list.setSelectedIndex( 0 );
list.addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
AttributeCol attr = new AttributeCol();
attr.attr = list.getItemText(list.getSelectedIndex());
dt.attributeCols.add(attr);
scrapeData(dt.getMetadataCols().size() + dt.attributeCols.size() + 1);
refreshGrid();
refreshAttributeWidget();
pop.hide();
}
});
addbutton.setTitle(constants.AddMetadataToTheRule());
addbutton.addClickListener( new ClickListener() {
public void onClick(Widget w) {
MetadataCol met = new MetadataCol();
met.attr = box.getText();
dt.getMetadataCols().add(met);
scrapeData(dt.getMetadataCols().size() + 1);
refreshGrid();
refreshAttributeWidget();
pop.hide();
}
});
DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
horiz.add( box );
horiz.add( addbutton );
pop.addAttribute(constants.Metadata1(), horiz );
pop.addAttribute(constants.Attribute(), list);
// pop.addAttribute("", ok);
pop.show();
}
private void addItem(String at, final ListBox list) {
if (!hasAttribute(at, dt.attributeCols)) list.addItem( at );
}
private boolean hasAttribute(String at, List attributeCols) {
for (Iterator iterator = attributeCols.iterator(); iterator
.hasNext();) {
AttributeCol c = (AttributeCol) iterator.next();
if (c.attr.equals(at)) {
return true;
}
}
return false;