ISelection selection = _treeViewer.getSelection();
if (selection instanceof TreeSelection) {
TreeSelection treeSelection = (TreeSelection) selection;
Object node = treeSelection.getFirstElement();
if (node instanceof WGSchemaDocumentDefinition) {
WGSchemaDocumentDefinition def = (WGSchemaDocumentDefinition)node;
String typeName = "Document Definition";
if (def instanceof WGContentTypeDefinition) {
typeName = "Content Type Definition";
} else if (def instanceof WGAreaDefinition) {
typeName = "Area Definition";
} else if (def instanceof WGLanguageDefinition) {
typeName = "Language Definition";
}
boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + def.getName() + "'?");
if (result) {
_model.removeSchemaDocumentDefintion(def);
}
} else if (node instanceof WGContentItemDefinition) {
WGContentItemDefinition def = (WGContentItemDefinition)node;
String typeName = "Item Definition";
boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + def.getName() + "'?");
if (result) {
_model.remove(def);
}
} else if (node instanceof WGMetaFieldDefinition) {
WGMetaFieldDefinition def = (WGMetaFieldDefinition)node;
String typeName = "Property";
boolean result = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Delete " + typeName, "Delete " + typeName + " '" + AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def.getName()) + "'?");
if (result) {
_model.remove(def);
}
}
}