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); }
@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(); } }
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); } }
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)); }
protected void dragged(ZNode z) { log.info("dragged: " + z); // create dependency on z? if (z.getNodeType() == ZNodeType.DEPENDENCY) selectedNode.getDependencies().add(z); }