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. |
From: <an...@us...> - 2008-02-04 17:00:03
|
Revision: 731 http://magicmap.svn.sourceforge.net/magicmap/?rev=731&view=rev Author: anweiss Date: 2008-02-04 07:51:35 -0800 (Mon, 04 Feb 2008) Log Message: ----------- renamed pollintevall to pollinterval and selected the correct pollinterval in the options menu at startup Modified Paths: -------------- trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerPoller.java trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainFrame.java trunk/magicmapclient/src/net/sf/magicmap/client/utils/Settings.java Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerPoller.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerPoller.java 2008-02-04 15:43:54 UTC (rev 730) +++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/ServerPoller.java 2008-02-04 15:51:35 UTC (rev 731) @@ -40,7 +40,7 @@ } public void start(){ - this.timer.scheduleAtFixedRate(pollPositionsTimerTask(), Settings.POLL_DELAY, Settings.getPollIntevall()); + this.timer.scheduleAtFixedRate(pollPositionsTimerTask(), Settings.POLL_DELAY, Settings.getPollInterval()); this.timer.scheduleAtFixedRate(pollGeoPointsTimerTask(), Settings.POLL_DELAY + 1000, 120000); } Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainFrame.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainFrame.java 2008-02-04 15:43:54 UTC (rev 730) +++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/MainFrame.java 2008-02-04 15:51:35 UTC (rev 731) @@ -253,7 +253,7 @@ menu.add(dataInvocationRate); for (int i = 0; i < MainFrame.numberOfdataInvocationRateAction; i++) dataInvocationRate.add(GUIBuilder.createCheckBoxMenuItem(this.dataInvocationRateAction[i], false)); - this.dataInvocationRateAction[4].setSelected(true); + this.dataInvocationRateAction[(Settings.getPollInterval()/1000)-1].setSelected(true); return menu; } @@ -590,7 +590,7 @@ } } }; - + this.homepageAction = new MagicAction("homepage") { /** @@ -806,7 +806,7 @@ for (int j = 0; j < MainFrame.numberOfdataInvocationRateAction; j++) MainFrame.this.dataInvocationRateAction[j].setSelected(false); MainFrame.this.dataInvocationRateAction[thisAction].setSelected(true); - Settings.setPollIntevall((thisAction + 1) * 1000); + Settings.setPollInterval((thisAction + 1) * 1000); Controller.getInstance().restartServerPoller(); } }; Modified: trunk/magicmapclient/src/net/sf/magicmap/client/utils/Settings.java =================================================================== --- trunk/magicmapclient/src/net/sf/magicmap/client/utils/Settings.java 2008-02-04 15:43:54 UTC (rev 730) +++ trunk/magicmapclient/src/net/sf/magicmap/client/utils/Settings.java 2008-02-04 15:51:35 UTC (rev 731) @@ -36,7 +36,7 @@ private static final String settingsFileName = "settings.ini"; private static final String SERVERNAMES_KEY = "servernames"; private static final String LASTSELECTEDSERVER_KEY = "lastselectedserver"; - private static final String POLLINTERVALL_KEY = "pollintevall"; + private static final String POLLINTERVAL_KEY = "pollinterval"; private static final String CLIENTNAME_KEY = "clientname"; private static final String STANDALONE_KEY = "standalone"; // private static final String VIEWOPTION_KEY = "viewoption"; @@ -55,7 +55,7 @@ private static ArrayList<String> default_server_list = new ArrayList<String>(); private static int lastSelectedServer = 0; public static final int TIMEOUT = 15000; - private static int pollIntevall = 5000; + private static int pollInterval = 5000; public static final long POLL_DELAY = 500; public static String WEBSERVICE_PATH = "/magicmap/services/"; @@ -80,12 +80,12 @@ Settings.clientMAC = clientMAC; } - public static int getPollIntevall(){ - return Settings.pollIntevall; + public static int getPollInterval(){ + return Settings.pollInterval; } - public static void setPollIntevall(int pollIntevall){ - Settings.pollIntevall = pollIntevall; + public static void setPollInterval(int pollInterval){ + Settings.pollInterval = pollInterval; } public static String getClientName(){ @@ -207,11 +207,11 @@ else // default value Settings.lastSelectedServer = 0; - if ((property = Settings.settingsProperties.getProperty(Settings.POLLINTERVALL_KEY)) != null) - Settings.pollIntevall = Integer.parseInt(property.trim()); + if ((property = Settings.settingsProperties.getProperty(Settings.POLLINTERVAL_KEY)) != null) + Settings.pollInterval = Integer.parseInt(property.trim()); else // default value - Settings.pollIntevall = 5000; + Settings.pollInterval = 5000; if ((property = Settings.settingsProperties.getProperty(Settings.CLIENTNAME_KEY)) != null) Settings.clientName = property.trim(); else @@ -282,7 +282,7 @@ Settings.settingsProperties.put(Settings.SERVERNAMES_KEY, property.substring(0, property.lastIndexOf(','))); Settings.settingsProperties.put(Settings.LASTSELECTEDSERVER_KEY, String .valueOf(Settings.lastSelectedServer)); - Settings.settingsProperties.put(Settings.POLLINTERVALL_KEY, String.valueOf(Settings.pollIntevall)); + Settings.settingsProperties.put(Settings.POLLINTERVAL_KEY, String.valueOf(Settings.pollInterval)); Settings.settingsProperties.put(Settings.CLIENTNAME_KEY, Settings.clientName); if (Settings.standAlone) property = "YES"; @@ -297,7 +297,7 @@ + "# This file stores the configuration for MagicMap. #" + newline + "# #" + newline + "####################################################################" + newline - + newline + "# Comma seperated list of default MagicMap-Servers" + newline + + newline + "# Comma separated list of default MagicMap-Servers" + newline + "# servernames= server-url1:port1, server-url2:port2 , ..." + newline + newline + "# lastselectedserver=index" + newline + newline + "# pollintevall=time in ms" + newline + newline + "# clientname=" + newline + newline + "# standalone=(YES|NO)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |