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);
}
}
}
}
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
schemaSection.setTextClient(schemaSectionToolBar);
_treeViewer = new TreeViewer(tree);
_treeViewer.setContentProvider(new WGASchemaDefinitionContentProvider());
_treeViewer.setLabelProvider(new WGASchemaDefinitionLabelProvider());
_treeViewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 != null && e2 != null) {
if (e1 instanceof WGMetaFieldDefinition && e2 instanceof WGMetaFieldDefinition) {
WGMetaFieldDefinition def1 = (WGMetaFieldDefinition) e1;
WGMetaFieldDefinition def2 = (WGMetaFieldDefinition) e2;
return AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def1.getName()).compareTo(AddContentTypeMetaDefinitionDialog.METADATA_DEFINITION_LABELS.get(def2.getName()));
} else if (e1 instanceof String && e2 instanceof String) {
if (e1.equals(WGASchemaDefinitionContentProvider.CONTENTTYPE_DEFINITIONS_ROOT)) {
return -1;
} else if (e1.equals(WGASchemaDefinitionContentProvider.AREA_DEFINITIONS_ROOT) && e2.equals(WGASchemaDefinitionContentProvider.LANGUAGE_DEFINITIONS_ROOT)) {
return -1;
} else {
return 1;
}
} else if (e1 instanceof WGMetaFieldDefinition && e2 instanceof WGContentItemDefinition) {
return -1;
} else if (e1 instanceof WGContentItemDefinition && e2 instanceof WGMetaFieldDefinition) {
return 1;
} else if (e1 instanceof WGContentItemDefinition && e2 instanceof WGContentItemDefinition) {
WGContentItemDefinition def1 = (WGContentItemDefinition) e1;
WGContentItemDefinition def2 = (WGContentItemDefinition) e2;
if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
return 1;
} else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
return -1;
} else {
return def1.getName().compareTo(def2.getName());
}
} else if (e1 instanceof WGContentTypeDefinition && e2 instanceof WGContentTypeDefinition) {
WGContentTypeDefinition def1 = (WGContentTypeDefinition) e1;
WGContentTypeDefinition def2 = (WGContentTypeDefinition) e2;
if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
return 1;
} else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
return -1;
} else {
return def1.getName().compareTo(def2.getName());
}
} else if (e1 instanceof WGAreaDefinition && e2 instanceof WGAreaDefinition) {
WGAreaDefinition def1 = (WGAreaDefinition) e1;
WGAreaDefinition def2 = (WGAreaDefinition) e2;
if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
return 1;
} else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
return -1;
} else {
return def1.getName().compareTo(def2.getName());
}
} else if (e1 instanceof WGLanguageDefinition && e2 instanceof WGLanguageDefinition) {
WGLanguageDefinition def1 = (WGLanguageDefinition) e1;
WGLanguageDefinition def2 = (WGLanguageDefinition) e2;
if (def1.getName().startsWith("<") && !def2.getName().startsWith("<")) {
return 1;
} else if (def2.getName().startsWith("<") && !def1.getName().startsWith("<")) {
return -1;
} else {
return def1.getName().compareTo(def2.getName());
}
}
}
return super.compare(viewer, e1, e2);