if (event.widget == addIndexButton) {
if (notAllowed("Adding an Index"))
return;
// creating the dialog and open it
AddIndexDialog dialog = new AddIndexDialog(this);
if (dialog.open() == Window.CANCEL)
return;
FsIndexDescription id = UIMAFramework.getResourceSpecifierFactory()
.createFsIndexDescription();
id.setLabel(dialog.indexName);
id.setTypeName(dialog.indexType);
id.setKeys(dialog.keys);
id.setKind(dialog.indexKind);
addFsIndexDescription(id);
updateIndexSpec(new TableTreeItem(tt, SWT.NONE), id);
tt.getTable().setSelection(tt.getTable().getItemCount() - 1);
packTable(tt.getTable());
setFileDirty();
} else if (event.widget == addKeyButton) {
if (notAllowed("Adding an Index"))
return;
TableTreeItem parent = tt.getSelection()[0];
if (null != parent.getParentItem())
parent = parent.getParentItem();
if (foolingAroundWithAnnotationIndex(parent))
return;
FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent);
AddIndexKeyDialog dialog = new AddIndexKeyDialog(this, fsid.getTypeName(),
handleDefaultIndexKind(fsid.getKind()), getAlreadyUsedFeatures(fsid));
FsIndexKeyDescription newKey = addOrEditIndexKey(dialog, null);
if (null != newKey) {
addFsIndexKeyDescription(fsid, newKey);
updateKeySpec(new TableTreeItem(parent, SWT.NONE), newKey);
parent.setExpanded(true);
setFileDirty();
}
} else if (event.widget == removeButton) {
TableTreeItem item = tt.getSelection()[0];
if (foolingAroundWithAnnotationIndex(item))
return;
Object o = item.getData();
if (o instanceof FsIndexDescription) {
if (Window.CANCEL == Utility.popOkCancel("Confirm Remove",
"Do you want to remove this index?", MessageDialog.WARNING))
return;
removeFsIndexDescription((FsIndexDescription) o);
} else {
if (Window.CANCEL == Utility.popOkCancel("Confirm Remove",
"Do you want to remove this key?", MessageDialog.WARNING))
return;
TableTreeItem parent = item.getParentItem();
FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent);
removeFsIndexKeyDescription(fsid, (FsIndexKeyDescription) o);
}
tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
item.dispose();
setFileDirty();
} else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
if (notAllowed("Adding an Index"))
return;
if (tt.getSelectionCount() != 1)
return;
TableTreeItem item = tt.getSelection()[0];
if (foolingAroundWithAnnotationIndex(item))
return;
Object o = item.getData();
if (o instanceof FsIndexDescription) {
FsIndexDescription fsid = (FsIndexDescription) o;
AddIndexDialog dialog = new AddIndexDialog(this, fsid);
if (dialog.open() == Window.CANCEL)
return;
valueChanged = false;
fsid.setLabel(setValueChanged(dialog.indexName, fsid.getLabel()));
fsid.setTypeName(setValueChanged(dialog.indexType, fsid.getTypeName()));