From: Florian L. <fle...@us...> - 2005-10-12 21:44:24
|
Update of /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/views In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19902/src/net/sf/magicmap/client/views Modified Files: MapView.java OutlineView.java Log Message: Interaktivität zwischen Treeview und Mapview unvollständig Index: OutlineView.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/views/OutlineView.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OutlineView.java 29 Sep 2005 14:48:19 -0000 1.4 --- OutlineView.java 12 Oct 2005 21:44:17 -0000 1.5 *************** *** 16,22 **** --- 16,25 ---- import javax.swing.JTree; import javax.swing.border.EmptyBorder; + import javax.swing.event.TreeSelectionEvent; + import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; + import javax.swing.tree.TreePath; import net.sf.magicmap.client.controller.Controller; *************** *** 34,38 **** * @author thuebner */ ! public class OutlineView extends View implements NodeModelListener { private NodeModel model; --- 37,41 ---- * @author thuebner */ ! public class OutlineView extends View implements NodeModelListener, TreeSelectionListener{ private NodeModel model; *************** *** 70,78 **** nodeClients = new OutlineNode(GUIUtils.i18n("clients")); nodeLocations = new OutlineNode(GUIUtils.i18n("locations")); ! treeroot.add(nodeAccessPoints); treeroot.add(nodeClients); treeroot.add(nodeLocations); ! tree = new JTree(treemodel); tree.setRootVisible(false); --- 73,81 ---- nodeClients = new OutlineNode(GUIUtils.i18n("clients")); nodeLocations = new OutlineNode(GUIUtils.i18n("locations")); ! treeroot.add(nodeAccessPoints); treeroot.add(nodeClients); treeroot.add(nodeLocations); ! tree = new JTree(treemodel); tree.setRootVisible(false); *************** *** 80,83 **** --- 83,88 ---- tree.setBorder(new EmptyBorder(new Insets(3, 3, 3, 3))); + tree.addTreeSelectionListener(this); + JComponent pane = new JScrollPane(tree,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); pane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0))); *************** *** 137,142 **** private class OutlineRenderer extends DefaultTreeCellRenderer { - private Node node; - /* (non-Javadoc) * @see javax.swing.tree.TreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean) --- 142,145 ---- *************** *** 168,171 **** --- 171,200 ---- } + + private TreePath getOutlineNodePath(OutlineNode root, Node node){ + int size = root.getChildCount(); + for (int i = 0; i < size; i++){ + OutlineNode on = (OutlineNode) root.getChildAt(i); + if (on.getNode() == node){ + return new TreePath((Object[])on.getPath()); + } + } + return null; + } + + private TreePath getOutlineNodePath(Node node){ + switch (node.getType()) { + case NodeModel.NODETYPE_ACCESSPOINT : + return getOutlineNodePath(nodeAccessPoints, node); + case NodeModel.NODETYPE_CLIENT : + return getOutlineNodePath(nodeClients, node); + case NodeModel.NODETYPE_LOCATION : + return getOutlineNodePath(nodeLocations, node); + default : + return null; + } + } + + private OutlineNode findOutlineNode(OutlineNode root, Node node){ int size = root.getChildCount(); *************** *** 177,182 **** } return null; ! } ! private OutlineNode findOutlineNode(Node node){ switch (node.getType()) { --- 206,211 ---- } return null; ! } ! private OutlineNode findOutlineNode(Node node){ switch (node.getType()) { *************** *** 197,200 **** --- 226,230 ---- public void nodeAddedEvent(Node node){ OutlineNode on = new OutlineNode(node); + on.setAllowsChildren(false); int index = 0; switch (node.getType()) { *************** *** 249,253 **** private int getAlphabeticalIndex(OutlineNode parent,OutlineNode node){ int index=0; ! while((parent.getChildCount() > index) && (((OutlineNode)(node)).getNode().getDisplayName().compareToIgnoreCase(((OutlineNode)(parent.getChildAt(index))).getNode().getDisplayName()) > 0)){ ++index; } --- 279,283 ---- private int getAlphabeticalIndex(OutlineNode parent,OutlineNode node){ int index=0; ! while((parent.getChildCount() > index) && (node.getNode().getDisplayName().compareToIgnoreCase(((OutlineNode)(parent.getChildAt(index))).getNode().getDisplayName()) > 0)){ ++index; } *************** *** 255,257 **** --- 285,310 ---- } + public void setSelected(Node node){ + setSelected(getOutlineNodePath(node)); + } + + private void setSelected(TreePath outlineNodePath) { + tree.setSelectionPath(outlineNodePath); + } + + + public void clearSelection(){ + tree.clearSelection(); + } + + public void valueChanged(TreeSelectionEvent e) { + if(!((OutlineNode)e.getPath().getLastPathComponent()).getAllowsChildren()){ + Node node = ((OutlineNode)e.getPath().getLastPathComponent()).getNode(); + Controller.getInstance().getMapView().getPACWGraphDraw().setSelected(Controller.getInstance().getMapView().findVertex(node)); + } else { + Controller.getInstance().getMapView().getPACWGraphDraw().setSelected(null); + } + } + + } \ No newline at end of file Index: MapView.java =================================================================== RCS file: /cvsroot/magicmap/magicmapclient/src/net/sf/magicmap/client/views/MapView.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** MapView.java 4 Oct 2005 13:12:24 -0000 1.13 --- MapView.java 12 Oct 2005 21:44:17 -0000 1.14 *************** *** 1092,1095 **** --- 1092,1096 ---- Controller.getInstance().getMeasurementView().setTitle( GUIUtils.i18n("measurement") + " " + Controller.getInstance().getClient().getDisplayName()); + Controller.getInstance().getOutlineView().clearSelection(); return; } *************** *** 1160,1162 **** --- 1161,1167 ---- } + public PACWGraphDraw getPACWGraphDraw(){ + return graphdraw; + } + } \ No newline at end of file |