diff options
author | Bernard Normier <bernard@zeroc.com> | 2005-07-01 15:20:33 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2005-07-01 15:20:33 +0000 |
commit | 1ff98f14066ee60dd8ef2109cf7d772235740a9b (patch) | |
tree | 3f6e809c3d470e1190d1f73bd02f1b8d9847e78a | |
parent | Removed applicationSynced call, fixed node observer nodeUp method to not (diff) | |
download | ice-1ff98f14066ee60dd8ef2109cf7d772235740a9b.tar.bz2 ice-1ff98f14066ee60dd8ef2109cf7d772235740a9b.tar.xz ice-1ff98f14066ee60dd8ef2109cf7d772235740a9b.zip |
Added start/stop popup menu
-rwxr-xr-x | java/src/IceGrid/AdminGUI.java | 9 | ||||
-rwxr-xr-x | java/src/IceGrid/MainPane.java | 48 | ||||
-rwxr-xr-x | java/src/IceGrid/Model.java | 159 | ||||
-rwxr-xr-x | java/src/IceGrid/RegistryObserverI.java | 34 | ||||
-rwxr-xr-x | java/src/IceGrid/SessionKeeper.java | 100 | ||||
-rwxr-xr-x | java/src/IceGrid/StatusBar.java | 2 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Application.java | 11 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/ApplicationViewRoot.java | 24 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Node.java | 7 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/NodeViewRoot.java | 19 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/ServerInstance.java | 115 |
11 files changed, 358 insertions, 170 deletions
diff --git a/java/src/IceGrid/AdminGUI.java b/java/src/IceGrid/AdminGUI.java index ea1a6749633..3295db9e54e 100755 --- a/java/src/IceGrid/AdminGUI.java +++ b/java/src/IceGrid/AdminGUI.java @@ -81,7 +81,7 @@ public class AdminGUI extends JFrame });
_communicator = Ice.Util.initialize(args);
- _model = new Model(_communicator);
+ _model = new Model(_communicator, new StatusBarI());
initComponents();
@@ -97,7 +97,7 @@ public class AdminGUI extends JFrame // Display the window.
//
setVisible(true);
- _sessionKeeper = new SessionKeeper(this, _model, _prefs, _statusBar);
+ _sessionKeeper = new SessionKeeper(this, _model, _prefs);
_sessionKeeper.createSession(true);
}
@@ -203,8 +203,7 @@ public class AdminGUI extends JFrame //
// Status bar
//
- _statusBar = new StatusBarI();
- getContentPane().add(_statusBar, BorderLayout.PAGE_END);
+ getContentPane().add((StatusBarI)_model.getStatusBar(), BorderLayout.PAGE_END);
//
// Actions
@@ -338,8 +337,6 @@ public class AdminGUI extends JFrame private Action _discardAction;
private Action _pasteAction;
- private StatusBarI _statusBar;
-
private Preferences _prefs = Preferences.userNodeForPackage(getClass());
private Ice.Communicator _communicator;
diff --git a/java/src/IceGrid/MainPane.java b/java/src/IceGrid/MainPane.java index c2d1834e853..97ed8422f91 100755 --- a/java/src/IceGrid/MainPane.java +++ b/java/src/IceGrid/MainPane.java @@ -12,24 +12,63 @@ import java.util.prefs.Preferences; import java.util.prefs.BackingStoreException; import javax.swing.*; import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import com.jgoodies.looks.Options; import com.jgoodies.looks.plastic.PlasticLookAndFeel; import com.jgoodies.looks.windows.WindowsLookAndFeel; import com.jgoodies.forms.factories.Borders; -import javax.swing.border.EmptyBorder; +import javax.swing.border.EmptyBorder; import javax.swing.plaf.SplitPaneUI; import javax.swing.plaf.basic.BasicSplitPaneUI; - import javax.swing.border.AbstractBorder; +import IceGrid.TreeNode.CommonBase; + + public class MainPane extends JSplitPane { + class PopupListener extends MouseAdapter + { + public void mousePressed(MouseEvent e) + { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) + { + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) + { + if (e.isPopupTrigger()) + { + JTree tree = (JTree)e.getComponent(); + + TreePath path = tree.getPathForLocation(e.getX(), e.getY()); + + if(path != null) + { + CommonBase node = (CommonBase)path.getLastPathComponent(); + JPopupMenu popup = node.getPopupMenu(); + if(popup != null) + { + popup.show(tree, e.getX(), e.getY()); + } + } + } + } + } + + public void updateUI() { super.updateUI(); @@ -62,10 +101,13 @@ public class MainPane extends JSplitPane tabbedPane.setBorder(new ShadowBorder()); TreeCellRenderer renderer = new CellRenderer(); + PopupListener popupListener = new PopupListener(); JTree nodeTree = new JTree(_model.getTreeModel(TreeModelI.NODE_VIEW)); nodeTree.setCellRenderer(renderer); ToolTipManager.sharedInstance().registerComponent(nodeTree); + nodeTree.addMouseListener(popupListener); + JScrollPane nodeScroll = new JScrollPane(nodeTree, @@ -79,6 +121,8 @@ public class MainPane extends JSplitPane JTree appTree = new JTree(_model.getTreeModel(TreeModelI.APPLICATION_VIEW)); appTree.setCellRenderer(renderer); ToolTipManager.sharedInstance().registerComponent(appTree); + appTree.addMouseListener(popupListener); + JScrollPane appScroll = new JScrollPane(appTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java index 7ae1f4b3091..2eb2d548ac8 100755 --- a/java/src/IceGrid/Model.java +++ b/java/src/IceGrid/Model.java @@ -8,7 +8,12 @@ // **********************************************************************
package IceGrid;
+import java.util.prefs.Preferences;
+
+import java.awt.Component;
+import java.awt.Cursor;
import javax.swing.tree.TreeModel;
+import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import IceGrid.TreeNode.NodeViewRoot;
@@ -20,7 +25,6 @@ import IceGrid.TreeNode.ApplicationViewRoot; public class Model
{
-
//
// Application view:
//
@@ -93,6 +97,57 @@ public class Model // -- adapters, databases (see above)
+ public static class ConnectInfo
+ {
+ ConnectInfo(Preferences connectionPrefs,
+ Ice.Communicator communicator)
+ {
+ String defaultLocator = communicator.getProperties().
+ getProperty("Ice.Default.Locator");
+ if(defaultLocator.equals(""))
+ {
+ defaultLocator = "IceGrid/Locator:ssl -h hostname -p port -t timeout";
+ }
+
+ _connectionPrefs = connectionPrefs;
+ locatorProxy = _connectionPrefs.
+ get("locatorProxy", defaultLocator);
+ username = _connectionPrefs.get("username", username);
+ useGlacier = _connectionPrefs.
+ getBoolean("useGlacier", useGlacier);
+ autoconnect = _connectionPrefs.
+ getBoolean("autoconnect", autoconnect);
+ adminIdentity = _connectionPrefs.
+ get("adminIdentity", adminIdentity);
+ sessionManagerIdentity = _connectionPrefs.
+ get("sessionManagerIdentity", sessionManagerIdentity);
+ }
+
+ void save()
+ {
+ _connectionPrefs.put("locatorProxy", locatorProxy);
+ _connectionPrefs.put("username", username);
+ _connectionPrefs.putBoolean("useGlacier", useGlacier);
+ _connectionPrefs.putBoolean("autoconnect", autoconnect);
+ _connectionPrefs.put("adminIdentity", adminIdentity);
+ _connectionPrefs.put("sessionManagerIdentity",
+ sessionManagerIdentity);
+ }
+
+ String locatorProxy;
+ String username = System.getProperty("user.name");
+ char[] password;
+ boolean useGlacier = false;
+ boolean autoconnect = false;
+ String adminIdentity = "IceGrid/Admin";
+ String sessionManagerIdentity = "IceGrid/SessionManager";
+
+ private Preferences _connectionPrefs;
+ }
+
+
+
+
//
// All Model's methods run in the UI thread
//
@@ -155,13 +210,6 @@ public class Model _applicationViewRoot.applicationRemoved(name);
}
- void applicationSynced(ApplicationDescriptor desc)
- {
- _nodeViewRoot.remove(desc.name);
- _nodeViewRoot.put(desc.name, desc.nodes, true);
- _applicationViewRoot.applicationSynced(desc);
- }
-
void applicationUpdated(ApplicationUpdateDescriptor desc)
{
for(int i = 0; i < desc.removeNodes.length; ++i)
@@ -222,8 +270,80 @@ public class Model _latestSerial = -1;
_nodeViewRoot.clear();
_applicationViewRoot.clear();
+ _sessionManager = null;
+ _admin = null;
}
+
+ boolean setConnectInfo(ConnectInfo info, Component parent,
+ Cursor oldCursor)
+ {
+
+ //
+ // Default locator
+ //
+ Ice.LocatorPrx defaultLocator = null;
+ try
+ {
+ defaultLocator = Ice.LocatorPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(info.locatorProxy));
+ _communicator.setDefaultLocator(defaultLocator);
+ }
+ catch(Ice.LocalException e)
+ {
+ sessionLost();
+ parent.setCursor(oldCursor);
+ JOptionPane.showMessageDialog(
+ parent,
+ "The locator proxy is invalid: " + e.toString(),
+ "Invalid locator proxy",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Session manager
+ //
+ try
+ {
+ _sessionManager = SessionManagerPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(info.sessionManagerIdentity));
+ }
+ catch(Ice.LocalException e)
+ {
+ sessionLost();
+ parent.setCursor(oldCursor);
+ JOptionPane.showMessageDialog(
+ parent,
+ "The session manager identity is invalid: " + e.toString(),
+ "Invalid session manager",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Admin
+ //
+ try
+ {
+ _admin = AdminPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(info.adminIdentity));
+ }
+ catch(Ice.LocalException e)
+ {
+ sessionLost();
+ parent.setCursor(oldCursor);
+ JOptionPane.showMessageDialog(
+ parent,
+ "The admin identity is invalid: " + e.toString(),
+ "Invalid admin identity",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ return true;
+ }
+
boolean save()
{
return true;
@@ -234,9 +354,26 @@ public class Model return true;
}
- Model(Ice.Communicator communicator)
+ public AdminPrx getAdmin()
+ {
+ return _admin;
+ }
+
+ public SessionManagerPrx getSessionManager()
+ {
+ return _sessionManager;
+ }
+
+ public StatusBar getStatusBar()
+ {
+ return _statusBar;
+ }
+
+
+ Model(Ice.Communicator communicator, StatusBar statusBar)
{
_communicator = communicator;
+ _statusBar = statusBar;
_nodeViewRoot = new NodeViewRoot(this);
_nodeModel = new TreeModelI(_nodeViewRoot);
@@ -248,6 +385,10 @@ public class Model private Ice.Communicator _communicator;
+ private StatusBar _statusBar;
+ private SessionManagerPrx _sessionManager;
+ private AdminPrx _admin;
+
private NodeViewRoot _nodeViewRoot;
private ApplicationViewRoot _applicationViewRoot;
diff --git a/java/src/IceGrid/RegistryObserverI.java b/java/src/IceGrid/RegistryObserverI.java index 0c500888cb8..0fc7c1b6625 100755 --- a/java/src/IceGrid/RegistryObserverI.java +++ b/java/src/IceGrid/RegistryObserverI.java @@ -13,10 +13,9 @@ import javax.swing.SwingUtilities; class RegistryObserverI extends _RegistryObserverDisp
{
- RegistryObserverI(SessionKeeper sessionKeeper, StatusBar statusBar, Model model)
+ RegistryObserverI(SessionKeeper sessionKeeper, Model model)
{
_sessionKeeper = sessionKeeper;
- _statusBar = statusBar;
_model = model;
}
@@ -51,7 +50,7 @@ class RegistryObserverI extends _RegistryObserverDisp if(_initialized)
{
_model.registryInit(_serial, _applications);
- _statusBar.setText("Connected; initialized (" + _serial + ")");
+ _model.getStatusBar().setText("Connected; initialized (" + _serial + ")");
}
else
{
@@ -79,7 +78,7 @@ class RegistryObserverI extends _RegistryObserverDisp if(_model.updateSerial(serial))
{
_model.applicationAdded(desc);
- _statusBar.setText("Connected; application '"
+ _model.getStatusBar().setText("Connected; application '"
+ desc.name + "' added (" + serial + ")");
}
else
@@ -101,7 +100,7 @@ class RegistryObserverI extends _RegistryObserverDisp if(_model.updateSerial(serial))
{
_model.applicationRemoved(name);
- _statusBar.setText("Connected; application '"
+ _model.getStatusBar().setText("Connected; application '"
+ name + "' removed (" + serial + ")");
}
else
@@ -113,28 +112,6 @@ class RegistryObserverI extends _RegistryObserverDisp });
}
- public void applicationSynced(final int serial, final ApplicationDescriptor desc,
- Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- if(_model.updateSerial(serial))
- {
- _model.applicationSynced(desc);
- _statusBar.setText("Connected; application '"
- + desc.name + "' sync-ed (" + serial + ")");
- }
- else
- {
- _sessionKeeper.sessionLost(
- "Received application update (application sync-ed) out of sequence");
- }
- }
- });
- }
-
public void applicationUpdated(final int serial, final ApplicationUpdateDescriptor desc,
Ice.Current current)
{
@@ -145,7 +122,7 @@ class RegistryObserverI extends _RegistryObserverDisp if(_model.updateSerial(serial))
{
_model.applicationUpdated(desc);
- _statusBar.setText("Connected; application '"
+ _model.getStatusBar().setText("Connected; application '"
+ desc.name + "' updated (" + serial + ")");
}
else
@@ -158,7 +135,6 @@ class RegistryObserverI extends _RegistryObserverDisp private SessionKeeper _sessionKeeper;
- private StatusBar _statusBar;
private Model _model;
private boolean _initialized = false;
diff --git a/java/src/IceGrid/SessionKeeper.java b/java/src/IceGrid/SessionKeeper.java index 64d97424ba8..21faaa5f92f 100755 --- a/java/src/IceGrid/SessionKeeper.java +++ b/java/src/IceGrid/SessionKeeper.java @@ -139,7 +139,7 @@ class SessionKeeper setResizable(false);
}
- boolean showDialog(ConnectInfo info)
+ boolean showDialog(Model.ConnectInfo info)
{
if(isVisible() == false)
{
@@ -168,7 +168,7 @@ class SessionKeeper }
}
- private ConnectInfo _info;
+ private Model.ConnectInfo _info;
private JTextField _locatorProxy;
private JTextField _username;
@@ -180,56 +180,7 @@ class SessionKeeper private JTextField _sessionManagerIdentity;
}
-
- static class ConnectInfo
- {
- ConnectInfo(Preferences connectionPrefs,
- Ice.Communicator communicator)
- {
- String defaultLocator = communicator.getProperties().
- getProperty("Ice.Default.Locator");
- if(defaultLocator.equals(""))
- {
- defaultLocator = "IceGrid/Locator:ssl -h hostname -p port -t timeout";
- }
-
- _connectionPrefs = connectionPrefs;
- locatorProxy = _connectionPrefs.
- get("locatorProxy", defaultLocator);
- username = _connectionPrefs.get("username", username);
- useGlacier = _connectionPrefs.
- getBoolean("useGlacier", useGlacier);
- autoconnect = _connectionPrefs.
- getBoolean("autoconnect", autoconnect);
- adminIdentity = _connectionPrefs.
- get("adminIdentity", adminIdentity);
- sessionManagerIdentity = _connectionPrefs.
- get("sessionManagerIdentity", sessionManagerIdentity);
- }
-
- void save()
- {
- _connectionPrefs.put("locatorProxy", locatorProxy);
- _connectionPrefs.put("username", username);
- _connectionPrefs.putBoolean("useGlacier", useGlacier);
- _connectionPrefs.putBoolean("autoconnect", autoconnect);
- _connectionPrefs.put("adminIdentity", adminIdentity);
- _connectionPrefs.put("sessionManagerIdentity",
- sessionManagerIdentity);
- }
-
- String locatorProxy;
- String username = System.getProperty("user.name");
- char[] password;
- boolean useGlacier = false;
- boolean autoconnect = false;
- String adminIdentity = "IceGrid/Admin";
- String sessionManagerIdentity = "IceGrid/SessionManager";
-
- private Preferences _connectionPrefs;
- }
-
-
+
//
// We create a brand new Pinger thread for each session
//
@@ -290,13 +241,12 @@ class SessionKeeper SessionKeeper(Frame parent, Model model,
- Preferences prefs, StatusBar statusBar)
+ Preferences prefs)
{
_parent = parent;
_connectDialog = new ConnectDialog();
_model = model;
_connectionPrefs = prefs.node("Connection");
- _statusBar = statusBar;
}
//
@@ -304,7 +254,7 @@ class SessionKeeper //
void createSession(boolean autoconnectEnabled)
{
- ConnectInfo connectInfo = new ConnectInfo(_connectionPrefs,
+ Model.ConnectInfo connectInfo = new Model.ConnectInfo(_connectionPrefs,
_model.getCommunicator());
boolean openDialog = true;
if(autoconnectEnabled && !connectInfo.useGlacier &&
@@ -325,7 +275,7 @@ class SessionKeeper //
// Runs in UI thread
//
- private boolean doConnect(Component parent, ConnectInfo info)
+ private boolean doConnect(Component parent, Model.ConnectInfo info)
{
if(_session != null)
{
@@ -379,41 +329,18 @@ class SessionKeeper }
else
{
-
- Ice.LocatorPrx defaultLocator = null;
- try
- {
- defaultLocator = Ice.LocatorPrxHelper.
- uncheckedCast(
- _model.getCommunicator().stringToProxy(info.locatorProxy));
- }
- catch(Ice.LocalException e)
+ if(!_model.setConnectInfo(info, parent, oldCursor))
{
- parent.setCursor(oldCursor);
- JOptionPane.showMessageDialog(
- parent,
- "The locator proxy is invalid: " + e.toString(),
- "Invalid locator proxy",
- JOptionPane.ERROR_MESSAGE);
return false;
}
- _model.getCommunicator().setDefaultLocator(defaultLocator);
-
- //
- // TODO: timeout
- //
-
- SessionManagerPrx sessionManager = SessionManagerPrxHelper.
- uncheckedCast(
- _model.getCommunicator().stringToProxy(
- info.sessionManagerIdentity));
try
{
- _session = sessionManager.createLocalSession(info.username);
+ _session = _model.getSessionManager().createLocalSession(info.username);
}
catch(Ice.LocalException e)
{
+ _model.sessionLost();
parent.setCursor(oldCursor);
JOptionPane.showMessageDialog(parent,
"Could not create session: "
@@ -424,7 +351,7 @@ class SessionKeeper }
}
- _statusBar.setText("Connected");
+ _model.getStatusBar().setText("Connected");
//
// Start thread
@@ -509,7 +436,7 @@ class SessionKeeper }
_thread = null;
_session = null;
- _statusBar.setText("Not connected");
+ _model.getStatusBar().setText("Not connected");
}
}
@@ -537,7 +464,7 @@ class SessionKeeper _nodeObserverIdentity.category = "nodeObserver";
RegistryObserverI registryObserverServant = new RegistryObserverI(
- this, _statusBar, _model);
+ this, _model);
RegistryObserverPrx registryObserver =
RegistryObserverPrxHelper.uncheckedCast(
@@ -600,8 +527,7 @@ class SessionKeeper private Model _model;
private Preferences _connectionPrefs;
- private StatusBar _statusBar;
-
+
private Pinger _thread;
private SessionPrx _session;
diff --git a/java/src/IceGrid/StatusBar.java b/java/src/IceGrid/StatusBar.java index 7189870aaa4..659622e6cfa 100755 --- a/java/src/IceGrid/StatusBar.java +++ b/java/src/IceGrid/StatusBar.java @@ -8,7 +8,7 @@ // **********************************************************************
package IceGrid;
-interface StatusBar
+public interface StatusBar
{
void setText(String text);
}
diff --git a/java/src/IceGrid/TreeNode/Application.java b/java/src/IceGrid/TreeNode/Application.java index 887788c6044..195dd921167 100755 --- a/java/src/IceGrid/TreeNode/Application.java +++ b/java/src/IceGrid/TreeNode/Application.java @@ -58,9 +58,18 @@ class Application extends Parent _descriptor.variables.putAll(desc.variables);
//
- // TODO: comment
+ // Targets and comment
//
+ if(desc.targets != null)
+ {
+ _descriptor.targets = desc.targets.value;
+ }
+
+ if(desc.comment != null)
+ {
+ _descriptor.comment = desc.comment.value;
+ }
//
// Server templates
diff --git a/java/src/IceGrid/TreeNode/ApplicationViewRoot.java b/java/src/IceGrid/TreeNode/ApplicationViewRoot.java index 40ee4686ea6..180dd2b21be 100755 --- a/java/src/IceGrid/TreeNode/ApplicationViewRoot.java +++ b/java/src/IceGrid/TreeNode/ApplicationViewRoot.java @@ -51,42 +51,24 @@ public class ApplicationViewRoot extends Parent public void applicationAdded(ApplicationDescriptor desc)
{
- applicationAdded(desc, true);
- }
-
- private Application applicationAdded(ApplicationDescriptor desc, boolean fireEvent)
- {
//
// This always fires insert events on the node view for the new server
// instances
//
Application child = new Application(desc, _model, true);
child.addParent(this);
- addChild(child, fireEvent);
- return child;
+ addChild(child, true);
}
-
+
public void applicationRemoved(String name)
{
- applicationRemoved(name, true);
- }
-
- private void applicationRemoved(String name, boolean fireEvent)
- {
Application application = (Application)findChild(name);
if(application != null)
{
application.removeFromNodes();
}
- removeChild(name, fireEvent);
- }
-
- public void applicationSynced(ApplicationDescriptor desc)
- {
- applicationRemoved(desc.name, false);
- Application child = applicationAdded(desc, false);
- child.fireStructureChangedEvent(this);
+ removeChild(name, true);
}
public void applicationUpdated(ApplicationUpdateDescriptor desc)
diff --git a/java/src/IceGrid/TreeNode/Node.java b/java/src/IceGrid/TreeNode/Node.java index 49f6de7cf4b..5509a613f36 100755 --- a/java/src/IceGrid/TreeNode/Node.java +++ b/java/src/IceGrid/TreeNode/Node.java @@ -104,7 +104,7 @@ class Node extends Parent if(info == null)
{
- info = _unknownServerDynamicInfo;
+ info = _inactiveServerDynamicInfo;
}
child.updateDynamicInfo(info);
}
@@ -176,7 +176,7 @@ class Node extends Parent Object obj = _serverInfoMap.get(serverName);
if(obj == null)
{
- return _unknownServerDynamicInfo;
+ return _inactiveServerDynamicInfo;
}
else
{
@@ -259,4 +259,7 @@ class Node extends Parent static private ServerDynamicInfo _unknownServerDynamicInfo =
new ServerDynamicInfo();
+
+ static private ServerDynamicInfo _inactiveServerDynamicInfo =
+ new ServerDynamicInfo(null, ServerState.Inactive, 0);
}
diff --git a/java/src/IceGrid/TreeNode/NodeViewRoot.java b/java/src/IceGrid/TreeNode/NodeViewRoot.java index fe2497b3dfc..4566c672207 100755 --- a/java/src/IceGrid/TreeNode/NodeViewRoot.java +++ b/java/src/IceGrid/TreeNode/NodeViewRoot.java @@ -126,23 +126,19 @@ public class NodeViewRoot extends Parent String nodeName = updatedInfo.name;
java.util.Map serverMap = new java.util.HashMap();
- System.err.println("nodeUp gives info on:");
for(int i = 0; i < updatedInfo.servers.length; ++i)
{
- System.err.println(updatedInfo.servers[i].name);
- if(updatedInfo.servers[i].state != ServerState.Destroyed)
- {
- serverMap.put(updatedInfo.servers[i].name, updatedInfo.servers[i]);
- }
+ assert(updatedInfo.servers[i].state != ServerState.Destroyed);
+ assert(updatedInfo.servers[i].state != ServerState.Inactive);
+
+ serverMap.put(updatedInfo.servers[i].name, updatedInfo.servers[i]);
}
java.util.Map adapterMap = new java.util.HashMap();
for(int i = 0; i < updatedInfo.adapters.length; ++i)
{
- if(updatedInfo.adapters[i].proxy != null)
- {
- adapterMap.put(updatedInfo.adapters[i].id, updatedInfo.adapters[i].proxy);
- }
+ assert(updatedInfo.adapters[i].proxy != null);
+ adapterMap.put(updatedInfo.adapters[i].id, updatedInfo.adapters[i].proxy);
}
_nodeServerInfoMap.put(nodeName, serverMap);
@@ -172,7 +168,8 @@ public class NodeViewRoot extends Parent java.util.Map serverMap = (java.util.Map)_nodeServerInfoMap.get(nodeName);
if(serverMap != null)
{
- if(updatedInfo.state == ServerState.Destroyed)
+ if(updatedInfo.state == ServerState.Destroyed ||
+ updatedInfo.state == ServerState.Inactive)
{
serverMap.remove(updatedInfo.name);
}
diff --git a/java/src/IceGrid/TreeNode/ServerInstance.java b/java/src/IceGrid/TreeNode/ServerInstance.java index 958aab0b188..f115b5cd02b 100755 --- a/java/src/IceGrid/TreeNode/ServerInstance.java +++ b/java/src/IceGrid/TreeNode/ServerInstance.java @@ -9,10 +9,14 @@ package IceGrid.TreeNode;
import java.awt.Component;
+import java.awt.event.ActionEvent;
import javax.swing.JPopupMenu;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.Icon;
+import javax.swing.JMenuItem;
+import javax.swing.Action;
+import javax.swing.AbstractAction;
import javax.swing.tree.DefaultTreeCellRenderer;
import IceGrid.TreeModelI;
@@ -26,9 +30,55 @@ import IceGrid.ServerDynamicInfo; class ServerInstance extends Parent
{
+ static class PopupMenu extends JPopupMenu
+ {
+ PopupMenu()
+ {
+ _startAction = new AbstractAction("Start")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _server.start();
+ }
+ };
+
+ _stopAction = new AbstractAction("Stop")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _server.stop();
+ }
+ };
+
+ add(_startAction);
+ add(_stopAction);
+ }
+
+ void setServer(ServerInstance server)
+ {
+ _server = server;
+ ServerState state = _server.getState();
+
+ boolean canStart = (_server.getState() == ServerState.Inactive);
+ _startAction.setEnabled(canStart);
+ _stopAction.setEnabled(!canStart);
+ }
+
+ private ServerInstance _server;
+ private Action _startAction;
+ private Action _stopAction;
+
+ }
+
+
public JPopupMenu getPopupMenu()
{
- return null;
+ if(_popup == null)
+ {
+ _popup = new PopupMenu();
+ }
+ _popup.setServer(this);
+ return _popup;
}
public JPanel getProperties(int view)
@@ -208,6 +258,68 @@ class ServerInstance extends Parent }
}
+ void start()
+ {
+ //
+ // TODO: if this can take a long time, make the invocation in a separate thread
+ //
+
+ boolean started = false;
+ try
+ {
+ _model.getStatusBar().setText("Starting server '" + _id + "'...");
+ started = _model.getAdmin().startServer(_id);
+ }
+ catch(IceGrid.ServerNotExistException e)
+ {
+ _model.getStatusBar().setText("Server '" + _id + "' no longer exists.");
+ }
+ catch(IceGrid.NodeUnreachableException e)
+ {
+ _model.getStatusBar().setText("Could not reach the node for server '" + _id + "'.");
+ }
+ catch(Ice.LocalException e)
+ {
+ _model.getStatusBar().setText("Starting server '" + _id + "'... failed: " + e.toString());
+ }
+ if(started)
+ {
+ _model.getStatusBar().setText("Starting server '" + _id + "'... success!");
+ }
+ else
+ {
+ _model.getStatusBar().setText("Starting server '" + _id + "'... failed!");
+ }
+ }
+
+ void stop()
+ {
+ try
+ {
+ _model.getStatusBar().setText("Stopping server '" + _id + "'...");
+ _model.getAdmin().stopServer(_id);
+ }
+ catch(IceGrid.ServerNotExistException e)
+ {
+ _model.getStatusBar().setText("Server '" + _id + "' no longer exists.");
+ }
+ catch(IceGrid.NodeUnreachableException e)
+ {
+ _model.getStatusBar().setText("Could not reach the node for server '" + _id + "'.");
+ }
+ catch(Ice.LocalException e)
+ {
+ _model.getStatusBar().setText("Stopping server '" + _id + "'... failed: " + e.toString());
+ }
+ _model.getStatusBar().setText("Stopping server '" + _id + "'... done.");
+ }
+
+ ServerState getState()
+ {
+ return _state;
+ }
+
+
public String toString()
{
String result = _descriptor.descriptor.name;
@@ -250,5 +362,6 @@ class ServerInstance extends Parent static private DefaultTreeCellRenderer _cellRenderer;
static private Icon[] _icons;
+ static private PopupMenu _popup;
}
|