public Command getCreateLinkCommand(View source, View target, GenCommonBase linkType) {
      IElementType metamodelType = getElementType(linkType);
      CreateRelationshipRequest relationShipReq = new CreateRelationshipRequest(metamodelType);

      ConnectionViewAndElementDescriptor desc =
          new ConnectionViewAndElementDescriptor(
              new CreateElementRequestAdapter(relationShipReq),
              metamodelType instanceof IHintedType
                  ? ((IHintedType) metamodelType).getSemanticHint()
                  : "",
              getDefaultPreferencesHint());

      CreateConnectionViewAndElementRequest req = new CreateConnectionViewAndElementRequest(desc);
      req.setType(RequestConstants.REQ_CONNECTION_START);

      EditPart sourceEditPart = findEditPart(source);
      req.setSourceEditPart(sourceEditPart);
      // Note: initializes the sourceCommand in the request
      Command sourceCmd = sourceEditPart.getCommand(req);
      if (sourceCmd == null || !sourceCmd.canExecute()) {
        return null;
      }

      EditPart targetEditPart = target != null ? findEditPart(target) : null;
      if (targetEditPart != null) {
        req.setType(RequestConstants.REQ_CONNECTION_END);
        req.setTargetEditPart(targetEditPart);
        req.setLocation(new Point(0, 0));
        sourceEditPart.getCommand(req);
        Command targetCmd = targetEditPart.getCommand(req);
        return targetCmd;
      }
      return null;
    }
 @Override
 public void run() {
   Command cmd = createCommand(getSelectedObjects());
   if (cmd != null && cmd.canExecute()) {
     execute(cmd);
   }
 }
 /** @generated */
 private Collection<IAdaptable> createConnections(
     Collection<TaiPanLinkDescriptor> linkDescriptors, Domain2Notation domain2NotationMap) {
   LinkedList<IAdaptable> adapters = new LinkedList<IAdaptable>();
   for (TaiPanLinkDescriptor nextLinkDescriptor : linkDescriptors) {
     EditPart sourceEditPart = getSourceEditPart(nextLinkDescriptor, domain2NotationMap);
     EditPart targetEditPart = getTargetEditPart(nextLinkDescriptor, domain2NotationMap);
     if (sourceEditPart == null || targetEditPart == null) {
       continue;
     }
     CreateConnectionViewRequest.ConnectionViewDescriptor descriptor =
         new CreateConnectionViewRequest.ConnectionViewDescriptor(
             nextLinkDescriptor.getSemanticAdapter(),
             TaiPanVisualIDRegistry.getType(nextLinkDescriptor.getVisualID()),
             ViewUtil.APPEND,
             false,
             ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
     CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor);
     ccr.setType(RequestConstants.REQ_CONNECTION_START);
     ccr.setSourceEditPart(sourceEditPart);
     sourceEditPart.getCommand(ccr);
     ccr.setTargetEditPart(targetEditPart);
     ccr.setType(RequestConstants.REQ_CONNECTION_END);
     Command cmd = targetEditPart.getCommand(ccr);
     if (cmd != null && cmd.canExecute()) {
       executeCommand(cmd);
       IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject();
       if (viewAdapter != null) {
         adapters.add(viewAdapter);
       }
     }
   }
   return adapters;
 }
