use of org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand in project webtools.sourceediting by eclipse.
the class AbstractExtensionsSection method widgetSelected.
public void widgetSelected(SelectionEvent event) {
if (event.widget == addButton) {
ExtensionsSchemasRegistry registry = getExtensionsSchemasRegistry();
AddExtensionsComponentDialog dialog = createAddExtensionsComponentDialog();
List properties = registry.getAllExtensionsSchemasContribution();
dialog.setInput(properties);
dialog.setBlockOnOpen(true);
dialog.setPrefStore(getPrefStore());
if (prevCategory != null)
dialog.setInitialCategorySelection(prevCategory);
if (dialog.open() == Window.OK) {
Object newSelection = null;
Object[] result = dialog.getResult();
if (result != null) {
SpecificationForExtensionsSchema extensionsSchemaSpec = (SpecificationForExtensionsSchema) result[1];
AddExtensionCommand addExtensionCommand = getAddExtensionCommand(result[0]);
if (addExtensionCommand != null) {
addExtensionCommand.setSchemaProperties(extensionsSchemaSpec);
if (getCommandStack() != null) {
getCommandStack().execute(addExtensionCommand);
newSelection = addExtensionCommand.getNewObject();
}
}
}
// refresh();
if (newSelection != null) {
extensionTreeViewer.setSelection(new StructuredSelection(newSelection));
}
}
prevCategory = dialog.getSelectedCategory();
} else if (event.widget == removeButton) {
ISelection selection = extensionTreeViewer.getSelection();
if (selection instanceof StructuredSelection) {
Object o = ((StructuredSelection) selection).getFirstElement();
Command command = getRemoveExtensionCommand(o);
if (getCommandStack() != null) {
getCommandStack().execute(command);
}
}
} else if (event.widget == extensionTreeViewer.getTree()) {
}
}
use of org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand in project webtools.sourceediting by eclipse.
the class ExtensionsSection method getAddExtensionCommand.
protected AddExtensionCommand getAddExtensionCommand(Object o) {
AddExtensionCommand addExtensionCommand = null;
if (o instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) o;
ExtensibleAddExtensionCommand extensibleAddExtensionCommand = getExtensionsSchemasRegistry().getAddExtensionCommand(element.getTargetNamespace());
if (extensibleAddExtensionCommand != null) {
extensibleAddExtensionCommand.setInputs((XSDConcreteComponent) input, element);
addExtensionCommand = extensibleAddExtensionCommand;
} else {
addExtensionCommand = new AddExtensionElementCommand(Messages._UI_ACTION_ADD_APPINFO_ELEMENT, (XSDConcreteComponent) input, element);
}
} else if (o instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) o;
addExtensionCommand = new AddExtensionAttributeCommand(Messages._UI_ACTION_ADD_APPINFO_ATTRIBUTE, (XSDConcreteComponent) input, attribute);
}
return addExtensionCommand;
}
Aggregations