|
From: <fle...@us...> - 2008-02-01 12:12:43
|
Revision: 726
http://magicmap.svn.sourceforge.net/magicmap/?rev=726&view=rev
Author: flederohr
Date: 2008-02-01 04:12:41 -0800 (Fri, 01 Feb 2008)
Log Message:
-----------
added menu for accesspoint-hiding to the OutlineView
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INodeSelectionModel.java
trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeSelectionModel.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java 2008-02-01 11:53:28 UTC (rev 725)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java 2008-02-01 12:12:41 UTC (rev 726)
@@ -6,11 +6,14 @@
import java.awt.Dimension;
import java.awt.Insets;
+import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.border.EmptyBorder;
@@ -20,12 +23,22 @@
import net.sf.magicmap.client.controller.Controller;
import net.sf.magicmap.client.gui.MainGUI;
+import net.sf.magicmap.client.gui.MapPanel;
import net.sf.magicmap.client.gui.utils.GUIBuilder;
import net.sf.magicmap.client.gui.utils.GUIConstants;
import net.sf.magicmap.client.gui.utils.GUIUtils;
+import net.sf.magicmap.client.gui.utils.MagicAction;
import net.sf.magicmap.client.gui.utils.RelativePanelBuilder;
+import net.sf.magicmap.client.gui.utils.menu.NodeMenuAndPredicate;
+import net.sf.magicmap.client.gui.utils.menu.NodeMenuContainer;
+import net.sf.magicmap.client.gui.utils.menu.NodeMenuPredicate;
+import net.sf.magicmap.client.gui.utils.menu.NodeMenuTypePredicate;
+import net.sf.magicmap.client.model.node.AccessPointNode;
+import net.sf.magicmap.client.model.node.ClientNode;
+import net.sf.magicmap.client.model.node.INode;
import net.sf.magicmap.client.model.node.INodeModel;
import net.sf.magicmap.client.model.node.INodeModelSelectionListener;
+import net.sf.magicmap.client.model.node.LocationNode;
import net.sf.magicmap.client.model.node.MapNode;
import net.sf.magicmap.client.model.node.Node;
import net.sf.magicmap.client.model.node.NodeModelConstants;
@@ -63,10 +76,57 @@
this.outlineModel = new OutlineModel(nodeModel);
rootNode = (OutlineTreeNode) outlineModel.getRoot();
setContent(buildViewComponent());
+ buildNodeMenu();
MainGUI.getInstance().getNodeSelectionModel().addNodeModelSelectionListener(this);
MainGUI.getInstance().registerJComponent(this, name);
}
+ private void buildNodeMenu(){
+ NodeMenuContainer nc = this.getMenuContainer();
+
+ nc.addNodeMenuItem(this, GUIBuilder.createMenuItem(new MagicAction("map.panel.context.hide.ap"){
+ /**
+ *
+ */
+ private static final long serialVersionUID = 0L;
+
+ @Override
+ public void actionPerformed(ActionEvent e){
+ AccessPointNode ap = (AccessPointNode) MainGUI.getInstance().getNodeSelectionModel().getSelectedNode();
+ ap.setHiddenStatus(true);
+ ap.setName(ap.getName() + "(" + GUIUtils.i18n("node.accesspoint.is.hide") + ")");
+ Controller.getInstance().setAccessPointHiddenStatus(ap.getMacAddress(), true, ((MapPanel)MainGUI.getInstance().getJComponent("mapPanel")));
+ }
+ }),new NodeMenuAndPredicate(new NodeMenuTypePredicate(NodeModelConstants.NODETYPE_ACCESSPOINT),new NodeMenuPredicate(){
+
+ public boolean show(Object context){
+ return !((AccessPointNode)context).isHidden();
+ }
+
+ }));
+
+ nc.addNodeMenuItem(this, GUIBuilder.createMenuItem(new MagicAction("map.panel.context.hide.ap.off"){
+ /**
+ *
+ */
+ private static final long serialVersionUID = 0L;
+
+ @Override
+ public void actionPerformed(ActionEvent e){
+ AccessPointNode ap = (AccessPointNode) MainGUI.getInstance().getNodeSelectionModel().getSelectedNode();
+ ap.setHiddenStatus(false);
+ ap.setName(ap.getName().substring(0, ap.getName().length() - 5));
+ Controller.getInstance().setAccessPointHiddenStatus(ap.getMacAddress(), false, ((MapPanel)MainGUI.getInstance().getJComponent("mapPanel")));
+ }
+ }),new NodeMenuAndPredicate(new NodeMenuTypePredicate(NodeModelConstants.NODETYPE_ACCESSPOINT),new NodeMenuPredicate(){
+
+ public boolean show(Object context){
+ return ((AccessPointNode)context).isHidden();
+ }
+
+ }));
+ }
+
/* (non-Javadoc)
* @see net.sf.magicmap.client.views.View#buildViewComponent()
*/
@@ -141,7 +201,7 @@
*/
public synchronized void valueChanged(TreeSelectionEvent tse){
OutlineTreeNode outlineTreeNode = ((OutlineTreeNode) tse.getPath().getLastPathComponent());
- if (null != outlineTreeNode.getNode()) {
+ if (null != outlineTreeNode) {
final Node node = outlineTreeNode.getNode();
if (null != node) {
MainGUI.getInstance().getNodeSelectionModel().removeNodeModelSelectionListener(this);
@@ -272,6 +332,10 @@
break;
case MouseEvent.BUTTON3 :
// TODO: right-click-menu
+ Node node;
+ // check if MapNode is selected
+ if ((node = ((OutlineTreeNode) ((OutlineTree) e.getSource()).getSelectionPath().getLastPathComponent())
+ .getNode()) instanceof Node) this.getMenuContainer().buildMenu(node, new JPopupMenu()).show(this, e.getX(), e.getY());
break;
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INodeSelectionModel.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INodeSelectionModel.java 2008-02-01 11:53:28 UTC (rev 725)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/node/INodeSelectionModel.java 2008-02-01 12:12:41 UTC (rev 726)
@@ -18,4 +18,6 @@
* @return the selected node.
*/
Node selectNode(Node selectedNode);
+
+ Node getSelectedNode();
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeSelectionModel.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeSelectionModel.java 2008-02-01 11:53:28 UTC (rev 725)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/model/node/NodeSelectionModel.java 2008-02-01 12:12:41 UTC (rev 726)
@@ -41,4 +41,8 @@
}
return selectedNode;
}
+
+ public Node getSelectedNode(){
+ return selectedNode;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|