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);
}
}
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();
}
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;
}
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();
}
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;
}
Aggregations