Search in sources :

Example 1 with AddExtensionsComponentDialog

use of org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog 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()) {
    }
}
Also used : SpecificationForExtensionsSchema(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema) AddExtensionsComponentDialog(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog) Command(org.eclipse.gef.commands.Command) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) ExtensionsSchemasRegistry(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry) List(java.util.List) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)

Example 2 with AddExtensionsComponentDialog

use of org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog in project webtools.sourceediting by eclipse.

the class ExtensionsSection method createAddExtensionsComponentDialog.

protected AddExtensionsComponentDialog createAddExtensionsComponentDialog() {
    AddExtensionsComponentDialog dialog = new AddExtensionsComponentDialog(composite.getShell(), getExtensionsSchemasRegistry()) {

        protected IStructuredContentProvider getCategoryContentProvider() {
            return new XSDCategoryContentProvider();
        }
    };
    dialog.addElementsTableFilter(new AddExtensionsComponentDialogFilter(input, dialog));
    return dialog;
}
Also used : AddExtensionsComponentDialog(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog)

Aggregations

AddExtensionsComponentDialog (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog)2 List (java.util.List)1 Command (org.eclipse.gef.commands.Command)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 AddExtensionCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)1 ExtensionsSchemasRegistry (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry)1 SpecificationForExtensionsSchema (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema)1