diff options
author | Bernard Normier <bernard@zeroc.com> | 2005-08-02 15:39:34 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2005-08-02 15:39:34 +0000 |
commit | ca26b6792a02d7ffeffd172a0744566b78cf4602 (patch) | |
tree | 3a72423e563996d3788ee77d0f3bc055795d2e16 /java/src | |
parent | LocalExceptions -> LocalException (diff) | |
download | ice-ca26b6792a02d7ffeffd172a0744566b78cf4602.tar.bz2 ice-ca26b6792a02d7ffeffd172a0744566b78cf4602.tar.xz ice-ca26b6792a02d7ffeffd172a0744566b78cf4602.zip |
Fixed build failure
Diffstat (limited to 'java/src')
21 files changed, 535 insertions, 1251 deletions
diff --git a/java/src/IceGrid/MainPane.java b/java/src/IceGrid/MainPane.java index 38ff6c1c8f7..1953b5bb55d 100755 --- a/java/src/IceGrid/MainPane.java +++ b/java/src/IceGrid/MainPane.java @@ -80,11 +80,6 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector static class SelectionListener implements TreeSelectionListener { - SelectionListener(int view) - { - _view = view; - } - public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); @@ -94,49 +89,8 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector node.displayProperties(); } } - - private int _view; - } - class TabListener implements ChangeListener - { - public void stateChanged(ChangeEvent e) - { - JTabbedPane tabbedPane = (JTabbedPane)e.getSource(); - int selectedPane = tabbedPane.getSelectedIndex(); - if(selectedPane >= 0) - { - if(_treeList.size() > selectedPane) - { - JTree tree = (JTree)_treeList.get(selectedPane); - TreePath path = tree.getSelectionPath(); - if(path != null) - { - CommonBase node = (CommonBase)path.getLastPathComponent(); - node.displayProperties(); - return; - } - } - } - if(_rightPane != null) - { - _rightPane.setTitle("Properties"); - _rightPane.setContent(_emptyPanel); - _rightPane.validate(); - _rightPane.repaint(); - } - } - - void add(JTree tree) - { - _treeList.add(tree); - } - - private java.util.List _treeList = new java.util.Vector(); - } - - public void updateUI() { super.updateUI(); @@ -161,66 +115,28 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector _model.setTreeNodeSelector(this); setBorder(new EmptyBorder(10, 10, 10, 10)); - - // - // Left pane - // - _tabbedPane = new JTabbedPane(); - _tabbedPane.setPreferredSize(new Dimension(280, 350)); - - _tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE); - _tabbedPane.setBorder(new ShadowBorder()); - TabListener tabListener = new TabListener(); - _tabbedPane.addChangeListener(tabListener); TreeCellRenderer renderer = new CellRenderer(); PopupListener popupListener = new PopupListener(); + _tree = new JTree(_model.getTreeModel()); + _tree.setCellRenderer(renderer); + ToolTipManager.sharedInstance().registerComponent(_tree); + _tree.addMouseListener(popupListener); - JTree nodeTree = new JTree(_model.getTreeModel(TreeModelI.NODE_VIEW)); - nodeTree.setCellRenderer(renderer); - ToolTipManager.sharedInstance().registerComponent(nodeTree); - nodeTree.addMouseListener(popupListener); - - nodeTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - SelectionListener treeSelectionListener = new SelectionListener(TreeModelI.NODE_VIEW); - nodeTree.addTreeSelectionListener(treeSelectionListener); - nodeTree.setRootVisible(true); - _treeArray[0] = nodeTree; - - - JScrollPane nodeScroll = - new JScrollPane(nodeTree, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - nodeScroll.setBorder(Borders.DIALOG_BORDER); - - - _tabbedPane.addTab("Node View", nodeScroll); - tabListener.add(nodeTree); - - JTree appTree = new JTree(_model.getTreeModel(TreeModelI.APPLICATION_VIEW)); - appTree.setCellRenderer(renderer); - ToolTipManager.sharedInstance().registerComponent(appTree); - appTree.addMouseListener(popupListener); - - appTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - SelectionListener appSelectionListener = new SelectionListener(TreeModelI.APPLICATION_VIEW); - appTree.addTreeSelectionListener(appSelectionListener); - appTree.setRootVisible(true); - _treeArray[1] = appTree; + _tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + SelectionListener appSelectionListener = new SelectionListener(); + _tree.addTreeSelectionListener(appSelectionListener); + _tree.setRootVisible(true); JScrollPane appScroll = - new JScrollPane(appTree, + new JScrollPane(_tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); appScroll.setBorder(Borders.DIALOG_BORDER); - _tabbedPane.addTab("Application View", appScroll); - tabListener.add(appTree); - JPanel leftPane = new JPanel(new BorderLayout()); - leftPane.add(_tabbedPane); + leftPane.add(_tree); // // Right pane @@ -235,16 +151,11 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector setRightComponent(_rightPane); } - public void selectNode(TreePath path, int view) + public void selectNode(TreePath path) { - if(_tabbedPane.getSelectedIndex() != view) - { - _tabbedPane.setSelectedIndex(view); - } - _treeArray[view].setSelectionPath(path); + _tree.setSelectionPath(path); } - // // Adapted from JGoodies SimpleInternalFrame // @@ -298,8 +209,7 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector private Model _model; - private JTabbedPane _tabbedPane; - private JTree[] _treeArray = new JTree[TreeModelI.VIEW_COUNT]; + private JTree _tree; private SimpleInternalFrame _rightPane; static private JPanel _emptyPanel; diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java index 95b24ddb67c..bbecb12971a 100755 --- a/java/src/IceGrid/Model.java +++ b/java/src/IceGrid/Model.java @@ -17,9 +17,7 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities;
import javax.swing.tree.TreePath;
-import IceGrid.TreeNode.NodeViewRoot;
-import IceGrid.TreeNode.ApplicationViewRoot;
-
+import IceGrid.TreeNode.Root;
import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
//
@@ -29,7 +27,6 @@ import com.jgoodies.uif_lite.panel.SimpleInternalFrame; public class Model
{
//
- // Application view:
//
// root
// |
@@ -66,43 +63,30 @@ public class Model // | -- $database
// |
// |
- // -- server instances
- // | |
- // | -- $server instance
- // | |
- // | (like node view below)
- // |
- // -- node variables
+ // -- nodes
+ // |
+ // -- $node
// |
- // -- $nodevar (leaf, shows per-application variables)
- //
- //
- // Node view:
- //
- // root
- // |
- // -- $node
- // |
- // -- $instance
- // |
- // -- adapters
- // | |
- // | -- $adapter
- // |
- // -- databases
- // | |
- // | -- $database
- // |
- // -- services (only for IceBox servers)
- // |
- // -- $service
- // |
- // -- adapters, databases (see above)
+ // -- $instance
+ // |
+ // -- adapters
+ // | |
+ // | -- $adapter
+ // |
+ // -- databases
+ // | |
+ // | -- $database
+ // |
+ // -- services (only for IceBox servers)
+ // |
+ // -- $service
+ // |
+ // -- adapters, databases (see above)
public static interface TreeNodeSelector
{
- void selectNode(TreePath path, int view);
+ void selectNode(TreePath path);
}
public static class ConnectInfo
@@ -166,30 +150,15 @@ public class Model return _communicator;
}
- public NodeViewRoot getNodeViewRoot()
- {
- return _nodeViewRoot;
- }
-
- public ApplicationViewRoot getApplicationViewRoot()
+
+ public Root getRoot()
{
- return _applicationViewRoot;
+ return _root;
}
- public TreeModelI getTreeModel(int view)
+ public TreeModelI getTreeModel()
{
- if(view == TreeModelI.NODE_VIEW)
- {
- return _nodeModel;
- }
- else if(view == TreeModelI.APPLICATION_VIEW)
- {
- return _applicationModel;
- }
- else
- {
- return null;
- }
+ return _treeModel;
}
@@ -202,32 +171,22 @@ public class Model assert(_latestSerial == -1);
_latestSerial = serial;
- _nodeViewRoot.init(applications);
- _applicationViewRoot.init(applications);
+ _root.init(applications);
}
void applicationAdded(ApplicationDescriptor desc)
{
- _nodeViewRoot.put(desc.name, desc.nodes, true);
- _applicationViewRoot.applicationAdded(desc);
+ _root.applicationAdded(desc);
}
void applicationRemoved(String name)
{
- _nodeViewRoot.remove(name);
- _applicationViewRoot.applicationRemoved(name);
+ _root.applicationRemoved(name);
}
void applicationUpdated(ApplicationUpdateDescriptor desc)
{
- for(int i = 0; i < desc.removeNodes.length; ++i)
- {
- _nodeViewRoot.remove(desc.name, desc.removeNodes[i]);
- }
- _nodeViewRoot.put(desc.name, desc.nodes, true);
- _nodeViewRoot.removeServers(desc.removeServers);
-
- _applicationViewRoot.applicationUpdated(desc);
+ _root.applicationUpdated(desc);
}
boolean updateSerial(int serial)
@@ -250,22 +209,22 @@ public class Model void nodeUp(NodeDynamicInfo updatedInfo)
{
- _nodeViewRoot.nodeUp(updatedInfo);
+ _root.nodeUp(updatedInfo);
}
void nodeDown(String node)
{
- _nodeViewRoot.nodeDown(node);
+ _root.nodeDown(node);
}
void updateServer(String node, ServerDynamicInfo updatedInfo)
{
- _nodeViewRoot.updateServer(node, updatedInfo);
+ _root.updateServer(node, updatedInfo);
}
void updateAdapter(String node, AdapterDynamicInfo updatedInfo)
{
- _nodeViewRoot.updateAdapter(node, updatedInfo);
+ _root.updateAdapter(node, updatedInfo);
}
@@ -276,8 +235,7 @@ public class Model void sessionLost()
{
_latestSerial = -1;
- _nodeViewRoot.clear();
- _applicationViewRoot.clear();
+ _root.clear();
_sessionManager = null;
_admin = null;
}
@@ -415,25 +373,18 @@ public class Model _communicator = communicator;
_statusBar = statusBar;
- _nodeViewRoot = new NodeViewRoot(this);
- _nodeModel = new TreeModelI(_nodeViewRoot);
-
- _applicationViewRoot = new ApplicationViewRoot(this);
- _applicationModel = new TreeModelI(_applicationViewRoot);
+ _root = new Root(this);
+ _treeModel = new TreeModelI(_root);
}
-
private Ice.Communicator _communicator;
private StatusBar _statusBar;
private SessionManagerPrx _sessionManager;
private AdminPrx _admin;
-
- private NodeViewRoot _nodeViewRoot;
- private ApplicationViewRoot _applicationViewRoot;
- private TreeModelI _nodeModel;
- private TreeModelI _applicationModel;
+ private Root _root;
+ private TreeModelI _treeModel;
private int _latestSerial = -1;
diff --git a/java/src/IceGrid/TreeModelI.java b/java/src/IceGrid/TreeModelI.java index dfc764ce638..52154923ed3 100755 --- a/java/src/IceGrid/TreeModelI.java +++ b/java/src/IceGrid/TreeModelI.java @@ -16,9 +16,6 @@ import javax.swing.event.EventListenerList; import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeModelEvent;
-import IceGrid.TreeNode.NodeViewRoot;
-import IceGrid.TreeNode.ApplicationViewRoot;
-
public class TreeModelI implements TreeModel
{
public Object getRoot()
diff --git a/java/src/IceGrid/TreeNode/Adapter.java b/java/src/IceGrid/TreeNode/Adapter.java index b923e5cb2a5..93517163092 100755 --- a/java/src/IceGrid/TreeNode/Adapter.java +++ b/java/src/IceGrid/TreeNode/Adapter.java @@ -65,7 +65,7 @@ class Adapter extends Leaf builder.append("", _registerProcess);
builder.nextLine();
- builder.append("", _noWaitForActivation);
+ builder.append("", _waitForActivation);
builder.nextLine();
_scrollPane = new JScrollPane(builder.getPanel(),
@@ -95,10 +95,6 @@ class Adapter extends Leaf Utils.substituteVariables(descriptor.id, variables));
_id.setEditable(editable);
- _endpoints.setText(
- Utils.substituteVariables(descriptor.endpoints, variables));
- _endpoints.setEditable(editable);
-
Ice.StringHolder toolTipHolder = new Ice.StringHolder();
Utils.Stringifier stringifier = new Utils.Stringifier()
@@ -127,8 +123,8 @@ class Adapter extends Leaf _registerProcess.setSelected(descriptor.registerProcess);
_registerProcess.setEnabled(editable);
- _noWaitForActivation.setSelected(descriptor.noWaitForActivation);
- _noWaitForActivation.setEnabled(editable);
+ _waitForActivation.setSelected(descriptor.waitForActivation);
+ _waitForActivation.setEnabled(editable);
}
@@ -136,7 +132,7 @@ class Adapter extends Leaf private JTextField _id = new JTextField(20);
private JTextField _endpoints = new JTextField(20);
private JCheckBox _registerProcess = new JCheckBox("Register Process");
- private JCheckBox _noWaitForActivation = new JCheckBox("Don't wait for me");
+ private JCheckBox _waitForActivation = new JCheckBox("Wait for me");
private JTextField _objects = new JTextField(20);
private JButton _objectsButton = new JButton("...");
@@ -154,24 +150,17 @@ class Adapter extends Leaf int row,
boolean hasFocus)
{
- if(_node == null)
- {
- return null;
- }
- else
+ if(_cellRenderer == null)
{
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
- }
-
- _cellRenderer.setToolTipText(_toolTip);
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
}
+
+ _cellRenderer.setToolTipText(_toolTip);
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
}
public void displayProperties()
@@ -193,38 +182,21 @@ class Adapter extends Leaf Adapter(String adapterName, AdapterDescriptor descriptor,
boolean editable, java.util.Map[] variables,
- Model model, Node node)
+ Model model)
{
super(adapterName, model);
_descriptor = descriptor;
_editable = editable;
_variables = variables;
- _node = node;
-
- if(_node != null)
- {
- _adapterId = Utils.substituteVariables(_descriptor.id, _variables);
- _proxy = node.registerAdapter(_adapterId, this);
- createToolTip();
- }
- //
- // Otherwise we have an adapter in a template
- // (possibly in a service instance within a server template)
- //
}
void unregister()
{
- if(_node != null)
- {
- _node.unregisterAdapter(_adapterId);
- _node = null;
- }
+
}
void updateProxy(Ice.ObjectPrx proxy)
{
- assert(_node != null);
_proxy = proxy;
createToolTip();
fireNodeChangedEvent(this);
@@ -262,7 +234,6 @@ class Adapter extends Leaf private java.util.Map[] _variables;
private String _adapterId;
- private Node _node;
private Ice.ObjectPrx _proxy;
private String _toolTip;
diff --git a/java/src/IceGrid/TreeNode/Adapters.java b/java/src/IceGrid/TreeNode/Adapters.java index a408e0d818a..be467bc29a7 100755 --- a/java/src/IceGrid/TreeNode/Adapters.java +++ b/java/src/IceGrid/TreeNode/Adapters.java @@ -19,7 +19,7 @@ class Adapters extends Parent //
Adapters(java.util.List descriptors, Model model)
{
- this(descriptors, true, null, model, null);
+ this(descriptors, true, null, model);
}
//
@@ -27,7 +27,7 @@ class Adapters extends Parent //
Adapters(java.util.List descriptors, boolean editable,
java.util.Map[] variables,
- Model model, Node node)
+ Model model)
{
super("Adapters", model);
_descriptors = descriptors;
@@ -48,7 +48,7 @@ class Adapters extends Parent Adapter child = new Adapter(adapterName, descriptor,
_editable, _variables,
- _model, node);
+ _model);
addChild(child);
}
}
diff --git a/java/src/IceGrid/TreeNode/Application.java b/java/src/IceGrid/TreeNode/Application.java index c7d7111260f..acb7ac2b562 100755 --- a/java/src/IceGrid/TreeNode/Application.java +++ b/java/src/IceGrid/TreeNode/Application.java @@ -12,7 +12,8 @@ import IceGrid.ApplicationDescriptor; import IceGrid.ApplicationUpdateDescriptor;
import IceGrid.TemplateDescriptor;
import IceGrid.Model;
-
+import IceGrid.ServerDynamicInfo;
+import IceGrid.AdapterDynamicInfo;
class Application extends Parent
{
@@ -23,39 +24,35 @@ class Application extends Parent boolean fireEvent)
{
super(descriptor.name, model);
-
_descriptor = descriptor;
- _nodeVars = new NodeVars(_descriptor.nodes, _model);
- addChild(_nodeVars);
-
//
- // _serviceTemplates must be created before _serverTemplates
- // and _serverInstances, since they may refer to them
+ // TODO: add replicated adapter
//
- _serviceTemplates = new ServiceTemplates(_descriptor.serviceTemplates, _model);
-
+
+ _serviceTemplates = new ServiceTemplates(_descriptor.serviceTemplates,
+ _model);
addChild(_serviceTemplates);
- _serverTemplates = new ServerTemplates(descriptor.serverTemplates, this);
+ _serverTemplates = new ServerTemplates(descriptor.serverTemplates,
+ this);
addChild(_serverTemplates);
- //
- // _serverInstances must be processed last, after the templates
- // and the node variables have been created.
- //
- _serverInstances = new ServerInstances(_descriptor.servers, this, fireEvent);
- addChild(_serverInstances);
- }
-
- void removeFromNodes()
- {
- _serverInstances.removeFromNodes();
+ _nodes = new Nodes(_descriptor.nodes, _model);
+ addChild(_nodes);
}
void update(ApplicationUpdateDescriptor desc)
{
//
+ // Description
+ //
+ if(desc.description != null)
+ {
+ _descriptor.description = desc.description.value;
+ }
+
+ //
// Variables
//
for(int i = 0; i < desc.removeVariables.length; ++i)
@@ -64,19 +61,18 @@ class Application extends Parent }
_descriptor.variables.putAll(desc.variables);
+
//
- // Targets and comment
+ // Service templates
//
-
- if(desc.targets != null)
- {
- _descriptor.targets = desc.targets.value;
- }
-
- if(desc.comment != null)
+ for(int i = 0; i < desc.removeServiceTemplates.length; ++i)
{
- _descriptor.comment = desc.comment.value;
+ _descriptor.serviceTemplates.remove(desc.
+ removeServiceTemplates[i]);
}
+ _descriptor.serviceTemplates.putAll(desc.serviceTemplates);
+ _serviceTemplates.update(desc.serviceTemplates,
+ desc.removeServiceTemplates);
//
// Server templates
@@ -86,37 +82,18 @@ class Application extends Parent _descriptor.serverTemplates.remove(desc.removeServerTemplates[i]);
}
_descriptor.serverTemplates.putAll(desc.serverTemplates);
- _serverTemplates.update(desc.serverTemplates, desc.removeServerTemplates);
+ _serverTemplates.update(desc.serverTemplates,
+ desc.removeServerTemplates);
//
- // Service templates
- //
- for(int i = 0; i < desc.removeServiceTemplates.length; ++i)
- {
- _descriptor.serviceTemplates.remove(desc.removeServiceTemplates[i]);
- }
- _descriptor.serviceTemplates.putAll(desc.serviceTemplates);
- _serviceTemplates.update(desc.serviceTemplates, desc.removeServiceTemplates);
-
- //
// Nodes
//
for(int i = 0; i < desc.removeNodes.length; ++i)
{
_descriptor.nodes.remove(desc.removeNodes[i]);
}
- _descriptor.nodes.addAll(desc.nodes);
- _nodeVars.update(desc.nodes, desc.removeNodes);
-
- //
- // Servers
- //
- for(int i = 0; i < desc.removeServers.length; ++i)
- {
- _descriptor.servers.remove(desc.removeServers[i]);
- }
- _descriptor.servers.addAll(desc.servers);
- _serverInstances.update(desc.servers, desc.removeServers);
+ _descriptor.nodes.putAll(_nodes.update(desc.nodes,
+ desc.removeNodes));
}
ServerTemplate findServerTemplate(String id)
@@ -137,9 +114,9 @@ class Application extends Parent }
- NodeVar findNodeVar(String id)
+ Node findNode(String id)
{
- return (NodeVar)_nodeVars.findChild(id);
+ return (Node)_nodes.findChild(id);
}
ServerTemplates getServerTemplates()
@@ -157,10 +134,10 @@ class Application extends Parent java.util.Map getNodeVariables(String id)
{
- NodeVar nodeVar = findNodeVar(id);
- if(nodeVar != null)
+ Node node = findNode(id);
+ if(node != null)
{
- return nodeVar.getVariables();
+ return node.getVariables();
}
else
{
@@ -168,6 +145,28 @@ class Application extends Parent }
}
+ void nodeUp(String nodeName, java.util.Map serverMap,
+ java.util.Map adapterMap)
+ {
+ _nodes.nodeUp(nodeName, serverMap, adapterMap);
+ }
+
+ void nodeDown(String nodeName)
+ {
+ _nodes.nodeDown(nodeName);
+ }
+
+ void updateServer(String nodeName, ServerDynamicInfo updatedInfo)
+ {
+ _nodes.updateServer(nodeName, updatedInfo);
+ }
+
+ void updateAdapter(String nodeName, AdapterDynamicInfo updatedInfo)
+ {
+ _nodes.updateAdapter(nodeName, updatedInfo);
+ }
+
+
private ApplicationDescriptor _descriptor;
//
@@ -175,7 +174,5 @@ class Application extends Parent //
private ServerTemplates _serverTemplates;
private ServiceTemplates _serviceTemplates;
- private NodeVars _nodeVars;
- private ServerInstances _serverInstances;
-
+ private Nodes _nodes;
}
diff --git a/java/src/IceGrid/TreeNode/ApplicationViewRoot.java b/java/src/IceGrid/TreeNode/ApplicationViewRoot.java deleted file mode 100755 index 180dd2b21be..00000000000 --- a/java/src/IceGrid/TreeNode/ApplicationViewRoot.java +++ /dev/null @@ -1,79 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGrid.TreeNode;
-
-import IceGrid.ApplicationDescriptor;
-import IceGrid.ApplicationUpdateDescriptor;
-import IceGrid.TreeModelI;
-import IceGrid.Model;
-
-public class ApplicationViewRoot extends Parent
-{
- public ApplicationViewRoot(Model model)
- {
- super("Applications", model, TreeModelI.APPLICATION_VIEW);
- }
-
- //
- // The node view root must be (re-)initialized before the application view root
- //
- public void init(java.util.List descriptors)
- {
- assert(_children.size() == 0);
-
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- ApplicationDescriptor descriptor = (ApplicationDescriptor)p.next();
- Application child = new Application(descriptor, _model, false);
- addChild(child);
- child.addParent(this);
- }
-
- //
- // Fire structure change for both application and node views
- //
- fireStructureChangedEvent(this);
- _model.getNodeViewRoot().fireStructureChangedEvent(this);
- }
-
- public void clear()
- {
- clearChildren();
- fireStructureChangedEvent(this);
- }
-
- public void applicationAdded(ApplicationDescriptor desc)
- {
- //
- // 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, true);
- }
-
- public void applicationRemoved(String name)
- {
- Application application = (Application)findChild(name);
- if(application != null)
- {
- application.removeFromNodes();
- }
-
- removeChild(name, true);
- }
-
- public void applicationUpdated(ApplicationUpdateDescriptor desc)
- {
- Application application = (Application)findChild(desc.name);
- application.update(desc);
- }
-}
diff --git a/java/src/IceGrid/TreeNode/CommonBase.java b/java/src/IceGrid/TreeNode/CommonBase.java index 07a2c23b49f..6af9f19194d 100755 --- a/java/src/IceGrid/TreeNode/CommonBase.java +++ b/java/src/IceGrid/TreeNode/CommonBase.java @@ -32,47 +32,25 @@ public interface CommonBase extends TreeCellRenderer String getId();
//
- // Add this node as a parent. This operation does something
- // only when newParent a root node or was attached to a
- // root node using addParent().
- // addParent() is propagated to the child of this node.
+ // Set this node as a parent, and recursively update
+ // the path of all children.
// This method has no effect on the parent->children relationship,
// only child->parent.
//
- void addParent(CommonBase newParent);
+ void setParent(CommonBase newParent);
//
- // Recursively destroys a sub-parent-tree: the children
- // forget this parent, but it does not affect the parents
- // knowledge about their children.
- //
- void removeParent(CommonBase parent);
-
-
- //
- // Adds this parent for this view. Used by the view-less addParent
- // to notify its children.
- //
- void addParent(CommonBase newParent, TreePath path, int view);
-
- //
- // Remove the parent for this view; used by the view-less
- // removeParent to notify its children.
- //
- void removeParent(int view);
-
- //
- // Get the parent for the given view
+ // Get this node's parent
// This is used by nodes to create events
// pointing to themselves
//
- CommonBase getParent(int view);
+ CommonBase getParent();
//
- // The path to this node for the given view;
+ // The path to this node
// typically used by children to create TreeModelEvents
//
- TreePath getPath(int view);
+ TreePath getPath();
//
// Get pop-up menu
diff --git a/java/src/IceGrid/TreeNode/CommonBaseI.java b/java/src/IceGrid/TreeNode/CommonBaseI.java index 3f2122e57f4..a069781581a 100755 --- a/java/src/IceGrid/TreeNode/CommonBaseI.java +++ b/java/src/IceGrid/TreeNode/CommonBaseI.java @@ -25,12 +25,6 @@ import IceGrid.Model; abstract class CommonBaseI implements CommonBase
{
- static class ViewData
- {
- public TreePath path;
- public CommonBase parent;
- }
-
public String toString()
{
return _id;
@@ -41,63 +35,35 @@ abstract class CommonBaseI implements CommonBase return _id;
}
- public void addParent(CommonBase parent)
+ public void setParent(CommonBase parent)
{
- //
- // Check if this parent has any view; there is no point in remembering
- // a parent that does not belong to a view: getParent etc is used
- // only to create event to fire using the view's TreeModel.
- //
- assert(parent != null);
-
- for(int i = 0; i < TreeModelI.VIEW_COUNT; i++)
- {
- TreePath parentPath = parent.getPath(i);
- if(parentPath != null)
+ _parent = parent;
+ if(_parent == null)
+ {
+ _path = null;
+ }
+ else
+ {
+ TreePath parentPath = _parent.getPath();
+ if(parentPath == null)
{
- addParent(parent, parentPath, i);
+ _path = null;
}
- }
- }
-
- public void addParent(CommonBase parent, TreePath parentPath, int view)
- {
- assert(parent != null);
- assert(parentPath != null);
- assert(_parents[view] == null);
- assert(_paths[view] == null);
-
- _parents[view] = parent;
- _paths[view] = parentPath.pathByAddingChild(this);
- }
-
- public void removeParent(CommonBase parent)
- {
- assert(parent != null);
-
- for(int i = 0; i < TreeModelI.VIEW_COUNT; i++)
- {
- if(_parents[i] == parent)
+ else
{
- removeParent(i);
+ _path = parentPath.pathByAddingChild(this);
}
}
}
- public void removeParent(int view)
+ public TreePath getPath()
{
- _paths[view] = null;
- _parents[view] = null;
- }
-
- public TreePath getPath(int view)
- {
- return _paths[view];
+ return _path;
}
- public CommonBase getParent(int view)
+ public CommonBase getParent()
{
- return _parents[view];
+ return _parent;
}
@@ -139,14 +105,14 @@ abstract class CommonBaseI implements CommonBase }
//
- // Fires a nodesChanged event with this node for this specific view
+ // Fires a nodesChanged event with this node
//
- void fireNodeChangedEvent(Object source, int view)
+ void fireNodeChangedEvent(Object source)
{
//
- // Bug if I am not in this view
+ // Bug if I am not attached to the root
//
- assert(_paths[view] != null);
+ assert _path != null;
int[] childIndices = new int[1];
Object[] children = new Object[1];
@@ -154,7 +120,7 @@ abstract class CommonBaseI implements CommonBase TreeModelEvent event;
- if(_parents[view] == null)
+ if(_parent == null)
{
//
// I am root
@@ -165,47 +131,18 @@ abstract class CommonBaseI implements CommonBase }
else
{
- childIndices[0] = _parents[view].getIndex(this);
- event = new TreeModelEvent(source, _parents[view].getPath(view), childIndices, children);
+ childIndices[0] = _parent.getIndex(this);
+ event = new TreeModelEvent(source, _parent.getPath(), childIndices, children);
}
- _model.getTreeModel(view).fireNodesChangedEvent(event);
- }
-
- //
- // Fires a nodesChanged event with this node for all my views (usually just one)
- //
- void fireNodeChangedEvent(Object source)
- {
- for(int i = 0; i < TreeModelI.VIEW_COUNT; ++i)
- {
- if(_paths[i] != null)
- {
- fireNodeChangedEvent(source, i);
- }
- }
- }
-
-
- void fireStructureChangedEvent(Object source, int view)
- {
- //
- // Bug if I am not in this view
- //
- assert(_paths[view] != null);
-
- TreeModelEvent event = new TreeModelEvent(source, _paths[view]);
- _model.getTreeModel(view).fireStructureChangedEvent(event);
+ _model.getTreeModel().fireNodesChangedEvent(event);
}
void fireStructureChangedEvent(Object source)
{
- for(int i = 0; i < TreeModelI.VIEW_COUNT; ++i)
- {
- if(_paths[i] != null)
- {
- fireStructureChangedEvent(source, i);
- }
- }
+ assert _path != null;
+
+ TreeModelEvent event = new TreeModelEvent(source, _path);
+ _model.getTreeModel().fireStructureChangedEvent(event);
}
static String templateLabel(String templateName, java.util.Collection col)
@@ -230,14 +167,14 @@ abstract class CommonBaseI implements CommonBase return result;
}
- protected CommonBaseI(String id, Model model, int rootForView)
+ protected CommonBaseI(String id, Model model, boolean root)
{
_id = id;
_model = model;
- if(rootForView >= 0)
+ if(root)
{
- _paths[rootForView] = new TreePath(this);
+ _path = new TreePath(this);
}
}
@@ -246,12 +183,9 @@ abstract class CommonBaseI implements CommonBase return _model;
}
-
- //
- // view to Path/Parent arrays
- //
- protected TreePath[] _paths = new TreePath[TreeModelI.VIEW_COUNT];
- protected CommonBase[] _parents = new CommonBase[TreeModelI.VIEW_COUNT];
+
+ protected TreePath _path;
+ protected CommonBase _parent;
//
// Id (application name, server instance name etc)
@@ -261,10 +195,10 @@ abstract class CommonBaseI implements CommonBase //
// The Model
//
- protected IceGrid.Model _model;
+ protected Model _model;
//
// The default panel
//
- protected JPanel _panel;
+ static protected JPanel _panel;
}
diff --git a/java/src/IceGrid/TreeNode/Leaf.java b/java/src/IceGrid/TreeNode/Leaf.java index 7c2645b1c04..d5396e0b9d9 100755 --- a/java/src/IceGrid/TreeNode/Leaf.java +++ b/java/src/IceGrid/TreeNode/Leaf.java @@ -38,6 +38,6 @@ class Leaf extends CommonBaseI protected Leaf(String id, Model model)
{
- super(id, model, -1);
+ super(id, model, false);
}
}
diff --git a/java/src/IceGrid/TreeNode/Node.java b/java/src/IceGrid/TreeNode/Node.java index 5509a613f36..0eac410dc48 100755 --- a/java/src/IceGrid/TreeNode/Node.java +++ b/java/src/IceGrid/TreeNode/Node.java @@ -112,6 +112,7 @@ class Node extends Parent //
// Update the state of all adapters
//
+ /*
p = _adapters.entrySet().iterator();
while(p.hasNext())
{
@@ -121,7 +122,8 @@ class Node extends Parent Ice.ObjectPrx proxy = (Ice.ObjectPrx)_adapterInfoMap.get(id);
adapter.updateProxy(proxy);
}
-
+ */
+
fireNodeChangedEvent(this);
}
@@ -143,28 +145,18 @@ class Node extends Parent //
// Update the state of all adapters
//
+ /*
p = _adapters.values().iterator();
while(p.hasNext())
{
Adapter adapter = (Adapter)p.next();
adapter.updateProxy(null);
}
+ */
fireNodeChangedEvent(this);
}
-
- void updateServer(ServerDynamicInfo info)
- {
- //
- // NodeViewRoot updates the map
- //
- ServerInstance child = (ServerInstance)findChild(info.name);
- if(child != null)
- {
- child.updateDynamicInfo(info);
- }
- }
-
+
ServerDynamicInfo getServerDynamicInfo(String serverName)
{
if(_serverInfoMap == null)
@@ -184,73 +176,148 @@ class Node extends Parent }
}
}
+
+ /*
+ ServerInstances(java.util.List descriptors,
+ Application application,
+ boolean fireEvent)
+ {
+ super("Server instances", application.getModel());
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ //
+ // The ServerInstance constructor inserts the new object in the
+ // node view model
+ //
+ ServerInstanceDescriptor descriptor =
+ (ServerInstanceDescriptor)p.next();
+
+
- void updateAdapter(AdapterDynamicInfo info)
+ String serverName = computeServerName(descriptor, application);
+
+ ServerInstance child = new ServerInstance(serverName,
+ descriptor,
+ application,
+ fireEvent);
+ addChild(child);
+ }
+ }
+
+ void update(java.util.List updates, String[] removeServers)
{
//
- // NodeViewRoot updates the map
+ // Note: _descriptors is updated by Application
//
- Adapter adapter = (Adapter)_adapters.get(info.id);
- if(adapter != null)
+
+ Application application = (Application)getParent(TreeModelI.APPLICATION_VIEW);
+
+ //
+ // One big set of removes
+ //
+ for(int i = 0; i < removeServers.length; ++i)
{
- adapter.updateProxy(info.proxy);
+ ServerInstance server = (ServerInstance)findChild(removeServers[i]);
+ server.removeFromNode();
}
- }
-
- Node(String applicationName, Model model, NodeDescriptor descriptor,
- java.util.Map serverInfoMap, java.util.Map adapterInfoMap)
- {
- super(descriptor.name, model);
- _serverInfoMap = serverInfoMap;
- _adapterInfoMap = adapterInfoMap;
- _applicationMap.put(applicationName, descriptor);
- }
+ removeChildren(removeServers);
- void addApplication(String applicationName, NodeDescriptor descriptor)
- {
- _applicationMap.put(applicationName, descriptor);
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+ java.util.Vector updatedChildren = new java.util.Vector();
+
+ java.util.Iterator p = updates.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor descriptor = (ServerInstanceDescriptor)p.next();
+
+ String serverName = computeServerName(descriptor, application);
+
+ ServerInstance child = (ServerInstance)findChild(serverName);
+ if(child == null)
+ {
+ newChildren.add(new ServerInstance(serverName, descriptor, application, true));
+ }
+ else
+ {
+ child.rebuild(application, descriptor, true);
+ updatedChildren.add(child);
+ }
+ }
+
+ updateChildren((CommonBaseI[])updatedChildren.toArray(new CommonBaseI[0]));
+ addChildren((CommonBaseI[])newChildren.toArray(new CommonBaseI[0]));
}
-
- //
- // Returns true when this node should be destroyed
- //
- boolean removeApplication(String applicationName)
+
+ void removeFromNodes()
{
- _applicationMap.remove(applicationName);
- return (_applicationMap.size() == 0);
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerInstance server = (ServerInstance)p.next();
+ server.removeFromNode();
+ }
}
- //
- // The node maintains a map adapter id => Adapter
- //
- Ice.ObjectPrx registerAdapter(String id, Adapter adapter)
+ static String computeServerName(ServerInstanceDescriptor instanceDescriptor,
+ Application application)
{
- _adapters.put(id, adapter);
- Ice.ObjectPrx result = null;
- if(_adapterInfoMap != null)
+ String nodeName = instanceDescriptor.node;
+
+ if(instanceDescriptor.template.length() > 0)
{
- result = (Ice.ObjectPrx)_adapterInfoMap.get(id);
+ //
+ // Can't be null
+ //
+ TemplateDescriptor templateDescriptor =
+ application.findServerTemplateDescriptor(instanceDescriptor.template);
+
+ java.util.Map parameters =
+ Utils.substituteVariables(instanceDescriptor.parameterValues,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
+
+ return Utils.substituteVariables(templateDescriptor.descriptor.name,
+ parameters,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
+ }
+ else
+ {
+
+ return Utils.substituteVariables(instanceDescriptor.descriptor.name,
+ application.getNodeVariables(nodeName),
+ application.getVariables());
}
- return result;
}
- void unregisterAdapter(String id)
+ */
+
+
+ java.util.Map getVariables()
{
- _adapters.remove(id);
+ return null;
}
- private java.util.Map _applicationMap = new java.util.HashMap();
+
+ Node(String applicationName, Model model,
+ String nodeName, NodeDescriptor descriptor,
+ java.util.Map serverInfoMap, java.util.Map adapterInfoMap)
+ {
+ super(nodeName, model);
+ _serverInfoMap = serverInfoMap;
+ _adapterInfoMap = adapterInfoMap;
+ }
private java.util.Map _serverInfoMap;
private java.util.Map _adapterInfoMap;
- //
- // Adapter id => Adapter
- //
- private java.util.Map _adapters = new java.util.HashMap();
-
-
static private DefaultTreeCellRenderer _cellRenderer;
static private Icon _nodeUpOpen;
static private Icon _nodeUpClosed;
diff --git a/java/src/IceGrid/TreeNode/NodeVar.java b/java/src/IceGrid/TreeNode/NodeVar.java deleted file mode 100755 index ddd93ae8a44..00000000000 --- a/java/src/IceGrid/TreeNode/NodeVar.java +++ /dev/null @@ -1,34 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGrid.TreeNode;
-
-import IceGrid.NodeDescriptor;
-import IceGrid.Model;
-
-class NodeVar extends Leaf
-{
- NodeVar(NodeDescriptor descriptor, Model model)
- {
- super(descriptor.name, model);
- rebuild(descriptor);
- }
-
- void rebuild(NodeDescriptor descriptor)
- {
- _descriptor = descriptor;
- }
-
- java.util.Map getVariables()
- {
- return _descriptor.variables;
- }
-
- private NodeDescriptor _descriptor;
-
-}
diff --git a/java/src/IceGrid/TreeNode/NodeVars.java b/java/src/IceGrid/TreeNode/NodeVars.java deleted file mode 100755 index 157348bf718..00000000000 --- a/java/src/IceGrid/TreeNode/NodeVars.java +++ /dev/null @@ -1,63 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGrid.TreeNode;
-
-import IceGrid.NodeDescriptor;
-import IceGrid.Model;
-
-class NodeVars extends Parent
-{
- NodeVars(java.util.List descriptors, Model model)
- {
- super("Node settings", model);
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- NodeDescriptor descriptor = (NodeDescriptor)p.next();
- addChild(new NodeVar(descriptor, model));
- }
- }
-
- void update(java.util.List descriptors, String[] removeNodes)
- {
- //
- // Note: _descriptors is updated by Application
- //
-
- //
- // One big set of removes
- //
- removeChildren(removeNodes);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
- java.util.Vector updatedChildren = new java.util.Vector();
-
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- NodeDescriptor nodeDescriptor = (NodeDescriptor)p.next();
- NodeVar child = (NodeVar)findChild(nodeDescriptor.name);
- if(child == null)
- {
- newChildren.add(new NodeVar(nodeDescriptor, _model));
- }
- else
- {
- child.rebuild(nodeDescriptor);
- updatedChildren.add(child);
- }
- }
-
- updateChildren((CommonBaseI[])updatedChildren.toArray(new CommonBaseI[0]));
- addChildren((CommonBaseI[])newChildren.toArray(new CommonBaseI[0]));
- }
-}
diff --git a/java/src/IceGrid/TreeNode/NodeViewRoot.java b/java/src/IceGrid/TreeNode/NodeViewRoot.java deleted file mode 100755 index 4566c672207..00000000000 --- a/java/src/IceGrid/TreeNode/NodeViewRoot.java +++ /dev/null @@ -1,227 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGrid.TreeNode;
-
-import IceGrid.ApplicationDescriptor;
-import IceGrid.NodeDescriptor;
-import IceGrid.TreeModelI;
-import IceGrid.Model;
-import IceGrid.NodeDynamicInfo;
-import IceGrid.ServerDynamicInfo;
-import IceGrid.AdapterDynamicInfo;
-import IceGrid.ServerState;
-
-public class NodeViewRoot extends Parent
-{
- public NodeViewRoot(Model model)
- {
- super("Nodes", model, TreeModelI.NODE_VIEW);
- }
-
- public void init(java.util.List applications)
- {
- assert(_children.size() == 0);
-
- java.util.Iterator p = applications.iterator();
- while(p.hasNext())
- {
- ApplicationDescriptor descriptor = (ApplicationDescriptor)p.next();
- put(descriptor.name, descriptor.nodes, false);
- }
- }
-
- public void clear()
- {
- _nodeMap.clear();
- _nodeServerInfoMap.clear();
- _nodeAdapterInfoMap.clear();
- clearChildren();
- fireStructureChangedEvent(this);
- }
-
- public void put(String applicationName, java.util.List nodeDescriptors,
- boolean fireEvent)
- {
- java.util.Iterator p = nodeDescriptors.iterator();
-
- while(p.hasNext())
- {
- NodeDescriptor descriptor = (NodeDescriptor)p.next();
- String nodeName = descriptor.name;
-
- Node child = (Node)findChild(nodeName);
- if(child == null)
- {
- java.util.Map serverInfoMap = (java.util.Map)_nodeServerInfoMap.get(nodeName);
- java.util.Map adapterInfoMap = (java.util.Map)_nodeAdapterInfoMap.get(nodeName);
- child = new Node(applicationName, _model, descriptor, serverInfoMap, adapterInfoMap);
- _nodeMap.put(nodeName, child);
- child.addParent(this);
- addChild(child, fireEvent);
- }
- else
- {
- child.addApplication(applicationName, descriptor);
- }
- }
- }
-
- public void remove(String applicationName)
- {
- int i = 0;
- java.util.Iterator p = _children.iterator();
-
- while(p.hasNext())
- {
- Node child = (Node)p.next();
- if(child.removeApplication(applicationName))
- {
- _nodeMap.remove(child.getId());
- p.remove();
- fireNodeRemovedEvent(this, child, i);
- }
- else
- {
- ++i;
- }
- }
- }
-
- public void remove(String applicationName, String nodeName)
- {
- Node child = (Node)_nodeMap.get(nodeName);
- assert(child != null);
-
- if(child.removeApplication(applicationName))
- {
- _nodeMap.remove(nodeName);
- removeChild(nodeName, true);
- }
- }
-
- public void removeServers(String[] removeServers)
- {
- if(removeServers.length > 0)
- {
- java.util.List serverList =
- new java.util.LinkedList(java.util.Arrays.asList(removeServers));
-
- java.util.Iterator p = _nodeMap.values().iterator();
- while(p.hasNext() && serverList.size() > 0)
- {
- Node node = (Node)p.next();
- node.removeChildren(serverList);
- }
- }
- }
-
- public void nodeUp(NodeDynamicInfo updatedInfo)
- {
- String nodeName = updatedInfo.name;
-
- java.util.Map serverMap = new java.util.HashMap();
- for(int i = 0; i < updatedInfo.servers.length; ++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)
- {
- assert(updatedInfo.adapters[i].proxy != null);
- adapterMap.put(updatedInfo.adapters[i].id, updatedInfo.adapters[i].proxy);
- }
-
- _nodeServerInfoMap.put(nodeName, serverMap);
- _nodeAdapterInfoMap.put(nodeName, adapterMap);
-
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.up(serverMap, adapterMap);
- }
- }
-
- public void nodeDown(String nodeName)
- {
- _nodeServerInfoMap.remove(nodeName);
- _nodeAdapterInfoMap.remove(nodeName);
-
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.down();
- }
- }
-
- public void updateServer(String nodeName, ServerDynamicInfo updatedInfo)
- {
- java.util.Map serverMap = (java.util.Map)_nodeServerInfoMap.get(nodeName);
- if(serverMap != null)
- {
- if(updatedInfo.state == ServerState.Destroyed ||
- updatedInfo.state == ServerState.Inactive)
- {
- serverMap.remove(updatedInfo.name);
- }
- else
- {
- serverMap.put(updatedInfo.name, updatedInfo);
- }
-
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.updateServer(updatedInfo);
- }
- }
- //
- // Else log a warning?
- //
-
- }
-
- public void updateAdapter(String nodeName, AdapterDynamicInfo updatedInfo)
- {
- java.util.Map adapterMap = (java.util.Map)_nodeAdapterInfoMap.get(nodeName);
- if(adapterMap != null)
- {
- if(updatedInfo.proxy == null)
- {
- adapterMap.remove(updatedInfo.id);
- }
- else
- {
- adapterMap.put(updatedInfo.id, updatedInfo.proxy);
- }
-
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.updateAdapter(updatedInfo);
- }
- }
- //
- // Else log a warning?
- //
- }
-
-
- Node findNode(String name)
- {
- return (Node)_nodeMap.get(name);
- }
-
- private java.util.Map _nodeMap = new java.util.HashMap();
- private java.util.Map _nodeServerInfoMap = new java.util.HashMap();
- private java.util.Map _nodeAdapterInfoMap = new java.util.HashMap();
-}
diff --git a/java/src/IceGrid/TreeNode/Parent.java b/java/src/IceGrid/TreeNode/Parent.java index 735732c92ba..c5a8cdf40dc 100755 --- a/java/src/IceGrid/TreeNode/Parent.java +++ b/java/src/IceGrid/TreeNode/Parent.java @@ -86,29 +86,26 @@ class Parent extends CommonBaseI return false;
}
- public void addParent(CommonBase parent)
+ public void setParent(CommonBase parent)
{
- assert(parent != null);
- for(int i = 0; i < TreeModelI.VIEW_COUNT; i++)
- {
- TreePath parentPath = parent.getPath(i);
- if(parentPath != null)
+ _parent = parent;
+ if(parent == null)
+ {
+ _path = null;
+ }
+ else
+ {
+ TreePath parentPath = _parent.getPath();
+ if(parentPath == null)
+ {
+ _path = null;
+ }
+ else
{
- addParent(parent, parentPath, i);
+ _path = parentPath.pathByAddingChild(this);
}
}
- }
-
- public void addParent(CommonBase parent, TreePath parentPath, int view)
- {
- assert(parent != null);
- assert(parentPath != null);
- assert(_parents[view] == null);
- assert(_paths[view] == null);
-
- _parents[view] = parent;
- _paths[view] = parentPath.pathByAddingChild(this);
-
+
//
// Propagate to children
//
@@ -116,33 +113,7 @@ class Parent extends CommonBaseI while(p.hasNext())
{
CommonBase child = (CommonBase)p.next();
- child.addParent(this, _paths[view], view);
- }
- }
-
- public void removeParent(CommonBase parent)
- {
- assert(parent != null);
-
- for(int i = 0; i < TreeModelI.VIEW_COUNT; i++)
- {
- if(_parents[i] == parent)
- {
- removeParent(i);
- }
- }
- }
-
- public void removeParent(int view)
- {
- _paths[view] = null;
- _parents[view] = null;
-
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- CommonBase child = (CommonBase)p.next();
- child.removeParent(view);
+ child.setParent(this);
}
}
@@ -427,15 +398,9 @@ class Parent extends CommonBaseI void fireNodesInsertedEvent(Object source, Object[] children, int[] childIndices)
{
- for(int i = 0; i < TreeModelI.VIEW_COUNT; ++i)
- {
- if(_paths[i] != null)
- {
- TreeModelEvent event = new TreeModelEvent(source, _paths[i],
- childIndices, children);
- _model.getTreeModel(i).fireNodesInsertedEvent(event);
- }
- }
+ assert _path != null;
+ TreeModelEvent event = new TreeModelEvent(source, _path, childIndices, children);
+ _model.getTreeModel().fireNodesInsertedEvent(event);
}
void fireNodeRemovedEvent(Object source, Object child, int index)
@@ -450,15 +415,11 @@ class Parent extends CommonBaseI void fireNodesRemovedEvent(Object source, Object[] children, int[] childIndices)
{
- for(int i = 0; i < TreeModelI.VIEW_COUNT; ++i)
- {
- if(_paths[i] != null)
- {
- TreeModelEvent event = new TreeModelEvent(source, _paths[i],
- childIndices, children);
- _model.getTreeModel(i).fireNodesRemovedEvent(event);
- }
- }
+ assert _path != null;
+
+ TreeModelEvent event = new TreeModelEvent(source, _path,
+ childIndices, children);
+ _model.getTreeModel().fireNodesRemovedEvent(event);
}
javax.swing.ComboBoxModel getComboBoxModel()
@@ -467,14 +428,14 @@ class Parent extends CommonBaseI }
- Parent(String id, Model model, int rootForView)
+ Parent(String id, Model model, boolean root)
{
- super(id, model, rootForView);
+ super(id, model, root);
}
Parent(String id, Model model)
{
- this(id, model, -1);
+ this(id, model, false);
}
diff --git a/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java b/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java index d522e36503e..255048aabbe 100755 --- a/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java +++ b/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java @@ -154,10 +154,6 @@ class ServerDescriptorEditor if(descriptor instanceof IceBoxDescriptor)
{
IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)descriptor;
- _endpoints.setText(
- Utils.substituteVariables(iceBoxDescriptor.endpoints, variables));
- _endpointsLabel.setEnabled(true);
- _endpoints.setEnabled(true);
}
else
{
@@ -167,7 +163,7 @@ class ServerDescriptorEditor }
_name.setText(
- Utils.substituteVariables(descriptor.name, variables));
+ Utils.substituteVariables(descriptor.id, variables));
Ice.StringHolder toolTipHolder = new Ice.StringHolder();
@@ -187,7 +183,7 @@ class ServerDescriptorEditor _properties.setToolTipText(toolTipHolder.value);
_comment.setText(
- Utils.substituteVariables(descriptor.comment, variables));
+ Utils.substituteVariables(descriptor.description, variables));
_exe.setText(
Utils.substituteVariables(descriptor.exe, variables));
diff --git a/java/src/IceGrid/TreeNode/ServerInstance.java b/java/src/IceGrid/TreeNode/ServerInstance.java index a08ff349679..9396c33bb05 100755 --- a/java/src/IceGrid/TreeNode/ServerInstance.java +++ b/java/src/IceGrid/TreeNode/ServerInstance.java @@ -90,22 +90,6 @@ class ServerInstance extends Parent builder.setLineGapSize(LayoutStyle.getCurrent().getParagraphPad());
- //
- // Node combo box
- //
- builder.append("Node");
- builder.append(_node, _nodeButton);
- builder.nextLine();
-
- //
- // Targets field
- //
- builder.append("Targets");
- _targets.setToolTipText("XML-descriptor targets used to deploy this server");
- builder.append(_targets, 3);
- _targets.setEditable(false);
- builder.nextLine();
-
_serverDescriptorEditor.build(builder);
_scrollPane = new JScrollPane(builder.getPanel(),
@@ -118,12 +102,10 @@ class ServerInstance extends Parent void show(ServerInstance server)
{
+ /*
_server = server;
ServerInstanceDescriptor descriptor = server.getDescriptor();
- _node.setModel(_server.getModel().getNodeViewRoot().getComboBoxModel());
- _node.setSelectedItem(_server.getParent(TreeModelI.NODE_VIEW));
-
ServerDescriptor serverDescriptor = null;
Ice.StringHolder toolTipHolder = new Ice.StringHolder();
@@ -131,7 +113,7 @@ class ServerInstance extends Parent if(descriptor.template.length() == 0)
{
- serverDescriptor = descriptor.descriptor;
+ serverDescriptor = null;
if(_server.getModel().substituteVariables())
{
variables = new java.util.Map[] {
@@ -211,6 +193,7 @@ class ServerInstance extends Parent _targets.setToolTipText(toolTipHolder.value);
_serverDescriptorEditor.show(serverDescriptor, variables);
+ */
}
Editor(boolean editDetails)
@@ -228,65 +211,13 @@ class ServerInstance extends Parent if(template != null && _server != null)
{
_server.getModel().getTreeNodeSelector().
- selectNode(
- template.getPath(
- TreeModelI.APPLICATION_VIEW),
- TreeModelI.APPLICATION_VIEW);
+ selectNode(template.getPath());
}
}
};
gotoTemplate.putValue(Action.SHORT_DESCRIPTION, "Goto this template");
_templateButton = new JButton(gotoTemplate);
_parameterValuesButton = new JButton("...");
-
- //
- // gotoNode action
- //
- AbstractAction gotoNode = new AbstractAction("->")
- {
- public void actionPerformed(ActionEvent e)
- {
- Node node = (Node)_node.getSelectedItem();
- if(node != null)
- {
- //
- // I have the node but I really want to get to the NodeVar;
- // too bad node does not contain them
- //
-
- if(_server != null)
- {
- CommonBase parent = _server.getParent(
- TreeModelI.APPLICATION_VIEW);
- if(parent != null)
- {
- Application app = (Application)parent.getParent(
- TreeModelI.APPLICATION_VIEW);
- if(app != null)
- {
- NodeVar nodeVar = app.findNodeVar(
- node.getId());
-
- //
- // TODO: offer to create a new nodeVar when
- // nodeVar == null
- //
- if(nodeVar != null)
- {
- _server.getModel().getTreeNodeSelector().
- selectNode(
- nodeVar.getPath(
- TreeModelI.APPLICATION_VIEW),
- TreeModelI.APPLICATION_VIEW);
- }
- }
- }
- }
- }
- }
- };
- gotoNode.putValue(Action.SHORT_DESCRIPTION, "Show the variables for this node");
- _nodeButton = new JButton(gotoNode);
}
@@ -303,11 +234,6 @@ class ServerInstance extends Parent private JTextField _parameterValues = new JTextField(20);
private JButton _parameterValuesButton;
- private JComboBox _node = new JComboBox();
- private JButton _nodeButton;
-
- private JTextField _targets = new JTextField(20);
-
private ServerDescriptorEditor _serverDescriptorEditor;
private ServerInstance _server;
@@ -459,30 +385,6 @@ class ServerInstance extends Parent rebuild(application, descriptor, fireNodeViewEvent);
}
-
- void removeFromNode()
- {
- removeFromNode(true);
- }
-
- private void removeFromNode(boolean fireNodeViewEvent)
- {
- if(_serviceInstances != null)
- {
- _serviceInstances.unregisterAdapters();
- }
- if(_adapters != null)
- {
- _adapters.unregisterAll();
- }
-
- Node node = (Node)getParent(TreeModelI.NODE_VIEW);
- if(node != null)
- {
- node.removeChild(_id, fireNodeViewEvent);
- }
- }
-
//
// Update the server instance and all its subtree
//
@@ -490,36 +392,11 @@ class ServerInstance extends Parent ServerInstanceDescriptor newDescriptor,
boolean fireNodeViewEvent)
{
+ /*
assert(newDescriptor != null);
- removeFromNode(fireNodeViewEvent);
- clearChildren();
-
- //
- // First check if my node changed [node view]
- // For the application view, the only way a server instance can change application
- // is by being removed and then re-added (i.e. not with an update)
- //
- boolean newNode = false;
-
- if(_descriptor == null)
- {
- newNode = true;
- }
- else if(_descriptor.node != newDescriptor.node)
- {
- newNode = true;
- //
- // Remove from existing node
- //
- CommonBase parent = _parents[TreeModelI.NODE_VIEW];
- assert(parent != null); // must be connected
- removeParent(parent);
- ((Parent)parent).removeChild(this);
- }
_descriptor = newDescriptor;
+ clearChildren();
- Node node = _model.getNodeViewRoot().findNode(_descriptor.node);
-
java.util.Map appVariables = application.getVariables();
_nodeVariables =
application.getNodeVariables(_descriptor.node); // can be null
@@ -580,6 +457,8 @@ class ServerInstance extends Parent addParent(node); // propagates to children
node.addChild(this, fireNodeViewEvent);
}
+
+ */
}
void updateDynamicInfo(ServerDynamicInfo info)
@@ -675,22 +554,11 @@ class ServerInstance extends Parent {
return _descriptor;
}
-
-
- Application getApplication()
- {
- CommonBase parent = getParent(TreeModelI.APPLICATION_VIEW);
- return
- (Application)parent.getParent(TreeModelI.APPLICATION_VIEW);
- }
-
- java.util.Map getNodeVariables()
- {
- return _nodeVariables;
- }
-
+
public String toString()
{
+ return "";
+ /*
String result = _descriptor.descriptor.name;
if(!_descriptor.template.equals(""))
@@ -700,6 +568,7 @@ class ServerInstance extends Parent _descriptor.parameterValues.values());
}
return result;
+ */
}
private static String toolTip(ServerState state, int pid)
@@ -719,7 +588,6 @@ class ServerInstance extends Parent private String _toolTip = toolTip(_state, _pid);
private ServerInstanceDescriptor _descriptor;
- private java.util.Map _nodeVariables;
//
// Children
diff --git a/java/src/IceGrid/TreeNode/ServerInstances.java b/java/src/IceGrid/TreeNode/ServerInstances.java deleted file mode 100755 index c00c6bfcae3..00000000000 --- a/java/src/IceGrid/TreeNode/ServerInstances.java +++ /dev/null @@ -1,138 +0,0 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGrid.TreeNode;
-
-import IceGrid.Model;
-import IceGrid.ServerInstanceDescriptor;
-import IceGrid.TemplateDescriptor;
-import IceGrid.TreeModelI;
-import IceGrid.Utils;
-
-
-class ServerInstances extends Parent
-{
- ServerInstances(java.util.List descriptors,
- Application application,
- boolean fireEvent)
- {
- super("Server instances", application.getModel());
- _descriptors = descriptors;
-
- java.util.Iterator p = _descriptors.iterator();
- while(p.hasNext())
- {
- //
- // The ServerInstance constructor inserts the new object in the
- // node view model
- //
- ServerInstanceDescriptor descriptor =
- (ServerInstanceDescriptor)p.next();
-
- String serverName = computeServerName(descriptor, application);
-
- ServerInstance child = new ServerInstance(serverName,
- descriptor,
- application,
- fireEvent);
- addChild(child);
- }
- }
-
- void update(java.util.List updates, String[] removeServers)
- {
- //
- // Note: _descriptors is updated by Application
- //
-
- Application application = (Application)getParent(TreeModelI.APPLICATION_VIEW);
-
- //
- // One big set of removes
- //
- for(int i = 0; i < removeServers.length; ++i)
- {
- ServerInstance server = (ServerInstance)findChild(removeServers[i]);
- server.removeFromNode();
- }
- removeChildren(removeServers);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
- java.util.Vector updatedChildren = new java.util.Vector();
-
- java.util.Iterator p = updates.iterator();
- while(p.hasNext())
- {
- ServerInstanceDescriptor descriptor = (ServerInstanceDescriptor)p.next();
-
- String serverName = computeServerName(descriptor, application);
-
- ServerInstance child = (ServerInstance)findChild(serverName);
- if(child == null)
- {
- newChildren.add(new ServerInstance(serverName, descriptor, application, true));
- }
- else
- {
- child.rebuild(application, descriptor, true);
- updatedChildren.add(child);
- }
- }
-
- updateChildren((CommonBaseI[])updatedChildren.toArray(new CommonBaseI[0]));
- addChildren((CommonBaseI[])newChildren.toArray(new CommonBaseI[0]));
- }
-
- void removeFromNodes()
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServerInstance server = (ServerInstance)p.next();
- server.removeFromNode();
- }
- }
-
-
- static String computeServerName(ServerInstanceDescriptor instanceDescriptor,
- Application application)
- {
- String nodeName = instanceDescriptor.node;
-
- if(instanceDescriptor.template.length() > 0)
- {
- //
- // Can't be null
- //
- TemplateDescriptor templateDescriptor =
- application.findServerTemplateDescriptor(instanceDescriptor.template);
-
- java.util.Map parameters =
- Utils.substituteVariables(instanceDescriptor.parameterValues,
- application.getNodeVariables(nodeName),
- application.getVariables());
-
- return Utils.substituteVariables(templateDescriptor.descriptor.name,
- parameters,
- application.getNodeVariables(nodeName),
- application.getVariables());
- }
- else
- {
-
- return Utils.substituteVariables(instanceDescriptor.descriptor.name,
- application.getNodeVariables(nodeName),
- application.getVariables());
- }
- }
-
- private java.util.List _descriptors;
-}
diff --git a/java/src/IceGrid/TreeNode/ServerTemplates.java b/java/src/IceGrid/TreeNode/ServerTemplates.java index d469af44e60..ed62b758986 100755 --- a/java/src/IceGrid/TreeNode/ServerTemplates.java +++ b/java/src/IceGrid/TreeNode/ServerTemplates.java @@ -37,7 +37,7 @@ class ServerTemplates extends Parent // Note: _descriptors is updated by Application
//
- Application application = (Application)getParent(TreeModelI.APPLICATION_VIEW);
+ Application application = (Application)getParent();
//
// One big set of removes
diff --git a/java/src/IceGrid/TreeNode/ServiceInstance.java b/java/src/IceGrid/TreeNode/ServiceInstance.java index bbbed0d74f1..06723f18d39 100755 --- a/java/src/IceGrid/TreeNode/ServiceInstance.java +++ b/java/src/IceGrid/TreeNode/ServiceInstance.java @@ -68,7 +68,7 @@ class ServiceInstance extends Parent _adapters = new Adapters(serviceDescriptor.adapters,
childrenEditable,
- variables, _model, node);
+ variables, _model);
addChild(_adapters);
_dbEnvs = new DbEnvs(serviceDescriptor.dbEnvs, childrenEditable,
diff --git a/java/src/IceGrid/Utils.java b/java/src/IceGrid/Utils.java index bc0ba63323e..c5524262be8 100755 --- a/java/src/IceGrid/Utils.java +++ b/java/src/IceGrid/Utils.java @@ -231,4 +231,199 @@ public class Utils return substituteVariables(input,
new java.util.Map[]{m1, m2, m3});
}
+
+
+ static public class Resolver
+ {
+ //
+ // Simple resolver
+ //
+ public Resolver(java.util.Map[] variables)
+ {
+ this(variables, null, null);
+ }
+
+ //
+ // Resolver for instance; parameters is not yet substituted
+ //
+ public Resolver(Resolver parent, java.util.TreeMap parameters)
+ {
+ java.util.TreeMap substitutedParameters =
+ substituteParameterValues(parameters, parent);
+
+ _variables = parent._variables;
+ _resolvedVariableCache = (java.util.HashMap)parent._resolvedVariableCache.clone();
+ _parameters = substitutedParameters;
+ }
+
+
+ private Resolver(java.util.Map[] variables, // ordered read-only variable maps
+ java.util.HashMap resolvedVariableCache, // null or read-write
+ java.util.Map parameters) // null or read-only
+ {
+ _variables = variables;
+ _resolvedVariableCache = resolvedVariableCache;
+ _parameters = parameters;
+
+ assert _variables != null;
+
+ if(_resolvedVariableCache == null)
+ {
+ _resolvedVariableCache = new java.util.HashMap();
+ }
+ if(_parameters == null)
+ {
+ _subResolver = this;
+ }
+ else
+ {
+ _subResolver = new Resolver(_variables, _resolvedVariableCache, null);
+ }
+ }
+
+ public String find(String name)
+ {
+ if(_parameters != null)
+ {
+ Object obj = _parameters.get(name);
+ if(obj != null)
+ {
+ return (String)obj;
+ }
+ }
+
+ Object obj = _resolvedVariableCache.get(name);
+ if(obj != null)
+ {
+ return (String)obj;
+ }
+ else
+ {
+ for(int i = 0; i < _variables.length; ++i)
+ {
+ obj = _variables[i].get(name);
+ if(obj != null)
+ {
+ break;
+ }
+ }
+ if(obj != null)
+ {
+ //
+ // If I lookup up myself, I am in trouble!
+ //
+ _resolvedVariableCache.put(name, _recursiveDefError);
+ String result = Utils.substitute((String)obj, _subResolver);
+ _resolvedVariableCache.put(name, result);
+ return result;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ //
+ // Put this entry; particularly useful for predefined variables
+ //
+ public void put(String name, String value)
+ {
+ _resolvedVariableCache.put(name, value);
+ }
+
+ //
+ // The sorted substituted parameters
+ //
+ public java.util.Map getParameters()
+ {
+ return _parameters;
+ }
+
+ private java.util.Map[] _variables;
+ private java.util.HashMap _resolvedVariableCache;
+ private java.util.Map _parameters;
+ private Resolver _subResolver;
+ static private String _recursiveDefError = "<recursive def error>";
+ }
+
+
+ static public String substitute(String input, Resolver resolver)
+ {
+ if(resolver == null)
+ {
+ return input;
+ }
+
+ int beg = 0;
+ int end = 0;
+
+ while((beg = input.indexOf("${", beg)) != -1)
+ {
+ if(beg > 0 && input.charAt(beg - 1) == '$')
+ {
+ int escape = beg - 1;
+ while(escape > 0 && input.charAt(escape = 1) == '$')
+ {
+ --escape;
+ }
+
+ input = input.substring(0, escape) + input.substring(beg - (beg - escape) / 2);
+ if((beg - escape) % 2 != 0)
+ {
+ ++beg;
+ continue;
+ }
+ else
+ {
+ beg -= (beg - escape) / 2;
+ }
+ }
+
+ end = input.indexOf('}', beg);
+ if(end == -1)
+ {
+ //
+ // Malformed variable, can't substitute anything else
+ //
+ return input;
+ }
+
+ String name = input.substring(beg + 2, end);
+
+ //
+ // Resolve name
+ //
+ String val = resolver.find(name);
+ if(val != null)
+ {
+ input = input.substring(0, beg) + val + input.substring(end + 1);
+ beg += val.length();
+ }
+ else
+ {
+ //
+ // No substitution, keep ${name} in the result
+ //
+ ++beg;
+ }
+ }
+ return input;
+ }
+
+ //
+ // Substitute all the values from the input map
+ //
+ static public java.util.TreeMap substituteParameterValues(java.util.TreeMap input,
+ Resolver resolver)
+ {
+ java.util.TreeMap result = (java.util.TreeMap)input.clone();
+ java.util.Iterator p = result.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ entry.setValue(substitute((String)entry.getValue(), resolver));
+ }
+ return result;
+ }
}
|