Search in sources :

Example 1 with GenericGroupFigure

use of org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure 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 GenericGroupFigure

use of org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure in project webtools.sourceediting by eclipse.

the class ModelGroupDefinitionReferenceEditPart method refreshVisuals.

protected void refreshVisuals() {
    super.refreshVisuals();
    XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) getModel();
    figure.getIconFigure().image = adapter.getImage();
    GenericGroupFigure groupFigure = (GenericGroupFigure) getFigure();
    String nodeName = "";
    // TODO: commmon this up with ModelGroupEditPart, XSDParticleAdapter's code
    // -2 means the user didn't specify (so the default is 1)
    int minOccurs = adapter.getMinOccurs();
    int maxOccurs = adapter.getMaxOccurs();
    // $NON-NLS-1$
    String occurenceDescription = "";
    if (minOccurs == -3 && maxOccurs == -3) {
        occurenceDescription = nodeName;
        groupFigure.setText(null);
    } else if (minOccurs == 0 && (maxOccurs == -2 || maxOccurs == 1)) {
        // $NON-NLS-1$
        occurenceDescription = nodeName + " [0..1]";
        groupFigure.setText("0..1");
    } else if ((minOccurs == 1 && maxOccurs == 1) || (minOccurs == -2 && maxOccurs == 1) || (minOccurs == 1 && maxOccurs == -2)) {
        // $NON-NLS-1$
        occurenceDescription = nodeName + " [1..1]";
        groupFigure.setText("1..1");
    } else if (minOccurs == -2 && maxOccurs == -2) {
        occurenceDescription = nodeName;
        groupFigure.setText(null);
    } else {
        if (maxOccurs == -2)
            maxOccurs = 1;
        // $NON-NLS-1$ //$NON-NLS-2$
        String maxSymbol = maxOccurs == -1 ? "*" : "" + maxOccurs;
        // $NON-NLS-1$ //$NON-NLS-2$
        String minSymbol = minOccurs == -2 ? "1" : "" + minOccurs;
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        occurenceDescription = nodeName + " [" + minSymbol + ".." + maxSymbol + "]";
        groupFigure.setText(minSymbol + ".." + maxSymbol);
    }
    groupFigure.getIconFigure().setToolTipText(occurenceDescription);
    groupFigure.getIconFigure().repaint();
}
Also used : GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter)

Example 3 with GenericGroupFigure

use of org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure in project webtools.sourceediting by eclipse.

the class ModelGroupDefinitionReferenceEditPart method createConnectionFigure.

public ReferenceConnection createConnectionFigure(BaseEditPart child) {
    ReferenceConnection connectionFigure = new ReferenceConnection();
    connectionFigure.setSourceAnchor(new CenteredConnectionAnchor(((GenericGroupFigure) getFigure()).getIconFigure(), CenteredConnectionAnchor.RIGHT, 0, 0));
    if (child instanceof ModelGroupEditPart) {
        connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((ModelGroupEditPart) child).getTargetFigure(), CenteredConnectionAnchor.LEFT, 0, 0));
    } else // for the cyclic group references
    {
        connectionFigure.setTargetAnchor(new CenteredConnectionAnchor(((GenericGroupFigure) getFigure()).getIconFigure(), CenteredConnectionAnchor.RIGHT, 0, 0));
    }
    connectionFigure.setHighlight(false);
    return connectionFigure;
}
Also used : CenteredConnectionAnchor(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)

Example 4 with GenericGroupFigure

use of org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure in project webtools.sourceediting by eclipse.

the class BaseDragAndDropCommand method addConnectorToParent.

protected void addConnectorToParent(IFigure p) {
    Rectangle r = originalLocation.getCopy();
    Rectangle pBounds = r.getCopy();
    PointList pointList = getConnectionPoints(r);
    if (pointList != null && pointList.size() > 0) {
        polyLine.setPoints(pointList);
        Point firstPoint = pointList.getFirstPoint();
        if (firstPoint != null) {
            pBounds = pBounds.getUnion(new Rectangle(firstPoint.x, firstPoint.y, 1, 1));
        }
    }
    if (parentEditPart != null) {
        if (parentEditPart.getFigure() instanceof GenericGroupFigure) {
            GenericGroupFigure fig = (GenericGroupFigure) parentEditPart.getFigure();
            Rectangle iconBounds = getZoomedBounds(fig.getIconFigure().getBounds());
            pBounds = pBounds.getUnion(iconBounds);
        }
    }
    p.setBounds(pBounds);
    p.validate();
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with GenericGroupFigure

use of org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure in project webtools.sourceediting by eclipse.

the class BaseDragAndDropCommand method getConnectionPoint.

// This method supports the preview connection line function related to drag and drop
// 
protected Point getConnectionPoint(ConnectableEditPart parentEditPart, BaseFieldEditPart childRefEditPart, int[] data) {
    Point point = null;
    List childList = parentEditPart.getChildren();
    if (parentEditPart.getFigure() instanceof GenericGroupFigure && childList.size() > 0) {
        point = new Point();
        Rectangle r = getConnectedEditPartConnectionBounds(parentEditPart);
        point.x = r.x + r.width;
        point.y = r.y + r.height / 2;
    }
    return point;
}
Also used : GenericGroupFigure(org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

GenericGroupFigure (org.eclipse.wst.xsd.ui.internal.design.figures.GenericGroupFigure)14 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 CenteredConnectionAnchor (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.CenteredConnectionAnchor)3 Iterator (java.util.Iterator)2 Point (org.eclipse.draw2d.geometry.Point)2 PointList (org.eclipse.draw2d.geometry.PointList)2 BaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart)2 XSDBaseFieldEditPart (org.eclipse.wst.xsd.ui.internal.design.editparts.XSDBaseFieldEditPart)2 Figure (org.eclipse.draw2d.Figure)1 FreeformLayout (org.eclipse.draw2d.FreeformLayout)1 IFigure (org.eclipse.draw2d.IFigure)1 Label (org.eclipse.draw2d.Label)1 Polyline (org.eclipse.draw2d.Polyline)1 Image (org.eclipse.swt.graphics.Image)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