Search in sources :

Example 51 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project yamcs-studio by yamcs.

the class ArrayLayoutEditPolicy method getResizeChildrenCommand.

/**
 *The behavior of resizing children in an array will be determined by its editpart.
 *
 * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#
 * getResizeChildrenCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
 */
@Override
protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
    if (request.getType().equals(REQ_MOVE_CHILDREN) || request.getType().equals(REQ_ALIGN_CHILDREN)) {
        return null;
    }
    CompoundCommand resize = new CompoundCommand();
    Command c;
    List<?> children = getHostArrayEditPart().getChildren();
    GraphicalEditPart child = (GraphicalEditPart) request.getEditParts().get(0);
    Object contraint = translateToModelConstraint(getConstraintForResize(request, child));
    c = createChangeConstraintCommand(request, (EditPart) children.get(0), contraint);
    resize.add(c);
    return resize.unwrap();
}
Also used : WidgetSetConstraintCommand(org.csstudio.opibuilder.commands.WidgetSetConstraintCommand) AddWidgetCommand(org.csstudio.opibuilder.commands.AddWidgetCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) WidgetCreateCommand(org.csstudio.opibuilder.commands.WidgetCreateCommand) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 52 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project yamcs-studio by yamcs.

the class ArrayLayoutEditPolicy method getAddCommand.

/* Override super method because array widget only allows adding one child.
     * (non-Javadoc)
     * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getAddCommand(org.eclipse.gef.Request)
     */
@Override
protected Command getAddCommand(Request generic) {
    ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
    List<?> editParts = request.getEditParts();
    CompoundCommand command = new CompoundCommand();
    // $NON-NLS-1$
    command.setDebugLabel("Add in ConstrainedLayoutEditPolicy");
    GraphicalEditPart child;
    if (editParts.size() > 0) {
        child = (GraphicalEditPart) editParts.get(0);
        command.add(createAddCommand(request, child, translateToModelConstraint(getConstraintFor(request, child))));
    }
    return command.unwrap();
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 53 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project yamcs-studio by yamcs.

the class AbstractBaseEditPart method doRefreshVisuals.

/**
 * Resizes the figure. Use {@link AbstractBaseEditPart} to implement more complex refreshing behavior.
 *
 * @param refreshableFigure
 *            the figure
 */
protected synchronized void doRefreshVisuals(final IFigure refreshableFigure) {
    super.refreshVisuals();
    AbstractWidgetModel model = getWidgetModel();
    GraphicalEditPart parent = (GraphicalEditPart) getParent();
    if (parent != null) {
        parent.setLayoutConstraint(this, refreshableFigure, new Rectangle(model.getLocation(), model.getSize()));
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Rectangle(org.eclipse.draw2d.geometry.Rectangle) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Aggregations

GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)53 ArrayList (java.util.ArrayList)17 List (java.util.List)16 Rectangle (org.eclipse.draw2d.geometry.Rectangle)15 Command (org.eclipse.gef.commands.Command)15 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)13 Point (org.eclipse.draw2d.geometry.Point)12 Request (org.eclipse.gef.Request)12 IFigure (org.eclipse.draw2d.IFigure)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11 EditPart (org.eclipse.gef.EditPart)7 Dimension (org.eclipse.draw2d.geometry.Dimension)6 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)4 Iterator (java.util.Iterator)3 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)3 EditPartViewer (org.eclipse.gef.EditPartViewer)3 AbstractWorkflowPortBarEditPart (org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart)3