@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { DwFeatureEditPart editPart = (DwFeatureEditPart)getHost(); DwGraphicalFeatureModelViewer viewer = (DwGraphicalFeatureModelViewer)editPart.getEditor(); DwFeatureWrapped wrappedFeature = (DwFeatureWrapped)getHost().getModel(); if(!viewer.isLastDateSelected()) return null; Command deleteCommand = null; if(viewer.getCurrentSelectedDate().equals(new Date(Long.MIN_VALUE))){ deleteCommand = new DwFeatureDeletePermanentlyCommand(viewer, getHost()); ((DwFeatureDeletePermanentlyCommand)deleteCommand).setFeature(wrappedFeature); }else{ deleteCommand = new DwFeatureDeleteCommand(viewer, getHost()); ((DwFeatureDeleteCommand)deleteCommand).setFeature(wrappedFeature); } return deleteCommand; }
/** * {@inheritDoc} */ @Override protected Command createDeleteCommand(final GroupRequest request) { if (getHost() instanceof DeleteableEditPart) { final DeleteableEditPart editPart = (DeleteableEditPart) getHost(); if (!editPart.isDeleteable()) { return null; } } else { return null; } final ERDiagram diagram = (ERDiagram) getHost().getRoot().getContents().getModel(); return this.createDeleteCommand(diagram, getHost().getModel()); }
/** * {@inheritDoc} */ @Override protected Command createDeleteCommand(GroupRequest request) { if (this.getHost() instanceof DeleteableEditPart) { DeleteableEditPart editPart = (DeleteableEditPart) this.getHost(); if (!editPart.isDeleteable()) { return null; } } else { return null; } ERDiagram diagram = (ERDiagram) this.getHost().getRoot().getContents() .getModel(); return this.createDeleteCommand(diagram, this.getHost().getModel()); }
protected Command createDeleteCommand(GroupRequest deleteRequest) { Object parent = getHost().getParent().getModel(); Object child = getHost().getModel(); if (parent instanceof Window && child instanceof TitleBar){ return new DeleteTitleBarCommand((Window) parent, (TitleBar) child); } else if (parent instanceof TitleBar){ return new DeleteTitleBarChildCommand((TitleBar) parent, (TitaniumUIBoundedElement) child); } else if (parent instanceof Container && child instanceof Element) { return new DeleteElementCommand((Container) parent, (Element) child); } else if (parent instanceof TitaniumUIContainer && child instanceof TitaniumUIElement) { return new DeleteTitaniumElementCommand((TitaniumUIContainer) parent, (TitaniumUIBoundedElement) child); } return super.createDeleteCommand(deleteRequest); }
/** * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest) */ @Override protected Command getDeleteCommand(GroupRequest request) { Command command; if (getHost() instanceof AbstractChildCompartmentEditPart) { if (!(getHost() instanceof AttributeEditPart) && !(getHost() instanceof OperationEditPart)) { return null; } } command = new DeleteNodeCommand(); ((DeleteNodeCommand) command).setParent(getHost().getParent().getModel()); ((DeleteNodeCommand) command).setNode(getHost().getModel()); return command; }
/** * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest) */ @Override protected Command getDeleteCommand(GroupRequest request) { if (getHost() instanceof LifeLineNameHeaderEditPart) { return null; } if (getHost() instanceof AbstractChildCompartmentEditPart) { return null; } else { DeleteLifeLineCommand command = new DeleteLifeLineCommand(); ((DeleteLifeLineCommand) command).setDiagram(SequenceUtil.getDiagram(getHost())); ((DeleteLifeLineCommand) command).setLifeLineNode((LifeLineNode) getHost().getModel()); return command; } }
@Override protected void createEditPolicies() { installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { @Override protected Command createDeleteCommand(GroupRequest deleteRequest) { return new DeleteCommand(getModel()); } }); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new TableNodeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new TableLayoutEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new SelectionEditPolicy() { @Override protected void hideSelection() { getFigure().hideSelectedBorder(); } @Override protected void showSelection() { getFigure().showSelectedBorder(); } }); }
/** * Search for every AMcollection (superclass of the row of the table) * and create a delete cell command for everyone of its children */ @Override public Command createDeleteCommand(List objects) { if (objects.isEmpty()) return null; if (!(objects.get(0) instanceof EditPart)) return null; GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE); deleteReq.setEditParts(objects); JSSCompoundCommand compoundCmd = new JSSCompoundCommand(getText(), null); for (int i = 0; i < objects.size(); i++) { EditPart object = (EditPart) objects.get(i); if (object.getModel() instanceof AMCollection && !(object.getModel() instanceof MTableDetail)) { AMCollection model = (AMCollection) object.getModel(); compoundCmd.setReferenceNodeIfNull(model); createDeleteCommands(model.getChildren(), compoundCmd); } } return compoundCmd; }
@Override protected void createEditPolicies() { installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()); installEditPolicy(EditPolicy.CONTAINER_ROLE, new AxisContainerEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { protected Command createDeleteCommand(GroupRequest deleteRequest) { DependentAxis dataset = (DependentAxis) getHost().getModel(); Chart parent = (Chart) dataset.eContainer(); DeleteAxisFromChartCommand cmd = new DeleteAxisFromChartCommand(parent, dataset); return cmd; } }); }
@Override protected void createEditPolicies() { installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { protected Command createDeleteCommand(GroupRequest deleteRequest) { Dataset dataset = (Dataset) getHost().getModel(); DependentAxis parent = (DependentAxis) getHost().getParent().getModel(); DeleteDatasetsFromAxisCommand cmd = new DeleteDatasetsFromAxisCommand(parent, dataset); return cmd; } }); }
@Override protected void createEditPolicies() { installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()); installEditPolicy(EditPolicy.CONTAINER_ROLE, new ChartContainerEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { protected Command createDeleteCommand(GroupRequest deleteRequest) { Chart chart = getModel(); ChartSet parent = chart.getParent(); DeleteChartCommand deleteChartCommand = new DeleteChartCommand(parent, chart); return deleteChartCommand; } }); }
@Override protected void createEditPolicies() { installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { protected Command createDeleteCommand(GroupRequest deleteRequest) { // TODO: implement // 1. do not use this scatter set in the current chart // 2. if scatter set used only here, then delete scatter set from shared axis return new DeleteScatterSetCommand(getModel(), getChart()); } }); }
/** * Create a command to remove the selected objects. * * @param objects * The objects to be deleted. * @return The command to remove the selected objects. */ public Command createDeleteCommand(List objects) { if (objects.isEmpty()) return null; if (!(objects.get(0) instanceof EditPart)) return null; GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE); deleteReq.setEditParts(objects); CompoundCommand compoundCmd = new CompoundCommand( GEFMessages.DeleteAction_ActionDeleteCommandName); for (int i = 0; i < objects.size(); i++) { EditPart object = (EditPart) objects.get(i); Command cmd = object.getCommand(deleteReq); if (cmd != null) compoundCmd.add(cmd); } return compoundCmd; }
@Override protected Command getOrphanChildrenCommand(GroupRequest request) { CompoundCommand result = new CompoundCommand(); List<EditPart> list = request.getEditParts(); result.setDebugLabel("Orphan children"); for (EditPart part : list) { ORMOrphanChildCommand orphan = new ORMOrphanChildCommand(); orphan.setChild((Shape) part.getModel()); orphan.setParent((Model) this.getHost().getModel()); orphan.setLabel("Reparenting"); result.add(orphan); } return result.unwrap(); }
@Override protected void createEditPolicies() { // mark & unmark commands installEditPolicy("Mark and Unmark", new CodeElementMarkEditPolicy()); // delete command installEditPolicy(EditPolicy.COMPONENT_ROLE, new ComponentEditPolicy() { @Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Object container = getHost().getParent().getModel(); Object ce = getHost().getModel(); if (container instanceof Shape && ce instanceof CodeElement) return new DeleteCodeElementCommand((Shape) container, (CodeElement) ce); return super.createDeleteCommand(deleteRequest); } }); }
protected void createEditPolicies( ) { installEditPolicy( EditPolicy.COMPONENT_ROLE, new ReportComponentEditPolicy( ) { protected org.eclipse.gef.commands.Command createDeleteCommand( GroupRequest deleteRequest ) { return UnexecutableCommand.INSTANCE; } protected Command getOrphanCommand( ) { return new Command( ) { }; } } ); installEditPolicy( EditPolicy.LAYOUT_ROLE, new CrosstabCellFlowLayoutEditPolicy( ) ); installEditPolicy( EditPolicy.CONTAINER_ROLE, new CrosstabCellContainerEditPolicy( ) ); }
/** * Returns either a DeletePathNodeCommand * * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest) */ protected Command getDeleteCommand(GroupRequest request) { Object parent = getHost().getParent().getModel(); Object node = getHost().getModel(); java.util.Map registry; if (getHost().getViewer() instanceof TreeViewer) { // we need an editpart registry with NodeConnectionEditParts UCMNavMultiPageEditor editor = (UCMNavMultiPageEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); registry = editor.getCurrentPage().getGraphicalViewer().getEditPartRegistry(); } else registry = getHost().getViewer().getEditPartRegistry(); if (parent instanceof UCMmap && node instanceof PathNode) { return new DeletePathNodeCommand((PathNode) node, registry); } return super.createDeleteCommand(request); }
/** * Returns a DeleteMapCommand * * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest) */ protected Command getDeleteCommand(GroupRequest request) { Object elem = getHost().getModel(); if (elem instanceof UCMmap) { UCMmap diagram = (UCMmap) elem; URNspec urn = (URNspec) diagram.eContainer().eContainer(); int nbDiagrams = urn.getUrndef().getSpecDiagrams().size(); if (nbDiagrams > 1) { // we can delete it, not the last GRL/UCM diagram return new DeleteMapCommand(diagram); } else { // last diagram, cannot delete! return null; } } else return null; }
/** * Returns a DeleteGRLGraphCommand * * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#getDeleteCommand(org.eclipse.gef.requests.GroupRequest) */ protected Command getDeleteCommand(GroupRequest request) { Object elem = getHost().getModel(); if (elem instanceof GRLGraph) { GRLGraph diagram = (GRLGraph) elem; URNspec urn = (URNspec) diagram.eContainer().eContainer(); int nbDiagrams = urn.getUrndef().getSpecDiagrams().size(); if (nbDiagrams > 1) { // we can delete it, not the last GRL/UCM diagram return new DeleteGRLGraphCommand(diagram); } else { // last diagram, cannot delete! return null; } } else return null; }
/** * Test #3 for requirement ReqElemDelete * * Author: jkealey */ public void testReqElemDelete3() { testReqComp1(); // set the parent somewhere. ComponentRefEditPart parentEditPart = (ComponentRefEditPart) getMapEditPart(0).getChildren().get(2); Command cmd = parentEditPart.getCommand(new GroupRequest(RequestConstants.REQ_DELETE)); assertTrue("ComponentRefEditPolicy doesn't return a valid DeleteComponentRefCommand", cmd instanceof DeleteComponentRefCommand && cmd.canExecute()); //$NON-NLS-1$ getGraphicalViewer().getEditDomain().getCommandStack().execute(cmd); // refresh the edit part tree because we aren't hooked up to the command stack getMapEditPart(0).refreshChildren(); assertEquals("only one ComponentRef should remain in model ", 1, getMap().getContRefs().size()); //$NON-NLS-1$ assertEquals("Only one ComponentRefEditPart should remain in editpart tree ", 2, getMapEditPart(0).getChildren().size()); //$NON-NLS-1$ }
@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 protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ModuleOperationParameterNode) { ModuleOperationParameterNode pNode = (ModuleOperationParameterNode) node; ModuleOperationParameterDeleteCommand cmd = new ModuleOperationParameterDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ModuleOperationNode) pNode.getParent()); ret = cmd; } return ret; }
@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 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; }
@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 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 DeployedModuleInstanceNode) { DeployedModuleInstanceNode pNode = (DeployedModuleInstanceNode) node; DeployedModuleInstanceDeleteCommand cmd = new DeployedModuleInstanceDeleteCommand(); 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 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 ComputingNodeConfigurationNode) { ComputingNodeConfigurationNode pNode = (ComputingNodeConfigurationNode) node; ComputingNodeConfigurationDeleteCommand cmd = new ComputingNodeConfigurationDeleteCommand(); cmd.setNode(pNode); cmd.setParent((PlatformConfigurationNode) 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; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof LogicalComputingNode) { CompoundWrapperCommand cCmd = new CompoundWrapperCommand(); LogicalComputingNode cNode = (LogicalComputingNode) node; LogicalComputingDeleteCommand cmd = new LogicalComputingDeleteCommand(); cmd.setNode(cNode); cmd.setParent((LogicalComputingPlatformNode) cNode.getParent()); cCmd.add(cmd); ret = cCmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof LogicalComputingPlatformNode) { CompoundWrapperCommand cCmd = new CompoundWrapperCommand(); LogicalComputingPlatformNode cNode = (LogicalComputingPlatformNode) node; LogicalComputingPlatformDeleteCommand cmd = new LogicalComputingPlatformDeleteCommand(); cmd.setNode(cNode); cmd.setParent((LogicalSystemNode) cNode.getParent()); cCmd.add(cmd); ret = cCmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ComponentNode) { CompoundWrapperCommand cCmd = new CompoundWrapperCommand(); ComponentNode cNode = (ComponentNode) node; ComponentNodeDeleteCommand cmd = new ComponentNodeDeleteCommand(); cmd.setNode(cNode); cmd.setParent((CompositeNode) cNode.getParent()); getModifiedlinks(cNode); if (modifiedLinks != null && modifiedLinks.size() > 0) { for (Link link : modifiedLinks) { LinkDeleteCommand lCmd = new LinkDeleteCommand(); lCmd.setLink(link); lCmd.setSource(lCmd.getLink().getSource()); lCmd.setTarget(lCmd.getLink().getTarget()); cCmd.add(lCmd); } } getProperties(cNode); if (properties != null && properties.size() > 0) { for (Node child : properties) { ComponentPropertyNodeDeleteCommand pCmd = new ComponentPropertyNodeDeleteCommand(); pCmd.setNode((ComponentPropertyNode) child); pCmd.setParent(cNode); cCmd.add(pCmd); } } cCmd.add(cmd); ret = cCmd; } return ret; }
@Override protected Command createDeleteCommand(GroupRequest deleteRequest) { Command ret = null; Node node = (Node) getHost().getModel(); if (node instanceof ComponentPropertyNode) { ComponentPropertyNode pNode = (ComponentPropertyNode) node; ComponentPropertyNodeDeleteCommand cmd = new ComponentPropertyNodeDeleteCommand(); cmd.setNode(pNode); cmd.setParent((ComponentNode) pNode.getParent()); ret = cmd; } return ret; }