@Override protected Command getConnectionCreateCommand( CreateConnectionRequest request) { LinkCommand command = new LinkCommand(); command.setConnection(new Link()); command.setSource(getComponentEditPart().getCastedModel()); ConnectionAnchor ctor = getComponentEditPart().getSourceConnectionAnchor( request); if (ctor == null) return null; command.setSourceTerminal(getComponentEditPart() .mapConnectionAnchorToTerminal(ctor)); request.setStartCommand(command); return command; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ModuleInstancePropertyNode.class) && getHost().getModel() instanceof ModuleInstanceNode) { ModuleInstancePropertyCreateCommand cmd = new ModuleInstancePropertyCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 2); cmd.setNode((ModuleInstancePropertyNode) node); cmd.setParent((ModuleInstanceNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ModuleInstancePropertyNode.DEF_WIDTH, ModuleInstancePropertyNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getMoveBendpointCommand(BendpointRequest request) { Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); BendpointMoveCommand cmd = new BendpointMoveCommand(); cmd.setLink((Link) request.getSource().getModel()); cmd.setIndex(request.getIndex()); cmd.setNewLocation(p); return cmd; }
@Override protected Command getReconnectSourceCommand( ReconnectRequest request) { Link link=(Link)request.getConnectionEditPart().getModel(); Component comp=getComponentEditPart().getCastedModel(); LinkReconnectSourceCommand cmd=new LinkReconnectSourceCommand(link); cmd.setOldSource(link); cmd.setNewSource(comp); ConnectionAnchor anchor=getComponentEditPart().getSourceConnectionAnchor(request); if(anchor==null){ return null; } cmd.setNewSourceTerminal(getComponentEditPart().mapConnectionAnchorToTerminal(anchor)); return cmd; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ComputingNodeConfigurationNode.class) && (getHost().getModel() instanceof PlatformConfigurationNode)) { ComputingNodeConfigurationCreateCommand cmd = new ComputingNodeConfigurationCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 1); cmd.setNode((ComputingNodeConfigurationNode) node); cmd.setParent((PlatformConfigurationNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ComputingNodeConfigurationNode.DEF_WIDTH, ComputingNodeConfigurationNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(LogicalComputingPlatformNode.class) && (getHost().getModel() instanceof LogicalSystemNode)) { LogicalComputingPlatformCreateCommand cmd = new LogicalComputingPlatformCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); cmd.setNode((LogicalComputingPlatformNode) node); cmd.setParent((LogicalSystemNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingPlatformNode.DEF_WIDTH, LogicalComputingPlatformNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(LogicalComputingNode.class) && (getHost().getModel() instanceof LogicalComputingPlatformNode)) { LogicalComputingCreateCommand cmd = new LogicalComputingCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 1); cmd.setNode((LogicalComputingNode) node); cmd.setParent((LogicalComputingPlatformNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, LogicalComputingNode.DEF_WIDTH, LogicalComputingNode.DEF_HEIGHT)); ret = cmd; } return ret; }
protected Command getCreateBendpointCommand(BendpointRequest request) { CreateBendpointCommand com = new CreateBendpointCommand(); Point p = request.getLocation(); conn = getConnection(); conn.translateToRelative(p); com.setLocation(p); Point ref1 = conn.getSourceAnchor().getReferencePoint(); Point ref2 = conn.getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); com.setConn((Connection) request.getSource().getModel()); com.setIndex(request.getIndex()); return com; }
@Override protected Command createMoveChildCommand(EditPart child, EditPart after) { if (child == after || getHost().getChildren().size() == 1) { return null; } int index = getHost().getChildren().indexOf(child); if (index == 0) { if (after == null) return null; } else { if (after == getHost().getChildren().get(index - 1)) return null; } ColumnReorderCommand cmd = new ColumnReorderCommand((Table) getHost().getModel(), (Column) child.getModel()); if (after != null) { cmd.setAfterColumn((Column) after.getModel()); } return cmd; }
@Override protected Command getCreateCommand(CreateRequest request) { Command ret = null; if (request.getNewObjectType().equals(ComponentPropertyNode.class) && (getHost().getModel() instanceof ComponentNode)) { ComponentPropertyNodeCreateCommand cmd = new ComponentPropertyNodeCreateCommand(); Node node = (Node) request.getNewObject(); node.setParent((Node) getHost().getModel()); Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); p = node.getAnchor(p, 1); cmd.setNode((ComponentPropertyNode) node); cmd.setParent((ComponentNode) node.getParent()); cmd.setLocation(new Rectangle(p.x, p.y, ComponentPropertyNode.DEF_WIDTH, ComponentPropertyNode.DEF_HEIGHT)); ret = cmd; } return ret; }
@Override protected Command getConnectionCompleteCommand( CreateConnectionRequest request) { LinkCommand command = (LinkCommand) request .getStartCommand(); command.setTarget(getComponentEditPart().getCastedModel()); ConnectionAnchor ctor = getComponentEditPart().getTargetConnectionAnchor( request); if (ctor == null) return null; command.setTargetTerminal(getComponentEditPart() .mapConnectionAnchorToTerminal(ctor)); return command; }
protected Command getMoveBendpointCommand(BendpointRequest request) { MoveBendpointCommand com = new MoveBendpointCommand(); Point p = request.getLocation(); conn = getConnection(); conn.translateToRelative(p); com.setLocation(p); Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); com.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); com.setConn((Connection) request.getSource().getModel()); com.setIndex(request.getIndex()); return com; }
@Override protected Command getReconnectTargetCommand( ReconnectRequest request) { Link link=(Link)request.getConnectionEditPart().getModel(); Component component=getComponentEditPart().getCastedModel(); ConnectionAnchor anchor=getComponentEditPart().getTargetConnectionAnchor(request); if(anchor==null){ return null; } LinkReconnectTargetCommand command=new LinkReconnectTargetCommand(link); command.setOldTarget(link); command.setNewTarget(component); command.setNewTargetTerminal(getComponentEditPart().mapConnectionAnchorToTerminal(anchor)); return command; }
private Command createCopyCommand(List<Object> selectedObjects) { if (selectedObjects == null || selectedObjects.isEmpty()) { return null; } CopyNodeCommand cmd = new CopyNodeCommand(); Iterator<Object> it = selectedObjects.iterator(); while (it.hasNext()) { Object obj = it.next(); if (!(obj instanceof EditPart)) continue; EditPart ep = (EditPart) obj; if (!(ep.getModel() instanceof GWNode)) continue; GWNode gWNode = (GWNode) ep.getModel(); if (!cmd.isCopyableNode(gWNode)) return null; cmd.addElement(ep); } return cmd; }
@Override protected Command createChangeConstraintCommand(EditPart child, Object constraint) { ChangeConstraintCommand ret = new ChangeConstraintCommand(); ret.setModel((Node) child.getModel()); ret.setNewConstraint((Rectangle) constraint); return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof TriggerInstanceNode) { TriggerInstanceNode pNode = (TriggerInstanceNode) node; TriggerInstanceDeleteCommand cmd = new TriggerInstanceDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ComponentImplementationNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ModuleInstanceNode) { ModuleInstanceNode pNode = (ModuleInstanceNode) node; ModuleInstanceDeleteCommand cmd = new ModuleInstanceDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ModuleTypeNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof DynamicTriggerInstanceNode) { DynamicTriggerInstanceNode pNode = (DynamicTriggerInstanceNode) node; DynamicTriggerInstanceDeleteCommand cmd = new DynamicTriggerInstanceDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ComponentImplementationNode) pNode.getParent()); ret = cmd; } return ret; }
@Override public Command getCommand(Request request) { if (request.getType().equals(RequestConstants.TABLE_MODIFY)) { return createTableModifyCommand(request); } return null; }
@Override protected Command getDeleteCommand(GroupRequest request) { LinkDeleteCommand cmd = new LinkDeleteCommand(); cmd.setLink((Link) getHost().getModel()); cmd.setSource(cmd.getLink().getSource()); cmd.setTarget(cmd.getLink().getTarget()); return cmd; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ModuleTypeNode) { ModuleTypeNode pNode = (ModuleTypeNode) node; ModuleTypeDeleteCommand cmd = new ModuleTypeDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ComponentImplementationNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command getMoveBendpointCommand(BendpointRequest request) { MoveBendpointCommand command=new MoveBendpointCommand(); Point point = request.getLocation(); int index=request.getIndex(); Transition transition=(Transition)getHost().getModel(); command.setIndex(index); command.setPoint(point); command.setTransition(transition); return command; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ModuleImplementationNode) { ModuleImplementationNode pNode = (ModuleImplementationNode) node; ModuleImplementationDeleteCommand cmd = new ModuleImplementationDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ModuleTypeNode) pNode.getParent()); ret = cmd; } return ret; }
@SuppressWarnings("unchecked") public Command createTableModifyCommand(Request request) { Map<String, Object> map = request.getExtendedData(); Table model = (Table) getHost().getModel(); Table data = (Table) map.get(TableModifyCommand.TEMP_DATA); return new TableModifyCommand(model, data); }
@Override protected Command getConnectionCreateCommand(CreateConnectionRequest request) { Node start = (Node) getHost().getModel(); if (start instanceof ServiceOperationNode || start instanceof TriggerInstanceTerminalNode || start instanceof DynamicTriggerInstanceTerminalNode || start instanceof ModuleOperationNode) { LinkCreateCommand cmd = new LinkCreateCommand(); cmd.setSource(start); cmd.setLink((Link) request.getNewObject()); request.setStartCommand(cmd); return cmd; } return null; }
/** * Creates the command which is used to move and/or resize a shape */ @Override protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) { if (child instanceof ComponentEditPart && constraint instanceof Rectangle) { //return a command that can move and/or resize a Shape return new ComponentSetConstraintCommand((Component) child.getModel(), request, (Rectangle) constraint); } else if (child instanceof CommentBoxEditPart && constraint instanceof Rectangle){ return new CommentBoxSetConstraintCommand((CommentBox) child.getModel(), request , (Rectangle) constraint); } return super.createChangeConstraintCommand(request, child, constraint); }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ModuleOperationNode) { ModuleOperationNode pNode = (ModuleOperationNode) node; ModuleOperationDeleteCommand cmd = new ModuleOperationDeleteCommand(); cmd.setNode(pNode); cmd.initLinks(); cmd.setParent((ModuleTypeNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command getCreateBendpointCommand(BendpointRequest request) { Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); BendpointCreateCommand cmd = new BendpointCreateCommand(); cmd.setLink((Link) request.getSource().getModel()); cmd.setLocation(p); cmd.setIndex(request.getIndex()); return cmd; }
@Override protected Command getDeleteBendpointCommand(BendpointRequest request) { Viewport vp = ((FigureCanvas) getHost().getViewer().getControl()).getViewport(); Point viewSize = vp.getViewLocation(); Point p = request.getLocation(); p.setX(p.x + viewSize.x); p.setY(p.y + viewSize.y); BendpointDeleteCommand cmd = new BendpointDeleteCommand(); cmd.setLink((Link) request.getSource().getModel()); cmd.setLocation(p); cmd.setIndex(request.getIndex()); return cmd; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof PlatformConfigurationNode) { PlatformConfigurationNode pNode = (PlatformConfigurationNode) node; PlatformConfigurationDeleteCommand cmd = new PlatformConfigurationDeleteCommand(); cmd.setNode(pNode); cmd.setParent((DeploymentNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ProtectionDomainNode) { ProtectionDomainNode pNode = (ProtectionDomainNode) node; ProtectionDomainDeleteCommand cmd = new ProtectionDomainDeleteCommand(); cmd.setNode(pNode); cmd.setParent((DeploymentNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof DeployedTriggerInstanceNode) { DeployedTriggerInstanceNode pNode = (DeployedTriggerInstanceNode) node; DeployedTriggerInstanceDeleteCommand cmd = new DeployedTriggerInstanceDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ProtectionDomainNode) pNode.getParent()); ret = cmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof LogicalProcessorsNode) { CompoundWrapperCommand cCmd = new CompoundWrapperCommand(); LogicalProcessorsNode cNode = (LogicalProcessorsNode) node; LogicalProcessorsDeleteCommand cmd = new LogicalProcessorsDeleteCommand(); cmd.setNode(cNode); cmd.setParent((LogicalComputingNode) cNode.getParent()); cCmd.add(cmd); ret = cCmd; } return ret; }