Ejemplo n.º 1
0
 FoundItem getFoundItem(Node n, String text) {
   String s = n.getNodeValue();
   if (s == null) s = n.getNodeName();
   String string;
   if (text != null) {
     int index = s.indexOf(text);
     int left = Math.max(0, index - 5);
     int right = Math.min(s.length(), index + text.length() + 20);
     string = s.substring(left, right);
   } else string = s;
   TreeNode tn = jtree.getTreeNode(n);
   TreePath tp = getTreePath(tn);
   return new FoundItem(string, tp);
 }
  static DivisionOperatorWorkspaceObject load(Node node) throws ProgramLoadingException {
    if (!node.getNodeName().equals("division")) throw new ProgramLoadingException();

    DivisionOperatorWorkspaceObject obj =
        new DivisionOperatorWorkspaceObject(Workspace.getWorkspace());
    Node lop = Workspace.getChildElementByName(node, "loperand");
    Node rop = Workspace.getChildElementByName(node, "roperand");

    if (lop != null) {
      Node lopNode = Workspace.getNthChildElement(lop, 0);
      if (lopNode != null) {
        WorkspaceObject lopObj = Workspace.dispatchLoad(lopNode);
        if (lopObj != null) {
          obj.leftSink.progCombine(lopObj);
        }
      }
    }

    if (rop != null) {
      Node ropNode = Workspace.getNthChildElement(rop, 0);
      if (ropNode != null) {
        WorkspaceObject ropObj = Workspace.dispatchLoad(ropNode);
        if (ropObj != null) {
          obj.rightSink.progCombine(ropObj);
        }
      }
    }

    return obj;
  }
Ejemplo n.º 3
0
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      if (isSelected) this.setBackground(table.getSelectionBackground());
      else this.setBackground(table.getBackground());

      Node node = nodes.get(row);
      Request request = nodeIDToRequest.get(node.getNodeID());
      if (request == null) {
        this.setString("NONE");
        this.setValue(0);
      } else {
        int percent = (int) Math.round(request.getPercentDone());
        this.setString(request.getType().toString() + "  " + percent + "%");
        this.setValue(percent);
      }
      return this;
    }
Ejemplo n.º 4
0
 public void actionPerformed(ActionEvent event) {
   JTree tree = getTree();
   TreePath path = tree.getSelectionPath();
   if (path == null) {
     sheet.getLogger().warning("Warning: User must select a node to delete");
     // XXX add message telling users to select a node
   } else {
     Node selected = (Node) path.getLastPathComponent();
     try {
       Node parent = selected.getParent();
       if (parent != null) {
         parent.removeChild(selected);
         select(parent);
       }
     } catch (UnsupportedOperationException uox) {
       sheet.getLogger().warning("Cannot delete node: " + selected);
     }
   }
 }
  static RandomIntegerWorkspaceObject load(Node node) throws ProgramLoadingException {
    if (!node.getNodeName().equals("randint")) throw new ProgramLoadingException();

    RandomIntegerWorkspaceObject obj = new RandomIntegerWorkspaceObject(Workspace.getWorkspace());

    Node subNode = Workspace.getNthChildElement(node, 0);
    if (subNode != null) {
      WorkspaceObject wsObj = Workspace.dispatchLoad(subNode);
      if (wsObj != null) {
        obj.sink.progCombine(wsObj);
      }
    }
    return obj;
  }
  void buildStructure(final Node root, final boolean activate) throws Exception {
    doAndWaitForBuilder(
        () -> {
          myCom = root.addChild("com");
          myIntellij = myCom.addChild("intellij");
          myOpenApi = myIntellij.addChild("openapi");
          myFabrique = root.addChild("jetbrains").addChild("fabrique");
          myIde = myFabrique.addChild("ide");
          myRunner = root.addChild("xUnit").addChild("runner");
          myRcp = root.addChild("org").addChild("eclipse").addChild("rcp");

          if (activate) {
            getBuilder().getUi().activate(true);
          }
        });
  }
Ejemplo n.º 7
0
  public synchronized Object getValueAt(int row, int col) {
    Node node = nodes.get(row);

    switch (col) {
      case 0:
        return node.getNodeID();
      case 1:
        return node.getCurrState();
      case 2:
        return node.getTailBlockID();
      case 3:
        return node.getHeadBlockID();
      case 4:
        return node.getLocalTime();
      case 5:
        return node.getGlobalTime();
      case 6:
        return node.getIsTimeSynchronized();
      case 7:
        return new LastRequestCellRendererClass();
      default:
        return "UNKNOWN";
    }
  }
 public Node addChild(Node node) {
   myChildElements.add(node);
   node.setParent(this);
   return node;
 }