diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-12-15 00:06:59 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-12-15 00:06:59 +0000 |
commit | 4c60c45b26926d584ed9b1d9f2c83488dd7ee2fd (patch) | |
tree | 13a1cdaf99912daaac31063dbd404d1c923ba13f /java/src | |
parent | Fix (diff) | |
download | ice-4c60c45b26926d584ed9b1d9f2c83488dd7ee2fd.tar.bz2 ice-4c60c45b26926d584ed9b1d9f2c83488dd7ee2fd.tar.xz ice-4c60c45b26926d584ed9b1d9f2c83488dd7ee2fd.zip |
Added support for service property sets in icebox server instances
Diffstat (limited to 'java/src')
-rwxr-xr-x | java/src/IceGridGUI/Application/Node.java | 38 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PlainServer.java | 4 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PlainService.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertySet.java | 78 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertySetEditor.java | 91 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertySetParent.java | 3 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/PropertySets.java | 46 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServerInstance.java | 257 | ||||
-rw-r--r-- | java/src/IceGridGUI/Application/ServerInstancePropertySetEditor.java | 67 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServerTemplate.java | 4 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServiceInstance.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/ServiceTemplate.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Application/TreeNode.java | 10 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Server.java | 37 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Service.java | 37 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Utils.java | 22 |
16 files changed, 601 insertions, 99 deletions
diff --git a/java/src/IceGridGUI/Application/Node.java b/java/src/IceGridGUI/Application/Node.java index cbd85fa3261..e4100c23930 100755 --- a/java/src/IceGridGUI/Application/Node.java +++ b/java/src/IceGridGUI/Application/Node.java @@ -785,7 +785,7 @@ class Node extends TreeNode implements PropertySetParent } else { - ps = new PropertySet(false, this, id, psd); + ps = new PropertySet(false, this, id, id, psd); newPropertySets.add(ps); _descriptor.propertySets.put(id, psd); } @@ -1016,8 +1016,9 @@ class Node extends TreeNode implements PropertySetParent while(p.hasNext()) { java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + String id = (String)entry.getKey(); insertPropertySet(new PropertySet(false, this, - (String)entry.getKey(), + id, id, (PropertySetDescriptor)entry.getValue()), false); } @@ -1146,11 +1147,42 @@ class Node extends TreeNode implements PropertySetParent public void tryAdd(String id, PropertySetDescriptor descriptor) throws UpdateFailedException { - insertPropertySet(new PropertySet(true, this, id, descriptor), + insertPropertySet(new PropertySet(true, this, id, id, descriptor), true); _descriptor.propertySets.put(id, descriptor); } + public void tryRename(String oldId, String oldId2, String newId) + throws UpdateFailedException + { + PropertySet oldChild = findPropertySet(oldId); + assert oldChild != null; + removePropertySet(oldChild); + PropertySetDescriptor descriptor = (PropertySetDescriptor)oldChild.getDescriptor(); + + try + { + insertPropertySet( + new PropertySet(true, this, newId, newId, descriptor), + true); + } + catch(UpdateFailedException ex) + { + try + { + insertPropertySet(oldChild, true); + } + catch(UpdateFailedException ufe) + { + assert false; + } + throw ex; + } + + _editable.removeElement(oldId, oldChild.getEditable(), PropertySet.class); + _descriptor.propertySets.remove(oldId); + _descriptor.propertySets.put(newId, descriptor); + } void tryAdd(ServerInstanceDescriptor instanceDescriptor, boolean addDescriptor) throws UpdateFailedException diff --git a/java/src/IceGridGUI/Application/PlainServer.java b/java/src/IceGridGUI/Application/PlainServer.java index 02555521d33..aa96cb4f8c1 100755 --- a/java/src/IceGridGUI/Application/PlainServer.java +++ b/java/src/IceGridGUI/Application/PlainServer.java @@ -346,7 +346,7 @@ class PlainServer extends Communicator implements Server writeOptions(writer, _descriptor.options); writeEnvs(writer, _descriptor.envs); - writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters); + writePropertySet(writer, "", "", _descriptor.propertySet, _descriptor.adapters); writeDistribution(writer, _descriptor.distrib); _adapters.write(writer); @@ -365,7 +365,7 @@ class PlainServer extends Communicator implements Server writeOptions(writer, _descriptor.options); writeEnvs(writer, _descriptor.envs); - writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters); + writePropertySet(writer, _descriptor.propertySet, _descriptor.adapters); writeDistribution(writer, _descriptor.distrib); _adapters.write(writer); diff --git a/java/src/IceGridGUI/Application/PlainService.java b/java/src/IceGridGUI/Application/PlainService.java index bd697e44c91..f4e244b63d4 100755 --- a/java/src/IceGridGUI/Application/PlainService.java +++ b/java/src/IceGridGUI/Application/PlainService.java @@ -264,7 +264,7 @@ class PlainService extends Communicator implements Service, Cloneable writer.writeElement("description", _descriptor.descriptor.description); } - writePropertySet(writer, "", _descriptor.descriptor.propertySet, + writePropertySet(writer, _descriptor.descriptor.propertySet, _descriptor.descriptor.adapters); _adapters.write(writer); _dbEnvs.write(writer); diff --git a/java/src/IceGridGUI/Application/PropertySet.java b/java/src/IceGridGUI/Application/PropertySet.java index b55d9848532..bd0dbd9d274 100755 --- a/java/src/IceGridGUI/Application/PropertySet.java +++ b/java/src/IceGridGUI/Application/PropertySet.java @@ -85,8 +85,15 @@ class PropertySet extends TreeNode if(!_ephemeral) { - parent.removeDescriptor(_id); - parent.getEditable().removeElement(_id, _editable, PropertySet.class); + parent.removeDescriptor(_unsubstitutedId); + if(_editable != null) + { + parent.getEditable().removeElement(_unsubstitutedId, _editable, PropertySet.class); + } + else + { + parent.getEditable().markModified(); + } getRoot().updated(); } } @@ -95,16 +102,31 @@ class PropertySet extends TreeNode { if(_editor == null) { - _editor = (PropertySetEditor)getRoot(). - getEditor(PropertySetEditor.class, this); + if(_inServerInstance) + { + _editor = (PropertySetEditor)getRoot(). + getEditor(ServerInstancePropertySetEditor.class, this); + } + else + { + _editor = (PropertySetEditor)getRoot(). + getEditor(PropertySetEditor.class, this); + } } - _editor.show(this); + _editor.show(_unsubstitutedId, this); return _editor; } protected Editor createEditor() { - return new PropertySetEditor(); + if(_inServerInstance) + { + return new ServerInstancePropertySetEditor(); + } + else + { + return new PropertySetEditor(); + } } public boolean isEphemeral() @@ -112,6 +134,11 @@ class PropertySet extends TreeNode return _ephemeral; } + public String unsubstitutedId() + { + return _unsubstitutedId; + } + Object getDescriptor() { return _descriptor; @@ -130,28 +157,57 @@ class PropertySet extends TreeNode void commit() { - _editable.commit(); + if(_editable != null) + { + _editable.commit(); + } } Editable getEditable() { - return _editable; + if(_editable != null) + { + return _editable; + } + else + { + return ((PropertySetParent)_parent).getEditable(); + } } PropertySet(boolean brandNew, TreeNode parent, String id, + String unsubstitutedId, PropertySetDescriptor descriptor) { super(parent, id); + _unsubstitutedId = unsubstitutedId; + _inServerInstance = (parent instanceof ServerInstance); _ephemeral = false; _editable = new Editable(brandNew); rebuild(descriptor); } + + PropertySet(TreeNode parent, + String id, + String unsubstitutedId, + PropertySetDescriptor descriptor) + { + super(parent, id); + _unsubstitutedId = unsubstitutedId; + _inServerInstance = (parent instanceof ServerInstance); + _ephemeral = false; + _editable = null; + rebuild(descriptor); + } + PropertySet(TreeNode parent, String id, PropertySetDescriptor descriptor) { super(parent, id); + _unsubstitutedId = id; + _inServerInstance = (parent instanceof ServerInstance); _ephemeral = true; _editable = null; rebuild(descriptor); @@ -161,7 +217,9 @@ class PropertySet extends TreeNode { if(!_ephemeral) { - writePropertySet(writer, _id, _descriptor, null); + writePropertySet(writer, _unsubstitutedId, + _inServerInstance ? "service" : "id", + _descriptor, null); } } @@ -171,8 +229,10 @@ class PropertySet extends TreeNode } private PropertySetDescriptor _descriptor; + private String _unsubstitutedId; private final boolean _ephemeral; private final Editable _editable; + private final boolean _inServerInstance; private PropertySetEditor _editor; static private DefaultTreeCellRenderer _cellRenderer; diff --git a/java/src/IceGridGUI/Application/PropertySetEditor.java b/java/src/IceGridGUI/Application/PropertySetEditor.java index a287b1c2645..df75b04b7dc 100755 --- a/java/src/IceGridGUI/Application/PropertySetEditor.java +++ b/java/src/IceGridGUI/Application/PropertySetEditor.java @@ -17,7 +17,7 @@ import javax.swing.Action; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JScrollPane; @@ -50,7 +50,7 @@ class PropertySetEditor extends Editor try { - parent.tryAdd(_id.getText().trim(), descriptor); + parent.tryAdd(getIdText(), descriptor); } catch(UpdateFailedException e) { @@ -79,7 +79,36 @@ class PropertySetEditor extends Editor // Success // _target = ((TreeNode)parent).findChildWithDescriptor(descriptor); - _id.setEditable(false); + root.updated(); + if(refresh) + { + root.setSelectedNode(_target); + } + } + else if(!isSimpleUpdate()) + { + PropertySetDescriptor descriptor = + (PropertySetDescriptor)nps.getDescriptor(); + + try + { + parent.tryRename(_target.getId(), _oldId, getIdText()); + } + catch(UpdateFailedException e) + { + JOptionPane.showMessageDialog( + root.getCoordinator().getMainFrame(), + e.toString(), + "Apply failed", + JOptionPane.ERROR_MESSAGE); + return false; + } + + // + // Success + // + _target = ((TreeNode)parent).findChildWithDescriptor(descriptor); + writeDescriptor(); root.updated(); if(refresh) { @@ -123,12 +152,15 @@ class PropertySetEditor extends Editor PropertySetEditor() { - // - // Associate updateListener with various fields - // - _id.getDocument().addDocumentListener(_updateListener); + this("ID"); _id.setToolTipText("The id of this Property Set"); - + _id.getDocument().addDocumentListener(_updateListener); + } + + protected PropertySetEditor(String label) + { + _idLabel = new JLabel(label); + _propertySets.getDocument().addDocumentListener(_updateListener); _propertySets.setToolTipText("Property Set References"); _properties = new PropertiesField(this); @@ -146,13 +178,13 @@ class PropertySetEditor extends Editor boolean isSimpleUpdate() { - return true; + return getIdText().equals(_oldId); } protected void appendProperties(DefaultFormBuilder builder) { - builder.append("ID" ); - builder.append(_id, 3); + builder.append(_idLabel); + builder.append(getIdComponent(), 3); builder.nextLine(); builder.append("Property Sets"); @@ -184,10 +216,10 @@ class PropertySetEditor extends Editor protected boolean validate() { - return check(new String[]{"ID", _id.getText()}); + return check(new String[]{_idLabel.getText(), getIdText()}); } - void show(PropertySet nps) + void show(String unsubstitutedId, PropertySet nps) { detectUpdates(false); _target = nps; @@ -198,9 +230,9 @@ class PropertySetEditor extends Editor PropertySetDescriptor descriptor = (PropertySetDescriptor)nps.getDescriptor(); - _id.setText(_target.getId()); - _id.setEditable(_target.isEphemeral()); - + showId(unsubstitutedId, resolver); + _oldId = unsubstitutedId; + _propertySets.setList(java.util.Arrays.asList(descriptor.references), resolver); _propertySets.setEditable(isEditable); @@ -213,13 +245,36 @@ class PropertySetEditor extends Editor detectUpdates(true); } + protected JComponent getIdComponent() + { + return _id; + } + + protected String getIdText() + { + return _id.getText().trim(); + } + + protected void showId(String unsubstitutedId, Utils.Resolver resolver) + { + // + // This version does NOT substitute the ID + // + _id.setText(unsubstitutedId); + _id.setEditable(resolver == null); + } + + private PropertySet getPropertySet() { return (PropertySet)_target; } - private JTextField _id = new JTextField(20); - + private String _oldId; + + private final JTextField _id = new JTextField(20); + private final JLabel _idLabel; + private ListTextField _propertySets = new ListTextField(20); private PropertiesField _properties; } diff --git a/java/src/IceGridGUI/Application/PropertySetParent.java b/java/src/IceGridGUI/Application/PropertySetParent.java index eea1e10061b..8bcc74b9fef 100755 --- a/java/src/IceGridGUI/Application/PropertySetParent.java +++ b/java/src/IceGridGUI/Application/PropertySetParent.java @@ -16,6 +16,9 @@ interface PropertySetParent void tryAdd(String id, PropertySetDescriptor descriptor) throws UpdateFailedException; + void tryRename(String oldId, String oldUnresolveId, String newUnresolvedId) + throws UpdateFailedException; + void insertPropertySet(PropertySet nps, boolean fireEvent) throws UpdateFailedException; diff --git a/java/src/IceGridGUI/Application/PropertySets.java b/java/src/IceGridGUI/Application/PropertySets.java index 485ce7c1229..2c822ab3a56 100755 --- a/java/src/IceGridGUI/Application/PropertySets.java +++ b/java/src/IceGridGUI/Application/PropertySets.java @@ -92,8 +92,9 @@ class PropertySets extends ListTreeNode implements PropertySetParent { java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - insertChild(new PropertySet(false, this, - (String)entry.getKey(), + String id = (String)entry.getKey(); + + insertChild(new PropertySet(false, this, id, id, (PropertySetDescriptor)entry.getValue()), false); } } @@ -125,7 +126,7 @@ class PropertySets extends ListTreeNode implements PropertySetParent if(child == null) { newChildren.add( - new PropertySet(false, this, id, psd)); + new PropertySet(false, this, id, id, psd)); } else { @@ -170,11 +171,44 @@ class PropertySets extends ListTreeNode implements PropertySetParent throws UpdateFailedException { insertChild( - new PropertySet(true, this, id, descriptor), + new PropertySet(true, this, id, id, descriptor), true); _descriptors.put(id, descriptor); } + + public void tryRename(String oldId, String oldId2, String newId) + throws UpdateFailedException + { + PropertySet oldChild = (PropertySet)findChild(oldId); + assert oldChild != null; + removeChild(oldChild); + PropertySetDescriptor descriptor = (PropertySetDescriptor)oldChild.getDescriptor(); + + try + { + insertChild( + new PropertySet(true, this, newId, newId, descriptor), + true); + } + catch(UpdateFailedException ex) + { + try + { + insertChild(oldChild, true); + } + catch(UpdateFailedException ufe) + { + assert false; + } + throw ex; + } + + _editable.removeElement(oldId, oldChild.getEditable(), PropertySet.class); + _descriptors.remove(oldId); + _descriptors.put(newId, descriptor); + } + public void insertPropertySet(PropertySet nps, boolean fireEvent) throws UpdateFailedException @@ -199,8 +233,10 @@ class PropertySets extends ListTreeNode implements PropertySetParent private void newPropertySet(PropertySetDescriptor descriptor) { + String id = makeNewChildId("PropertySet"); + PropertySet propertySet = - new PropertySet(this, makeNewChildId("PropertySet"), descriptor); + new PropertySet(this, id, descriptor); try { diff --git a/java/src/IceGridGUI/Application/ServerInstance.java b/java/src/IceGridGUI/Application/ServerInstance.java index 52b3d134327..1f1cdd68aa4 100755 --- a/java/src/IceGridGUI/Application/ServerInstance.java +++ b/java/src/IceGridGUI/Application/ServerInstance.java @@ -11,6 +11,7 @@ package IceGridGUI.Application; import java.awt.Component; import javax.swing.Icon; +import javax.swing.JPopupMenu; import javax.swing.JTree; import javax.swing.tree.TreeCellRenderer; @@ -19,7 +20,7 @@ import javax.swing.tree.DefaultTreeCellRenderer; import IceGrid.*; import IceGridGUI.*; -class ServerInstance extends TreeNode implements Server +class ServerInstance extends ListTreeNode implements Server, PropertySetParent { static public ServerInstanceDescriptor copyDescriptor(ServerInstanceDescriptor sid) @@ -30,6 +31,14 @@ class ServerInstance extends TreeNode implements Server } // + // Overrides ListTreeNode + // + public boolean getAllowsChildren() + { + return _isIceBox; + } + + // // Actions // public boolean[] getAvailableActions() @@ -40,7 +49,8 @@ class ServerInstance extends TreeNode implements Server Object clipboard = getCoordinator().getClipboard(); if(clipboard != null && (clipboard instanceof ServerDescriptor - || clipboard instanceof ServerInstanceDescriptor)) + || clipboard instanceof ServerInstanceDescriptor + || (_isIceBox && clipboard instanceof PropertySetDescriptor))) { actions[PASTE] = true; } @@ -50,6 +60,11 @@ class ServerInstance extends TreeNode implements Server { actions[SHOW_VARS] = true; actions[SUBSTITUTE_VARS] = true; + + if(_isIceBox) + { + actions[NEW_PROPERTY_SET] = true; + } } return actions; @@ -63,9 +78,45 @@ class ServerInstance extends TreeNode implements Server public void paste() { + if(_isIceBox) + { + Object descriptor = getCoordinator().getClipboard(); + if(descriptor instanceof PropertySetDescriptor) + { + newPropertySet(PropertySet.copyDescriptor((PropertySetDescriptor)descriptor)); + return; + } + } + ((TreeNode)_parent).paste(); } + public void newPropertySet() + { + newPropertySet(new PropertySetDescriptor( + new String[0], new java.util.LinkedList())); + } + + + public JPopupMenu getPopupMenu() + { + if(_isIceBox) + { + ApplicationActions actions = getCoordinator().getActionsForPopup(); + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(actions.get(NEW_PROPERTY_SET)); + } + actions.setTarget(this); + return _popup; + } + else + { + return null; + } + } + public Editor getEditor() { if(_editor == null) @@ -100,10 +151,12 @@ class ServerInstance extends TreeNode implements Server _serverIcon = Utils.getIcon("/icons/16x16/server_inactive.png"); _iceboxServerIcon = Utils.getIcon("/icons/16x16/icebox_server_inactive.png"); + + _cellRenderer.setLeafIcon(_serverIcon); + _cellRenderer.setOpenIcon(_iceboxServerIcon); + _cellRenderer.setClosedIcon(_iceboxServerIcon); } - _cellRenderer.setLeafIcon(_isIceBox ? _iceboxServerIcon : _serverIcon); - return _cellRenderer.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); } @@ -142,7 +195,7 @@ class ServerInstance extends TreeNode implements Server _descriptor.template = copy.template; _descriptor.parameterValues = copy.parameterValues; - _descriptor.propertySet = copy.propertySet; + _descriptor.propertySet = copy.propertySet; } // @@ -154,19 +207,24 @@ class ServerInstance extends TreeNode implements Server boolean isIceBox) throws UpdateFailedException { - super(parent, serverId); + super(brandNew, parent, serverId); _ephemeral = false; - _editable = new Editable(brandNew); rebuild(resolver, instanceDescriptor, isIceBox); } ServerInstance(TreeNode parent, String serverId, ServerInstanceDescriptor instanceDescriptor) { - super(parent, serverId); + super(false, parent, serverId); _ephemeral = true; - _editable = null; - rebuild(null, instanceDescriptor, false); + try + { + rebuild(null, instanceDescriptor, false); + } + catch(UpdateFailedException e) + { + assert false; + } } void write(XMLWriter writer) throws java.io.IOException @@ -181,14 +239,23 @@ class ServerInstance extends TreeNode implements Server attributes.addFirst(createAttribute("template", _descriptor.template)); if(_descriptor.propertySet.references.length == 0 && - _descriptor.propertySet.properties.size() == 0) + _descriptor.propertySet.properties.size() == 0 && + _children.size() == 0) { writer.writeElement("server-instance", attributes); } else { writer.writeStartTag("server-instance", attributes); - writePropertySet(writer, "", _descriptor.propertySet, null); + writePropertySet(writer, _descriptor.propertySet, null); + + java.util.Iterator p = _children.iterator(); + while(p.hasNext()) + { + PropertySet ps = (PropertySet)p.next(); + ps.write(writer); + } + writer.writeEndTag("server-instance"); } } @@ -202,7 +269,12 @@ class ServerInstance extends TreeNode implements Server void isIceBox(boolean newValue) { - _isIceBox = newValue; + if(newValue != _isIceBox) + { + _isIceBox = newValue; + _children.clear(); + getRoot().getTreeModel().nodeStructureChanged(this); + } } static private class Backup @@ -218,9 +290,9 @@ class ServerInstance extends TreeNode implements Server public Object rebuild(java.util.List editables) throws UpdateFailedException { - Backup backup = new Backup(((Node)_parent).getEditable().save()); Node node = (Node)_parent; - + Backup backup = new Backup(node.getEditable().save()); + TemplateDescriptor templateDescriptor = getRoot().findServerTemplateDescriptor(_descriptor.template); @@ -309,26 +381,164 @@ class ServerInstance extends TreeNode implements Server } } + + public void tryAdd(String unsubstitutedId, PropertySetDescriptor descriptor) + throws UpdateFailedException + { + insertPropertySet(new PropertySet(this, + Utils.substitute(unsubstitutedId, _resolver), + unsubstitutedId, + descriptor), + true); + _descriptor.servicePropertySets.put(unsubstitutedId, descriptor); + _editable.markModified(); + } + + public void tryRename(String oldId, String oldUnresolvedId, + String newUnsubstitutedId) + throws UpdateFailedException + { + PropertySet oldChild = (PropertySet)findChild(oldId); + assert oldChild != null; + removePropertySet(oldChild); + PropertySetDescriptor descriptor = (PropertySetDescriptor)oldChild.getDescriptor(); + + try + { + insertPropertySet( + new PropertySet(this, + Utils.substitute(newUnsubstitutedId, _resolver), + newUnsubstitutedId, descriptor), + true); + } + catch(UpdateFailedException ex) + { + try + { + insertPropertySet(oldChild, true); + } + catch(UpdateFailedException ufe) + { + assert false; + } + throw ex; + } + + _editable.markModified(); + _descriptor.servicePropertySets.remove(oldUnresolvedId); + _descriptor.servicePropertySets.put(newUnsubstitutedId, descriptor); + } + + + public void insertPropertySet(PropertySet nps, boolean fireEvent) + throws UpdateFailedException + { + insertChild(nps, fireEvent); + } + + public void removePropertySet(PropertySet nps) + { + removeChild(nps); + } + + public void removeDescriptor(String unsubstitutedId) + { + _descriptor.servicePropertySets.remove(unsubstitutedId); + } + + public Editable getEditable() + { + return _editable; + } + + Object[] getServiceNames() + { + assert _isIceBox; + + // + // Retrieve the list of service instances + // + + Communicator.ChildList services = getRoot(). + findServerTemplate(_descriptor.template).getServices(); + + Object[] result = new Object[services.size()]; + int i = 0; + + java.util.Iterator p = services.iterator(); + while(p.hasNext()) + { + TreeNode n = (TreeNode)p.next(); + ServiceInstanceDescriptor d = (ServiceInstanceDescriptor)n.getDescriptor(); + + if(d.template.length() > 0) + { + TemplateDescriptor templateDescriptor + = (TemplateDescriptor)getRoot().findServiceTemplateDescriptor(d.template); + assert templateDescriptor != null; + Utils.Resolver serviceResolver = new Utils.Resolver(_resolver, + d.parameterValues, + templateDescriptor.parameterDefaults); + + ServiceDescriptor serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor; + + result[i++] = serviceResolver.substitute(serviceDescriptor.name); + } + else + { + result[i++] = _resolver.substitute(d.descriptor.name); + } + } + return result; + } + // - // Update the server + // Update the server and its children // void rebuild(Utils.Resolver resolver, ServerInstanceDescriptor instanceDescriptor, - boolean isIceBox) + boolean isIceBox) throws UpdateFailedException { _resolver = resolver; _isIceBox = isIceBox; _descriptor = instanceDescriptor; + + _children.clear(); + + java.util.Iterator p = _descriptor.servicePropertySets.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + String unsubstitutedId = (String)entry.getKey(); + + insertPropertySet(new PropertySet(this, + Utils.substitute(unsubstitutedId, _resolver), + unsubstitutedId, + (PropertySetDescriptor)entry.getValue()), + false); + } } - Utils.Resolver getResolver() + private void newPropertySet(PropertySetDescriptor descriptor) { - return _resolver; + String id = makeNewChildId("Service"); + + PropertySet ps = new PropertySet(this, id, descriptor); + try + { + insertChild(ps, true); + } + catch(UpdateFailedException e) + { + assert false; + } + getRoot().setSelectedNode(ps); } - - public Editable getEditable() + + + Utils.Resolver getResolver() { - return _editable; + return _resolver; } public boolean isEphemeral() @@ -355,10 +565,9 @@ class ServerInstance extends TreeNode implements Server private ServerInstanceEditor _editor; private Utils.Resolver _resolver; - private Editable _editable; static private DefaultTreeCellRenderer _cellRenderer; static private Icon _serverIcon; static private Icon _iceboxServerIcon; - + static private JPopupMenu _popup; } diff --git a/java/src/IceGridGUI/Application/ServerInstancePropertySetEditor.java b/java/src/IceGridGUI/Application/ServerInstancePropertySetEditor.java new file mode 100644 index 00000000000..7cabda2e2b6 --- /dev/null +++ b/java/src/IceGridGUI/Application/ServerInstancePropertySetEditor.java @@ -0,0 +1,67 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 IceGridGUI.Application; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JTextField; + +import IceGrid.*; +import IceGridGUI.*; + +class ServerInstancePropertySetEditor extends PropertySetEditor +{ + ServerInstancePropertySetEditor() + { + super("Service Name"); + _id.setToolTipText("The name of the service"); + + JTextField idTextField = (JTextField) + _id.getEditor().getEditorComponent(); + idTextField.getDocument().addDocumentListener(_updateListener); + } + + protected void buildPropertiesPanel() + { + super.buildPropertiesPanel(); + _propertiesPanel.setName("Service Instance Property Set"); + } + + protected JComponent getIdComponent() + { + return _id; + } + + protected String getIdText() + { + if(_id.getSelectedItem() == null) + { + return ""; + } + else + { + return _id.getSelectedItem().toString().trim(); + } + } + + protected void showId(String unsubstitutedId, Utils.Resolver resolver) + { + ServerInstance s = (ServerInstance)_target.getParent(); + + _id.setEnabled(true); + _id.setEditable(true); + _id.setModel(new DefaultComboBoxModel(s.getServiceNames())); + _id.setSelectedItem(Utils.substitute(unsubstitutedId, resolver)); + _id.setEditable(resolver == null); + _id.setEnabled(resolver == null); + } + + private JComboBox _id = new JComboBox(); +}
\ No newline at end of file diff --git a/java/src/IceGridGUI/Application/ServerTemplate.java b/java/src/IceGridGUI/Application/ServerTemplate.java index c418ccec73b..5809ab07c48 100755 --- a/java/src/IceGridGUI/Application/ServerTemplate.java +++ b/java/src/IceGridGUI/Application/ServerTemplate.java @@ -260,7 +260,7 @@ class ServerTemplate extends Communicator PlainServer.writeOptions(writer, descriptor.options); PlainServer.writeEnvs(writer, descriptor.envs); - writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters); + writePropertySet(writer, "", "", descriptor.propertySet, descriptor.adapters); writeDistribution(writer, descriptor.distrib); _adapters.write(writer); @@ -281,7 +281,7 @@ class ServerTemplate extends Communicator PlainServer.writeOptions(writer, descriptor.options); PlainServer.writeEnvs(writer, descriptor.envs); - writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters); + writePropertySet(writer, descriptor.propertySet, descriptor.adapters); writeDistribution(writer, descriptor.distrib); _adapters.write(writer); diff --git a/java/src/IceGridGUI/Application/ServiceInstance.java b/java/src/IceGridGUI/Application/ServiceInstance.java index cd89f9f9eab..c58439b0320 100755 --- a/java/src/IceGridGUI/Application/ServiceInstance.java +++ b/java/src/IceGridGUI/Application/ServiceInstance.java @@ -334,7 +334,7 @@ class ServiceInstance extends TreeNode implements Service, Cloneable else { writer.writeStartTag("service-instance", attributes); - writePropertySet(writer, "", _descriptor.propertySet, null); + writePropertySet(writer, _descriptor.propertySet, null); writer.writeEndTag("service-instance"); } } diff --git a/java/src/IceGridGUI/Application/ServiceTemplate.java b/java/src/IceGridGUI/Application/ServiceTemplate.java index 73a34a31a0e..42869f6c440 100755 --- a/java/src/IceGridGUI/Application/ServiceTemplate.java +++ b/java/src/IceGridGUI/Application/ServiceTemplate.java @@ -151,7 +151,7 @@ class ServiceTemplate extends Communicator writer.writeElement("description", descriptor.description); } - writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters); + writePropertySet(writer, descriptor.propertySet, descriptor.adapters); _adapters.write(writer); _dbEnvs.write(writer); writer.writeEndTag("service"); diff --git a/java/src/IceGridGUI/Application/TreeNode.java b/java/src/IceGridGUI/Application/TreeNode.java index c7af0ac6345..b74fd1f2698 100755 --- a/java/src/IceGridGUI/Application/TreeNode.java +++ b/java/src/IceGridGUI/Application/TreeNode.java @@ -114,7 +114,13 @@ public abstract class TreeNode extends TreeNodeBase } } - static void writePropertySet(XMLWriter writer, String id, + static void writePropertySet(XMLWriter writer, PropertySetDescriptor psd, java.util.List adapters) + throws java.io.IOException + { + writePropertySet(writer, "", "", psd, adapters); + } + + static void writePropertySet(XMLWriter writer, String id, String idAttrName, PropertySetDescriptor psd, java.util.List adapters) throws java.io.IOException { @@ -142,7 +148,7 @@ public abstract class TreeNode extends TreeNodeBase java.util.List attributes = new java.util.LinkedList(); if(id.length() > 0) { - attributes.add(createAttribute("id", id)); + attributes.add(createAttribute(idAttrName, id)); } if(psd.references.length == 0 && psd.properties.size() == 0) { diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index 03ba6c925a3..af7af717e55 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -608,6 +608,7 @@ class Server extends ListArrayTreeNode _dbEnvs.clear(); createDbEnvs(); _services.clear(); + _servicePropertySets.clear(); createServices(); getRoot().getTreeModel().nodeStructureChanged(this); @@ -615,6 +616,7 @@ class Server extends ListArrayTreeNode else if(serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor) { _services.clear(); + _servicePropertySets.clear(); createServices(); getRoot().getTreeModel().nodeStructureChanged(this); } @@ -718,20 +720,20 @@ class Server extends ListArrayTreeNode java.util.SortedMap getProperties() { - Utils.ExpandedPropertySet instancePropertySet = null; + java.util.List psList = new java.util.LinkedList(); Node node = (Node)_parent; + + psList.add(node.expand(_serverDescriptor.propertySet, + _application.name, _resolver)); + if(_instanceDescriptor != null) { - instancePropertySet = node.expand(_instanceDescriptor.propertySet, - _application.name, _resolver); + psList.add(node.expand(_instanceDescriptor.propertySet, + _application.name, _resolver)); } - Utils.ExpandedPropertySet propertySet = - node.expand(_serverDescriptor.propertySet, - _application.name, _resolver); - - return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver); + return Utils.propertySetsToMap(psList, _resolver); } private void createAdapters() @@ -771,8 +773,18 @@ class Server extends ListArrayTreeNode { if(_serverDescriptor instanceof IceBoxDescriptor) { + if(_instanceDescriptor != null) + { + java.util.Iterator p = _instanceDescriptor.servicePropertySets.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + _servicePropertySets.put(_resolver.substitute((String)entry.getKey()), entry.getValue()); + } + } + IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor; - + java.util.Iterator p = iceBoxDescriptor.services.iterator(); while(p.hasNext()) { @@ -785,6 +797,7 @@ class Server extends ListArrayTreeNode private void createService(ServiceInstanceDescriptor descriptor) { ServiceDescriptor serviceDescriptor = null; + PropertySetDescriptor serverInstancePSDescriptor = null; String serviceName = null; Utils.Resolver serviceResolver = null; @@ -803,6 +816,8 @@ class Server extends ListArrayTreeNode templateDescriptor.parameterDefaults); serviceName = serviceResolver.substitute(serviceDescriptor.name); serviceResolver.put("service", serviceName); + + serverInstancePSDescriptor = (PropertySetDescriptor)_servicePropertySets.get(serviceName); } else { @@ -815,7 +830,7 @@ class Server extends ListArrayTreeNode } _services.add(new Service(this, serviceName, serviceResolver, - descriptor, serviceDescriptor)); + descriptor, serviceDescriptor, serverInstancePSDescriptor)); } static private String toolTip(ServerState state, int pid, boolean enabled) @@ -836,6 +851,8 @@ class Server extends ListArrayTreeNode private ServerInstanceDescriptor _instanceDescriptor; + private java.util.Map _servicePropertySets = new java.util.HashMap(); // with substituted names! + private ServerDescriptor _serverDescriptor; private ApplicationDescriptor _application; diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java index 28c6e72d887..08044814473 100755 --- a/java/src/IceGridGUI/LiveDeployment/Service.java +++ b/java/src/IceGridGUI/LiveDeployment/Service.java @@ -56,13 +56,15 @@ class Service extends ListArrayTreeNode Service(Server parent, String serviceName, Utils.Resolver resolver, ServiceInstanceDescriptor descriptor, - ServiceDescriptor serviceDescriptor) + ServiceDescriptor serviceDescriptor, + PropertySetDescriptor serverInstancePSDescriptor) { super(parent, serviceName, 2); _resolver = resolver; _instanceDescriptor = descriptor; _serviceDescriptor = serviceDescriptor; + _serverInstancePSDescriptor = serverInstancePSDescriptor; _childrenArray[0] = _adapters; _childrenArray[1] = _dbEnvs; @@ -127,22 +129,28 @@ class Service extends ListArrayTreeNode java.util.SortedMap getProperties() { - Utils.ExpandedPropertySet instancePropertySet = null; + java.util.List psList = new java.util.LinkedList(); Node node = (Node)_parent.getParent(); String applicationName = ((Server)_parent).getApplication().name; + psList.add(node.expand(_serviceDescriptor.propertySet, + applicationName, _resolver)); + if(_instanceDescriptor != null) { - instancePropertySet = node.expand(_instanceDescriptor.propertySet, - applicationName, _resolver); - } + psList.add(node.expand(_instanceDescriptor.propertySet, + applicationName, _resolver)); + } - Utils.ExpandedPropertySet propertySet = - node.expand(_serviceDescriptor.propertySet, - applicationName, _resolver); + if(_serverInstancePSDescriptor != null) + { + psList.add(node.expand(_serverInstancePSDescriptor, + applicationName, _resolver)); + + } - return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver); + return Utils.propertySetsToMap(psList, _resolver); } private void createAdapters() @@ -179,12 +187,13 @@ class Service extends ListArrayTreeNode } } - private ServiceInstanceDescriptor _instanceDescriptor; - private ServiceDescriptor _serviceDescriptor; - private Utils.Resolver _resolver; + private final ServiceInstanceDescriptor _instanceDescriptor; + private final ServiceDescriptor _serviceDescriptor; + private final PropertySetDescriptor _serverInstancePSDescriptor; + private final Utils.Resolver _resolver; - private java.util.List _adapters = new java.util.LinkedList(); - private java.util.List _dbEnvs = new java.util.LinkedList(); + private final java.util.List _adapters = new java.util.LinkedList(); + private final java.util.List _dbEnvs = new java.util.LinkedList(); static private ServiceEditor _editor; static private DefaultTreeCellRenderer _cellRenderer; diff --git a/java/src/IceGridGUI/Utils.java b/java/src/IceGridGUI/Utils.java index 2abcbe3b519..2ea7cb76587 100755 --- a/java/src/IceGridGUI/Utils.java +++ b/java/src/IceGridGUI/Utils.java @@ -377,21 +377,29 @@ public class Utils public java.util.List properties; // list of PropertyDescriptor } - static public java.util.SortedMap propertySetToMap( - ExpandedPropertySet propertySet, - ExpandedPropertySet instancePropertySet, // can be null + static public java.util.SortedMap propertySetsToMap( + java.util.List propertySets, Resolver resolver) { java.util.SortedMap toMap = new java.util.TreeMap(); - - addSet(propertySet, resolver, toMap); - if(instancePropertySet != null) + java.util.Iterator p = propertySets.iterator(); + while(p.hasNext()) { - addSet(instancePropertySet, resolver, toMap); + ExpandedPropertySet propertySet = (ExpandedPropertySet)p.next(); + addSet(propertySet, resolver, toMap); } return toMap; } + static public java.util.SortedMap propertySetToMap( + ExpandedPropertySet propertySet, + Resolver resolver) + { + java.util.List list = new java.util.LinkedList(); + list.add(propertySet); + return propertySetsToMap(list, resolver); + } + static private void addSet(ExpandedPropertySet set, Resolver resolver, java.util.SortedMap toMap) { |