private Map<String, String> getServerByNodeId(String id) { Map<String, String> map = new LinkedHashMap<String, String>(); INode node = view.getNode(id); if (node == null) return map; if (INode.MONITOR.equals(node.getType())) { return map; } if (INode.ENTITY.equals(node.getType())) { EntityInfo entityinfo = view.getEntityInfo(node); if (entityinfo.getDeviceType() != null) { if ("_win".equals(entityinfo.getDeviceType()) || "_unix".equals(entityinfo.getDeviceType())) { map.put( entityinfo.getSvId(), entityinfo.getName() + "(" + entityinfo.getDeviceType() + ")"); return map; } } } IForkNode f = (IForkNode) node; List<String> ids = f.getSonList(); for (String newid : ids) { map.putAll(this.getServerByNodeId(newid)); } return map; }
@Override public void onEvent(Event event) throws Exception { try { if (node == null) return; // 过滤不需要处理的节点 Treechildren mytreechildren = treeitem.getTreechildren(); // 无子节点或者是处于收缩状态的节点 if (mytreechildren == null || mytreechildren.getChildren().size() > 0 || treeitem.isOpen() == false) return; // 是监测器节点的情况 if (INode.MONITOR.equals(node.getType())) { return; } List<EccTreeItem> sons = node.getChildRen(); // 查找其儿子 if (sons != null && sons.size() > 0) { for (EccTreeItem son : sons) { if (son == null) continue; // 如果是监视器 -- 页节点 if (INode.ENTITY.equals(son.getType())) { if (this.tree.getMonitorType() != null) { // MonitorInfo monitorinfo = // this.tree.getTreemodel().getView().getMonitorInfo(son.getValue()); EntityInfo entityInfo = this.tree.getTreemodel().getView().getEntityInfo(son.getValue()); if (!this.tree.getMonitorType().equals(entityInfo.getType())) { continue; } } BaseTreeitem tii = getTreeitem(son); tii.setParent(mytreechildren); } else { if (existChildren(son)) { // 如果存在儿子 BaseTreeitem tii = getTreeitem(son); tii.setParent(mytreechildren); Treechildren newtreechildren = new Treechildren(); tii.appendChild(newtreechildren); // 给以可以展开的属性 tii.addEventListener( Events.ON_OPEN, new TreeitemOpenListener(tii, this.tree)); // 添加展开事件 } } } } } catch (Exception e) { e.printStackTrace(); Messagebox.show(e.getMessage(), "错误", Messagebox.OK, Messagebox.ERROR); } }