Package org.eclipse.emf.common.command

Examples of org.eclipse.emf.common.command.Command


                public void run() {
                  firePropertyChange(IEditorPart.PROP_DIRTY);

                  // Try to select the affected objects.
                  //
                  Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
                  if (mostRecentCommand != null) {
                    setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                  }
                  if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
                    propertySheetPage.refresh();
                  }
                }
View Full Code Here


        Resource resource = eclass.eResource();
        ResourceSet resourceSet = resource.getResourceSet();
        TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
        try{
        if (domain != null){
          Command setCommand = domain.createCommand(SetCommand.class, new CommandParameter(eclass,
              EcorePackage.Literals.ENAMED_ELEMENT__NAME, newName));
          domain.getCommandStack().execute(setCommand);
          try {
            resource.save(Collections.emptyMap());
          } catch (IOException e) {
View Full Code Here

                public void run() {
                  firePropertyChange(IEditorPart.PROP_DIRTY);

                  // Try to select the affected objects.
                  //
                  Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
                  if (mostRecentCommand != null) {
                    setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                  }
                  if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
                    propertySheetPage.refresh();
                  }
                }
View Full Code Here

              Object[] selection = initialObjectCreationPage.packageField.getSelection();
              if (selection != null && selection.length > 0) {
                JavaPack pack = (JavaPack)JexPackage.eINSTANCE.getEFactoryInstance().create(JexPackage.eINSTANCE.getJavaPack());
                pack.setName(((IJavaElement)selection[0]).getElementName());
                ((AbstractRequirement)rootObject).getJavaElements().add(pack);
                Command createChildrenCommand = null;
                if (initialObjectCreationPage.immediateChildrenButton.getSelection()) {
                  createChildrenCommand = new CreateChildrenFromJavaModelCommand(pack, Flags.AccPublic, false);
                } else if (initialObjectCreationPage.recursiveChildrenButton.getSelection()) {
                  createChildrenCommand = new CreateChildrenFromJavaModelCommand(pack, Flags.AccPublic, true);
                }
                if (createChildrenCommand != null && createChildrenCommand.canExecute()) {
                  createChildrenCommand.execute();
                }
              }
              // Save the contents of the resource to the file system.
              //
              Map options = new HashMap();
View Full Code Here

    }
    return null;
  }
 
  public Object execute(ExecutionEvent event) throws ExecutionException {
    Command command = createEmfCommand(event);
    if (command != null && command.canExecute()) {
      EditingDomain editingDomain = getEditingDomain(event);
      if (editingDomain != null) {
        editingDomain.getCommandStack().execute(command);
      } else {
        command.execute();
      }
      return command.getAffectedObjects();
    }
    return null;
  }
View Full Code Here

    private void updateModel() {
      EStructuralFeature structuralFeature = getEStructuralFeature();
      if (getEObject() != null && structuralFeature != null) {
        String value = text.getText().trim();
        if (isChanged(value, getFeatureValue())) {
          Command command = new SetCommand(editor.getEditingDomain(), getEObject(), structuralFeature, (value != null && value.length() > 0 ? value : null));
          editor.getEditingDomain().getCommandStack().execute(command);
  //      getEObject().eSet(structuralFeature, (value != null && value.length() > 0 ? value : null));
        }
      }
    }
View Full Code Here

  @Override
  protected void okPressed() {
    IStatus status = validate();
    if ( status.isOK() ) {
      Command cmd = generateOkCommand();
      if ( cmd.canExecute() ) {
        cmd.execute();
        dbContext.updateModels();
        doCleanUp();
        super.okPressed();
      }
    }
View Full Code Here

  @Override
  public void commitEdit(Cell<?> treeCell, Object newValue) {
    Object item = treeCell.getItem();
    Object value = EcoreUtil.createFromString(attribute.getEAttributeType(), (String) newValue);
    Command command = SetCommand.create(editingDomain, item, attribute, value);
    if (command.canExecute())
      editingDomain.getCommandStack().execute(command);
  }
View Full Code Here

  @Execute
  void execute() {
    Group group = ContactsFactory.eINSTANCE.createGroup();
    group.setName("New Group");
    Command command = AddCommand.create(contactsManager.getEditingDomain(), contactsManager.getRootGroup(), ContactsPackage.Literals.GROUP__GROUPS, group);
    if (command != null && command.canExecute())
      contactsManager.getEditingDomain().getCommandStack().execute(command);
  }
View Full Code Here

  ContactsManager contactsManager;

  @Execute
  void execute() {
    Contact contact = ContactsFactory.eINSTANCE.createContact();
    Command command = AddCommand.create(contactsManager.getEditingDomain(), contactsManager.getRootGroup(), ContactsPackage.Literals.GROUP__CONTACTS, contact);
    if (command != null && command.canExecute())
      contactsManager.getEditingDomain().getCommandStack().execute(command);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.common.command.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.