// ActionListener Interface
  public void actionPerformed(ActionEvent e) {
    OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched();
    OutlinerCellRendererImpl textArea = doc.panel.layout.getUIComponent(doc.tree.getEditingNode());

    if (textArea == null) {
      return;
    }

    Node node = textArea.node;
    JoeTree tree = node.getTree();
    OutlineLayoutManager layout = tree.getDocument().panel.layout;

    if (doc.tree.getComponentFocus() == OutlineLayoutManager.TEXT) {
      ToggleEditableAction.toggleEditableInheritanceText(node, tree, layout);
    } else if (doc.tree.getComponentFocus() == OutlineLayoutManager.ICON) {
      ToggleEditableAction.toggleEditableInheritance(node, tree, layout);
    }
  }
  // Undoable Interface
  @Override
  public void redo() {
    JoeTree tree = parent.getTree();

    // Remove node from visible nodes cache
    tree.removeNode(oldNode);

    // Swap the nodes
    parent.removeChild(oldNode, index);

    if (newNode != null) {
      parent.insertChild(newNode, index);

      // Insert the node into the visible nodes cache
      tree.insertNode(newNode);

      // Handle Selection
      tree.addNodeToSelection(newNode);
    }
  }
Esempio n. 3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // System.out.println("MergeAction");

    OutlinerCellRendererImpl textArea = null;
    boolean isIconFocused = true;
    Component c = (Component) e.getSource();
    if (c instanceof OutlineButton) {
      textArea = ((OutlineButton) c).renderer;
    } else if (c instanceof OutlineLineNumber) {
      textArea = ((OutlineLineNumber) c).renderer;
    } else if (c instanceof OutlineCommentIndicator) {
      textArea = ((OutlineCommentIndicator) c).renderer;
    } else if (c instanceof OutlinerCellRendererImpl) {
      textArea = (OutlinerCellRendererImpl) c;
      isIconFocused = false;
    }

    // Shorthand
    Node node = textArea.node;
    JoeTree tree = node.getTree();
    OutlineLayoutManager layout = tree.getDocument().panel.layout;

    // System.out.println(e.getModifiers());
    switch (e.getModifiers()) {
      case 2:
        if (isIconFocused) {
          merge(node, tree, layout, false);
        }
        break;

      case 3:
        if (isIconFocused) {
          merge(node, tree, layout, true);
        }
        break;
    }
  }