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 /java/src/IceGrid/Model.java | |
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
Diffstat (limited to 'java/src/IceGrid/Model.java')
-rwxr-xr-x | java/src/IceGrid/Model.java | 159 |
1 files changed, 150 insertions, 9 deletions
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;
|