Example #4
0
 @SuppressWarnings("unchecked")
 @Override
 protected boolean calculateEnabled() {
   Command cmd = createCopyCommand(getSelectedObjects());
   if (cmd == null) return false;
   return cmd.canExecute();
 }
 /** Test that GMF Text drop is not possible in a lifeline. */
 public void testGMFTextDropInALifelineNotPossible() {
   ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_ADD);
   changeBoundsRequest.setEditParts(textEditPart);
   Command dropGMFNoteInLifelineCmd = lifelineEditPart.getCommand(changeBoundsRequest);
   assertFalse(
       "The GMF Text should not be droppable in lifeline", dropGMFNoteInLifelineCmd.canExecute());
 }
  public static void createMessageFlow(
      TransactionalEditingDomain editingDomain,
      Message event,
      ThrowMessageEvent source,
      AbstractCatchMessageEvent target,
      DiagramEditPart dep) {
    EditPart targetEP = findEditPart(dep, target);
    EditPart sourceEP = findEditPart(dep, source);

    CreateConnectionViewAndElementRequest request =
        new CreateConnectionViewAndElementRequest(
            ProcessElementTypes.MessageFlow_4002,
            ((IHintedType) ProcessElementTypes.MessageFlow_4002).getSemanticHint(),
            dep.getDiagramPreferencesHint());
    Command createMessageFlowCommand =
        CreateConnectionViewAndElementRequest.getCreateCommand(request, sourceEP, targetEP);
    if (createMessageFlowCommand.canExecute()) {
      dep.getDiagramEditDomain().getDiagramCommandStack().execute(createMessageFlowCommand);
      dep.getDiagramEditDomain().getDiagramCommandStack().flush();
      dep.refresh();

      ConnectionViewAndElementDescriptor desc =
          (ConnectionViewAndElementDescriptor) request.getNewObject();
      MessageFlow message = (MessageFlow) desc.getElementAdapter().getAdapter(MessageFlow.class);
      SetCommand setCommand =
          new SetCommand(
              editingDomain, message, ProcessPackage.Literals.ELEMENT__NAME, event.getName());
      editingDomain.getCommandStack().execute(setCommand);
    }
  }
Example #7
0
  @Override
  protected CommandResult doExecuteWithResult(
      IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info)
      throws ExecutionException {
    CommandResult cmdResult = super.doExecuteWithResult(progressMonitor, info);
    if (!cmdResult.getStatus().isOK()) {
      if (cmdResult.getStatus().getSeverity() != IStatus.CANCEL) {
        Activator.log.error(cmdResult.getStatus().getException());
      }
      return cmdResult;
    }

    Object returnValue = cmdResult.getReturnValue();
    if (returnValue instanceof List<?>) {
      _selectedCmd =
          (Command)
              ((List<?>) returnValue)
                  .get(((List<?>) returnValue).size() - 1); // Returns the last command
    } else {
      _selectedCmd = (Command) cmdResult.getReturnValue();
    }
    Assert.isTrue(_selectedCmd != null && _selectedCmd.canExecute());
    _selectedCmd.execute();

    return CommandResult.newOKCommandResult();
  }
