Search in sources :

Example 1 with StructureEditPart

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

the class FieldFigure method editPartAttached.

public void editPartAttached(EditPart owner) {
    StructureEditPart structureEditPart = null;
    for (EditPart parent = owner.getParent(); parent != null; parent = parent.getParent()) {
        if (parent instanceof StructureEditPart) {
            structureEditPart = (StructureEditPart) parent;
            break;
        }
    }
    RowLayout rowLayout = (RowLayout) rowFigure.getLayoutManager();
    IStructureFigure typeFigure = structureEditPart.getStructureFigure();
    Assert.isTrue(typeFigure instanceof StructureFigure, "Expected object of type StructureFigure");
    rowLayout.setColumnData(((StructureFigure) typeFigure).getColumnData());
}
Also used : IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) RowLayout(org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.layouts.RowLayout) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) EditPart(org.eclipse.gef.EditPart)

Example 2 with StructureEditPart

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

the class CompartmentFigure method editPartAttached.

public void editPartAttached(EditPart owner) {
    StructureEditPart structureEditPart = null;
    for (EditPart parent = owner.getParent(); parent != null; parent = parent.getParent()) {
        if (parent instanceof StructureEditPart) {
            structureEditPart = (StructureEditPart) parent;
            break;
        }
    }
    RowLayout rowLayout = (RowLayout) rowFigure.getLayoutManager();
    IStructureFigure typeFigure = structureEditPart.getStructureFigure();
    Assert.isTrue(typeFigure instanceof StructureFigure, "Expected object of type StructureFigure");
    rowLayout.setColumnData(((StructureFigure) typeFigure).getColumnData());
}
Also used : IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) RowLayout(org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.layouts.RowLayout) StructureEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart) EditPart(org.eclipse.gef.EditPart)

Example 3 with StructureEditPart

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

Aggregations

EditPart (org.eclipse.gef.EditPart)3 StructureEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.StructureEditPart)3 IStructureFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure)2 RowLayout (org.eclipse.wst.xsd.ui.internal.adt.typeviz.design.layouts.RowLayout)2 Iterator (java.util.Iterator)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IHolderEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IHolderEditPart)1 RootContentEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.RootContentEditPart)1