Search in sources :

Example 1 with DesignViewGraphicalViewer

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method editorModeChanged.

public void editorModeChanged(EditorMode newEditorMode) {
    // if (isInitializing)
    // return;
    EditPartFactory editPartFactory = newEditorMode.getEditPartFactory();
    if (editPartFactory != null) {
        graphicalViewer.setEditPartFactory(editPartFactory);
        if (graphicalViewer instanceof DesignViewGraphicalViewer) {
            DesignViewGraphicalViewer viewer = (DesignViewGraphicalViewer) graphicalViewer;
            IADTObject input = viewer.getInput();
            viewer.setInput(null);
            // viewer.getRootEditPart().refresh();
            // viewer.getRootEditPart().getContents().refresh();
            viewer.setInput(input);
            floatingToolbar.setEditPartFactory(editPartFactory);
            floatingToolbar.setModel(getModel());
            floatingToolbar.refresh(!(input instanceof IModel));
            Control control = graphicalViewer.getControl();
            if (control instanceof Composite) {
                Composite parent = ((Composite) control).getParent();
                parent.layout();
            }
        }
    }
    IContentProvider provider = newEditorMode.getOutlineProvider();
    if (provider != null) {
        ADTContentOutlinePage outline = (ADTContentOutlinePage) getContentOutlinePage();
        if (outline != null) {
            TreeViewer treeViewer = outline.getTreeViewer();
            if (treeViewer != null) {
                outline.getTreeViewer().setContentProvider(provider);
                outline.getTreeViewer().refresh();
            }
        }
    }
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) TreeViewer(org.eclipse.jface.viewers.TreeViewer) EditPartFactory(org.eclipse.gef.EditPartFactory) ADTContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage)

Example 2 with DesignViewGraphicalViewer

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.

the class DesignViewNavigationLocation method restoreLocation.

public void restoreLocation() {
    XSDSchema schema = (XSDSchema) getEditorPart().getAdapter(XSDSchema.class);
    Object viewer = getEditorPart().getAdapter(GraphicalViewer.class);
    if (viewer instanceof DesignViewGraphicalViewer) {
        DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) viewer;
        XSDConcreteComponent component = Path.computeComponent(schema, path);
        if (component != null) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(component);
            if (adapter instanceof IADTObject) {
                graphicalViewer.setInput((IADTObject) adapter);
            }
        } else if (path.segments.isEmpty()) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(schema);
            if (adapter instanceof IADTObject) {
                graphicalViewer.setInput((IADTObject) adapter);
            }
        }
    }
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) EObject(org.eclipse.emf.ecore.EObject) Adapter(org.eclipse.emf.common.notify.Adapter) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 3 with DesignViewGraphicalViewer

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.

the class DeleteAction method run.

public void run() {
    for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) {
        Object selection = i.next();
        Command command = null;
        boolean doSetInput = false;
        boolean doSetModelAsInput = false;
        IADTObject topLevelContainer = null;
        IModel model = null;
        if (selection instanceof IGraphElement) {
            IGraphElement xsdObj = (IGraphElement) selection;
            if (xsdObj instanceof XSDBaseAdapter) {
                XSDBaseAdapter baseAdapter = (XSDBaseAdapter) xsdObj;
                // is null and the read only check cannot be completed
                if (baseAdapter == null || baseAdapter.isReadOnly()) {
                    continue;
                }
                topLevelContainer = xsdObj.getTopContainer();
                if (topLevelContainer == selection) {
                    doSetInput = true;
                    doSetModelAsInput = true;
                }
                command = xsdObj.getDeleteCommand();
                model = xsdObj.getModel();
            }
        }
        if (command != null) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
                if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
                    IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor();
                    if (editorPart != null) {
                        Object viewer = editorPart.getAdapter(GraphicalViewer.class);
                        if (viewer instanceof DesignViewGraphicalViewer) {
                            Object input = ((DesignViewGraphicalViewer) viewer).getInput();
                            if (input != selection) {
                                // Bug 86218 : Don't switch to top level view if the object we're deleting
                                // is not the input to the viewer
                                doSetInput = false;
                            }
                        }
                    }
                }
            }
            command.execute();
            if (doSetInput) {
                if (model != null && doSetModelAsInput)
                    provider.setSelection(new StructuredSelection(model));
                else if (topLevelContainer != null && !doSetModelAsInput)
                    provider.setSelection(new StructuredSelection(topLevelContainer));
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) IWorkbench(org.eclipse.ui.IWorkbench) DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) Command(org.eclipse.gef.commands.Command) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 4 with DesignViewGraphicalViewer

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.

the class SetInputToGraphView method run.

public void run() {
    Object selection = input;
    if (selection == null) {
        selection = ((IStructuredSelection) getSelection()).getFirstElement();
    }
    Object adapter = getWorkbenchPart().getAdapter(GraphicalViewer.class);
    if (selection instanceof IADTObject) {
        IADTObject obj = (IADTObject) selection;
        if (adapter instanceof DesignViewGraphicalViewer) {
            DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) adapter;
            EditPart editPart = graphicalViewer.getInputEditPart();
            if (editPart instanceof RootContentEditPart) {
                graphicalViewer.setInputAndMarkLocation(obj);
            }
        }
    }
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) EditPart(org.eclipse.gef.EditPart) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)

Example 5 with DesignViewGraphicalViewer

use of org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer in project webtools.sourceediting by eclipse.

the class ADTMultiPageEditor method getGraphicalViewer.

protected ScrollingGraphicalViewer getGraphicalViewer() {
    DesignViewGraphicalViewer viewer = new DesignViewGraphicalViewer(this, getSelectionManager());
    viewer.addInputChangdListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection input = (IStructuredSelection) event.getSelection();
            floatingToolbar.refresh(isTableOfContentsApplicable(input.getFirstElement()));
        }
    });
    // Workaround bug 227687 An edit part's focus state is not updated properly
    // Once this is bug is fixed, we can remove custom selection manager
    viewer.setSelectionManager(new CustomSelectionManager());
    return viewer;
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

DesignViewGraphicalViewer (org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer)5 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IModel (org.eclipse.wst.xsd.ui.internal.adt.facade.IModel)2 Iterator (java.util.Iterator)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPart (org.eclipse.gef.EditPart)1 EditPartFactory (org.eclipse.gef.EditPartFactory)1 Command (org.eclipse.gef.commands.Command)1 IContentProvider (org.eclipse.jface.viewers.IContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbench (org.eclipse.ui.IWorkbench)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1