Example #8
0
  @Override
  @Execute
  public void execute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) {
    if (bm.wIsSet("viewer") && Clipboard.instance().getInternalOrNativeEntityContents() == null) {
      IEntityPartViewer viewer = (IEntityPartViewer) bm.wGetValue("viewer");
      if (ClipboardUtils.hasTextFocus(viewer) || ClipboardUtils.hasTextSeletion(viewer)) {
        IEntity focusEntity = bm.wGet("focusEntity");
        ITextualEntityPart focusPart =
            (ITextualEntityPart) viewer.getEditPartRegistry().get(focusEntity);

        String textContents = Clipboard.instance().getTextContents();
        Command command = focusPart.getCommand(TextualRequest.createInsertRequest(textContents));

        CommandStack commandStack = viewer.getEditDomain().getCommandStack();
        if (command instanceof ITextCommand) {
          TextTransactionCommand transactionCommand = new TextTransactionCommand();
          transactionCommand.setModel(focusEntity);
          transactionCommand.merge((ITextCommand) command);
          transactionCommand.setLabel(getLabel(bm));
          commandStack.execute(transactionCommand);
        } else {
          command.setLabel(getLabel(bm) + " text");
          commandStack.execute(command);
        }
        return;
      }
    }
    super.execute(bm);
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
   * org.eclipse.core.runtime.IAdaptable)
   */
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    if (diagramEP != null && getEditingDomain() != null) {
      diagramEP.refresh();
      Namespace context = constraint.getContext();
      Collection<EditPart> allTopSemanticEditPart =
          DiagramEditPartsUtil.getAllTopSemanticEditPart(diagramEP);
      EditPart constraintEditPart = getEditPart(constraint, allTopSemanticEditPart);
      EditPart contextEditPart = getEditPart(context, allTopSemanticEditPart);

      if (constraintEditPart != null && contextEditPart != null) {
        Collection<EditPart> constraintAndContext = new ArrayList<EditPart>();
        constraintAndContext.add(constraintEditPart);
        constraintAndContext.add(contextEditPart);
        final Request request =
            new ShowHideRelatedLinkRequest(
                constraintAndContext, ShowHideKind.SHOW_ALL_LINK_BETWEEN_SELECTED_ELEMENT);
        final Command cmd = diagramEP.getCommand(request);
        if (cmd != null) {
          cmd.execute();
        }
      }
    }
    return null;
  }
  protected Command chainGuideAttachmentCommand(
      Request request, LogicSubpart part, Command cmd, boolean horizontal) {
    Command result = cmd;

    // Attach to guide, if one is given
    Integer guidePos =
        (Integer)
            request
                .getExtendedData()
                .get(
                    horizontal
                        ? SnapToGuides.KEY_HORIZONTAL_GUIDE
                        : SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos != null) {
      int alignment =
          ((Integer)
                  request
                      .getExtendedData()
                      .get(
                          horizontal
                              ? SnapToGuides.KEY_HORIZONTAL_ANCHOR
                              : SnapToGuides.KEY_VERTICAL_ANCHOR))
              .intValue();
      ChangeGuideCommand cgm = new ChangeGuideCommand(part, horizontal);
      cgm.setNewGuide(findGuideAt(guidePos.intValue(), horizontal), alignment);
      result = result.chain(cgm);
    }

    return result;
  }
  private boolean ourHandleKeyDown(KeyEvent event) {
    if (ourAcceptArrowKey(event)) {
      int direction = 0;
      switch (event.keyCode) {
        case SWT.ARROW_DOWN:
          direction = PositionConstants.SOUTH;
          break;
        case SWT.ARROW_UP:
          direction = PositionConstants.NORTH;
          break;
        case SWT.ARROW_RIGHT:
          direction = PositionConstants.EAST;
          break;
        case SWT.ARROW_LEFT:
          direction = PositionConstants.WEST;
          break;
      }

      boolean consumed = false;
      if (direction != 0 && event.stateMask == 0) consumed = navigateNextAnchor(direction);
      if (!consumed) {
        event.stateMask |= SWT.CONTROL;
        event.stateMask &= ~SWT.SHIFT;
        if (getCurrentViewer().getKeyHandler().keyPressed(event)) {
          navigateNextAnchor(0);
          updateTargetRequest();
          updateTargetUnderMouse();
          Command command = getCommand();
          if (command != null) setCurrentCommand(command);
          return true;
        }
      }
    }

    if (acceptConnectionStart(event)) {
      updateTargetUnderMouse();
      setConnectionSource(getTargetEditPart());
      ((CreateConnectionRequest) getTargetRequest()).setSourceEditPart(getTargetEditPart());
      setState(STATE_ACCESSIBLE_DRAG_IN_PROGRESS);
      ourPlaceMouseInViewer(getLocation().getTranslated(6, 6));
      return true;
    }

    if (acceptConnectionFinish(event)) {
      Command command = getCommand();
      if (command != null && command.canExecute()) {
        setState(STATE_INITIAL);
        ourPlaceMouseInViewer(getLocation().getTranslated(6, 6));
        eraseSourceFeedback();
        eraseTargetFeedback();
        setCurrentCommand(command);
        executeCurrentCommand();
        handleFinished();
      }
      return true;
    }

    return super.handleKeyDown(event);
  }
Example #12
0
 @SuppressWarnings("unchecked")
 @Override
 public void run() {
   Command cmd = createCopyCommand(getSelectedObjects());
   if (cmd != null && cmd.canExecute()) {
     cmd.execute();
   }
 }
