summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-07-14 23:40:17 +0000
committerBernard Normier <bernard@zeroc.com>2005-07-14 23:40:17 +0000
commit87236a07f5bd4201cd7c2f43d6e9a5fc5d50fbdb (patch)
treee8ecaf5e21798004eab55cfd6df6a7b9bb0e764b /java/src
parentadding package, adapterDeactivation (diff)
downloadice-87236a07f5bd4201cd7c2f43d6e9a5fc5d50fbdb.tar.bz2
ice-87236a07f5bd4201cd7c2f43d6e9a5fc5d50fbdb.tar.xz
ice-87236a07f5bd4201cd7c2f43d6e9a5fc5d50fbdb.zip
Displaying more properties
Diffstat (limited to 'java/src')
-rwxr-xr-xjava/src/IceGrid/AdminGUI.java15
-rwxr-xr-xjava/src/IceGrid/MainPane.java14
-rwxr-xr-xjava/src/IceGrid/Model.java28
-rwxr-xr-xjava/src/IceGrid/TreeNode/Adapter.java181
-rwxr-xr-xjava/src/IceGrid/TreeNode/Adapters.java33
-rwxr-xr-xjava/src/IceGrid/TreeNode/Application.java72
-rwxr-xr-xjava/src/IceGrid/TreeNode/CommonBase.java3
-rwxr-xr-xjava/src/IceGrid/TreeNode/CommonBaseI.java11
-rwxr-xr-xjava/src/IceGrid/TreeNode/DbEnv.java13
-rwxr-xr-xjava/src/IceGrid/TreeNode/DbEnvs.java33
-rwxr-xr-xjava/src/IceGrid/TreeNode/NodeVar.java5
-rwxr-xr-xjava/src/IceGrid/TreeNode/Parent.java35
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerDescriptorEditor.java252
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerDescriptorRenderer.java165
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerInstance.java457
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerInstances.java64
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerTemplate.java54
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServerTemplates.java22
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServiceInstance.java81
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServiceInstances.java114
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServiceTemplate.java8
-rwxr-xr-xjava/src/IceGrid/TreeNode/ServiceTemplates.java7
-rwxr-xr-xjava/src/IceGrid/Utils.java132
23 files changed, 1426 insertions, 373 deletions
diff --git a/java/src/IceGrid/AdminGUI.java b/java/src/IceGrid/AdminGUI.java
index 8f10bb00a37..32effdba2e6 100755
--- a/java/src/IceGrid/AdminGUI.java
+++ b/java/src/IceGrid/AdminGUI.java
@@ -307,6 +307,21 @@ public class AdminGUI extends JFrame
editMenu.add(deleteAction);
toolBar.add(deleteAction);
+ toolBar.addSeparator();
+ Action substituteVarAction = new AbstractAction("${}")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _model.toggleSubstituteVariables();
+ }
+ };
+
+ substituteVarAction.putValue(Action.SHORT_DESCRIPTION,
+ "Substitute variables and parameters in servers' properties");
+
+ toolBar.add(new JToggleButton(substituteVarAction));
+
+
Action aboutAction = new AbstractAction("About...")
{
public void actionPerformed(ActionEvent e)
diff --git a/java/src/IceGrid/MainPane.java b/java/src/IceGrid/MainPane.java
index 8ad3819e6a8..38ff6c1c8f7 100755
--- a/java/src/IceGrid/MainPane.java
+++ b/java/src/IceGrid/MainPane.java
@@ -78,7 +78,7 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector
}
}
- class SelectionListener implements TreeSelectionListener
+ static class SelectionListener implements TreeSelectionListener
{
SelectionListener(int view)
{
@@ -91,7 +91,7 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector
if(path != null)
{
CommonBase node = (CommonBase)path.getLastPathComponent();
- node.displayProperties(_rightPane, _view);
+ node.displayProperties();
}
}
@@ -114,11 +114,7 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector
if(path != null)
{
CommonBase node = (CommonBase)path.getLastPathComponent();
-
- //
- // Assumes the pane indexing matches the view indexing
- //
- node.displayProperties(_rightPane, selectedPane);
+ node.displayProperties();
return;
}
}
@@ -170,7 +166,8 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector
// Left pane
//
_tabbedPane = new JTabbedPane();
- _tabbedPane.setMinimumSize(new Dimension(200, 300));
+ _tabbedPane.setPreferredSize(new Dimension(280, 350));
+
_tabbedPane.putClientProperty(Options.NO_CONTENT_BORDER_KEY, Boolean.TRUE);
_tabbedPane.setBorder(new ShadowBorder());
TabListener tabListener = new TabListener();
@@ -232,6 +229,7 @@ public class MainPane extends JSplitPane implements Model.TreeNodeSelector
_emptyPanel = new JPanel();
_emptyPanel.setBackground(Color.RED);
_rightPane.setContent(_emptyPanel);
+ _model.setPropertiesFrame(_rightPane);
setLeftComponent(leftPane);
setRightComponent(_rightPane);
diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java
index f44db467edb..95b24ddb67c 100755
--- a/java/src/IceGrid/Model.java
+++ b/java/src/IceGrid/Model.java
@@ -20,6 +20,8 @@ import javax.swing.tree.TreePath;
import IceGrid.TreeNode.NodeViewRoot;
import IceGrid.TreeNode.ApplicationViewRoot;
+import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
+
//
// Where all the data are kept
//
@@ -360,6 +362,19 @@ public class Model
return true;
}
+ void toggleSubstituteVariables()
+ {
+ _substituteVariables = !_substituteVariables;
+ //
+ // TODO: need to send a notification to redisplay current properties
+ //
+ }
+
+ public boolean substituteVariables()
+ {
+ return _substituteVariables;
+ }
+
public AdminPrx getAdmin()
{
return _admin;
@@ -385,6 +400,15 @@ public class Model
return _treeNodeSelector;
}
+ public void setPropertiesFrame(SimpleInternalFrame frame)
+ {
+ _propertiesFrame = frame;
+ }
+
+ public SimpleInternalFrame getPropertiesFrame()
+ {
+ return _propertiesFrame;
+ }
Model(Ice.Communicator communicator, StatusBar statusBar)
{
@@ -414,4 +438,8 @@ public class Model
private int _latestSerial = -1;
private TreeNodeSelector _treeNodeSelector;
+
+ private boolean _substituteVariables = false;
+
+ private SimpleInternalFrame _propertiesFrame;
}
diff --git a/java/src/IceGrid/TreeNode/Adapter.java b/java/src/IceGrid/TreeNode/Adapter.java
index 4d3ea8c0d6a..b923e5cb2a5 100755
--- a/java/src/IceGrid/TreeNode/Adapter.java
+++ b/java/src/IceGrid/TreeNode/Adapter.java
@@ -9,14 +9,141 @@
package IceGrid.TreeNode;
import java.awt.Component;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.util.LayoutStyle;
+import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
+
import IceGrid.AdapterDescriptor;
import IceGrid.Model;
+import IceGrid.ObjectDescriptor;
+import IceGrid.Utils;
class Adapter extends Leaf
{
+ static class Editor
+ {
+ JComponent getComponent()
+ {
+ if(_scrollPane == null)
+ {
+ //
+ // Build everything using JGoodies's DefaultFormBuilder
+ //
+ FormLayout layout = new FormLayout(
+ "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setBorder(Borders.DLU2_BORDER);
+ builder.setRowGroupingEnabled(true);
+
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ builder.append("Name" );
+ builder.append(_name, 3);
+ builder.nextLine();
+
+ builder.append("Id" );
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ builder.append("Endpoints" );
+ builder.append(_endpoints, 3);
+ builder.nextLine();
+
+ builder.append("Registered Objects");
+ builder.append(_objects, _objectsButton);
+ builder.nextLine();
+
+ builder.append("", _registerProcess);
+ builder.nextLine();
+ builder.append("", _noWaitForActivation);
+ builder.nextLine();
+
+ _scrollPane = new JScrollPane(builder.getPanel(),
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ _scrollPane.setBorder(Borders.DIALOG_BORDER);
+ }
+ return _scrollPane;
+ }
+
+ void show(Adapter adapter)
+ {
+ _adapter = adapter;
+ AdapterDescriptor descriptor = adapter.getDescriptor();
+
+ final java.util.Map[] variables =
+ _adapter.getModel().substituteVariables() ?
+ adapter.getVariables() : null;
+
+ boolean editable = adapter.isEditable() && (variables == null);
+
+ _name.setText(
+ Utils.substituteVariables(descriptor.name, variables));
+ _name.setEditable(editable);
+
+ _id.setText(
+ 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()
+ {
+ public String toString(Object obj)
+ {
+ ObjectDescriptor od = (ObjectDescriptor)obj;
+ Ice.Identity sid = new Ice.Identity(
+ Utils.substituteVariables(od.id.name, variables),
+ Utils.substituteVariables(od.id.category, variables));
+
+ return Ice.Util.identityToString(sid)
+ + " as '"
+ + Utils.substituteVariables(od.type, variables)
+ + "'";
+ }
+ };
+
+ _objects.setText(
+ Utils.stringify(descriptor.objects, stringifier,
+ ", ", toolTipHolder));
+ _objects.setToolTipText(toolTipHolder.value);
+ _objects.setEditable(editable);
+ _objectsButton.setEnabled(editable);
+
+ _registerProcess.setSelected(descriptor.registerProcess);
+ _registerProcess.setEnabled(editable);
+
+ _noWaitForActivation.setSelected(descriptor.noWaitForActivation);
+ _noWaitForActivation.setEnabled(editable);
+
+ }
+
+ private JTextField _name = new JTextField(20);
+ 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 JTextField _objects = new JTextField(20);
+ private JButton _objectsButton = new JButton("...");
+
+ private Adapter _adapter;
+ private JScrollPane _scrollPane;
+ }
+
public Component getTreeCellRendererComponent(
JTree tree,
@@ -47,30 +174,54 @@ class Adapter extends Leaf
}
}
+ public void displayProperties()
+ {
+ SimpleInternalFrame propertiesFrame = _model.getPropertiesFrame();
+
+ propertiesFrame.setTitle("Properties for " + _id);
+ if(_editor == null)
+ {
+ _editor = new Editor();
+ }
+
+ _editor.show(this);
+ propertiesFrame.setContent(_editor.getComponent());
+ propertiesFrame.validate();
+ propertiesFrame.repaint();
+ }
- Adapter(AdapterDescriptor descriptor, Model model, Node node)
+
+ Adapter(String adapterName, AdapterDescriptor descriptor,
+ boolean editable, java.util.Map[] variables,
+ Model model, Node node)
{
- super(descriptor.name, model);
+ super(adapterName, model);
_descriptor = descriptor;
+ _editable = editable;
+ _variables = variables;
_node = node;
if(_node != null)
{
- _proxy = node.registerAdapter(_descriptor.id, this);
+ _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(_descriptor.id);
+ _node.unregisterAdapter(_adapterId);
_node = null;
}
}
-
void updateProxy(Ice.ObjectPrx proxy)
{
assert(_node != null);
@@ -79,6 +230,21 @@ class Adapter extends Leaf
fireNodeChangedEvent(this);
}
+ AdapterDescriptor getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ boolean isEditable()
+ {
+ return _editable;
+ }
+
+ java.util.Map[] getVariables()
+ {
+ return _variables;
+ }
+
private void createToolTip()
{
if(_proxy == null)
@@ -92,9 +258,14 @@ class Adapter extends Leaf
}
private AdapterDescriptor _descriptor;
+ private boolean _editable;
+ private java.util.Map[] _variables;
+
+ private String _adapterId;
private Node _node;
private Ice.ObjectPrx _proxy;
private String _toolTip;
static private DefaultTreeCellRenderer _cellRenderer;
+ static private Editor _editor;
}
diff --git a/java/src/IceGrid/TreeNode/Adapters.java b/java/src/IceGrid/TreeNode/Adapters.java
index ffc7aed73fd..a408e0d818a 100755
--- a/java/src/IceGrid/TreeNode/Adapters.java
+++ b/java/src/IceGrid/TreeNode/Adapters.java
@@ -10,20 +10,45 @@ package IceGrid.TreeNode;
import IceGrid.AdapterDescriptor;
import IceGrid.Model;
+import IceGrid.Utils;
class Adapters extends Parent
{
- Adapters(java.util.List descriptors, Model model, Node node)
+ //
+ // In server or service template
+ //
+ Adapters(java.util.List descriptors, Model model)
+ {
+ this(descriptors, true, null, model, null);
+ }
+
+ //
+ // In server or service instance
+ //
+ Adapters(java.util.List descriptors, boolean editable,
+ java.util.Map[] variables,
+ Model model, Node node)
{
super("Adapters", model);
-
_descriptors = descriptors;
+ _editable = editable;
+ _variables = variables;
java.util.Iterator p = _descriptors.iterator();
while(p.hasNext())
{
AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
- Adapter child = new Adapter(descriptor, _model, node);
+
+ String adapterName = descriptor.name;
+ if(_variables != null)
+ {
+ adapterName = Utils.substituteVariables(adapterName,
+ _variables);
+ }
+
+ Adapter child = new Adapter(adapterName, descriptor,
+ _editable, _variables,
+ _model, node);
addChild(child);
}
}
@@ -39,4 +64,6 @@ class Adapters extends Parent
}
private java.util.List _descriptors;
+ private boolean _editable;
+ private java.util.Map[] _variables;
}
diff --git a/java/src/IceGrid/TreeNode/Application.java b/java/src/IceGrid/TreeNode/Application.java
index 0453f5283ef..c7d7111260f 100755
--- a/java/src/IceGrid/TreeNode/Application.java
+++ b/java/src/IceGrid/TreeNode/Application.java
@@ -10,8 +10,10 @@ package IceGrid.TreeNode;
import IceGrid.ApplicationDescriptor;
import IceGrid.ApplicationUpdateDescriptor;
+import IceGrid.TemplateDescriptor;
import IceGrid.Model;
+
class Application extends Parent
{
//
@@ -24,20 +26,25 @@ class Application extends Parent
_descriptor = descriptor;
- _serverTemplates = new ServerTemplates(_descriptor.serverTemplates,
- _model);
- addChild(_serverTemplates);
-
- _serviceTemplates = new ServiceTemplates(_descriptor.serviceTemplates,
- _model);
- addChild(_serviceTemplates);
-
_nodeVars = new NodeVars(_descriptor.nodes, _model);
addChild(_nodeVars);
- _serverInstances = new ServerInstances(_descriptor.servers,
- _model,
- fireEvent);
+ //
+ // _serviceTemplates must be created before _serverTemplates
+ // and _serverInstances, since they may refer to them
+ //
+ _serviceTemplates = new ServiceTemplates(_descriptor.serviceTemplates, _model);
+
+ addChild(_serviceTemplates);
+
+ _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);
}
@@ -116,7 +123,50 @@ class Application extends Parent
{
return (ServerTemplate)_serverTemplates.findChild(id);
}
+
+ TemplateDescriptor findServerTemplateDescriptor(String templateName)
+ {
+ return (TemplateDescriptor)
+ _descriptor.serverTemplates.get(templateName);
+ }
+
+ TemplateDescriptor findServiceTemplateDescriptor(String templateName)
+ {
+ return (TemplateDescriptor)
+ _descriptor.serviceTemplates.get(templateName);
+ }
+
+
+ NodeVar findNodeVar(String id)
+ {
+ return (NodeVar)_nodeVars.findChild(id);
+ }
+ ServerTemplates getServerTemplates()
+ {
+ return _serverTemplates;
+ }
+
+ //
+ // Should only be used for reading
+ //
+ java.util.Map getVariables()
+ {
+ return _descriptor.variables;
+ }
+
+ java.util.Map getNodeVariables(String id)
+ {
+ NodeVar nodeVar = findNodeVar(id);
+ if(nodeVar != null)
+ {
+ return nodeVar.getVariables();
+ }
+ else
+ {
+ return null;
+ }
+ }
private ApplicationDescriptor _descriptor;
diff --git a/java/src/IceGrid/TreeNode/CommonBase.java b/java/src/IceGrid/TreeNode/CommonBase.java
index c71f3816cd2..07a2c23b49f 100755
--- a/java/src/IceGrid/TreeNode/CommonBase.java
+++ b/java/src/IceGrid/TreeNode/CommonBase.java
@@ -79,6 +79,5 @@ public interface CommonBase extends TreeCellRenderer
//
JPopupMenu getPopupMenu();
- void displayProperties(SimpleInternalFrame frame, int view);
-
+ void displayProperties();
}
diff --git a/java/src/IceGrid/TreeNode/CommonBaseI.java b/java/src/IceGrid/TreeNode/CommonBaseI.java
index e2ff879cc36..3f2122e57f4 100755
--- a/java/src/IceGrid/TreeNode/CommonBaseI.java
+++ b/java/src/IceGrid/TreeNode/CommonBaseI.java
@@ -109,7 +109,7 @@ abstract class CommonBaseI implements CommonBase
return null;
}
- public void displayProperties(SimpleInternalFrame frame, int view)
+ public void displayProperties()
{
if(_panel == null)
{
@@ -119,10 +119,11 @@ abstract class CommonBaseI implements CommonBase
_panel.setBorder(Borders.DIALOG_BORDER);
}
- frame.setTitle("Properties");
- frame.setContent(_panel);
- frame.validate();
- frame.repaint();
+ SimpleInternalFrame propertiesFrame = _model.getPropertiesFrame();
+ propertiesFrame.setTitle("Properties");
+ propertiesFrame.setContent(_panel);
+ propertiesFrame.validate();
+ propertiesFrame.repaint();
}
public Component getTreeCellRendererComponent(
diff --git a/java/src/IceGrid/TreeNode/DbEnv.java b/java/src/IceGrid/TreeNode/DbEnv.java
index 88cc66b975c..00eaf631c3a 100755
--- a/java/src/IceGrid/TreeNode/DbEnv.java
+++ b/java/src/IceGrid/TreeNode/DbEnv.java
@@ -13,14 +13,17 @@ import IceGrid.Model;
class DbEnv extends Leaf
{
- DbEnv(DbEnvDescriptor descriptor, Model model, boolean inTemplate)
+ DbEnv(String dbEnvName, DbEnvDescriptor descriptor,
+ boolean editable, java.util.Map[] variables,
+ Model model)
{
- super(descriptor.name, model);
-
+ super(dbEnvName, model);
_descriptor = descriptor;
- _inTemplate = inTemplate;
+ _editable = editable;
+ _variables = variables;
}
private DbEnvDescriptor _descriptor;
- private boolean _inTemplate;
+ private boolean _editable;
+ private java.util.Map[] _variables;
}
diff --git a/java/src/IceGrid/TreeNode/DbEnvs.java b/java/src/IceGrid/TreeNode/DbEnvs.java
index 3ab34c2af59..320ee9a9c5d 100755
--- a/java/src/IceGrid/TreeNode/DbEnvs.java
+++ b/java/src/IceGrid/TreeNode/DbEnvs.java
@@ -10,23 +10,48 @@ package IceGrid.TreeNode;
import IceGrid.DbEnvDescriptor;
import IceGrid.Model;
+import IceGrid.Utils;
class DbEnvs extends Parent
{
- DbEnvs(java.util.List descriptors, Model model, boolean inTemplate)
+ //
+ // In server or service template
+ //
+ DbEnvs(java.util.List descriptors, Model model)
+ {
+ this(descriptors, true, null, model);
+ }
+
+ //
+ // In server or service instance
+ //
+ DbEnvs(java.util.List descriptors,
+ boolean editable,
+ java.util.Map[] variables,
+ Model model)
{
super("DbEnvs", model);
_descriptors = descriptors;
- _inTemplate = inTemplate;
+ _editable = editable;
+ _variables = variables;
java.util.Iterator p = _descriptors.iterator();
while(p.hasNext())
{
DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
- addChild(new DbEnv(descriptor, _model, _inTemplate));
+
+ String dbEnvName = descriptor.name;
+ if(_variables != null)
+ {
+ dbEnvName = Utils.substituteVariables(dbEnvName, _variables);
+ }
+ addChild(new DbEnv(dbEnvName, descriptor, _editable, _variables,
+ _model));
}
}
private java.util.List _descriptors;
- private boolean _inTemplate;
+ private boolean _editable;
+ private java.util.Map[] _variables;
+
}
diff --git a/java/src/IceGrid/TreeNode/NodeVar.java b/java/src/IceGrid/TreeNode/NodeVar.java
index 864bf2c663b..ddd93ae8a44 100755
--- a/java/src/IceGrid/TreeNode/NodeVar.java
+++ b/java/src/IceGrid/TreeNode/NodeVar.java
@@ -24,6 +24,11 @@ class NodeVar extends Leaf
_descriptor = descriptor;
}
+ java.util.Map getVariables()
+ {
+ return _descriptor.variables;
+ }
+
private NodeDescriptor _descriptor;
}
diff --git a/java/src/IceGrid/TreeNode/Parent.java b/java/src/IceGrid/TreeNode/Parent.java
index 5e53d1e6886..735732c92ba 100755
--- a/java/src/IceGrid/TreeNode/Parent.java
+++ b/java/src/IceGrid/TreeNode/Parent.java
@@ -19,6 +19,36 @@ import IceGrid.TreeModelI;
class Parent extends CommonBaseI
{
+
+ //
+ // Adapts parent to a ComboBoxModel
+ //
+ class ComboBoxModel extends javax.swing.AbstractListModel
+ implements javax.swing.ComboBoxModel
+ {
+ public Object getElementAt(int index)
+ {
+ return getChildAt(index);
+ }
+
+ public int getSize()
+ {
+ return getChildCount();
+ }
+
+ public Object getSelectedItem()
+ {
+ return _selectedItem;
+ }
+
+ public void setSelectedItem(Object obj)
+ {
+ _selectedItem = obj;
+ }
+
+ private Object _selectedItem;
+ }
+
static class ChildComparator implements java.util.Comparator
{
public int compare(Object o1, Object o2)
@@ -431,7 +461,10 @@ class Parent extends CommonBaseI
}
}
-
+ javax.swing.ComboBoxModel getComboBoxModel()
+ {
+ return new ComboBoxModel();
+ }
Parent(String id, Model model, int rootForView)
diff --git a/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java b/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java
new file mode 100755
index 00000000000..d522e36503e
--- /dev/null
+++ b/java/src/IceGrid/TreeNode/ServerDescriptorEditor.java
@@ -0,0 +1,252 @@
+// **********************************************************************
+//
+// 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.ServerDescriptor;
+import IceGrid.IceBoxDescriptor;
+import IceGrid.PropertyDescriptor;
+import IceGrid.Utils;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JTextField;
+import javax.swing.JTextArea;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.util.LayoutStyle;
+
+class ServerDescriptorEditor
+{
+ void build(DefaultFormBuilder builder)
+ {
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ builder.appendSeparator();
+ builder.append("Name");
+ builder.append(_name, 3);
+ builder.nextLine();
+
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_comment);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.appendSeparator("Configuration");
+ builder.append("Properties");
+ if(_editable)
+ {
+ builder.append(_properties, new JButton("..."));
+ }
+ else
+ {
+ builder.append(_properties, 3);
+ }
+ builder.nextLine();
+
+ builder.append(_endpointsLabel);
+ builder.append(_endpoints, 3);
+ builder.nextLine();
+
+
+ builder.appendSeparator("Process Launch");
+
+ builder.append("Activation Mode");
+ builder.append(_activation, 3);
+
+ builder.nextLine();
+
+ builder.append("Command");
+ if(_editable)
+ {
+ builder.append(_exe, new JButton("..."));
+ }
+ else
+ {
+ builder.append(_exe, 3);
+ }
+ builder.nextLine();
+
+ builder.append("Command Arguments");
+ if(_editable)
+ {
+ builder.append(_options, new JButton("..."));
+ }
+ else
+ {
+ builder.append(_options, 3);
+ }
+ builder.nextLine();
+
+ builder.append("Working Directory");
+ if(_editable)
+ {
+ builder.append(_pwd, new JButton("..."));
+ }
+ else
+ {
+ builder.append(_pwd, 3);
+ }
+ builder.nextLine();
+
+ builder.append("Environment Variables");
+ if(_editable)
+ {
+ builder.append(_envs, new JButton("..."));
+ }
+ else
+ {
+ builder.append(_envs, 3);
+ }
+ builder.nextLine();
+
+
+ if(!_editable)
+ {
+ //
+ // All the components are just for show
+ //
+ _name.setEditable(false);
+ _comment.setEditable(false);
+ _comment.setOpaque(false);
+
+ _properties.setEditable(false);
+ _endpoints.setEditable(false);
+
+ _activation.setEditable(false);
+ _exe.setEditable(false);
+ _options.setEditable(false);
+ _pwd.setEditable(false);
+ _envs.setEditable(false);
+ }
+ }
+
+ void show(ServerDescriptor descriptor, final java.util.Map[] variables)
+ {
+ //
+ // Can't edit with substitutions
+ //
+ if(variables != null)
+ {
+ assert(!_editable);
+ }
+
+ //
+ // Unfortunately this does not resize the panel;
+ // not a big deal for just one line
+ //
+ if(descriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)descriptor;
+ _endpoints.setText(
+ Utils.substituteVariables(iceBoxDescriptor.endpoints, variables));
+ _endpointsLabel.setEnabled(true);
+ _endpoints.setEnabled(true);
+ }
+ else
+ {
+ _endpoints.setText("");
+ _endpointsLabel.setEnabled(false);
+ _endpoints.setEnabled(false);
+ }
+
+ _name.setText(
+ Utils.substituteVariables(descriptor.name, variables));
+
+ Ice.StringHolder toolTipHolder = new Ice.StringHolder();
+
+ Utils.Stringifier propertyStringifier = new Utils.Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)obj;
+ return Utils.substituteVariables(pd.name, variables)
+ + "="
+ + Utils.substituteVariables(pd.value, variables);
+ }
+ };
+
+ _properties.setText(Utils.stringify(descriptor.properties, propertyStringifier,
+ ", ", toolTipHolder));
+ _properties.setToolTipText(toolTipHolder.value);
+
+ _comment.setText(
+ Utils.substituteVariables(descriptor.comment, variables));
+ _exe.setText(
+ Utils.substituteVariables(descriptor.exe, variables));
+
+ Utils.Stringifier eltStringifier = new Utils.Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ return Utils.substituteVariables((String)obj, variables);
+ }
+ };
+
+
+ _options.setText(Utils.stringify(
+ java.util.Arrays.asList(descriptor.options),
+ eltStringifier,
+ " ", toolTipHolder));
+ _options.setToolTipText(toolTipHolder.value);
+
+ _envs.setText(Utils.stringify(
+ java.util.Arrays.asList(descriptor.envs),
+ eltStringifier,
+ " ", toolTipHolder));
+ _envs.setToolTipText(toolTipHolder.value);
+
+ _activation.setText(
+ Utils.substituteVariables(descriptor.activation, variables));
+ }
+
+
+ ServerDescriptorEditor(boolean editable)
+ {
+ _editable = editable;
+ }
+
+ //
+ // Editor or simple read-only renderer?
+ //
+ private boolean _editable;
+
+ //
+ // ComponentDescriptor
+ //
+ private JTextField _name = new JTextField(20);
+ private JTextField _properties = new JTextField(20);
+ private JTextArea _comment = new JTextArea(3, 20);
+
+ //
+ // ServerDescriptor
+ //
+ private JTextField _exe = new JTextField(20);
+ private JTextField _pwd = new JTextField(20);
+ private JTextField _options = new JTextField(20);
+ private JTextField _envs = new JTextField(20);
+
+ private JTextField _activation = new JTextField("20");
+
+ //
+ // IceBoxDescriptor
+ //
+ private JLabel _endpointsLabel = new JLabel("IceBox Endpoints");
+ private JTextField _endpoints = new JTextField(20);
+};
diff --git a/java/src/IceGrid/TreeNode/ServerDescriptorRenderer.java b/java/src/IceGrid/TreeNode/ServerDescriptorRenderer.java
deleted file mode 100755
index 6aa8b8e5bdd..00000000000
--- a/java/src/IceGrid/TreeNode/ServerDescriptorRenderer.java
+++ /dev/null
@@ -1,165 +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.ServerDescriptor;
-import IceGrid.IceBoxDescriptor;
-import IceGrid.PropertyDescriptor;
-import IceGrid.Utils;
-
-import javax.swing.JTextField;
-import javax.swing.JTextArea;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-class ServerDescriptorRenderer
-{
- void build(DefaultFormBuilder builder)
- {
- builder.appendSeparator("Server Descriptor");
- builder.append("Name");
- builder.append(_name, 3);
- builder.nextLine();
- builder.append("Properties");
- builder.append(_properties, 3);
- builder.nextLine();
- builder.append("Comment");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_comment);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
- builder.append("Command");
- builder.append(_exe, 3);
- builder.nextLine();
- builder.append("Command Arguments");
- builder.append(_options, 3);
- builder.nextLine();
- builder.append("Working Directory");
- builder.append(_pwd, 3);
- builder.nextLine();
- builder.append("Interpreter");
- builder.append(_interpreter, 3);
- builder.nextLine();
- builder.append("Interpreter Options");
- builder.append(_interpreterOptions, 3);
- builder.nextLine();
- builder.append("Environment Variables");
- builder.append(_envs, 3);
- builder.nextLine();
- builder.append("Activation Mode");
- builder.append(_activation, 3);
- builder.nextLine();
- builder.append(_endpointsLabel);
- builder.append(_endpoints, 3);
-
- //
- // Make every component non-editable (they are just for show)
- //
- _name.setEditable(false);
- _properties.setEditable(false);
- _comment.setEditable(false);
- _comment.setOpaque(false);
- _exe.setEditable(false);
- _options.setEditable(false);
- _pwd.setEditable(false);
- _interpreter.setEditable(false);
- _interpreterOptions.setEditable(false);
- _envs.setEditable(false);
- _activation.setEditable(false);
- _endpoints.setEditable(false);
- }
-
- void showDescriptor(ServerDescriptor descriptor)
- {
- //
- // Unfortunately this does not resize the panel;
- // not a big deal for just one line
- //
- if(descriptor instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)descriptor;
- _endpoints.setText(iceBoxDescriptor.endpoints);
- _endpointsLabel.setVisible(true);
- _endpoints.setVisible(true);
- }
- else
- {
- _endpointsLabel.setVisible(false);
- _endpoints.setVisible(false);
- }
-
- _name.setText(descriptor.name);
-
- Ice.StringHolder toolTipHolder = new Ice.StringHolder();
-
- Utils.Stringifier propertyStringifier = new Utils.Stringifier()
- {
- public String toString(Object obj)
- {
- PropertyDescriptor pd = (PropertyDescriptor)obj;
- return pd.name + "=" + pd.value;
- }
- };
-
- _properties.setText(Utils.stringify(descriptor.properties, propertyStringifier,
- ", ", toolTipHolder));
- _properties.setToolTipText(toolTipHolder.value);
-
- _comment.setText(descriptor.comment);
- _exe.setText(descriptor.exe);
-
- _options.setText(Utils.stringify(descriptor.options, " ", toolTipHolder));
- _options.setToolTipText(toolTipHolder.value);
-
- _interpreter.setText(descriptor.interpreter);
-
- _interpreterOptions.setText(Utils.stringify(descriptor.interpreterOptions, " ", toolTipHolder));
- _interpreterOptions.setToolTipText(toolTipHolder.value);
-
-
- _envs.setText(Utils.stringify(descriptor.envs, " ", toolTipHolder));
- _envs.setToolTipText(toolTipHolder.value);
-
- _activation.setText(descriptor.activation);
- }
-
- //
- // ComponentDescriptor
- //
- private JTextField _name = new JTextField(20);
- private JTextField _variables = new JTextField(20);
- private JTextField _properties = new JTextField(20);
- private JTextArea _comment = new JTextArea(3, 20);
-
- //
- // ServerDescriptor
- //
- private JTextField _exe = new JTextField(20);
- private JTextField _pwd = new JTextField(20);
- private JTextField _options = new JTextField(20);
- private JTextField _interpreter = new JTextField(20);
- private JTextField _interpreterOptions = new JTextField(20);
- private JTextField _envs = new JTextField(20);
- private JTextField _activation = new JTextField(20);
-
- //
- // IceBoxDescriptor
- //
- private JLabel _endpointsLabel = new JLabel("IceBox Endpoints");
- private JTextField _endpoints = new JTextField(20);
-};
diff --git a/java/src/IceGrid/TreeNode/ServerInstance.java b/java/src/IceGrid/TreeNode/ServerInstance.java
index c3e1a6cc4c6..a08ff349679 100755
--- a/java/src/IceGrid/TreeNode/ServerInstance.java
+++ b/java/src/IceGrid/TreeNode/ServerInstance.java
@@ -10,36 +10,43 @@ 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.JTextField;
+import javax.swing.Action;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
import javax.swing.JTextField;
-import javax.swing.JComboBox;
-import javax.swing.JButton;
import javax.swing.JToggleButton;
+import javax.swing.JTree;
+import javax.swing.UIManager;
+import javax.swing.tree.DefaultTreeCellRenderer;
-import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.layout.Sizes;
+import com.jgoodies.forms.util.LayoutStyle;
+import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
-import IceGrid.TreeModelI;
import IceGrid.IceBoxDescriptor;
+import IceGrid.Model;
+import IceGrid.TemplateDescriptor;
+import IceGrid.TreeModelI;
+import IceGrid.ServerDescriptor;
+import IceGrid.ServerDynamicInfo;
import IceGrid.ServerInstanceDescriptor;
import IceGrid.ServerState;
-import IceGrid.TemplateDescriptor;
import IceGrid.Utils;
-import IceGrid.Model;
-import IceGrid.ServerDynamicInfo;
class ServerInstance extends Parent
{
@@ -53,64 +60,53 @@ class ServerInstance extends Parent
//
// Build everything using JGoodies's DefaultFormBuilder
//
- FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
+ FormLayout layout = new FormLayout(
+ "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.setBorder(Borders.DLU2_BORDER);
builder.setRowGroupingEnabled(true);
- builder.appendSeparator("Server Instance Descriptor");
+
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ //
+ // Type combox box
+ //
+ builder.append("Type");
+ builder.append(_type, 3);
+ builder.nextLine();
- builder.append("Node");
- builder.append(_node, 3);
+ //
+ // Template combox box
+ //
+ builder.append(_templateLabel, _template, _templateButton);
builder.nextLine();
- AbstractAction gotoTemplate = new AbstractAction("->")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(_server != null)
- {
- CommonBase parent = _server.getParent(TreeModelI.APPLICATION_VIEW);
- if(parent != null)
- {
- Application app = (Application)parent.getParent(TreeModelI.APPLICATION_VIEW);
- if(app != null)
- {
- ServerTemplate template = app.findServerTemplate(_template.getText());
- if(template != null)
- {
- _server.getModel().getTreeNodeSelector().selectNode(
- template.getPath(TreeModelI.APPLICATION_VIEW),
- TreeModelI.APPLICATION_VIEW);
- }
- }
- }
- }
- }
- };
- gotoTemplate.putValue(Action.SHORT_DESCRIPTION, "Goto this template");
-
-
- builder.append("Template", _template);
- builder.append(new JButton(gotoTemplate));
+ //
+ // Parameters
+ //
+ builder.append(_parameterValuesLabel, _parameterValues, _parameterValuesButton);
builder.nextLine();
- builder.append("Parameters", _parameterValues);
- builder.append(new JButton("..."));
+ builder.setLineGapSize(LayoutStyle.getCurrent().getParagraphPad());
+
+ //
+ // Node combo box
+ //
+ builder.append("Node");
+ builder.append(_node, _nodeButton);
builder.nextLine();
-
- _myDescriptor = new JComboBox();
- _myDescriptor.addItem("");
- _myDescriptor.addItem("ServerDescriptor");
- _myDescriptor.addItem("IceBoxDescriptor");
- builder.append("My Descriptor", _myDescriptor);
- builder.append(new JToggleButton("Edit"));
-
+
+ //
+ // Targets field
+ //
builder.append("Targets");
+ _targets.setToolTipText("XML-descriptor targets used to deploy this server");
builder.append(_targets, 3);
_targets.setEditable(false);
builder.nextLine();
- _serverDescriptorRenderer.build(builder);
+
+ _serverDescriptorEditor.build(builder);
_scrollPane = new JScrollPane(builder.getPanel(),
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
@@ -124,32 +120,197 @@ class ServerInstance extends Parent
{
_server = server;
ServerInstanceDescriptor descriptor = server.getDescriptor();
- _template.setText(descriptor.template);
- _node.setText(descriptor.node);
-
+
+ _node.setModel(_server.getModel().getNodeViewRoot().getComboBoxModel());
+ _node.setSelectedItem(_server.getParent(TreeModelI.NODE_VIEW));
+
+ ServerDescriptor serverDescriptor = null;
Ice.StringHolder toolTipHolder = new Ice.StringHolder();
-
- _parameterValues.setText(Utils.stringify(descriptor.parameterValues, "=",
- ", ", toolTipHolder));
- _parameterValues.setToolTipText(toolTipHolder.value);
+
+ java.util.Map[] variables = null;
+
+ if(descriptor.template.length() == 0)
+ {
+ serverDescriptor = descriptor.descriptor;
+ if(_server.getModel().substituteVariables())
+ {
+ variables = new java.util.Map[] {
+ server.getNodeVariables(),
+ server.getApplication().getVariables()};
+ }
+
+ if(serverDescriptor instanceof IceBoxDescriptor)
+ {
+ _type.setSelectedIndex(ICEBOX);
+ }
+ else
+ {
+ _type.setSelectedIndex(PLAIN_SERVER);
+ }
+
+ _templateLabel.setEnabled(false);
+ _template.setEnabled(false);
+ _template.setModel(new DefaultComboBoxModel());
+ _template.setSelectedItem(null);
+ _templateButton.setEnabled(false);
+
+ _parameterValuesLabel.setEnabled(false);
+ _parameterValues.setEnabled(false);
+ _parameterValues.setText("");
+ _parameterValues.setToolTipText(null);
+ _parameterValuesButton.setEnabled(false);
+ }
+ else
+ {
+ _type.setSelectedIndex(TEMPLATE_INSTANCE);
+
+ _templateLabel.setEnabled(true);
+ _template.setEnabled(true);
+ _templateButton.setEnabled(true);
+
+ Application application = _server.getApplication();
+
+ TemplateDescriptor templateDescriptor =
+ application.findServerTemplateDescriptor(descriptor.template);
+
+ _template.setModel(application.getServerTemplates().getComboBoxModel());
+ _template.setSelectedItem(templateDescriptor);
+ serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
+
+ _parameterValuesLabel.setEnabled(true);
+ _parameterValues.setEnabled(true);
+ _parameterValuesButton.setEnabled(true);
+
+ String stringifiedParameterValues;
+ if(_server.getModel().substituteVariables())
+ {
+ java.util.Map substitutedParameters = Utils.substituteVariables(
+ descriptor.parameterValues, _server.getNodeVariables(),
+ application.getVariables());
+
+ stringifiedParameterValues = Utils.stringify(substitutedParameters, "=",
+ ", ", toolTipHolder);
+ _parameterValues.setEditable(false);
+
+ variables = new java.util.Map[]{
+ substitutedParameters,
+ server.getNodeVariables(),
+ application.getVariables()};
+ }
+ else
+ {
+ stringifiedParameterValues = Utils.stringify(descriptor.parameterValues, "=",
+ ", ", toolTipHolder);
+ _parameterValues.setEditable(true);
+ }
+ _parameterValues.setText(stringifiedParameterValues);
+ _parameterValues.setToolTipText(toolTipHolder.value);
+ }
_targets.setText(Utils.stringify(descriptor.targets, ", ", toolTipHolder));
_targets.setToolTipText(toolTipHolder.value);
- _serverDescriptorRenderer.showDescriptor(descriptor.descriptor);
+ _serverDescriptorEditor.show(serverDescriptor, variables);
}
+
+ Editor(boolean editDetails)
+ {
+ _serverDescriptorEditor = new ServerDescriptorEditor(editDetails);
+ //
+ // gotoTemplate action
+ //
+ AbstractAction gotoTemplate = new AbstractAction("->")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ ServerTemplate template = (ServerTemplate)
+ _template.getSelectedItem();
+ if(template != null && _server != null)
+ {
+ _server.getModel().getTreeNodeSelector().
+ selectNode(
+ template.getPath(
+ TreeModelI.APPLICATION_VIEW),
+ TreeModelI.APPLICATION_VIEW);
+ }
+ }
+ };
+ gotoTemplate.putValue(Action.SHORT_DESCRIPTION, "Goto this template");
+ _templateButton = new JButton(gotoTemplate);
+ _parameterValuesButton = new JButton("...");
- private JTextField _node = new JTextField(20);
- private JTextField _template = new JTextField(20);
+ //
+ // 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);
+ }
+
+
+ private final int PLAIN_SERVER = 0;
+ private final int ICEBOX = 1;
+ private final int TEMPLATE_INSTANCE = 2;
+ private String[] _typeList = {"Plain Server", "IceBox Server", "Template Instance"};
+ private JComboBox _type = new JComboBox(_typeList);
+
+ private JLabel _templateLabel = new JLabel("Template");
+ private JComboBox _template = new JComboBox();
+ private JButton _templateButton;
+ private JLabel _parameterValuesLabel = new JLabel("Parameters");
private JTextField _parameterValues = new JTextField(20);
- private JComboBox _myDescriptor;
+ private JButton _parameterValuesButton;
+
+ private JComboBox _node = new JComboBox();
+ private JButton _nodeButton;
+
private JTextField _targets = new JTextField(20);
- private ServerDescriptorRenderer _serverDescriptorRenderer =
- new ServerDescriptorRenderer();
+ private ServerDescriptorEditor _serverDescriptorEditor;
private ServerInstance _server;
-
private JScrollPane _scrollPane;
}
@@ -203,18 +364,38 @@ class ServerInstance extends Parent
return _popup;
}
- public void displayProperties(SimpleInternalFrame frame, int view)
+ public void displayProperties()
{
- frame.setTitle("Properties for " + _id);
+ SimpleInternalFrame propertiesFrame = _model.getPropertiesFrame();
+
+ propertiesFrame.setTitle("Properties for " + _id);
- if(_editor == null)
+ //
+ // Pick the appropriate editor
+ //
+ Editor editor = null;
+ if(_descriptor.template.length() > 0 || _model.substituteVariables())
+ {
+ if(_editor == null)
+ {
+ _editor = new Editor(false);
+ }
+
+ editor = _editor;
+ }
+ else
{
- _editor = new Editor();
+ if(_fullEditor == null)
+ {
+ _fullEditor = new Editor(true);
+ }
+ editor = _fullEditor;
}
- _editor.show(this);
- frame.setContent(_editor.getComponent());
- frame.validate();
- frame.repaint();
+
+ editor.show(this);
+ propertiesFrame.setContent(editor.getComponent());
+ propertiesFrame.validate();
+ propertiesFrame.repaint();
}
@@ -236,11 +417,16 @@ class ServerInstance extends Parent
_icons = new Icon[7];
_icons[0] = Utils.getIcon("/icons/unknown.png");
_icons[ServerState.Inactive.value() + 1] = Utils.getIcon("/icons/inactive.png");
- _icons[ServerState.Activating.value() + 1] = Utils.getIcon("/icons/activating.png");
- _icons[ServerState.Active.value() + 1] = Utils.getIcon("/icons/active.png");
- _icons[ServerState.Deactivating.value() + 1] = Utils.getIcon("/icons/deactivating.png");
- _icons[ServerState.Destroying.value() + 1] = Utils.getIcon("/icons/destroying.png");
- _icons[ServerState.Destroyed.value() + 1] = Utils.getIcon("/icons/destroyed.png");
+ _icons[ServerState.Activating.value() + 1] =
+ Utils.getIcon("/icons/activating.png");
+ _icons[ServerState.Active.value() + 1] =
+ Utils.getIcon("/icons/active.png");
+ _icons[ServerState.Deactivating.value() + 1] =
+ Utils.getIcon("/icons/deactivating.png");
+ _icons[ServerState.Destroying.value() + 1] =
+ Utils.getIcon("/icons/destroying.png");
+ _icons[ServerState.Destroyed.value() + 1] =
+ Utils.getIcon("/icons/destroyed.png");
}
//
@@ -264,13 +450,13 @@ class ServerInstance extends Parent
//
// Builds the server instance and all its sub-tree
//
- ServerInstance(ServerInstanceDescriptor descriptor,
- Model model,
+ ServerInstance(String serverName,
+ ServerInstanceDescriptor descriptor,
+ Application application,
boolean fireNodeViewEvent)
{
- super(descriptor.descriptor.name, model);
-
- rebuild(descriptor, fireNodeViewEvent);
+ super(serverName, application.getModel());
+ rebuild(application, descriptor, fireNodeViewEvent);
}
@@ -300,7 +486,8 @@ class ServerInstance extends Parent
//
// Update the server instance and all its subtree
//
- void rebuild(ServerInstanceDescriptor newDescriptor,
+ void rebuild(Application application,
+ ServerInstanceDescriptor newDescriptor,
boolean fireNodeViewEvent)
{
assert(newDescriptor != null);
@@ -333,28 +520,57 @@ class ServerInstance extends Parent
Node node = _model.getNodeViewRoot().findNode(_descriptor.node);
- if(_descriptor.descriptor instanceof IceBoxDescriptor)
+ java.util.Map appVariables = application.getVariables();
+ _nodeVariables =
+ application.getNodeVariables(_descriptor.node); // can be null
+ java.util.Map parameters = null;
+ ServerDescriptor serverDescriptor = null;
+ boolean editable = false;
+
+ if(_descriptor.template.length() > 0)
{
- _iceBoxDescriptor = (IceBoxDescriptor)_descriptor.descriptor;
+ TemplateDescriptor templateDescriptor =
+ application.findServerTemplateDescriptor(_descriptor.template);
+ serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
+ parameters = Utils.substituteVariables(_descriptor.parameterValues,
+ _nodeVariables, appVariables);
+ }
+ else
+ {
+ serverDescriptor = _descriptor.descriptor;
+ editable = true;
+ }
+
+ if(serverDescriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)serverDescriptor;
//
// We need to pass the node to register the adapters
//
- _serviceInstances = new ServiceInstances(_iceBoxDescriptor.services,
- _model, node);
+ _serviceInstances = new ServiceInstances(iceBoxDescriptor.services,
+ editable,
+ application,
+ _nodeVariables,
+ parameters,
+ node);
addChild(_serviceInstances);
_serviceInstances.addParent(this); // no-op when newNode == true
}
- else
- {
- _iceBoxDescriptor = null;
- }
- _adapters = new Adapters(_descriptor.descriptor.adapters, _model, node);
+ java.util.Map[] variables = new java.util.Map[3];
+ variables[0] = parameters;
+ variables[1] = _nodeVariables;
+ variables[2] = appVariables;
+
+ _adapters = new Adapters(serverDescriptor.adapters,
+ editable, variables,
+ _model, node);
addChild(_adapters);
_adapters.addParent(this); // no-op when newNode == true
- _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model, false);
+ _dbEnvs = new DbEnvs(serverDescriptor.dbEnvs,
+ editable, variables, _model);
addChild(_dbEnvs);
_dbEnvs.addParent(this); // no-op when newNode == true
@@ -408,11 +624,13 @@ class ServerInstance extends Parent
}
catch(IceGrid.NodeUnreachableException e)
{
- _model.getStatusBar().setText("Could not reach the node for server '" + _id + "'.");
+ _model.getStatusBar().setText("Could not reach the node for server '" + _id
+ + "'.");
}
catch(Ice.LocalException e)
{
- _model.getStatusBar().setText("Starting server '" + _id + "'... failed: " + e.toString());
+ _model.getStatusBar().setText("Starting server '" + _id + "'... failed: "
+ + e.toString());
}
if(started)
{
@@ -437,11 +655,13 @@ class ServerInstance extends Parent
}
catch(IceGrid.NodeUnreachableException e)
{
- _model.getStatusBar().setText("Could not reach the node for server '" + _id + "'.");
+ _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 + "'... failed: "
+ + e.toString());
}
_model.getStatusBar().setText("Stopping server '" + _id + "'... done.");
}
@@ -456,7 +676,19 @@ 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()
{
String result = _descriptor.descriptor.name;
@@ -487,9 +719,8 @@ class ServerInstance extends Parent
private String _toolTip = toolTip(_state, _pid);
private ServerInstanceDescriptor _descriptor;
- private TemplateDescriptor _templateDescriptor;
- private IceBoxDescriptor _iceBoxDescriptor;
-
+ private java.util.Map _nodeVariables;
+
//
// Children
//
@@ -500,6 +731,8 @@ class ServerInstance extends Parent
static private DefaultTreeCellRenderer _cellRenderer;
static private Icon[] _icons;
static private PopupMenu _popup;
- static private Editor _editor;
+
+ static private Editor _fullEditor; // writable server descriptor
+ static private Editor _editor; // read-only server descriptor
}
diff --git a/java/src/IceGrid/TreeNode/ServerInstances.java b/java/src/IceGrid/TreeNode/ServerInstances.java
index 6477f03d4e9..c00c6bfcae3 100755
--- a/java/src/IceGrid/TreeNode/ServerInstances.java
+++ b/java/src/IceGrid/TreeNode/ServerInstances.java
@@ -8,16 +8,20 @@
// **********************************************************************
package IceGrid.TreeNode;
-import IceGrid.ServerInstanceDescriptor;
import IceGrid.Model;
+import IceGrid.ServerInstanceDescriptor;
+import IceGrid.TemplateDescriptor;
+import IceGrid.TreeModelI;
+import IceGrid.Utils;
+
class ServerInstances extends Parent
{
ServerInstances(java.util.List descriptors,
- Model model,
+ Application application,
boolean fireEvent)
{
- super("Server instances", model);
+ super("Server instances", application.getModel());
_descriptors = descriptors;
java.util.Iterator p = _descriptors.iterator();
@@ -29,20 +33,25 @@ class ServerInstances extends Parent
//
ServerInstanceDescriptor descriptor =
(ServerInstanceDescriptor)p.next();
+
+ String serverName = computeServerName(descriptor, application);
- ServerInstance child = new ServerInstance(descriptor,
- _model,
+ ServerInstance child = new ServerInstance(serverName,
+ descriptor,
+ application,
fireEvent);
addChild(child);
}
}
- void update(java.util.List descriptors, String[] removeServers)
+ 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
//
@@ -59,18 +68,21 @@ class ServerInstances extends Parent
java.util.Vector newChildren = new java.util.Vector();
java.util.Vector updatedChildren = new java.util.Vector();
- java.util.Iterator p = descriptors.iterator();
+ java.util.Iterator p = updates.iterator();
while(p.hasNext())
{
ServerInstanceDescriptor descriptor = (ServerInstanceDescriptor)p.next();
- ServerInstance child = (ServerInstance)findChild(descriptor.descriptor.name);
+
+ String serverName = computeServerName(descriptor, application);
+
+ ServerInstance child = (ServerInstance)findChild(serverName);
if(child == null)
{
- newChildren.add(new ServerInstance(descriptor, _model, true));
+ newChildren.add(new ServerInstance(serverName, descriptor, application, true));
}
else
{
- child.rebuild(descriptor, true);
+ child.rebuild(application, descriptor, true);
updatedChildren.add(child);
}
}
@@ -90,5 +102,37 @@ class ServerInstances extends Parent
}
+ 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/ServerTemplate.java b/java/src/IceGrid/TreeNode/ServerTemplate.java
index a195ece99a7..e571ccceacb 100755
--- a/java/src/IceGrid/TreeNode/ServerTemplate.java
+++ b/java/src/IceGrid/TreeNode/ServerTemplate.java
@@ -8,19 +8,52 @@
// **********************************************************************
package IceGrid.TreeNode;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.JToggleButton;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
+
import IceGrid.IceBoxDescriptor;
-import IceGrid.TemplateDescriptor;
import IceGrid.Model;
+import IceGrid.ServerDescriptor;
+import IceGrid.TemplateDescriptor;
+import IceGrid.TreeModelI;
+import IceGrid.ServerDynamicInfo;
+import IceGrid.TemplateDescriptor;
+import IceGrid.Utils;
+
class ServerTemplate extends Parent
{
- ServerTemplate(String name, Model model, TemplateDescriptor descriptor)
+
+ //
+ // Application is needed to lookup service templates
+ //
+ ServerTemplate(String name, TemplateDescriptor descriptor, Application application)
{
- super(name, model);
- rebuild(descriptor);
+ super(name, application.getModel());
+ rebuild(descriptor, application);
}
- void rebuild(TemplateDescriptor descriptor)
+ void rebuild(TemplateDescriptor descriptor, Application application)
{
_descriptor = descriptor;
clearChildren();
@@ -34,7 +67,7 @@ class ServerTemplate extends Parent
{
_iceBoxDescriptor = (IceBoxDescriptor)_descriptor.descriptor;
- _serviceInstances = new ServiceInstances(_iceBoxDescriptor.services, _model, null);
+ _serviceInstances = new ServiceInstances(_iceBoxDescriptor.services, application);
addChild(_serviceInstances);
}
else
@@ -43,10 +76,10 @@ class ServerTemplate extends Parent
_iceBoxDescriptor = null;
}
- _adapters = new Adapters(_descriptor.descriptor.adapters, _model, null);
+ _adapters = new Adapters(_descriptor.descriptor.adapters, _model);
addChild(_adapters);
- _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model, true);
+ _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model);
addChild(_dbEnvs);
}
@@ -56,6 +89,11 @@ class ServerTemplate extends Parent
return templateLabel(_id, _descriptor.parameters);
}
+ public TemplateDescriptor getDescriptor()
+ {
+ return _descriptor;
+ }
+
private TemplateDescriptor _descriptor;
private IceBoxDescriptor _iceBoxDescriptor;
diff --git a/java/src/IceGrid/TreeNode/ServerTemplates.java b/java/src/IceGrid/TreeNode/ServerTemplates.java
index 3c59b50620a..d469af44e60 100755
--- a/java/src/IceGrid/TreeNode/ServerTemplates.java
+++ b/java/src/IceGrid/TreeNode/ServerTemplates.java
@@ -8,14 +8,15 @@
// **********************************************************************
package IceGrid.TreeNode;
-import IceGrid.TemplateDescriptor;
import IceGrid.Model;
+import IceGrid.TemplateDescriptor;
+import IceGrid.TreeModelI;
class ServerTemplates extends Parent
{
- ServerTemplates(java.util.Map descriptors, Model model)
+ ServerTemplates(java.util.Map descriptors, Application application)
{
- super("Server templates", model);
+ super("Server templates", application.getModel());
_descriptors = descriptors;
@@ -24,17 +25,20 @@ class ServerTemplates extends Parent
while(p.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- addChild(new ServerTemplate((String)entry.getKey(), _model,
- (TemplateDescriptor)entry.getValue()));
+ addChild(new ServerTemplate((String)entry.getKey(),
+ (TemplateDescriptor)entry.getValue(),
+ application));
}
}
- void update(java.util.Map descriptors, String[] removeTemplates)
+ void update(java.util.Map updates, String[] removeTemplates)
{
//
// Note: _descriptors is updated by Application
//
+ Application application = (Application)getParent(TreeModelI.APPLICATION_VIEW);
+
//
// One big set of removes
//
@@ -46,7 +50,7 @@ class ServerTemplates extends Parent
java.util.Vector newChildren = new java.util.Vector();
java.util.Vector updatedChildren = new java.util.Vector();
- java.util.Iterator p = descriptors.entrySet().iterator();
+ java.util.Iterator p = updates.entrySet().iterator();
while(p.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
@@ -55,11 +59,11 @@ class ServerTemplates extends Parent
ServerTemplate child = (ServerTemplate)findChild(name);
if(child == null)
{
- newChildren.add(new ServerTemplate(name, _model, templateDescriptor));
+ newChildren.add(new ServerTemplate(name, templateDescriptor, application));
}
else
{
- child.rebuild(templateDescriptor);
+ child.rebuild(templateDescriptor, application);
updatedChildren.add(child);
}
}
diff --git a/java/src/IceGrid/TreeNode/ServiceInstance.java b/java/src/IceGrid/TreeNode/ServiceInstance.java
index 0ac0c8e7f36..bbbed0d74f1 100755
--- a/java/src/IceGrid/TreeNode/ServiceInstance.java
+++ b/java/src/IceGrid/TreeNode/ServiceInstance.java
@@ -8,22 +8,73 @@
// **********************************************************************
package IceGrid.TreeNode;
+import IceGrid.Model;
+import IceGrid.ServiceDescriptor;
import IceGrid.ServiceInstanceDescriptor;
import IceGrid.TemplateDescriptor;
-import IceGrid.Model;
+
class ServiceInstance extends Parent
{
- ServiceInstance(ServiceInstanceDescriptor descriptor, Model model, Node node)
+ ServiceInstance(String id,
+ String displayString,
+ ServiceInstanceDescriptor descriptor,
+ ServiceDescriptor serviceDescriptor,
+ boolean editable, // False when the enclosing server instance
+ // is a template-instance
+ java.util.Map serverParameters, // When the enclosing server instance
+ // is a template instance,
+ // this server's parameters (substituted);
+ // null otherwise
+ java.util.Map myParameters, // When this is a template instance within
+ // a server instance, descriptor.parameterValues
+ // substituted using parameters + variables
+ java.util.Map nodeVariables,
+ java.util.Map appVariables,
+ Model model,
+ Node node)
{
- super(descriptor.descriptor.name, model);
+ super(id, model);
+ _displayString = displayString;
_descriptor = descriptor;
-
- _adapters = new Adapters(_descriptor.descriptor.adapters, _model, node);
- addChild(_adapters);
+ _editable = editable;
+
+ if(serviceDescriptor != null)
+ {
+ boolean childrenEditable = _editable && (descriptor.template.length() == 0);
+
+ //
+ // For the children, the proper parameters can be used as variables.
+ // Note that the fields of the service-instance itself should be
+ // substituted with parameters (if any) + variables.
+ //
+ java.util.Map[] variables = null;
+ if(node != null)
+ {
+ variables = new java.util.Map[3];
+ if(myParameters != null)
+ {
+ variables[0] = myParameters;
+ assert(descriptor.template.length() > 0);
+ }
+ else
+ {
+ variables[0] = serverParameters;
+ assert(descriptor.template.length() == 0);
+ }
+ variables[1] = nodeVariables;
+ variables[2] = appVariables;
+ }
- _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model, false);
- addChild(_dbEnvs);
+ _adapters = new Adapters(serviceDescriptor.adapters,
+ childrenEditable,
+ variables, _model, node);
+ addChild(_adapters);
+
+ _dbEnvs = new DbEnvs(serviceDescriptor.dbEnvs, childrenEditable,
+ variables, _model);
+ addChild(_dbEnvs);
+ }
}
void unregisterAdapters()
@@ -33,17 +84,19 @@ class ServiceInstance extends Parent
public String toString()
{
- String result = _descriptor.descriptor.name;
-
- if(!_descriptor.template.equals(""))
+ if(_displayString != null)
+ {
+ return _displayString;
+ }
+ else
{
- result += ": " + templateLabel(_descriptor.template,
- _descriptor.parameterValues.values());
+ return _id;
}
- return result;
}
private ServiceInstanceDescriptor _descriptor;
+ private String _displayString;
+ private boolean _editable;
private Adapters _adapters;
private DbEnvs _dbEnvs;
}
diff --git a/java/src/IceGrid/TreeNode/ServiceInstances.java b/java/src/IceGrid/TreeNode/ServiceInstances.java
index 40c2934442d..0d6ebbddaea 100755
--- a/java/src/IceGrid/TreeNode/ServiceInstances.java
+++ b/java/src/IceGrid/TreeNode/ServiceInstances.java
@@ -8,14 +8,33 @@
// **********************************************************************
package IceGrid.TreeNode;
-import IceGrid.ServiceInstanceDescriptor;
import IceGrid.Model;
+import IceGrid.ServiceDescriptor;
+import IceGrid.ServiceInstanceDescriptor;
+import IceGrid.TemplateDescriptor;
+import IceGrid.Utils;
class ServiceInstances extends Parent
{
- ServiceInstances(java.util.List descriptors, Model model, Node node)
+ //
+ // In server template
+ //
+ ServiceInstances(java.util.List descriptors, Application application)
+ {
+ this(descriptors, true, application, null, null, null);
+ }
+
+ //
+ // In server instance
+ //
+ ServiceInstances(java.util.List descriptors,
+ boolean editable,
+ Application application,
+ java.util.Map nodeVariables,
+ java.util.Map parameters,
+ Node node)
{
- super("Service instances", model);
+ super("Service instances", application.getModel());
_descriptors = descriptors;
java.util.Iterator p = _descriptors.iterator();
@@ -23,7 +42,94 @@ class ServiceInstances extends Parent
{
ServiceInstanceDescriptor descriptor =
(ServiceInstanceDescriptor)p.next();
- addChild(new ServiceInstance(descriptor, _model, node));
+
+ ServiceDescriptor serviceDescriptor = null;
+ String serviceId = null;
+ String displayString = null;
+ java.util.Map substitutedParameters = null;
+
+ if(descriptor.template.length() > 0)
+ {
+ TemplateDescriptor templateDescriptor
+ = application.findServiceTemplateDescriptor(descriptor.template);
+
+ if(templateDescriptor != null)
+ {
+ serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
+ }
+
+ if(node != null) // in server instance
+ {
+ //
+ // Substitute parameter values with variables + parameters,
+ // then use variables + these substituted parameter
+ // values on the serviceDescriptor
+ //
+
+ substitutedParameters =
+ Utils.substituteVariables(descriptor.parameterValues,
+ parameters,
+ nodeVariables,
+ application.getVariables());
+
+ if(serviceDescriptor != null)
+ {
+ serviceId = Utils.substituteVariables(serviceDescriptor.name,
+ substitutedParameters,
+ nodeVariables,
+ application.getVariables());
+
+ displayString = serviceId + ": " + templateLabel(descriptor.template,
+ substitutedParameters.values());
+ }
+ else
+ {
+ serviceId = "????: " + templateLabel(descriptor.template,
+ substitutedParameters.values());
+ }
+ }
+ else
+ {
+ //
+ // serviceId = TemplateName<unsubstituted param 1, ....>
+ //
+ serviceId = templateLabel(descriptor.template,
+ descriptor.parameterValues.values());
+ }
+ }
+ else
+ {
+ serviceDescriptor = descriptor.descriptor; // can't be null
+
+ if(node != null) // in server instance
+ {
+ //
+ // Use variables and parameters on this serviceDescriptor
+ //
+
+ serviceId = Utils.substituteVariables(serviceDescriptor.name,
+ parameters,
+ nodeVariables,
+ application.getVariables());
+
+ }
+ else
+ {
+ serviceId = serviceDescriptor.name;
+ }
+ }
+
+ addChild(new ServiceInstance(serviceId,
+ displayString,
+ descriptor,
+ serviceDescriptor,
+ editable,
+ parameters,
+ substitutedParameters,
+ nodeVariables,
+ application.getVariables(),
+ _model,
+ node));
}
}
diff --git a/java/src/IceGrid/TreeNode/ServiceTemplate.java b/java/src/IceGrid/TreeNode/ServiceTemplate.java
index f1846ec462b..613aa2534a9 100755
--- a/java/src/IceGrid/TreeNode/ServiceTemplate.java
+++ b/java/src/IceGrid/TreeNode/ServiceTemplate.java
@@ -13,13 +13,13 @@ import IceGrid.Model;
class ServiceTemplate extends Parent
{
- ServiceTemplate(String name, Model model, TemplateDescriptor descriptor)
+ ServiceTemplate(String name, TemplateDescriptor descriptor, Model model)
{
super(name, model);
rebuild(descriptor);
}
- void rebuild(TemplateDescriptor descriptor)
+ void rebuild(TemplateDescriptor descriptor)
{
_descriptor = descriptor;
clearChildren();
@@ -29,10 +29,10 @@ class ServiceTemplate extends Parent
//
java.util.Collections.sort(_descriptor.parameters);
- _adapters = new Adapters(_descriptor.descriptor.adapters, _model, null);
+ _adapters = new Adapters(_descriptor.descriptor.adapters, _model);
addChild(_adapters);
- _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model, true);
+ _dbEnvs = new DbEnvs(_descriptor.descriptor.dbEnvs, _model);
addChild(_dbEnvs);
}
diff --git a/java/src/IceGrid/TreeNode/ServiceTemplates.java b/java/src/IceGrid/TreeNode/ServiceTemplates.java
index aaf1609b4a1..693b678d30e 100755
--- a/java/src/IceGrid/TreeNode/ServiceTemplates.java
+++ b/java/src/IceGrid/TreeNode/ServiceTemplates.java
@@ -24,8 +24,9 @@ class ServiceTemplates extends Parent
while(p.hasNext())
{
java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- addChild(new ServiceTemplate((String)entry.getKey(), _model,
- (TemplateDescriptor)entry.getValue()));
+ addChild(new ServiceTemplate((String)entry.getKey(),
+ (TemplateDescriptor)entry.getValue(),
+ _model));
}
}
@@ -55,7 +56,7 @@ class ServiceTemplates extends Parent
ServiceTemplate child = (ServiceTemplate)findChild(name);
if(child == null)
{
- newChildren.add(new ServiceTemplate(name, _model, templateDescriptor));
+ newChildren.add(new ServiceTemplate(name, templateDescriptor, _model));
}
else
{
diff --git a/java/src/IceGrid/Utils.java b/java/src/IceGrid/Utils.java
index e93d96e471b..bc0ba63323e 100755
--- a/java/src/IceGrid/Utils.java
+++ b/java/src/IceGrid/Utils.java
@@ -99,4 +99,136 @@ public class Utils
return stringify(stringMap.entrySet(), stringifier, separator, toolTipHolder);
}
+
+ //
+ // Same algorithm as DescriptorVariables::substituteImpl (see IceGrid C++)
+ //
+ static public String substituteVariables(String input, java.util.Map[] stringMaps)
+ {
+ if(stringMaps == 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 subsitute anything else
+ //
+ return input;
+ }
+
+ String name = input.substring(beg + 2, end);
+
+ //
+ // Lookup name's value
+ //
+ String val = null;
+ for(int i = 0; i < stringMaps.length; ++i)
+ {
+ if(stringMaps[i] != null)
+ {
+ val = (String)stringMaps[i].get(name);
+ if(val != null)
+ {
+ break; // for
+ }
+ }
+ }
+
+ 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;
+ }
+
+ static public String substituteVariables(String input, java.util.Map m1)
+ {
+ return substituteVariables(input,
+ new java.util.Map[]{m1});
+ }
+
+ static public String substituteVariables(String input, java.util.Map m1,
+ java.util.Map m2)
+ {
+ return substituteVariables(input,
+ new java.util.Map[]{m1, m2});
+ }
+
+ static public String substituteVariables(String input, java.util.Map m1,
+ java.util.Map m2, java.util.Map m3)
+ {
+ return substituteVariables(input,
+ new java.util.Map[]{m1, m2, m3});
+ }
+
+ static public java.util.Map substituteVariables(java.util.Map input,
+ java.util.Map[] stringMaps)
+ {
+ java.util.Map result = new java.util.HashMap();
+
+ java.util.Iterator p = input.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ result.put(entry.getKey(),
+ substituteVariables((String)entry.getValue(), stringMaps));
+ }
+
+ return result;
+ }
+
+
+ static public java.util.Map substituteVariables(java.util.Map input,
+ java.util.Map m1,
+ java.util.Map m2)
+ {
+ return substituteVariables(input,
+ new java.util.Map[]{m1, m2});
+ }
+
+ static public java.util.Map substituteVariables(java.util.Map input,
+ java.util.Map m1,
+ java.util.Map m2,
+ java.util.Map m3)
+ {
+ return substituteVariables(input,
+ new java.util.Map[]{m1, m2, m3});
+ }
}