// 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);
    }
  }
Ejemplo n.º 2
0
  // Methods
  public void dehoist() {
    // Shorthand
    JoeTree tree = hoistedNode.getTree();
    tree.setRootNodeCommentState(oldTreeCommentState);

    hoistedNode.setHoisted(false);

    // Prune things
    tree.setRootNode(oldNodeSet);
    tree.getVisibleNodes().clear();
    hoistedNodeParent.insertChild(hoistedNode, hoistedNodeIndex);
    hoistedNode.setDepthRecursively(hoistedNodeDepth);
    for (int i = 0; i < oldNodeSet.numOfChildren(); i++) {
      Node node = oldNodeSet.getChild(i);
      tree.insertNode(node);
    }

    return;
  }
Ejemplo n.º 3
0
  public void hoist() {

    // Shorthand
    JoeTree tree = hoistedNode.getTree();
    tree.setRootNodeCommentState(newTreeCommentState);

    hoistedNode.setHoisted(true);

    // Prune things
    hoistedNode.getParent().removeChild(hoistedNode);
    hoistedNode.setDepthRecursively(-1);
    tree.setRootNode(hoistedNode);
    tree.getVisibleNodes().clear();
    for (int i = 0; i < hoistedNode.numOfChildren(); i++) {
      Node node = hoistedNode.getChild(i);
      tree.insertNode(node);
    }

    return;
  }
Ejemplo n.º 4
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;
    }
  }
Ejemplo n.º 5
0
  // IconFocusedMethods
  public static void merge(
      Node currentNode, JoeTree tree, OutlineLayoutManager layout, boolean withSpaces) {
    JoeNodeList nodeList = tree.getSelectedNodes();

    // Get merged text
    StringBuffer buf = new StringBuffer();
    boolean didMerge = false;

    if (withSpaces) {
      for (int i = 0, limit = nodeList.size(); i < limit; i++) {
        Node node = nodeList.get(i);

        // Skip if node is not editable
        if (!node.isEditable()) {
          continue;
        }

        didMerge = true;
        node.getMergedValueWithSpaces(buf, i);
      }
    } else {
      for (int i = 0, limit = nodeList.size(); i < limit; i++) {
        Node node = nodeList.get(i);

        // Skip if node is not editable
        if (!node.isEditable()) {
          continue;
        }

        didMerge = true;
        node.getMergedValue(buf);
      }
    }

    // It's possible all nodes were read-only. If so then abort.
    if (!didMerge) {
      return;
    }

    // Get youngest editable node
    Node youngestNode = null;
    for (int i = 0, limit = nodeList.size(); i < limit; i++) {
      Node node = nodeList.get(i);

      if (node.isEditable()) {
        youngestNode = node;
        break;
      }
    }

    // Abort if no editable nodes found.
    if (youngestNode == null) {
      return;
    }

    Node parent = youngestNode.getParent();
    CompoundUndoableReplace undoable = new CompoundUndoableReplace(parent);

    Node newNode = new NodeImpl(tree, buf.toString());
    newNode.setDepth(youngestNode.getDepth());
    newNode.setCommentState(youngestNode.getCommentState());

    undoable.addPrimitive(new PrimitiveUndoableReplace(parent, youngestNode, newNode));

    // Iterate over the remaining selected nodes deleting each one
    int mergeCount = 1;
    for (int i = 0, limit = nodeList.size(); i < limit; i++) {
      Node node = nodeList.get(i);

      // Abort if node is not editable
      if (!node.isEditable() || node == youngestNode) {
        continue;
      }

      undoable.addPrimitive(new PrimitiveUndoableReplace(parent, node, null));
      mergeCount++;
    }

    if (!undoable.isEmpty()) {
      if (withSpaces) {
        if (mergeCount == 1) {
          undoable.setName("Merge Node with Spaces");
        } else {
          undoable.setName(
              new StringBuffer()
                  .append("Merge ")
                  .append(mergeCount)
                  .append(" Nodes with Spaces")
                  .toString());
        }
      } else {
        if (mergeCount == 1) {
          undoable.setName("Merge Node");
        } else {
          undoable.setName(
              new StringBuffer().append("Merge ").append(mergeCount).append(" Nodes").toString());
        }
      }
      tree.getDocument().getUndoQueue().add(undoable);
      undoable.redo();
    }

    return;
  }