Search in sources :

Example 16 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest 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 17 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project archi by archimatetool.

the class ArchimateContainerLayoutPolicy method getAddCommand.

// Over-ride this method to add a sub-command for nested connections
@Override
protected Command getAddCommand(Request generic) {
    Object parent = getHost().getModel();
    ChangeBoundsRequest request = (ChangeBoundsRequest) generic;
    CompoundCommand command = new CompoundCommand();
    // Add relations/connections between parent and child if Prefs set and if parent is an Archimate object
    boolean doAddNestedConnections = ConnectionPreferences.createRelationWhenMovingElement() && parent instanceof IDiagramModelArchimateObject;
    List<IDiagramModelArchimateObject> childObjectsForNewConnections = new ArrayList<IDiagramModelArchimateObject>();
    // Delete connections between parent and child if Prefs set and if parent is an Archimate object
    boolean doDeleteNestedConnections = ConnectionPreferences.useNestedConnections();
    List<IDiagramModelArchimateObject> childObjectsForDeletedConnections = new ArrayList<IDiagramModelArchimateObject>();
    for (Object editPart : request.getEditParts()) {
        GraphicalEditPart child = (GraphicalEditPart) editPart;
        AddObjectCommand addCommand = createAddCommand(request, child, translateToModelConstraint(getConstraintFor(request, child)));
        command.add(addCommand);
        // If we use nested connections, and child is an Archimate diagram object add it to the list
        if (doAddNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
            childObjectsForNewConnections.add((IDiagramModelArchimateObject) addCommand.child);
        }
        // If we need to delete some nested connections
        if (doDeleteNestedConnections && addCommand.child instanceof IDiagramModelArchimateObject) {
            childObjectsForDeletedConnections.add((IDiagramModelArchimateObject) addCommand.child);
        }
    }
    // We have some child objects for deletion connections
    if (!childObjectsForDeletedConnections.isEmpty()) {
        Command cmd = new DeleteNestedConnectionsCommand((IDiagramModelArchimateObject) parent, childObjectsForDeletedConnections);
        command.add(cmd);
    }
    // We have some child objects so add the sub command
    if (!childObjectsForNewConnections.isEmpty()) {
        Command cmd = new CreateNestedArchimateConnectionsWithDialogCommand((IDiagramModelArchimateObject) parent, childObjectsForNewConnections);
        command.add(cmd);
    }
    return command.unwrap();
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) CreateNestedArchimateConnectionsWithDialogCommand(com.archimatetool.editor.diagram.commands.CreateNestedArchimateConnectionsWithDialogCommand) Command(org.eclipse.gef.commands.Command) CreateNestedArchimateConnectionsWithDialogCommand(com.archimatetool.editor.diagram.commands.CreateNestedArchimateConnectionsWithDialogCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DeleteNestedConnectionsCommand(com.archimatetool.editor.diagram.commands.DeleteNestedConnectionsCommand) ArrayList(java.util.ArrayList) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) DeleteNestedConnectionsCommand(com.archimatetool.editor.diagram.commands.DeleteNestedConnectionsCommand) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 18 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.

the class WholeFlowLayoutEditPolicy method getCloneCommand.

protected Command getCloneCommand(ChangeBoundsRequest request) {
    String reqType = request.getType() == WholeDragEditPartsTracker.REQ_SHARE ? PartRequest.SHARE_CHILD : PartRequest.CLONE_CHILD;
    CompoundCommand command = new CompoundCommand();
    List<?> editParts = ((ChangeBoundsRequest) request).getEditParts();
    EditPart insertionReference = getInsertionReference(request);
    for (int i = 0; i < editParts.size(); i++) {
        EditPart child = (EditPart) editParts.get(i);
        command.add(createCloneChildCommand(reqType, child, insertionReference));
    }
    return command.unwrap();
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 19 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project whole by wholeplatform.

the class WholeTreeLayoutEditPolicy method getCloneCommand.

protected Command getCloneCommand(ChangeBoundsRequest request) {
    String reqType = request.getType() == WholeDragEditPartsTracker.REQ_SHARE ? PartRequest.SHARE_CHILD : PartRequest.CLONE_CHILD;
    CompoundCommand command = new CompoundCommand();
    List editParts = ((ChangeBoundsRequest) request).getEditParts();
    EditPart insertionReference = getInsertionReference(request);
    for (int i = 0; i < editParts.size(); i++) {
        EditPart child = (EditPart) editParts.get(i);
        command.add(createCloneChildCommand(reqType, child, insertionReference));
    }
    return command.unwrap();
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 20 with ChangeBoundsRequest

use of org.eclipse.gef.requests.ChangeBoundsRequest in project statecharts by Yakindu.

the class RegionCompartmentEditPart method createDefaultEditPolicies.

@Override
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CompartmentCreationEditPolicy());
    installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new RegionCompartmentCanonicalEditPolicy());
    installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
    installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicy() {

        @Override
        protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
            // Remove dithering connection anchors
            CompoundCommand result = new CompoundCommand();
            result.add(super.getResizeChildrenCommand(request));
            AdjustIdentityAnchorCommand command = new AdjustIdentityAnchorCommand(TransactionUtil.getEditingDomain(resolveSemanticElement()), request);
            result.add(new ICommandProxy(command));
            return result;
        }
    });
    // Removes the collapse expand handler
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableEditPolicyEx());
    installEditPolicy(EditPolicyRoles.SNAP_FEEDBACK_ROLE, new SimpleSnapFeedbackPolicy());
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) ResizableEditPolicyEx(org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx) XYLayoutEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy) AdjustIdentityAnchorCommand(org.yakindu.base.xtext.utils.gmf.commands.AdjustIdentityAnchorCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) AdjustIdentityAnchorCommand(org.yakindu.base.xtext.utils.gmf.commands.AdjustIdentityAnchorCommand) CompartmentCreationEditPolicy(org.yakindu.sct.ui.editor.policies.CompartmentCreationEditPolicy) RegionCompartmentCanonicalEditPolicy(org.yakindu.sct.ui.editor.policies.RegionCompartmentCanonicalEditPolicy) DragDropEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)24 Point (org.eclipse.draw2d.geometry.Point)8 EditPart (org.eclipse.gef.EditPart)7 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)7 List (java.util.List)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 ArrayList (java.util.ArrayList)5 Command (org.eclipse.gef.commands.Command)4 PointList (org.eclipse.draw2d.geometry.PointList)3 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)3 IFigure (org.eclipse.draw2d.IFigure)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2 Shell (org.eclipse.swt.widgets.Shell)2 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)2 IEntity (org.whole.lang.model.IEntity)2 IImportAsModelDialog (org.whole.lang.ui.dialogs.IImportAsModelDialog)2 CreateNestedArchimateConnectionsWithDialogCommand (com.archimatetool.editor.diagram.commands.CreateNestedArchimateConnectionsWithDialogCommand)1