public void performExecution() { if (compoundCommand != null) { try { actualCommandStack.execute(compoundCommand); } finally { compoundCommand = null; } } }
@Override protected boolean prepare() { boolean result = true; CommandStack commandStack = domain.getCommandStack(); if (domain == null || !(commandStack instanceof PersistentCommandStack) || commandStack.getMostRecentCommand() != null) { result = false; } return result; }
/** * Call this method to undo the last transformation. * * @return True, if it was successful. */ public boolean undoLastTransformation() { Objects.requireNonNull(editingDomain, "To be able to undo the transformation initialize with editing domain."); if (currentIndex > 0) { editingDomain.getCommandStack().undo(); currentIndex--; return true; } return false; }
editingDomain.getCommandStack().flush(); Resource mainResource = editingDomain.getResourceSet().getResources().get(0);
/** * Execute a command directly on the command stack */ public void executeViaStack(Command command) { getCommandStack().execute(command); }
@Override protected boolean prepare() { boolean result = true; CommandStack commandStack = domain.getCommandStack(); if (domain == null || !(commandStack instanceof PersistentCommandStack) || commandStack.getMostRecentCommand() != null) { result = false; } return result; }
public void backtrackXTimes(int steps) { for (int i = steps; i > 0; i--) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked " + steps + " times."); }
protected void executeCommand(Command command) throws ModelManipulationException { if (command.canExecute()) { domain.getCommandStack().execute(command); } else { throw new ModelManipulationException("Cannot execute command"); } }
public void undoUntilRoot() { while(trajectory.canStepBack()) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); logger.debug("Backtracked to root."); }
public void modifyText(ModifyEvent e) { if (syncTextAndModel()) { CommandModifyServiceInterfaceText command = new CommandModifyServiceInterfaceText(null, null, eObject_, text_.getText()); artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } }
public int backtrackUntilLastCommonActivation(Object[] newTrajectory) { Iterator<Object> currentTrajectoryIterator = trajectory.getTrajectory().iterator(); if (!currentTrajectoryIterator.hasNext()) { return 0; } int indexOfLastCommonActivation = 0; for (Object activationCode : newTrajectory) { if (currentTrajectoryIterator.hasNext()) { Object activationCodeFromCurrent = currentTrajectoryIterator.next(); if (activationCodeFromCurrent.equals(activationCode)) { indexOfLastCommonActivation++; } else { break; } } else { // current trajectory is smaller break; } } int numberOfBacktracks = trajectory.getDepth() - indexOfLastCommonActivation; if (numberOfBacktracks > 0) { for (int i = numberOfBacktracks; i > 0; i--) { domain.getCommandStack().undo(); trajectory.backtrack(); } activationCodes.updateActivationCodes(); } logger.debug("Backtracked " + numberOfBacktracks + " times."); return indexOfLastCommonActivation; }
public void modifyText(ModifyEvent e) { if (syncTextAndModel()) { CommandModifyHandlerClassText command = new CommandModifyHandlerClassText(null, null, eObject_, text_.getText()); if (artifactEdit != null) { artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } } }
public boolean undoLastTransformation() { if (!trajectory.canStepBack()) { return false; } domain.getCommandStack().undo(); activationCodes.updateActivationCodes(); Object lastActivationId = trajectory.getLastActivationId(); trajectory.backtrack(); if (handlers != null) { for (IExploreEventHandler iExploreEventHandler : handlers) { iExploreEventHandler.undo(lastActivationId); } } logger.debug("Backtrack."); return true; }
public void modifyText(ModifyEvent e) { if (syncTextAndModel()) { CommandModifyText command = new CommandModifyText(null, null, eObject_, feature_, text_.getText(), nillable_); if (artifactEdit != null) { artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } } }
editingDomain.getCommandStack().execute(cc);
domain.getCommandStack().execute(rc);
/** * Sets the property value. If an editing domain can be obtained, the command returned by {@link #createSetCommand * createSetcommand} is executed; otherwise, {@link #setValue setValue} is called to set the value. */ @Override public void setPropertyValue(Object object, Object value) { EObject eObject = (EObject)owner; EditingDomain editingDomain = getEditingDomain(owner); if (editingDomain == null) { setValue(eObject, feature, value); } else { editingDomain.getCommandStack().execute(createSetCommand(editingDomain, eObject, feature, value)); } }
public void modifyText(ModifyEvent e) { if (syncTextAndModel()) { //Handle PortComponentRef_ServiceEndpointInterface feature in a special way. String SEIFeatureName = Webservice_clientPackage.eINSTANCE.getPortComponentRef_ServiceEndpointInterface().getName(); if ((eObject_ instanceof PortComponentRef) && (feature_.getName().equals(SEIFeatureName))) { CommandModifySEI command = new CommandModifySEI(null, null, (PortComponentRef) eObject_, text_.getText(), nillable_); artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } else { CommandModifyText command = new CommandModifyText(null, null, eObject_, feature_, text_.getText(), nillable_); artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } } }
public void modifyText(ModifyEvent e) { if (syncTextAndModel()) { //Handle QName_NamespaceURI feature in a special way. String namespaceFeatureName = CommonPackage.eINSTANCE.getQName_NamespaceURI().getName(); if ((eObject_ instanceof QName) && (feature_.getName().equals(namespaceFeatureName))) { CommandModifyNSURI command = new CommandModifyNSURI(null, null, (QName) eObject_, text_.getText(), nillable_); if (artifactEdit != null) { artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } } else { CommandModifyText command = new CommandModifyText(null, null, eObject_, feature_, text_.getText(), nillable_); if (artifactEdit != null) { artifactEdit.getContentModelRoot().eResource().setModified(true); artifactEdit.getCommandStack().execute(command); } } } } }
domain.getCommandStack().execute(rc);