Search in sources :

Example 1 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method openOnGlobalReference.

/**
 * Method openOnGlobalReference. The comp argument is a resolved xsd schema
 * object from another file. This is created and called from another schema
 * model to allow F3 navigation to open a new editor and choose the referenced
 * object within that editor context
 *
 * @param comp
 */
public void openOnGlobalReference(XSDConcreteComponent comp) {
    XSDConcreteComponent namedComponent = openOnSelectionHelper.openOnGlobalReference(comp);
    if (namedComponent == null) {
        namedComponent = getXSDSchema();
    }
    XSDBaseAdapter adapter = (XSDBaseAdapter) XSDAdapterFactory.getInstance().adapt(namedComponent);
    getSelectionManager().setSelection(new StructuredSelection(adapter));
    IAction action = getActionRegistry().getAction(SetInputToGraphView.ID);
    if (action != null) {
        action.run();
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IAction(org.eclipse.jface.action.IAction) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)

Example 2 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class XSDEditPartFactory method createStructureFigure.

public IStructureFigure createStructureFigure(Object model) {
    IStructureFigure figure = delegate.createStructureFigure(model);
    if (model instanceof XSDBaseAdapter) {
        XSDConcreteComponent comp = (XSDConcreteComponent) ((XSDBaseAdapter) model).getTarget();
        boolean isReadOnly = ((XSDBaseAdapter) model).isReadOnly();
        figure.getNameLabel().setIcon(XSDCommonUIUtils.getUpdatedImage(comp, ((XSDBaseAdapter) model).getImage(), isReadOnly));
    }
    return figure;
}
Also used : IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)

Example 3 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class AddXSDModelGroupAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
        AddXSDModelGroupCommand command = null;
        if (xsdComponent instanceof XSDElementDeclaration) {
            XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent;
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor);
            getCommandStack().execute(command);
        } else if (xsdComponent instanceof XSDModelGroup) {
            XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent;
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor);
            getCommandStack().execute(command);
        } else if (xsdComponent instanceof XSDComplexTypeDefinition || xsdComponent instanceof XSDModelGroupDefinition) {
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor);
            getCommandStack().execute(command);
        }
        if (command != null) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
            if (adapter != null)
                provider.setSelection(new StructuredSelection(adapter));
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) AddXSDModelGroupCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDModelGroupCommand) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Example 4 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class AddXSDRedefinableContentAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    if (selection instanceof XSDRedefine) {
        ComponentSearchListDialogConfiguration configuration = new ComponentSearchListDialogConfiguration();
        configuration.setDescriptionProvider(new RedefineDescriptor());
        configuration.setSearchListProvider(new RedefineSearchListProvider((XSDRedefine) selection, this));
        ComponentSearchListDialog dialog = new ComponentSearchListDialog(Display.getDefault().getActiveShell(), Messages._UI_LABEL_REDEFINE_COMPONENT, configuration) {

            protected Control createDialogArea(Composite parent) {
                // Adjust the dialog's initial size.
                Composite mainComposite = (Composite) super.createDialogArea(parent);
                GridData gridData = (GridData) mainComposite.getLayoutData();
                gridData.heightHint = 500;
                gridData.widthHint = 350;
                return mainComposite;
            }
        };
        dialog.create();
        dialog.setBlockOnOpen(true);
        int result = dialog.open();
        if (result == Window.OK) {
            ComponentSpecification selectedComponent = dialog.getSelectedComponent();
            buildRedefine((XSDRedefine) selection, selectedComponent);
        }
    }
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) ComponentSearchListDialog(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialog) Composite(org.eclipse.swt.widgets.Composite) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) GridData(org.eclipse.swt.layout.GridData) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ComponentSearchListDialogConfiguration(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSearchListDialogConfiguration)

Example 5 with XSDBaseAdapter

use of org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter in project webtools.sourceediting by eclipse.

the class SetMultiplicityAction method getXSDInput.

private XSDConcreteComponent getXSDInput() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    XSDConcreteComponent xsdConcreteComponent = null;
    if (selection instanceof XSDBaseAdapter) {
        xsdConcreteComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
    }
    return xsdConcreteComponent;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)23 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)16 Adapter (org.eclipse.emf.common.notify.Adapter)14 XSDSchema (org.eclipse.xsd.XSDSchema)10 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)6 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)5 Iterator (java.util.Iterator)4 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)4 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)4 List (java.util.List)3 Point (org.eclipse.draw2d.geometry.Point)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 ArrayList (java.util.ArrayList)2 Image (org.eclipse.swt.graphics.Image)2 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)2