Example #13
0
  @Override
  protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info)
      throws ExecutionException {

    if (_selectedCmd != null && _selectedCmd.canUndo()) {
      _selectedCmd.undo();
    }
    return super.doUndoWithResult(progressMonitor, info);
  }
 /** @generated */
 protected Command getSemanticCommand(IEditCommandRequest request) {
   IEditCommandRequest completedRequest = completeRequest(request);
   Object editHelperContext = completedRequest.getEditHelperContext();
   if (editHelperContext instanceof View
       || (editHelperContext instanceof IEditHelperContext
           && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) {
     // no semantic commands are provided for pure design elements
     return null;
   }
   if (editHelperContext == null) {
     editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel());
   }
   IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext);
   if (elementType
       == ElementTypeRegistry.getInstance()
           .getType("org.eclipse.gmf.runtime.emf.type.core.default")) { // $NON-NLS-1$
     elementType = null;
   }
   Command semanticCommand = getSemanticCommandSwitch(completedRequest);
   if (elementType != null) {
     if (semanticCommand != null) {
       ICommand command =
           semanticCommand instanceof ICommandProxy
               ? ((ICommandProxy) semanticCommand).getICommand()
               : new CommandProxy(semanticCommand);
       completedRequest.setParameter(
           FlowDesigner.diagram.edit.helpers.FlowDesignerBaseEditHelper.EDIT_POLICY_COMMAND,
           command);
     }
     ICommand command = elementType.getEditCommand(completedRequest);
     if (command != null) {
       if (!(command instanceof CompositeTransactionalCommand)) {
         TransactionalEditingDomain editingDomain =
             ((IGraphicalEditPart) getHost()).getEditingDomain();
         command =
             new CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command);
       }
       semanticCommand = new ICommandProxy(command);
     }
   }
   boolean shouldProceed = true;
   if (completedRequest instanceof DestroyRequest) {
     shouldProceed = shouldProceed((DestroyRequest) completedRequest);
   }
   if (shouldProceed) {
     if (completedRequest instanceof DestroyRequest) {
       TransactionalEditingDomain editingDomain =
           ((IGraphicalEditPart) getHost()).getEditingDomain();
       Command deleteViewCommand =
           new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel()));
       semanticCommand =
           semanticCommand == null ? deleteViewCommand : semanticCommand.chain(deleteViewCommand);
     }
     return semanticCommand;
   }
   return null;
 }
