Search in sources :

Example 1 with BaseFieldEditPart

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

the class XSDElementDragAndDropCommand method setup.

protected void setup() {
    canExecute = false;
    // Drop target is model group
    if (target instanceof ModelGroupEditPart) {
        parentEditPart = (ModelGroupEditPart) target;
        if (((GenericGroupFigure) parentEditPart.getFigure()).getIconFigure().getBounds().contains(location)) {
            xsdComponentToDrag = (XSDConcreteComponent) ((XSDElementDeclarationAdapter) itemToDrag.getModel()).getTarget();
            action = new MoveXSDElementAction(((ModelGroupEditPart) target).getXSDModelGroup(), xsdComponentToDrag, null, null);
            canExecute = action.canMove();
        }
    } else if (target instanceof BaseFieldEditPart) {
        targetSpacesList = new ArrayList();
        // Calculate the list of all sibling field edit parts;
        List targetEditPartSiblings = calculateFieldEditParts();
        calculateModelGroupList();
        doDrop(targetEditPartSiblings, itemToDrag);
    }
}
Also used : ModelGroupEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) MoveXSDElementAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDElementDeclarationAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 2 with BaseFieldEditPart

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

the class BaseDragAndDropCommand method calculateFieldEditParts.

protected List calculateFieldEditParts() {
    List list = target.getParent().getChildren();
    List listOfFields = new ArrayList();
    for (Iterator i = list.iterator(); i.hasNext(); ) {
        Object o = i.next();
        if (o instanceof BaseFieldEditPart) {
            listOfFields.add(o);
        }
    }
    return listOfFields;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) XSDBaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 3 with BaseFieldEditPart

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

the class XSDBaseAction method doEdit.

protected void doEdit(Object obj, IWorkbenchPart part) {
    if (obj instanceof TopLevelComponentEditPart) {
        TopLevelComponentEditPart editPart = (TopLevelComponentEditPart) obj;
        if (addedComponent == ((XSDBaseAdapter) editPart.getModel()).getTarget()) {
            editPart.setScroll(true);
            editPart.addFeedback();
            editPart.doEditName(!(part instanceof ContentOutline));
        }
    } else if (obj instanceof BaseFieldEditPart) {
        BaseFieldEditPart editPart = (BaseFieldEditPart) obj;
        editPart.doEditName(!(part instanceof ContentOutline));
    } else if (obj instanceof IAutoDirectEdit) {
        ((IAutoDirectEdit) obj).doEditName(!(part instanceof ContentOutline));
    }
}
Also used : IAutoDirectEdit(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IAutoDirectEdit) ContentOutline(org.eclipse.ui.views.contentoutline.ContentOutline) TopLevelComponentEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.TopLevelComponentEditPart) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 4 with BaseFieldEditPart

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

the class LabelCellEditorLocator method relocate.

public void relocate(CellEditor celleditor) {
    Text text = (Text) celleditor.getControl();
    Label label = namedEditPart.getNameLabelFigure();
    if (text.getBounds().x <= 0) {
        int widthToRemove = 0;
        // HACK
        if (namedEditPart instanceof BaseFieldEditPart) {
            BaseFieldEditPart field = (BaseFieldEditPart) namedEditPart;
            IFieldFigure fieldFigure = field.getFieldFigure();
            widthToRemove = fieldFigure.getTypeLabel().getBounds().width;
        // TODO: !! perhaps the IFieldFigure should just have a method to compute this?
        // Label typeAnnotationLabel = ((FieldFigure) field.getFigure()).getTypeAnnotationLabel();
        // Label nameAnnotationLabel = ((FieldFigure) field.getFigure()).getNameAnnotationLabel();
        // widthToRemove = typeLabel.getBounds().width + typeAnnotationLabel.getBounds().width + nameAnnotationLabel.getBounds().width;
        }
        Rectangle boundingRect = label.getTextBounds();
        // Reduce the width by the amount we shifted along the x-axis
        int delta = Math.abs(boundingRect.x - label.getParent().getBounds().x);
        label.getParent().translateToAbsolute(boundingRect);
        org.eclipse.swt.graphics.Rectangle trim = text.computeTrim(0, 0, 0, 0);
        boundingRect.translate(trim.x, trim.y);
        boundingRect.height = boundingRect.height - trim.y;
        boundingRect.width = label.getParent().getBounds().width - delta - widthToRemove;
        text.setBounds(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height);
        // Translate point
        if (cursorLocation != null) {
            Point translatedPoint = new Point(cursorLocation.x - boundingRect.x, cursorLocation.y - boundingRect.y);
            // Calculate text offset corresponding to the translated point
            text.setSelection(0, 0);
            int xCaret = text.getCaretLocation().x;
            int offset = text.getCaretPosition();
            while (xCaret < translatedPoint.x) {
                text.setSelection(offset + 1, offset + 1);
                xCaret = text.getCaretLocation().x;
                int newOffset = text.getCaretPosition();
                if (newOffset == offset) {
                    break;
                }
                offset++;
            }
            text.setSelection(offset, offset);
        }
    }
}
Also used : Label(org.eclipse.draw2d.Label) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.draw2d.geometry.Point) IFieldFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure) Point(org.eclipse.draw2d.geometry.Point) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Example 5 with BaseFieldEditPart

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

the class AddFieldAction method doEdit.

protected void doEdit(Object obj, IWorkbenchPart part) {
    if (obj instanceof BaseFieldEditPart) {
        BaseFieldEditPart editPart = (BaseFieldEditPart) obj;
        editPart.doEditName(!(part instanceof ContentOutline));
    }
}
Also used : ContentOutline(org.eclipse.ui.views.contentoutline.ContentOutline) BaseFieldEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)

Aggregations

BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)7 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Point (org.eclipse.draw2d.geometry.Point)2 ContentOutline (org.eclipse.ui.views.contentoutline.ContentOutline)2 GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)2 Iterator (java.util.Iterator)1 Label (org.eclipse.draw2d.Label)1 PointList (org.eclipse.draw2d.geometry.PointList)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 Text (org.eclipse.swt.widgets.Text)1 MoveXSDAttributeAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDAttributeAction)1 MoveXSDElementAction (org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction)1 XSDAttributeDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeDeclarationAdapter)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 XSDElementDeclarationAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDElementDeclarationAdapter)1 IAutoDirectEdit (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.IAutoDirectEdit)1 IFieldFigure (org.eclipse.wst.xsd.ui.internal.adt.design.figures.IFieldFigure)1