|
From: <fle...@us...> - 2007-10-08 14:58:25
|
Revision: 672
http://magicmap.svn.sourceforge.net/magicmap/?rev=672&view=rev
Author: flederohr
Date: 2007-10-08 07:58:23 -0700 (Mon, 08 Oct 2007)
Log Message:
-----------
Handle maploading:
double left-click on MapNodes in OutlineView opens Map
Modified Paths:
--------------
trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java
trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java
trunk/magicmapclient/src/net/sf/magicmap/client/controller/VirtualServerManager.java
trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java
trunk/magicmapclient/src/net/sf/magicmap/client/interfaces/MapNamesCallback.java
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java 2007-10-08 12:17:52 UTC (rev 671)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/Controller.java 2007-10-08 14:58:23 UTC (rev 672)
@@ -4,8 +4,10 @@
package net.sf.magicmap.client.controller;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
+import java.net.URL;
import java.rmi.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,10 +33,12 @@
import net.sf.magicmap.client.model.node.ClientNode;
import net.sf.magicmap.client.model.node.GeoPos;
import net.sf.magicmap.client.model.node.INodeModel;
+import net.sf.magicmap.client.model.node.MapNode;
import net.sf.magicmap.client.model.node.Node;
import net.sf.magicmap.client.model.node.NodeModel;
import net.sf.magicmap.client.plugin.PluginManager;
import net.sf.magicmap.client.utils.Settings;
+import net.sf.magicmap.server.dto.MapDTO;
import net.sf.magicmap.server.exception.SessionException;
import org.apache.log4j.xml.DOMConfigurator;
@@ -51,7 +55,8 @@
ServerDisconnectCallback,
ServerConnectCallback,
CreateNewMapCallback,
- MapNamesCallback {
+ MapNamesCallback,
+ MapCallback {
private static int numCalled = 0;
private static int disconnectAttempts = 0;
@@ -170,6 +175,9 @@
closeMap();
}
if (isMapLoaded() && isConnected()) {
+ // TODO: Interface f\xFCr GUI mit methode setMapTitle()
+ ((MapView) MainGUI.getInstance().getJComponent("mapView")).setTitle(GUIUtils.i18n("map", false) + " - "
+ + currentMap.name);
this.serverManager.resetTimestamp();
this.poller.start();
// initializeScanner(); // Scanner neu initialisieren
@@ -179,6 +187,7 @@
if (this.currentMap.realheight > 0 && this.currentMap.realwidth > 0)
// TODO: Interface f\xFCr GUI mit methode setMapTitle()
+
((MapView) MainGUI.getInstance().getJComponent("mapView")).setTitle(GUIUtils.i18n("map", false) + " - "
+ this.currentMap.name + " Gr\xF6\xDFe: " + this.currentMap.realwidth + " X "
+ this.currentMap.realheight + " cm");
@@ -226,6 +235,9 @@
this.client.setPosition(0, 0, 0);
this.client.setFix(false);
this.nodeModel.clear();
+
+ // TODO: move this to right click menu
+ this.retrieveMapNames(this, false);
}
/**
@@ -419,8 +431,6 @@
*/
public void retrieveMap(String name, MapCallback callback){
this.serverManager.retrieveMap(name, callback);
- // TODO: Interface f\xFCr GUI mit methode setMapTitle()
- ((MapView) MainGUI.getInstance().getJComponent("mapView")).setTitle(GUIUtils.i18n("map", false) + " - " + name);
}
public void retrieveMapNames(MapNamesCallback callback, boolean openMapDialog){
@@ -444,11 +454,11 @@
public void addScannerHandler(AbstractScannerHandler handler){
this.scannerAllocator.addScanResultHandler(handler);
}
-
+
public void removeScannerHandler(AbstractScannerHandler handler){
this.scannerAllocator.removeScanResultHandler(handler);
}
-
+
public void initializePlugins(){
try {
this.pluginManager = new PluginManager(new Settings(), this);
@@ -503,4 +513,32 @@
public void openMapDialog(String[] names){
MainGUI.getInstance().getMainFrame().openMapDialog(names);
}
+
+ public void retrievedMapNames(final String[] names){
+ for (String string : names) {
+ retrieveMap(string, this);
+ }
+ }
+
+ public void getMapError(Exception e){
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mapReceived(MapDTO mapDTO){
+ try {
+ URL imageURL = new URL(mapDTO.getImageURL());
+ // check if map image is accessible
+ imageURL.openStream();
+
+ INodeModel nodeModel = Controller.getInstance().getNodeModel();
+ MapNode node = new MapNode(nodeModel);
+ node.setName(mapDTO.getName());
+ node.setDisplayName(mapDTO.getName());
+ node.setMapInfo(mapDTO);
+ nodeModel.addNode(node);
+ } catch (MalformedURLException e) {
+ } catch (IOException e) {
+ }
+ }
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java 2007-10-08 12:17:52 UTC (rev 671)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/SOAPServerManager.java 2007-10-08 14:58:23 UTC (rev 672)
@@ -183,8 +183,11 @@
if (!isConnected()) return;
try {
String[] names = SOAPServerManager.this.mapDelegate.getMapNames();
- if (openDialog)
+ if (openDialog) {
callback.openMapDialog(names);
+ } else {
+ callback.retrievedMapNames(names);
+ }
} catch (Exception e) {
e.printStackTrace();
callback.getMapNamesError(e);
@@ -324,8 +327,6 @@
}
}
-
-
/**
* Entfernt einen Referenzpunkt oder die Positionierung eines AccessPoints
* oder Clients mit gegebener Id vom Server
@@ -739,5 +740,4 @@
}
}
-
}
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/controller/VirtualServerManager.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/controller/VirtualServerManager.java 2007-10-08 12:17:52 UTC (rev 671)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/controller/VirtualServerManager.java 2007-10-08 14:58:23 UTC (rev 672)
@@ -1,6 +1,5 @@
/*
* Created on 10.05.2005
- *
*/
package net.sf.magicmap.client.controller;
@@ -184,6 +183,8 @@
if (openDialog) {
callback.openMapDialog(names);
+ } else {
+ callback.retrievedMapNames(names);
}
} catch (Exception e) {
e.printStackTrace();
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java 2007-10-08 12:17:52 UTC (rev 671)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/gui/views/OutlineView.java 2007-10-08 14:58:23 UTC (rev 672)
@@ -6,6 +6,8 @@
import java.awt.Dimension;
import java.awt.Insets;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.JPanel;
@@ -16,6 +18,7 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
+import net.sf.magicmap.client.controller.Controller;
import net.sf.magicmap.client.gui.MainGUI;
import net.sf.magicmap.client.gui.utils.GUIBuilder;
import net.sf.magicmap.client.gui.utils.GUIConstants;
@@ -23,6 +26,7 @@
import net.sf.magicmap.client.gui.utils.RelativePanelBuilder;
import net.sf.magicmap.client.model.node.INodeModel;
import net.sf.magicmap.client.model.node.INodeModelSelectionListener;
+import net.sf.magicmap.client.model.node.MapNode;
import net.sf.magicmap.client.model.node.Node;
import net.sf.magicmap.client.model.node.NodeModelConstants;
import net.sf.magicmap.client.model.node.NodeModelSelectionEvent;
@@ -36,7 +40,7 @@
*
* @author thuebner
*/
-public class OutlineView extends View implements TreeSelectionListener, INodeModelSelectionListener {
+public class OutlineView extends View implements TreeSelectionListener, INodeModelSelectionListener, MouseListener {
/**
* serial version id
@@ -74,6 +78,8 @@
tree.addTreeSelectionListener(this);
+ tree.addMouseListener(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)));
@@ -249,4 +255,45 @@
public OutlineModel getOutlineModel(){
return this.outlineModel;
}
+
+ public void mouseClicked(MouseEvent e){
+
+ switch (e.getButton()) {
+ case MouseEvent.BUTTON1 :
+ if (e.getClickCount() == 2) {
+ Node node;
+ // check if MapNode is selected
+ if ((node = ((OutlineTreeNode) ((OutlineTree) e.getSource()).getSelectionPath()
+ .getLastPathComponent()).getNode()) instanceof MapNode)
+ Controller.getInstance().setCurrentMap(((MapNode) node).getMapInfo());
+ }
+ break;
+ case MouseEvent.BUTTON2 :
+ break;
+ case MouseEvent.BUTTON3 :
+ // TODO: right-click-menu
+ break;
+ }
+
+ }
+
+ public void mouseEntered(MouseEvent e){
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseExited(MouseEvent e){
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mousePressed(MouseEvent e){
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseReleased(MouseEvent e){
+ // TODO Auto-generated method stub
+
+ }
}
\ No newline at end of file
Modified: trunk/magicmapclient/src/net/sf/magicmap/client/interfaces/MapNamesCallback.java
===================================================================
--- trunk/magicmapclient/src/net/sf/magicmap/client/interfaces/MapNamesCallback.java 2007-10-08 12:17:52 UTC (rev 671)
+++ trunk/magicmapclient/src/net/sf/magicmap/client/interfaces/MapNamesCallback.java 2007-10-08 14:58:23 UTC (rev 672)
@@ -15,6 +15,12 @@
* @param names - the names of the maps
*/
public void openMapDialog(String[] names);
+
+ /**
+ * Get the retrieved map names
+ * @param names - the names of the maps
+ */
+ public void retrievedMapNames(String[] names);
/**
* Get the error msg of the failed map names retrievement
@@ -22,4 +28,5 @@
*/
public void getMapNamesError(Exception e);
+
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|