Example #15
0
  @Override
  protected Command createChangeConstraintCommand(
      ChangeBoundsRequest request, EditPart child, Object constraint) {

    BControlChangeLayoutCommand cmd = new BControlChangeLayoutCommand();
    BControl part = (BControl) child.getModel();
    cmd.setModel(child.getModel());
    cmd.setConstraint((Rectangle) constraint);
    Command result = cmd;

    if ((request.getResizeDirection() & PositionConstants.NORTH_SOUTH) != 0) {
      Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_HORIZONTAL_GUIDE);
      if (guidePos != null) {
        result = chainGuideAttachmentCommand(request, part, result, true);
      } else if (part.getHorizontalGuide() != null) {
        // SnapToGuides didn't provide a horizontal guide, but this part
        // is attached
        // to a horizontal guide. Now we check to see if the part is
        // attached to
        // the guide along the edge being resized. If that is the case,
        // we need to
        // detach the part from the guide; otherwise, we leave it alone.
        int alignment = part.getHorizontalGuide().getAlignment(part);
        int edgeBeingResized = 0;
        if ((request.getResizeDirection() & PositionConstants.NORTH) != 0) edgeBeingResized = -1;
        else edgeBeingResized = 1;
        if (alignment == edgeBeingResized)
          result = result.chain(new ChangeGuideCommand(part, true));
      }
    }

    if ((request.getResizeDirection() & PositionConstants.EAST_WEST) != 0) {
      Integer guidePos = (Integer) request.getExtendedData().get(SnapToGuides.KEY_VERTICAL_GUIDE);
      if (guidePos != null) {
        result = chainGuideAttachmentCommand(request, part, result, false);
      } else if (part.getVerticalGuide() != null) {
        int alignment = part.getVerticalGuide().getAlignment(part);
        int edgeBeingResized = 0;
        if ((request.getResizeDirection() & PositionConstants.WEST) != 0) edgeBeingResized = -1;
        else edgeBeingResized = 1;
        if (alignment == edgeBeingResized)
          result = result.chain(new ChangeGuideCommand(part, false));
      }
    }

    if (request.getType().equals(REQ_MOVE_CHILDREN)
        || request.getType().equals(REQ_ALIGN_CHILDREN)) {
      result = chainGuideAttachmentCommand(request, part, result, true);
      result = chainGuideAttachmentCommand(request, part, result, false);
      result = chainGuideDetachmentCommand(request, part, result, true);
      result = chainGuideDetachmentCommand(request, part, result, false);
    }

    return result;
  }
  /** {@inheritedDoc}. */
  @Override
  public Command getDropObjectsCommand(DropObjectsRequest dropRequest) {
    TypeDropHelper helper = new TypeDropHelper(getEditingDomain());

    // Single drop management possible drop action list can be proposed
    if (dropRequest.getObjects().size() == 1) {

      // List of available drop commands
      final List<Command> commandChoice = new ArrayList<Command>();

      // 1. Try to set the target element type with dropped object
      Command dropAsSetType =
          helper.getDropAsTypedElementType(dropRequest, (GraphicalEditPart) getHost());
      if ((dropAsSetType != null) && (dropAsSetType.canExecute())) {
        commandChoice.add(dropAsSetType);
      }

      // 3. Build default drop command (show view of the dropped object)
      Command defaultDropCommand = super.getDropObjectsCommand(dropRequest);
      defaultDropCommand.setLabel("Default drop (Show dropped object in diagram)");
      if ((defaultDropCommand != null) && (defaultDropCommand.canExecute())) {
        commandChoice.add(defaultDropCommand);
      }

      // Prepare the selection command (if several command are available) or return the drop command
      if (commandChoice.size() > 1) {
        RunnableWithResult<ICommand> runnable;
        Display.getDefault()
            .syncExec(
                runnable =
                    new RunnableWithResult.Impl<ICommand>() {

                      public void run() {
                        setResult(
                            new SelectAndExecuteCommand(
                                "Select drop action for ",
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                commandChoice));
                      }
                    });

        ICommand selectCommand = runnable.getResult();

        return new ICommandProxy(selectCommand);
      } else if (commandChoice.size() == 1) {
        return commandChoice.get(0);
      }

      // else (command choice is empty)
      return UnexecutableCommand.INSTANCE;
    }

    return super.getDropObjectsCommand(dropRequest);
  }
 /** Writes the sorting/filtering specified by the dialog */
 protected void performApply() {
   Command sortAndFilteringCommand = getApplyCommand();
   if (sortAndFilteringCommand != null && sortAndFilteringCommand.canExecute()) {
     editPart
         .getRoot()
         .getViewer()
         .getEditDomain()
         .getCommandStack()
         .execute(sortAndFilteringCommand);
     createBackUp();
   }
   updateApplyButton();
 }
  public void createObject(int x, int y) {
    if (availableForInsert && this.entry != null) {
      updateCursor(false);
      availableForInsert = false;
      switch (this.entry.getType()) {
        case TRIGGER_BLOCK:
        case CUSTOM_BLOCK:
          CreateUnspecifiedTypeRequest request =
              new CreateUnspecifiedTypeRequest(
                  Collections.singletonList(Neuro4jElementTypes.LogicNode_2017),
                  diagramEditPart.getDiagramPreferencesHint());

          request.setLocation(new Point(x, y));
          Command command = diagramEditPart.getCommand(request);
          command.execute();
          List newObject = (List) request.getNewObject();
          ViewAndElementDescriptor desc = (ViewAndElementDescriptor) newObject.get(0);
          ShapeImpl shape = (ShapeImpl) desc.getAdapter(ShapeImpl.class);
          LogicNode lNode = (LogicNode) shape.getElement();
          updateCustomBlock(lNode, this.entry);
          break;

        case CHILD:
          if (entry.getParent().getType() != ListEntryType.FLOW) {
            return;
          }
          request =
              new CreateUnspecifiedTypeRequest(
                  Collections.singletonList(Neuro4jElementTypes.CallNode_2008),
                  diagramEditPart.getDiagramPreferencesHint());

          request.setLocation(new Point(x, y));
          command = diagramEditPart.getCommand(request);
          command.execute();
          newObject = (List) request.getNewObject();
          desc = (ViewAndElementDescriptor) newObject.get(0);
          shape = (ShapeImpl) desc.getAdapter(ShapeImpl.class);
          CallNode cNode = (CallNode) shape.getElement();

          updateCallBlock(cNode, entry);

          break;

        default:
          break;
      }
      this.entry = null;
    }
  }
 /** Test that GMF Text creation is not possible in a lifeline. */
 public void testGMFTextCreationInALifelineNotPossible() {
   CreateViewRequest createViewRequest =
       new CreateViewRequest(
           Collections.singletonList(
               new CreateViewRequest.ViewDescriptor(
                   null,
                   Node.class,
                   "Text",
                   ((IDiagramPreferenceSupport) lifelineEditPart.getRoot())
                       .getPreferencesHint())));
   Command createGMFTextInLifelineCmd = lifelineEditPart.getCommand(createViewRequest);
   assertFalse(
       "The GMF Text creation should not be allowed in lifeline",
       createGMFTextInLifelineCmd.canExecute());
 }
 @Override
 protected Cursor calculateCursor() {
   Cursor cursorToReturn;
   if (moveGroupActivated) {
     Command command = getCurrentCommand();
     if (command == null || !command.canExecute()) {
       cursorToReturn = getDisabledCursor();
     } else {
       cursorToReturn = SharedCursors.ARROW;
     }
   } else {
     cursorToReturn = super.calculateCursor();
   }
   return cursorToReturn;
 }
 public void runCommand(Command command, IContextModelManager modelManager) {
   if (modelManager.getCommandStack() == null) {
     command.execute();
   } else {
     modelManager.getCommandStack().execute(command);
   }
 }
  protected Command chainGuideDetachmentCommand(
      Request request, LogicSubpart part, Command cmd, boolean horizontal) {
    Command result = cmd;

    // Detach from guide, if none is given
    Integer guidePos =
        (Integer)
            request
                .getExtendedData()
                .get(
                    horizontal
                        ? SnapToGuides.KEY_HORIZONTAL_GUIDE
                        : SnapToGuides.KEY_VERTICAL_GUIDE);
    if (guidePos == null) result = result.chain(new ChangeGuideCommand(part, horizontal));

    return result;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.action.IAction#run()
  */
 public void run() {
   // TODO: figure out how to get the default attributes from
   // the tag create metadata. Get a tag creation provider?
   Map attributes = new LinkedHashMap();
   attributes.put("href", ""); // $NON-NLS-1$//$NON-NLS-2$
   attributes.put("rel", "Stylesheet"); // $NON-NLS-1$//$NON-NLS-2$
   attributes.put("type", "text/css"); // $NON-NLS-1$//$NON-NLS-2$
   Command command =
       new AddSubNodeCommand(
           PDPlugin.getResourceString(
               "ItemCreationEditPolicy.CommandLabel.CreateItem"), //$NON-NLS-1$
           _parentElement,
           IHTMLConstants.TAG_LINK,
           ITLDConstants.URI_HTML,
           attributes);
   command.execute();
 }
Example #24
0
  @Override
  public void execute() {
    if (_chain == null) {
      _chain = createCommandChain();
    }

    _chain.execute();
  }
 @Override
 public void execute() {
   super.execute();
   oldDisplayText = customTestStepData.getDisplayText();
   customTestStepData.setDisplayText(displayText);
   oldPath = customTestStepData.getPath();
   customTestStepData.setPath(path);
 }
 @Override
 protected void finalize() throws Throwable {
   if (backups != null) {
     for (Backup backup : backups) {
       backup.dispose();
     }
   }
   super.finalize();
 }
Example #27
0
  @Override
  protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info)
      throws ExecutionException {

    if (_selectedCmd != null && CommandUtilities.canRedo(_selectedCmd)) {
      _selectedCmd.redo();
    }
    return super.doRedoWithResult(progressMonitor, info);
  }
 @Override
 public void undo() {
   if (findProcessProvider != null) {
     findProcessProvider.setIcons((IProcess) elem, oldImage);
   }
   if (changeCmd != null) {
     changeCmd.undo();
   }
 }
Example #29
0
  /**
   * Adds a "Set as default" behavior to a list of commands
   *
   * @param commands
   * @return
   */
  protected List<Command> convertToDefault(List<Command> commands) {
    List<Command> result = new ArrayList<Command>(commands.size());
    for (Command command : commands) {
      final Command commandToExecute = command;
      CompoundCommand compound = new CompoundCommand(commandToExecute.getLabel());
      compound.add(commandToExecute);
      compound.add(
          new Command("Set default drop behavior") {

            @Override
            public void execute() {
              defaultHandler.defaultActionSelected(commandToExecute);
            }
          });

      result.add(compound);
    }
    return result;
  }
Example #30
0
  private Command createCommand(List<?> selection, RGB newColor) {
    CompoundCommand result = new CompoundCommand(Messages.FillColorAction_1);

    for (Object object : selection) {
      if (object instanceof EditPart) {
        Object model = ((EditPart) object).getModel();
        if (shouldEnable(model)) {
          Command cmd =
              new FillColorCommand(
                  (IDiagramModelObject) model, ColorFactory.convertRGBToString(newColor));
          if (cmd.canExecute()) {
            result.add(cmd);
          }
        }
      }
    }

    return result.unwrap();
  }