Esempio n. 1
0
  /**
   * ------------------------------------------------------ Deletes and copies the parts that are
   * selected in the given to this clipboard.
   *
   * @param editor the editor that contians the selected parts to cut
   * @see MiEditor#getSelectedParts
   * @see MiPart#isSelected ------------------------------------------------------
   */
  public void cutSelectionToClipBoard(MiEditor editor) {
    MiParts selectedParts = new MiParts();
    editor.getSelectedParts(selectedParts);

    for (int i = 0; i < selectedParts.size(); ++i) {
      if (!selectedParts.get(i).isCopyable()) {
        selectedParts.removeElementAt(i);
        --i;
      }
    }
    for (int i = 0; i < selectedParts.size(); ++i) {
      MiPart part = selectedParts.elementAt(i);
      editor.deSelect(part);
    }

    MiNestedTransaction nestedTransaction = new MiNestedTransaction(Mi_CUT_DISPLAY_NAME);
    MiSystem.getTransactionManager().startTransaction(nestedTransaction);

    // MiDeletePartsCommand deleteCmd = new MiDeletePartsCommand(editor, selectedParts, true);

    MiParts pastableSelectedParts = MiUtility.makeCopyOfNetwork(selectedParts);
    MiDeletePartsCommand deleteCmd =
        MiSystem.getCommandBuilder().getDeletePartsCommand().create(editor, selectedParts, true);
    MiChangeContentsTransaction replaceCmd =
        new MiChangeContentsTransaction(this, pastableSelectedParts);

    MiSystem.getTransactionManager().appendTransaction(Mi_CUT_DISPLAY_NAME, replaceCmd, deleteCmd);

    deleteCmd.doit(editor, true);
    replaceCmd.doit(this, pastableSelectedParts, true);

    dispatchAction(Mi_CLIPBOARD_NOW_HAS_DATA_ACTION);

    MiSystem.getTransactionManager().commitTransaction(nestedTransaction);
  }
Esempio n. 2
0
  /**
   * ------------------------------------------------------ Copies the given part to this clipboard.
   *
   * @param part the part to copy to the clipboard
   *     ------------------------------------------------------
   */
  public void copyToClipBoard(MiPart part) {
    MiParts parts = new MiParts();
    parts.addElement(part.deepCopy());

    MiChangeContentsTransaction cmd = new MiChangeContentsTransaction(this, parts);
    cmd.doit(this, parts, true);
    MiSystem.getTransactionManager().appendTransaction(cmd);
    dispatchAction(Mi_CLIPBOARD_NOW_HAS_DATA_ACTION);
  }
Esempio n. 3
0
  /**
   * ------------------------------------------------------ Copies the parts that are selected in
   * the given to this clipboard.
   *
   * @param editor the editor that contians the selected parts to copy
   * @see MiEditor#getSelectedParts
   * @see MiPart#isSelected ------------------------------------------------------
   */
  public void copySelectionToClipBoard(MiEditor editor) {
    MiParts selectedObjects = new MiParts();
    editor.getSelectedParts(selectedObjects);

    for (int i = 0; i < selectedObjects.size(); ++i) {
      if (!selectedObjects.get(i).isCopyable()) {
        selectedObjects.removeElementAt(i);
        --i;
      }
    }

    selectedObjects = MiUtility.makeCopyOfNetwork(selectedObjects);

    MiChangeContentsTransaction cmd = new MiChangeContentsTransaction(this, selectedObjects);
    cmd.doit(this, selectedObjects, true);
    MiSystem.getTransactionManager().appendTransaction(cmd);
    dispatchAction(Mi_CLIPBOARD_NOW_HAS_DATA_ACTION);
  }
Esempio n. 4
0
  /**
   * ------------------------------------------------------ Deletes the given part and then copies
   * the given part to this clipboard.
   *
   * @param part the part to cut to the clipboard
   *     ------------------------------------------------------
   */
  public void cutToClipBoard(MiPart part) {
    MiParts parts = new MiParts();
    parts.addElement(part);

    // MiDeletePartsCommand deleteCmd = new MiDeletePartsCommand(part.getContainingEditor(), parts,
    // true);
    MiDeletePartsCommand deleteCmd =
        MiSystem.getCommandBuilder()
            .getDeletePartsCommand()
            .create(part.getContainingEditor(), parts, true);

    MiChangeContentsTransaction replaceCmd = new MiChangeContentsTransaction(this, parts);

    MiiTransaction openTransaction =
        MiSystem.getTransactionManager()
            .startTransaction(new MiNestedTransaction(Mi_CUT_DISPLAY_NAME, replaceCmd, deleteCmd));

    deleteCmd.doit(part.getContainingEditor(), true);
    replaceCmd.doit(this, parts, true);

    dispatchAction(Mi_CLIPBOARD_NOW_HAS_DATA_ACTION);

    MiSystem.getTransactionManager().commitTransaction(openTransaction);
  }