當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandStack.execute方法代碼示例

本文整理匯總了Java中org.eclipse.emf.common.command.CommandStack.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandStack.execute方法的具體用法?Java CommandStack.execute怎麽用?Java CommandStack.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.common.command.CommandStack的用法示例。


在下文中一共展示了CommandStack.execute方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
public static Object execute(TransactionalEditingDomain editingDomain, RecordingCommand command) {
	final CommandStack commandStack = editingDomain.getCommandStack();
	ResourceSet rs = editingDomain.getResourceSet();
	IExecutionCheckpoint checkpoint = IExecutionCheckpoint.CHECKPOINTS.get(rs);
	Object result = null;
	try {
		if (checkpoint != null) {
			checkpoint.allow(rs, true);
		}
		commandStack.execute(command);
		if (command.getResult() != null && command.getResult().size() == 1) {
			result = command.getResult().iterator().next();
		}
	} finally {
		if (checkpoint != null) {
			checkpoint.allow(rs, false);
		}
	}
	return result;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:21,代碼來源:CommandExecution.java

示例2: createEmfFileForDiagram

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
public static void createEmfFileForDiagram(URI diagramResourceUri, final Diagram diagram) {

    // Create a resource set and EditingDomain
    final TransactionalEditingDomain editingDomain = GraphitiUiInternal.getEmfService().createResourceSetAndEditingDomain();
    final ResourceSet resourceSet = editingDomain.getResourceSet();
    // Create a resource for this file.
    final Resource resource = resourceSet.createResource(diagramResourceUri);
    final CommandStack commandStack = editingDomain.getCommandStack();
    commandStack.execute(new RecordingCommand(editingDomain) {

      @Override
      protected void doExecute() {
        resource.setTrackingModification(true);
        resource.getContents().add(diagram);

      }
    });

    save(editingDomain, Collections.<Resource, Map<?, ?>> emptyMap());
    editingDomain.dispose();
  }
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:22,代碼來源:FileService.java

示例3: mergeBack

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
protected EObject mergeBack(final EObject object, final TransactionalEditingDomain editingDomain) {
  XtextResource _resource = this.resourceProvider.getResource();
  IParseResult _parseResult = _resource.getParseResult();
  final EObject modelCopy = _parseResult.getRootASTElement();
  final EObject copy = this.modelMerger.findMatchingObject(modelCopy, object);
  boolean _or = false;
  if ((copy == null)) {
    _or = true;
  } else {
    EObject _eContainer = copy.eContainer();
    boolean _tripleEquals = (_eContainer == null);
    _or = _tripleEquals;
  }
  if (_or) {
    return null;
  }
  CommandStack _commandStack = editingDomain.getCommandStack();
  _commandStack.execute(new RecordingCommand(editingDomain, "Text Changes") {
    @Override
    protected void doExecute() {
      TextPropertiesViewPart.this.modelMerger.merge(copy, object);
    }
  });
  return copy;
}
 
開發者ID:spoenemann,項目名稱:xtext-gef,代碼行數:26,代碼來源:TextPropertiesViewPart.java

示例4: refreshRepresentations

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
/**
 * Refreshes given {@link DRepresentation} in the given {@link TransactionalEditingDomain}.
 * 
 * @param transactionalEditingDomain
 *            the {@link TransactionalEditingDomain}
 * @param representations
 *            the {@link List} of {@link DRepresentation} to refresh
 */
public void refreshRepresentations(final TransactionalEditingDomain transactionalEditingDomain,
		final List<DRepresentation> representations) {
	// TODO prevent the editors from getting dirty
	if (representations.size() != 0) {
		final RefreshRepresentationsCommand refresh = new RefreshRepresentationsCommand(
				transactionalEditingDomain, new NullProgressMonitor(), representations);

		CommandStack commandStack = transactionalEditingDomain.getCommandStack();

		// If the command stack is transactionnal, we add a one-shot exception handler.
		if (commandStack instanceof AbstractTransactionalCommandStack) {
			AbstractTransactionalCommandStack transactionnalCommandStack = (AbstractTransactionalCommandStack)commandStack;
			transactionnalCommandStack.setExceptionHandler(new ExceptionHandler() {

				@Override
				public void handleException(Exception e) {
					// TODO Auto-generated method stub

					String repString = representations.stream().map(r -> r.getName()).collect(
							Collectors.joining(", "));
					DebugSiriusIdeUiPlugin.getPlugin().getLog().log(new Status(IStatus.WARNING,
							DebugSiriusIdeUiPlugin.ID, "Failed to refresh Sirius representation(s)["
									+ repString + "], we hope to be able to do it later", e));

					// Self-remove from the command stack.
					transactionnalCommandStack.setExceptionHandler(null);

				}
			});
		}

		commandStack.execute(refresh);

	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:44,代碼來源:AbstractDSLDebuggerServices.java

示例5: createDiagram

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
/**
 * Create a diagram with given URIs.
 * 
 * @param diagramURI
 *            URI for the diagram file
 * @param modelURI
 *            URI for the model file
 * @param progressMonitor
 *            progress monitor
 * @return a resource for the new diagram file
 */
private Resource createDiagram(final URI diagramURI, final URI modelURI,
        final IProgressMonitor progressMonitor) {
    progressMonitor.beginTask("Creating diagram and model files", 2);
    // create a resource set and editing domain
    TransactionalEditingDomain editingDomain = GraphitiUi.getEmfService()
            .createResourceSetAndEditingDomain();
    ResourceSet resourceSet = editingDomain.getResourceSet();
    CommandStack commandStack = editingDomain.getCommandStack();
    // create resources for the diagram and domain model files
    final Resource diagramResource = resourceSet.createResource(diagramURI);
    final Resource modelResource = resourceSet.createResource(modelURI);
    if (diagramResource != null && modelResource != null) {
        commandStack.execute(new RecordingCommand(editingDomain) {
            @Override
            protected void doExecute() {
                createModel(diagramResource, diagramURI.lastSegment(), modelResource,
                        modelURI.lastSegment());
            }
        });
        progressMonitor.worked(1);

        try {
            modelResource.save(createSaveOptions());
            diagramResource.save(createSaveOptions());
        } catch (IOException exception) {
            IStatus status = new Status(IStatus.ERROR, PLUGIN_ID,
                    "Unable to store model and diagram resources", exception);
            StatusManager.getManager().handle(status);
        }
        setCharset(WorkspaceSynchronizer.getFile(modelResource));
        setCharset(WorkspaceSynchronizer.getFile(diagramResource));
    }
    progressMonitor.done();
    return diagramResource;
}
 
開發者ID:spoenemann,項目名稱:xtext-gef,代碼行數:47,代碼來源:GraphitiNewWizard.java

示例6: createEmfFileForDiagram

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
public static TransactionalEditingDomain createEmfFileForDiagram(URI diagramResourceUri, final Diagram diagram,
		final InputStream contentStream, final IFile resourceFile) {

	// Create a resource set and EditingDomain
	final TransactionalEditingDomain editingDomain = DiagramEditorFactory.createResourceSetAndEditingDomain();
	final ResourceSet resourceSet = editingDomain.getResourceSet();
	// Create a resource for this file.
	final Resource resource = resourceSet.createResource(diagramResourceUri);

	final CommandStack commandStack = editingDomain.getCommandStack();
	commandStack.execute(new RecordingCommand(editingDomain) {

		@Override
		protected void doExecute() {
			resource.setTrackingModification(true);
			if (contentStream == null) {
				resource.getContents().add(diagram);
			} else {
				try {
					resourceFile.create(contentStream, IResource.FORCE, null);
				} catch (CoreException e) {
					// TODO
					e.printStackTrace();
				}
			}
		}
	});

	save(editingDomain, Collections.<Resource, Map<?, ?>> emptyMap());
	return editingDomain;
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:32,代碼來源:FileService.java

示例7: deleteCommandTest

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
/**
 * check element deletion tracking.
 * 
 * @throws UnsupportedOperationException on test fail
 * @throws UnsupportedNotificationException on test fail
 */
@Test
public void deleteCommandTest() throws UnsupportedOperationException, UnsupportedNotificationException {

	final TestElement useCase = Create.testElement();
	Add.toProject(getLocalProject(), useCase);
	clearOperations();
	final ModelElementId useCaseId = getProject().getModelElementId(useCase);

	final Command deleteCommand = DeleteCommand.create(
		ESWorkspaceProviderImpl.getInstance().getEditingDomain(),
		useCase);
	final CommandStack commandStack = ESWorkspaceProviderImpl.getInstance().getEditingDomain().getCommandStack();
	if (deleteCommand.canExecute()) {
		commandStack.execute(deleteCommand);
	} else {
		fail(COMMAND_NOT_EXECUTABLE);
	}

	final List<AbstractOperation> operations = getProjectSpace().getOperations();

	assertEquals(1, operations.size());
	final AbstractOperation operation = operations.get(0);
	assertTrue(operation instanceof CreateDeleteOperation);
	final CreateDeleteOperation createDeleteOperation = (CreateDeleteOperation) operation;

	assertEquals(useCaseId, createDeleteOperation.getModelElementId());
	assertEquals(0, createDeleteOperation.getSubOperations().size());
	assertTrue(createDeleteOperation.isDelete());
}
 
開發者ID:edgarmueller,項目名稱:emfstore-rest,代碼行數:36,代碼來源:CommandTest.java

示例8: createDiagram

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
public static Resource createDiagram(final URI diagramURI, final URI modelURI) {
    // create a resource set and editing domain
    TransactionalEditingDomain editingDomain = GraphitiUi.getEmfService()
            .createResourceSetAndEditingDomain();
    ResourceSet resourceSet = editingDomain.getResourceSet();
    CommandStack commandStack = editingDomain.getCommandStack();
    // create resources for the diagram and domain model files
    final Resource diagramResource = resourceSet.createResource(diagramURI);
    final Resource modelResource = resourceSet.createResource(modelURI);
    if (diagramResource != null && modelResource != null) {
        commandStack.execute(new RecordingCommand(editingDomain) {
            @Override
            protected void doExecute() {
                createModel(diagramResource, diagramURI.lastSegment(), modelResource,
                        modelURI.lastSegment());
            }
        });

        try {
            modelResource.save(createSaveOptions());
            diagramResource.save(createSaveOptions());
        } catch (IOException exception) {
            IStatus status = new Status(IStatus.ERROR, "de.cau.cs.rtprak.turing.graphiti",
                    "Unable to store model and diagram resources", exception);
            StatusManager.getManager().handle(status);
        }
        setCharset(WorkspaceSynchronizer.getFile(modelResource));
        setCharset(WorkspaceSynchronizer.getFile(diagramResource));
    }
    return diagramResource;
}
 
開發者ID:CloudScale-Project,項目名稱:Environment,代碼行數:32,代碼來源:Util.java

示例9: createDiagram

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
/**
 * Create a diagram with given URIs.
 * 
 * @param diagramURI
 *            URI for the diagram file
 * @param modelURI
 *            URI for the model file
 * @param progressMonitor
 *            progress monitor
 * @return a resource for the new diagram file
 */
private Resource createDiagram(final URI diagramURI, final URI modelURI,
        final IProgressMonitor progressMonitor) {
    progressMonitor.beginTask("Creating diagram and model files", 2);
    // create a resource set and editing domain
    TransactionalEditingDomain editingDomain = GraphitiUi.getEmfService()
            .createResourceSetAndEditingDomain();
    ResourceSet resourceSet = editingDomain.getResourceSet();
    CommandStack commandStack = editingDomain.getCommandStack();
    // create resources for the diagram and domain model files
    final Resource diagramResource = resourceSet.createResource(diagramURI);
    final Resource modelResource = resourceSet.createResource(modelURI);
    if (diagramResource != null && modelResource != null) {
        commandStack.execute(new RecordingCommand(editingDomain) {
            @Override
            protected void doExecute() {
                createModel(diagramResource, diagramURI.lastSegment(), modelResource,
                        modelURI.lastSegment());
            }
        });
        progressMonitor.worked(1);

        try {
            modelResource.save(createSaveOptions());
            diagramResource.save(createSaveOptions());
        } catch (IOException exception) {
            IStatus status = new Status(IStatus.ERROR, "de.cau.cs.rtprak.turing.graphiti",
                    "Unable to store model and diagram resources", exception);
            StatusManager.getManager().handle(status);
        }
        setCharset(WorkspaceSynchronizer.getFile(modelResource));
        setCharset(WorkspaceSynchronizer.getFile(diagramResource));
    }
    progressMonitor.done();
    return diagramResource;
}
 
開發者ID:CloudScale-Project,項目名稱:Environment,代碼行數:47,代碼來源:GraphitiNewWizard.java

示例10: handleRename

import org.eclipse.emf.common.command.CommandStack; //導入方法依賴的package包/類
private void handleRename(final String theNewName, final EObject theSemanticElement,
        final TransactionalEditingDomain theDomain, final CommandStack theCommandStack) {
    final SetName setName = theCommandStack instanceof IWorkspaceCommandStack
            && theLastOperationCreatedTheElement(theSemanticElement, (IWorkspaceCommandStack) theCommandStack) ? new SetNameTheFirstTime(
                    theDomain, theNewName, theSemanticElement, (IWorkspaceCommandStack) theCommandStack) : new Rename(
                            theDomain, theNewName, theSemanticElement, graphicalEditPart.getViewer().getControl().getShell());
                    if (setName.confirm()) {
                        theCommandStack.execute(setName);
                        setName.after();
                    }
}
 
開發者ID:info-sharing-environment,項目名稱:NIEM-Modeling-Tool,代碼行數:12,代碼來源:ClassifierNamePopupEditorConfiguration.java


注:本文中的org.eclipse.emf.common.command.CommandStack.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。