Search in sources :

Example 6 with RootContentEditPart

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

the class DesignViewGraphicalViewer method getEditPart.

protected EditPart getEditPart(EditPart parent, Object object) {
    EditPart result = null;
    for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) {
        EditPart editPart = (EditPart) i.next();
        if (editPart.getModel() == object && !(editPart instanceof IHolderEditPart) && !(editPart instanceof RootContentEditPart)) {
            result = editPart;
            break;
        }
    }
    if (result == null) {
        for (Iterator i = parent.getChildren().iterator(); i.hasNext(); ) {
            EditPart editPart = getEditPart((EditPart) i.next(), object);
            if (editPart != null) {
                // First check to see if there is a selection
                ISelection currentSelection = getSelection();
                // direct edit mode
                if (currentSelection != null) {
                    if (currentSelection instanceof StructuredSelection) {
                        EditPart targetStructureEditPart = (EditPart) ((StructuredSelection) currentSelection).getFirstElement();
                        if (targetStructureEditPart != null) {
                            while (targetStructureEditPart != null) {
                                if (targetStructureEditPart instanceof StructureEditPart) {
                                    break;
                                }
                                targetStructureEditPart = targetStructureEditPart.getParent();
                            }
                        }
                        EditPart potentialEditPartToSelect = editPart;
                        while (potentialEditPartToSelect != null) {
                            if (potentialEditPartToSelect instanceof StructureEditPart) {
                                break;
                            }
                            potentialEditPartToSelect = potentialEditPartToSelect.getParent();
                        }
                        // the edit part we found
                        if (potentialEditPartToSelect == targetStructureEditPart || potentialEditPartToSelect == null || targetStructureEditPart == null) {
                            result = editPart;
                            break;
                        }
                    }
                } else // Otherwise just find the first one and return
                {
                    result = editPart;
                    break;
                }
            }
        }
    }
    return result;
}
Also used : IHolderEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart) IHolderEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) EditPart(org.eclipse.gef.EditPart) Iterator(java.util.Iterator) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RootContentEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)

Example 7 with RootContentEditPart

use of org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart 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)

Aggregations

RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)7 EditPart (org.eclipse.gef.EditPart)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IHolderEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart)2 StructureEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart)2 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)2 Iterator (java.util.Iterator)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 EObject (org.eclipse.emf.ecore.EObject)1 EditPartFactory (org.eclipse.gef.EditPartFactory)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 IAction (org.eclipse.jface.action.IAction)1 ISelection (org.eclipse.jface.viewers.ISelection)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 IEditorPart (org.eclipse.ui.IEditorPart)1