예제 #1
0
파일: Z.java 프로젝트: adamldavis/z
  public void activateGoUp() {
    File pFile = selectedNode.getParentFile();

    if (selectedNode.getNodeType() == ZNodeType.PACKAGE) {
      for (int i = 0; i < selectedNode.getName().split("\\.").length; i++) {
        pFile = pFile.getParentFile();
      }
    } else if (selectedNode.getNodeType() == ZNodeType.MODULE) {
      pFile = pFile.getParentFile();
    }
    selectedNode = new ZCodeLoader(apiFactory).load(pFile);
    clicked(selectedNode);
  }
예제 #2
0
파일: Z.java 프로젝트: adamldavis/z
 @Override
 public void keyPressed(KeyEvent e) {
   if (!links.isEmpty()) return;
   switch (e.getKeyChar()) {
     case 's':
       // TODO: Search!!!!
       String name = display.showInputDialog("Search", "Z");
       ZTask activeTask = taskList.getActiveTask();
       for (ZNode node : getZNodes()) {
         if (node.getName().startsWith(name)) {
           log.info("found {}", node.getName());
           if (activeTask != null) {
             activeTask.add(node);
           }
         }
       }
       break;
     case 'm':
       if (selectedNode.getNodeType() == ZNodeType.CLASS) {
         addMethodLinks();
       }
       break;
     case 'p':
       // TODO: add polymorphic links
     case 'i':
     case 'r':
       // TODO: add import/require links
     case 'h':
     case 'f':
       addFieldLinks();
   }
 }
예제 #3
0
파일: Z.java 프로젝트: adamldavis/z
 public void createSubNode(Point point) {
   if (selectedNode != null) {
     // create sub-module
     final ZNodeType subtype;
     switch (selectedNode.getNodeType()) {
       case METHOD:
         subtype = ZNodeType.CALLEE;
         break;
       case CLASS:
         subtype = ZNodeType.METHOD;
         break;
       case PACKAGE:
         subtype = ZNodeType.CLASS;
         break;
       case CALLEE:
       case CALLER:
       case DEPENDENCY:
         return;
       default:
         subtype = ZNodeType.PACKAGE;
     }
     ZNode sub = createNewZ(point, subtype);
     if (sub != null) selectedNode.getSubmodules().add(sub);
   }
 }
예제 #4
0
파일: Z.java 프로젝트: adamldavis/z
  protected void addFieldLinks() {
    log.info("addFieldLinks()");
    final Map<String, ZNode> nodeMap = new HashMap<String, ZNode>();
    final Pattern patt = Pattern.compile("(private |protected |public |final |static )+\\s*(\\w+)");

    // TODO redo this to actually include packages
    for (ZNode node : selectedNode.getSubmodules()) {
      if (node.getNodeType() == ZNodeType.CLASS) {
        nodeMap.put(node.getName(), node);
      }
    }
    log.info("nodeMap={}", nodeMap);
    for (ZNode node : selectedNode.getSubmodules()) {
      for (String line : node.getCodeLines()) {
        final Matcher matcher = patt.matcher(line);
        if (matcher.find()) {
          log.info("group2={}", matcher.group(2));
          if (nodeMap.containsKey(matcher.group(2))) {
            links.add(new ZNodeLink(node, nodeMap.get(matcher.group(2)), LinkType.HAS_A));
          }
        }
      }
    }
    // just add 1 so there's at least 1
    links.add(new ZNodeLink(selectedNode, selectedNode, LinkType.HAS_A));
  }
예제 #5
0
파일: Z.java 프로젝트: adamldavis/z
 protected void dragged(ZNode z) {
   log.info("dragged: " + z);
   // create dependency on z?
   if (z.getNodeType() == ZNodeType.DEPENDENCY) selectedNode.getDependencies().add(z);
 }