summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2006-09-15 19:42:39 +0000
committerBernard Normier <bernard@zeroc.com>2006-09-15 19:42:39 +0000
commit926a34c0cde3bb59a64c6906442246015290c310 (patch)
tree247d19ba42bd29fb7b60d96ac936ca91d497357b /java/src
parentMerged fixes from 3.1 branch (diff)
downloadice-926a34c0cde3bb59a64c6906442246015290c310.tar.bz2
ice-926a34c0cde3bb59a64c6906442246015290c310.tar.xz
ice-926a34c0cde3bb59a64c6906442246015290c310.zip
dos2unix
Diffstat (limited to 'java/src')
-rwxr-xr-xjava/src/IceGridGUI/AdminRouter.java110
-rwxr-xr-xjava/src/IceGridGUI/Application/AbstractServerEditor.java340
-rwxr-xr-xjava/src/IceGridGUI/Application/Adapter.java456
-rwxr-xr-xjava/src/IceGridGUI/Application/AdapterEditor.java1152
-rwxr-xr-xjava/src/IceGridGUI/Application/ApplicationEditor.java504
-rwxr-xr-xjava/src/IceGridGUI/Application/Communicator.java1806
-rwxr-xr-xjava/src/IceGridGUI/Application/CommunicatorChildEditor.java244
-rwxr-xr-xjava/src/IceGridGUI/Application/CommunicatorSubEditor.java218
-rwxr-xr-xjava/src/IceGridGUI/Application/DbEnv.java388
-rwxr-xr-xjava/src/IceGridGUI/Application/DbEnvEditor.java400
-rwxr-xr-xjava/src/IceGridGUI/Application/DescriptorHolder.java30
-rwxr-xr-xjava/src/IceGridGUI/Application/Editable.java212
-rwxr-xr-xjava/src/IceGridGUI/Application/Editor.java480
-rwxr-xr-xjava/src/IceGridGUI/Application/ListTextField.java158
-rwxr-xr-xjava/src/IceGridGUI/Application/ListTreeNode.java478
-rwxr-xr-xjava/src/IceGridGUI/Application/MapField.java388
-rwxr-xr-xjava/src/IceGridGUI/Application/Node.java2622
-rwxr-xr-xjava/src/IceGridGUI/Application/NodeEditor.java522
-rwxr-xr-xjava/src/IceGridGUI/Application/Nodes.java636
-rwxr-xr-xjava/src/IceGridGUI/Application/ParameterValuesField.java396
-rwxr-xr-xjava/src/IceGridGUI/Application/ParametersField.java388
-rwxr-xr-xjava/src/IceGridGUI/Application/PlainServer.java1102
-rwxr-xr-xjava/src/IceGridGUI/Application/PlainServerEditor.java152
-rwxr-xr-xjava/src/IceGridGUI/Application/PlainService.java590
-rwxr-xr-xjava/src/IceGridGUI/Application/PlainServiceEditor.java180
-rwxr-xr-xjava/src/IceGridGUI/Application/PropertiesField.java452
-rwxr-xr-xjava/src/IceGridGUI/Application/PropertySet.java358
-rwxr-xr-xjava/src/IceGridGUI/Application/PropertySetEditor.java438
-rwxr-xr-xjava/src/IceGridGUI/Application/PropertySetParent.java54
-rwxr-xr-xjava/src/IceGridGUI/Application/PropertySets.java436
-rwxr-xr-xjava/src/IceGridGUI/Application/ReplicaGroup.java446
-rwxr-xr-xjava/src/IceGridGUI/Application/ReplicaGroupEditor.java826
-rwxr-xr-xjava/src/IceGridGUI/Application/ReplicaGroups.java468
-rwxr-xr-xjava/src/IceGridGUI/Application/Root.java2500
-rwxr-xr-xjava/src/IceGridGUI/Application/Server.java38
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerInstance.java718
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerInstanceEditor.java456
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerSubEditor.java792
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerTemplate.java716
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerTemplateEditor.java128
-rwxr-xr-xjava/src/IceGridGUI/Application/ServerTemplates.java548
-rwxr-xr-xjava/src/IceGridGUI/Application/Service.java24
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceInstance.java716
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceInstanceEditor.java476
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceSubEditor.java220
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceTemplate.java522
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceTemplateEditor.java128
-rwxr-xr-xjava/src/IceGridGUI/Application/ServiceTemplates.java442
-rwxr-xr-xjava/src/IceGridGUI/Application/TemplateEditor.java416
-rwxr-xr-xjava/src/IceGridGUI/Application/TemplateInstance.java32
-rwxr-xr-xjava/src/IceGridGUI/Application/Templates.java122
-rwxr-xr-xjava/src/IceGridGUI/Application/TreeNode.java758
-rwxr-xr-xjava/src/IceGridGUI/Application/UpdateFailedException.java52
-rwxr-xr-xjava/src/IceGridGUI/ApplicationActions.java510
-rwxr-xr-xjava/src/IceGridGUI/BareBonesBrowserLaunch.java108
-rwxr-xr-xjava/src/IceGridGUI/CellRenderer.java80
-rwxr-xr-xjava/src/IceGridGUI/Coordinator.java4032
-rwxr-xr-xjava/src/IceGridGUI/EditorBase.java142
-rwxr-xr-xjava/src/IceGridGUI/LiveActions.java254
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Adapter.java350
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/AdapterEditor.java356
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java138
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/DbEnv.java150
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/DbEnvEditor.java192
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Editor.java36
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java280
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/ListTreeNode.java162
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Node.java1738
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/NodeEditor.java308
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/ObjectDialog.java240
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/RegistryEditor.java306
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Root.java1630
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Server.java1468
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/ServerEditor.java598
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/Service.java382
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/ServiceEditor.java102
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/TableField.java392
-rwxr-xr-xjava/src/IceGridGUI/LiveDeployment/TreeNode.java362
-rwxr-xr-xjava/src/IceGridGUI/Main.java188
-rwxr-xr-xjava/src/IceGridGUI/NodeObserverI.java164
-rwxr-xr-xjava/src/IceGridGUI/RegistryObserverI.java104
-rwxr-xr-xjava/src/IceGridGUI/SessionKeeper.java2526
-rwxr-xr-xjava/src/IceGridGUI/StatusBar.java30
-rwxr-xr-xjava/src/IceGridGUI/Tab.java54
-rwxr-xr-xjava/src/IceGridGUI/TreeNodeBase.java700
-rwxr-xr-xjava/src/IceGridGUI/Utils.java832
-rwxr-xr-xjava/src/IceGridGUI/XMLWriter.java342
87 files changed, 23245 insertions, 23245 deletions
diff --git a/java/src/IceGridGUI/AdminRouter.java b/java/src/IceGridGUI/AdminRouter.java
index 0e598a7e7fc..3f95bf9f6a9 100755
--- a/java/src/IceGridGUI/AdminRouter.java
+++ b/java/src/IceGridGUI/AdminRouter.java
@@ -1,55 +1,55 @@
-// **********************************************************************
-//
-// 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;
-
-import IceGrid.*;
-
-class AdminRouter extends Ice.Blobject
-{
- public boolean ice_invoke(byte[] inParams,
- Ice.ByteSeqHolder outParams,
- Ice.Current current)
- {
-
- if(_admin == null)
- {
- throw new Ice.ObjectNotExistException(current.id,
- current.facet,
- current.operation);
- }
- else if(current.operation.equals("ice_id") ||
- current.operation.equals("ice_ids") ||
- current.operation.equals("ice_isA") ||
- current.operation.equals("ice_ping") ||
- current.operation.equals("getDefaultApplicationDescriptor"))
- {
-
- return _admin.ice_invoke(current.operation,
- current.mode,
- inParams, outParams,
- current.ctx);
- }
- else
- {
- //
- // Routing other operations could be a security risk
- //
- throw new Ice.OperationNotExistException(current.id,
- current.facet,
- current.operation);
- }
- }
-
- AdminRouter(AdminPrx admin)
- {
- _admin = admin;
- }
-
- private final AdminPrx _admin;
-}
+// **********************************************************************
+//
+// 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;
+
+import IceGrid.*;
+
+class AdminRouter extends Ice.Blobject
+{
+ public boolean ice_invoke(byte[] inParams,
+ Ice.ByteSeqHolder outParams,
+ Ice.Current current)
+ {
+
+ if(_admin == null)
+ {
+ throw new Ice.ObjectNotExistException(current.id,
+ current.facet,
+ current.operation);
+ }
+ else if(current.operation.equals("ice_id") ||
+ current.operation.equals("ice_ids") ||
+ current.operation.equals("ice_isA") ||
+ current.operation.equals("ice_ping") ||
+ current.operation.equals("getDefaultApplicationDescriptor"))
+ {
+
+ return _admin.ice_invoke(current.operation,
+ current.mode,
+ inParams, outParams,
+ current.ctx);
+ }
+ else
+ {
+ //
+ // Routing other operations could be a security risk
+ //
+ throw new Ice.OperationNotExistException(current.id,
+ current.facet,
+ current.operation);
+ }
+ }
+
+ AdminRouter(AdminPrx admin)
+ {
+ _admin = admin;
+ }
+
+ private final AdminPrx _admin;
+}
diff --git a/java/src/IceGridGUI/Application/AbstractServerEditor.java b/java/src/IceGridGUI/Application/AbstractServerEditor.java
index 78aab335011..19a9ee33aa7 100755
--- a/java/src/IceGridGUI/Application/AbstractServerEditor.java
+++ b/java/src/IceGridGUI/Application/AbstractServerEditor.java
@@ -1,170 +1,170 @@
-// **********************************************************************
-//
-// 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.JOptionPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
-
-import com.jgoodies.looks.Options;
-import com.jgoodies.looks.HeaderStyle;
-import com.jgoodies.looks.BorderStyle;
-import com.jgoodies.looks.plastic.PlasticLookAndFeel;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// Base class for ServerEditor and ServerInstanceEditor
-//
-
-abstract class AbstractServerEditor extends Editor
-{
- abstract protected void writeDescriptor();
- abstract protected boolean isSimpleUpdate();
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Server Properties");
- }
-
- protected boolean applyUpdate()
- {
- Root root = _target.getRoot();
- Server server = (Server)_target;
-
- root.disableSelectionListener();
- try
- {
- if(_target.isEphemeral())
- {
- Node node = (Node)_target.getParent();
- writeDescriptor();
-
- _target.destroy(); // just removes the child
-
- try
- {
- if(server instanceof PlainServer)
- {
- node.tryAdd((ServerDescriptor)server.getDescriptor(), true);
- }
- else
- {
- node.tryAdd((ServerInstanceDescriptor)server.getDescriptor(), true);
- }
- }
- catch(UpdateFailedException e)
- {
- //
- // Add back ephemeral child
- //
- try
- {
- node.insertServer(_target, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = (TreeNode)node.findChildWithDescriptor(server.getDescriptor());
-
- root.updated();
- root.setSelectedNode(_target);
- }
- else if(isSimpleUpdate())
- {
- writeDescriptor();
- root.updated();
- server.getEditable().markModified();
- }
- else
- {
- //
- // Save to be able to rollback
- //
- Object savedDescriptor = server.saveDescriptor();
- Node node = (Node)_target.getParent();
- writeDescriptor();
-
- node.removeServer(_target);
-
- try
- {
- if(server instanceof PlainServer)
- {
- node.tryAdd((ServerDescriptor)server.getDescriptor(), false);
- }
- else
- {
- node.tryAdd((ServerInstanceDescriptor)server.getDescriptor(), false);
- }
- }
- catch(UpdateFailedException e)
- {
- //
- // Restore
- //
- try
- {
- node.insertServer(_target, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- server.restoreDescriptor(savedDescriptor);
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- node.getEditable().removeElement(_target.getId(), server.getEditable(),
- Server.class); // replaced by brand new Server
-
- _target = node.findChildWithDescriptor(server.getDescriptor());
- root.updated();
- root.setSelectedNode(_target);
- }
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-}
+// **********************************************************************
+//
+// 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.JOptionPane;
+import javax.swing.JTextField;
+import javax.swing.JToolBar;
+
+import com.jgoodies.looks.Options;
+import com.jgoodies.looks.HeaderStyle;
+import com.jgoodies.looks.BorderStyle;
+import com.jgoodies.looks.plastic.PlasticLookAndFeel;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// Base class for ServerEditor and ServerInstanceEditor
+//
+
+abstract class AbstractServerEditor extends Editor
+{
+ abstract protected void writeDescriptor();
+ abstract protected boolean isSimpleUpdate();
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Server Properties");
+ }
+
+ protected boolean applyUpdate()
+ {
+ Root root = _target.getRoot();
+ Server server = (Server)_target;
+
+ root.disableSelectionListener();
+ try
+ {
+ if(_target.isEphemeral())
+ {
+ Node node = (Node)_target.getParent();
+ writeDescriptor();
+
+ _target.destroy(); // just removes the child
+
+ try
+ {
+ if(server instanceof PlainServer)
+ {
+ node.tryAdd((ServerDescriptor)server.getDescriptor(), true);
+ }
+ else
+ {
+ node.tryAdd((ServerInstanceDescriptor)server.getDescriptor(), true);
+ }
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Add back ephemeral child
+ //
+ try
+ {
+ node.insertServer(_target, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = (TreeNode)node.findChildWithDescriptor(server.getDescriptor());
+
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+ else if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ root.updated();
+ server.getEditable().markModified();
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ Object savedDescriptor = server.saveDescriptor();
+ Node node = (Node)_target.getParent();
+ writeDescriptor();
+
+ node.removeServer(_target);
+
+ try
+ {
+ if(server instanceof PlainServer)
+ {
+ node.tryAdd((ServerDescriptor)server.getDescriptor(), false);
+ }
+ else
+ {
+ node.tryAdd((ServerInstanceDescriptor)server.getDescriptor(), false);
+ }
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Restore
+ //
+ try
+ {
+ node.insertServer(_target, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ server.restoreDescriptor(savedDescriptor);
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ node.getEditable().removeElement(_target.getId(), server.getEditable(),
+ Server.class); // replaced by brand new Server
+
+ _target = node.findChildWithDescriptor(server.getDescriptor());
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+}
diff --git a/java/src/IceGridGUI/Application/Adapter.java b/java/src/IceGridGUI/Application/Adapter.java
index ca5d8512a6a..8e483da0bce 100755
--- a/java/src/IceGridGUI/Application/Adapter.java
+++ b/java/src/IceGridGUI/Application/Adapter.java
@@ -1,228 +1,228 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Adapter extends TreeNode implements DescriptorHolder
-{
- static public AdapterDescriptor copyDescriptor(AdapterDescriptor d)
- {
- return (AdapterDescriptor)d.clone();
- }
-
- static public java.util.List
- copyDescriptors(java.util.List descriptors)
- {
- java.util.List copy = new java.util.LinkedList();
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- copy.add(copyDescriptor((AdapterDescriptor)p.next()));
- }
- return copy;
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- boolean[] parentActions = ((TreeNode)_parent).getAvailableActions();
-
- actions[PASTE] = parentActions[PASTE];
- actions[DELETE] = true;
-
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = parentActions[SHOW_VARS];
- actions[SUBSTITUTE_VARS] = parentActions[SUBSTITUTE_VARS];
- }
- return actions;
- }
-
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/adapter_inactive.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (AdapterEditor)getRoot().getEditor(AdapterEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new AdapterEditor();
- }
-
-
- public void destroy()
- {
- removeProperty(_id, "Endpoints");
- removeProperty(_id, "PublishedEndpoints");
-
- ((Communicator)_parent).getAdapters().destroyChild(this);
- }
-
- Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object saveDescriptor()
- {
- return copyDescriptor(_descriptor);
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- AdapterDescriptor ad = (AdapterDescriptor)savedDescriptor;
-
- _descriptor.name = ad.name;
- _descriptor.id = ad.id;
- _descriptor.replicaGroupId = ad.replicaGroupId;
- _descriptor.description = ad.description;
- _descriptor.registerProcess = ad.registerProcess;
- _descriptor.waitForActivation = ad.waitForActivation;
- _descriptor.objects = ad.objects;
- }
-
- Adapter(Communicator parent, String adapterName, AdapterDescriptor descriptor,
- boolean ephemeral)
- {
- super(parent, adapterName);
- _descriptor = descriptor;
- _ephemeral = ephemeral;
- }
-
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", _descriptor.name));
- attributes.add(createAttribute("endpoints", getProperty("Endpoints")));
- attributes.add(createAttribute("id", _descriptor.id));
- if(_descriptor.registerProcess)
- {
- attributes.add(createAttribute("register-process", "true"));
- }
- if(_descriptor.replicaGroupId.length() > 0)
- {
- attributes.add(createAttribute("replica-group", _descriptor.replicaGroupId));
- }
- if(!_descriptor.waitForActivation)
- {
- attributes.add(createAttribute("wait-for-activation", "false"));
- }
-
- if(_descriptor.description.length() == 0
- && _descriptor.objects.isEmpty()
- && _descriptor.allocatables.isEmpty())
- {
- writer.writeElement("adapter", attributes);
- }
- else
- {
- writer.writeStartTag("adapter", attributes);
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- writeObjects("object", writer, _descriptor.objects);
- writeObjects("allocatable", writer, _descriptor.allocatables);
- writer.writeEndTag("adapter");
- }
- }
- }
-
- boolean inIceBox()
- {
- return ((Communicator)_parent).isIceBox();
- }
-
- String getProperty(String property)
- {
- return ((Communicator)_parent).getProperty(_descriptor.name + "." + property);
- }
- void setProperty(String name, String property, String newValue)
- {
- ((Communicator)_parent).setProperty(name + "." + property, newValue);
- }
- void removeProperty(String name, String property)
- {
- ((Communicator)_parent).removeProperty(name + "." + property);
- }
-
- String getDefaultAdapterId()
- {
- return getDefaultAdapterId(_id);
- }
-
- String getDefaultAdapterId(String name)
- {
- return (_parent instanceof Service ||
- _parent instanceof ServiceTemplate) ?
- "${server}.${service}." + name: "${server}." + name;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- private final boolean _ephemeral;
- private AdapterDescriptor _descriptor;
- private AdapterEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Adapter extends TreeNode implements DescriptorHolder
+{
+ static public AdapterDescriptor copyDescriptor(AdapterDescriptor d)
+ {
+ return (AdapterDescriptor)d.clone();
+ }
+
+ static public java.util.List
+ copyDescriptors(java.util.List descriptors)
+ {
+ java.util.List copy = new java.util.LinkedList();
+ java.util.Iterator p = descriptors.iterator();
+ while(p.hasNext())
+ {
+ copy.add(copyDescriptor((AdapterDescriptor)p.next()));
+ }
+ return copy;
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ boolean[] parentActions = ((TreeNode)_parent).getAvailableActions();
+
+ actions[PASTE] = parentActions[PASTE];
+ actions[DELETE] = true;
+
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = parentActions[SHOW_VARS];
+ actions[SUBSTITUTE_VARS] = parentActions[SUBSTITUTE_VARS];
+ }
+ return actions;
+ }
+
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/adapter_inactive.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (AdapterEditor)getRoot().getEditor(AdapterEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new AdapterEditor();
+ }
+
+
+ public void destroy()
+ {
+ removeProperty(_id, "Endpoints");
+ removeProperty(_id, "PublishedEndpoints");
+
+ ((Communicator)_parent).getAdapters().destroyChild(this);
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object saveDescriptor()
+ {
+ return copyDescriptor(_descriptor);
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ AdapterDescriptor ad = (AdapterDescriptor)savedDescriptor;
+
+ _descriptor.name = ad.name;
+ _descriptor.id = ad.id;
+ _descriptor.replicaGroupId = ad.replicaGroupId;
+ _descriptor.description = ad.description;
+ _descriptor.registerProcess = ad.registerProcess;
+ _descriptor.waitForActivation = ad.waitForActivation;
+ _descriptor.objects = ad.objects;
+ }
+
+ Adapter(Communicator parent, String adapterName, AdapterDescriptor descriptor,
+ boolean ephemeral)
+ {
+ super(parent, adapterName);
+ _descriptor = descriptor;
+ _ephemeral = ephemeral;
+ }
+
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", _descriptor.name));
+ attributes.add(createAttribute("endpoints", getProperty("Endpoints")));
+ attributes.add(createAttribute("id", _descriptor.id));
+ if(_descriptor.registerProcess)
+ {
+ attributes.add(createAttribute("register-process", "true"));
+ }
+ if(_descriptor.replicaGroupId.length() > 0)
+ {
+ attributes.add(createAttribute("replica-group", _descriptor.replicaGroupId));
+ }
+ if(!_descriptor.waitForActivation)
+ {
+ attributes.add(createAttribute("wait-for-activation", "false"));
+ }
+
+ if(_descriptor.description.length() == 0
+ && _descriptor.objects.isEmpty()
+ && _descriptor.allocatables.isEmpty())
+ {
+ writer.writeElement("adapter", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("adapter", attributes);
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ writeObjects("object", writer, _descriptor.objects);
+ writeObjects("allocatable", writer, _descriptor.allocatables);
+ writer.writeEndTag("adapter");
+ }
+ }
+ }
+
+ boolean inIceBox()
+ {
+ return ((Communicator)_parent).isIceBox();
+ }
+
+ String getProperty(String property)
+ {
+ return ((Communicator)_parent).getProperty(_descriptor.name + "." + property);
+ }
+ void setProperty(String name, String property, String newValue)
+ {
+ ((Communicator)_parent).setProperty(name + "." + property, newValue);
+ }
+ void removeProperty(String name, String property)
+ {
+ ((Communicator)_parent).removeProperty(name + "." + property);
+ }
+
+ String getDefaultAdapterId()
+ {
+ return getDefaultAdapterId(_id);
+ }
+
+ String getDefaultAdapterId(String name)
+ {
+ return (_parent instanceof Service ||
+ _parent instanceof ServiceTemplate) ?
+ "${server}.${service}." + name: "${server}." + name;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ private final boolean _ephemeral;
+ private AdapterDescriptor _descriptor;
+ private AdapterEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/Application/AdapterEditor.java b/java/src/IceGridGUI/Application/AdapterEditor.java
index 0d108fd40ef..c37deef59c9 100755
--- a/java/src/IceGridGUI/Application/AdapterEditor.java
+++ b/java/src/IceGridGUI/Application/AdapterEditor.java
@@ -1,576 +1,576 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.AbstractAction;
-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.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class AdapterEditor extends CommunicatorChildEditor
-{
- AdapterEditor()
- {
- _objects = new MapField(this, "Identity", "Type", true);
- _allocatables = new MapField(this, "Identity", "Type", true);
-
- //
- // Create buttons
- //
-
- //
- // _replicaGroupButton
- //
- Action gotoReplicaGroup = new AbstractAction(
- "", Utils.getIcon("/icons/16x16/goto.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- Object obj = _replicaGroupId.getSelectedItem();
- Adapter adapter = getAdapter();
-
- ReplicaGroup rg = null;
- if(obj instanceof ReplicaGroup)
- {
- rg = (ReplicaGroup)obj;
- }
- else
- {
- String replicaGroupId =
- Utils.substitute(obj.toString(), adapter.getResolver());
-
- rg = adapter.getRoot().findReplicaGroup(replicaGroupId);
- }
-
- //
- // The button is enabled therefore rg should be != null
- //
- if(rg != null)
- {
- adapter.getRoot().setSelectedNode(rg);
- }
- }
- };
- gotoReplicaGroup.putValue(Action.SHORT_DESCRIPTION,
- "Goto the definition of this replica group");
- _replicaGroupButton = new JButton(gotoReplicaGroup);
-
- Action checkRegisterProcess = new AbstractAction("Register Process")
- {
- public void actionPerformed(ActionEvent e)
- {
- updated();
- }
- };
- _registerProcess = new JCheckBox(checkRegisterProcess);
- _registerProcess.setToolTipText(
- "<html>During activation, create a Process object<br>"
- + "in this adapter and register it with IceGrid<br>"
- + "to enable clean shutdown; you should register<br>"
- + "exactly one Process object per server.</html>");
-
- Action checkWaitForActivation =
- new AbstractAction("Wait for Activation")
- {
- public void actionPerformed(ActionEvent e)
- {
- updated();
- }
- };
- _waitForActivation = new JCheckBox(checkWaitForActivation);
- _waitForActivation.setToolTipText(
- "<html>When starting the enclosing server, "
- + "does IceGrid<br>wait for this adapter to become active?</html>");
- //
- // Associate updateListener with various fields
- //
- _name.getDocument().addDocumentListener(
- new DocumentListener()
- {
- public void changedUpdate(DocumentEvent e)
- {
- update();
- }
-
- public void insertUpdate(DocumentEvent e)
- {
- update();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- update();
- }
-
- private void update()
- {
- updated();
- //
- // Recompute default id
- //
- _defaultAdapterId = getAdapter().getDefaultAdapterId(_name.getText().trim());
- refreshId();
- }
- });
-
- _name.setToolTipText(
- "Identifies this object adapter within an Ice communicator");
-
- _endpoints.getDocument().addDocumentListener(_updateListener);
- _endpoints.setToolTipText(
- "<html>The network interface(s) on which this object adapter receives requests;<br>"
- + "for example:<br>"
- + " tcp (listen on all local interfaces using a random port)<br>"
- + " tcp -h venus.foo.com (listen on just one interface)<br>"
- + " tcp -t 10000 (sets a timeout of 10,000 milliseconds)<br>"
- + " ssl -h venus.foo.com (accepts SSL connections instead of plain TCP)"
- + "</html>");
-
- _description.getDocument().addDocumentListener(_updateListener);
- _description.setToolTipText(
- "An optional description for this object adapter");
-
- JTextField idTextField = (JTextField)
- _id.getEditor().getEditorComponent();
- idTextField.getDocument().addDocumentListener(_updateListener);
- _id.setToolTipText("Identities this object adapter within an IceGrid deployment");
-
- JTextField replicaGroupIdTextField = (JTextField)
- _replicaGroupId.getEditor().getEditorComponent();
- replicaGroupIdTextField.getDocument().addDocumentListener(_updateListener);
- _replicaGroupId.setToolTipText("Select a replica group");
-
- JTextField publishedEndpointsTextField = (JTextField)
- _publishedEndpoints.getEditor().getEditorComponent();
- publishedEndpointsTextField.getDocument().addDocumentListener(_updateListener);
- _publishedEndpoints.setToolTipText(
- "Endpoints registered with the IceGrid Registry during the activation of this adapter.");
- }
-
-
- //
- // From CommunicatorChildEditor
- //
-
- void writeDescriptor()
- {
- AdapterDescriptor descriptor =
- (AdapterDescriptor)getAdapter().getDescriptor();
- descriptor.name = _name.getText().trim();
- descriptor.description = _description.getText();
- descriptor.id = getIdAsString();
- descriptor.replicaGroupId = getReplicaGroupIdAsString();
- descriptor.registerProcess = _registerProcess.isSelected();
- descriptor.waitForActivation = _waitForActivation.isSelected();
- descriptor.objects = mapToObjectDescriptorSeq(_objects.get());
- descriptor.allocatables = mapToObjectDescriptorSeq(_allocatables.get());
- }
-
- boolean isSimpleUpdate()
- {
- AdapterDescriptor descriptor =
- (AdapterDescriptor)getAdapter().getDescriptor();
-
- return descriptor.name.equals(_name.getText().trim());
- }
-
- Communicator.ChildList getChildList()
- {
- return ((Communicator)_target.getParent()).getAdapters();
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Adapter 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(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Adapter ID");
- builder.append(_id, 3);
- builder.nextLine();
-
- builder.append("Replica Group", _replicaGroupId);
- builder.append(_replicaGroupButton);
- builder.nextLine();
-
- builder.append("Endpoints" );
- builder.append(_endpoints, 3);
- builder.nextLine();
-
- builder.append("Published Endpoints" );
- builder.append(_publishedEndpoints, 3);
- builder.nextLine();
-
- builder.append("", _registerProcess);
- builder.nextLine();
- builder.append("", _waitForActivation);
- builder.nextLine();
-
- builder.append("Well-known Objects");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_objects);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Allocatable Objects");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_allocatables);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Adapter Properties");
- }
-
-
- void postUpdate()
- {
- //
- // Change enclosing properties after successful update
- //
- String name = _name.getText().trim();
- Adapter adapter = getAdapter();
- if(!name.equals(_oldName))
- {
- adapter.removeProperty(_oldName, "Endpoints");
- adapter.removeProperty(_oldName, "PublishedEndpoints");
- _oldName = name;
- }
-
- adapter.setProperty(name, "Endpoints", _endpoints.getText().trim());
-
- Object published = _publishedEndpoints.getSelectedItem();
- if(published == PUBLISH_ACTUAL)
- {
- adapter.removeProperty(name, "PublishedEndpoints");
- }
- else
- {
- adapter.setProperty(name, "PublishedEndpoints",
- published.toString().trim());
-
- }
- }
-
- private void setId(String id)
- {
- if(id.equals(_defaultAdapterId))
- {
- _id.setSelectedItem(DEFAULT_ADAPTER_ID);
- }
- else
- {
- _id.setSelectedItem(id);
- }
- }
-
- private void refreshId()
- {
- Object id = _id.getSelectedItem();
- _id.setModel(new DefaultComboBoxModel(new Object[]
- {DEFAULT_ADAPTER_ID}));
- _id.setSelectedItem(id);
- }
-
- private String getIdAsString()
- {
- Object obj = _id.getSelectedItem();
- return obj.toString().trim();
- }
-
- private void setReplicaGroupId(String replicaGroupId)
- {
- if(replicaGroupId.equals(""))
- {
- _replicaGroupId.setSelectedItem(NOT_REPLICATED);
- }
- else
- {
- ReplicaGroups replicaGroups =
- getAdapter().getRoot().getReplicaGroups();
-
- ReplicaGroup replicaGroup =
- (ReplicaGroup)replicaGroups.findChild(replicaGroupId);
-
- if(replicaGroup != null)
- {
- _replicaGroupId.setSelectedItem(replicaGroup);
- }
- else
- {
- _replicaGroupId.setSelectedItem(replicaGroupId);
- }
- }
- }
-
- private String getReplicaGroupIdAsString()
- {
- Object obj = _replicaGroupId.getSelectedItem();
- if(obj == NOT_REPLICATED)
- {
- return "";
- }
- else
- {
- return obj.toString().trim();
- }
- }
-
- protected boolean validate()
- {
- return check(new String[]{
- "Adapter Name", _name.getText().trim(),
- "Adapter ID", getIdAsString(),
- "Endpoints", _endpoints.getText().trim()
- });
- }
-
- void show(Adapter adapter)
- {
- detectUpdates(false);
- _target = adapter;
-
- AdapterDescriptor descriptor = (AdapterDescriptor)adapter.getDescriptor();
-
- final Utils.Resolver resolver = adapter.getCoordinator().substitute() ?
- adapter.getResolver() : null;
-
- boolean isEditable = resolver == null;
- boolean inIceBox = adapter.inIceBox();
-
- _oldName = descriptor.name;
-
- _name.setText(Utils.substitute(descriptor.name, resolver));
- _name.setEditable(isEditable && !inIceBox);
-
- _description.setText(
- Utils.substitute(descriptor.description, resolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
-
- //
- // Need to make control editable & enabled before changing it
- //
- _id.setEnabled(true);
- _id.setEditable(true);
- _defaultAdapterId = adapter.getDefaultAdapterId();
- refreshId();
- if(descriptor.id == null)
- {
- descriptor.id = _defaultAdapterId;
- }
-
- setId(Utils.substitute(descriptor.id, resolver));
- _id.setEnabled(isEditable);
- _id.setEditable(isEditable);
-
- _replicaGroupId.setEnabled(true);
- _replicaGroupId.setEditable(true);
-
- final ReplicaGroups replicaGroups =
- adapter.getRoot().getReplicaGroups();
- _replicaGroupId.setModel(replicaGroups.createComboBoxModel(NOT_REPLICATED));
-
- _replicaGroupId.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- if(e.getStateChange() == ItemEvent.SELECTED)
- {
- Object item = e.getItem();
- boolean enabled = (item instanceof ReplicaGroup);
- if(!enabled && item != NOT_REPLICATED)
- {
- if(resolver != null)
- {
- String replicaGroupId =
- resolver.substitute(item.toString().trim());
- enabled = (replicaGroups.findChild(replicaGroupId) != null);
- }
- }
- _replicaGroupButton.setEnabled(enabled);
- }
- }
- });
-
- setReplicaGroupId(Utils.substitute(descriptor.replicaGroupId, resolver));
- _replicaGroupId.setEnabled(isEditable);
- _replicaGroupId.setEditable(isEditable);
-
- if(adapter.isEphemeral())
- {
- _endpoints.setText("default");
- }
- else
- {
- _endpoints.setText(Utils.substitute(adapter.getProperty("Endpoints"), resolver));
- }
- _endpoints.setEditable(isEditable);
-
- _publishedEndpoints.setEnabled(true);
- _publishedEndpoints.setEditable(true);
- String published =
- Utils.substitute(adapter.getProperty("PublishedEndpoints"), resolver);
- if(published == null || published.equals(""))
- {
- _publishedEndpoints.setSelectedItem(PUBLISH_ACTUAL);
- }
- else
- {
- _publishedEndpoints.setSelectedItem(published);
- }
- _publishedEndpoints.setEnabled(isEditable);
- _publishedEndpoints.setEditable(isEditable);
-
- //
- // Objects
- //
- _objects.set(objectDescriptorSeqToMap(descriptor.objects), resolver, isEditable);
- _allocatables.set(objectDescriptorSeqToMap(descriptor.allocatables), resolver, isEditable);
-
- _registerProcess.setSelected(descriptor.registerProcess);
- _registerProcess.setEnabled(isEditable);
-
- _waitForActivation.setSelected(descriptor.waitForActivation);
- _waitForActivation.setEnabled(isEditable);
-
- _applyButton.setEnabled(adapter.isEphemeral());
- _discardButton.setEnabled(adapter.isEphemeral());
- detectUpdates(true);
- }
-
- Adapter getAdapter()
- {
- return (Adapter)_target;
- }
-
- static java.util.Map objectDescriptorSeqToMap(java.util.List objects)
- {
- java.util.Map result = new java.util.TreeMap();
- java.util.Iterator p = objects.iterator();
- while(p.hasNext())
- {
- ObjectDescriptor od = (ObjectDescriptor)p.next();
- result.put(Ice.Util.identityToString(od.id),
- od.type);
- }
- return result;
- }
-
- static java.util.LinkedList mapToObjectDescriptorSeq(java.util.Map map)
- {
- java.util.LinkedList result = new java.util.LinkedList();
- java.util.Iterator p = map.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- Ice.Identity id =
- Ice.Util.stringToIdentity((String)entry.getKey());
- String type = (String)entry.getValue();
- result.add(new ObjectDescriptor(id, type));
- }
- return result;
- }
-
- private String _defaultAdapterId = "";
-
- private final Object DEFAULT_ADAPTER_ID = new Object()
- {
- public String toString()
- {
- return _defaultAdapterId;
- }
- };
-
- private String _oldName;
-
- private JTextField _name = new JTextField(20);
- private JTextArea _description = new JTextArea(3, 20);
-
- private JComboBox _id = new JComboBox(new Object[] {DEFAULT_ADAPTER_ID});
- private JComboBox _replicaGroupId = new JComboBox();
- private JButton _replicaGroupButton;
-
- private JTextField _endpoints = new JTextField(20);
- private JComboBox _publishedEndpoints = new JComboBox(
- new Object[]{PUBLISH_ACTUAL});
-
- private JTextField _currentStatus = new JTextField(20);
- private JTextField _currentEndpoints = new JTextField(20);
-
- private JCheckBox _registerProcess;
- private JCheckBox _waitForActivation;
-
- private MapField _objects;
- private MapField _allocatables;
-
- static private final Object PUBLISH_ACTUAL = new Object()
- {
- public String toString()
- {
- return "Actual endpoints";
- }
- };
-
- static private final Object NOT_REPLICATED = new Object()
- {
- public String toString()
- {
- return "Does not belong to a replica group";
- }
- };
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.AbstractAction;
+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.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class AdapterEditor extends CommunicatorChildEditor
+{
+ AdapterEditor()
+ {
+ _objects = new MapField(this, "Identity", "Type", true);
+ _allocatables = new MapField(this, "Identity", "Type", true);
+
+ //
+ // Create buttons
+ //
+
+ //
+ // _replicaGroupButton
+ //
+ Action gotoReplicaGroup = new AbstractAction(
+ "", Utils.getIcon("/icons/16x16/goto.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Object obj = _replicaGroupId.getSelectedItem();
+ Adapter adapter = getAdapter();
+
+ ReplicaGroup rg = null;
+ if(obj instanceof ReplicaGroup)
+ {
+ rg = (ReplicaGroup)obj;
+ }
+ else
+ {
+ String replicaGroupId =
+ Utils.substitute(obj.toString(), adapter.getResolver());
+
+ rg = adapter.getRoot().findReplicaGroup(replicaGroupId);
+ }
+
+ //
+ // The button is enabled therefore rg should be != null
+ //
+ if(rg != null)
+ {
+ adapter.getRoot().setSelectedNode(rg);
+ }
+ }
+ };
+ gotoReplicaGroup.putValue(Action.SHORT_DESCRIPTION,
+ "Goto the definition of this replica group");
+ _replicaGroupButton = new JButton(gotoReplicaGroup);
+
+ Action checkRegisterProcess = new AbstractAction("Register Process")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ updated();
+ }
+ };
+ _registerProcess = new JCheckBox(checkRegisterProcess);
+ _registerProcess.setToolTipText(
+ "<html>During activation, create a Process object<br>"
+ + "in this adapter and register it with IceGrid<br>"
+ + "to enable clean shutdown; you should register<br>"
+ + "exactly one Process object per server.</html>");
+
+ Action checkWaitForActivation =
+ new AbstractAction("Wait for Activation")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ updated();
+ }
+ };
+ _waitForActivation = new JCheckBox(checkWaitForActivation);
+ _waitForActivation.setToolTipText(
+ "<html>When starting the enclosing server, "
+ + "does IceGrid<br>wait for this adapter to become active?</html>");
+ //
+ // Associate updateListener with various fields
+ //
+ _name.getDocument().addDocumentListener(
+ new DocumentListener()
+ {
+ public void changedUpdate(DocumentEvent e)
+ {
+ update();
+ }
+
+ public void insertUpdate(DocumentEvent e)
+ {
+ update();
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ update();
+ }
+
+ private void update()
+ {
+ updated();
+ //
+ // Recompute default id
+ //
+ _defaultAdapterId = getAdapter().getDefaultAdapterId(_name.getText().trim());
+ refreshId();
+ }
+ });
+
+ _name.setToolTipText(
+ "Identifies this object adapter within an Ice communicator");
+
+ _endpoints.getDocument().addDocumentListener(_updateListener);
+ _endpoints.setToolTipText(
+ "<html>The network interface(s) on which this object adapter receives requests;<br>"
+ + "for example:<br>"
+ + " tcp (listen on all local interfaces using a random port)<br>"
+ + " tcp -h venus.foo.com (listen on just one interface)<br>"
+ + " tcp -t 10000 (sets a timeout of 10,000 milliseconds)<br>"
+ + " ssl -h venus.foo.com (accepts SSL connections instead of plain TCP)"
+ + "</html>");
+
+ _description.getDocument().addDocumentListener(_updateListener);
+ _description.setToolTipText(
+ "An optional description for this object adapter");
+
+ JTextField idTextField = (JTextField)
+ _id.getEditor().getEditorComponent();
+ idTextField.getDocument().addDocumentListener(_updateListener);
+ _id.setToolTipText("Identities this object adapter within an IceGrid deployment");
+
+ JTextField replicaGroupIdTextField = (JTextField)
+ _replicaGroupId.getEditor().getEditorComponent();
+ replicaGroupIdTextField.getDocument().addDocumentListener(_updateListener);
+ _replicaGroupId.setToolTipText("Select a replica group");
+
+ JTextField publishedEndpointsTextField = (JTextField)
+ _publishedEndpoints.getEditor().getEditorComponent();
+ publishedEndpointsTextField.getDocument().addDocumentListener(_updateListener);
+ _publishedEndpoints.setToolTipText(
+ "Endpoints registered with the IceGrid Registry during the activation of this adapter.");
+ }
+
+
+ //
+ // From CommunicatorChildEditor
+ //
+
+ void writeDescriptor()
+ {
+ AdapterDescriptor descriptor =
+ (AdapterDescriptor)getAdapter().getDescriptor();
+ descriptor.name = _name.getText().trim();
+ descriptor.description = _description.getText();
+ descriptor.id = getIdAsString();
+ descriptor.replicaGroupId = getReplicaGroupIdAsString();
+ descriptor.registerProcess = _registerProcess.isSelected();
+ descriptor.waitForActivation = _waitForActivation.isSelected();
+ descriptor.objects = mapToObjectDescriptorSeq(_objects.get());
+ descriptor.allocatables = mapToObjectDescriptorSeq(_allocatables.get());
+ }
+
+ boolean isSimpleUpdate()
+ {
+ AdapterDescriptor descriptor =
+ (AdapterDescriptor)getAdapter().getDescriptor();
+
+ return descriptor.name.equals(_name.getText().trim());
+ }
+
+ Communicator.ChildList getChildList()
+ {
+ return ((Communicator)_target.getParent()).getAdapters();
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Adapter 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(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Adapter ID");
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ builder.append("Replica Group", _replicaGroupId);
+ builder.append(_replicaGroupButton);
+ builder.nextLine();
+
+ builder.append("Endpoints" );
+ builder.append(_endpoints, 3);
+ builder.nextLine();
+
+ builder.append("Published Endpoints" );
+ builder.append(_publishedEndpoints, 3);
+ builder.nextLine();
+
+ builder.append("", _registerProcess);
+ builder.nextLine();
+ builder.append("", _waitForActivation);
+ builder.nextLine();
+
+ builder.append("Well-known Objects");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_objects);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Allocatable Objects");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_allocatables);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Adapter Properties");
+ }
+
+
+ void postUpdate()
+ {
+ //
+ // Change enclosing properties after successful update
+ //
+ String name = _name.getText().trim();
+ Adapter adapter = getAdapter();
+ if(!name.equals(_oldName))
+ {
+ adapter.removeProperty(_oldName, "Endpoints");
+ adapter.removeProperty(_oldName, "PublishedEndpoints");
+ _oldName = name;
+ }
+
+ adapter.setProperty(name, "Endpoints", _endpoints.getText().trim());
+
+ Object published = _publishedEndpoints.getSelectedItem();
+ if(published == PUBLISH_ACTUAL)
+ {
+ adapter.removeProperty(name, "PublishedEndpoints");
+ }
+ else
+ {
+ adapter.setProperty(name, "PublishedEndpoints",
+ published.toString().trim());
+
+ }
+ }
+
+ private void setId(String id)
+ {
+ if(id.equals(_defaultAdapterId))
+ {
+ _id.setSelectedItem(DEFAULT_ADAPTER_ID);
+ }
+ else
+ {
+ _id.setSelectedItem(id);
+ }
+ }
+
+ private void refreshId()
+ {
+ Object id = _id.getSelectedItem();
+ _id.setModel(new DefaultComboBoxModel(new Object[]
+ {DEFAULT_ADAPTER_ID}));
+ _id.setSelectedItem(id);
+ }
+
+ private String getIdAsString()
+ {
+ Object obj = _id.getSelectedItem();
+ return obj.toString().trim();
+ }
+
+ private void setReplicaGroupId(String replicaGroupId)
+ {
+ if(replicaGroupId.equals(""))
+ {
+ _replicaGroupId.setSelectedItem(NOT_REPLICATED);
+ }
+ else
+ {
+ ReplicaGroups replicaGroups =
+ getAdapter().getRoot().getReplicaGroups();
+
+ ReplicaGroup replicaGroup =
+ (ReplicaGroup)replicaGroups.findChild(replicaGroupId);
+
+ if(replicaGroup != null)
+ {
+ _replicaGroupId.setSelectedItem(replicaGroup);
+ }
+ else
+ {
+ _replicaGroupId.setSelectedItem(replicaGroupId);
+ }
+ }
+ }
+
+ private String getReplicaGroupIdAsString()
+ {
+ Object obj = _replicaGroupId.getSelectedItem();
+ if(obj == NOT_REPLICATED)
+ {
+ return "";
+ }
+ else
+ {
+ return obj.toString().trim();
+ }
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{
+ "Adapter Name", _name.getText().trim(),
+ "Adapter ID", getIdAsString(),
+ "Endpoints", _endpoints.getText().trim()
+ });
+ }
+
+ void show(Adapter adapter)
+ {
+ detectUpdates(false);
+ _target = adapter;
+
+ AdapterDescriptor descriptor = (AdapterDescriptor)adapter.getDescriptor();
+
+ final Utils.Resolver resolver = adapter.getCoordinator().substitute() ?
+ adapter.getResolver() : null;
+
+ boolean isEditable = resolver == null;
+ boolean inIceBox = adapter.inIceBox();
+
+ _oldName = descriptor.name;
+
+ _name.setText(Utils.substitute(descriptor.name, resolver));
+ _name.setEditable(isEditable && !inIceBox);
+
+ _description.setText(
+ Utils.substitute(descriptor.description, resolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+
+ //
+ // Need to make control editable & enabled before changing it
+ //
+ _id.setEnabled(true);
+ _id.setEditable(true);
+ _defaultAdapterId = adapter.getDefaultAdapterId();
+ refreshId();
+ if(descriptor.id == null)
+ {
+ descriptor.id = _defaultAdapterId;
+ }
+
+ setId(Utils.substitute(descriptor.id, resolver));
+ _id.setEnabled(isEditable);
+ _id.setEditable(isEditable);
+
+ _replicaGroupId.setEnabled(true);
+ _replicaGroupId.setEditable(true);
+
+ final ReplicaGroups replicaGroups =
+ adapter.getRoot().getReplicaGroups();
+ _replicaGroupId.setModel(replicaGroups.createComboBoxModel(NOT_REPLICATED));
+
+ _replicaGroupId.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ if(e.getStateChange() == ItemEvent.SELECTED)
+ {
+ Object item = e.getItem();
+ boolean enabled = (item instanceof ReplicaGroup);
+ if(!enabled && item != NOT_REPLICATED)
+ {
+ if(resolver != null)
+ {
+ String replicaGroupId =
+ resolver.substitute(item.toString().trim());
+ enabled = (replicaGroups.findChild(replicaGroupId) != null);
+ }
+ }
+ _replicaGroupButton.setEnabled(enabled);
+ }
+ }
+ });
+
+ setReplicaGroupId(Utils.substitute(descriptor.replicaGroupId, resolver));
+ _replicaGroupId.setEnabled(isEditable);
+ _replicaGroupId.setEditable(isEditable);
+
+ if(adapter.isEphemeral())
+ {
+ _endpoints.setText("default");
+ }
+ else
+ {
+ _endpoints.setText(Utils.substitute(adapter.getProperty("Endpoints"), resolver));
+ }
+ _endpoints.setEditable(isEditable);
+
+ _publishedEndpoints.setEnabled(true);
+ _publishedEndpoints.setEditable(true);
+ String published =
+ Utils.substitute(adapter.getProperty("PublishedEndpoints"), resolver);
+ if(published == null || published.equals(""))
+ {
+ _publishedEndpoints.setSelectedItem(PUBLISH_ACTUAL);
+ }
+ else
+ {
+ _publishedEndpoints.setSelectedItem(published);
+ }
+ _publishedEndpoints.setEnabled(isEditable);
+ _publishedEndpoints.setEditable(isEditable);
+
+ //
+ // Objects
+ //
+ _objects.set(objectDescriptorSeqToMap(descriptor.objects), resolver, isEditable);
+ _allocatables.set(objectDescriptorSeqToMap(descriptor.allocatables), resolver, isEditable);
+
+ _registerProcess.setSelected(descriptor.registerProcess);
+ _registerProcess.setEnabled(isEditable);
+
+ _waitForActivation.setSelected(descriptor.waitForActivation);
+ _waitForActivation.setEnabled(isEditable);
+
+ _applyButton.setEnabled(adapter.isEphemeral());
+ _discardButton.setEnabled(adapter.isEphemeral());
+ detectUpdates(true);
+ }
+
+ Adapter getAdapter()
+ {
+ return (Adapter)_target;
+ }
+
+ static java.util.Map objectDescriptorSeqToMap(java.util.List objects)
+ {
+ java.util.Map result = new java.util.TreeMap();
+ java.util.Iterator p = objects.iterator();
+ while(p.hasNext())
+ {
+ ObjectDescriptor od = (ObjectDescriptor)p.next();
+ result.put(Ice.Util.identityToString(od.id),
+ od.type);
+ }
+ return result;
+ }
+
+ static java.util.LinkedList mapToObjectDescriptorSeq(java.util.Map map)
+ {
+ java.util.LinkedList result = new java.util.LinkedList();
+ java.util.Iterator p = map.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ Ice.Identity id =
+ Ice.Util.stringToIdentity((String)entry.getKey());
+ String type = (String)entry.getValue();
+ result.add(new ObjectDescriptor(id, type));
+ }
+ return result;
+ }
+
+ private String _defaultAdapterId = "";
+
+ private final Object DEFAULT_ADAPTER_ID = new Object()
+ {
+ public String toString()
+ {
+ return _defaultAdapterId;
+ }
+ };
+
+ private String _oldName;
+
+ private JTextField _name = new JTextField(20);
+ private JTextArea _description = new JTextArea(3, 20);
+
+ private JComboBox _id = new JComboBox(new Object[] {DEFAULT_ADAPTER_ID});
+ private JComboBox _replicaGroupId = new JComboBox();
+ private JButton _replicaGroupButton;
+
+ private JTextField _endpoints = new JTextField(20);
+ private JComboBox _publishedEndpoints = new JComboBox(
+ new Object[]{PUBLISH_ACTUAL});
+
+ private JTextField _currentStatus = new JTextField(20);
+ private JTextField _currentEndpoints = new JTextField(20);
+
+ private JCheckBox _registerProcess;
+ private JCheckBox _waitForActivation;
+
+ private MapField _objects;
+ private MapField _allocatables;
+
+ static private final Object PUBLISH_ACTUAL = new Object()
+ {
+ public String toString()
+ {
+ return "Actual endpoints";
+ }
+ };
+
+ static private final Object NOT_REPLICATED = new Object()
+ {
+ public String toString()
+ {
+ return "Does not belong to a replica group";
+ }
+ };
+}
diff --git a/java/src/IceGridGUI/Application/ApplicationEditor.java b/java/src/IceGridGUI/Application/ApplicationEditor.java
index 98252d32962..474d676ed7c 100755
--- a/java/src/IceGridGUI/Application/ApplicationEditor.java
+++ b/java/src/IceGridGUI/Application/ApplicationEditor.java
@@ -1,252 +1,252 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ApplicationEditor extends Editor
-{
- protected boolean applyUpdate()
- {
- Root root = (Root)_target;
- MainPane mainPane = _target.getCoordinator().getMainPane();
-
- root.disableSelectionListener();
- try
- {
- if(isSimpleUpdate())
- {
- writeDescriptor();
- root.updated();
- root.getEditable().markModified();
- }
- else
- {
- //
- // Save to be able to rollback
- //
- ApplicationDescriptor savedDescriptor = root.saveDescriptor();
- writeDescriptor();
- try
- {
- root.rebuild();
- }
- catch(UpdateFailedException e)
- {
- root.restoreDescriptor(savedDescriptor);
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- //
- // Success
- //
- root.updated();
- root.getEditable().markModified();
-
- if(!savedDescriptor.name.equals(root.getId()))
- {
- mainPane.resetTitle(root);
- }
- }
-
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-
- ApplicationEditor()
- {
- _name.getDocument().addDocumentListener(_updateListener);
- _description.getDocument().addDocumentListener(_updateListener);
-
- //
- // Variables
- //
- _variables = new MapField(this, "Name", "Value", false);
-
- //
- // Distrib
- //
- _distrib = new JComboBox(new Object[]{NO_DISTRIB, DEFAULT_DISTRIB});
- _distrib.setEditable(true);
- _distrib.setToolTipText("The proxy to the IcePatch2 server holding your files");
-
- JTextField distribTextField = (JTextField)
- _distrib.getEditor().getEditorComponent();
- distribTextField.getDocument().addDocumentListener(
- _updateListener);
-
- _distribDirs.getDocument().addDocumentListener(_updateListener);
- _distribDirs.setToolTipText(
- "<html>Include only these directories when patching.<br>"
- + "Use whitespace as separator; use double-quotes around directories containing whitespaces</html>");
-
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Name");
- builder.append(_name, 3);
-
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Variables");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_variables);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- JComponent c = builder.appendSeparator("Distribution");
- c.setToolTipText("Files shared by all servers in your application");
- builder.append("IcePatch2 Proxy");
- builder.append(_distrib, 3);
- builder.nextLine();
- builder.append("Directories");
- builder.append(_distribDirs, 3);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Application Properties");
- }
-
- boolean isSimpleUpdate()
- {
- ApplicationDescriptor descriptor = (ApplicationDescriptor)_target.getDescriptor();
- return descriptor.name.equals(_name.getText().trim())
- && _variables.get().equals(descriptor.variables);
- }
-
- void writeDescriptor()
- {
- ApplicationDescriptor descriptor = (ApplicationDescriptor)_target.getDescriptor();
- descriptor.name = _name.getText().trim();
- descriptor.variables = _variables.get();
- descriptor.description = _description.getText();
-
- if(_distrib.getSelectedItem() == NO_DISTRIB)
- {
- descriptor.distrib.icepatch = "";
- }
- else
- {
- descriptor.distrib.icepatch = _distrib.getSelectedItem().toString().trim();
- }
- descriptor.distrib.directories = _distribDirs.getList();
- }
-
- protected boolean validate()
- {
- return check(new String[]{"Name", _name.getText().trim()});
- }
-
- void show(Root root)
- {
- detectUpdates(false);
- _target = root;
-
- Utils.Resolver resolver = getDetailResolver();
- boolean isEditable = (resolver == null);
-
- ApplicationDescriptor descriptor =
- (ApplicationDescriptor)root.getDescriptor();
-
- _name.setText(descriptor.name);
- _name.setEditable(!root.isLive());
-
- _description.setText(
- Utils.substitute(descriptor.description, resolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
- _description.setToolTipText("An optional description for this application");
-
- _variables.set(descriptor.variables, resolver, isEditable);
-
- _distrib.setEnabled(true);
- _distrib.setEditable(true);
- String icepatch =
- Utils.substitute(descriptor.distrib.icepatch, resolver);
- if(icepatch.equals(""))
- {
- _distrib.setSelectedItem(NO_DISTRIB);
- }
- else
- {
- _distrib.setSelectedItem(icepatch);
- }
- _distrib.setEnabled(isEditable);
- _distrib.setEditable(isEditable);
-
- _distribDirs.setList(descriptor.distrib.directories, resolver);
- _distribDirs.setEditable(isEditable);
-
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- detectUpdates(true);
- }
-
- static private final Object NO_DISTRIB = new Object()
- {
- public String toString()
- {
- return "None selected";
- }
- };
- static private final String DEFAULT_DISTRIB = "${application}.IcePatch2/server";
-
- private JTextField _name = new JTextField(20);
- private JTextArea _description = new JTextArea(3, 20);
- private MapField _variables;
- private JComboBox _distrib;
- private ListTextField _distribDirs = new ListTextField(20);
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JComboBox;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ApplicationEditor extends Editor
+{
+ protected boolean applyUpdate()
+ {
+ Root root = (Root)_target;
+ MainPane mainPane = _target.getCoordinator().getMainPane();
+
+ root.disableSelectionListener();
+ try
+ {
+ if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ root.updated();
+ root.getEditable().markModified();
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ ApplicationDescriptor savedDescriptor = root.saveDescriptor();
+ writeDescriptor();
+ try
+ {
+ root.rebuild();
+ }
+ catch(UpdateFailedException e)
+ {
+ root.restoreDescriptor(savedDescriptor);
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ //
+ // Success
+ //
+ root.updated();
+ root.getEditable().markModified();
+
+ if(!savedDescriptor.name.equals(root.getId()))
+ {
+ mainPane.resetTitle(root);
+ }
+ }
+
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+
+ ApplicationEditor()
+ {
+ _name.getDocument().addDocumentListener(_updateListener);
+ _description.getDocument().addDocumentListener(_updateListener);
+
+ //
+ // Variables
+ //
+ _variables = new MapField(this, "Name", "Value", false);
+
+ //
+ // Distrib
+ //
+ _distrib = new JComboBox(new Object[]{NO_DISTRIB, DEFAULT_DISTRIB});
+ _distrib.setEditable(true);
+ _distrib.setToolTipText("The proxy to the IcePatch2 server holding your files");
+
+ JTextField distribTextField = (JTextField)
+ _distrib.getEditor().getEditorComponent();
+ distribTextField.getDocument().addDocumentListener(
+ _updateListener);
+
+ _distribDirs.getDocument().addDocumentListener(_updateListener);
+ _distribDirs.setToolTipText(
+ "<html>Include only these directories when patching.<br>"
+ + "Use whitespace as separator; use double-quotes around directories containing whitespaces</html>");
+
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Name");
+ builder.append(_name, 3);
+
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Variables");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_variables);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ JComponent c = builder.appendSeparator("Distribution");
+ c.setToolTipText("Files shared by all servers in your application");
+ builder.append("IcePatch2 Proxy");
+ builder.append(_distrib, 3);
+ builder.nextLine();
+ builder.append("Directories");
+ builder.append(_distribDirs, 3);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Application Properties");
+ }
+
+ boolean isSimpleUpdate()
+ {
+ ApplicationDescriptor descriptor = (ApplicationDescriptor)_target.getDescriptor();
+ return descriptor.name.equals(_name.getText().trim())
+ && _variables.get().equals(descriptor.variables);
+ }
+
+ void writeDescriptor()
+ {
+ ApplicationDescriptor descriptor = (ApplicationDescriptor)_target.getDescriptor();
+ descriptor.name = _name.getText().trim();
+ descriptor.variables = _variables.get();
+ descriptor.description = _description.getText();
+
+ if(_distrib.getSelectedItem() == NO_DISTRIB)
+ {
+ descriptor.distrib.icepatch = "";
+ }
+ else
+ {
+ descriptor.distrib.icepatch = _distrib.getSelectedItem().toString().trim();
+ }
+ descriptor.distrib.directories = _distribDirs.getList();
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"Name", _name.getText().trim()});
+ }
+
+ void show(Root root)
+ {
+ detectUpdates(false);
+ _target = root;
+
+ Utils.Resolver resolver = getDetailResolver();
+ boolean isEditable = (resolver == null);
+
+ ApplicationDescriptor descriptor =
+ (ApplicationDescriptor)root.getDescriptor();
+
+ _name.setText(descriptor.name);
+ _name.setEditable(!root.isLive());
+
+ _description.setText(
+ Utils.substitute(descriptor.description, resolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+ _description.setToolTipText("An optional description for this application");
+
+ _variables.set(descriptor.variables, resolver, isEditable);
+
+ _distrib.setEnabled(true);
+ _distrib.setEditable(true);
+ String icepatch =
+ Utils.substitute(descriptor.distrib.icepatch, resolver);
+ if(icepatch.equals(""))
+ {
+ _distrib.setSelectedItem(NO_DISTRIB);
+ }
+ else
+ {
+ _distrib.setSelectedItem(icepatch);
+ }
+ _distrib.setEnabled(isEditable);
+ _distrib.setEditable(isEditable);
+
+ _distribDirs.setList(descriptor.distrib.directories, resolver);
+ _distribDirs.setEditable(isEditable);
+
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ detectUpdates(true);
+ }
+
+ static private final Object NO_DISTRIB = new Object()
+ {
+ public String toString()
+ {
+ return "None selected";
+ }
+ };
+ static private final String DEFAULT_DISTRIB = "${application}.IcePatch2/server";
+
+ private JTextField _name = new JTextField(20);
+ private JTextArea _description = new JTextArea(3, 20);
+ private MapField _variables;
+ private JComboBox _distrib;
+ private ListTextField _distribDirs = new ListTextField(20);
+}
diff --git a/java/src/IceGridGUI/Application/Communicator.java b/java/src/IceGridGUI/Application/Communicator.java
index 7ebd77bd979..c051fea25c7 100755
--- a/java/src/IceGridGUI/Application/Communicator.java
+++ b/java/src/IceGridGUI/Application/Communicator.java
@@ -1,903 +1,903 @@
-// **********************************************************************
-//
-// 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 java.util.Enumeration;
-
-import javax.swing.JOptionPane;
-import javax.swing.tree.DefaultTreeModel;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// The base class for Server, Service, ServerTemplate and ServiceTemplate
-//
-abstract class Communicator extends TreeNode implements DescriptorHolder
-{
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- if(_p.hasNext())
- {
- return true;
- }
-
- while(++_index < _childListArray.length)
- {
- _p = _childListArray[_index].iterator();
- if(_p.hasNext())
- {
- return true;
- }
- }
- return false;
- }
-
- public Object nextElement()
- {
- try
- {
- return _p.next();
- }
- catch(java.util.NoSuchElementException nse)
- {
- if(hasMoreElements())
- {
- return _p.next();
- }
- else
- {
- throw nse;
- }
- }
- }
-
- private int _index = 0;
- private java.util.Iterator _p = _childListArray[0].iterator();
- };
- }
-
- public boolean getAllowsChildren()
- {
- return true;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- if(childIndex < 0)
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- int offset = 0;
- for(int i = 0; i < _childListArray.length; ++i)
- {
- if(childIndex < offset + _childListArray[i].size())
- {
- return _childListArray[i].get(childIndex - offset);
- }
- else
- {
- offset += _childListArray[i].size();
- }
- }
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
-
- public int getChildCount()
- {
- int result = 0;
- for(int i = 0; i < _childListArray.length; ++i)
- {
- result += _childListArray[i].size();
- }
- return result;
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- int offset = 0;
- for(int i = 0; i < _childListArray.length; ++i)
- {
- int index = _childListArray[i].indexOf(node);
- if(index == -1)
- {
- offset += _childListArray[i].size();
- }
- else
- {
- return offset + index;
- }
- }
- return -1;
- }
-
- public boolean isLeaf()
- {
- for(int i = 0; i < _childListArray.length; ++i)
- {
- if(!_childListArray[i].isEmpty())
- {
- return false;
- }
- }
- return true;
- }
-
- //
- // Actions
- //
-
- public void newAdapter()
- {
- _adapters.newChild();
- }
- public void newDbEnv()
- {
- _dbEnvs.newChild();
- }
- public void newService()
- {
- _services.newChild();
- }
- public void newServiceFromTemplate()
- {
- _services.newServiceFromTemplate();
- }
-
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
-
- if(descriptor instanceof AdapterDescriptor)
- {
- AdapterDescriptor d = (AdapterDescriptor)descriptor;
- _adapters.newAdapter(Adapter.copyDescriptor(d));
- }
- else if(descriptor instanceof DbEnvDescriptor)
- {
- DbEnvDescriptor d = (DbEnvDescriptor)descriptor;
- _dbEnvs.newDbEnv(DbEnv.copyDescriptor(d));
- }
- else if(descriptor instanceof ServiceInstanceDescriptor && _services.initialized())
- {
- ServiceInstanceDescriptor d = (ServiceInstanceDescriptor)descriptor;
- _services.newService(ServiceInstance.copyDescriptor(d));
- }
- else
- {
- ((TreeNode)_parent).paste();
- }
- }
-
- abstract CommunicatorDescriptor getCommunicatorDescriptor();
- abstract Editable getEnclosingEditable();
-
- //
- // When 'this' is a template, returns all instances of this template.
- // Otherwise, return just 'this'
- //
- java.util.List findInstances()
- {
- java.util.List result = new java.util.LinkedList();
- result.add(this);
- return result;
- }
-
-
- TreeNode findChildLike(TreeNode other)
- {
- if(other instanceof Adapter)
- {
- return _adapters.findChildById(other.getId());
- }
- else if(other instanceof DbEnv)
- {
- return _dbEnvs.findChildById(other.getId());
- }
- else if(other instanceof Service)
- {
- return _dbEnvs.findChildById(other.getId());
- }
- else
- {
- return null;
- }
- }
-
- boolean isIceBox()
- {
- return false;
- }
-
- protected Communicator(TreeNode parent, String id)
- {
- super(parent, id);
- }
-
- abstract class ChildList
- {
- abstract TreeNode createChild(Object descriptor) throws UpdateFailedException;
- abstract void newChild();
-
- protected ChildList(boolean sorted)
- {
- _sorted = sorted;
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- TreeNode child = (TreeNode)p.next();
- child.write(writer);
- }
- }
-
- //
- // Some list-like methods
- //
- java.util.Iterator iterator()
- {
- return _children.iterator();
- }
-
- TreeNode get(int index)
- {
- return (TreeNode)_children.get(index);
- }
-
- int indexOf(Object obj)
- {
- return _children.indexOf(obj);
- }
-
- int size()
- {
- return _children.size();
- }
-
- boolean isEmpty()
- {
- return _children.isEmpty();
- }
-
- //
- // Non-list methods
- //
-
- void init(java.util.List descriptors) throws UpdateFailedException
- {
- assert _descriptors == null;
- assert _children.isEmpty();
-
- _descriptors = descriptors;
- java.util.Iterator p = _descriptors.iterator();
-
- while(p.hasNext())
- {
- Object descriptor = p.next();
- TreeNode child = createChild(descriptor);
- addChild(child, false);
- }
- }
-
- boolean initialized()
- {
- return _descriptors != null;
- }
-
- void clear()
- {
- _descriptors = null;
- _children.clear();
- }
-
- TreeNode addNewChild(Object descriptor) throws UpdateFailedException
- {
- TreeNode child = createChild(descriptor);
- addChild(child, true);
-
- return child;
- }
-
- TreeNode findChildWithDescriptor(Object descriptor)
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- TreeNode child = (TreeNode)p.next();
- if(child.getDescriptor() == descriptor)
- {
- return child;
- }
- }
- return null;
- }
-
- TreeNode findChildById(String id)
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- TreeNode child = (TreeNode)p.next();
- if(child.getId().equals(id))
- {
- return child;
- }
- }
- return null;
- }
-
- void addChild(TreeNode child, boolean fireEvent) throws UpdateFailedException
- {
- if(_sorted)
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- if(!insertSortedChild(child, _children, treeModel))
- {
- throw new UpdateFailedException(Communicator.this, child.getId());
- }
- }
- else
- {
- //
- // Just add the child at the end of the list
- //
- _children.add(child);
- if(fireEvent)
- {
- getRoot().getTreeModel().nodesWereInserted(Communicator.this, new int[]{getIndex(child)});
- }
- }
- }
-
- int removeChild(TreeNode child)
- {
- int index = getIndex(child);
-
- _children.remove(child);
-
- getRoot().getTreeModel().nodesWereRemoved(Communicator.this,
- new int[]{index},
- new Object[]{child});
- return index;
- }
-
- void destroyChild(TreeNode child)
- {
- if(child.isEphemeral())
- {
- removeChild(child);
- }
- else
- {
- Object descriptor = child.getDescriptor();
- removeDescriptor(descriptor);
- getEnclosingEditable().markModified();
- getRoot().updated();
- removeChild(child);
- }
- }
-
- void addDescriptor(Object descriptor)
- {
- _descriptors.add(descriptor);
- }
-
- void removeDescriptor(Object descriptor)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = _descriptors.iterator();
- while(p.hasNext())
- {
- if(descriptor == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
- boolean canMove(TreeNode child, boolean up)
- {
- int i = _children.indexOf(child);
- assert i != -1;
- return (up && i > 0) || (!up && i < _children.size() - 1);
- }
-
- void tryAdd(Object descriptor) throws UpdateFailedException
- {
- addDescriptor(descriptor);
- try
- {
- addNewChild(descriptor);
- }
- catch(UpdateFailedException e)
- {
- removeDescriptor(descriptor);
- throw e;
- }
- getEnclosingEditable().markModified();
- }
-
- void tryUpdate(TreeNode child) throws UpdateFailedException
- {
- //
- // Child is an Adapter or DbEnv
- //
- assert _sorted;
-
- Object descriptor = child.getDescriptor();
- removeChild(child);
- try
- {
- addNewChild(descriptor);
- }
- catch(UpdateFailedException e)
- {
- addChild(child, true);
- throw e;
- }
- getEnclosingEditable().markModified();
- }
-
- protected String makeNewChildId(String base)
- {
- String id = base;
- int i = 0;
- while(findChildById(id) != null)
- {
- id = base + "-" + (++i);
- }
- return id;
- }
-
- protected java.util.List _children = new java.util.LinkedList();
- protected java.util.List _descriptors;
- protected boolean _sorted;
- }
-
- class Adapters extends ChildList
- {
- Adapters()
- {
- super(true);
- }
-
- void newChild()
- {
- AdapterDescriptor descriptor = new AdapterDescriptor(
- "NewAdapter",
- "",
- null,
- "",
- false,
- true,
- new java.util.LinkedList(),
- new java.util.LinkedList()
- );
-
- newAdapter(descriptor);
- }
-
- TreeNode createChild(Object descriptor)
- {
- AdapterDescriptor ad = (AdapterDescriptor)descriptor;
- String name = Utils.substitute(ad.name, getResolver());
- return new Adapter(Communicator.this, name, ad, false);
- }
-
- private void newAdapter(AdapterDescriptor descriptor)
- {
- descriptor.name = makeNewChildId(descriptor.name);
- Adapter adapter = new Adapter(Communicator.this, descriptor.name, descriptor, true);
- try
- {
- addChild(adapter, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(adapter);
- }
-
- }
-
- class DbEnvs extends ChildList
- {
- DbEnvs()
- {
- super(true);
- }
-
- void newChild()
- {
- DbEnvDescriptor descriptor = new DbEnvDescriptor(
- "NewDbEnv",
- "",
- "",
- new java.util.LinkedList());
-
- newDbEnv(descriptor);
- }
-
- TreeNode createChild(Object descriptor)
- {
- DbEnvDescriptor dd = (DbEnvDescriptor)descriptor;
- String name = Utils.substitute(dd.name, getResolver());
- return new DbEnv(Communicator.this, name, dd, false);
- }
-
- private void newDbEnv(DbEnvDescriptor descriptor)
- {
- descriptor.name = makeNewChildId(descriptor.name);
- DbEnv dbEnv = new DbEnv(Communicator.this, descriptor.name, descriptor, true);
- try
- {
- addChild(dbEnv, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(dbEnv);
- }
-
- }
-
- class Services extends ChildList
- {
- Services()
- {
- super(false);
- }
-
- void newChild()
- {
- ServiceDescriptor serviceDescriptor =
- new ServiceDescriptor(new java.util.LinkedList(),
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
- new java.util.LinkedList(),
- "",
- "NewService",
- "");
-
- ServiceInstanceDescriptor descriptor =
- new ServiceInstanceDescriptor("",
- new java.util.HashMap(),
- serviceDescriptor,
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
-
- newService(descriptor);
- }
-
- void newServiceFromTemplate()
- {
- ServiceInstanceDescriptor descriptor =
- new ServiceInstanceDescriptor("",
- new java.util.HashMap(),
- null,
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
- newService(descriptor);
- }
-
- void move(TreeNode child, boolean up)
- {
- int index = getIndex(child);
- int listIndex = _children.indexOf(child);
-
- Object descriptor = child.getDescriptor();
-
- getEnclosingEditable().markModified();
- getRoot().updated();
-
- _descriptors.remove(listIndex);
- if(up)
- {
- _descriptors.add(listIndex - 1, descriptor);
- }
- else
- {
- _descriptors.add(listIndex + 1, descriptor);
- }
-
- _children.remove(listIndex);
- getRoot().getTreeModel().nodesWereRemoved(Communicator.this,
- new int[]{index},
- new Object[]{child});
- if(up)
- {
- _children.add(listIndex - 1, child);
- getRoot().getTreeModel().nodesWereInserted(Communicator.this,
- new int[]{index - 1});
-
- }
- else
- {
- _children.add(listIndex + 1, child);
- getRoot().getTreeModel().nodesWereInserted(Communicator.this,
- new int[]{index + 1});
-
- }
- getRoot().setSelectedNode(child);
- getCoordinator().showActions(child);
- }
-
- TreeNode createChild(Object o) throws UpdateFailedException
- {
- ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)o;
-
- if(descriptor.descriptor == null)
- {
- TemplateDescriptor templateDescriptor
- = getRoot().findServiceTemplateDescriptor(descriptor.template);
-
- assert templateDescriptor != null;
-
- String serviceName = null;
- String displayString = null;
- Utils.Resolver serviceResolver = null;
-
- if(Communicator.this instanceof PlainServer)
- {
- serviceResolver = new Utils.Resolver(getResolver(),
- descriptor.parameterValues,
- templateDescriptor.parameterDefaults);
-
- ServiceDescriptor serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
- assert serviceDescriptor != null;
-
- serviceName = serviceResolver.substitute(serviceDescriptor.name);
- serviceResolver.put("service", serviceName);
- displayString = serviceName + ": " + descriptor.template + "<>";
- }
- else
- {
- //
- // Note: service names don't have to be unique
- //
- serviceName = descriptor.template + "<>";
- }
-
- return new ServiceInstance(Communicator.this,
- serviceName,
- displayString,
- descriptor,
- serviceResolver);
- }
- else
- {
- ServiceDescriptor serviceDescriptor = descriptor.descriptor;
-
- String serviceName = null;
- Utils.Resolver serviceResolver = null;
-
- if(Communicator.this instanceof PlainServer)
- {
- serviceResolver = new Utils.Resolver(getResolver());
- serviceName = serviceResolver.substitute(serviceDescriptor.name);
- serviceResolver.put("service", serviceName);
- }
- else
- {
- serviceName = serviceDescriptor.name;
- }
-
- return new PlainService(Communicator.this,
- serviceName,
- descriptor,
- serviceResolver);
- }
- }
-
- void tryUpdate(TreeNode child) throws UpdateFailedException
- {
- //
- // Rebuilding a Service is quite different since the creation of a service can
- // trigger an UpdateFailedException
- //
- Object descriptor = child.getDescriptor();
- int listIndex = _children.indexOf(child);
- assert listIndex != -1;
-
- TreeNode newChild = createChild(descriptor);
- _children.set(listIndex, newChild);
- getRoot().getTreeModel().nodeChanged(newChild);
-
- getEnclosingEditable().markModified();
- }
-
- private void newService(ServiceInstanceDescriptor descriptor)
- {
- if(descriptor.descriptor == null)
- {
- String name = makeNewChildId("NewService");
-
- //
- // Make sure descriptor.template points to a real template
- //
- ServiceTemplate t = getRoot().findServiceTemplate(descriptor.template);
-
- if(t == null)
- {
- t = (ServiceTemplate)getRoot().getServiceTemplates().getChildAt(0);
-
- if(t == null)
- {
- JOptionPane.showMessageDialog(
- getCoordinator().getMainFrame(),
- "You need to create a service template before you can create a service from a template.",
- "No Service Template",
- JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- else
- {
- descriptor.template = t.getId();
- descriptor.parameterValues = new java.util.HashMap();
- }
- }
-
- //
- // Validate/update parameterValues
- //
- TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
- descriptor.parameterValues = Editor.makeParameterValues(descriptor.parameterValues,
- td.parameters);
-
-
- ServiceInstance service = new ServiceInstance(Communicator.this, name, descriptor);
- try
- {
- addChild(service, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(service);
- }
- else
- {
- descriptor.descriptor.name = makeNewChildId(descriptor.descriptor.name);
-
- PlainService service = new PlainService(Communicator.this, descriptor);
- try
- {
- addChild(service, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(service);
- }
- }
- }
-
- Adapters getAdapters()
- {
- return _adapters;
- }
-
- DbEnvs getDbEnvs()
- {
- return _dbEnvs;
- }
-
- Services getServices()
- {
- return _services;
- }
-
- java.util.List findServiceInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _services.iterator();
- while(p.hasNext())
- {
- Object obj = p.next();
- if(obj instanceof ServiceInstance)
- {
- ServiceInstance service = (ServiceInstance)obj;
- ServiceInstanceDescriptor d =
- (ServiceInstanceDescriptor)service.getDescriptor();
- if(d.template.equals(template))
- {
- result.add(service);
- }
- }
- }
- return result;
- }
-
- void removeServiceInstances(String template)
- {
- java.util.Iterator p = _services.iterator();
- while(p.hasNext())
- {
- Object obj = p.next();
- if(obj instanceof ServiceInstance)
- {
- ServiceInstance service = (ServiceInstance)obj;
- ServiceInstanceDescriptor d =
- (ServiceInstanceDescriptor)service.getDescriptor();
- if(d.template.equals(template))
- {
- _services.removeChild(service);
- _services.removeDescriptor(d);
- getEnclosingEditable().markModified();
- }
- }
- }
- }
-
- void removeSortedChildren(String[] childIds, java.util.List fromChildren)
- {
- removeSortedChildren(childIds, fromChildren, getRoot().getTreeModel());
- }
- void childrenChanged(java.util.List children)
- {
- childrenChanged(children, getRoot().getTreeModel());
- }
-
- String getProperty(String key)
- {
- CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
- java.util.Iterator p = descriptor.propertySet.properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- if(pd.name.equals(key))
- {
- return pd.value;
- }
- }
- return null;
- }
-
- void setProperty(String key, String newValue)
- {
- CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
- removeProperty(key);
- ((java.util.LinkedList)descriptor.propertySet.properties).addFirst(new PropertyDescriptor(key, newValue));
- }
-
- void removeProperty(String key)
- {
- CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
- java.util.Iterator p = descriptor.propertySet.properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- if(pd.name.equals(key))
- {
- p.remove();
- }
- }
- }
-
- //
- // Children
- //
- protected Adapters _adapters = new Adapters();
- protected DbEnvs _dbEnvs = new DbEnvs();
- protected Services _services = new Services();
- protected ChildList[] _childListArray = new ChildList[]{_adapters, _dbEnvs, _services};
-}
+// **********************************************************************
+//
+// 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 java.util.Enumeration;
+
+import javax.swing.JOptionPane;
+import javax.swing.tree.DefaultTreeModel;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// The base class for Server, Service, ServerTemplate and ServiceTemplate
+//
+abstract class Communicator extends TreeNode implements DescriptorHolder
+{
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ if(_p.hasNext())
+ {
+ return true;
+ }
+
+ while(++_index < _childListArray.length)
+ {
+ _p = _childListArray[_index].iterator();
+ if(_p.hasNext())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ try
+ {
+ return _p.next();
+ }
+ catch(java.util.NoSuchElementException nse)
+ {
+ if(hasMoreElements())
+ {
+ return _p.next();
+ }
+ else
+ {
+ throw nse;
+ }
+ }
+ }
+
+ private int _index = 0;
+ private java.util.Iterator _p = _childListArray[0].iterator();
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ if(childIndex < 0)
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ int offset = 0;
+ for(int i = 0; i < _childListArray.length; ++i)
+ {
+ if(childIndex < offset + _childListArray[i].size())
+ {
+ return _childListArray[i].get(childIndex - offset);
+ }
+ else
+ {
+ offset += _childListArray[i].size();
+ }
+ }
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+
+ public int getChildCount()
+ {
+ int result = 0;
+ for(int i = 0; i < _childListArray.length; ++i)
+ {
+ result += _childListArray[i].size();
+ }
+ return result;
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ int offset = 0;
+ for(int i = 0; i < _childListArray.length; ++i)
+ {
+ int index = _childListArray[i].indexOf(node);
+ if(index == -1)
+ {
+ offset += _childListArray[i].size();
+ }
+ else
+ {
+ return offset + index;
+ }
+ }
+ return -1;
+ }
+
+ public boolean isLeaf()
+ {
+ for(int i = 0; i < _childListArray.length; ++i)
+ {
+ if(!_childListArray[i].isEmpty())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ //
+ // Actions
+ //
+
+ public void newAdapter()
+ {
+ _adapters.newChild();
+ }
+ public void newDbEnv()
+ {
+ _dbEnvs.newChild();
+ }
+ public void newService()
+ {
+ _services.newChild();
+ }
+ public void newServiceFromTemplate()
+ {
+ _services.newServiceFromTemplate();
+ }
+
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+
+ if(descriptor instanceof AdapterDescriptor)
+ {
+ AdapterDescriptor d = (AdapterDescriptor)descriptor;
+ _adapters.newAdapter(Adapter.copyDescriptor(d));
+ }
+ else if(descriptor instanceof DbEnvDescriptor)
+ {
+ DbEnvDescriptor d = (DbEnvDescriptor)descriptor;
+ _dbEnvs.newDbEnv(DbEnv.copyDescriptor(d));
+ }
+ else if(descriptor instanceof ServiceInstanceDescriptor && _services.initialized())
+ {
+ ServiceInstanceDescriptor d = (ServiceInstanceDescriptor)descriptor;
+ _services.newService(ServiceInstance.copyDescriptor(d));
+ }
+ else
+ {
+ ((TreeNode)_parent).paste();
+ }
+ }
+
+ abstract CommunicatorDescriptor getCommunicatorDescriptor();
+ abstract Editable getEnclosingEditable();
+
+ //
+ // When 'this' is a template, returns all instances of this template.
+ // Otherwise, return just 'this'
+ //
+ java.util.List findInstances()
+ {
+ java.util.List result = new java.util.LinkedList();
+ result.add(this);
+ return result;
+ }
+
+
+ TreeNode findChildLike(TreeNode other)
+ {
+ if(other instanceof Adapter)
+ {
+ return _adapters.findChildById(other.getId());
+ }
+ else if(other instanceof DbEnv)
+ {
+ return _dbEnvs.findChildById(other.getId());
+ }
+ else if(other instanceof Service)
+ {
+ return _dbEnvs.findChildById(other.getId());
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ boolean isIceBox()
+ {
+ return false;
+ }
+
+ protected Communicator(TreeNode parent, String id)
+ {
+ super(parent, id);
+ }
+
+ abstract class ChildList
+ {
+ abstract TreeNode createChild(Object descriptor) throws UpdateFailedException;
+ abstract void newChild();
+
+ protected ChildList(boolean sorted)
+ {
+ _sorted = sorted;
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ TreeNode child = (TreeNode)p.next();
+ child.write(writer);
+ }
+ }
+
+ //
+ // Some list-like methods
+ //
+ java.util.Iterator iterator()
+ {
+ return _children.iterator();
+ }
+
+ TreeNode get(int index)
+ {
+ return (TreeNode)_children.get(index);
+ }
+
+ int indexOf(Object obj)
+ {
+ return _children.indexOf(obj);
+ }
+
+ int size()
+ {
+ return _children.size();
+ }
+
+ boolean isEmpty()
+ {
+ return _children.isEmpty();
+ }
+
+ //
+ // Non-list methods
+ //
+
+ void init(java.util.List descriptors) throws UpdateFailedException
+ {
+ assert _descriptors == null;
+ assert _children.isEmpty();
+
+ _descriptors = descriptors;
+ java.util.Iterator p = _descriptors.iterator();
+
+ while(p.hasNext())
+ {
+ Object descriptor = p.next();
+ TreeNode child = createChild(descriptor);
+ addChild(child, false);
+ }
+ }
+
+ boolean initialized()
+ {
+ return _descriptors != null;
+ }
+
+ void clear()
+ {
+ _descriptors = null;
+ _children.clear();
+ }
+
+ TreeNode addNewChild(Object descriptor) throws UpdateFailedException
+ {
+ TreeNode child = createChild(descriptor);
+ addChild(child, true);
+
+ return child;
+ }
+
+ TreeNode findChildWithDescriptor(Object descriptor)
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ TreeNode child = (TreeNode)p.next();
+ if(child.getDescriptor() == descriptor)
+ {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ TreeNode findChildById(String id)
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ TreeNode child = (TreeNode)p.next();
+ if(child.getId().equals(id))
+ {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ void addChild(TreeNode child, boolean fireEvent) throws UpdateFailedException
+ {
+ if(_sorted)
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ if(!insertSortedChild(child, _children, treeModel))
+ {
+ throw new UpdateFailedException(Communicator.this, child.getId());
+ }
+ }
+ else
+ {
+ //
+ // Just add the child at the end of the list
+ //
+ _children.add(child);
+ if(fireEvent)
+ {
+ getRoot().getTreeModel().nodesWereInserted(Communicator.this, new int[]{getIndex(child)});
+ }
+ }
+ }
+
+ int removeChild(TreeNode child)
+ {
+ int index = getIndex(child);
+
+ _children.remove(child);
+
+ getRoot().getTreeModel().nodesWereRemoved(Communicator.this,
+ new int[]{index},
+ new Object[]{child});
+ return index;
+ }
+
+ void destroyChild(TreeNode child)
+ {
+ if(child.isEphemeral())
+ {
+ removeChild(child);
+ }
+ else
+ {
+ Object descriptor = child.getDescriptor();
+ removeDescriptor(descriptor);
+ getEnclosingEditable().markModified();
+ getRoot().updated();
+ removeChild(child);
+ }
+ }
+
+ void addDescriptor(Object descriptor)
+ {
+ _descriptors.add(descriptor);
+ }
+
+ void removeDescriptor(Object descriptor)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ if(descriptor == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+ boolean canMove(TreeNode child, boolean up)
+ {
+ int i = _children.indexOf(child);
+ assert i != -1;
+ return (up && i > 0) || (!up && i < _children.size() - 1);
+ }
+
+ void tryAdd(Object descriptor) throws UpdateFailedException
+ {
+ addDescriptor(descriptor);
+ try
+ {
+ addNewChild(descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ removeDescriptor(descriptor);
+ throw e;
+ }
+ getEnclosingEditable().markModified();
+ }
+
+ void tryUpdate(TreeNode child) throws UpdateFailedException
+ {
+ //
+ // Child is an Adapter or DbEnv
+ //
+ assert _sorted;
+
+ Object descriptor = child.getDescriptor();
+ removeChild(child);
+ try
+ {
+ addNewChild(descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ addChild(child, true);
+ throw e;
+ }
+ getEnclosingEditable().markModified();
+ }
+
+ protected String makeNewChildId(String base)
+ {
+ String id = base;
+ int i = 0;
+ while(findChildById(id) != null)
+ {
+ id = base + "-" + (++i);
+ }
+ return id;
+ }
+
+ protected java.util.List _children = new java.util.LinkedList();
+ protected java.util.List _descriptors;
+ protected boolean _sorted;
+ }
+
+ class Adapters extends ChildList
+ {
+ Adapters()
+ {
+ super(true);
+ }
+
+ void newChild()
+ {
+ AdapterDescriptor descriptor = new AdapterDescriptor(
+ "NewAdapter",
+ "",
+ null,
+ "",
+ false,
+ true,
+ new java.util.LinkedList(),
+ new java.util.LinkedList()
+ );
+
+ newAdapter(descriptor);
+ }
+
+ TreeNode createChild(Object descriptor)
+ {
+ AdapterDescriptor ad = (AdapterDescriptor)descriptor;
+ String name = Utils.substitute(ad.name, getResolver());
+ return new Adapter(Communicator.this, name, ad, false);
+ }
+
+ private void newAdapter(AdapterDescriptor descriptor)
+ {
+ descriptor.name = makeNewChildId(descriptor.name);
+ Adapter adapter = new Adapter(Communicator.this, descriptor.name, descriptor, true);
+ try
+ {
+ addChild(adapter, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(adapter);
+ }
+
+ }
+
+ class DbEnvs extends ChildList
+ {
+ DbEnvs()
+ {
+ super(true);
+ }
+
+ void newChild()
+ {
+ DbEnvDescriptor descriptor = new DbEnvDescriptor(
+ "NewDbEnv",
+ "",
+ "",
+ new java.util.LinkedList());
+
+ newDbEnv(descriptor);
+ }
+
+ TreeNode createChild(Object descriptor)
+ {
+ DbEnvDescriptor dd = (DbEnvDescriptor)descriptor;
+ String name = Utils.substitute(dd.name, getResolver());
+ return new DbEnv(Communicator.this, name, dd, false);
+ }
+
+ private void newDbEnv(DbEnvDescriptor descriptor)
+ {
+ descriptor.name = makeNewChildId(descriptor.name);
+ DbEnv dbEnv = new DbEnv(Communicator.this, descriptor.name, descriptor, true);
+ try
+ {
+ addChild(dbEnv, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(dbEnv);
+ }
+
+ }
+
+ class Services extends ChildList
+ {
+ Services()
+ {
+ super(false);
+ }
+
+ void newChild()
+ {
+ ServiceDescriptor serviceDescriptor =
+ new ServiceDescriptor(new java.util.LinkedList(),
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
+ new java.util.LinkedList(),
+ "",
+ "NewService",
+ "");
+
+ ServiceInstanceDescriptor descriptor =
+ new ServiceInstanceDescriptor("",
+ new java.util.HashMap(),
+ serviceDescriptor,
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
+
+ newService(descriptor);
+ }
+
+ void newServiceFromTemplate()
+ {
+ ServiceInstanceDescriptor descriptor =
+ new ServiceInstanceDescriptor("",
+ new java.util.HashMap(),
+ null,
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
+ newService(descriptor);
+ }
+
+ void move(TreeNode child, boolean up)
+ {
+ int index = getIndex(child);
+ int listIndex = _children.indexOf(child);
+
+ Object descriptor = child.getDescriptor();
+
+ getEnclosingEditable().markModified();
+ getRoot().updated();
+
+ _descriptors.remove(listIndex);
+ if(up)
+ {
+ _descriptors.add(listIndex - 1, descriptor);
+ }
+ else
+ {
+ _descriptors.add(listIndex + 1, descriptor);
+ }
+
+ _children.remove(listIndex);
+ getRoot().getTreeModel().nodesWereRemoved(Communicator.this,
+ new int[]{index},
+ new Object[]{child});
+ if(up)
+ {
+ _children.add(listIndex - 1, child);
+ getRoot().getTreeModel().nodesWereInserted(Communicator.this,
+ new int[]{index - 1});
+
+ }
+ else
+ {
+ _children.add(listIndex + 1, child);
+ getRoot().getTreeModel().nodesWereInserted(Communicator.this,
+ new int[]{index + 1});
+
+ }
+ getRoot().setSelectedNode(child);
+ getCoordinator().showActions(child);
+ }
+
+ TreeNode createChild(Object o) throws UpdateFailedException
+ {
+ ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)o;
+
+ if(descriptor.descriptor == null)
+ {
+ TemplateDescriptor templateDescriptor
+ = getRoot().findServiceTemplateDescriptor(descriptor.template);
+
+ assert templateDescriptor != null;
+
+ String serviceName = null;
+ String displayString = null;
+ Utils.Resolver serviceResolver = null;
+
+ if(Communicator.this instanceof PlainServer)
+ {
+ serviceResolver = new Utils.Resolver(getResolver(),
+ descriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+
+ ServiceDescriptor serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
+ assert serviceDescriptor != null;
+
+ serviceName = serviceResolver.substitute(serviceDescriptor.name);
+ serviceResolver.put("service", serviceName);
+ displayString = serviceName + ": " + descriptor.template + "<>";
+ }
+ else
+ {
+ //
+ // Note: service names don't have to be unique
+ //
+ serviceName = descriptor.template + "<>";
+ }
+
+ return new ServiceInstance(Communicator.this,
+ serviceName,
+ displayString,
+ descriptor,
+ serviceResolver);
+ }
+ else
+ {
+ ServiceDescriptor serviceDescriptor = descriptor.descriptor;
+
+ String serviceName = null;
+ Utils.Resolver serviceResolver = null;
+
+ if(Communicator.this instanceof PlainServer)
+ {
+ serviceResolver = new Utils.Resolver(getResolver());
+ serviceName = serviceResolver.substitute(serviceDescriptor.name);
+ serviceResolver.put("service", serviceName);
+ }
+ else
+ {
+ serviceName = serviceDescriptor.name;
+ }
+
+ return new PlainService(Communicator.this,
+ serviceName,
+ descriptor,
+ serviceResolver);
+ }
+ }
+
+ void tryUpdate(TreeNode child) throws UpdateFailedException
+ {
+ //
+ // Rebuilding a Service is quite different since the creation of a service can
+ // trigger an UpdateFailedException
+ //
+ Object descriptor = child.getDescriptor();
+ int listIndex = _children.indexOf(child);
+ assert listIndex != -1;
+
+ TreeNode newChild = createChild(descriptor);
+ _children.set(listIndex, newChild);
+ getRoot().getTreeModel().nodeChanged(newChild);
+
+ getEnclosingEditable().markModified();
+ }
+
+ private void newService(ServiceInstanceDescriptor descriptor)
+ {
+ if(descriptor.descriptor == null)
+ {
+ String name = makeNewChildId("NewService");
+
+ //
+ // Make sure descriptor.template points to a real template
+ //
+ ServiceTemplate t = getRoot().findServiceTemplate(descriptor.template);
+
+ if(t == null)
+ {
+ t = (ServiceTemplate)getRoot().getServiceTemplates().getChildAt(0);
+
+ if(t == null)
+ {
+ JOptionPane.showMessageDialog(
+ getCoordinator().getMainFrame(),
+ "You need to create a service template before you can create a service from a template.",
+ "No Service Template",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ else
+ {
+ descriptor.template = t.getId();
+ descriptor.parameterValues = new java.util.HashMap();
+ }
+ }
+
+ //
+ // Validate/update parameterValues
+ //
+ TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
+ descriptor.parameterValues = Editor.makeParameterValues(descriptor.parameterValues,
+ td.parameters);
+
+
+ ServiceInstance service = new ServiceInstance(Communicator.this, name, descriptor);
+ try
+ {
+ addChild(service, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(service);
+ }
+ else
+ {
+ descriptor.descriptor.name = makeNewChildId(descriptor.descriptor.name);
+
+ PlainService service = new PlainService(Communicator.this, descriptor);
+ try
+ {
+ addChild(service, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(service);
+ }
+ }
+ }
+
+ Adapters getAdapters()
+ {
+ return _adapters;
+ }
+
+ DbEnvs getDbEnvs()
+ {
+ return _dbEnvs;
+ }
+
+ Services getServices()
+ {
+ return _services;
+ }
+
+ java.util.List findServiceInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _services.iterator();
+ while(p.hasNext())
+ {
+ Object obj = p.next();
+ if(obj instanceof ServiceInstance)
+ {
+ ServiceInstance service = (ServiceInstance)obj;
+ ServiceInstanceDescriptor d =
+ (ServiceInstanceDescriptor)service.getDescriptor();
+ if(d.template.equals(template))
+ {
+ result.add(service);
+ }
+ }
+ }
+ return result;
+ }
+
+ void removeServiceInstances(String template)
+ {
+ java.util.Iterator p = _services.iterator();
+ while(p.hasNext())
+ {
+ Object obj = p.next();
+ if(obj instanceof ServiceInstance)
+ {
+ ServiceInstance service = (ServiceInstance)obj;
+ ServiceInstanceDescriptor d =
+ (ServiceInstanceDescriptor)service.getDescriptor();
+ if(d.template.equals(template))
+ {
+ _services.removeChild(service);
+ _services.removeDescriptor(d);
+ getEnclosingEditable().markModified();
+ }
+ }
+ }
+ }
+
+ void removeSortedChildren(String[] childIds, java.util.List fromChildren)
+ {
+ removeSortedChildren(childIds, fromChildren, getRoot().getTreeModel());
+ }
+ void childrenChanged(java.util.List children)
+ {
+ childrenChanged(children, getRoot().getTreeModel());
+ }
+
+ String getProperty(String key)
+ {
+ CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
+ java.util.Iterator p = descriptor.propertySet.properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ if(pd.name.equals(key))
+ {
+ return pd.value;
+ }
+ }
+ return null;
+ }
+
+ void setProperty(String key, String newValue)
+ {
+ CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
+ removeProperty(key);
+ ((java.util.LinkedList)descriptor.propertySet.properties).addFirst(new PropertyDescriptor(key, newValue));
+ }
+
+ void removeProperty(String key)
+ {
+ CommunicatorDescriptor descriptor = getCommunicatorDescriptor();
+ java.util.Iterator p = descriptor.propertySet.properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ if(pd.name.equals(key))
+ {
+ p.remove();
+ }
+ }
+ }
+
+ //
+ // Children
+ //
+ protected Adapters _adapters = new Adapters();
+ protected DbEnvs _dbEnvs = new DbEnvs();
+ protected Services _services = new Services();
+ protected ChildList[] _childListArray = new ChildList[]{_adapters, _dbEnvs, _services};
+}
diff --git a/java/src/IceGridGUI/Application/CommunicatorChildEditor.java b/java/src/IceGridGUI/Application/CommunicatorChildEditor.java
index b80d4e9f625..d9ccbe65788 100755
--- a/java/src/IceGridGUI/Application/CommunicatorChildEditor.java
+++ b/java/src/IceGridGUI/Application/CommunicatorChildEditor.java
@@ -1,122 +1,122 @@
-// **********************************************************************
-//
-// 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.JOptionPane;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-abstract class CommunicatorChildEditor extends Editor
-{
- abstract void writeDescriptor();
- abstract boolean isSimpleUpdate();
- abstract Communicator.ChildList getChildList();
-
- void postUpdate() {}
-
- protected boolean applyUpdate()
- {
- Root root = _target.getRoot();
- root.disableSelectionListener();
- try
- {
- if(_target.isEphemeral())
- {
- Communicator.ChildList childList = getChildList();
-
- writeDescriptor();
- Object descriptor = _target.getDescriptor();
- _target.destroy(); // just removes the child
-
- try
- {
- childList.tryAdd(descriptor);
- }
- catch(UpdateFailedException e)
- {
- //
- // Restore ephemeral
- //
- try
- {
- childList.addChild(_target, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
-
- root.setSelectedNode(_target);
- return false;
- }
-
- //
- // Success
- //
- _target = childList.findChildWithDescriptor(descriptor);
- root.updated();
- root.setSelectedNode(_target);
- }
- else if(isSimpleUpdate())
- {
- writeDescriptor();
- root.updated();
- ((Communicator)_target.getParent()).getEnclosingEditable().markModified();
- }
- else
- {
- //
- // Save to be able to rollback
- //
- Object savedDescriptor = ((DescriptorHolder)_target).saveDescriptor();
- Communicator.ChildList childList = getChildList();
- writeDescriptor();
- try
- {
- childList.tryUpdate(_target);
- }
- catch(UpdateFailedException e)
- {
- ((DescriptorHolder)_target).restoreDescriptor(savedDescriptor);
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = childList.findChildWithDescriptor(_target.getDescriptor());
- root.updated();
- root.setSelectedNode(_target);
- }
-
- postUpdate();
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-}
+// **********************************************************************
+//
+// 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.JOptionPane;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+abstract class CommunicatorChildEditor extends Editor
+{
+ abstract void writeDescriptor();
+ abstract boolean isSimpleUpdate();
+ abstract Communicator.ChildList getChildList();
+
+ void postUpdate() {}
+
+ protected boolean applyUpdate()
+ {
+ Root root = _target.getRoot();
+ root.disableSelectionListener();
+ try
+ {
+ if(_target.isEphemeral())
+ {
+ Communicator.ChildList childList = getChildList();
+
+ writeDescriptor();
+ Object descriptor = _target.getDescriptor();
+ _target.destroy(); // just removes the child
+
+ try
+ {
+ childList.tryAdd(descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Restore ephemeral
+ //
+ try
+ {
+ childList.addChild(_target, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+
+ root.setSelectedNode(_target);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = childList.findChildWithDescriptor(descriptor);
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+ else if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ root.updated();
+ ((Communicator)_target.getParent()).getEnclosingEditable().markModified();
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ Object savedDescriptor = ((DescriptorHolder)_target).saveDescriptor();
+ Communicator.ChildList childList = getChildList();
+ writeDescriptor();
+ try
+ {
+ childList.tryUpdate(_target);
+ }
+ catch(UpdateFailedException e)
+ {
+ ((DescriptorHolder)_target).restoreDescriptor(savedDescriptor);
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = childList.findChildWithDescriptor(_target.getDescriptor());
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+
+ postUpdate();
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+}
diff --git a/java/src/IceGridGUI/Application/CommunicatorSubEditor.java b/java/src/IceGridGUI/Application/CommunicatorSubEditor.java
index a3e7f2e4d9d..22e68e62bfb 100755
--- a/java/src/IceGridGUI/Application/CommunicatorSubEditor.java
+++ b/java/src/IceGridGUI/Application/CommunicatorSubEditor.java
@@ -1,109 +1,109 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class CommunicatorSubEditor
-{
- CommunicatorSubEditor(Editor mainEditor)
- {
- _mainEditor = mainEditor;
-
- _description.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _description.setToolTipText("An optional description");
-
- _propertySets.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _properties = new PropertiesField(mainEditor);
- _description.setToolTipText("Property Set References");
- }
-
-
- void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Property Sets");
- builder.append(_propertySets, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- void writeDescriptor(CommunicatorDescriptor descriptor)
- {
- descriptor.propertySet.references =
- (String[])_propertySets.getList().toArray(new String[0]);
- descriptor.propertySet.properties = _properties.getProperties();
- descriptor.description = _description.getText();
- }
-
- void show(CommunicatorDescriptor descriptor, boolean isEditable)
- {
- Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
- isEditable = isEditable && (detailResolver == null);
-
- _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
- detailResolver);
- _propertySets.setEditable(isEditable);
-
- _properties.setProperties(descriptor.propertySet.properties,
- descriptor.adapters,
- detailResolver, isEditable);
-
- _description.setText(
- Utils.substitute(descriptor.description, detailResolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
- }
-
- protected Editor _mainEditor;
-
- private JTextArea _description = new JTextArea(3, 20);
- private ListTextField _propertySets = new ListTextField(20);
- private PropertiesField _properties;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class CommunicatorSubEditor
+{
+ CommunicatorSubEditor(Editor mainEditor)
+ {
+ _mainEditor = mainEditor;
+
+ _description.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _description.setToolTipText("An optional description");
+
+ _propertySets.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _properties = new PropertiesField(mainEditor);
+ _description.setToolTipText("Property Set References");
+ }
+
+
+ void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Property Sets");
+ builder.append(_propertySets, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ void writeDescriptor(CommunicatorDescriptor descriptor)
+ {
+ descriptor.propertySet.references =
+ (String[])_propertySets.getList().toArray(new String[0]);
+ descriptor.propertySet.properties = _properties.getProperties();
+ descriptor.description = _description.getText();
+ }
+
+ void show(CommunicatorDescriptor descriptor, boolean isEditable)
+ {
+ Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
+ isEditable = isEditable && (detailResolver == null);
+
+ _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
+ detailResolver);
+ _propertySets.setEditable(isEditable);
+
+ _properties.setProperties(descriptor.propertySet.properties,
+ descriptor.adapters,
+ detailResolver, isEditable);
+
+ _description.setText(
+ Utils.substitute(descriptor.description, detailResolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+ }
+
+ protected Editor _mainEditor;
+
+ private JTextArea _description = new JTextArea(3, 20);
+ private ListTextField _propertySets = new ListTextField(20);
+ private PropertiesField _properties;
+}
diff --git a/java/src/IceGridGUI/Application/DbEnv.java b/java/src/IceGridGUI/Application/DbEnv.java
index 321d2417a1a..446cf5c4cac 100755
--- a/java/src/IceGridGUI/Application/DbEnv.java
+++ b/java/src/IceGridGUI/Application/DbEnv.java
@@ -1,194 +1,194 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class DbEnv extends TreeNode implements DescriptorHolder
-{
- static public DbEnvDescriptor copyDescriptor(DbEnvDescriptor d)
- {
- return (DbEnvDescriptor)d.clone();
- }
-
- static public java.util.List copyDescriptors(java.util.List list)
- {
- java.util.List copy = new java.util.LinkedList();
- java.util.Iterator p = list.iterator();
- while(p.hasNext())
- {
- copy.add(copyDescriptor((DbEnvDescriptor)p.next()));
- }
- return copy;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/database.png"));
- }
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
- boolean[] parentActions = ((TreeNode)_parent).getAvailableActions();
-
- actions[PASTE] = parentActions[PASTE];
- actions[DELETE] = true;
-
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = parentActions[SHOW_VARS];
- actions[SUBSTITUTE_VARS] = parentActions[SUBSTITUTE_VARS];
- }
- return actions;
- }
-
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (DbEnvEditor)getRoot().getEditor(DbEnvEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new DbEnvEditor();
- }
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object copyDescriptor()
- {
- return copyDescriptor(_descriptor);
- }
-
- public Object saveDescriptor()
- {
- return copyDescriptor(_descriptor);
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- DbEnvDescriptor clone = (DbEnvDescriptor)savedDescriptor;
- _descriptor.name = clone.name;
- _descriptor.dbHome = clone.dbHome;
- _descriptor.description = clone.description;
- _descriptor.properties = clone.properties;
- }
-
- public void destroy()
- {
- ((Communicator)_parent).getDbEnvs().destroyChild(this);
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- DbEnv(Communicator parent, String dbEnvName, DbEnvDescriptor descriptor,
- boolean ephemeral)
- {
- super(parent, dbEnvName);
- _descriptor = descriptor;
- _ephemeral = ephemeral;
- }
-
- static void writeDbProperties(XMLWriter writer,
- java.util.List properties)
- throws java.io.IOException
- {
- java.util.Iterator p = properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", pd.name));
- attributes.add(createAttribute("value", pd.value));
- writer.writeElement("dbproperty", attributes);
- }
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", _descriptor.name));
- if(_descriptor.dbHome.length() > 0)
- {
- attributes.add(createAttribute("home", _descriptor.dbHome));
- }
-
- if(_descriptor.description.length() == 0 &&
- _descriptor.properties.isEmpty())
- {
- writer.writeElement("dbenv", attributes);
- }
- else
- {
- writer.writeStartTag("dbenv", attributes);
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- writeDbProperties(writer, _descriptor.properties);
- writer.writeEndTag("dbenv");
- }
- }
- }
-
- private DbEnvDescriptor _descriptor;
- private final boolean _ephemeral;
- private DbEnvEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class DbEnv extends TreeNode implements DescriptorHolder
+{
+ static public DbEnvDescriptor copyDescriptor(DbEnvDescriptor d)
+ {
+ return (DbEnvDescriptor)d.clone();
+ }
+
+ static public java.util.List copyDescriptors(java.util.List list)
+ {
+ java.util.List copy = new java.util.LinkedList();
+ java.util.Iterator p = list.iterator();
+ while(p.hasNext())
+ {
+ copy.add(copyDescriptor((DbEnvDescriptor)p.next()));
+ }
+ return copy;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/database.png"));
+ }
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+ boolean[] parentActions = ((TreeNode)_parent).getAvailableActions();
+
+ actions[PASTE] = parentActions[PASTE];
+ actions[DELETE] = true;
+
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = parentActions[SHOW_VARS];
+ actions[SUBSTITUTE_VARS] = parentActions[SUBSTITUTE_VARS];
+ }
+ return actions;
+ }
+
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (DbEnvEditor)getRoot().getEditor(DbEnvEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new DbEnvEditor();
+ }
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object copyDescriptor()
+ {
+ return copyDescriptor(_descriptor);
+ }
+
+ public Object saveDescriptor()
+ {
+ return copyDescriptor(_descriptor);
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ DbEnvDescriptor clone = (DbEnvDescriptor)savedDescriptor;
+ _descriptor.name = clone.name;
+ _descriptor.dbHome = clone.dbHome;
+ _descriptor.description = clone.description;
+ _descriptor.properties = clone.properties;
+ }
+
+ public void destroy()
+ {
+ ((Communicator)_parent).getDbEnvs().destroyChild(this);
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ DbEnv(Communicator parent, String dbEnvName, DbEnvDescriptor descriptor,
+ boolean ephemeral)
+ {
+ super(parent, dbEnvName);
+ _descriptor = descriptor;
+ _ephemeral = ephemeral;
+ }
+
+ static void writeDbProperties(XMLWriter writer,
+ java.util.List properties)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", pd.name));
+ attributes.add(createAttribute("value", pd.value));
+ writer.writeElement("dbproperty", attributes);
+ }
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", _descriptor.name));
+ if(_descriptor.dbHome.length() > 0)
+ {
+ attributes.add(createAttribute("home", _descriptor.dbHome));
+ }
+
+ if(_descriptor.description.length() == 0 &&
+ _descriptor.properties.isEmpty())
+ {
+ writer.writeElement("dbenv", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("dbenv", attributes);
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ writeDbProperties(writer, _descriptor.properties);
+ writer.writeEndTag("dbenv");
+ }
+ }
+ }
+
+ private DbEnvDescriptor _descriptor;
+ private final boolean _ephemeral;
+ private DbEnvEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/Application/DbEnvEditor.java b/java/src/IceGridGUI/Application/DbEnvEditor.java
index 4261c4daa0a..e7f83f50c4a 100755
--- a/java/src/IceGridGUI/Application/DbEnvEditor.java
+++ b/java/src/IceGridGUI/Application/DbEnvEditor.java
@@ -1,200 +1,200 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class DbEnvEditor extends CommunicatorChildEditor
-{
- DbEnvEditor()
- {
- _name.getDocument().addDocumentListener(_updateListener);
- _name.setToolTipText(
- "Identifies this Freeze database environment within an Ice communicator");
- _description.getDocument().addDocumentListener(_updateListener);
- _description.setToolTipText(
- "An optional description for this database environment");
-
- JTextField dbHomeTextField = (JTextField)
- _dbHome.getEditor().getEditorComponent();
- dbHomeTextField.getDocument().addDocumentListener(_updateListener);
- _dbHome.setToolTipText("<html><i>node data dir</i>/servers/<i>server id</i>"
- + "/dbs/<i>db env name</i> if created by the IceGrid Node;<br>"
- + "otherwise, IceGrid does not create this directory"
- + "</html>");
-
- _properties = new PropertiesField(this);
- }
-
- void writeDescriptor()
- {
- DbEnvDescriptor descriptor =
- (DbEnvDescriptor)getDbEnv().getDescriptor();
- descriptor.name = _name.getText().trim();
- descriptor.description = _description.getText();
- descriptor.dbHome = getDbHomeAsString();
- descriptor.properties = _properties.getProperties();
- }
-
- boolean isSimpleUpdate()
- {
- DbEnvDescriptor descriptor =
- (DbEnvDescriptor)getDbEnv().getDescriptor();
- return descriptor.name.equals(_name.getText().trim());
- }
-
- Communicator.ChildList getChildList()
- {
- return ((Communicator)_target.getParent()).getDbEnvs();
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- 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(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("DB Home" );
- builder.append(_dbHome, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Database Environment Properties");
- }
-
- protected boolean validate()
- {
- return check(new String[]{"Name", _name.getText().trim()});
- }
-
- void show(DbEnv dbEnv)
- {
- detectUpdates(false);
- _target = dbEnv;
-
- DbEnvDescriptor descriptor = (DbEnvDescriptor)dbEnv.getDescriptor();
-
- Utils.Resolver resolver = null;
- if(dbEnv.getCoordinator().substitute())
- {
- resolver = dbEnv.getResolver();
- }
- boolean isEditable = resolver == null;
-
- _name.setText(
- Utils.substitute(descriptor.name, resolver));
- _name.setEditable(isEditable);
-
- _description.setText(
- Utils.substitute(descriptor.description, resolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
-
- _dbHome.setEnabled(true);
- _dbHome.setEditable(true);
- setDbHome(Utils.substitute(descriptor.dbHome, resolver));
- _dbHome.setEnabled(isEditable);
- _dbHome.setEditable(isEditable);
-
- _properties.setProperties(descriptor.properties, null,
- resolver, isEditable);
-
- _applyButton.setEnabled(dbEnv.isEphemeral());
- _discardButton.setEnabled(dbEnv.isEphemeral());
- detectUpdates(true);
- }
-
- private DbEnv getDbEnv()
- {
- return (DbEnv)_target;
- }
-
- private void setDbHome(String dbHome)
- {
- if(dbHome.equals(""))
- {
- _dbHome.setSelectedItem(NO_DB_HOME);
- }
- else
- {
- _dbHome.setSelectedItem(dbHome);
- }
- }
-
- private String getDbHomeAsString()
- {
- Object obj = _dbHome.getSelectedItem();
- if(obj == NO_DB_HOME)
- {
- return "";
- }
- else
- {
- return obj.toString().trim();
- }
- }
-
- private JTextField _name = new JTextField(20);
- private JTextArea _description = new JTextArea(3, 20);
-
- private JComboBox _dbHome = new JComboBox(new Object[]{NO_DB_HOME});
- private PropertiesField _properties;
-
- static private final Object NO_DB_HOME = new Object()
- {
- public String toString()
- {
- return "Created by the IceGrid Node";
- }
- };
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class DbEnvEditor extends CommunicatorChildEditor
+{
+ DbEnvEditor()
+ {
+ _name.getDocument().addDocumentListener(_updateListener);
+ _name.setToolTipText(
+ "Identifies this Freeze database environment within an Ice communicator");
+ _description.getDocument().addDocumentListener(_updateListener);
+ _description.setToolTipText(
+ "An optional description for this database environment");
+
+ JTextField dbHomeTextField = (JTextField)
+ _dbHome.getEditor().getEditorComponent();
+ dbHomeTextField.getDocument().addDocumentListener(_updateListener);
+ _dbHome.setToolTipText("<html><i>node data dir</i>/servers/<i>server id</i>"
+ + "/dbs/<i>db env name</i> if created by the IceGrid Node;<br>"
+ + "otherwise, IceGrid does not create this directory"
+ + "</html>");
+
+ _properties = new PropertiesField(this);
+ }
+
+ void writeDescriptor()
+ {
+ DbEnvDescriptor descriptor =
+ (DbEnvDescriptor)getDbEnv().getDescriptor();
+ descriptor.name = _name.getText().trim();
+ descriptor.description = _description.getText();
+ descriptor.dbHome = getDbHomeAsString();
+ descriptor.properties = _properties.getProperties();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ DbEnvDescriptor descriptor =
+ (DbEnvDescriptor)getDbEnv().getDescriptor();
+ return descriptor.name.equals(_name.getText().trim());
+ }
+
+ Communicator.ChildList getChildList()
+ {
+ return ((Communicator)_target.getParent()).getDbEnvs();
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ 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(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("DB Home" );
+ builder.append(_dbHome, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Database Environment Properties");
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"Name", _name.getText().trim()});
+ }
+
+ void show(DbEnv dbEnv)
+ {
+ detectUpdates(false);
+ _target = dbEnv;
+
+ DbEnvDescriptor descriptor = (DbEnvDescriptor)dbEnv.getDescriptor();
+
+ Utils.Resolver resolver = null;
+ if(dbEnv.getCoordinator().substitute())
+ {
+ resolver = dbEnv.getResolver();
+ }
+ boolean isEditable = resolver == null;
+
+ _name.setText(
+ Utils.substitute(descriptor.name, resolver));
+ _name.setEditable(isEditable);
+
+ _description.setText(
+ Utils.substitute(descriptor.description, resolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+
+ _dbHome.setEnabled(true);
+ _dbHome.setEditable(true);
+ setDbHome(Utils.substitute(descriptor.dbHome, resolver));
+ _dbHome.setEnabled(isEditable);
+ _dbHome.setEditable(isEditable);
+
+ _properties.setProperties(descriptor.properties, null,
+ resolver, isEditable);
+
+ _applyButton.setEnabled(dbEnv.isEphemeral());
+ _discardButton.setEnabled(dbEnv.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private DbEnv getDbEnv()
+ {
+ return (DbEnv)_target;
+ }
+
+ private void setDbHome(String dbHome)
+ {
+ if(dbHome.equals(""))
+ {
+ _dbHome.setSelectedItem(NO_DB_HOME);
+ }
+ else
+ {
+ _dbHome.setSelectedItem(dbHome);
+ }
+ }
+
+ private String getDbHomeAsString()
+ {
+ Object obj = _dbHome.getSelectedItem();
+ if(obj == NO_DB_HOME)
+ {
+ return "";
+ }
+ else
+ {
+ return obj.toString().trim();
+ }
+ }
+
+ private JTextField _name = new JTextField(20);
+ private JTextArea _description = new JTextArea(3, 20);
+
+ private JComboBox _dbHome = new JComboBox(new Object[]{NO_DB_HOME});
+ private PropertiesField _properties;
+
+ static private final Object NO_DB_HOME = new Object()
+ {
+ public String toString()
+ {
+ return "Created by the IceGrid Node";
+ }
+ };
+}
diff --git a/java/src/IceGridGUI/Application/DescriptorHolder.java b/java/src/IceGridGUI/Application/DescriptorHolder.java
index 5be2b6c2299..caf43652ff5 100755
--- a/java/src/IceGridGUI/Application/DescriptorHolder.java
+++ b/java/src/IceGridGUI/Application/DescriptorHolder.java
@@ -1,15 +1,15 @@
-// **********************************************************************
-//
-// 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;
-
-interface DescriptorHolder
-{
- Object saveDescriptor();
- void restoreDescriptor(Object descriptor);
-}
+// **********************************************************************
+//
+// 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;
+
+interface DescriptorHolder
+{
+ Object saveDescriptor();
+ void restoreDescriptor(Object descriptor);
+}
diff --git a/java/src/IceGridGUI/Application/Editable.java b/java/src/IceGridGUI/Application/Editable.java
index 32ab21070fb..dbca1555d31 100755
--- a/java/src/IceGridGUI/Application/Editable.java
+++ b/java/src/IceGridGUI/Application/Editable.java
@@ -1,106 +1,106 @@
-// **********************************************************************
-//
-// 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;
-
-class Editable implements Cloneable
-{
- Editable(boolean brandNew)
- {
- _isNew = brandNew;
- }
-
- boolean isNew()
- {
- return _isNew;
- }
-
- boolean isModified()
- {
- return _modified;
- }
-
- void markModified()
- {
- _modified = true;
- }
-
- void commit()
- {
- _isNew = false;
- _modified = false;
- _removedElements.clear();
- }
-
- void markNew()
- {
- _isNew = true;
- }
-
- void removeElement(String id, Editable editable, Class forClass)
- {
- if(!editable.isNew())
- {
- java.util.TreeSet set = (java.util.TreeSet)_removedElements.get(forClass);
- if(set == null)
- {
- set = new java.util.TreeSet();
- _removedElements.put(forClass, set);
- }
- set.add(id);
- }
- }
-
- String[] removedElements(Class forClass)
- {
- java.util.TreeSet set = (java.util.TreeSet)_removedElements.get(forClass);
- if(set == null)
- {
- return new String[0];
- }
- else
- {
- return (String[])set.toArray(new String[0]);
- }
- }
-
- Editable save()
- {
- try
- {
- Editable result = (Editable)clone();
- java.util.HashMap removedElements = new java.util.HashMap();
- java.util.Iterator p = result._removedElements.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- Object val = ((java.util.TreeSet)entry.getValue()).clone();
- removedElements.put(entry.getKey(), val);
- }
- result._removedElements = removedElements;
- return result;
- }
- catch(CloneNotSupportedException e)
- {
- assert false;
- return null;
- }
- }
-
- void restore(Editable clone)
- {
- _isNew = clone._isNew;
- _modified = clone._modified;
- _removedElements = clone._removedElements;
- }
-
- private boolean _isNew = false;
- private boolean _modified = false;
-
- private java.util.HashMap _removedElements = new java.util.HashMap();
-}
+// **********************************************************************
+//
+// 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;
+
+class Editable implements Cloneable
+{
+ Editable(boolean brandNew)
+ {
+ _isNew = brandNew;
+ }
+
+ boolean isNew()
+ {
+ return _isNew;
+ }
+
+ boolean isModified()
+ {
+ return _modified;
+ }
+
+ void markModified()
+ {
+ _modified = true;
+ }
+
+ void commit()
+ {
+ _isNew = false;
+ _modified = false;
+ _removedElements.clear();
+ }
+
+ void markNew()
+ {
+ _isNew = true;
+ }
+
+ void removeElement(String id, Editable editable, Class forClass)
+ {
+ if(!editable.isNew())
+ {
+ java.util.TreeSet set = (java.util.TreeSet)_removedElements.get(forClass);
+ if(set == null)
+ {
+ set = new java.util.TreeSet();
+ _removedElements.put(forClass, set);
+ }
+ set.add(id);
+ }
+ }
+
+ String[] removedElements(Class forClass)
+ {
+ java.util.TreeSet set = (java.util.TreeSet)_removedElements.get(forClass);
+ if(set == null)
+ {
+ return new String[0];
+ }
+ else
+ {
+ return (String[])set.toArray(new String[0]);
+ }
+ }
+
+ Editable save()
+ {
+ try
+ {
+ Editable result = (Editable)clone();
+ java.util.HashMap removedElements = new java.util.HashMap();
+ java.util.Iterator p = result._removedElements.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ Object val = ((java.util.TreeSet)entry.getValue()).clone();
+ removedElements.put(entry.getKey(), val);
+ }
+ result._removedElements = removedElements;
+ return result;
+ }
+ catch(CloneNotSupportedException e)
+ {
+ assert false;
+ return null;
+ }
+ }
+
+ void restore(Editable clone)
+ {
+ _isNew = clone._isNew;
+ _modified = clone._modified;
+ _removedElements = clone._removedElements;
+ }
+
+ private boolean _isNew = false;
+ private boolean _modified = false;
+
+ private java.util.HashMap _removedElements = new java.util.HashMap();
+}
diff --git a/java/src/IceGridGUI/Application/Editor.java b/java/src/IceGridGUI/Application/Editor.java
index abd137b2669..62298aa0f04 100755
--- a/java/src/IceGridGUI/Application/Editor.java
+++ b/java/src/IceGridGUI/Application/Editor.java
@@ -1,240 +1,240 @@
-// **********************************************************************
-//
-// 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 java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JToolBar;
-
-import javax.swing.tree.TreePath;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.factories.Borders;
-import com.jgoodies.forms.factories.ButtonBarFactory;
-import com.jgoodies.forms.factories.DefaultComponentFactory;
-import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.util.LayoutStyle;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-public class Editor extends EditorBase
-{
- static public java.util.Map makeParameterValues(
- java.util.Map oldParameterValues,
- java.util.List newParameters)
- {
- java.util.Map result = new java.util.HashMap();
-
- java.util.Iterator p = newParameters.iterator();
- while(p.hasNext())
- {
- Object name = p.next();
- Object value = oldParameterValues.get(name);
- if(value != null)
- {
- result.put(name, value);
- }
- }
- return result;
- }
-
- public boolean save()
- {
- if(_applyButton.isEnabled())
- {
- return validate() && applyUpdate();
- }
- else
- {
- return true;
- }
- }
-
- protected boolean validate()
- {
- return true;
- }
-
- protected boolean applyUpdate()
- {
- assert false;
- return false;
- }
-
- protected void detectUpdates(boolean val)
- {
- _detectUpdates = val;
- }
-
- protected void discardUpdate()
- {
- if(_target.isEphemeral())
- {
- _target.delete();
- }
- else
- {
- _target.getCoordinator().getCurrentTab().showNode(_target);
- }
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {}
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- JComponent buttonBar =
- ButtonBarFactory.buildRightAlignedBar(_applyButton,
- _discardButton);
- buttonBar.setBorder(Borders.DIALOG_BORDER);
- _propertiesPanel.add(buttonBar, BorderLayout.SOUTH);
- }
-
-
- Editor()
- {
- //
- // _applyButton
- //
- AbstractAction apply = new AbstractAction("Apply")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(validate())
- {
- applyUpdate();
- }
- }
- };
- _applyButton = new JButton(apply);
- _applyButton.setEnabled(false);
-
- //
- // _discardButton
- //
- AbstractAction discard = new AbstractAction("Discard")
- {
- public void actionPerformed(ActionEvent e)
- {
- discardUpdate();
- }
- };
- _discardButton = new JButton(discard);
- _discardButton.setEnabled(false);
-
- _updateListener = new DocumentListener()
- {
- public void changedUpdate(DocumentEvent e)
- {
- updated();
- }
-
- public void insertUpdate(DocumentEvent e)
- {
- updated();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- updated();
- }
- };
- }
-
- //
- // Used by the sub-editor (when there is one)
- //
- Object getSubDescriptor()
- {
- return null;
- }
-
- Utils.Resolver getDetailResolver()
- {
- return null;
- }
-
- TreeNode getTarget()
- {
- return _target;
- }
-
- void updated()
- {
- if(_detectUpdates)
- {
- _target.getRoot().disableRegistryUpdates();
- _applyButton.setEnabled(true);
- _discardButton.setEnabled(true);
- }
- }
-
- DocumentListener getUpdateListener()
- {
- return _updateListener;
- }
-
- //
- // Check that these 'val' are filled in
- //
- boolean check(String[] nameValArray)
- {
- String emptyFields = "";
- int errorCount = 0;
-
- for(int i = 1; i < nameValArray.length; i += 2)
- {
- if(nameValArray[i] == null || nameValArray[i].length() == 0)
- {
- errorCount++;
- if(emptyFields.length() > 0)
- {
- emptyFields += "\n";
- }
- emptyFields += "'" + nameValArray[i - 1] + "'";
- }
- }
-
- if(errorCount > 0)
- {
- String message = errorCount == 1 ?
- emptyFields + " cannot be empty" :
- "The following fields cannot be empty:\n" + emptyFields;
-
- JOptionPane.showMessageDialog(
- _target.getCoordinator().getMainFrame(),
- message,
- "Validation failed",
- JOptionPane.ERROR_MESSAGE);
- }
-
- return errorCount == 0;
- }
-
- protected JButton _applyButton;
- protected JButton _discardButton;
- protected DocumentListener _updateListener;
-
- protected TreeNode _target;
- private boolean _detectUpdates = true;
-}
+// **********************************************************************
+//
+// 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 java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JToolBar;
+
+import javax.swing.tree.TreePath;
+
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.factories.ButtonBarFactory;
+import com.jgoodies.forms.factories.DefaultComponentFactory;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.util.LayoutStyle;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+public class Editor extends EditorBase
+{
+ static public java.util.Map makeParameterValues(
+ java.util.Map oldParameterValues,
+ java.util.List newParameters)
+ {
+ java.util.Map result = new java.util.HashMap();
+
+ java.util.Iterator p = newParameters.iterator();
+ while(p.hasNext())
+ {
+ Object name = p.next();
+ Object value = oldParameterValues.get(name);
+ if(value != null)
+ {
+ result.put(name, value);
+ }
+ }
+ return result;
+ }
+
+ public boolean save()
+ {
+ if(_applyButton.isEnabled())
+ {
+ return validate() && applyUpdate();
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ protected boolean validate()
+ {
+ return true;
+ }
+
+ protected boolean applyUpdate()
+ {
+ assert false;
+ return false;
+ }
+
+ protected void detectUpdates(boolean val)
+ {
+ _detectUpdates = val;
+ }
+
+ protected void discardUpdate()
+ {
+ if(_target.isEphemeral())
+ {
+ _target.delete();
+ }
+ else
+ {
+ _target.getCoordinator().getCurrentTab().showNode(_target);
+ }
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {}
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ JComponent buttonBar =
+ ButtonBarFactory.buildRightAlignedBar(_applyButton,
+ _discardButton);
+ buttonBar.setBorder(Borders.DIALOG_BORDER);
+ _propertiesPanel.add(buttonBar, BorderLayout.SOUTH);
+ }
+
+
+ Editor()
+ {
+ //
+ // _applyButton
+ //
+ AbstractAction apply = new AbstractAction("Apply")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if(validate())
+ {
+ applyUpdate();
+ }
+ }
+ };
+ _applyButton = new JButton(apply);
+ _applyButton.setEnabled(false);
+
+ //
+ // _discardButton
+ //
+ AbstractAction discard = new AbstractAction("Discard")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ discardUpdate();
+ }
+ };
+ _discardButton = new JButton(discard);
+ _discardButton.setEnabled(false);
+
+ _updateListener = new DocumentListener()
+ {
+ public void changedUpdate(DocumentEvent e)
+ {
+ updated();
+ }
+
+ public void insertUpdate(DocumentEvent e)
+ {
+ updated();
+ }
+
+ public void removeUpdate(DocumentEvent e)
+ {
+ updated();
+ }
+ };
+ }
+
+ //
+ // Used by the sub-editor (when there is one)
+ //
+ Object getSubDescriptor()
+ {
+ return null;
+ }
+
+ Utils.Resolver getDetailResolver()
+ {
+ return null;
+ }
+
+ TreeNode getTarget()
+ {
+ return _target;
+ }
+
+ void updated()
+ {
+ if(_detectUpdates)
+ {
+ _target.getRoot().disableRegistryUpdates();
+ _applyButton.setEnabled(true);
+ _discardButton.setEnabled(true);
+ }
+ }
+
+ DocumentListener getUpdateListener()
+ {
+ return _updateListener;
+ }
+
+ //
+ // Check that these 'val' are filled in
+ //
+ boolean check(String[] nameValArray)
+ {
+ String emptyFields = "";
+ int errorCount = 0;
+
+ for(int i = 1; i < nameValArray.length; i += 2)
+ {
+ if(nameValArray[i] == null || nameValArray[i].length() == 0)
+ {
+ errorCount++;
+ if(emptyFields.length() > 0)
+ {
+ emptyFields += "\n";
+ }
+ emptyFields += "'" + nameValArray[i - 1] + "'";
+ }
+ }
+
+ if(errorCount > 0)
+ {
+ String message = errorCount == 1 ?
+ emptyFields + " cannot be empty" :
+ "The following fields cannot be empty:\n" + emptyFields;
+
+ JOptionPane.showMessageDialog(
+ _target.getCoordinator().getMainFrame(),
+ message,
+ "Validation failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ return errorCount == 0;
+ }
+
+ protected JButton _applyButton;
+ protected JButton _discardButton;
+ protected DocumentListener _updateListener;
+
+ protected TreeNode _target;
+ private boolean _detectUpdates = true;
+}
diff --git a/java/src/IceGridGUI/Application/ListTextField.java b/java/src/IceGridGUI/Application/ListTextField.java
index dfac4d7a2cb..5c1b149ada2 100755
--- a/java/src/IceGridGUI/Application/ListTextField.java
+++ b/java/src/IceGridGUI/Application/ListTextField.java
@@ -1,79 +1,79 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-import javax.swing.JTextField;
-
-//
-// A special field used to show/edit a list of strings separated
-// by whitespace
-//
-
-public class ListTextField extends JTextField
-{
- public ListTextField(int columns)
- {
- super(columns);
- }
-
- public void setList(java.util.List list, final Utils.Resolver resolver)
- {
- Utils.Stringifier stringifier = new Utils.Stringifier()
- {
- public String toString(Object obj)
- {
- return Utils.substitute((String)obj, resolver);
- }
- };
-
- setText(Utils.stringify(list, stringifier, " ", null));
- }
-
- public java.util.LinkedList getList()
- {
- String text = getText().trim();
- java.util.LinkedList result = new java.util.LinkedList();
-
- while(text.length() > 0)
- {
- if(text.startsWith("\""))
- {
- int last = text.indexOf("\"", 1);
- if(last == -1)
- {
- result.add(text.substring(1));
- text = "";
- }
- else
- {
- result.add(text.substring(1, last));
- text = text.substring(last + 1).trim();
- }
- }
- else
- {
- String[] strings = text.split("\\s", 2);
- if(strings.length == 1)
- {
- result.add(strings[0]);
- text = "";
- }
- else
- {
- result.add(strings[0]);
- text = strings[1].trim();
- }
- }
- }
- return result;
- }
-}
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+import javax.swing.JTextField;
+
+//
+// A special field used to show/edit a list of strings separated
+// by whitespace
+//
+
+public class ListTextField extends JTextField
+{
+ public ListTextField(int columns)
+ {
+ super(columns);
+ }
+
+ public void setList(java.util.List list, final Utils.Resolver resolver)
+ {
+ Utils.Stringifier stringifier = new Utils.Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ return Utils.substitute((String)obj, resolver);
+ }
+ };
+
+ setText(Utils.stringify(list, stringifier, " ", null));
+ }
+
+ public java.util.LinkedList getList()
+ {
+ String text = getText().trim();
+ java.util.LinkedList result = new java.util.LinkedList();
+
+ while(text.length() > 0)
+ {
+ if(text.startsWith("\""))
+ {
+ int last = text.indexOf("\"", 1);
+ if(last == -1)
+ {
+ result.add(text.substring(1));
+ text = "";
+ }
+ else
+ {
+ result.add(text.substring(1, last));
+ text = text.substring(last + 1).trim();
+ }
+ }
+ else
+ {
+ String[] strings = text.split("\\s", 2);
+ if(strings.length == 1)
+ {
+ result.add(strings[0]);
+ text = "";
+ }
+ else
+ {
+ result.add(strings[0]);
+ text = strings[1].trim();
+ }
+ }
+ }
+ return result;
+ }
+}
diff --git a/java/src/IceGridGUI/Application/ListTreeNode.java b/java/src/IceGridGUI/Application/ListTreeNode.java
index 4b36c3a03a5..bc5a92c2497 100755
--- a/java/src/IceGridGUI/Application/ListTreeNode.java
+++ b/java/src/IceGridGUI/Application/ListTreeNode.java
@@ -1,239 +1,239 @@
-// **********************************************************************
-//
-// 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.tree.DefaultTreeModel;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// An editable TreeNode that holds a list of children
-//
-abstract class ListTreeNode extends TreeNode
-{
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- return _p.hasNext();
- }
-
- public Object nextElement()
- {
- return _p.next();
- }
-
- private java.util.Iterator _p = _children.iterator();
- };
- }
-
- public boolean getAllowsChildren()
- {
- return true;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- if(childIndex < 0)
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- else if(childIndex < _children.size())
- {
- return (javax.swing.tree.TreeNode)_children.get(childIndex);
- }
- else
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- }
-
- public int getChildCount()
- {
- return _children.size();
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- return _children.indexOf(node);
- }
-
- public boolean isLeaf()
- {
- return _children.isEmpty();
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new Editor();
- }
- return _editor;
- }
-
- protected Editor createEditor()
- {
- assert false;
- return null;
- }
-
- protected ListTreeNode(boolean brandNew, TreeNode parent, String id)
- {
- super(parent, id);
- _editable = new Editable(brandNew);
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- TreeNode node = (TreeNode)p.next();
- node.write(writer);
- }
- }
-
- void insertChild(TreeNode child, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- if(!insertSortedChild(child, _children, treeModel))
- {
- throw new UpdateFailedException(this, child.getId());
- }
- }
-
- void insertChildren(java.util.List newChildren, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- String badChildId = insertSortedChildren(newChildren, _children, treeModel);
-
- if(badChildId != null)
- {
- throw new UpdateFailedException(this, badChildId);
- }
- }
-
- int removeChild(TreeNode child)
- {
- int index = getIndex(child);
- _children.remove(child);
-
- getRoot().getTreeModel().nodesWereRemoved(this,
- new int[]{index},
- new Object[]{child});
- return index;
- }
-
- void removeChildren(String[] childIds)
- {
- removeSortedChildren(childIds, _children, getRoot().getTreeModel());
- }
-
- void childrenChanged(java.util.List children)
- {
- childrenChanged(children, getRoot().getTreeModel());
- }
-
- Editable getEditable()
- {
- return _editable;
- }
-
- javax.swing.ComboBoxModel createComboBoxModel()
- {
- return new ComboBoxModel();
- }
-
- javax.swing.ComboBoxModel createComboBoxModel(Object item)
- {
- return new ComboBoxModel(item);
- }
-
- //
- // Adapts ListTreeNode to a ComboBoxModel
- //
- class ComboBoxModel extends javax.swing.AbstractListModel
- implements javax.swing.ComboBoxModel
- {
- public Object getElementAt(int index)
- {
- if(_firstItem != null)
- {
- if(index == 0)
- {
- return _firstItem;
- }
- else
- {
- return getChildAt(index - 1);
- }
- }
- else
- {
- return getChildAt(index);
- }
- }
-
- public int getSize()
- {
- if(_firstItem != null)
- {
- return getChildCount() + 1;
- }
- else
- {
- return getChildCount();
- }
- }
-
- public Object getSelectedItem()
- {
- return _selectedItem;
- }
-
- public void setSelectedItem(Object obj)
- {
- if(obj != _selectedItem)
- {
- _selectedItem = obj;
- fireContentsChanged(this, -1, -1);
- }
- }
-
- ComboBoxModel(Object firstItem)
- {
- _firstItem = firstItem;
- }
-
- ComboBoxModel()
- {
- _firstItem = null;
- }
-
- private final Object _firstItem;
- private Object _selectedItem;
- }
-
- protected final java.util.LinkedList _children = new java.util.LinkedList();
- protected Editable _editable;
-
- static private Editor _editor;
-}
+// **********************************************************************
+//
+// 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.tree.DefaultTreeModel;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// An editable TreeNode that holds a list of children
+//
+abstract class ListTreeNode extends TreeNode
+{
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return _p.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return _p.next();
+ }
+
+ private java.util.Iterator _p = _children.iterator();
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ if(childIndex < 0)
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ else if(childIndex < _children.size())
+ {
+ return (javax.swing.tree.TreeNode)_children.get(childIndex);
+ }
+ else
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ }
+
+ public int getChildCount()
+ {
+ return _children.size();
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ return _children.indexOf(node);
+ }
+
+ public boolean isLeaf()
+ {
+ return _children.isEmpty();
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new Editor();
+ }
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ assert false;
+ return null;
+ }
+
+ protected ListTreeNode(boolean brandNew, TreeNode parent, String id)
+ {
+ super(parent, id);
+ _editable = new Editable(brandNew);
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ TreeNode node = (TreeNode)p.next();
+ node.write(writer);
+ }
+ }
+
+ void insertChild(TreeNode child, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ if(!insertSortedChild(child, _children, treeModel))
+ {
+ throw new UpdateFailedException(this, child.getId());
+ }
+ }
+
+ void insertChildren(java.util.List newChildren, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ String badChildId = insertSortedChildren(newChildren, _children, treeModel);
+
+ if(badChildId != null)
+ {
+ throw new UpdateFailedException(this, badChildId);
+ }
+ }
+
+ int removeChild(TreeNode child)
+ {
+ int index = getIndex(child);
+ _children.remove(child);
+
+ getRoot().getTreeModel().nodesWereRemoved(this,
+ new int[]{index},
+ new Object[]{child});
+ return index;
+ }
+
+ void removeChildren(String[] childIds)
+ {
+ removeSortedChildren(childIds, _children, getRoot().getTreeModel());
+ }
+
+ void childrenChanged(java.util.List children)
+ {
+ childrenChanged(children, getRoot().getTreeModel());
+ }
+
+ Editable getEditable()
+ {
+ return _editable;
+ }
+
+ javax.swing.ComboBoxModel createComboBoxModel()
+ {
+ return new ComboBoxModel();
+ }
+
+ javax.swing.ComboBoxModel createComboBoxModel(Object item)
+ {
+ return new ComboBoxModel(item);
+ }
+
+ //
+ // Adapts ListTreeNode to a ComboBoxModel
+ //
+ class ComboBoxModel extends javax.swing.AbstractListModel
+ implements javax.swing.ComboBoxModel
+ {
+ public Object getElementAt(int index)
+ {
+ if(_firstItem != null)
+ {
+ if(index == 0)
+ {
+ return _firstItem;
+ }
+ else
+ {
+ return getChildAt(index - 1);
+ }
+ }
+ else
+ {
+ return getChildAt(index);
+ }
+ }
+
+ public int getSize()
+ {
+ if(_firstItem != null)
+ {
+ return getChildCount() + 1;
+ }
+ else
+ {
+ return getChildCount();
+ }
+ }
+
+ public Object getSelectedItem()
+ {
+ return _selectedItem;
+ }
+
+ public void setSelectedItem(Object obj)
+ {
+ if(obj != _selectedItem)
+ {
+ _selectedItem = obj;
+ fireContentsChanged(this, -1, -1);
+ }
+ }
+
+ ComboBoxModel(Object firstItem)
+ {
+ _firstItem = firstItem;
+ }
+
+ ComboBoxModel()
+ {
+ _firstItem = null;
+ }
+
+ private final Object _firstItem;
+ private Object _selectedItem;
+ }
+
+ protected final java.util.LinkedList _children = new java.util.LinkedList();
+ protected Editable _editable;
+
+ static private Editor _editor;
+}
diff --git a/java/src/IceGridGUI/Application/MapField.java b/java/src/IceGridGUI/Application/MapField.java
index e8d40bf8945..e0df77800a4 100755
--- a/java/src/IceGridGUI/Application/MapField.java
+++ b/java/src/IceGridGUI/Application/MapField.java
@@ -1,194 +1,194 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-
-//
-// A special field used to show/edit a map
-//
-
-public class MapField extends JTable
-{
- public MapField(Editor editor, String headKey, String headValue, boolean substituteKey)
- {
- _substituteKey = substituteKey;
-
- _columnNames = new java.util.Vector(2);
- _columnNames.add(headKey);
- _columnNames.add(headValue);
-
- _editor = editor;
-
- Action deleteRow = new AbstractAction("Delete selected row(s)")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(_editable)
- {
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
-
- for(;;)
- {
- int selectedRow = getSelectedRow();
- if(selectedRow == -1)
- {
- break;
- }
- else
- {
- _model.removeRow(selectedRow);
- }
- }
- }
- }
- };
- getActionMap().put("delete", deleteRow);
- getInputMap().put(
- KeyStroke.getKeyStroke("DELETE"), "delete");
-
- }
-
- public void set(java.util.Map map, Utils.Resolver resolver,
- boolean editable)
- {
- _editable = editable;
-
- //
- // Transform map into vector of vectors
- //
- java.util.Vector vector = new java.util.Vector(map.size());
- java.util.Iterator p = map.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Vector row = new java.util.Vector(2);
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- if(_substituteKey)
- {
- row.add(Utils.substitute((String)entry.getKey(), resolver));
- }
- else
- {
- row.add((String)entry.getKey());
- }
- row.add(Utils.substitute((String)entry.getValue(), resolver));
- vector.add(row);
- }
-
- if(_editable)
- {
- java.util.Vector newRow = new java.util.Vector(2);
- newRow.add("");
- newRow.add("");
- vector.add(newRow);
- }
-
- _model = new DefaultTableModel(vector, _columnNames)
- {
- public boolean isCellEditable(int row, int column)
- {
- return _editable;
- }
- };
-
- _model.addTableModelListener(new TableModelListener()
- {
- public void tableChanged(TableModelEvent e)
- {
- if(_editable)
- {
- Object lastKey = _model.getValueAt(
- _model.getRowCount() - 1 , 0);
- if(lastKey != null && !lastKey.equals(""))
- {
- _model.addRow(new Object[]{"", ""});
- }
- _editor.updated();
- }
- }
- });
- setModel(_model);
-
- setCellSelectionEnabled(_editable);
- setOpaque(_editable);
- setPreferredScrollableViewportSize(getPreferredSize());
-
- DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
- getDefaultRenderer(String.class);
- cr.setOpaque(_editable);
- }
-
-
- public java.util.TreeMap get()
- {
- assert _editable;
-
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
- java.util.Vector vector = _model.getDataVector();
-
- java.util.TreeMap result = new java.util.TreeMap();
-
- java.util.Iterator p = vector.iterator();
- while(p.hasNext())
- {
- java.util.Vector row = (java.util.Vector)p.next();
-
- //
- // Eliminate rows with null or empty keys
- //
- String key = (String)row.elementAt(0);
- if(key != null)
- {
- key = key.trim();
- if(!key.equals(""))
- {
- String val = (String) row.elementAt(1);
- if(val == null)
- {
- val = "";
- }
- result.put(key, val);
- }
- }
- }
- return result;
- }
-
- private DefaultTableModel _model;
- private java.util.Vector _columnNames;
- private boolean _editable = false;
-
- private boolean _substituteKey;
-
- private Editor _editor;
-}
-
-
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+
+
+//
+// A special field used to show/edit a map
+//
+
+public class MapField extends JTable
+{
+ public MapField(Editor editor, String headKey, String headValue, boolean substituteKey)
+ {
+ _substituteKey = substituteKey;
+
+ _columnNames = new java.util.Vector(2);
+ _columnNames.add(headKey);
+ _columnNames.add(headValue);
+
+ _editor = editor;
+
+ Action deleteRow = new AbstractAction("Delete selected row(s)")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if(_editable)
+ {
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+
+ for(;;)
+ {
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1)
+ {
+ break;
+ }
+ else
+ {
+ _model.removeRow(selectedRow);
+ }
+ }
+ }
+ }
+ };
+ getActionMap().put("delete", deleteRow);
+ getInputMap().put(
+ KeyStroke.getKeyStroke("DELETE"), "delete");
+
+ }
+
+ public void set(java.util.Map map, Utils.Resolver resolver,
+ boolean editable)
+ {
+ _editable = editable;
+
+ //
+ // Transform map into vector of vectors
+ //
+ java.util.Vector vector = new java.util.Vector(map.size());
+ java.util.Iterator p = map.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = new java.util.Vector(2);
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ if(_substituteKey)
+ {
+ row.add(Utils.substitute((String)entry.getKey(), resolver));
+ }
+ else
+ {
+ row.add((String)entry.getKey());
+ }
+ row.add(Utils.substitute((String)entry.getValue(), resolver));
+ vector.add(row);
+ }
+
+ if(_editable)
+ {
+ java.util.Vector newRow = new java.util.Vector(2);
+ newRow.add("");
+ newRow.add("");
+ vector.add(newRow);
+ }
+
+ _model = new DefaultTableModel(vector, _columnNames)
+ {
+ public boolean isCellEditable(int row, int column)
+ {
+ return _editable;
+ }
+ };
+
+ _model.addTableModelListener(new TableModelListener()
+ {
+ public void tableChanged(TableModelEvent e)
+ {
+ if(_editable)
+ {
+ Object lastKey = _model.getValueAt(
+ _model.getRowCount() - 1 , 0);
+ if(lastKey != null && !lastKey.equals(""))
+ {
+ _model.addRow(new Object[]{"", ""});
+ }
+ _editor.updated();
+ }
+ }
+ });
+ setModel(_model);
+
+ setCellSelectionEnabled(_editable);
+ setOpaque(_editable);
+ setPreferredScrollableViewportSize(getPreferredSize());
+
+ DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
+ getDefaultRenderer(String.class);
+ cr.setOpaque(_editable);
+ }
+
+
+ public java.util.TreeMap get()
+ {
+ assert _editable;
+
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+ java.util.Vector vector = _model.getDataVector();
+
+ java.util.TreeMap result = new java.util.TreeMap();
+
+ java.util.Iterator p = vector.iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = (java.util.Vector)p.next();
+
+ //
+ // Eliminate rows with null or empty keys
+ //
+ String key = (String)row.elementAt(0);
+ if(key != null)
+ {
+ key = key.trim();
+ if(!key.equals(""))
+ {
+ String val = (String) row.elementAt(1);
+ if(val == null)
+ {
+ val = "";
+ }
+ result.put(key, val);
+ }
+ }
+ }
+ return result;
+ }
+
+ private DefaultTableModel _model;
+ private java.util.Vector _columnNames;
+ private boolean _editable = false;
+
+ private boolean _substituteKey;
+
+ private Editor _editor;
+}
+
+
diff --git a/java/src/IceGridGUI/Application/Node.java b/java/src/IceGridGUI/Application/Node.java
index c325df8db3e..b413385fd1d 100755
--- a/java/src/IceGridGUI/Application/Node.java
+++ b/java/src/IceGridGUI/Application/Node.java
@@ -1,1311 +1,1311 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import java.util.Enumeration;
-
-import javax.swing.Icon;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTextField;
-import javax.swing.JTree;
-
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Node extends TreeNode implements PropertySetParent
-{
- static public NodeDescriptor
- copyDescriptor(NodeDescriptor nd)
- {
- NodeDescriptor copy = (NodeDescriptor)nd.clone();
-
- copy.propertySets = PropertySets.copyDescriptors(copy.propertySets);
-
-
- copy.serverInstances = new java.util.LinkedList();
- java.util.Iterator p = nd.serverInstances.iterator();
- while(p.hasNext())
- {
- copy.serverInstances.add(ServerInstance.copyDescriptor(
- (ServerInstanceDescriptor)p.next()));
- }
-
- copy.servers = new java.util.LinkedList();
- p = nd.servers.iterator();
- while(p.hasNext())
- {
- copy.servers.add(PlainServer.copyDescriptor(
- (ServerDescriptor)p.next()));
- }
-
- return copy;
- }
-
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- if(!_p.hasNext())
- {
- if(!_iteratingOverServers)
- {
- _p = _servers.iterator();
- _iteratingOverServers = true;
- return _p.hasNext();
- }
- return false;
- }
- return true;
- }
-
- public Object nextElement()
- {
- return _p.next();
- }
-
- private java.util.Iterator _p = _propertySets.iterator();
- private boolean _iteratingOverServers = false;
- };
- }
-
- public boolean getAllowsChildren()
- {
- return true;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- if(childIndex < 0)
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- else if(childIndex < _propertySets.size())
- {
- return (javax.swing.tree.TreeNode)_propertySets.get(childIndex);
- }
- else if(childIndex < (_propertySets.size() + _servers.size()))
- {
- return (javax.swing.tree.TreeNode)_servers.get(
- childIndex - _propertySets.size());
- }
- else
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- }
-
- public int getChildCount()
- {
- return _propertySets.size() + _servers.size();
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- if(node instanceof PropertySet)
- {
- return _propertySets.indexOf(node);
- }
- else
- {
- int index = _servers.indexOf(node);
- if(index != -1)
- {
- index += _propertySets.size();
- }
- return index;
- }
- }
-
- public boolean isLeaf()
- {
- return _propertySets.isEmpty() && _servers.isEmpty();
- }
-
- void removeServers(String[] childIds)
- {
- removeSortedChildren(childIds, _servers, getRoot().getTreeModel());
- }
-
- void removePropertySets(String[] childIds)
- {
- removeSortedChildren(childIds, _propertySets, getRoot().getTreeModel());
- }
-
- void childrenChanged(java.util.List children)
- {
- childrenChanged(children, getRoot().getTreeModel());
- }
-
- Server findServer(String id)
- {
- return (Server)find(id, _servers);
- }
-
- PropertySet findPropertySet(String id)
- {
- return (PropertySet)find(id, _propertySets);
- }
-
- void insertPropertySets(java.util.List newChildren, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- String badChildId = insertSortedChildren(newChildren, _propertySets, treeModel);
-
- if(badChildId != null)
- {
- throw new UpdateFailedException(this, badChildId);
- }
- }
-
-
- void insertServer(TreeNode child, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- if(!insertSortedChild(child, _servers, treeModel))
- {
- throw new UpdateFailedException(this, child.getId());
- }
- }
-
- void insertServers(java.util.List newChildren, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- String badChildId = insertSortedChildren(newChildren, _servers, treeModel);
-
- if(badChildId != null)
- {
- throw new UpdateFailedException(this, badChildId);
- }
- }
-
- void removeServer(TreeNode child)
- {
- int index = getIndex(child);
- _servers.remove(child);
-
- getRoot().getTreeModel().nodesWereRemoved(this,
- new int[]{index},
- new Object[]{child});
- }
-
- public void insertPropertySet(PropertySet child, boolean fireEvent)
- throws UpdateFailedException
- {
- DefaultTreeModel treeModel = fireEvent ?
- getRoot().getTreeModel() : null;
-
- if(!insertSortedChild(child, _propertySets, treeModel))
- {
- throw new UpdateFailedException(this, child.getId());
- }
- }
-
- public void removePropertySet(PropertySet child)
- {
- int index = getIndex(child);
- _propertySets.remove(child);
-
- getRoot().getTreeModel().nodesWereRemoved(this,
- new int[]{index},
- new Object[]{child});
- }
-
- public void removeDescriptor(String id)
- {
- _descriptor.propertySets.remove(id);
- }
-
- public Editable getEditable()
- {
- return _editable;
- }
-
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- actions[COPY] = true;
- actions[DELETE] = true;
-
- Object descriptor = getCoordinator().getClipboard();
- if(descriptor != null)
- {
- actions[PASTE] = descriptor instanceof NodeDescriptor ||
- descriptor instanceof ServerInstanceDescriptor ||
- descriptor instanceof ServerDescriptor ||
- descriptor instanceof PropertySetDescriptor;
- }
-
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- actions[NEW_PROPERTY_SET] = true;
- actions[NEW_SERVER] = true;
- actions[NEW_SERVER_ICEBOX] = true;
- actions[NEW_SERVER_FROM_TEMPLATE] = true;
- }
- return actions;
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_PROPERTY_SET));
- _popup.addSeparator();
- _popup.add(actions.get(NEW_SERVER));
- _popup.add(actions.get(NEW_SERVER_ICEBOX));
- _popup.add(actions.get(NEW_SERVER_FROM_TEMPLATE));
- }
- actions.setTarget(this);
- return _popup;
- }
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
- if(descriptor instanceof NodeDescriptor)
- {
- ((TreeNode)_parent).paste();
- }
- else if(descriptor instanceof PropertySetDescriptor)
- {
- newPropertySet(PropertySet.copyDescriptor((PropertySetDescriptor)descriptor));
- }
- else if(descriptor instanceof ServerInstanceDescriptor)
- {
- newServer(ServerInstance.copyDescriptor((ServerInstanceDescriptor)descriptor));
- }
- else
- {
- newServer(PlainServer.copyDescriptor(((ServerDescriptor)descriptor)));
- }
- }
-
- public void newPropertySet()
- {
- newPropertySet(new PropertySetDescriptor(
- new String[0], new java.util.LinkedList()));
- }
-
- public void newServer()
- {
- newServer(PlainServer.newServerDescriptor());
- }
- public void newServerIceBox()
- {
- newServer(PlainServer.newIceBoxDescriptor());
- }
- public void newServerFromTemplate()
- {
- ServerInstanceDescriptor descriptor =
- new ServerInstanceDescriptor("",
- new java.util.HashMap(),
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
-
- newServer(descriptor);
- }
-
- public void destroy()
- {
- Nodes nodes = (Nodes)_parent;
- if(_ephemeral)
- {
- nodes.removeChild(this);
- }
- else
- {
- nodes.removeChild(this);
- nodes.removeDescriptor(_id);
- nodes.getEditable().removeElement(_id, _editable, Node.class);
- getRoot().updated();
- }
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
- Icon nodeIcon = Utils.getIcon("/icons/16x16/node.png");
- _cellRenderer.setOpenIcon(nodeIcon);
- _cellRenderer.setClosedIcon(nodeIcon);
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (NodeEditor)getRoot().getEditor(NodeEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new NodeEditor();
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
-
- Object getDescriptor()
- {
- return _descriptor;
- }
-
-
- NodeDescriptor saveDescriptor()
- {
- return (NodeDescriptor)_descriptor.clone();
- }
-
- void restoreDescriptor(NodeDescriptor copy)
- {
- _descriptor.description = copy.description;
- _descriptor.loadFactor = copy.loadFactor;
- _descriptor.variables = copy.variables;
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", _id));
- if(_descriptor.loadFactor.length() > 0)
- {
- attributes.add(createAttribute("load-factor",
- _descriptor.loadFactor));
- }
-
- writer.writeStartTag("node", attributes);
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- writeVariables(writer, _descriptor.variables);
-
-
- java.util.Iterator p = _propertySets.iterator();
- while(p.hasNext())
- {
- PropertySet ps = (PropertySet)p.next();
- ps.write(writer);
- }
-
- p = _servers.iterator();
- while(p.hasNext())
- {
- TreeNode server = (TreeNode)p.next();
- server.write(writer);
- }
- writer.writeEndTag("node");
- }
- }
-
-
- static class Backup
- {
- Utils.Resolver resolver;
- java.util.List backupList;
- java.util.List servers;
- }
-
- //
- // Try to rebuild this node;
- // returns a backup object if rollback is later necessary
- // We don't rebuild the property sets since they don't
- // depend on the variables.
- //
-
- Backup rebuild(java.util.List editables)
- throws UpdateFailedException
- {
- Root root = getRoot();
- Backup backup = new Backup();
- backup.resolver = _resolver;
-
- _resolver = new Utils.Resolver(new java.util.Map[]
- {_descriptor.variables, root.getVariables()});
-
- _resolver.put("application", root.getId());
- _resolver.put("node", _id);
-
- backup.backupList = new java.util.Vector();
- backup.servers = (java.util.LinkedList)_servers.clone();
-
- java.util.Iterator p = backup.servers.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- try
- {
- backup.backupList.add(server.rebuild(editables));
- }
- catch(UpdateFailedException e)
- {
- restore(backup);
- throw e;
- }
- }
- return backup;
- }
-
- void commit()
- {
- _editable.commit();
- _origVariables = _descriptor.variables;
- _origDescription = _descriptor.description;
- _origLoadFactor = _descriptor.loadFactor;
-
- java.util.Iterator p = _propertySets.iterator();
- while(p.hasNext())
- {
- PropertySet ps = (PropertySet)p.next();
- ps.commit();
- }
-
- p = _servers.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- server.getEditable().commit();
- }
- }
-
- void restore(Backup backup)
- {
- for(int i = backup.backupList.size() - 1; i >= 0; --i)
- {
- ((Server)backup.servers.get(i)).restore(backup.backupList.get(i));
- }
- _resolver = backup.resolver;
- }
-
- ServerInstance createServer(boolean brandNew,
- ServerInstanceDescriptor instanceDescriptor)
- throws UpdateFailedException
- {
- Root root = getRoot();
-
- //
- // Find template
- //
- TemplateDescriptor templateDescriptor =
- root.findServerTemplateDescriptor(instanceDescriptor.template);
-
- assert templateDescriptor != null;
-
- ServerDescriptor serverDescriptor =
- (ServerDescriptor)templateDescriptor.descriptor;
-
- assert serverDescriptor != null;
- boolean isIceBox = serverDescriptor instanceof IceBoxDescriptor;
-
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver =
- new Utils.Resolver(_resolver,
- instanceDescriptor.parameterValues,
- templateDescriptor.parameterDefaults);
-
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Create server
- //
- return new ServerInstance(brandNew, this, serverId,
- instanceResolver, instanceDescriptor, isIceBox);
- }
-
- PlainServer createServer(boolean brandNew, ServerDescriptor serverDescriptor)
- throws UpdateFailedException
- {
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Create server
- //
- return new PlainServer(brandNew, this, serverId,
- instanceResolver, serverDescriptor);
-
- }
-
- NodeUpdateDescriptor getUpdate()
- {
- NodeUpdateDescriptor update = new NodeUpdateDescriptor();
- update.name = _id;
-
- //
- // First: property sets
- //
- if(_editable.isNew())
- {
- update.removePropertySets = new String[0];
- update.propertySets = _descriptor.propertySets;
- }
- else
- {
- update.removePropertySets = _editable.removedElements(PropertySet.class);
- update.propertySets = new java.util.HashMap();
-
- java.util.Iterator p = _propertySets.iterator();
- while(p.hasNext())
- {
- PropertySet ps = (PropertySet)p.next();
- if(ps.getEditable().isNew() || ps.getEditable().isModified())
- {
- update.propertySets.put(ps.getId(), ps.getDescriptor());
- }
- }
- }
-
- //
- // Then: servers
- //
- if(_editable.isNew())
- {
- update.removeServers = new String[0];
- }
- else
- {
- update.removeServers = _editable.removedElements(Server.class);
- }
-
- update.serverInstances = new java.util.LinkedList();
- update.servers = new java.util.LinkedList();
-
- java.util.Iterator p = _servers.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- if(_editable.isNew() || server.getEditable().isModified()
- || server.getEditable().isNew())
- {
- if(server instanceof PlainServer)
- {
- update.servers.add(server.getDescriptor());
- }
- else
- {
- update.serverInstances.add(server.getDescriptor());
- }
- }
- }
-
- //
- // Anything in this update?
- //
- if(!_editable.isNew() && !_editable.isModified()
- && update.removePropertySets.length == 0
- && update.propertySets.size() == 0
- && update.removeServers.length == 0
- && update.servers.size() == 0
- && update.serverInstances.size() == 0)
- {
- return null;
- }
-
- if(_editable.isNew())
- {
- update.variables = _descriptor.variables;
- update.removeVariables = new String[0];
- update.loadFactor = new IceGrid.BoxedString(_descriptor.loadFactor);
- }
- else
- {
- if(!_descriptor.description.equals(_origDescription))
- {
- update.description = new IceGrid.BoxedString(_descriptor.description);
- }
-
- if(!_descriptor.loadFactor.equals(_origLoadFactor))
- {
- update.loadFactor = new IceGrid.BoxedString(_descriptor.loadFactor);
- }
-
- //
- // Diff variables (TODO: avoid duplication with same code in Root)
- //
- update.variables = new java.util.TreeMap(_descriptor.variables);
- java.util.List removeVariables = new java.util.LinkedList();
-
- p = _origVariables.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- Object key = entry.getKey();
- Object newValue = update.variables.get(key);
- if(newValue == null)
- {
- removeVariables.add(key);
- }
- else
- {
- Object value = entry.getValue();
- if(newValue.equals(value))
- {
- update.variables.remove(key);
- }
- }
- }
- update.removeVariables = (String[])removeVariables.toArray(new String[0]);
- }
-
- return update;
- }
-
-
- void update(NodeUpdateDescriptor update,
- java.util.Set serverTemplates, java.util.Set serviceTemplates)
- throws UpdateFailedException
- {
- Root root = getRoot();
-
- java.util.Vector newServers = new java.util.Vector();
- java.util.Vector updatedServers = new java.util.Vector();
-
- if(update != null)
- {
- //
- // Description
- //
- if(update.description != null)
- {
- _descriptor.description = update.description.value;
- _origDescription = _descriptor.description;
- }
-
- //
- // Load factor
- //
- if(update.loadFactor != null)
- {
- _descriptor.loadFactor = update.loadFactor.value;
- _origLoadFactor = _descriptor.loadFactor;
- }
-
- //
- // Variables
- //
- for(int i = 0; i < update.removeVariables.length; ++i)
- {
- _descriptor.variables.remove(update.removeVariables[i]);
- }
- _descriptor.variables.putAll(update.variables);
-
-
- //
- // Property Sets
- //
- removePropertySets(update.removePropertySets);
- for(int i = 0; i < update.removePropertySets.length; ++i)
- {
- _descriptor.propertySets.remove(update.removePropertySets[i]);
- }
-
- java.util.Vector newPropertySets = new java.util.Vector();
- java.util.Vector updatedPropertySets = new java.util.Vector();
-
- java.util.Iterator p = update.propertySets.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- String id = (String)entry.getKey();
- PropertySetDescriptor psd = (PropertySetDescriptor)entry.getValue();
-
- //
- // Lookup named property set
- //
- PropertySet ps = findPropertySet(id);
- if(ps != null)
- {
- ps.rebuild(psd);
- updatedPropertySets.add(ps);
- }
- else
- {
- ps = new PropertySet(false, this, id, psd);
- newPropertySets.add(ps);
- _descriptor.propertySets.put(id, psd);
- }
- }
- childrenChanged(updatedPropertySets);
- insertPropertySets(newPropertySets, true);
-
-
- //
- // Update _descriptor
- //
- for(int i = 0; i < update.removeServers.length; ++i)
- {
- Server server = findServer(update.removeServers[i]);
- removeDescriptor(server);
- }
-
- //
- // One big set of removes
- //
- removeServers(update.removeServers);
-
- //
- // One big set of updates, followed by inserts
- //
- p = update.serverInstances.iterator();
- while(p.hasNext())
- {
- ServerInstanceDescriptor instanceDescriptor =
- (ServerInstanceDescriptor)p.next();
-
- //
- // Find template
- //
- TemplateDescriptor templateDescriptor =
- root.findServerTemplateDescriptor(instanceDescriptor.template);
-
- assert templateDescriptor != null;
-
- ServerDescriptor serverDescriptor =
- (ServerDescriptor)templateDescriptor.descriptor;
-
- assert serverDescriptor != null;
-
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver =
- new Utils.Resolver(_resolver,
- instanceDescriptor.parameterValues,
- templateDescriptor.parameterDefaults);
-
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Lookup servers
- //
- ServerInstance server = (ServerInstance)findServer(serverId);
- if(server != null)
- {
- removeDescriptor(server);
- server.rebuild(instanceResolver, instanceDescriptor,
- serverDescriptor instanceof IceBoxDescriptor);
- updatedServers.add(server);
- _descriptor.serverInstances.add(instanceDescriptor);
- }
- else
- {
- server = new ServerInstance(false, this, serverId, instanceResolver,
- instanceDescriptor,
- serverDescriptor instanceof IceBoxDescriptor);
- newServers.add(server);
- _descriptor.serverInstances.add(instanceDescriptor);
- }
- }
-
- //
- // Plain servers
- //
- p = update.servers.iterator();
- while(p.hasNext())
- {
- ServerDescriptor serverDescriptor = (ServerDescriptor)p.next();
-
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Lookup server
- //
- PlainServer server = (PlainServer)findServer(serverId);
-
- if(server != null)
- {
- removeDescriptor(server);
- server.rebuild(instanceResolver, serverDescriptor);
- updatedServers.add(server);
- _descriptor.servers.add(serverDescriptor);
- }
- else
- {
- server = new PlainServer(false, this, serverId, instanceResolver,
- serverDescriptor);
- newServers.add(server);
- _descriptor.servers.add(serverDescriptor);
- }
- }
- }
-
- //
- // Find servers affected by template updates
- //
- java.util.Set serverSet = new java.util.HashSet();
-
- java.util.Iterator p = serverTemplates.iterator();
- while(p.hasNext())
- {
- String template = (String)p.next();
- java.util.List serverInstances = findServerInstances(template);
- java.util.Iterator q = serverInstances.iterator();
- while(q.hasNext())
- {
- ServerInstance server = (ServerInstance)q.next();
- if(!updatedServers.contains(server) && !newServers.contains(server))
- {
- serverSet.add(server);
- }
- }
- }
-
- //
- // Servers affected by service-template updates
- //
- p = serviceTemplates.iterator();
- while(p.hasNext())
- {
- java.util.List serviceInstances =
- findServiceInstances((String)p.next());
- java.util.Iterator q = serviceInstances.iterator();
- while(q.hasNext())
- {
- ServiceInstance service = (ServiceInstance)q.next();
- Server server = (Server)service.getParent().getParent();
- if(!updatedServers.contains(server) && !newServers.contains(server))
- {
- serverSet.add(server);
- }
- }
- }
-
- //
- // Rebuild these servers
- //
- p = serverSet.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
-
- if(server instanceof PlainServer)
- {
- PlainServer ps = (PlainServer)server;
- ServerDescriptor serverDescriptor = (ServerDescriptor)ps.getDescriptor();
- Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
-
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- assert serverId.equals(ps.getId());
-
- ps.rebuild(instanceResolver, serverDescriptor);
- }
- else
- {
- ServerInstance si = (ServerInstance)server;
- ServerInstanceDescriptor instanceDescriptor = (ServerInstanceDescriptor)si.getDescriptor();
-
- TemplateDescriptor templateDescriptor =
- root.findServerTemplateDescriptor(instanceDescriptor.template);
- assert templateDescriptor != null;
-
- ServerDescriptor serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
- assert serverDescriptor != null;
-
- Utils.Resolver instanceResolver =
- new Utils.Resolver(_resolver,
- instanceDescriptor.parameterValues,
- templateDescriptor.parameterDefaults);
-
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- assert serverId.equals(si.getId());
-
- si.rebuild(instanceResolver, instanceDescriptor,
- serverDescriptor instanceof IceBoxDescriptor);
- }
- updatedServers.add(server);
- }
-
- childrenChanged(updatedServers);
- insertServers(newServers, true);
- }
-
- Node(boolean brandNew, TreeNode parent, String nodeName, NodeDescriptor descriptor)
- throws UpdateFailedException
- {
- super(parent, nodeName);
- _editable = new Editable(brandNew);
-
- _ephemeral = false;
- _descriptor = descriptor;
-
- _origVariables = _descriptor.variables;
- _origDescription = _descriptor.description;
- _origLoadFactor = _descriptor.loadFactor;
-
- _resolver = new Utils.Resolver(new java.util.Map[]
- {_descriptor.variables, getRoot().getVariables()});
-
- _resolver.put("application", getRoot().getId());
- _resolver.put("node", _id);
-
- //
- // Property Sets
- //
- java.util.Iterator p = _descriptor.propertySets.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- insertPropertySet(new PropertySet(false, this,
- (String)entry.getKey(),
- (PropertySetDescriptor)entry.getValue()),
- false);
- }
-
- //
- // Template instances
- //
- p = _descriptor.serverInstances.iterator();
- while(p.hasNext())
- {
- ServerInstanceDescriptor instanceDescriptor =
- (ServerInstanceDescriptor)p.next();
-
- insertServer(createServer(false, instanceDescriptor), false);
- }
-
- //
- // Plain servers
- //
- p = _descriptor.servers.iterator();
- while(p.hasNext())
- {
- ServerDescriptor serverDescriptor = (ServerDescriptor)p.next();
- insertServer(createServer(false, serverDescriptor), false);
- }
- }
-
- Node(TreeNode parent, String nodeName, NodeDescriptor descriptor)
- {
- super(parent, nodeName);
- _editable = new Editable(false);
- _ephemeral = true;
- _descriptor = descriptor;
- }
-
- java.util.List findServerInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _servers.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
-
- if(server instanceof ServerInstance)
- {
- ServerInstanceDescriptor instanceDescriptor
- = (ServerInstanceDescriptor)server.getDescriptor();
-
- if(instanceDescriptor.template.equals(template))
- {
- result.add(server);
- }
- }
- }
- return result;
- }
-
-
- void removeServerInstances(String template)
- {
- java.util.List toRemove = new java.util.LinkedList();
-
- java.util.Iterator p = _servers.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
-
- if(server instanceof ServerInstance)
- {
- ServerInstanceDescriptor instanceDescriptor
- = (ServerInstanceDescriptor)server.getDescriptor();
-
- if(instanceDescriptor.template.equals(template))
- {
- //
- // Remove instance
- //
- removeDescriptor(instanceDescriptor);
- String id = ((TreeNode)server).getId();
- _editable.removeElement(id, server.getEditable(), Server.class);
- toRemove.add(id);
- }
- }
- }
-
- if(toRemove.size() > 0)
- {
- removeServers((String[])toRemove.toArray(new String[0]));
- }
- }
-
- java.util.List findServiceInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _servers.iterator();
- while(p.hasNext())
- {
- Object o = p.next();
- if(o instanceof PlainServer)
- {
- result.addAll(((PlainServer)o).findServiceInstances(template));
- }
- }
- return result;
- }
-
- void removeServiceInstances(String template)
- {
- java.util.Iterator p = _servers.iterator();
- while(p.hasNext())
- {
- Object o = p.next();
- if(o instanceof PlainServer)
- {
- ((PlainServer)o).removeServiceInstances(template);
- }
- }
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
-
- public void tryAdd(String id, PropertySetDescriptor descriptor)
- throws UpdateFailedException
- {
- insertPropertySet(new PropertySet(true, this, id, descriptor),
- true);
- _descriptor.propertySets.put(id, descriptor);
- }
-
-
- void tryAdd(ServerInstanceDescriptor instanceDescriptor,
- boolean addDescriptor) throws UpdateFailedException
- {
- insertServer(createServer(true, instanceDescriptor), true);
-
- if(addDescriptor)
- {
- _descriptor.serverInstances.add(instanceDescriptor);
- }
- }
-
- void tryAdd(ServerDescriptor serverDescriptor,
- boolean addDescriptor) throws UpdateFailedException
- {
- insertServer(createServer(true, serverDescriptor), true);
-
- if(addDescriptor)
- {
- _descriptor.servers.add(serverDescriptor);
- }
- }
-
- void removeDescriptor(Server server)
- {
- if(server instanceof ServerInstance)
- {
- removeDescriptor((ServerInstanceDescriptor)server.getDescriptor());
- }
- else
- {
- removeDescriptor((ServerDescriptor)server.getDescriptor());
- }
- }
-
- void removeDescriptor(ServerDescriptor sd)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = _descriptor.servers.iterator();
- while(p.hasNext())
- {
- if(sd == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
- void removeDescriptor(ServerInstanceDescriptor sd)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = _descriptor.serverInstances.iterator();
- while(p.hasNext())
- {
- if(sd == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
- private void newPropertySet(PropertySetDescriptor descriptor)
- {
- String id = makeNewChildId("PropertySet");
-
- PropertySet ps = new PropertySet(this, id, descriptor);
- try
- {
- insertPropertySet(ps, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(ps);
- }
-
- private void newServer(ServerDescriptor descriptor)
- {
- descriptor.id = makeNewChildId(descriptor.id);
-
- PlainServer server = new PlainServer(this, descriptor.id, descriptor);
- try
- {
- insertServer(server, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(server);
- }
-
- private void newServer(ServerInstanceDescriptor descriptor)
- {
- String id = makeNewChildId("NewServer");
- Root root = getRoot();
-
- //
- // Make sure descriptor.template points to a real template
- //
- ServerTemplate t = root.findServerTemplate(descriptor.template);
-
- if(t == null)
- {
- t = (ServerTemplate)root.getServerTemplates().getChildAt(0);
-
- if(t == null)
- {
- JOptionPane.showMessageDialog(
- getCoordinator().getMainFrame(),
- "You need to create a server template before you can create a server from a template.",
- "No Server Template",
- JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- else
- {
- descriptor.template = t.getId();
- descriptor.parameterValues = new java.util.HashMap();
- }
- }
-
- ServerInstance server = new ServerInstance(this, id, descriptor);
- try
- {
- insertServer(server, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- root.setSelectedNode(server);
- }
-
- private NodeDescriptor _descriptor;
- private Utils.Resolver _resolver;
-
- private java.util.Map _origVariables;
- private String _origDescription;
- private String _origLoadFactor;
-
- private final boolean _ephemeral;
- private NodeEditor _editor;
-
- private java.util.LinkedList _propertySets = new java.util.LinkedList();
- private java.util.LinkedList _servers = new java.util.LinkedList();
-
- private Editable _editable;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import java.util.Enumeration;
+
+import javax.swing.Icon;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Node extends TreeNode implements PropertySetParent
+{
+ static public NodeDescriptor
+ copyDescriptor(NodeDescriptor nd)
+ {
+ NodeDescriptor copy = (NodeDescriptor)nd.clone();
+
+ copy.propertySets = PropertySets.copyDescriptors(copy.propertySets);
+
+
+ copy.serverInstances = new java.util.LinkedList();
+ java.util.Iterator p = nd.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ copy.serverInstances.add(ServerInstance.copyDescriptor(
+ (ServerInstanceDescriptor)p.next()));
+ }
+
+ copy.servers = new java.util.LinkedList();
+ p = nd.servers.iterator();
+ while(p.hasNext())
+ {
+ copy.servers.add(PlainServer.copyDescriptor(
+ (ServerDescriptor)p.next()));
+ }
+
+ return copy;
+ }
+
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ if(!_p.hasNext())
+ {
+ if(!_iteratingOverServers)
+ {
+ _p = _servers.iterator();
+ _iteratingOverServers = true;
+ return _p.hasNext();
+ }
+ return false;
+ }
+ return true;
+ }
+
+ public Object nextElement()
+ {
+ return _p.next();
+ }
+
+ private java.util.Iterator _p = _propertySets.iterator();
+ private boolean _iteratingOverServers = false;
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ if(childIndex < 0)
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ else if(childIndex < _propertySets.size())
+ {
+ return (javax.swing.tree.TreeNode)_propertySets.get(childIndex);
+ }
+ else if(childIndex < (_propertySets.size() + _servers.size()))
+ {
+ return (javax.swing.tree.TreeNode)_servers.get(
+ childIndex - _propertySets.size());
+ }
+ else
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ }
+
+ public int getChildCount()
+ {
+ return _propertySets.size() + _servers.size();
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ if(node instanceof PropertySet)
+ {
+ return _propertySets.indexOf(node);
+ }
+ else
+ {
+ int index = _servers.indexOf(node);
+ if(index != -1)
+ {
+ index += _propertySets.size();
+ }
+ return index;
+ }
+ }
+
+ public boolean isLeaf()
+ {
+ return _propertySets.isEmpty() && _servers.isEmpty();
+ }
+
+ void removeServers(String[] childIds)
+ {
+ removeSortedChildren(childIds, _servers, getRoot().getTreeModel());
+ }
+
+ void removePropertySets(String[] childIds)
+ {
+ removeSortedChildren(childIds, _propertySets, getRoot().getTreeModel());
+ }
+
+ void childrenChanged(java.util.List children)
+ {
+ childrenChanged(children, getRoot().getTreeModel());
+ }
+
+ Server findServer(String id)
+ {
+ return (Server)find(id, _servers);
+ }
+
+ PropertySet findPropertySet(String id)
+ {
+ return (PropertySet)find(id, _propertySets);
+ }
+
+ void insertPropertySets(java.util.List newChildren, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ String badChildId = insertSortedChildren(newChildren, _propertySets, treeModel);
+
+ if(badChildId != null)
+ {
+ throw new UpdateFailedException(this, badChildId);
+ }
+ }
+
+
+ void insertServer(TreeNode child, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ if(!insertSortedChild(child, _servers, treeModel))
+ {
+ throw new UpdateFailedException(this, child.getId());
+ }
+ }
+
+ void insertServers(java.util.List newChildren, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ String badChildId = insertSortedChildren(newChildren, _servers, treeModel);
+
+ if(badChildId != null)
+ {
+ throw new UpdateFailedException(this, badChildId);
+ }
+ }
+
+ void removeServer(TreeNode child)
+ {
+ int index = getIndex(child);
+ _servers.remove(child);
+
+ getRoot().getTreeModel().nodesWereRemoved(this,
+ new int[]{index},
+ new Object[]{child});
+ }
+
+ public void insertPropertySet(PropertySet child, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ DefaultTreeModel treeModel = fireEvent ?
+ getRoot().getTreeModel() : null;
+
+ if(!insertSortedChild(child, _propertySets, treeModel))
+ {
+ throw new UpdateFailedException(this, child.getId());
+ }
+ }
+
+ public void removePropertySet(PropertySet child)
+ {
+ int index = getIndex(child);
+ _propertySets.remove(child);
+
+ getRoot().getTreeModel().nodesWereRemoved(this,
+ new int[]{index},
+ new Object[]{child});
+ }
+
+ public void removeDescriptor(String id)
+ {
+ _descriptor.propertySets.remove(id);
+ }
+
+ public Editable getEditable()
+ {
+ return _editable;
+ }
+
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ actions[COPY] = true;
+ actions[DELETE] = true;
+
+ Object descriptor = getCoordinator().getClipboard();
+ if(descriptor != null)
+ {
+ actions[PASTE] = descriptor instanceof NodeDescriptor ||
+ descriptor instanceof ServerInstanceDescriptor ||
+ descriptor instanceof ServerDescriptor ||
+ descriptor instanceof PropertySetDescriptor;
+ }
+
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ actions[NEW_PROPERTY_SET] = true;
+ actions[NEW_SERVER] = true;
+ actions[NEW_SERVER_ICEBOX] = true;
+ actions[NEW_SERVER_FROM_TEMPLATE] = true;
+ }
+ return actions;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_PROPERTY_SET));
+ _popup.addSeparator();
+ _popup.add(actions.get(NEW_SERVER));
+ _popup.add(actions.get(NEW_SERVER_ICEBOX));
+ _popup.add(actions.get(NEW_SERVER_FROM_TEMPLATE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+ if(descriptor instanceof NodeDescriptor)
+ {
+ ((TreeNode)_parent).paste();
+ }
+ else if(descriptor instanceof PropertySetDescriptor)
+ {
+ newPropertySet(PropertySet.copyDescriptor((PropertySetDescriptor)descriptor));
+ }
+ else if(descriptor instanceof ServerInstanceDescriptor)
+ {
+ newServer(ServerInstance.copyDescriptor((ServerInstanceDescriptor)descriptor));
+ }
+ else
+ {
+ newServer(PlainServer.copyDescriptor(((ServerDescriptor)descriptor)));
+ }
+ }
+
+ public void newPropertySet()
+ {
+ newPropertySet(new PropertySetDescriptor(
+ new String[0], new java.util.LinkedList()));
+ }
+
+ public void newServer()
+ {
+ newServer(PlainServer.newServerDescriptor());
+ }
+ public void newServerIceBox()
+ {
+ newServer(PlainServer.newIceBoxDescriptor());
+ }
+ public void newServerFromTemplate()
+ {
+ ServerInstanceDescriptor descriptor =
+ new ServerInstanceDescriptor("",
+ new java.util.HashMap(),
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()));
+
+ newServer(descriptor);
+ }
+
+ public void destroy()
+ {
+ Nodes nodes = (Nodes)_parent;
+ if(_ephemeral)
+ {
+ nodes.removeChild(this);
+ }
+ else
+ {
+ nodes.removeChild(this);
+ nodes.removeDescriptor(_id);
+ nodes.getEditable().removeElement(_id, _editable, Node.class);
+ getRoot().updated();
+ }
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+ Icon nodeIcon = Utils.getIcon("/icons/16x16/node.png");
+ _cellRenderer.setOpenIcon(nodeIcon);
+ _cellRenderer.setClosedIcon(nodeIcon);
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (NodeEditor)getRoot().getEditor(NodeEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new NodeEditor();
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+
+ Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+
+ NodeDescriptor saveDescriptor()
+ {
+ return (NodeDescriptor)_descriptor.clone();
+ }
+
+ void restoreDescriptor(NodeDescriptor copy)
+ {
+ _descriptor.description = copy.description;
+ _descriptor.loadFactor = copy.loadFactor;
+ _descriptor.variables = copy.variables;
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", _id));
+ if(_descriptor.loadFactor.length() > 0)
+ {
+ attributes.add(createAttribute("load-factor",
+ _descriptor.loadFactor));
+ }
+
+ writer.writeStartTag("node", attributes);
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ writeVariables(writer, _descriptor.variables);
+
+
+ java.util.Iterator p = _propertySets.iterator();
+ while(p.hasNext())
+ {
+ PropertySet ps = (PropertySet)p.next();
+ ps.write(writer);
+ }
+
+ p = _servers.iterator();
+ while(p.hasNext())
+ {
+ TreeNode server = (TreeNode)p.next();
+ server.write(writer);
+ }
+ writer.writeEndTag("node");
+ }
+ }
+
+
+ static class Backup
+ {
+ Utils.Resolver resolver;
+ java.util.List backupList;
+ java.util.List servers;
+ }
+
+ //
+ // Try to rebuild this node;
+ // returns a backup object if rollback is later necessary
+ // We don't rebuild the property sets since they don't
+ // depend on the variables.
+ //
+
+ Backup rebuild(java.util.List editables)
+ throws UpdateFailedException
+ {
+ Root root = getRoot();
+ Backup backup = new Backup();
+ backup.resolver = _resolver;
+
+ _resolver = new Utils.Resolver(new java.util.Map[]
+ {_descriptor.variables, root.getVariables()});
+
+ _resolver.put("application", root.getId());
+ _resolver.put("node", _id);
+
+ backup.backupList = new java.util.Vector();
+ backup.servers = (java.util.LinkedList)_servers.clone();
+
+ java.util.Iterator p = backup.servers.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ try
+ {
+ backup.backupList.add(server.rebuild(editables));
+ }
+ catch(UpdateFailedException e)
+ {
+ restore(backup);
+ throw e;
+ }
+ }
+ return backup;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
+ _origLoadFactor = _descriptor.loadFactor;
+
+ java.util.Iterator p = _propertySets.iterator();
+ while(p.hasNext())
+ {
+ PropertySet ps = (PropertySet)p.next();
+ ps.commit();
+ }
+
+ p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ server.getEditable().commit();
+ }
+ }
+
+ void restore(Backup backup)
+ {
+ for(int i = backup.backupList.size() - 1; i >= 0; --i)
+ {
+ ((Server)backup.servers.get(i)).restore(backup.backupList.get(i));
+ }
+ _resolver = backup.resolver;
+ }
+
+ ServerInstance createServer(boolean brandNew,
+ ServerInstanceDescriptor instanceDescriptor)
+ throws UpdateFailedException
+ {
+ Root root = getRoot();
+
+ //
+ // Find template
+ //
+ TemplateDescriptor templateDescriptor =
+ root.findServerTemplateDescriptor(instanceDescriptor.template);
+
+ assert templateDescriptor != null;
+
+ ServerDescriptor serverDescriptor =
+ (ServerDescriptor)templateDescriptor.descriptor;
+
+ assert serverDescriptor != null;
+ boolean isIceBox = serverDescriptor instanceof IceBoxDescriptor;
+
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver =
+ new Utils.Resolver(_resolver,
+ instanceDescriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Create server
+ //
+ return new ServerInstance(brandNew, this, serverId,
+ instanceResolver, instanceDescriptor, isIceBox);
+ }
+
+ PlainServer createServer(boolean brandNew, ServerDescriptor serverDescriptor)
+ throws UpdateFailedException
+ {
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Create server
+ //
+ return new PlainServer(brandNew, this, serverId,
+ instanceResolver, serverDescriptor);
+
+ }
+
+ NodeUpdateDescriptor getUpdate()
+ {
+ NodeUpdateDescriptor update = new NodeUpdateDescriptor();
+ update.name = _id;
+
+ //
+ // First: property sets
+ //
+ if(_editable.isNew())
+ {
+ update.removePropertySets = new String[0];
+ update.propertySets = _descriptor.propertySets;
+ }
+ else
+ {
+ update.removePropertySets = _editable.removedElements(PropertySet.class);
+ update.propertySets = new java.util.HashMap();
+
+ java.util.Iterator p = _propertySets.iterator();
+ while(p.hasNext())
+ {
+ PropertySet ps = (PropertySet)p.next();
+ if(ps.getEditable().isNew() || ps.getEditable().isModified())
+ {
+ update.propertySets.put(ps.getId(), ps.getDescriptor());
+ }
+ }
+ }
+
+ //
+ // Then: servers
+ //
+ if(_editable.isNew())
+ {
+ update.removeServers = new String[0];
+ }
+ else
+ {
+ update.removeServers = _editable.removedElements(Server.class);
+ }
+
+ update.serverInstances = new java.util.LinkedList();
+ update.servers = new java.util.LinkedList();
+
+ java.util.Iterator p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ if(_editable.isNew() || server.getEditable().isModified()
+ || server.getEditable().isNew())
+ {
+ if(server instanceof PlainServer)
+ {
+ update.servers.add(server.getDescriptor());
+ }
+ else
+ {
+ update.serverInstances.add(server.getDescriptor());
+ }
+ }
+ }
+
+ //
+ // Anything in this update?
+ //
+ if(!_editable.isNew() && !_editable.isModified()
+ && update.removePropertySets.length == 0
+ && update.propertySets.size() == 0
+ && update.removeServers.length == 0
+ && update.servers.size() == 0
+ && update.serverInstances.size() == 0)
+ {
+ return null;
+ }
+
+ if(_editable.isNew())
+ {
+ update.variables = _descriptor.variables;
+ update.removeVariables = new String[0];
+ update.loadFactor = new IceGrid.BoxedString(_descriptor.loadFactor);
+ }
+ else
+ {
+ if(!_descriptor.description.equals(_origDescription))
+ {
+ update.description = new IceGrid.BoxedString(_descriptor.description);
+ }
+
+ if(!_descriptor.loadFactor.equals(_origLoadFactor))
+ {
+ update.loadFactor = new IceGrid.BoxedString(_descriptor.loadFactor);
+ }
+
+ //
+ // Diff variables (TODO: avoid duplication with same code in Root)
+ //
+ update.variables = new java.util.TreeMap(_descriptor.variables);
+ java.util.List removeVariables = new java.util.LinkedList();
+
+ p = _origVariables.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ Object key = entry.getKey();
+ Object newValue = update.variables.get(key);
+ if(newValue == null)
+ {
+ removeVariables.add(key);
+ }
+ else
+ {
+ Object value = entry.getValue();
+ if(newValue.equals(value))
+ {
+ update.variables.remove(key);
+ }
+ }
+ }
+ update.removeVariables = (String[])removeVariables.toArray(new String[0]);
+ }
+
+ return update;
+ }
+
+
+ void update(NodeUpdateDescriptor update,
+ java.util.Set serverTemplates, java.util.Set serviceTemplates)
+ throws UpdateFailedException
+ {
+ Root root = getRoot();
+
+ java.util.Vector newServers = new java.util.Vector();
+ java.util.Vector updatedServers = new java.util.Vector();
+
+ if(update != null)
+ {
+ //
+ // Description
+ //
+ if(update.description != null)
+ {
+ _descriptor.description = update.description.value;
+ _origDescription = _descriptor.description;
+ }
+
+ //
+ // Load factor
+ //
+ if(update.loadFactor != null)
+ {
+ _descriptor.loadFactor = update.loadFactor.value;
+ _origLoadFactor = _descriptor.loadFactor;
+ }
+
+ //
+ // Variables
+ //
+ for(int i = 0; i < update.removeVariables.length; ++i)
+ {
+ _descriptor.variables.remove(update.removeVariables[i]);
+ }
+ _descriptor.variables.putAll(update.variables);
+
+
+ //
+ // Property Sets
+ //
+ removePropertySets(update.removePropertySets);
+ for(int i = 0; i < update.removePropertySets.length; ++i)
+ {
+ _descriptor.propertySets.remove(update.removePropertySets[i]);
+ }
+
+ java.util.Vector newPropertySets = new java.util.Vector();
+ java.util.Vector updatedPropertySets = new java.util.Vector();
+
+ java.util.Iterator p = update.propertySets.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ String id = (String)entry.getKey();
+ PropertySetDescriptor psd = (PropertySetDescriptor)entry.getValue();
+
+ //
+ // Lookup named property set
+ //
+ PropertySet ps = findPropertySet(id);
+ if(ps != null)
+ {
+ ps.rebuild(psd);
+ updatedPropertySets.add(ps);
+ }
+ else
+ {
+ ps = new PropertySet(false, this, id, psd);
+ newPropertySets.add(ps);
+ _descriptor.propertySets.put(id, psd);
+ }
+ }
+ childrenChanged(updatedPropertySets);
+ insertPropertySets(newPropertySets, true);
+
+
+ //
+ // Update _descriptor
+ //
+ for(int i = 0; i < update.removeServers.length; ++i)
+ {
+ Server server = findServer(update.removeServers[i]);
+ removeDescriptor(server);
+ }
+
+ //
+ // One big set of removes
+ //
+ removeServers(update.removeServers);
+
+ //
+ // One big set of updates, followed by inserts
+ //
+ p = update.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor instanceDescriptor =
+ (ServerInstanceDescriptor)p.next();
+
+ //
+ // Find template
+ //
+ TemplateDescriptor templateDescriptor =
+ root.findServerTemplateDescriptor(instanceDescriptor.template);
+
+ assert templateDescriptor != null;
+
+ ServerDescriptor serverDescriptor =
+ (ServerDescriptor)templateDescriptor.descriptor;
+
+ assert serverDescriptor != null;
+
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver =
+ new Utils.Resolver(_resolver,
+ instanceDescriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Lookup servers
+ //
+ ServerInstance server = (ServerInstance)findServer(serverId);
+ if(server != null)
+ {
+ removeDescriptor(server);
+ server.rebuild(instanceResolver, instanceDescriptor,
+ serverDescriptor instanceof IceBoxDescriptor);
+ updatedServers.add(server);
+ _descriptor.serverInstances.add(instanceDescriptor);
+ }
+ else
+ {
+ server = new ServerInstance(false, this, serverId, instanceResolver,
+ instanceDescriptor,
+ serverDescriptor instanceof IceBoxDescriptor);
+ newServers.add(server);
+ _descriptor.serverInstances.add(instanceDescriptor);
+ }
+ }
+
+ //
+ // Plain servers
+ //
+ p = update.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDescriptor serverDescriptor = (ServerDescriptor)p.next();
+
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Lookup server
+ //
+ PlainServer server = (PlainServer)findServer(serverId);
+
+ if(server != null)
+ {
+ removeDescriptor(server);
+ server.rebuild(instanceResolver, serverDescriptor);
+ updatedServers.add(server);
+ _descriptor.servers.add(serverDescriptor);
+ }
+ else
+ {
+ server = new PlainServer(false, this, serverId, instanceResolver,
+ serverDescriptor);
+ newServers.add(server);
+ _descriptor.servers.add(serverDescriptor);
+ }
+ }
+ }
+
+ //
+ // Find servers affected by template updates
+ //
+ java.util.Set serverSet = new java.util.HashSet();
+
+ java.util.Iterator p = serverTemplates.iterator();
+ while(p.hasNext())
+ {
+ String template = (String)p.next();
+ java.util.List serverInstances = findServerInstances(template);
+ java.util.Iterator q = serverInstances.iterator();
+ while(q.hasNext())
+ {
+ ServerInstance server = (ServerInstance)q.next();
+ if(!updatedServers.contains(server) && !newServers.contains(server))
+ {
+ serverSet.add(server);
+ }
+ }
+ }
+
+ //
+ // Servers affected by service-template updates
+ //
+ p = serviceTemplates.iterator();
+ while(p.hasNext())
+ {
+ java.util.List serviceInstances =
+ findServiceInstances((String)p.next());
+ java.util.Iterator q = serviceInstances.iterator();
+ while(q.hasNext())
+ {
+ ServiceInstance service = (ServiceInstance)q.next();
+ Server server = (Server)service.getParent().getParent();
+ if(!updatedServers.contains(server) && !newServers.contains(server))
+ {
+ serverSet.add(server);
+ }
+ }
+ }
+
+ //
+ // Rebuild these servers
+ //
+ p = serverSet.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+
+ if(server instanceof PlainServer)
+ {
+ PlainServer ps = (PlainServer)server;
+ ServerDescriptor serverDescriptor = (ServerDescriptor)ps.getDescriptor();
+ Utils.Resolver instanceResolver = new Utils.Resolver(_resolver);
+
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ assert serverId.equals(ps.getId());
+
+ ps.rebuild(instanceResolver, serverDescriptor);
+ }
+ else
+ {
+ ServerInstance si = (ServerInstance)server;
+ ServerInstanceDescriptor instanceDescriptor = (ServerInstanceDescriptor)si.getDescriptor();
+
+ TemplateDescriptor templateDescriptor =
+ root.findServerTemplateDescriptor(instanceDescriptor.template);
+ assert templateDescriptor != null;
+
+ ServerDescriptor serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
+ assert serverDescriptor != null;
+
+ Utils.Resolver instanceResolver =
+ new Utils.Resolver(_resolver,
+ instanceDescriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ assert serverId.equals(si.getId());
+
+ si.rebuild(instanceResolver, instanceDescriptor,
+ serverDescriptor instanceof IceBoxDescriptor);
+ }
+ updatedServers.add(server);
+ }
+
+ childrenChanged(updatedServers);
+ insertServers(newServers, true);
+ }
+
+ Node(boolean brandNew, TreeNode parent, String nodeName, NodeDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ super(parent, nodeName);
+ _editable = new Editable(brandNew);
+
+ _ephemeral = false;
+ _descriptor = descriptor;
+
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
+ _origLoadFactor = _descriptor.loadFactor;
+
+ _resolver = new Utils.Resolver(new java.util.Map[]
+ {_descriptor.variables, getRoot().getVariables()});
+
+ _resolver.put("application", getRoot().getId());
+ _resolver.put("node", _id);
+
+ //
+ // Property Sets
+ //
+ java.util.Iterator p = _descriptor.propertySets.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ insertPropertySet(new PropertySet(false, this,
+ (String)entry.getKey(),
+ (PropertySetDescriptor)entry.getValue()),
+ false);
+ }
+
+ //
+ // Template instances
+ //
+ p = _descriptor.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor instanceDescriptor =
+ (ServerInstanceDescriptor)p.next();
+
+ insertServer(createServer(false, instanceDescriptor), false);
+ }
+
+ //
+ // Plain servers
+ //
+ p = _descriptor.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDescriptor serverDescriptor = (ServerDescriptor)p.next();
+ insertServer(createServer(false, serverDescriptor), false);
+ }
+ }
+
+ Node(TreeNode parent, String nodeName, NodeDescriptor descriptor)
+ {
+ super(parent, nodeName);
+ _editable = new Editable(false);
+ _ephemeral = true;
+ _descriptor = descriptor;
+ }
+
+ java.util.List findServerInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+
+ if(server instanceof ServerInstance)
+ {
+ ServerInstanceDescriptor instanceDescriptor
+ = (ServerInstanceDescriptor)server.getDescriptor();
+
+ if(instanceDescriptor.template.equals(template))
+ {
+ result.add(server);
+ }
+ }
+ }
+ return result;
+ }
+
+
+ void removeServerInstances(String template)
+ {
+ java.util.List toRemove = new java.util.LinkedList();
+
+ java.util.Iterator p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+
+ if(server instanceof ServerInstance)
+ {
+ ServerInstanceDescriptor instanceDescriptor
+ = (ServerInstanceDescriptor)server.getDescriptor();
+
+ if(instanceDescriptor.template.equals(template))
+ {
+ //
+ // Remove instance
+ //
+ removeDescriptor(instanceDescriptor);
+ String id = ((TreeNode)server).getId();
+ _editable.removeElement(id, server.getEditable(), Server.class);
+ toRemove.add(id);
+ }
+ }
+ }
+
+ if(toRemove.size() > 0)
+ {
+ removeServers((String[])toRemove.toArray(new String[0]));
+ }
+ }
+
+ java.util.List findServiceInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Object o = p.next();
+ if(o instanceof PlainServer)
+ {
+ result.addAll(((PlainServer)o).findServiceInstances(template));
+ }
+ }
+ return result;
+ }
+
+ void removeServiceInstances(String template)
+ {
+ java.util.Iterator p = _servers.iterator();
+ while(p.hasNext())
+ {
+ Object o = p.next();
+ if(o instanceof PlainServer)
+ {
+ ((PlainServer)o).removeServiceInstances(template);
+ }
+ }
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+
+ public void tryAdd(String id, PropertySetDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ insertPropertySet(new PropertySet(true, this, id, descriptor),
+ true);
+ _descriptor.propertySets.put(id, descriptor);
+ }
+
+
+ void tryAdd(ServerInstanceDescriptor instanceDescriptor,
+ boolean addDescriptor) throws UpdateFailedException
+ {
+ insertServer(createServer(true, instanceDescriptor), true);
+
+ if(addDescriptor)
+ {
+ _descriptor.serverInstances.add(instanceDescriptor);
+ }
+ }
+
+ void tryAdd(ServerDescriptor serverDescriptor,
+ boolean addDescriptor) throws UpdateFailedException
+ {
+ insertServer(createServer(true, serverDescriptor), true);
+
+ if(addDescriptor)
+ {
+ _descriptor.servers.add(serverDescriptor);
+ }
+ }
+
+ void removeDescriptor(Server server)
+ {
+ if(server instanceof ServerInstance)
+ {
+ removeDescriptor((ServerInstanceDescriptor)server.getDescriptor());
+ }
+ else
+ {
+ removeDescriptor((ServerDescriptor)server.getDescriptor());
+ }
+ }
+
+ void removeDescriptor(ServerDescriptor sd)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = _descriptor.servers.iterator();
+ while(p.hasNext())
+ {
+ if(sd == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+ void removeDescriptor(ServerInstanceDescriptor sd)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = _descriptor.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ if(sd == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+ private void newPropertySet(PropertySetDescriptor descriptor)
+ {
+ String id = makeNewChildId("PropertySet");
+
+ PropertySet ps = new PropertySet(this, id, descriptor);
+ try
+ {
+ insertPropertySet(ps, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(ps);
+ }
+
+ private void newServer(ServerDescriptor descriptor)
+ {
+ descriptor.id = makeNewChildId(descriptor.id);
+
+ PlainServer server = new PlainServer(this, descriptor.id, descriptor);
+ try
+ {
+ insertServer(server, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(server);
+ }
+
+ private void newServer(ServerInstanceDescriptor descriptor)
+ {
+ String id = makeNewChildId("NewServer");
+ Root root = getRoot();
+
+ //
+ // Make sure descriptor.template points to a real template
+ //
+ ServerTemplate t = root.findServerTemplate(descriptor.template);
+
+ if(t == null)
+ {
+ t = (ServerTemplate)root.getServerTemplates().getChildAt(0);
+
+ if(t == null)
+ {
+ JOptionPane.showMessageDialog(
+ getCoordinator().getMainFrame(),
+ "You need to create a server template before you can create a server from a template.",
+ "No Server Template",
+ JOptionPane.INFORMATION_MESSAGE);
+ return;
+ }
+ else
+ {
+ descriptor.template = t.getId();
+ descriptor.parameterValues = new java.util.HashMap();
+ }
+ }
+
+ ServerInstance server = new ServerInstance(this, id, descriptor);
+ try
+ {
+ insertServer(server, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ root.setSelectedNode(server);
+ }
+
+ private NodeDescriptor _descriptor;
+ private Utils.Resolver _resolver;
+
+ private java.util.Map _origVariables;
+ private String _origDescription;
+ private String _origLoadFactor;
+
+ private final boolean _ephemeral;
+ private NodeEditor _editor;
+
+ private java.util.LinkedList _propertySets = new java.util.LinkedList();
+ private java.util.LinkedList _servers = new java.util.LinkedList();
+
+ private Editable _editable;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/NodeEditor.java b/java/src/IceGridGUI/Application/NodeEditor.java
index d8f2cbb96a7..10cc65e1a9b 100755
--- a/java/src/IceGridGUI/Application/NodeEditor.java
+++ b/java/src/IceGridGUI/Application/NodeEditor.java
@@ -1,261 +1,261 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class NodeEditor extends Editor
-{
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Node Properties");
- }
-
- protected boolean applyUpdate()
- {
- Root root = _target.getRoot();
-
- root.disableSelectionListener();
- try
- {
- if(_target.isEphemeral())
- {
- Nodes nodes = (Nodes)_target.getParent();
- writeDescriptor();
- NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
- _target.destroy(); // just removes the child
- try
- {
- nodes.tryAdd(_name.getText().trim(), descriptor);
- }
- catch(UpdateFailedException e)
- {
- //
- // Add back ephemeral child
- //
- try
- {
- nodes.insertChild(_target, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = nodes.findChildWithDescriptor(descriptor);
- root.updated();
- root.setSelectedNode(_target);
- }
- else if(isSimpleUpdate())
- {
- writeDescriptor();
- root.updated();
- ((Node)_target).getEditable().markModified();
- }
- else
- {
- //
- // Save to be able to rollback
- //
- NodeDescriptor savedDescriptor = ((Node)_target).saveDescriptor();
- writeDescriptor();
-
- //
- // Rebuild node; don't need the backup
- // since it's just one node
- //
- java.util.List editables = new java.util.LinkedList();
-
- try
- {
- ((Node)_target).rebuild(editables);
- }
- catch(UpdateFailedException e)
- {
- ((Node)_target) .restoreDescriptor(savedDescriptor);
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- java.util.Iterator p = editables.iterator();
- while(p.hasNext())
- {
- Editable editable = (Editable)p.next();
- editable.markModified();
- }
-
- ((Node)_target).getEditable().markModified();
- root.updated();
- }
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-
- Utils.Resolver getDetailResolver()
- {
- if(_target.getCoordinator().substitute())
- {
- return _target.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- NodeEditor()
- {
- _name.getDocument().addDocumentListener(_updateListener);
- _name.setToolTipText("Must match the IceGrid.Node.Name property of the desired icegridnode process");
- _description.getDocument().addDocumentListener(_updateListener);
- _description.setToolTipText("An optional description for this node");
-
- //
- // Variables
- //
- _variables = new MapField(this, "Name", "Value", false);
-
- _loadFactor.getDocument().addDocumentListener(_updateListener);
- _loadFactor.setToolTipText("<html>A floating point value.<br>"
- + "When not specified, IceGrid uses 1.0 on all platforms<br>"
- + "except Windows where it uses 1.0 divided by <i>number of processors</i>.<html>");
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- 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(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Variables");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_variables);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Load Factor");
- builder.append(_loadFactor, 3);
- builder.nextLine();
- }
-
- boolean isSimpleUpdate()
- {
- NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
- return (_variables.get().equals(descriptor.variables));
- }
-
- void writeDescriptor()
- {
- NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
- descriptor.description = _description.getText();
- descriptor.variables = _variables.get();
- descriptor.loadFactor = _loadFactor.getText().trim();
- }
-
- protected boolean validate()
- {
- return check(new String[]{"Name", _name.getText().trim()});
- }
-
- void show(Node node)
- {
- detectUpdates(false);
- _target = node;
-
- Utils.Resolver resolver = getDetailResolver();
- boolean isEditable = (resolver == null);
-
- _name.setText(_target.getId());
- _name.setEditable(_target.isEphemeral());
-
- NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
-
- _description.setText(
- Utils.substitute(descriptor.description, resolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
-
- _variables.set(descriptor.variables, resolver, isEditable);
-
- _loadFactor.setText(
- Utils.substitute(descriptor.loadFactor, resolver));
- _loadFactor.setEditable(isEditable);
-
- _applyButton.setEnabled(node.isEphemeral());
- _discardButton.setEnabled(node.isEphemeral());
- detectUpdates(true);
- }
-
- private JTextField _name = new JTextField(20);
- private JTextArea _description = new JTextArea(3, 20);
- private MapField _variables;
- private JTextField _loadFactor = new JTextField(20);
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class NodeEditor extends Editor
+{
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Node Properties");
+ }
+
+ protected boolean applyUpdate()
+ {
+ Root root = _target.getRoot();
+
+ root.disableSelectionListener();
+ try
+ {
+ if(_target.isEphemeral())
+ {
+ Nodes nodes = (Nodes)_target.getParent();
+ writeDescriptor();
+ NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
+ _target.destroy(); // just removes the child
+ try
+ {
+ nodes.tryAdd(_name.getText().trim(), descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Add back ephemeral child
+ //
+ try
+ {
+ nodes.insertChild(_target, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = nodes.findChildWithDescriptor(descriptor);
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+ else if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ root.updated();
+ ((Node)_target).getEditable().markModified();
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ NodeDescriptor savedDescriptor = ((Node)_target).saveDescriptor();
+ writeDescriptor();
+
+ //
+ // Rebuild node; don't need the backup
+ // since it's just one node
+ //
+ java.util.List editables = new java.util.LinkedList();
+
+ try
+ {
+ ((Node)_target).rebuild(editables);
+ }
+ catch(UpdateFailedException e)
+ {
+ ((Node)_target) .restoreDescriptor(savedDescriptor);
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ java.util.Iterator p = editables.iterator();
+ while(p.hasNext())
+ {
+ Editable editable = (Editable)p.next();
+ editable.markModified();
+ }
+
+ ((Node)_target).getEditable().markModified();
+ root.updated();
+ }
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+
+ Utils.Resolver getDetailResolver()
+ {
+ if(_target.getCoordinator().substitute())
+ {
+ return _target.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ NodeEditor()
+ {
+ _name.getDocument().addDocumentListener(_updateListener);
+ _name.setToolTipText("Must match the IceGrid.Node.Name property of the desired icegridnode process");
+ _description.getDocument().addDocumentListener(_updateListener);
+ _description.setToolTipText("An optional description for this node");
+
+ //
+ // Variables
+ //
+ _variables = new MapField(this, "Name", "Value", false);
+
+ _loadFactor.getDocument().addDocumentListener(_updateListener);
+ _loadFactor.setToolTipText("<html>A floating point value.<br>"
+ + "When not specified, IceGrid uses 1.0 on all platforms<br>"
+ + "except Windows where it uses 1.0 divided by <i>number of processors</i>.<html>");
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ 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(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Variables");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_variables);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Load Factor");
+ builder.append(_loadFactor, 3);
+ builder.nextLine();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
+ return (_variables.get().equals(descriptor.variables));
+ }
+
+ void writeDescriptor()
+ {
+ NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
+ descriptor.description = _description.getText();
+ descriptor.variables = _variables.get();
+ descriptor.loadFactor = _loadFactor.getText().trim();
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"Name", _name.getText().trim()});
+ }
+
+ void show(Node node)
+ {
+ detectUpdates(false);
+ _target = node;
+
+ Utils.Resolver resolver = getDetailResolver();
+ boolean isEditable = (resolver == null);
+
+ _name.setText(_target.getId());
+ _name.setEditable(_target.isEphemeral());
+
+ NodeDescriptor descriptor = (NodeDescriptor)_target.getDescriptor();
+
+ _description.setText(
+ Utils.substitute(descriptor.description, resolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+
+ _variables.set(descriptor.variables, resolver, isEditable);
+
+ _loadFactor.setText(
+ Utils.substitute(descriptor.loadFactor, resolver));
+ _loadFactor.setEditable(isEditable);
+
+ _applyButton.setEnabled(node.isEphemeral());
+ _discardButton.setEnabled(node.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private JTextField _name = new JTextField(20);
+ private JTextArea _description = new JTextArea(3, 20);
+ private MapField _variables;
+ private JTextField _loadFactor = new JTextField(20);
+}
diff --git a/java/src/IceGridGUI/Application/Nodes.java b/java/src/IceGridGUI/Application/Nodes.java
index a448504b4f6..6d693217dad 100755
--- a/java/src/IceGridGUI/Application/Nodes.java
+++ b/java/src/IceGridGUI/Application/Nodes.java
@@ -1,318 +1,318 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Nodes extends ListTreeNode
-{
- static public java.util.Map
- copyDescriptors(java.util.Map descriptors)
- {
- java.util.Map copy = new java.util.HashMap();
- java.util.Iterator p = descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- copy.put(entry.getKey(),
- Node.copyDescriptor(
- (NodeDescriptor)entry.getValue()));
- }
- return copy;
- }
-
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- Object descriptor = getCoordinator().getClipboard();
- if(descriptor != null)
- {
- actions[PASTE] = descriptor instanceof NodeDescriptor;
- }
- actions[NEW_NODE] = true;
- return actions;
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_NODE));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
- newNode(Node.copyDescriptor((NodeDescriptor)descriptor));
- }
-
- public void newNode()
- {
- newNode(new NodeDescriptor(
- new java.util.TreeMap(),
- new java.util.LinkedList(),
- new java.util.LinkedList(),
- "",
- "",
- new java.util.HashMap()));
- }
-
- Nodes(TreeNode parent, java.util.Map descriptors)
- throws UpdateFailedException
- {
- super(false, parent, "Nodes");
- _descriptors = descriptors;
-
- java.util.Iterator p = _descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String nodeName = (String)entry.getKey();
- NodeDescriptor nodeDescriptor = (NodeDescriptor)entry.getValue();
- insertChild(new Node(false, this, nodeName, nodeDescriptor), false);
- }
- }
-
- //
- // Try to rebuild all my children
- // No-op if it fails
- //
- void rebuild() throws UpdateFailedException
- {
- java.util.List backupList = new java.util.Vector();
- java.util.List editables = new java.util.LinkedList();
-
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- try
- {
- backupList.add(node.rebuild(editables));
- }
- catch(UpdateFailedException e)
- {
- for(int i = backupList.size() - 1; i >= 0; --i)
- {
- ((Node)_children.get(i)).restore((Node.Backup)backupList.get(i));
- }
- throw e;
- }
- }
-
- //
- // Success
- //
- p = editables.iterator();
- while(p.hasNext())
- {
- Editable editable = (Editable)p.next();
- editable.markModified();
- }
- }
-
- void commit()
- {
- _editable.commit();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- node.commit();
- }
- }
-
- java.util.LinkedList getUpdates()
- {
- java.util.LinkedList updates = new java.util.LinkedList();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- NodeUpdateDescriptor d = node.getUpdate();
- if(d != null)
- {
- updates.add(d);
- }
- }
- return updates;
- }
-
- void removeServerInstances(String templateId)
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- node.removeServerInstances(templateId);
- }
- }
-
- java.util.List findServiceInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- result.addAll(node.findServiceInstances(template));
- }
- return result;
- }
-
-
- void removeServiceInstances(String templateId)
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- node.removeServiceInstances(templateId);
- }
- }
-
- void update(java.util.List updates, String[] removeNodes,
- java.util.Set serverTemplates, java.util.Set serviceTemplates)
- throws UpdateFailedException
- {
- Root root = getRoot();
-
- //
- // Note: _descriptors has already the nodes removed but
- // needs to get the updated and new NodeDescriptors
- //
-
- //
- // One big set of removes
- //
- removeChildren(removeNodes);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
- java.util.Set updatedNodes = new java.util.HashSet();
-
- java.util.Iterator p = updates.iterator();
- while(p.hasNext())
- {
- NodeUpdateDescriptor update = (NodeUpdateDescriptor)p.next();
- Node node = findNode(update.name);
-
- if(node == null)
- {
- NodeDescriptor nodeDescriptor = new NodeDescriptor(update.variables,
- update.serverInstances,
- update.servers,
- update.loadFactor.value,
- update.description.value,
- new java.util.HashMap());
- _descriptors.put(update.name, nodeDescriptor);
- node = new Node(false, this, update.name, nodeDescriptor);
- newChildren.add(node);
- }
- else
- {
- node.update(update, serverTemplates, serviceTemplates);
- updatedNodes.add(node);
- }
- }
-
- //
- // Some nodes are only affected by template updates
- //
- p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- if(!updatedNodes.contains(node))
- {
- node.update(null, serverTemplates, serviceTemplates);
- }
- }
-
- insertChildren(newChildren, true);
- }
-
-
-
- Node findNode(String nodeName)
- {
- return (Node)findChild(nodeName);
- }
-
- java.util.List findServerInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- result.addAll(node.findServerInstances(template));
- }
- return result;
- }
-
- void addDescriptor(String nodeName, NodeDescriptor descriptor)
- {
- _descriptors.put(nodeName, descriptor);
- }
- void removeDescriptor(String nodeName)
- {
- _descriptors.remove(nodeName);
- }
-
- Object getDescriptor()
- {
- return _descriptors;
- }
-
- void tryAdd(String nodeName, NodeDescriptor descriptor)
- throws UpdateFailedException
- {
- Node node = new Node(true, this, nodeName, descriptor);
- insertChild(node, true);
- _descriptors.put(nodeName, descriptor);
- }
-
- private void newNode(NodeDescriptor descriptor)
- {
- String name = makeNewChildId("NewNode");
-
- Node node = new Node(this, name, descriptor);
- try
- {
- insertChild(node, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(node);
- }
-
-
-
- private java.util.Map _descriptors;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Nodes extends ListTreeNode
+{
+ static public java.util.Map
+ copyDescriptors(java.util.Map descriptors)
+ {
+ java.util.Map copy = new java.util.HashMap();
+ java.util.Iterator p = descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ copy.put(entry.getKey(),
+ Node.copyDescriptor(
+ (NodeDescriptor)entry.getValue()));
+ }
+ return copy;
+ }
+
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ Object descriptor = getCoordinator().getClipboard();
+ if(descriptor != null)
+ {
+ actions[PASTE] = descriptor instanceof NodeDescriptor;
+ }
+ actions[NEW_NODE] = true;
+ return actions;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_NODE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+ newNode(Node.copyDescriptor((NodeDescriptor)descriptor));
+ }
+
+ public void newNode()
+ {
+ newNode(new NodeDescriptor(
+ new java.util.TreeMap(),
+ new java.util.LinkedList(),
+ new java.util.LinkedList(),
+ "",
+ "",
+ new java.util.HashMap()));
+ }
+
+ Nodes(TreeNode parent, java.util.Map descriptors)
+ throws UpdateFailedException
+ {
+ super(false, parent, "Nodes");
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ String nodeName = (String)entry.getKey();
+ NodeDescriptor nodeDescriptor = (NodeDescriptor)entry.getValue();
+ insertChild(new Node(false, this, nodeName, nodeDescriptor), false);
+ }
+ }
+
+ //
+ // Try to rebuild all my children
+ // No-op if it fails
+ //
+ void rebuild() throws UpdateFailedException
+ {
+ java.util.List backupList = new java.util.Vector();
+ java.util.List editables = new java.util.LinkedList();
+
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ try
+ {
+ backupList.add(node.rebuild(editables));
+ }
+ catch(UpdateFailedException e)
+ {
+ for(int i = backupList.size() - 1; i >= 0; --i)
+ {
+ ((Node)_children.get(i)).restore((Node.Backup)backupList.get(i));
+ }
+ throw e;
+ }
+ }
+
+ //
+ // Success
+ //
+ p = editables.iterator();
+ while(p.hasNext())
+ {
+ Editable editable = (Editable)p.next();
+ editable.markModified();
+ }
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ node.commit();
+ }
+ }
+
+ java.util.LinkedList getUpdates()
+ {
+ java.util.LinkedList updates = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ NodeUpdateDescriptor d = node.getUpdate();
+ if(d != null)
+ {
+ updates.add(d);
+ }
+ }
+ return updates;
+ }
+
+ void removeServerInstances(String templateId)
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ node.removeServerInstances(templateId);
+ }
+ }
+
+ java.util.List findServiceInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ result.addAll(node.findServiceInstances(template));
+ }
+ return result;
+ }
+
+
+ void removeServiceInstances(String templateId)
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ node.removeServiceInstances(templateId);
+ }
+ }
+
+ void update(java.util.List updates, String[] removeNodes,
+ java.util.Set serverTemplates, java.util.Set serviceTemplates)
+ throws UpdateFailedException
+ {
+ Root root = getRoot();
+
+ //
+ // Note: _descriptors has already the nodes removed but
+ // needs to get the updated and new NodeDescriptors
+ //
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removeNodes);
+
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+ java.util.Set updatedNodes = new java.util.HashSet();
+
+ java.util.Iterator p = updates.iterator();
+ while(p.hasNext())
+ {
+ NodeUpdateDescriptor update = (NodeUpdateDescriptor)p.next();
+ Node node = findNode(update.name);
+
+ if(node == null)
+ {
+ NodeDescriptor nodeDescriptor = new NodeDescriptor(update.variables,
+ update.serverInstances,
+ update.servers,
+ update.loadFactor.value,
+ update.description.value,
+ new java.util.HashMap());
+ _descriptors.put(update.name, nodeDescriptor);
+ node = new Node(false, this, update.name, nodeDescriptor);
+ newChildren.add(node);
+ }
+ else
+ {
+ node.update(update, serverTemplates, serviceTemplates);
+ updatedNodes.add(node);
+ }
+ }
+
+ //
+ // Some nodes are only affected by template updates
+ //
+ p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ if(!updatedNodes.contains(node))
+ {
+ node.update(null, serverTemplates, serviceTemplates);
+ }
+ }
+
+ insertChildren(newChildren, true);
+ }
+
+
+
+ Node findNode(String nodeName)
+ {
+ return (Node)findChild(nodeName);
+ }
+
+ java.util.List findServerInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ result.addAll(node.findServerInstances(template));
+ }
+ return result;
+ }
+
+ void addDescriptor(String nodeName, NodeDescriptor descriptor)
+ {
+ _descriptors.put(nodeName, descriptor);
+ }
+ void removeDescriptor(String nodeName)
+ {
+ _descriptors.remove(nodeName);
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptors;
+ }
+
+ void tryAdd(String nodeName, NodeDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ Node node = new Node(true, this, nodeName, descriptor);
+ insertChild(node, true);
+ _descriptors.put(nodeName, descriptor);
+ }
+
+ private void newNode(NodeDescriptor descriptor)
+ {
+ String name = makeNewChildId("NewNode");
+
+ Node node = new Node(this, name, descriptor);
+ try
+ {
+ insertChild(node, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(node);
+ }
+
+
+
+ private java.util.Map _descriptors;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/ParameterValuesField.java b/java/src/IceGridGUI/Application/ParameterValuesField.java
index 5959ca5bd95..f7f2c2bc499 100755
--- a/java/src/IceGridGUI/Application/ParameterValuesField.java
+++ b/java/src/IceGridGUI/Application/ParameterValuesField.java
@@ -1,198 +1,198 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableColumn;
-
-//
-// A special field used to show/edit parameter values
-//
-
-public class ParameterValuesField extends JTable
-{
- public ParameterValuesField(Editor editor)
- {
- _editor = editor;
-
- _columnNames = new java.util.Vector(2);
- _columnNames.add("Name");
- _columnNames.add("Value");
-
- _useDefaultCombo.setEditable(true);
- _notSetCombo.setEditable(true);
- }
-
- public void set(java.util.List names,
- java.util.Map values,
- java.util.Map defaultValues,
- final Utils.Resolver resolver)
- {
- //
- // Transform map into vector of vectors
- //
- java.util.Vector vector = new java.util.Vector(names.size());
- java.util.Iterator p = names.iterator();
-
- _hasDefault = new boolean[names.size()];
- int i = 0;
-
- while(p.hasNext())
- {
- java.util.Vector row = new java.util.Vector(2);
- String name = (String)p.next();
- row.add(name);
-
- _hasDefault[i] = (defaultValues.get(name) != null);
-
- Object val = values.get(name);
- if(val == null)
- {
- row.add(_hasDefault[i] ? _useDefault : _notSet);
- }
- else
- {
- row.add(Utils.substitute((String)val, resolver));
- }
- vector.add(row);
- i++;
- }
-
- _model = new DefaultTableModel(vector, _columnNames)
- {
- public boolean isCellEditable(int row, int column)
- {
- if(resolver == null)
- {
- return column > 0;
- }
- else
- {
- return false;
- }
- }
- };
-
- _model.addTableModelListener(new TableModelListener()
- {
- public void tableChanged(TableModelEvent e)
- {
- _editor.updated();
- }
- });
- setModel(_model);
-
- setCellSelectionEnabled(resolver == null);
- setOpaque(resolver == null);
- setPreferredScrollableViewportSize(getPreferredSize());
-
- DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
- getDefaultRenderer(String.class);
- cr.setOpaque(resolver == null);
- }
-
-
- public java.util.Map getValues()
- {
- java.util.Map values = new java.util.HashMap();
-
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
- java.util.Vector vector = _model.getDataVector();
-
- java.util.Iterator p = vector.iterator();
- while(p.hasNext())
- {
- java.util.Vector row = (java.util.Vector)p.next();
-
- //
- // Eliminate rows with null or empty names
- //
- String name = (String)row.elementAt(0);
- assert name != null;
-
- Object val = row.elementAt(1);
-
- //
- // Eliminate entries with default or not set value
- //
- if(val != _useDefault && val != _notSet)
- {
- assert val != null;
- values.put(name, val);
- }
- }
- return values;
- }
-
- public TableCellEditor getCellEditor(int row,
- int column)
- {
- if(column == 1)
- {
- return _hasDefault[row] ? _useDefaultEditor : _notSetEditor;
- }
- else
- {
- return super.getCellEditor(row, column);
- }
- }
-
-
- private static final Object _useDefault = new Object()
- {
- public String toString()
- {
- return "Use default";
- }
- };
-
- private static final Object _notSet = new Object()
- {
- public String toString()
- {
- return "Not set";
- }
- };
-
- private JComboBox _useDefaultCombo = new JComboBox(
- new Object[]{_useDefault});
-
- private JComboBox _notSetCombo = new JComboBox(
- new Object[]{_notSet});
-
- private TableCellEditor _useDefaultEditor = new DefaultCellEditor(_useDefaultCombo);
- private TableCellEditor _notSetEditor = new DefaultCellEditor(_notSetCombo);
-
- private DefaultTableModel _model;
- private java.util.Vector _columnNames;
- private Editor _editor;
-
- private boolean[] _hasDefault;
-}
-
-
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableColumn;
+
+//
+// A special field used to show/edit parameter values
+//
+
+public class ParameterValuesField extends JTable
+{
+ public ParameterValuesField(Editor editor)
+ {
+ _editor = editor;
+
+ _columnNames = new java.util.Vector(2);
+ _columnNames.add("Name");
+ _columnNames.add("Value");
+
+ _useDefaultCombo.setEditable(true);
+ _notSetCombo.setEditable(true);
+ }
+
+ public void set(java.util.List names,
+ java.util.Map values,
+ java.util.Map defaultValues,
+ final Utils.Resolver resolver)
+ {
+ //
+ // Transform map into vector of vectors
+ //
+ java.util.Vector vector = new java.util.Vector(names.size());
+ java.util.Iterator p = names.iterator();
+
+ _hasDefault = new boolean[names.size()];
+ int i = 0;
+
+ while(p.hasNext())
+ {
+ java.util.Vector row = new java.util.Vector(2);
+ String name = (String)p.next();
+ row.add(name);
+
+ _hasDefault[i] = (defaultValues.get(name) != null);
+
+ Object val = values.get(name);
+ if(val == null)
+ {
+ row.add(_hasDefault[i] ? _useDefault : _notSet);
+ }
+ else
+ {
+ row.add(Utils.substitute((String)val, resolver));
+ }
+ vector.add(row);
+ i++;
+ }
+
+ _model = new DefaultTableModel(vector, _columnNames)
+ {
+ public boolean isCellEditable(int row, int column)
+ {
+ if(resolver == null)
+ {
+ return column > 0;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ };
+
+ _model.addTableModelListener(new TableModelListener()
+ {
+ public void tableChanged(TableModelEvent e)
+ {
+ _editor.updated();
+ }
+ });
+ setModel(_model);
+
+ setCellSelectionEnabled(resolver == null);
+ setOpaque(resolver == null);
+ setPreferredScrollableViewportSize(getPreferredSize());
+
+ DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
+ getDefaultRenderer(String.class);
+ cr.setOpaque(resolver == null);
+ }
+
+
+ public java.util.Map getValues()
+ {
+ java.util.Map values = new java.util.HashMap();
+
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+ java.util.Vector vector = _model.getDataVector();
+
+ java.util.Iterator p = vector.iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = (java.util.Vector)p.next();
+
+ //
+ // Eliminate rows with null or empty names
+ //
+ String name = (String)row.elementAt(0);
+ assert name != null;
+
+ Object val = row.elementAt(1);
+
+ //
+ // Eliminate entries with default or not set value
+ //
+ if(val != _useDefault && val != _notSet)
+ {
+ assert val != null;
+ values.put(name, val);
+ }
+ }
+ return values;
+ }
+
+ public TableCellEditor getCellEditor(int row,
+ int column)
+ {
+ if(column == 1)
+ {
+ return _hasDefault[row] ? _useDefaultEditor : _notSetEditor;
+ }
+ else
+ {
+ return super.getCellEditor(row, column);
+ }
+ }
+
+
+ private static final Object _useDefault = new Object()
+ {
+ public String toString()
+ {
+ return "Use default";
+ }
+ };
+
+ private static final Object _notSet = new Object()
+ {
+ public String toString()
+ {
+ return "Not set";
+ }
+ };
+
+ private JComboBox _useDefaultCombo = new JComboBox(
+ new Object[]{_useDefault});
+
+ private JComboBox _notSetCombo = new JComboBox(
+ new Object[]{_notSet});
+
+ private TableCellEditor _useDefaultEditor = new DefaultCellEditor(_useDefaultCombo);
+ private TableCellEditor _notSetEditor = new DefaultCellEditor(_notSetCombo);
+
+ private DefaultTableModel _model;
+ private java.util.Vector _columnNames;
+ private Editor _editor;
+
+ private boolean[] _hasDefault;
+}
+
+
diff --git a/java/src/IceGridGUI/Application/ParametersField.java b/java/src/IceGridGUI/Application/ParametersField.java
index d3f48301b3d..e439cc89875 100755
--- a/java/src/IceGridGUI/Application/ParametersField.java
+++ b/java/src/IceGridGUI/Application/ParametersField.java
@@ -1,194 +1,194 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableColumn;
-
-//
-// A special field used to show/edit parameters
-//
-
-public class ParametersField extends JTable
-{
- public ParametersField(Editor editor)
- {
- _editor = editor;
-
- _columnNames = new java.util.Vector(2);
- _columnNames.add("Name");
- _columnNames.add("Default value");
-
- JComboBox comboBox = new JComboBox(
- new Object[]{_noDefault});
- comboBox.setEditable(true);
- _cellEditor = new DefaultCellEditor(comboBox);
-
- Action deleteRow = new AbstractAction("Delete selected row(s)")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
-
- for(;;)
- {
- int selectedRow = getSelectedRow();
- if(selectedRow == -1)
- {
- break;
- }
- else
- {
- _model.removeRow(selectedRow);
- }
- }
- }
- };
- getActionMap().put("delete", deleteRow);
- getInputMap().put(
- KeyStroke.getKeyStroke("DELETE"), "delete");
-
- }
-
- public void set(java.util.List names, java.util.Map values)
- {
- //
- // Transform map into vector of vectors
- //
- java.util.Vector vector = new java.util.Vector(names.size());
- java.util.Iterator p = names.iterator();
- while(p.hasNext())
- {
- java.util.Vector row = new java.util.Vector(2);
- String name = (String)p.next();
-
- row.add(name);
-
- Object val = values.get(name);
- if(val == null)
- {
- row.add(_noDefault);
- }
- else
- {
- row.add(val);
- }
- vector.add(row);
- }
-
-
- java.util.Vector newRow = new java.util.Vector(2);
- newRow.add("");
- newRow.add(_noDefault);
- vector.add(newRow);
-
- _model = new DefaultTableModel(vector, _columnNames);
-
- _model.addTableModelListener(new TableModelListener()
- {
- public void tableChanged(TableModelEvent e)
- {
- Object lastKey = _model.getValueAt(
- _model.getRowCount() - 1 , 0);
- if(lastKey != null && !lastKey.equals(""))
- {
- _model.addRow(new Object[]{"", _noDefault});
- }
-
- _editor.updated();
- }
- });
- setModel(_model);
-
- TableColumn valColumn = getColumnModel().getColumn(1);
- valColumn.setCellEditor(_cellEditor);
-
- setPreferredScrollableViewportSize(getPreferredSize());
- }
-
-
- public java.util.Map get(java.util.List names)
- {
- assert names != null;
-
- java.util.Map values = new java.util.HashMap();
-
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
- java.util.Vector vector = _model.getDataVector();
-
- java.util.Iterator p = vector.iterator();
- while(p.hasNext())
- {
- java.util.Vector row = (java.util.Vector)p.next();
-
- //
- // Eliminate rows with null or empty names
- //
- String name = (String)row.elementAt(0);
- if(name != null)
- {
- name = name.trim();
-
- if(!name.equals(""))
- {
- names.add(name);
-
- Object val = row.elementAt(1);
-
- //
- // Eliminate entries with "default" value
- //
- if(val != _noDefault)
- {
- assert val != null;
- values.put(name, val);
- }
- }
- }
- }
- return values;
- }
-
- private final Object _noDefault = new Object()
- {
- public String toString()
- {
- return "No default";
- }
- };
-
- private DefaultTableModel _model;
- private java.util.Vector _columnNames;
- private Editor _editor;
- private TableCellEditor _cellEditor;
-}
-
-
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableColumn;
+
+//
+// A special field used to show/edit parameters
+//
+
+public class ParametersField extends JTable
+{
+ public ParametersField(Editor editor)
+ {
+ _editor = editor;
+
+ _columnNames = new java.util.Vector(2);
+ _columnNames.add("Name");
+ _columnNames.add("Default value");
+
+ JComboBox comboBox = new JComboBox(
+ new Object[]{_noDefault});
+ comboBox.setEditable(true);
+ _cellEditor = new DefaultCellEditor(comboBox);
+
+ Action deleteRow = new AbstractAction("Delete selected row(s)")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+
+ for(;;)
+ {
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1)
+ {
+ break;
+ }
+ else
+ {
+ _model.removeRow(selectedRow);
+ }
+ }
+ }
+ };
+ getActionMap().put("delete", deleteRow);
+ getInputMap().put(
+ KeyStroke.getKeyStroke("DELETE"), "delete");
+
+ }
+
+ public void set(java.util.List names, java.util.Map values)
+ {
+ //
+ // Transform map into vector of vectors
+ //
+ java.util.Vector vector = new java.util.Vector(names.size());
+ java.util.Iterator p = names.iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = new java.util.Vector(2);
+ String name = (String)p.next();
+
+ row.add(name);
+
+ Object val = values.get(name);
+ if(val == null)
+ {
+ row.add(_noDefault);
+ }
+ else
+ {
+ row.add(val);
+ }
+ vector.add(row);
+ }
+
+
+ java.util.Vector newRow = new java.util.Vector(2);
+ newRow.add("");
+ newRow.add(_noDefault);
+ vector.add(newRow);
+
+ _model = new DefaultTableModel(vector, _columnNames);
+
+ _model.addTableModelListener(new TableModelListener()
+ {
+ public void tableChanged(TableModelEvent e)
+ {
+ Object lastKey = _model.getValueAt(
+ _model.getRowCount() - 1 , 0);
+ if(lastKey != null && !lastKey.equals(""))
+ {
+ _model.addRow(new Object[]{"", _noDefault});
+ }
+
+ _editor.updated();
+ }
+ });
+ setModel(_model);
+
+ TableColumn valColumn = getColumnModel().getColumn(1);
+ valColumn.setCellEditor(_cellEditor);
+
+ setPreferredScrollableViewportSize(getPreferredSize());
+ }
+
+
+ public java.util.Map get(java.util.List names)
+ {
+ assert names != null;
+
+ java.util.Map values = new java.util.HashMap();
+
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+ java.util.Vector vector = _model.getDataVector();
+
+ java.util.Iterator p = vector.iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = (java.util.Vector)p.next();
+
+ //
+ // Eliminate rows with null or empty names
+ //
+ String name = (String)row.elementAt(0);
+ if(name != null)
+ {
+ name = name.trim();
+
+ if(!name.equals(""))
+ {
+ names.add(name);
+
+ Object val = row.elementAt(1);
+
+ //
+ // Eliminate entries with "default" value
+ //
+ if(val != _noDefault)
+ {
+ assert val != null;
+ values.put(name, val);
+ }
+ }
+ }
+ }
+ return values;
+ }
+
+ private final Object _noDefault = new Object()
+ {
+ public String toString()
+ {
+ return "No default";
+ }
+ };
+
+ private DefaultTableModel _model;
+ private java.util.Vector _columnNames;
+ private Editor _editor;
+ private TableCellEditor _cellEditor;
+}
+
+
diff --git a/java/src/IceGridGUI/Application/PlainServer.java b/java/src/IceGridGUI/Application/PlainServer.java
index 105b796364c..328f638d2c6 100755
--- a/java/src/IceGridGUI/Application/PlainServer.java
+++ b/java/src/IceGridGUI/Application/PlainServer.java
@@ -1,551 +1,551 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-
-import javax.swing.Icon;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PlainServer extends Communicator implements Server
-{
- static public ServerDescriptor
- copyDescriptor(ServerDescriptor sd)
- {
- ServerDescriptor copy = (ServerDescriptor)sd.clone();
-
- copy.adapters = Adapter.copyDescriptors(copy.adapters);
- copy.dbEnvs = DbEnv.copyDescriptors(copy.dbEnvs);
-
- copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
-
- copy.distrib = (DistributionDescriptor)copy.distrib.clone();
-
- if(copy instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor ib = (IceBoxDescriptor)copy;
- ib.services = ServiceInstance.copyDescriptors(ib.services);
- }
- return copy;
- }
-
- static public void shallowRestore(ServerDescriptor from, ServerDescriptor into)
- {
- //
- // When editing a server or server template, if we update properties,
- // we replace the entire field
- //
- into.propertySet = from.propertySet;
- into.description = from.description;
- into.id = from.id;
- into.exe = from.exe;
- into.options = from.options;
- into.envs = from.envs;
- into.activation = from.activation;
- into.activationTimeout = from.activationTimeout;
- into.deactivationTimeout = from.deactivationTimeout;
- into.applicationDistrib = from.applicationDistrib;
- into.distrib.icepatch = from.distrib.icepatch;
- into.distrib.directories = from.distrib.directories;
- }
-
- static public ServerDescriptor newServerDescriptor()
- {
- return new ServerDescriptor(
- new java.util.LinkedList(),
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
- new java.util.LinkedList(),
- "",
- "NewServer",
- "",
- "",
- new java.util.LinkedList(),
- new java.util.LinkedList(),
- "manual",
- "",
- "",
- true,
- new DistributionDescriptor("", new java.util.LinkedList()),
- false, // Allocatable
- ""
- );
- }
-
- static public IceBoxDescriptor newIceBoxDescriptor()
- {
- AdapterDescriptor serviceManager = new AdapterDescriptor(
- "IceBox.ServiceManager",
- "",
- "", // direct-adapter by default
- "",
- true,
- true,
- new java.util.LinkedList(),
- new java.util.LinkedList());
-
- java.util.LinkedList adapterList = new java.util.LinkedList();
- adapterList.add(serviceManager);
-
- PropertyDescriptor pd =
- new PropertyDescriptor("IceBox.ServiceManager.Endpoints",
- "tcp -h 127.0.0.1");
- java.util.LinkedList properties = new java.util.LinkedList();
- properties.add(pd);
-
- return new IceBoxDescriptor(
- adapterList,
- new PropertySetDescriptor(new String[0], properties),
- new java.util.LinkedList(),
- "",
- "NewIceBox",
- "",
- "",
- new java.util.LinkedList(),
- new java.util.LinkedList(),
- "manual",
- "",
- "",
- true,
- new DistributionDescriptor("", new java.util.LinkedList()),
- false, // Allocatable
- "",
- new java.util.LinkedList()
- );
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- Object clipboard = getCoordinator().getClipboard();
- if(clipboard != null &&
- (clipboard instanceof ServerDescriptor
- || clipboard instanceof ServerInstanceDescriptor))
- {
- actions[PASTE] = true;
- }
-
- actions[DELETE] = true;
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
-
- actions[NEW_ADAPTER] = !_services.initialized();
- actions[NEW_DBENV] = !_services.initialized();
- actions[NEW_SERVICE] = _services.initialized();
- actions[NEW_SERVICE_FROM_TEMPLATE] = _services.initialized();
- return actions;
- }
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_ADAPTER));
- _popup.add(actions.get(NEW_DBENV));
- _popup.add(actions.get(NEW_SERVICE));
- _popup.add(actions.get(NEW_SERVICE_FROM_TEMPLATE));
- }
- actions.setTarget(this);
- return _popup;
- }
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (PlainServerEditor)getRoot().getEditor(PlainServerEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new PlainServerEditor();
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
-
- _serverIcon = Utils.getIcon("/icons/16x16/server_inactive.png");
- _iceboxServerIcon = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
- }
-
- boolean icebox = _descriptor instanceof IceBoxDescriptor;
-
- if(expanded)
- {
- _cellRenderer.setOpenIcon(icebox ? _iceboxServerIcon : _serverIcon);
- }
- else
- {
- _cellRenderer.setClosedIcon(icebox ? _iceboxServerIcon : _serverIcon);
- }
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public void destroy()
- {
- Node node = (Node)_parent;
-
- if(_ephemeral)
- {
- node.removeServer(this);
- }
- else
- {
- node.removeDescriptor(_descriptor);
- node.removeServer(this);
- node.getEditable().removeElement(_id, _editable, Server.class);
- getRoot().updated();
- }
- }
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object saveDescriptor()
- {
- ServerDescriptor clone = (ServerDescriptor)_descriptor.clone();
- clone.distrib = (DistributionDescriptor)clone.distrib.clone();
- return clone;
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- shallowRestore((ServerDescriptor)savedDescriptor, _descriptor);
- }
-
- //
- // Builds the server and all its sub-tree
- //
- PlainServer(boolean brandNew, TreeNode parent, String serverId,
- Utils.Resolver resolver, ServerDescriptor serverDescriptor)
- throws UpdateFailedException
- {
- super(parent, serverId);
- _ephemeral = false;
- _editable = new Editable(brandNew);
- rebuild(resolver, serverDescriptor);
- }
-
- PlainServer(TreeNode parent, String serverId, ServerDescriptor serverDescriptor)
- {
- super(parent, serverId);
- _ephemeral = true;
- _editable = null;
- try
- {
- rebuild(null, serverDescriptor);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- }
-
- static java.util.List createAttributes(ServerDescriptor descriptor)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("id", descriptor.id));
- if(descriptor.activation.length() > 0)
- {
- attributes.add(createAttribute("activation",
- descriptor.activation));
- }
- if(descriptor.activationTimeout.length() > 0)
- {
- attributes.add(createAttribute("activation-timeout",
- descriptor.activationTimeout));
- }
- if(!descriptor.applicationDistrib)
- {
- attributes.add(createAttribute("application-distrib", "false"));
- }
- if(descriptor.deactivationTimeout.length() > 0)
- {
- attributes.add(createAttribute("deactivation-timeout",
- descriptor.deactivationTimeout));
- }
- if(descriptor.exe.length() > 0)
- {
- attributes.add(createAttribute("exe", descriptor.exe));
- }
- if(descriptor.pwd.length() > 0)
- {
- attributes.add(createAttribute("pwd", descriptor.pwd));
- }
-
- return attributes;
- }
-
- static void writeOptions(XMLWriter writer, java.util.List options)
- throws java.io.IOException
- {
- java.util.Iterator p = options.iterator();
- while(p.hasNext())
- {
- writer.writeElement("option", (String)p.next());
- }
- }
-
- static void writeEnvs(XMLWriter writer, java.util.List envs)
- throws java.io.IOException
- {
- java.util.Iterator p = envs.iterator();
- while(p.hasNext())
- {
- writer.writeElement("env", (String)p.next());
- }
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- if(isIceBox())
- {
- writer.writeStartTag("icebox",
- createAttributes(_descriptor));
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- writeOptions(writer, _descriptor.options);
- writeEnvs(writer, _descriptor.envs);
-
- writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters);
- writeDistribution(writer, _descriptor.distrib);
-
- _adapters.write(writer);
- _services.write(writer);
- writer.writeEndTag("icebox");
- }
- else
- {
- writer.writeStartTag("server", createAttributes(_descriptor));
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
-
- writeOptions(writer, _descriptor.options);
- writeEnvs(writer, _descriptor.envs);
-
- writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters);
- writeDistribution(writer, _descriptor.distrib);
-
- _adapters.write(writer);
- _dbEnvs.write(writer);
- writer.writeEndTag("server");
- }
- }
- }
-
-
- boolean isIceBox()
- {
- return _descriptor instanceof IceBoxDescriptor;
- }
-
- public Object rebuild(java.util.List editables) throws UpdateFailedException
- {
- Node node = (Node)_parent;
- PlainServer newServer = node.createServer(false, _descriptor);
-
- Object backup = null;
-
- if(_id.equals(newServer.getId()))
- {
- //
- // A simple update. We can't simply rebuild server because
- // we need to keep a backup
- //
- if(_editable.isModified())
- {
- newServer.getEditable().markModified();
- }
-
- node.removeServer(this);
- try
- {
- node.insertServer(newServer, true);
- }
- catch(UpdateFailedException e)
- {
- assert false; // impossible, we just removed a child with
- // this id
- }
- }
- else
- {
- //
- // Typically, the id uses a variable whose definition changed
- //
- newServer.getEditable().markNew();
- node.removeServer(this);
- backup = node.getEditable().save();
- node.getEditable().removeElement(_id, _editable, Server.class);
-
- try
- {
- node.insertServer(newServer, true);
- }
- catch(UpdateFailedException e)
- {
- restore(backup);
- throw e;
- }
- }
-
- return backup;
- }
-
- public void restore(Object backupObj)
- {
- Editable backup = (Editable)backupObj;
- Node node = (Node)_parent;
-
- if(backup != null)
- {
- node.getEditable().restore(backup);
- }
-
- TreeNode badServer = node.findChildWithDescriptor(_descriptor);
-
- if(badServer != null)
- {
- node.removeServer(badServer);
- }
- try
- {
- node.insertServer(this, true);
- }
- catch(UpdateFailedException e)
- {
- assert false; // impossible
- }
- }
-
- void setServerDescriptor(ServerDescriptor descriptor)
- {
- _descriptor = descriptor;
- }
-
- //
- // Update the server and all its subtree
- //
- void rebuild(Utils.Resolver resolver,
- ServerDescriptor serverDescriptor) throws UpdateFailedException
- {
- assert serverDescriptor != null;
- _resolver = resolver;
- _descriptor = serverDescriptor;
-
- _adapters.clear();
- _dbEnvs.clear();
- _services.clear();
-
- if(!_ephemeral)
- {
- _adapters.init(_descriptor.adapters);
- if(_descriptor instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_descriptor;
- _services.init(iceBoxDescriptor.services);
-
- //
- // IceBox has not dbEnv
- //
- assert _descriptor.dbEnvs.size() == 0;
- }
- else
- {
- _dbEnvs.init(_descriptor.dbEnvs);
- }
- }
- }
-
- CommunicatorDescriptor getCommunicatorDescriptor()
- {
- return _descriptor;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- public Editable getEditable()
- {
- return _editable;
- }
-
- Editable getEnclosingEditable()
- {
- return _editable;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- private ServerDescriptor _descriptor;
- private final boolean _ephemeral;
-
- private PlainServerEditor _editor;
-
- private Utils.Resolver _resolver;
- private Editable _editable;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon _serverIcon;
- static private Icon _iceboxServerIcon;
-
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+
+import javax.swing.Icon;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PlainServer extends Communicator implements Server
+{
+ static public ServerDescriptor
+ copyDescriptor(ServerDescriptor sd)
+ {
+ ServerDescriptor copy = (ServerDescriptor)sd.clone();
+
+ copy.adapters = Adapter.copyDescriptors(copy.adapters);
+ copy.dbEnvs = DbEnv.copyDescriptors(copy.dbEnvs);
+
+ copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
+
+ copy.distrib = (DistributionDescriptor)copy.distrib.clone();
+
+ if(copy instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor ib = (IceBoxDescriptor)copy;
+ ib.services = ServiceInstance.copyDescriptors(ib.services);
+ }
+ return copy;
+ }
+
+ static public void shallowRestore(ServerDescriptor from, ServerDescriptor into)
+ {
+ //
+ // When editing a server or server template, if we update properties,
+ // we replace the entire field
+ //
+ into.propertySet = from.propertySet;
+ into.description = from.description;
+ into.id = from.id;
+ into.exe = from.exe;
+ into.options = from.options;
+ into.envs = from.envs;
+ into.activation = from.activation;
+ into.activationTimeout = from.activationTimeout;
+ into.deactivationTimeout = from.deactivationTimeout;
+ into.applicationDistrib = from.applicationDistrib;
+ into.distrib.icepatch = from.distrib.icepatch;
+ into.distrib.directories = from.distrib.directories;
+ }
+
+ static public ServerDescriptor newServerDescriptor()
+ {
+ return new ServerDescriptor(
+ new java.util.LinkedList(),
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
+ new java.util.LinkedList(),
+ "",
+ "NewServer",
+ "",
+ "",
+ new java.util.LinkedList(),
+ new java.util.LinkedList(),
+ "manual",
+ "",
+ "",
+ true,
+ new DistributionDescriptor("", new java.util.LinkedList()),
+ false, // Allocatable
+ ""
+ );
+ }
+
+ static public IceBoxDescriptor newIceBoxDescriptor()
+ {
+ AdapterDescriptor serviceManager = new AdapterDescriptor(
+ "IceBox.ServiceManager",
+ "",
+ "", // direct-adapter by default
+ "",
+ true,
+ true,
+ new java.util.LinkedList(),
+ new java.util.LinkedList());
+
+ java.util.LinkedList adapterList = new java.util.LinkedList();
+ adapterList.add(serviceManager);
+
+ PropertyDescriptor pd =
+ new PropertyDescriptor("IceBox.ServiceManager.Endpoints",
+ "tcp -h 127.0.0.1");
+ java.util.LinkedList properties = new java.util.LinkedList();
+ properties.add(pd);
+
+ return new IceBoxDescriptor(
+ adapterList,
+ new PropertySetDescriptor(new String[0], properties),
+ new java.util.LinkedList(),
+ "",
+ "NewIceBox",
+ "",
+ "",
+ new java.util.LinkedList(),
+ new java.util.LinkedList(),
+ "manual",
+ "",
+ "",
+ true,
+ new DistributionDescriptor("", new java.util.LinkedList()),
+ false, // Allocatable
+ "",
+ new java.util.LinkedList()
+ );
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ Object clipboard = getCoordinator().getClipboard();
+ if(clipboard != null &&
+ (clipboard instanceof ServerDescriptor
+ || clipboard instanceof ServerInstanceDescriptor))
+ {
+ actions[PASTE] = true;
+ }
+
+ actions[DELETE] = true;
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+
+ actions[NEW_ADAPTER] = !_services.initialized();
+ actions[NEW_DBENV] = !_services.initialized();
+ actions[NEW_SERVICE] = _services.initialized();
+ actions[NEW_SERVICE_FROM_TEMPLATE] = _services.initialized();
+ return actions;
+ }
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_ADAPTER));
+ _popup.add(actions.get(NEW_DBENV));
+ _popup.add(actions.get(NEW_SERVICE));
+ _popup.add(actions.get(NEW_SERVICE_FROM_TEMPLATE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (PlainServerEditor)getRoot().getEditor(PlainServerEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new PlainServerEditor();
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+
+ _serverIcon = Utils.getIcon("/icons/16x16/server_inactive.png");
+ _iceboxServerIcon = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
+ }
+
+ boolean icebox = _descriptor instanceof IceBoxDescriptor;
+
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(icebox ? _iceboxServerIcon : _serverIcon);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(icebox ? _iceboxServerIcon : _serverIcon);
+ }
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public void destroy()
+ {
+ Node node = (Node)_parent;
+
+ if(_ephemeral)
+ {
+ node.removeServer(this);
+ }
+ else
+ {
+ node.removeDescriptor(_descriptor);
+ node.removeServer(this);
+ node.getEditable().removeElement(_id, _editable, Server.class);
+ getRoot().updated();
+ }
+ }
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object saveDescriptor()
+ {
+ ServerDescriptor clone = (ServerDescriptor)_descriptor.clone();
+ clone.distrib = (DistributionDescriptor)clone.distrib.clone();
+ return clone;
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ shallowRestore((ServerDescriptor)savedDescriptor, _descriptor);
+ }
+
+ //
+ // Builds the server and all its sub-tree
+ //
+ PlainServer(boolean brandNew, TreeNode parent, String serverId,
+ Utils.Resolver resolver, ServerDescriptor serverDescriptor)
+ throws UpdateFailedException
+ {
+ super(parent, serverId);
+ _ephemeral = false;
+ _editable = new Editable(brandNew);
+ rebuild(resolver, serverDescriptor);
+ }
+
+ PlainServer(TreeNode parent, String serverId, ServerDescriptor serverDescriptor)
+ {
+ super(parent, serverId);
+ _ephemeral = true;
+ _editable = null;
+ try
+ {
+ rebuild(null, serverDescriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ }
+
+ static java.util.List createAttributes(ServerDescriptor descriptor)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("id", descriptor.id));
+ if(descriptor.activation.length() > 0)
+ {
+ attributes.add(createAttribute("activation",
+ descriptor.activation));
+ }
+ if(descriptor.activationTimeout.length() > 0)
+ {
+ attributes.add(createAttribute("activation-timeout",
+ descriptor.activationTimeout));
+ }
+ if(!descriptor.applicationDistrib)
+ {
+ attributes.add(createAttribute("application-distrib", "false"));
+ }
+ if(descriptor.deactivationTimeout.length() > 0)
+ {
+ attributes.add(createAttribute("deactivation-timeout",
+ descriptor.deactivationTimeout));
+ }
+ if(descriptor.exe.length() > 0)
+ {
+ attributes.add(createAttribute("exe", descriptor.exe));
+ }
+ if(descriptor.pwd.length() > 0)
+ {
+ attributes.add(createAttribute("pwd", descriptor.pwd));
+ }
+
+ return attributes;
+ }
+
+ static void writeOptions(XMLWriter writer, java.util.List options)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = options.iterator();
+ while(p.hasNext())
+ {
+ writer.writeElement("option", (String)p.next());
+ }
+ }
+
+ static void writeEnvs(XMLWriter writer, java.util.List envs)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = envs.iterator();
+ while(p.hasNext())
+ {
+ writer.writeElement("env", (String)p.next());
+ }
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ if(isIceBox())
+ {
+ writer.writeStartTag("icebox",
+ createAttributes(_descriptor));
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ writeOptions(writer, _descriptor.options);
+ writeEnvs(writer, _descriptor.envs);
+
+ writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters);
+ writeDistribution(writer, _descriptor.distrib);
+
+ _adapters.write(writer);
+ _services.write(writer);
+ writer.writeEndTag("icebox");
+ }
+ else
+ {
+ writer.writeStartTag("server", createAttributes(_descriptor));
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+
+ writeOptions(writer, _descriptor.options);
+ writeEnvs(writer, _descriptor.envs);
+
+ writePropertySet(writer, "", _descriptor.propertySet, _descriptor.adapters);
+ writeDistribution(writer, _descriptor.distrib);
+
+ _adapters.write(writer);
+ _dbEnvs.write(writer);
+ writer.writeEndTag("server");
+ }
+ }
+ }
+
+
+ boolean isIceBox()
+ {
+ return _descriptor instanceof IceBoxDescriptor;
+ }
+
+ public Object rebuild(java.util.List editables) throws UpdateFailedException
+ {
+ Node node = (Node)_parent;
+ PlainServer newServer = node.createServer(false, _descriptor);
+
+ Object backup = null;
+
+ if(_id.equals(newServer.getId()))
+ {
+ //
+ // A simple update. We can't simply rebuild server because
+ // we need to keep a backup
+ //
+ if(_editable.isModified())
+ {
+ newServer.getEditable().markModified();
+ }
+
+ node.removeServer(this);
+ try
+ {
+ node.insertServer(newServer, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false; // impossible, we just removed a child with
+ // this id
+ }
+ }
+ else
+ {
+ //
+ // Typically, the id uses a variable whose definition changed
+ //
+ newServer.getEditable().markNew();
+ node.removeServer(this);
+ backup = node.getEditable().save();
+ node.getEditable().removeElement(_id, _editable, Server.class);
+
+ try
+ {
+ node.insertServer(newServer, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ restore(backup);
+ throw e;
+ }
+ }
+
+ return backup;
+ }
+
+ public void restore(Object backupObj)
+ {
+ Editable backup = (Editable)backupObj;
+ Node node = (Node)_parent;
+
+ if(backup != null)
+ {
+ node.getEditable().restore(backup);
+ }
+
+ TreeNode badServer = node.findChildWithDescriptor(_descriptor);
+
+ if(badServer != null)
+ {
+ node.removeServer(badServer);
+ }
+ try
+ {
+ node.insertServer(this, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false; // impossible
+ }
+ }
+
+ void setServerDescriptor(ServerDescriptor descriptor)
+ {
+ _descriptor = descriptor;
+ }
+
+ //
+ // Update the server and all its subtree
+ //
+ void rebuild(Utils.Resolver resolver,
+ ServerDescriptor serverDescriptor) throws UpdateFailedException
+ {
+ assert serverDescriptor != null;
+ _resolver = resolver;
+ _descriptor = serverDescriptor;
+
+ _adapters.clear();
+ _dbEnvs.clear();
+ _services.clear();
+
+ if(!_ephemeral)
+ {
+ _adapters.init(_descriptor.adapters);
+ if(_descriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_descriptor;
+ _services.init(iceBoxDescriptor.services);
+
+ //
+ // IceBox has not dbEnv
+ //
+ assert _descriptor.dbEnvs.size() == 0;
+ }
+ else
+ {
+ _dbEnvs.init(_descriptor.dbEnvs);
+ }
+ }
+ }
+
+ CommunicatorDescriptor getCommunicatorDescriptor()
+ {
+ return _descriptor;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ public Editable getEditable()
+ {
+ return _editable;
+ }
+
+ Editable getEnclosingEditable()
+ {
+ return _editable;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ private ServerDescriptor _descriptor;
+ private final boolean _ephemeral;
+
+ private PlainServerEditor _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/PlainServerEditor.java b/java/src/IceGridGUI/Application/PlainServerEditor.java
index ed0189301eb..f0cf9316752 100755
--- a/java/src/IceGridGUI/Application/PlainServerEditor.java
+++ b/java/src/IceGridGUI/Application/PlainServerEditor.java
@@ -1,76 +1,76 @@
-// **********************************************************************
-//
-// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PlainServerEditor extends AbstractServerEditor
-{
- protected void writeDescriptor()
- {
- _subEditor.writeDescriptor();
- }
-
- protected boolean isSimpleUpdate()
- {
- return _subEditor.isSimpleUpdate();
- }
-
- PlainServerEditor()
- {
- _subEditor = new ServerSubEditor(this);
- }
-
- //
- // From Editor:
- //
- Utils.Resolver getDetailResolver()
- {
- if(_target.getCoordinator().substitute())
- {
- return _target.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- _subEditor.appendProperties(builder);
- }
-
- Object getSubDescriptor()
- {
- return _target.getDescriptor();
- }
-
- protected boolean validate()
- {
- return _subEditor.validate();
- }
-
- void show(PlainServer server)
- {
- detectUpdates(false);
- _target = server;
-
- _subEditor.show(true);
-
- _applyButton.setEnabled(server.isEphemeral());
- _discardButton.setEnabled(server.isEphemeral());
- detectUpdates(true);
- }
-
- private ServerSubEditor _subEditor;
-}
+// **********************************************************************
+//
+// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PlainServerEditor extends AbstractServerEditor
+{
+ protected void writeDescriptor()
+ {
+ _subEditor.writeDescriptor();
+ }
+
+ protected boolean isSimpleUpdate()
+ {
+ return _subEditor.isSimpleUpdate();
+ }
+
+ PlainServerEditor()
+ {
+ _subEditor = new ServerSubEditor(this);
+ }
+
+ //
+ // From Editor:
+ //
+ Utils.Resolver getDetailResolver()
+ {
+ if(_target.getCoordinator().substitute())
+ {
+ return _target.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ _subEditor.appendProperties(builder);
+ }
+
+ Object getSubDescriptor()
+ {
+ return _target.getDescriptor();
+ }
+
+ protected boolean validate()
+ {
+ return _subEditor.validate();
+ }
+
+ void show(PlainServer server)
+ {
+ detectUpdates(false);
+ _target = server;
+
+ _subEditor.show(true);
+
+ _applyButton.setEnabled(server.isEphemeral());
+ _discardButton.setEnabled(server.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private ServerSubEditor _subEditor;
+}
diff --git a/java/src/IceGridGUI/Application/PlainService.java b/java/src/IceGridGUI/Application/PlainService.java
index 1b417427d47..d13a0ba12dd 100755
--- a/java/src/IceGridGUI/Application/PlainService.java
+++ b/java/src/IceGridGUI/Application/PlainService.java
@@ -1,295 +1,295 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PlainService extends Communicator implements Service, Cloneable
-{
- static public ServiceDescriptor
- copyDescriptor(ServiceDescriptor sd)
- {
- ServiceDescriptor copy = (ServiceDescriptor)sd.clone();
- copy.adapters = Adapter.copyDescriptors(copy.adapters);
- copy.dbEnvs = DbEnv.copyDescriptors(copy.dbEnvs);
- copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
- return copy;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setOpenIcon(
- Utils.getIcon("/icons/16x16/service.png"));
-
- _cellRenderer.setClosedIcon(
- Utils.getIcon("/icons/16x16/service.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
-
- actions[DELETE] = true;
- actions[NEW_ADAPTER] = !_ephemeral;
- actions[NEW_DBENV] = !_ephemeral;
-
- if(_parent instanceof Server && !_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
-
- actions[MOVE_UP] = canMove(true);
- actions[MOVE_DOWN] = canMove(false);
- return actions;
- }
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_ADAPTER));
- _popup.add(actions.get(NEW_DBENV));
- _popup.addSeparator();
- _popup.add(actions.get(MOVE_UP));
- _popup.add(actions.get(MOVE_DOWN));
- }
- actions.setTarget(this);
- return _popup;
- }
- public void copy()
- {
- getCoordinator().setClipboard(ServiceInstance.copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
-
- public void moveUp()
- {
- move(true);
- }
- public void moveDown()
- {
- move(false);
- }
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object saveDescriptor()
- {
- return _descriptor.clone();
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- ServiceInstanceDescriptor sid = (ServiceInstanceDescriptor)savedDescriptor;
-
- _descriptor.descriptor.propertySet = sid.descriptor.propertySet;
- _descriptor.descriptor.description = sid.descriptor.description;
- _descriptor.descriptor.name = sid.descriptor.name;
- _descriptor.descriptor.entry = sid.descriptor.entry;
- }
-
- public void destroy()
- {
- ((Communicator)_parent).getServices().destroyChild(this);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (PlainServiceEditor)getRoot().getEditor(PlainServiceEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new PlainServiceEditor();
- }
-
- Editable getEnclosingEditable()
- {
- return ((Communicator)_parent).getEnclosingEditable();
- }
-
- private boolean canMove(boolean up)
- {
- if(_ephemeral)
- {
- return false;
- }
- else
- {
- return ((Communicator)_parent).getServices().canMove(this, up);
- }
- }
-
- private void move(boolean up)
- {
- assert canMove(up);
- ((Communicator)_parent).getServices().move(this, up);
- }
-
- public Object rebuild(java.util.List editables)
- throws UpdateFailedException
- {
- Communicator communicator = (Communicator)_parent;
- Services services = communicator.getServices();
- PlainService newService = null;
-
- newService = (PlainService)services.createChild(_descriptor);
-
- Object backup = null;
-
- try
- {
- backup = (PlainService)clone();
- }
- catch(CloneNotSupportedException e)
- {
- assert false;
- }
-
- reset(newService);
- getRoot().getTreeModel().nodeChanged(this);
- return backup;
- }
-
- public void restore(Object backupObj)
- {
- reset((PlainService)backupObj);
- getRoot().getTreeModel().nodeChanged(this);
- }
-
- private void reset(PlainService from)
- {
- _id = from._id;
- assert _parent == from._parent;
-
- _adapters = from._adapters;
- _dbEnvs = from._dbEnvs;
- _services = from._services;
- _childListArray = from._childListArray;
-
- _descriptor = from._descriptor;
- _resolver = from._resolver;
- }
-
- PlainService(Communicator parent,
- String name,
- ServiceInstanceDescriptor descriptor,
- Utils.Resolver resolver)
- throws UpdateFailedException
- {
- super(parent, name);
- _descriptor = descriptor;
- _ephemeral = false;
- _resolver = resolver;
-
- _adapters.init(_descriptor.descriptor.adapters);
- _dbEnvs.init(_descriptor.descriptor.dbEnvs);
- }
-
- //
- // New temporary object
- //
- PlainService(Communicator parent, ServiceInstanceDescriptor descriptor)
- {
- super(parent, descriptor.descriptor.name);
- _descriptor = descriptor;
- _ephemeral = true;
- }
-
- static java.util.List createAttributes(ServiceDescriptor descriptor)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", descriptor.name));
- attributes.add(createAttribute("entry", descriptor.entry));
- return attributes;
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- writer.writeStartTag("service", createAttributes(_descriptor.descriptor));
-
- if(_descriptor.descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.descriptor.description);
- }
-
- writePropertySet(writer, "", _descriptor.descriptor.propertySet,
- _descriptor.descriptor.adapters);
- _adapters.write(writer);
- _dbEnvs.write(writer);
- writer.writeEndTag("service");
- }
- }
-
- CommunicatorDescriptor getCommunicatorDescriptor()
- {
- return _descriptor.descriptor;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- private ServiceInstanceDescriptor _descriptor;
-
- private final boolean _ephemeral;
-
- private Utils.Resolver _resolver;
- private PlainServiceEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PlainService extends Communicator implements Service, Cloneable
+{
+ static public ServiceDescriptor
+ copyDescriptor(ServiceDescriptor sd)
+ {
+ ServiceDescriptor copy = (ServiceDescriptor)sd.clone();
+ copy.adapters = Adapter.copyDescriptors(copy.adapters);
+ copy.dbEnvs = DbEnv.copyDescriptors(copy.dbEnvs);
+ copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
+ return copy;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setOpenIcon(
+ Utils.getIcon("/icons/16x16/service.png"));
+
+ _cellRenderer.setClosedIcon(
+ Utils.getIcon("/icons/16x16/service.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+
+ actions[DELETE] = true;
+ actions[NEW_ADAPTER] = !_ephemeral;
+ actions[NEW_DBENV] = !_ephemeral;
+
+ if(_parent instanceof Server && !_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+
+ actions[MOVE_UP] = canMove(true);
+ actions[MOVE_DOWN] = canMove(false);
+ return actions;
+ }
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_ADAPTER));
+ _popup.add(actions.get(NEW_DBENV));
+ _popup.addSeparator();
+ _popup.add(actions.get(MOVE_UP));
+ _popup.add(actions.get(MOVE_DOWN));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(ServiceInstance.copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+
+ public void moveUp()
+ {
+ move(true);
+ }
+ public void moveDown()
+ {
+ move(false);
+ }
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object saveDescriptor()
+ {
+ return _descriptor.clone();
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ ServiceInstanceDescriptor sid = (ServiceInstanceDescriptor)savedDescriptor;
+
+ _descriptor.descriptor.propertySet = sid.descriptor.propertySet;
+ _descriptor.descriptor.description = sid.descriptor.description;
+ _descriptor.descriptor.name = sid.descriptor.name;
+ _descriptor.descriptor.entry = sid.descriptor.entry;
+ }
+
+ public void destroy()
+ {
+ ((Communicator)_parent).getServices().destroyChild(this);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (PlainServiceEditor)getRoot().getEditor(PlainServiceEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new PlainServiceEditor();
+ }
+
+ Editable getEnclosingEditable()
+ {
+ return ((Communicator)_parent).getEnclosingEditable();
+ }
+
+ private boolean canMove(boolean up)
+ {
+ if(_ephemeral)
+ {
+ return false;
+ }
+ else
+ {
+ return ((Communicator)_parent).getServices().canMove(this, up);
+ }
+ }
+
+ private void move(boolean up)
+ {
+ assert canMove(up);
+ ((Communicator)_parent).getServices().move(this, up);
+ }
+
+ public Object rebuild(java.util.List editables)
+ throws UpdateFailedException
+ {
+ Communicator communicator = (Communicator)_parent;
+ Services services = communicator.getServices();
+ PlainService newService = null;
+
+ newService = (PlainService)services.createChild(_descriptor);
+
+ Object backup = null;
+
+ try
+ {
+ backup = (PlainService)clone();
+ }
+ catch(CloneNotSupportedException e)
+ {
+ assert false;
+ }
+
+ reset(newService);
+ getRoot().getTreeModel().nodeChanged(this);
+ return backup;
+ }
+
+ public void restore(Object backupObj)
+ {
+ reset((PlainService)backupObj);
+ getRoot().getTreeModel().nodeChanged(this);
+ }
+
+ private void reset(PlainService from)
+ {
+ _id = from._id;
+ assert _parent == from._parent;
+
+ _adapters = from._adapters;
+ _dbEnvs = from._dbEnvs;
+ _services = from._services;
+ _childListArray = from._childListArray;
+
+ _descriptor = from._descriptor;
+ _resolver = from._resolver;
+ }
+
+ PlainService(Communicator parent,
+ String name,
+ ServiceInstanceDescriptor descriptor,
+ Utils.Resolver resolver)
+ throws UpdateFailedException
+ {
+ super(parent, name);
+ _descriptor = descriptor;
+ _ephemeral = false;
+ _resolver = resolver;
+
+ _adapters.init(_descriptor.descriptor.adapters);
+ _dbEnvs.init(_descriptor.descriptor.dbEnvs);
+ }
+
+ //
+ // New temporary object
+ //
+ PlainService(Communicator parent, ServiceInstanceDescriptor descriptor)
+ {
+ super(parent, descriptor.descriptor.name);
+ _descriptor = descriptor;
+ _ephemeral = true;
+ }
+
+ static java.util.List createAttributes(ServiceDescriptor descriptor)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", descriptor.name));
+ attributes.add(createAttribute("entry", descriptor.entry));
+ return attributes;
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ writer.writeStartTag("service", createAttributes(_descriptor.descriptor));
+
+ if(_descriptor.descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.descriptor.description);
+ }
+
+ writePropertySet(writer, "", _descriptor.descriptor.propertySet,
+ _descriptor.descriptor.adapters);
+ _adapters.write(writer);
+ _dbEnvs.write(writer);
+ writer.writeEndTag("service");
+ }
+ }
+
+ CommunicatorDescriptor getCommunicatorDescriptor()
+ {
+ return _descriptor.descriptor;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ private ServiceInstanceDescriptor _descriptor;
+
+ private final boolean _ephemeral;
+
+ private Utils.Resolver _resolver;
+ private PlainServiceEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/PlainServiceEditor.java b/java/src/IceGridGUI/Application/PlainServiceEditor.java
index b797461d6c9..3aab5e09b7b 100755
--- a/java/src/IceGridGUI/Application/PlainServiceEditor.java
+++ b/java/src/IceGridGUI/Application/PlainServiceEditor.java
@@ -1,90 +1,90 @@
-// **********************************************************************
-//
-// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PlainServiceEditor extends CommunicatorChildEditor
-{
- PlainServiceEditor()
- {
- _subEditor = new ServiceSubEditor(this);
- }
-
- //
- // From Editor:
- //
- Utils.Resolver getDetailResolver()
- {
- PlainService service = (PlainService)_target;
- if(service.getCoordinator().substitute())
- {
- return service.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- _subEditor.appendProperties(builder);
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Service Properties");
- }
-
- protected boolean validate()
- {
- return _subEditor.validate();
- }
-
-
- void writeDescriptor()
- {
- _subEditor.writeDescriptor();
- }
-
- boolean isSimpleUpdate()
- {
- return _subEditor.isSimpleUpdate();
- }
-
- Communicator.ChildList getChildList()
- {
- return ((Communicator)_target.getParent()).getServices();
- }
-
- Object getSubDescriptor()
- {
- ServiceInstanceDescriptor sid = (ServiceInstanceDescriptor)_target.getDescriptor();
- return sid.descriptor;
- }
-
- void show(PlainService service)
- {
- detectUpdates(false);
- _target = service;
-
- _subEditor.show(true);
-
- _applyButton.setEnabled(service.isEphemeral());
- _discardButton.setEnabled(service.isEphemeral());
- detectUpdates(true);
- }
-
- private ServiceSubEditor _subEditor;
-}
+// **********************************************************************
+//
+// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PlainServiceEditor extends CommunicatorChildEditor
+{
+ PlainServiceEditor()
+ {
+ _subEditor = new ServiceSubEditor(this);
+ }
+
+ //
+ // From Editor:
+ //
+ Utils.Resolver getDetailResolver()
+ {
+ PlainService service = (PlainService)_target;
+ if(service.getCoordinator().substitute())
+ {
+ return service.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ _subEditor.appendProperties(builder);
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Service Properties");
+ }
+
+ protected boolean validate()
+ {
+ return _subEditor.validate();
+ }
+
+
+ void writeDescriptor()
+ {
+ _subEditor.writeDescriptor();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return _subEditor.isSimpleUpdate();
+ }
+
+ Communicator.ChildList getChildList()
+ {
+ return ((Communicator)_target.getParent()).getServices();
+ }
+
+ Object getSubDescriptor()
+ {
+ ServiceInstanceDescriptor sid = (ServiceInstanceDescriptor)_target.getDescriptor();
+ return sid.descriptor;
+ }
+
+ void show(PlainService service)
+ {
+ detectUpdates(false);
+ _target = service;
+
+ _subEditor.show(true);
+
+ _applyButton.setEnabled(service.isEphemeral());
+ _discardButton.setEnabled(service.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private ServiceSubEditor _subEditor;
+}
diff --git a/java/src/IceGridGUI/Application/PropertiesField.java b/java/src/IceGridGUI/Application/PropertiesField.java
index 0fe864ac054..0de2e690502 100755
--- a/java/src/IceGridGUI/Application/PropertiesField.java
+++ b/java/src/IceGridGUI/Application/PropertiesField.java
@@ -1,226 +1,226 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-
-//
-// A special field used to show/edit properties
-//
-
-public class PropertiesField extends JTable
-{
- public PropertiesField(Editor editor)
- {
- _columnNames = new java.util.Vector(2);
- _columnNames.add("Name");
- _columnNames.add("Value");
-
- _editor = editor;
-
- Action deleteRow = new AbstractAction("Delete selected row(s)")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(_editable)
- {
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
-
- for(;;)
- {
- int selectedRow = getSelectedRow();
- if(selectedRow == -1)
- {
- break;
- }
- else
- {
- _model.removeRow(selectedRow);
- }
- }
- }
- }
- };
- getActionMap().put("delete", deleteRow);
- getInputMap().put(
- KeyStroke.getKeyStroke("DELETE"), "delete");
-
-
-
-
- }
-
-
- public void setProperties(java.util.List properties,
- java.util.List adapters,
- Utils.Resolver resolver, boolean editable)
- {
- _editable = editable;
-
- //
- // We don't show the .Endpoint and .PublishedEndpoints of adapters,
- // since they already appear in the Adapter pages
- //
- java.util.Set hiddenPropertyNames = new java.util.HashSet();
- _hiddenProperties.clear();
-
- if(adapters != null)
- {
- java.util.Iterator p = adapters.iterator();
- while(p.hasNext())
- {
- AdapterDescriptor ad = (AdapterDescriptor)p.next();
- hiddenPropertyNames.add(ad.name + ".Endpoints");
- hiddenPropertyNames.add(ad.name + ".PublishedEndpoints");
- }
- }
-
- //
- // Transform list into vector of vectors
- //
- java.util.Vector vector = new java.util.Vector(properties.size());
- java.util.Iterator p = properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- if(hiddenPropertyNames.contains(pd.name))
- {
- //
- // We keep them at the top of the list
- //
- if(_editable)
- {
- _hiddenProperties.add(pd);
- }
-
- //
- // We hide only the first occurence
- //
- hiddenPropertyNames.remove(pd.name);
- }
- else
- {
- java.util.Vector row = new java.util.Vector(2);
- row.add(Utils.substitute(pd.name, resolver));
- row.add(Utils.substitute(pd.value, resolver));
- vector.add(row);
- }
- }
-
- if(_editable)
- {
- java.util.Vector newRow = new java.util.Vector(2);
- newRow.add("");
- newRow.add("");
- vector.add(newRow);
- }
-
- _model = new DefaultTableModel(vector, _columnNames)
- {
- public boolean isCellEditable(int row, int column)
- {
- return _editable;
- }
- };
-
- _model.addTableModelListener(new TableModelListener()
- {
- public void tableChanged(TableModelEvent e)
- {
- if(_editable)
- {
- Object lastKey = _model.getValueAt(
- _model.getRowCount() - 1 , 0);
- if(lastKey != null && !lastKey.equals(""))
- {
- _model.addRow(new Object[]{"", ""});
- }
- _editor.updated();
- }
- }
- });
- setModel(_model);
-
- setCellSelectionEnabled(_editable);
- setOpaque(_editable);
- setPreferredScrollableViewportSize(getPreferredSize());
-
- DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
- getDefaultRenderer(String.class);
- cr.setOpaque(_editable);
- }
-
-
- public java.util.LinkedList getProperties()
- {
- assert _editable;
-
- if(isEditing())
- {
- getCellEditor().stopCellEditing();
- }
- java.util.Vector vector = _model.getDataVector();
-
- java.util.LinkedList result = new java.util.LinkedList(_hiddenProperties);
-
- java.util.Iterator p = vector.iterator();
- while(p.hasNext())
- {
- java.util.Vector row = (java.util.Vector)p.next();
-
- //
- // Eliminate rows with null or empty keys
- //
- String key = (String)row.elementAt(0);
- if(key != null)
- {
- key = key.trim();
- if(!key.equals(""))
- {
- String val = (String) row.elementAt(1);
- if(val == null)
- {
- val = "";
- }
-
- result.add(new PropertyDescriptor(key, val));
- }
- }
- }
- return result;
- }
-
- private DefaultTableModel _model;
- private java.util.Vector _columnNames;
- private boolean _editable = false;
-
- private java.util.LinkedList _hiddenProperties = new java.util.LinkedList();
-
- private Editor _editor;
-}
-
-
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+
+
+//
+// A special field used to show/edit properties
+//
+
+public class PropertiesField extends JTable
+{
+ public PropertiesField(Editor editor)
+ {
+ _columnNames = new java.util.Vector(2);
+ _columnNames.add("Name");
+ _columnNames.add("Value");
+
+ _editor = editor;
+
+ Action deleteRow = new AbstractAction("Delete selected row(s)")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if(_editable)
+ {
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+
+ for(;;)
+ {
+ int selectedRow = getSelectedRow();
+ if(selectedRow == -1)
+ {
+ break;
+ }
+ else
+ {
+ _model.removeRow(selectedRow);
+ }
+ }
+ }
+ }
+ };
+ getActionMap().put("delete", deleteRow);
+ getInputMap().put(
+ KeyStroke.getKeyStroke("DELETE"), "delete");
+
+
+
+
+ }
+
+
+ public void setProperties(java.util.List properties,
+ java.util.List adapters,
+ Utils.Resolver resolver, boolean editable)
+ {
+ _editable = editable;
+
+ //
+ // We don't show the .Endpoint and .PublishedEndpoints of adapters,
+ // since they already appear in the Adapter pages
+ //
+ java.util.Set hiddenPropertyNames = new java.util.HashSet();
+ _hiddenProperties.clear();
+
+ if(adapters != null)
+ {
+ java.util.Iterator p = adapters.iterator();
+ while(p.hasNext())
+ {
+ AdapterDescriptor ad = (AdapterDescriptor)p.next();
+ hiddenPropertyNames.add(ad.name + ".Endpoints");
+ hiddenPropertyNames.add(ad.name + ".PublishedEndpoints");
+ }
+ }
+
+ //
+ // Transform list into vector of vectors
+ //
+ java.util.Vector vector = new java.util.Vector(properties.size());
+ java.util.Iterator p = properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ if(hiddenPropertyNames.contains(pd.name))
+ {
+ //
+ // We keep them at the top of the list
+ //
+ if(_editable)
+ {
+ _hiddenProperties.add(pd);
+ }
+
+ //
+ // We hide only the first occurence
+ //
+ hiddenPropertyNames.remove(pd.name);
+ }
+ else
+ {
+ java.util.Vector row = new java.util.Vector(2);
+ row.add(Utils.substitute(pd.name, resolver));
+ row.add(Utils.substitute(pd.value, resolver));
+ vector.add(row);
+ }
+ }
+
+ if(_editable)
+ {
+ java.util.Vector newRow = new java.util.Vector(2);
+ newRow.add("");
+ newRow.add("");
+ vector.add(newRow);
+ }
+
+ _model = new DefaultTableModel(vector, _columnNames)
+ {
+ public boolean isCellEditable(int row, int column)
+ {
+ return _editable;
+ }
+ };
+
+ _model.addTableModelListener(new TableModelListener()
+ {
+ public void tableChanged(TableModelEvent e)
+ {
+ if(_editable)
+ {
+ Object lastKey = _model.getValueAt(
+ _model.getRowCount() - 1 , 0);
+ if(lastKey != null && !lastKey.equals(""))
+ {
+ _model.addRow(new Object[]{"", ""});
+ }
+ _editor.updated();
+ }
+ }
+ });
+ setModel(_model);
+
+ setCellSelectionEnabled(_editable);
+ setOpaque(_editable);
+ setPreferredScrollableViewportSize(getPreferredSize());
+
+ DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
+ getDefaultRenderer(String.class);
+ cr.setOpaque(_editable);
+ }
+
+
+ public java.util.LinkedList getProperties()
+ {
+ assert _editable;
+
+ if(isEditing())
+ {
+ getCellEditor().stopCellEditing();
+ }
+ java.util.Vector vector = _model.getDataVector();
+
+ java.util.LinkedList result = new java.util.LinkedList(_hiddenProperties);
+
+ java.util.Iterator p = vector.iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = (java.util.Vector)p.next();
+
+ //
+ // Eliminate rows with null or empty keys
+ //
+ String key = (String)row.elementAt(0);
+ if(key != null)
+ {
+ key = key.trim();
+ if(!key.equals(""))
+ {
+ String val = (String) row.elementAt(1);
+ if(val == null)
+ {
+ val = "";
+ }
+
+ result.add(new PropertyDescriptor(key, val));
+ }
+ }
+ }
+ return result;
+ }
+
+ private DefaultTableModel _model;
+ private java.util.Vector _columnNames;
+ private boolean _editable = false;
+
+ private java.util.LinkedList _hiddenProperties = new java.util.LinkedList();
+
+ private Editor _editor;
+}
+
+
diff --git a/java/src/IceGridGUI/Application/PropertySet.java b/java/src/IceGridGUI/Application/PropertySet.java
index 30646ea3431..b55d9848532 100755
--- a/java/src/IceGridGUI/Application/PropertySet.java
+++ b/java/src/IceGridGUI/Application/PropertySet.java
@@ -1,179 +1,179 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PropertySet extends TreeNode
-{
- static public PropertySetDescriptor
- copyDescriptor(PropertySetDescriptor d)
- {
- PropertySetDescriptor psd = (PropertySetDescriptor)d.clone();
- psd.properties = new java.util.LinkedList(psd.properties);
- return psd;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(
- Utils.getIcon("/icons/16x16/property_set.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
- actions[DELETE] = true;
-
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
- return actions;
- }
-
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
-
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public void destroy()
- {
- PropertySetParent parent = (PropertySetParent)_parent;
- parent.removePropertySet(this);
-
- if(!_ephemeral)
- {
- parent.removeDescriptor(_id);
- parent.getEditable().removeElement(_id, _editable, PropertySet.class);
- getRoot().updated();
- }
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (PropertySetEditor)getRoot().
- getEditor(PropertySetEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new PropertySetEditor();
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- Object getDescriptor()
- {
- return _descriptor;
- }
-
- Object saveDescriptor()
- {
- return _descriptor.clone();
- }
- void restoreDescriptor(Object savedDescriptor)
- {
- PropertySetDescriptor clone = (PropertySetDescriptor)savedDescriptor;
- _descriptor.references = clone.references;
- _descriptor.properties = clone.properties;
- }
-
- void commit()
- {
- _editable.commit();
- }
-
- Editable getEditable()
- {
- return _editable;
- }
-
- PropertySet(boolean brandNew,
- TreeNode parent,
- String id,
- PropertySetDescriptor descriptor)
- {
- super(parent, id);
- _ephemeral = false;
- _editable = new Editable(brandNew);
- rebuild(descriptor);
- }
-
- PropertySet(TreeNode parent, String id, PropertySetDescriptor descriptor)
- {
- super(parent, id);
- _ephemeral = true;
- _editable = null;
- rebuild(descriptor);
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- writePropertySet(writer, _id, _descriptor, null);
- }
- }
-
- void rebuild(PropertySetDescriptor descriptor)
- {
- _descriptor = descriptor;
- }
-
- private PropertySetDescriptor _descriptor;
- private final boolean _ephemeral;
- private final Editable _editable;
- private PropertySetEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PropertySet extends TreeNode
+{
+ static public PropertySetDescriptor
+ copyDescriptor(PropertySetDescriptor d)
+ {
+ PropertySetDescriptor psd = (PropertySetDescriptor)d.clone();
+ psd.properties = new java.util.LinkedList(psd.properties);
+ return psd;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(
+ Utils.getIcon("/icons/16x16/property_set.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+ actions[DELETE] = true;
+
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+ return actions;
+ }
+
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public void destroy()
+ {
+ PropertySetParent parent = (PropertySetParent)_parent;
+ parent.removePropertySet(this);
+
+ if(!_ephemeral)
+ {
+ parent.removeDescriptor(_id);
+ parent.getEditable().removeElement(_id, _editable, PropertySet.class);
+ getRoot().updated();
+ }
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (PropertySetEditor)getRoot().
+ getEditor(PropertySetEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new PropertySetEditor();
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ Object saveDescriptor()
+ {
+ return _descriptor.clone();
+ }
+ void restoreDescriptor(Object savedDescriptor)
+ {
+ PropertySetDescriptor clone = (PropertySetDescriptor)savedDescriptor;
+ _descriptor.references = clone.references;
+ _descriptor.properties = clone.properties;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ }
+
+ Editable getEditable()
+ {
+ return _editable;
+ }
+
+ PropertySet(boolean brandNew,
+ TreeNode parent,
+ String id,
+ PropertySetDescriptor descriptor)
+ {
+ super(parent, id);
+ _ephemeral = false;
+ _editable = new Editable(brandNew);
+ rebuild(descriptor);
+ }
+
+ PropertySet(TreeNode parent, String id, PropertySetDescriptor descriptor)
+ {
+ super(parent, id);
+ _ephemeral = true;
+ _editable = null;
+ rebuild(descriptor);
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ writePropertySet(writer, _id, _descriptor, null);
+ }
+ }
+
+ void rebuild(PropertySetDescriptor descriptor)
+ {
+ _descriptor = descriptor;
+ }
+
+ private PropertySetDescriptor _descriptor;
+ private final boolean _ephemeral;
+ private final Editable _editable;
+ private PropertySetEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/Application/PropertySetEditor.java b/java/src/IceGridGUI/Application/PropertySetEditor.java
index 63b6fdb0dfd..af61997df74 100755
--- a/java/src/IceGridGUI/Application/PropertySetEditor.java
+++ b/java/src/IceGridGUI/Application/PropertySetEditor.java
@@ -1,219 +1,219 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PropertySetEditor extends Editor
-{
- protected boolean applyUpdate()
- {
- PropertySet nps = (PropertySet)_target;
- Root root = nps.getRoot();
-
- root.disableSelectionListener();
- try
- {
- PropertySetParent parent = (PropertySetParent)nps.getParent();
- if(nps.isEphemeral())
- {
- writeDescriptor();
- PropertySetDescriptor descriptor =
- (PropertySetDescriptor)nps.getDescriptor();
- nps.destroy(); // just removes the child
-
- try
- {
- parent.tryAdd(_id.getText().trim(), descriptor);
- }
- catch(UpdateFailedException e)
- {
- //
- // Add back ephemeral child
- //
- try
- {
- parent.insertPropertySet(nps, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = ((TreeNode)parent).findChildWithDescriptor(descriptor);
- root.updated();
- root.setSelectedNode(_target);
- _id.setEditable(false);
- }
- else
- {
- writeDescriptor();
- root.updated();
- nps.getEditable().markModified();
- }
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-
- Utils.Resolver getDetailResolver()
- {
- Root root = _target.getRoot();
-
- if(root.getCoordinator().substitute())
- {
- return _target.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- PropertySetEditor()
- {
- //
- // Associate updateListener with various fields
- //
- _id.getDocument().addDocumentListener(_updateListener);
- _id.setToolTipText("The id of this Property Set");
-
- _propertySets.getDocument().addDocumentListener(_updateListener);
- _propertySets.setToolTipText("Property Set References");
- _properties = new PropertiesField(this);
- }
-
- void writeDescriptor()
- {
- PropertySetDescriptor descriptor =
- (PropertySetDescriptor)getPropertySet().getDescriptor();
-
- descriptor.references =
- (String[])_propertySets.getList().toArray(new String[0]);
- descriptor.properties = _properties.getProperties();
- }
-
- boolean isSimpleUpdate()
- {
- return true;
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("ID" );
- builder.append(_id, 3);
- builder.nextLine();
-
- builder.append("Property Sets");
- builder.append(_propertySets, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- JScrollPane scrollPane = new JScrollPane(_properties);
- CellConstraints cc = new CellConstraints();
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Named Property Set");
- }
-
- protected boolean validate()
- {
- return check(new String[]{"ID", _id.getText()});
- }
-
- void show(PropertySet nps)
- {
- detectUpdates(false);
- _target = nps;
-
- Utils.Resolver resolver = getDetailResolver();
- boolean isEditable = (resolver == null);
-
- PropertySetDescriptor descriptor =
- (PropertySetDescriptor)nps.getDescriptor();
-
- _id.setText(_target.getId());
- _id.setEditable(_target.isEphemeral());
-
- _propertySets.setList(java.util.Arrays.asList(descriptor.references),
- resolver);
- _propertySets.setEditable(isEditable);
-
- _properties.setProperties(descriptor.properties, null,
- getDetailResolver(), isEditable);
-
- _applyButton.setEnabled(nps.isEphemeral());
- _discardButton.setEnabled(nps.isEphemeral());
- detectUpdates(true);
- }
-
- private PropertySet getPropertySet()
- {
- return (PropertySet)_target;
- }
-
- private JTextField _id = new JTextField(20);
-
- private ListTextField _propertySets = new ListTextField(20);
- private PropertiesField _properties;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PropertySetEditor extends Editor
+{
+ protected boolean applyUpdate()
+ {
+ PropertySet nps = (PropertySet)_target;
+ Root root = nps.getRoot();
+
+ root.disableSelectionListener();
+ try
+ {
+ PropertySetParent parent = (PropertySetParent)nps.getParent();
+ if(nps.isEphemeral())
+ {
+ writeDescriptor();
+ PropertySetDescriptor descriptor =
+ (PropertySetDescriptor)nps.getDescriptor();
+ nps.destroy(); // just removes the child
+
+ try
+ {
+ parent.tryAdd(_id.getText().trim(), descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Add back ephemeral child
+ //
+ try
+ {
+ parent.insertPropertySet(nps, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = ((TreeNode)parent).findChildWithDescriptor(descriptor);
+ root.updated();
+ root.setSelectedNode(_target);
+ _id.setEditable(false);
+ }
+ else
+ {
+ writeDescriptor();
+ root.updated();
+ nps.getEditable().markModified();
+ }
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+
+ Utils.Resolver getDetailResolver()
+ {
+ Root root = _target.getRoot();
+
+ if(root.getCoordinator().substitute())
+ {
+ return _target.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ PropertySetEditor()
+ {
+ //
+ // Associate updateListener with various fields
+ //
+ _id.getDocument().addDocumentListener(_updateListener);
+ _id.setToolTipText("The id of this Property Set");
+
+ _propertySets.getDocument().addDocumentListener(_updateListener);
+ _propertySets.setToolTipText("Property Set References");
+ _properties = new PropertiesField(this);
+ }
+
+ void writeDescriptor()
+ {
+ PropertySetDescriptor descriptor =
+ (PropertySetDescriptor)getPropertySet().getDescriptor();
+
+ descriptor.references =
+ (String[])_propertySets.getList().toArray(new String[0]);
+ descriptor.properties = _properties.getProperties();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return true;
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("ID" );
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ builder.append("Property Sets");
+ builder.append(_propertySets, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ JScrollPane scrollPane = new JScrollPane(_properties);
+ CellConstraints cc = new CellConstraints();
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Named Property Set");
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"ID", _id.getText()});
+ }
+
+ void show(PropertySet nps)
+ {
+ detectUpdates(false);
+ _target = nps;
+
+ Utils.Resolver resolver = getDetailResolver();
+ boolean isEditable = (resolver == null);
+
+ PropertySetDescriptor descriptor =
+ (PropertySetDescriptor)nps.getDescriptor();
+
+ _id.setText(_target.getId());
+ _id.setEditable(_target.isEphemeral());
+
+ _propertySets.setList(java.util.Arrays.asList(descriptor.references),
+ resolver);
+ _propertySets.setEditable(isEditable);
+
+ _properties.setProperties(descriptor.properties, null,
+ getDetailResolver(), isEditable);
+
+ _applyButton.setEnabled(nps.isEphemeral());
+ _discardButton.setEnabled(nps.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private PropertySet getPropertySet()
+ {
+ return (PropertySet)_target;
+ }
+
+ private JTextField _id = new JTextField(20);
+
+ 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 e642f17bafb..eea1e10061b 100755
--- a/java/src/IceGridGUI/Application/PropertySetParent.java
+++ b/java/src/IceGridGUI/Application/PropertySetParent.java
@@ -1,27 +1,27 @@
-// **********************************************************************
-//
-// 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 IceGrid.*;
-import IceGridGUI.*;
-
-interface PropertySetParent
-{
- void tryAdd(String id, PropertySetDescriptor descriptor)
- throws UpdateFailedException;
-
- void insertPropertySet(PropertySet nps, boolean fireEvent)
- throws UpdateFailedException;
-
- void removePropertySet(PropertySet nps);
-
- void removeDescriptor(String id);
-
- Editable getEditable();
-}
+// **********************************************************************
+//
+// 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 IceGrid.*;
+import IceGridGUI.*;
+
+interface PropertySetParent
+{
+ void tryAdd(String id, PropertySetDescriptor descriptor)
+ throws UpdateFailedException;
+
+ void insertPropertySet(PropertySet nps, boolean fireEvent)
+ throws UpdateFailedException;
+
+ void removePropertySet(PropertySet nps);
+
+ void removeDescriptor(String id);
+
+ Editable getEditable();
+}
diff --git a/java/src/IceGridGUI/Application/PropertySets.java b/java/src/IceGridGUI/Application/PropertySets.java
index ade88653f2d..485ce7c1229 100755
--- a/java/src/IceGridGUI/Application/PropertySets.java
+++ b/java/src/IceGridGUI/Application/PropertySets.java
@@ -1,218 +1,218 @@
-// **********************************************************************
-//
-// 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.AbstractListModel;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class PropertySets extends ListTreeNode implements PropertySetParent
-{
- static public java.util.Map
- copyDescriptors(java.util.Map descriptors)
- {
- java.util.Map copy = new java.util.HashMap();
- java.util.Iterator p = descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- copy.put(entry.getKey(),
- PropertySet.copyDescriptor(
- (PropertySetDescriptor)entry.getValue()));
- }
- return copy;
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- Object descriptor = getCoordinator().getClipboard();
- if(descriptor != null)
- {
- actions[PASTE] = descriptor instanceof PropertySetDescriptor;
- }
-
- actions[NEW_PROPERTY_SET] = true;
- return actions;
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_PROPERTY_SET));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public void newPropertySet()
- {
- PropertySetDescriptor descriptor = new
- PropertySetDescriptor(new String[0],
- new java.util.LinkedList());
-
- newPropertySet(descriptor);
- }
-
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
-
- PropertySetDescriptor d = PropertySet.copyDescriptor(
- (PropertySetDescriptor)descriptor);
- newPropertySet(d);
- }
-
-
- PropertySets(TreeNode parent, java.util.Map desc)
- throws UpdateFailedException
- {
- super(false, parent, "Property Sets");
- _descriptors = desc;
-
- java.util.Iterator p = _descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- insertChild(new PropertySet(false, this,
- (String)entry.getKey(),
- (PropertySetDescriptor)entry.getValue()), false);
- }
- }
-
- void update(java.util.Map updates, String[] removePropertySets)
- throws UpdateFailedException
- {
- //
- // Note: _descriptors is updated by Root
- //
-
- //
- // One big set of removes
- //
- removeChildren(removePropertySets);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
-
- java.util.Iterator p = updates.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String id = (String)entry.getKey();
- PropertySetDescriptor psd = (PropertySetDescriptor)entry.getValue();
- PropertySet child = (PropertySet)findChild(id);
- if(child == null)
- {
- newChildren.add(
- new PropertySet(false, this, id, psd));
- }
- else
- {
- child.rebuild(psd);
- }
- }
- insertChildren(newChildren, true);
- }
-
- java.util.Map getUpdates()
- {
- java.util.Map updates = new java.util.HashMap();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- PropertySet ps = (PropertySet)p.next();
- if(ps.getEditable().isNew() || ps.getEditable().isModified())
- {
- updates.put(ps.getId(), ps.getDescriptor());
- }
- }
- return updates;
- }
-
- void commit()
- {
- _editable.commit();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- PropertySet ps = (PropertySet)p.next();
- ps.commit();
- }
- }
-
- Object getDescriptor()
- {
- return _descriptors;
- }
-
- public void tryAdd(String id, PropertySetDescriptor descriptor)
- throws UpdateFailedException
- {
- insertChild(
- new PropertySet(true, this, id, descriptor),
- true);
-
- _descriptors.put(id, descriptor);
- }
-
- public void insertPropertySet(PropertySet nps, boolean fireEvent)
- throws UpdateFailedException
- {
- insertChild(nps, fireEvent);
- }
-
- public void removePropertySet(PropertySet nps)
- {
- removeChild(nps);
- }
-
- public void removeDescriptor(String id)
- {
- _descriptors.remove(id);
- }
-
- public Editable getEditable()
- {
- return super.getEditable();
- }
-
- private void newPropertySet(PropertySetDescriptor descriptor)
- {
- PropertySet propertySet =
- new PropertySet(this, makeNewChildId("PropertySet"), descriptor);
-
- try
- {
- insertChild(propertySet, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(propertySet);
- }
-
- private java.util.Map _descriptors;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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.AbstractListModel;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class PropertySets extends ListTreeNode implements PropertySetParent
+{
+ static public java.util.Map
+ copyDescriptors(java.util.Map descriptors)
+ {
+ java.util.Map copy = new java.util.HashMap();
+ java.util.Iterator p = descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ copy.put(entry.getKey(),
+ PropertySet.copyDescriptor(
+ (PropertySetDescriptor)entry.getValue()));
+ }
+ return copy;
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ Object descriptor = getCoordinator().getClipboard();
+ if(descriptor != null)
+ {
+ actions[PASTE] = descriptor instanceof PropertySetDescriptor;
+ }
+
+ actions[NEW_PROPERTY_SET] = true;
+ return actions;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_PROPERTY_SET));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public void newPropertySet()
+ {
+ PropertySetDescriptor descriptor = new
+ PropertySetDescriptor(new String[0],
+ new java.util.LinkedList());
+
+ newPropertySet(descriptor);
+ }
+
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+
+ PropertySetDescriptor d = PropertySet.copyDescriptor(
+ (PropertySetDescriptor)descriptor);
+ newPropertySet(d);
+ }
+
+
+ PropertySets(TreeNode parent, java.util.Map desc)
+ throws UpdateFailedException
+ {
+ super(false, parent, "Property Sets");
+ _descriptors = desc;
+
+ java.util.Iterator p = _descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ insertChild(new PropertySet(false, this,
+ (String)entry.getKey(),
+ (PropertySetDescriptor)entry.getValue()), false);
+ }
+ }
+
+ void update(java.util.Map updates, String[] removePropertySets)
+ throws UpdateFailedException
+ {
+ //
+ // Note: _descriptors is updated by Root
+ //
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removePropertySets);
+
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+
+ java.util.Iterator p = updates.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ String id = (String)entry.getKey();
+ PropertySetDescriptor psd = (PropertySetDescriptor)entry.getValue();
+ PropertySet child = (PropertySet)findChild(id);
+ if(child == null)
+ {
+ newChildren.add(
+ new PropertySet(false, this, id, psd));
+ }
+ else
+ {
+ child.rebuild(psd);
+ }
+ }
+ insertChildren(newChildren, true);
+ }
+
+ java.util.Map getUpdates()
+ {
+ java.util.Map updates = new java.util.HashMap();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ PropertySet ps = (PropertySet)p.next();
+ if(ps.getEditable().isNew() || ps.getEditable().isModified())
+ {
+ updates.put(ps.getId(), ps.getDescriptor());
+ }
+ }
+ return updates;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ PropertySet ps = (PropertySet)p.next();
+ ps.commit();
+ }
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptors;
+ }
+
+ public void tryAdd(String id, PropertySetDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ insertChild(
+ new PropertySet(true, this, id, descriptor),
+ true);
+
+ _descriptors.put(id, descriptor);
+ }
+
+ public void insertPropertySet(PropertySet nps, boolean fireEvent)
+ throws UpdateFailedException
+ {
+ insertChild(nps, fireEvent);
+ }
+
+ public void removePropertySet(PropertySet nps)
+ {
+ removeChild(nps);
+ }
+
+ public void removeDescriptor(String id)
+ {
+ _descriptors.remove(id);
+ }
+
+ public Editable getEditable()
+ {
+ return super.getEditable();
+ }
+
+ private void newPropertySet(PropertySetDescriptor descriptor)
+ {
+ PropertySet propertySet =
+ new PropertySet(this, makeNewChildId("PropertySet"), descriptor);
+
+ try
+ {
+ insertChild(propertySet, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(propertySet);
+ }
+
+ private java.util.Map _descriptors;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/ReplicaGroup.java b/java/src/IceGridGUI/Application/ReplicaGroup.java
index 555d97c2034..046e5f3e581 100755
--- a/java/src/IceGridGUI/Application/ReplicaGroup.java
+++ b/java/src/IceGridGUI/Application/ReplicaGroup.java
@@ -1,223 +1,223 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ReplicaGroup extends TreeNode
-{
- static public ReplicaGroupDescriptor
- copyDescriptor(ReplicaGroupDescriptor d)
- {
- return (ReplicaGroupDescriptor)d.clone();
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(
- Utils.getIcon("/icons/16x16/replica_group.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
- actions[DELETE] = true;
-
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
- return actions;
- }
-
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
-
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public void destroy()
- {
- ReplicaGroups replicaGroups = (ReplicaGroups)_parent;
- replicaGroups.removeChild(this);
-
- if(!_ephemeral)
- {
- replicaGroups.removeDescriptor(_descriptor);
- replicaGroups.getEditable().
- removeElement(_id, _editable, ReplicaGroup.class);
- getRoot().updated();
- }
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ReplicaGroupEditor)getRoot().getEditor(ReplicaGroupEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ReplicaGroupEditor();
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- Object getDescriptor()
- {
- return _descriptor;
- }
-
- Object saveDescriptor()
- {
- return _descriptor.clone();
- }
- void restoreDescriptor(Object savedDescriptor)
- {
- ReplicaGroupDescriptor clone = (ReplicaGroupDescriptor)savedDescriptor;
- _descriptor.id = clone.id;
- _descriptor.description = clone.description;
- _descriptor.objects = clone.objects;
- _descriptor.loadBalancing = clone.loadBalancing;
- }
-
- void commit()
- {
- _editable.commit();
- }
-
- Editable getEditable()
- {
- return _editable;
- }
-
- ReplicaGroup(boolean brandNew,
- TreeNode parent,
- ReplicaGroupDescriptor descriptor)
- {
- super(parent, descriptor.id);
- _ephemeral = false;
- _editable = new Editable(brandNew);
- rebuild(descriptor);
- }
-
- ReplicaGroup(TreeNode parent, ReplicaGroupDescriptor descriptor)
- {
- super(parent, descriptor.id);
- _ephemeral = true;
- _editable = null;
- rebuild(descriptor);
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("id", _descriptor.id));
-
- if(_descriptor.loadBalancing == null &&
- _descriptor.description.length() == 0 && _descriptor.objects.isEmpty())
- {
- writer.writeElement("replica-group", attributes);
- }
- else
- {
- writer.writeStartTag("replica-group", attributes);
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- if(_descriptor.loadBalancing != null)
- {
- attributes.clear();
- if(_descriptor.loadBalancing instanceof RandomLoadBalancingPolicy)
- {
- attributes.add(createAttribute("type", "random"));
- }
- else if(_descriptor.loadBalancing instanceof RoundRobinLoadBalancingPolicy)
- {
- attributes.add(createAttribute("type", "round-robin"));
- }
- else if(_descriptor.loadBalancing instanceof AdaptiveLoadBalancingPolicy)
- {
- attributes.add(createAttribute("type", "adaptive"));
- AdaptiveLoadBalancingPolicy policy =
- (AdaptiveLoadBalancingPolicy)_descriptor.loadBalancing;
- attributes.add(createAttribute("load-sample", policy.loadSample));
- }
- attributes.add(createAttribute("n-replicas",
- _descriptor.loadBalancing.nReplicas));
- writer.writeElement("load-balancing", attributes);
- }
-
- writeObjects("object", writer, _descriptor.objects);
- writer.writeEndTag("replica-group");
- }
- }
- }
-
-
- void rebuild(ReplicaGroupDescriptor descriptor)
- {
- _descriptor = descriptor;
- //
- // And that's it since there is no children
- //
- }
-
- private ReplicaGroupDescriptor _descriptor;
- private final boolean _ephemeral;
- private final Editable _editable;
- private ReplicaGroupEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ReplicaGroup extends TreeNode
+{
+ static public ReplicaGroupDescriptor
+ copyDescriptor(ReplicaGroupDescriptor d)
+ {
+ return (ReplicaGroupDescriptor)d.clone();
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(
+ Utils.getIcon("/icons/16x16/replica_group.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+ actions[DELETE] = true;
+
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+ return actions;
+ }
+
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public void destroy()
+ {
+ ReplicaGroups replicaGroups = (ReplicaGroups)_parent;
+ replicaGroups.removeChild(this);
+
+ if(!_ephemeral)
+ {
+ replicaGroups.removeDescriptor(_descriptor);
+ replicaGroups.getEditable().
+ removeElement(_id, _editable, ReplicaGroup.class);
+ getRoot().updated();
+ }
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ReplicaGroupEditor)getRoot().getEditor(ReplicaGroupEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ReplicaGroupEditor();
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ Object saveDescriptor()
+ {
+ return _descriptor.clone();
+ }
+ void restoreDescriptor(Object savedDescriptor)
+ {
+ ReplicaGroupDescriptor clone = (ReplicaGroupDescriptor)savedDescriptor;
+ _descriptor.id = clone.id;
+ _descriptor.description = clone.description;
+ _descriptor.objects = clone.objects;
+ _descriptor.loadBalancing = clone.loadBalancing;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ }
+
+ Editable getEditable()
+ {
+ return _editable;
+ }
+
+ ReplicaGroup(boolean brandNew,
+ TreeNode parent,
+ ReplicaGroupDescriptor descriptor)
+ {
+ super(parent, descriptor.id);
+ _ephemeral = false;
+ _editable = new Editable(brandNew);
+ rebuild(descriptor);
+ }
+
+ ReplicaGroup(TreeNode parent, ReplicaGroupDescriptor descriptor)
+ {
+ super(parent, descriptor.id);
+ _ephemeral = true;
+ _editable = null;
+ rebuild(descriptor);
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("id", _descriptor.id));
+
+ if(_descriptor.loadBalancing == null &&
+ _descriptor.description.length() == 0 && _descriptor.objects.isEmpty())
+ {
+ writer.writeElement("replica-group", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("replica-group", attributes);
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ if(_descriptor.loadBalancing != null)
+ {
+ attributes.clear();
+ if(_descriptor.loadBalancing instanceof RandomLoadBalancingPolicy)
+ {
+ attributes.add(createAttribute("type", "random"));
+ }
+ else if(_descriptor.loadBalancing instanceof RoundRobinLoadBalancingPolicy)
+ {
+ attributes.add(createAttribute("type", "round-robin"));
+ }
+ else if(_descriptor.loadBalancing instanceof AdaptiveLoadBalancingPolicy)
+ {
+ attributes.add(createAttribute("type", "adaptive"));
+ AdaptiveLoadBalancingPolicy policy =
+ (AdaptiveLoadBalancingPolicy)_descriptor.loadBalancing;
+ attributes.add(createAttribute("load-sample", policy.loadSample));
+ }
+ attributes.add(createAttribute("n-replicas",
+ _descriptor.loadBalancing.nReplicas));
+ writer.writeElement("load-balancing", attributes);
+ }
+
+ writeObjects("object", writer, _descriptor.objects);
+ writer.writeEndTag("replica-group");
+ }
+ }
+ }
+
+
+ void rebuild(ReplicaGroupDescriptor descriptor)
+ {
+ _descriptor = descriptor;
+ //
+ // And that's it since there is no children
+ //
+ }
+
+ private ReplicaGroupDescriptor _descriptor;
+ private final boolean _ephemeral;
+ private final Editable _editable;
+ private ReplicaGroupEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/Application/ReplicaGroupEditor.java b/java/src/IceGridGUI/Application/ReplicaGroupEditor.java
index b935967c004..7a27b704812 100755
--- a/java/src/IceGridGUI/Application/ReplicaGroupEditor.java
+++ b/java/src/IceGridGUI/Application/ReplicaGroupEditor.java
@@ -1,413 +1,413 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ReplicaGroupEditor extends Editor
-{
- protected boolean applyUpdate()
- {
- ReplicaGroup replicaGroup = (ReplicaGroup)_target;
- Root root = replicaGroup.getRoot();
-
- root.disableSelectionListener();
- try
- {
- if(replicaGroup.isEphemeral())
- {
- ReplicaGroups replicaGroups = (ReplicaGroups)replicaGroup.getParent();
- writeDescriptor();
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
- replicaGroup.destroy(); // just removes the child
-
- try
- {
- replicaGroups.tryAdd(descriptor, true);
- }
- catch(UpdateFailedException e)
- {
- //
- // Add back ephemeral child
- //
- try
- {
- replicaGroups.insertChild(replicaGroup, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- root.setSelectedNode(replicaGroup);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = replicaGroups.findChildWithDescriptor(descriptor);
- root.updated();
- }
- else if(isSimpleUpdate())
- {
- writeDescriptor();
- root.updated();
- replicaGroup.getEditable().markModified();
- }
- else
- {
- //
- // Save to be able to rollback
- //
- Object savedDescriptor = replicaGroup.saveDescriptor();
- ReplicaGroups replicaGroups = (ReplicaGroups)replicaGroup.getParent();
- writeDescriptor();
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
-
- replicaGroups.removeChild(replicaGroup);
- try
- {
- replicaGroups.tryAdd(descriptor, false);
- }
- catch(UpdateFailedException e)
- {
- //
- // Restore all
- //
- try
- {
- replicaGroups.insertChild(replicaGroup, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- replicaGroup.restoreDescriptor(savedDescriptor);
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- root.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
-
- // replaced by brand new ReplicaGroup
- replicaGroups.getEditable().
- removeElement(replicaGroup.getId(),
- replicaGroup.getEditable(), ReplicaGroup.class);
-
- _target = replicaGroups.findChildWithDescriptor(descriptor);
- root.updated();
- root.setSelectedNode(_target);
- }
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-
- Utils.Resolver getDetailResolver()
- {
- Root root = _target.getRoot();
-
- if(root.getCoordinator().substitute())
- {
- return root.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- ReplicaGroupEditor()
- {
- _objects = new MapField(this, "Identity", "Type", true);
-
- //
- // load balancing
- //
- _loadBalancing.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- if(e.getStateChange() == ItemEvent.SELECTED)
- {
- updated();
-
- Object item = e.getItem();
- _nReplicasLabel.setVisible(item != RETURN_ALL);
- _nReplicas.setVisible(item != RETURN_ALL);
-
- _loadSampleLabel.setVisible(item == ADAPTIVE);
- _loadSample.setVisible(item == ADAPTIVE);
- }
- }
- });
- _loadBalancing.setToolTipText(
- "Specifies how IceGrid selects adapters when resolving a replica group ID");
-
- //
- // Associate updateListener with various fields
- //
- _id.getDocument().addDocumentListener(_updateListener);
- _id.setToolTipText("Must be unique within this IceGrid deployment");
-
- _description.getDocument().addDocumentListener(_updateListener);
- _description.setToolTipText(
- "An optional description for this replica group");
-
- _nReplicas.getDocument().addDocumentListener(_updateListener);
- _nReplicas.setToolTipText("<html>IceGrid returns the endpoints of "
- + "up to <i>number</i> adapters<br>"
- + "when resolving a replica group ID</html>");
-
- _loadSample.setEditable(true);
- JTextField loadSampleTextField = (JTextField)
- _loadSample.getEditor().getEditorComponent();
- loadSampleTextField.getDocument().addDocumentListener(_updateListener);
- _loadSample.setToolTipText(
- "Use the load average or CPU usage over the last 1, 5 or 15 minutes?");
-
- }
-
- void writeDescriptor()
- {
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)getReplicaGroup().getDescriptor();
-
- descriptor.id = _id.getText().trim();
- descriptor.description = _description.getText();
- descriptor.objects = AdapterEditor.mapToObjectDescriptorSeq(_objects.get());
-
- Object loadBalancing = _loadBalancing.getSelectedItem();
- if(loadBalancing == RETURN_ALL)
- {
- descriptor.loadBalancing = null;
- }
- else if(loadBalancing == RANDOM)
- {
- descriptor.loadBalancing = new RandomLoadBalancingPolicy(
- _nReplicas.getText().trim());
- }
- else if(loadBalancing == ROUND_ROBIN)
- {
- descriptor.loadBalancing = new RoundRobinLoadBalancingPolicy(
- _nReplicas.getText().trim());
- }
- else if(loadBalancing == ADAPTIVE)
- {
- descriptor.loadBalancing = new AdaptiveLoadBalancingPolicy(
- _nReplicas.getText().trim(),
- _loadSample.getSelectedItem().toString().trim());
- }
- else
- {
- assert false;
- }
- }
-
- boolean isSimpleUpdate()
- {
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)getReplicaGroup().getDescriptor();
- return descriptor.id.equals(_id.getText().trim());
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Replica Group ID");
- builder.append(_id, 3);
- builder.nextLine();
-
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Well-known Objects");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_objects);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Load Balancing Policy");
- builder.append(_loadBalancing, 3);
- builder.nextLine();
- _nReplicasLabel = builder.append("How many Adapters?");
- builder.append(_nReplicas, 3);
- builder.nextLine();
- _loadSampleLabel = builder.append("Load Sample");
- builder.append(_loadSample, 3);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Replica Group Properties");
- }
-
- protected boolean validate()
- {
- return check(new String[]{"Replica Group ID", _id.getText().trim()});
- }
-
-
- void show(ReplicaGroup replicaGroup)
- {
- //
- // Make sure everything is built
- //
- getProperties();
-
- detectUpdates(false);
- _target = replicaGroup;
-
- Utils.Resolver resolver = getDetailResolver();
- boolean isEditable = (resolver == null);
-
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
-
- _id.setText(descriptor.id);
- _id.setEditable(isEditable);
-
- _description.setText(
- Utils.substitute(descriptor.description, resolver));
- _description.setEditable(isEditable);
- _description.setOpaque(isEditable);
-
- _objects.set(AdapterEditor.objectDescriptorSeqToMap(descriptor.objects), resolver, isEditable);
-
- _loadBalancing.setEnabled(true);
-
- if(descriptor.loadBalancing == null)
- {
- _loadBalancing.setSelectedItem(RETURN_ALL);
- _nReplicas.setText("1");
- _loadSample.setSelectedItem("1");
- }
- else if(descriptor.loadBalancing instanceof RandomLoadBalancingPolicy)
- {
- _loadBalancing.setSelectedItem(RANDOM);
- _nReplicas.setText(
- Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
- _loadSample.setSelectedItem("1");
- }
- else if(descriptor.loadBalancing instanceof RoundRobinLoadBalancingPolicy)
- {
- _loadBalancing.setSelectedItem(ROUND_ROBIN);
- _nReplicas.setText(
- Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
- _loadSample.setSelectedItem("1");
- }
- else if(descriptor.loadBalancing instanceof AdaptiveLoadBalancingPolicy)
- {
- _loadBalancing.setSelectedItem(ADAPTIVE);
- _nReplicas.setText(
- Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
-
- _loadSample.setSelectedItem(
- Utils.substitute(
- ((AdaptiveLoadBalancingPolicy)descriptor.loadBalancing).loadSample,
- resolver));
- }
- else
- {
- assert false;
- }
- _nReplicas.setEditable(isEditable);
- _loadSample.setEditable(isEditable);
- _loadBalancing.setEnabled(isEditable);
-
- _applyButton.setEnabled(replicaGroup.isEphemeral());
- _discardButton.setEnabled(replicaGroup.isEphemeral());
- detectUpdates(true);
- }
-
- private ReplicaGroup getReplicaGroup()
- {
- return (ReplicaGroup)_target;
- }
-
- static private String RETURN_ALL = "Return all";
- static private String RANDOM = "Random";
- static private String ROUND_ROBIN = "Round-robin";
- static private String ADAPTIVE = "Adaptive";
-
- private JTextField _id = new JTextField(20);
- private JTextArea _description = new JTextArea(3, 20);
-
- private JComboBox _loadBalancing = new JComboBox(new Object[]
- {ADAPTIVE, RANDOM, RETURN_ALL, ROUND_ROBIN});
-
- private JLabel _nReplicasLabel;
- private JTextField _nReplicas = new JTextField(20);
-
- private JLabel _loadSampleLabel;
- private JComboBox _loadSample = new JComboBox(new Object[]
- {"1", "5", "15"});
-
- private MapField _objects;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ReplicaGroupEditor extends Editor
+{
+ protected boolean applyUpdate()
+ {
+ ReplicaGroup replicaGroup = (ReplicaGroup)_target;
+ Root root = replicaGroup.getRoot();
+
+ root.disableSelectionListener();
+ try
+ {
+ if(replicaGroup.isEphemeral())
+ {
+ ReplicaGroups replicaGroups = (ReplicaGroups)replicaGroup.getParent();
+ writeDescriptor();
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
+ replicaGroup.destroy(); // just removes the child
+
+ try
+ {
+ replicaGroups.tryAdd(descriptor, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Add back ephemeral child
+ //
+ try
+ {
+ replicaGroups.insertChild(replicaGroup, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ root.setSelectedNode(replicaGroup);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = replicaGroups.findChildWithDescriptor(descriptor);
+ root.updated();
+ }
+ else if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ root.updated();
+ replicaGroup.getEditable().markModified();
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ Object savedDescriptor = replicaGroup.saveDescriptor();
+ ReplicaGroups replicaGroups = (ReplicaGroups)replicaGroup.getParent();
+ writeDescriptor();
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
+
+ replicaGroups.removeChild(replicaGroup);
+ try
+ {
+ replicaGroups.tryAdd(descriptor, false);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Restore all
+ //
+ try
+ {
+ replicaGroups.insertChild(replicaGroup, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ replicaGroup.restoreDescriptor(savedDescriptor);
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ root.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+
+ // replaced by brand new ReplicaGroup
+ replicaGroups.getEditable().
+ removeElement(replicaGroup.getId(),
+ replicaGroup.getEditable(), ReplicaGroup.class);
+
+ _target = replicaGroups.findChildWithDescriptor(descriptor);
+ root.updated();
+ root.setSelectedNode(_target);
+ }
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+
+ Utils.Resolver getDetailResolver()
+ {
+ Root root = _target.getRoot();
+
+ if(root.getCoordinator().substitute())
+ {
+ return root.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ReplicaGroupEditor()
+ {
+ _objects = new MapField(this, "Identity", "Type", true);
+
+ //
+ // load balancing
+ //
+ _loadBalancing.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ if(e.getStateChange() == ItemEvent.SELECTED)
+ {
+ updated();
+
+ Object item = e.getItem();
+ _nReplicasLabel.setVisible(item != RETURN_ALL);
+ _nReplicas.setVisible(item != RETURN_ALL);
+
+ _loadSampleLabel.setVisible(item == ADAPTIVE);
+ _loadSample.setVisible(item == ADAPTIVE);
+ }
+ }
+ });
+ _loadBalancing.setToolTipText(
+ "Specifies how IceGrid selects adapters when resolving a replica group ID");
+
+ //
+ // Associate updateListener with various fields
+ //
+ _id.getDocument().addDocumentListener(_updateListener);
+ _id.setToolTipText("Must be unique within this IceGrid deployment");
+
+ _description.getDocument().addDocumentListener(_updateListener);
+ _description.setToolTipText(
+ "An optional description for this replica group");
+
+ _nReplicas.getDocument().addDocumentListener(_updateListener);
+ _nReplicas.setToolTipText("<html>IceGrid returns the endpoints of "
+ + "up to <i>number</i> adapters<br>"
+ + "when resolving a replica group ID</html>");
+
+ _loadSample.setEditable(true);
+ JTextField loadSampleTextField = (JTextField)
+ _loadSample.getEditor().getEditorComponent();
+ loadSampleTextField.getDocument().addDocumentListener(_updateListener);
+ _loadSample.setToolTipText(
+ "Use the load average or CPU usage over the last 1, 5 or 15 minutes?");
+
+ }
+
+ void writeDescriptor()
+ {
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)getReplicaGroup().getDescriptor();
+
+ descriptor.id = _id.getText().trim();
+ descriptor.description = _description.getText();
+ descriptor.objects = AdapterEditor.mapToObjectDescriptorSeq(_objects.get());
+
+ Object loadBalancing = _loadBalancing.getSelectedItem();
+ if(loadBalancing == RETURN_ALL)
+ {
+ descriptor.loadBalancing = null;
+ }
+ else if(loadBalancing == RANDOM)
+ {
+ descriptor.loadBalancing = new RandomLoadBalancingPolicy(
+ _nReplicas.getText().trim());
+ }
+ else if(loadBalancing == ROUND_ROBIN)
+ {
+ descriptor.loadBalancing = new RoundRobinLoadBalancingPolicy(
+ _nReplicas.getText().trim());
+ }
+ else if(loadBalancing == ADAPTIVE)
+ {
+ descriptor.loadBalancing = new AdaptiveLoadBalancingPolicy(
+ _nReplicas.getText().trim(),
+ _loadSample.getSelectedItem().toString().trim());
+ }
+ else
+ {
+ assert false;
+ }
+ }
+
+ boolean isSimpleUpdate()
+ {
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)getReplicaGroup().getDescriptor();
+ return descriptor.id.equals(_id.getText().trim());
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Replica Group ID");
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Well-known Objects");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_objects);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Load Balancing Policy");
+ builder.append(_loadBalancing, 3);
+ builder.nextLine();
+ _nReplicasLabel = builder.append("How many Adapters?");
+ builder.append(_nReplicas, 3);
+ builder.nextLine();
+ _loadSampleLabel = builder.append("Load Sample");
+ builder.append(_loadSample, 3);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Replica Group Properties");
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"Replica Group ID", _id.getText().trim()});
+ }
+
+
+ void show(ReplicaGroup replicaGroup)
+ {
+ //
+ // Make sure everything is built
+ //
+ getProperties();
+
+ detectUpdates(false);
+ _target = replicaGroup;
+
+ Utils.Resolver resolver = getDetailResolver();
+ boolean isEditable = (resolver == null);
+
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)replicaGroup.getDescriptor();
+
+ _id.setText(descriptor.id);
+ _id.setEditable(isEditable);
+
+ _description.setText(
+ Utils.substitute(descriptor.description, resolver));
+ _description.setEditable(isEditable);
+ _description.setOpaque(isEditable);
+
+ _objects.set(AdapterEditor.objectDescriptorSeqToMap(descriptor.objects), resolver, isEditable);
+
+ _loadBalancing.setEnabled(true);
+
+ if(descriptor.loadBalancing == null)
+ {
+ _loadBalancing.setSelectedItem(RETURN_ALL);
+ _nReplicas.setText("1");
+ _loadSample.setSelectedItem("1");
+ }
+ else if(descriptor.loadBalancing instanceof RandomLoadBalancingPolicy)
+ {
+ _loadBalancing.setSelectedItem(RANDOM);
+ _nReplicas.setText(
+ Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
+ _loadSample.setSelectedItem("1");
+ }
+ else if(descriptor.loadBalancing instanceof RoundRobinLoadBalancingPolicy)
+ {
+ _loadBalancing.setSelectedItem(ROUND_ROBIN);
+ _nReplicas.setText(
+ Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
+ _loadSample.setSelectedItem("1");
+ }
+ else if(descriptor.loadBalancing instanceof AdaptiveLoadBalancingPolicy)
+ {
+ _loadBalancing.setSelectedItem(ADAPTIVE);
+ _nReplicas.setText(
+ Utils.substitute(descriptor.loadBalancing.nReplicas, resolver));
+
+ _loadSample.setSelectedItem(
+ Utils.substitute(
+ ((AdaptiveLoadBalancingPolicy)descriptor.loadBalancing).loadSample,
+ resolver));
+ }
+ else
+ {
+ assert false;
+ }
+ _nReplicas.setEditable(isEditable);
+ _loadSample.setEditable(isEditable);
+ _loadBalancing.setEnabled(isEditable);
+
+ _applyButton.setEnabled(replicaGroup.isEphemeral());
+ _discardButton.setEnabled(replicaGroup.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private ReplicaGroup getReplicaGroup()
+ {
+ return (ReplicaGroup)_target;
+ }
+
+ static private String RETURN_ALL = "Return all";
+ static private String RANDOM = "Random";
+ static private String ROUND_ROBIN = "Round-robin";
+ static private String ADAPTIVE = "Adaptive";
+
+ private JTextField _id = new JTextField(20);
+ private JTextArea _description = new JTextArea(3, 20);
+
+ private JComboBox _loadBalancing = new JComboBox(new Object[]
+ {ADAPTIVE, RANDOM, RETURN_ALL, ROUND_ROBIN});
+
+ private JLabel _nReplicasLabel;
+ private JTextField _nReplicas = new JTextField(20);
+
+ private JLabel _loadSampleLabel;
+ private JComboBox _loadSample = new JComboBox(new Object[]
+ {"1", "5", "15"});
+
+ private MapField _objects;
+}
diff --git a/java/src/IceGridGUI/Application/ReplicaGroups.java b/java/src/IceGridGUI/Application/ReplicaGroups.java
index e0aab5a715e..49ecb81e6b1 100755
--- a/java/src/IceGridGUI/Application/ReplicaGroups.java
+++ b/java/src/IceGridGUI/Application/ReplicaGroups.java
@@ -1,234 +1,234 @@
-// **********************************************************************
-//
-// 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.AbstractListModel;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ReplicaGroups extends ListTreeNode
-{
- static public java.util.List
- copyDescriptors(java.util.List descriptors)
- {
- java.util.List copy = new java.util.LinkedList();
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- copy.add(ReplicaGroup.copyDescriptor(
- (ReplicaGroupDescriptor)p.next()));
- }
- return copy;
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- Object descriptor = getCoordinator().getClipboard();
- if(descriptor != null)
- {
- actions[PASTE] = descriptor instanceof ReplicaGroupDescriptor;
- }
-
- actions[NEW_REPLICA_GROUP] = true;
- return actions;
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_REPLICA_GROUP));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public void newReplicaGroup()
- {
- ReplicaGroupDescriptor descriptor = new
- ReplicaGroupDescriptor(
- makeNewChildId("NewReplicaGroup"),
- null,
- new java.util.LinkedList(),
- "");
-
- newReplicaGroup(descriptor);
- }
-
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
-
- ReplicaGroupDescriptor d = ReplicaGroup.copyDescriptor(
- (ReplicaGroupDescriptor)descriptor);
- d.id = makeNewChildId(d.id);
- newReplicaGroup(d);
- }
-
-
- ReplicaGroups(TreeNode parent, java.util.List desc) throws UpdateFailedException
- {
- super(false, parent, "Replica Groups");
- _descriptors = desc;
-
- java.util.Iterator p = _descriptors.iterator();
- while(p.hasNext())
- {
- ReplicaGroupDescriptor descriptor
- = (ReplicaGroupDescriptor)p.next();
-
- insertChild(new ReplicaGroup(false, this, descriptor), false);
- }
- }
-
- java.util.LinkedList getUpdates()
- {
- java.util.LinkedList updates = new java.util.LinkedList();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ReplicaGroup ra = (ReplicaGroup)p.next();
- if(ra.getEditable().isNew() || ra.getEditable().isModified())
- {
- updates.add(ra.getDescriptor());
- }
- }
- return updates;
- }
-
- void commit()
- {
- _editable.commit();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ReplicaGroup rg = (ReplicaGroup)p.next();
- rg.commit();
- }
- }
-
- void update(java.util.List descriptors, String[] removeReplicaGroups)
- {
- _descriptors = descriptors;
-
- //
- // One big set of removes
- //
- removeChildren(removeReplicaGroups);
-
- //
- // Updates and inserts
- //
- java.util.List updatedChildren = new java.util.LinkedList();
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- ReplicaGroupDescriptor descriptor =
- (ReplicaGroupDescriptor)p.next();
-
- ReplicaGroup child
- = (ReplicaGroup)findChild(descriptor.id);
-
- if(child == null)
- {
- try
- {
- insertChild(
- new ReplicaGroup(false, this, descriptor),
- true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- }
- else
- {
- child.rebuild(descriptor);
- updatedChildren.add(child);
- }
- }
- childrenChanged(updatedChildren);
- }
-
- Object getDescriptor()
- {
- return _descriptors;
- }
-
- /*
- Object saveDescriptor()
- {
- assert false;
- return null;
- }
- void restoreDescriptor(Object savedDescriptor)
- {
- assert false;
- }
- */
-
- void removeDescriptor(Object descriptor)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = _descriptors.iterator();
- while(p.hasNext())
- {
- if(descriptor == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
- void tryAdd(ReplicaGroupDescriptor descriptor, boolean addDescriptor)
- throws UpdateFailedException
- {
- insertChild(
- new ReplicaGroup(true, this, descriptor),
- true);
-
- if(addDescriptor)
- {
- _descriptors.add(descriptor);
- }
- }
-
- private void newReplicaGroup(ReplicaGroupDescriptor descriptor)
- {
- ReplicaGroup replicaGroup =
- new ReplicaGroup(this, descriptor);
-
- try
- {
- insertChild(replicaGroup, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(replicaGroup);
- }
-
- private java.util.List _descriptors;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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.AbstractListModel;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ReplicaGroups extends ListTreeNode
+{
+ static public java.util.List
+ copyDescriptors(java.util.List descriptors)
+ {
+ java.util.List copy = new java.util.LinkedList();
+ java.util.Iterator p = descriptors.iterator();
+ while(p.hasNext())
+ {
+ copy.add(ReplicaGroup.copyDescriptor(
+ (ReplicaGroupDescriptor)p.next()));
+ }
+ return copy;
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ Object descriptor = getCoordinator().getClipboard();
+ if(descriptor != null)
+ {
+ actions[PASTE] = descriptor instanceof ReplicaGroupDescriptor;
+ }
+
+ actions[NEW_REPLICA_GROUP] = true;
+ return actions;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_REPLICA_GROUP));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public void newReplicaGroup()
+ {
+ ReplicaGroupDescriptor descriptor = new
+ ReplicaGroupDescriptor(
+ makeNewChildId("NewReplicaGroup"),
+ null,
+ new java.util.LinkedList(),
+ "");
+
+ newReplicaGroup(descriptor);
+ }
+
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+
+ ReplicaGroupDescriptor d = ReplicaGroup.copyDescriptor(
+ (ReplicaGroupDescriptor)descriptor);
+ d.id = makeNewChildId(d.id);
+ newReplicaGroup(d);
+ }
+
+
+ ReplicaGroups(TreeNode parent, java.util.List desc) throws UpdateFailedException
+ {
+ super(false, parent, "Replica Groups");
+ _descriptors = desc;
+
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroupDescriptor descriptor
+ = (ReplicaGroupDescriptor)p.next();
+
+ insertChild(new ReplicaGroup(false, this, descriptor), false);
+ }
+ }
+
+ java.util.LinkedList getUpdates()
+ {
+ java.util.LinkedList updates = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroup ra = (ReplicaGroup)p.next();
+ if(ra.getEditable().isNew() || ra.getEditable().isModified())
+ {
+ updates.add(ra.getDescriptor());
+ }
+ }
+ return updates;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroup rg = (ReplicaGroup)p.next();
+ rg.commit();
+ }
+ }
+
+ void update(java.util.List descriptors, String[] removeReplicaGroups)
+ {
+ _descriptors = descriptors;
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removeReplicaGroups);
+
+ //
+ // Updates and inserts
+ //
+ java.util.List updatedChildren = new java.util.LinkedList();
+ java.util.Iterator p = descriptors.iterator();
+ while(p.hasNext())
+ {
+ ReplicaGroupDescriptor descriptor =
+ (ReplicaGroupDescriptor)p.next();
+
+ ReplicaGroup child
+ = (ReplicaGroup)findChild(descriptor.id);
+
+ if(child == null)
+ {
+ try
+ {
+ insertChild(
+ new ReplicaGroup(false, this, descriptor),
+ true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ }
+ else
+ {
+ child.rebuild(descriptor);
+ updatedChildren.add(child);
+ }
+ }
+ childrenChanged(updatedChildren);
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptors;
+ }
+
+ /*
+ Object saveDescriptor()
+ {
+ assert false;
+ return null;
+ }
+ void restoreDescriptor(Object savedDescriptor)
+ {
+ assert false;
+ }
+ */
+
+ void removeDescriptor(Object descriptor)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = _descriptors.iterator();
+ while(p.hasNext())
+ {
+ if(descriptor == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+ void tryAdd(ReplicaGroupDescriptor descriptor, boolean addDescriptor)
+ throws UpdateFailedException
+ {
+ insertChild(
+ new ReplicaGroup(true, this, descriptor),
+ true);
+
+ if(addDescriptor)
+ {
+ _descriptors.add(descriptor);
+ }
+ }
+
+ private void newReplicaGroup(ReplicaGroupDescriptor descriptor)
+ {
+ ReplicaGroup replicaGroup =
+ new ReplicaGroup(this, descriptor);
+
+ try
+ {
+ insertChild(replicaGroup, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(replicaGroup);
+ }
+
+ private java.util.List _descriptors;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/Root.java b/java/src/IceGridGUI/Application/Root.java
index 47fe70decf0..70f0d8bbf4c 100755
--- a/java/src/IceGridGUI/Application/Root.java
+++ b/java/src/IceGridGUI/Application/Root.java
@@ -1,1250 +1,1250 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import java.awt.Cursor;
-
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-
-import java.io.File;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-public class Root extends ListTreeNode
-{
- //
- // Construct a normal, existing Application
- //
- public Root(Coordinator coordinator, ApplicationDescriptor desc,
- boolean live, File file)
- {
- super(false, null, desc.name);
- _coordinator = coordinator;
- _descriptor = desc;
-
- _file = file;
- _live = live;
-
- try
- {
- init();
- }
- catch(UpdateFailedException e)
- {
- //
- // Impossible
- //
- System.err.println(e.toString());
- assert false;
- }
- }
-
- //
- // Construct a new Application
- //
- public Root(Coordinator coordinator, ApplicationDescriptor desc)
- {
- super(true, null, desc.name);
- _coordinator = coordinator;
- _descriptor = desc;
-
- _file = null;
- _live = false;
-
- try
- {
- init();
- }
- catch(UpdateFailedException e)
- {
- //
- // Impossible
- //
- assert false;
- }
- }
-
-
- private void init() throws UpdateFailedException
- {
- _resolver = new Utils.Resolver(_descriptor.variables);
- _resolver.put("application", _descriptor.name);
-
- _origVariables = _descriptor.variables;
- _origDescription = _descriptor.description;
- _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
-
- _propertySets = new PropertySets(this, _descriptor.propertySets);
- _replicaGroups = new ReplicaGroups(this, _descriptor.replicaGroups);
- _serviceTemplates = new ServiceTemplates(this, _descriptor.serviceTemplates);
- _serverTemplates = new ServerTemplates(this, _descriptor.serverTemplates);
- _nodes = new Nodes(this, _descriptor.nodes);
-
- _children.add(_nodes);
- _children.add(_propertySets);
- _children.add(_replicaGroups);
- _children.add(_serverTemplates);
- _children.add(_serviceTemplates);
-
- _tree = new JTree(this, true);
- _treeModel = (DefaultTreeModel)_tree.getModel();
- }
-
-
- static public ApplicationDescriptor
- copyDescriptor(ApplicationDescriptor ad)
- {
- ApplicationDescriptor copy = (ApplicationDescriptor)ad.clone();
-
- copy.propertySets = PropertySets.copyDescriptors(copy.propertySets);
-
- copy.replicaGroups =
- ReplicaGroups.copyDescriptors(copy.replicaGroups);
-
- copy.serverTemplates =
- ServerTemplates.copyDescriptors(copy.serverTemplates);
-
- copy.serviceTemplates =
- ServiceTemplates.copyDescriptors(copy.serviceTemplates);
-
- copy.nodes = Nodes.copyDescriptors(copy.nodes);
-
- copy.distrib = (DistributionDescriptor)copy.distrib.clone();
- return copy;
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ApplicationEditor)
- getEditor(ApplicationEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ApplicationEditor();
- }
-
- public TreeNode findNodeLike(TreePath path, boolean exactMatch)
- {
- TreeNode result = null;
- if(path == null)
- {
- return null;
- }
-
- for(int i = 0; i < path.getPathCount(); ++i)
- {
- TreeNode node = (TreeNode)path.getPathComponent(i);
-
- if(result == null)
- {
- if(node.getId().equals(_id))
- {
- result = this;
- }
- else
- {
- return null;
- }
- }
- else
- {
- TreeNode newNode = result.findChildLike(node);
- if(newNode == null)
- {
- if(exactMatch)
- {
- return null;
- }
- else
- {
- return result;
- }
- }
- else
- {
- result = newNode;
- }
- }
- }
-
- return result;
- }
-
- //
- // Check that this node is attached to the tree
- //
- public boolean hasNode(TreeNode node)
- {
- while(node != this)
- {
- TreeNode parent = (TreeNode)node.getParent();
- if(parent == null || parent.getIndex(node) == -1)
- {
- return false;
- }
- else
- {
- node = parent;
- }
- }
- return true;
- }
-
- public void setSelectedNode(TreeNode node)
- {
- _tree.setSelectionPath(node.getPath());
- }
-
- public TreeNode getSelectedNode()
- {
- TreePath path = _tree.getSelectionPath();
- if(path == null)
- {
- return null;
- }
- else
- {
- return (TreeNode)path.getLastPathComponent();
- }
- }
-
- public void selectServer(String nodeName, String serverId)
- {
- TreeNode target = _nodes;
- if(target != null)
- {
- Node node = (Node)target.findChild(nodeName);
- if(node != null)
- {
- target = node;
- Server server = node.findServer(serverId);
- if(server != null)
- {
- target = (TreeNode)server;
- }
- }
- setSelectedNode(target);
- }
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setOpenIcon(
- Utils.getIcon("/icons/16x16/application_open.png"));
- _cellRenderer.setClosedIcon(
- Utils.getIcon("/icons/16x16/application_closed.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- actions[COPY] = true;
- actions[DELETE] = true;
-
- Object descriptor = _coordinator.getClipboard();
- if(descriptor != null)
- {
- actions[PASTE] = descriptor instanceof ApplicationDescriptor;
- }
-
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- actions[NEW_NODE] = true;
- actions[NEW_PROPERTY_SET] = true;
- actions[NEW_REPLICA_GROUP] = true;
- actions[NEW_TEMPLATE_SERVER] = true;
- actions[NEW_TEMPLATE_SERVER_ICEBOX] = true;
- actions[NEW_TEMPLATE_SERVICE] = true;
-
- return actions;
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = _coordinator.getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_NODE));
- _popup.add(actions.get(NEW_PROPERTY_SET));
- _popup.add(actions.get(NEW_REPLICA_GROUP));
- _popup.addSeparator();
- _popup.add(actions.get(NEW_TEMPLATE_SERVER));
- _popup.add(actions.get(NEW_TEMPLATE_SERVER_ICEBOX));
- _popup.addSeparator();
- _popup.add(actions.get(NEW_TEMPLATE_SERVICE));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public void copy()
- {
- _coordinator.setClipboard(copyDescriptor(_descriptor));
- _coordinator.getActionsForMenu().get(PASTE).setEnabled(true);
- }
- public void paste()
- {
- _coordinator.pasteApplication();
- }
- public void newNode()
- {
- _nodes.newNode();
- }
- public void newPropertySet()
- {
- _propertySets.newPropertySet();
- }
- public void newReplicaGroup()
- {
- _replicaGroups.newReplicaGroup();
- }
- public void newTemplateServer()
- {
- _serverTemplates.newTemplateServer();
- }
- public void newTemplateServerIceBox()
- {
- _serverTemplates.newTemplateServerIceBox();
- }
- public void newTemplateService()
- {
- _serviceTemplates.newTemplateService();
- }
-
- public void save()
- {
- if(_live)
- {
- saveToRegistry();
- }
- else if(_file != null)
- {
- File file = _coordinator.saveToFile(false, this, _file);
- if(file != null)
- {
- _file = file;
- commit();
- _coordinator.getSaveAction().setEnabled(false);
- _coordinator.getDiscardUpdatesAction().setEnabled(false);
- }
- }
- else
- {
- assert false;
- }
- }
-
- public void saveToRegistry()
- {
- //
- // To be run in GUI thread when exclusive write access is acquired
- //
- Runnable runnable = new Runnable()
- {
- public void run()
- {
- _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try
- {
- if(_live && _canUseUpdateDescriptor)
- {
- ApplicationUpdateDescriptor updateDescriptor = createUpdateDescriptor();
- if(updateDescriptor != null)
- {
- _coordinator.getAdmin().updateApplication(updateDescriptor);
- commit();
- _skipUpdates++;
- }
- }
- else
- {
- //
- // Add or sync application
- //
- if(_coordinator.getLiveDeploymentRoot().getApplicationDescriptor(_id) == null)
- {
- assert _live == false;
- _coordinator.getAdmin().addApplication(_descriptor);
- commit();
- liveReset();
- _coordinator.addLiveApplication(Root.this);
- }
- else
- {
- _coordinator.getAdmin().syncApplication(_descriptor);
- commit();
-
- if(_live)
- {
- liveReset();
- _skipUpdates++;
- }
- else
- {
- //
- // Make this tab live or close it if there is one already open
- //
- ApplicationPane app = _coordinator.getLiveApplication(_id);
- if(app == null)
- {
- liveReset();
- _coordinator.addLiveApplication(Root.this);
- }
- else
- {
- boolean selected = isSelected();
- _coordinator.getMainPane().removeApplication(Root.this);
- if(selected)
- {
- _coordinator.getMainPane().setSelectedComponent(app);
- }
- }
- }
- }
- }
- if(isSelected())
- {
- _coordinator.getSaveAction().setEnabled(false);
- _coordinator.getSaveToRegistryAction().setEnabled(false);
- _coordinator.getDiscardUpdatesAction().setEnabled(false);
- }
- }
- catch(DeploymentException e)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "Application '" + _id + "': "+ e.reason,
- "Deployment Exception",
- JOptionPane.ERROR_MESSAGE);
- }
- catch(ApplicationNotExistException e)
- {
- //
- // Should never happen
- //
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "Application '" + _id + "' was not found in the IceGrid registry",
- "Deployment Exception",
- JOptionPane.ERROR_MESSAGE);
- }
- catch(AccessDeniedException e)
- {
- //
- // Should never happen
- //
- _coordinator.accessDenied(e);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- e.toString(),
- "Communication Exception",
- JOptionPane.ERROR_MESSAGE);
- }
- finally
- {
- _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- _coordinator.releaseExclusiveWriteAccess();
- }
- }
- };
-
- try
- {
- _coordinator.acquireExclusiveWriteAccess(runnable);
- }
- catch(AccessDeniedException e)
- {
- _coordinator.accessDenied(e);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- e.toString(),
- "Communication Exception",
- JOptionPane.ERROR_MESSAGE);
- }
- }
-
- public void saveToFile()
- {
- File file = _coordinator.saveToFile(true, this, _file);
- if(file != null)
- {
- _file = file;
- _live = false;
-
- _coordinator.removeLiveApplication(_id);
- _coordinator.getMainPane().resetIcon(this);
-
- commit();
- _coordinator.getSaveAction().setEnabled(false);
- _coordinator.getDiscardUpdatesAction().setEnabled(false);
- }
- }
-
- public void discardUpdates()
- {
- ApplicationDescriptor desc = null;
-
- if(_live)
- {
- desc = _coordinator.getLiveDeploymentRoot().getApplicationDescriptor(_id);
- assert desc != null;
- desc = IceGridGUI.Application.Root.copyDescriptor(desc);
- }
- else if(_file != null)
- {
- desc = _coordinator.parseFile(_file);
- if(desc == null)
- {
- return;
- }
- }
- else
- {
- assert false;
- }
-
- Root newRoot = new Root(_coordinator, desc, _live, _file);
- ApplicationPane app = _coordinator.getMainPane().findApplication(this);
- assert app != null;
- app.setRoot(newRoot);
-
- TreeNode node = newRoot.findNodeLike(_tree.getSelectionPath(), false);
- if(node == null)
- {
- newRoot.setSelectedNode(newRoot);
- }
- else
- {
- newRoot.setSelectedNode(node);
- }
- _coordinator.getCurrentTab().selected();
- }
-
- private void liveReset()
- {
- _live = true;
- _file = null;
- _coordinator.getMainPane().resetIcon(this);
- }
-
-
- private ApplicationUpdateDescriptor createUpdateDescriptor()
- {
- ApplicationUpdateDescriptor update = new ApplicationUpdateDescriptor();
- update.name = _descriptor.name;
- if(_editable.isModified())
- {
- //
- // Diff description
- //
- if(!_descriptor.description.equals(_origDescription))
- {
- update.description =
- new IceGrid.BoxedString(_descriptor.description);
- }
-
- //
- // Diff variables
- //
- update.variables = new java.util.TreeMap(_descriptor.variables);
- java.util.List removeVariables = new java.util.LinkedList();
-
- java.util.Iterator p = _origVariables.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- Object key = entry.getKey();
- Object newValue = update.variables.get(key);
- if(newValue == null)
- {
- removeVariables.add(key);
- }
- else
- {
- Object value = entry.getValue();
- if(newValue.equals(value))
- {
- update.variables.remove(key);
- }
- }
- }
- update.removeVariables = (String[])removeVariables.toArray(new String[0]);
-
- //
- // Diff distribution
- //
- if(!_descriptor.distrib.equals(_origDistrib))
- {
- update.distrib = new IceGrid.BoxedDistributionDescriptor(
- _descriptor.distrib);
- }
- }
- else
- {
- update.variables = new java.util.TreeMap();
- update.removeVariables = new String[0];
- }
-
- //
- // Property sets
- //
- update.removePropertySets = _propertySets.getEditable().
- removedElements(PropertySet.class);
- update.propertySets = _propertySets.getUpdates();
-
- //
- // Replica Groups
- //
- update.removeReplicaGroups = _replicaGroups.getEditable().
- removedElements(ReplicaGroup.class);
- update.replicaGroups = _replicaGroups.getUpdates();
-
- //
- // Server Templates
- //
- update.removeServerTemplates = _serverTemplates.getEditable().
- removedElements(ServerTemplate.class);
- update.serverTemplates = _serverTemplates.getUpdates();
-
- //
- // Service Templates
- //
- update.removeServiceTemplates = _serviceTemplates.getEditable().
- removedElements(ServiceTemplate.class);
- update.serviceTemplates =_serviceTemplates.getUpdates();
-
- //
- // Nodes
- //
- update.removeNodes = _nodes.getEditable().
- removedElements(Node.class);
- update.nodes = _nodes.getUpdates();
-
-
- //
- // Return null if nothing changed
- //
- if(!_editable.isModified() &&
- update.removePropertySets.length == 0 &&
- update.propertySets.size() == 0 &&
- update.removeReplicaGroups.length == 0 &&
- update.replicaGroups.size() == 0 &&
- update.removeServerTemplates.length == 0 &&
- update.serverTemplates.size() == 0 &&
- update.removeServiceTemplates.length == 0 &&
- update.serviceTemplates.size() == 0 &&
- update.removeNodes.length == 0 &&
- update.nodes.size() == 0)
- {
- return null;
- }
- else
- {
- return update;
- }
- }
-
- private void commit()
- {
- _updated = false;
- _registryUpdatesEnabled = true;
- _canUseUpdateDescriptor = true;
-
- assert _concurrentUpdates.size() == 0;
-
- _editable.commit();
- _origVariables = _descriptor.variables;
- _origDescription = _descriptor.description;
- _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
-
- _nodes.commit();
- _propertySets.commit();
- _replicaGroups.commit();
- _serverTemplates.commit();
- _serviceTemplates.commit();
- }
-
- public boolean isEphemeral()
- {
- return false;
- }
-
- public void destroy()
- {
- if(!_live && _file == null)
- {
- _coordinator.getMainPane().removeApplication(this);
- }
- else if(_live)
- {
- int confirm = JOptionPane.showConfirmDialog(
- _coordinator.getMainFrame(),
- "You are about to remove application '" + _id + "' from the IceGrid registry. "
- + "Do you want to proceed?",
- "Remove Confirmation",
- JOptionPane.YES_NO_OPTION);
-
- if(confirm == JOptionPane.YES_OPTION)
- {
- _coordinator.removeApplicationFromRegistry(_id);
- _discardMe = true;
- }
- }
- else
- {
- assert _file != null;
-
- int confirm = JOptionPane.showConfirmDialog(
- _coordinator.getMainFrame(),
- "You are about to remove application '" + _id + "' and its associated file. "
- + "Do you want to proceed?",
- "Remove Confirmation",
- JOptionPane.YES_NO_OPTION);
-
- if(confirm == JOptionPane.YES_OPTION)
- {
- if(_file.delete())
- {
- _coordinator.getMainPane().removeApplication(this);
- }
- }
- }
- }
-
- public boolean update(ApplicationUpdateDescriptor desc)
- {
- assert _live == true;
-
- if(_skipUpdates > 0)
- {
- _skipUpdates--;
- return false;
- }
-
- if(!_registryUpdatesEnabled)
- {
- if(_updated)
- {
- _canUseUpdateDescriptor = false;
- }
- else
- {
- _concurrentUpdates.add(desc);
- }
- return false;
- }
-
- try
- {
- //
- // Description
- //
- if(desc.description != null)
- {
- _descriptor.description = desc.description.value;
- _origDescription = _descriptor.description;
- }
-
- //
- // Variables
- //
- for(int i = 0; i < desc.removeVariables.length; ++i)
- {
- _descriptor.variables.remove(desc.removeVariables[i]);
- }
- _descriptor.variables.putAll(desc.variables);
-
- //
- // Distrib
- //
- if(desc.distrib != null)
- {
- _descriptor.distrib = desc.distrib.value;
- _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
- }
-
- //
- // Property Sets
- //
- for(int i = 0; i < desc.removePropertySets.length; ++i)
- {
- _descriptor.propertySets.remove(desc.removePropertySets[i]);
- }
- _descriptor.propertySets.putAll(desc.propertySets);
- _propertySets.update(desc.propertySets,
- desc.removePropertySets);
-
- //
- // Replica groups
- //
- for(int i = 0; i < desc.removeReplicaGroups.length; ++i)
- {
- _descriptor.replicaGroups.remove(desc.
- removeReplicaGroups[i]);
- }
- _descriptor.replicaGroups.addAll(desc.replicaGroups);
- _replicaGroups.update(desc.replicaGroups,
- desc.removeReplicaGroups);
-
-
- //
- // Service templates
- //
- for(int i = 0; i < desc.removeServiceTemplates.length; ++i)
- {
- _descriptor.serviceTemplates.remove(desc.
- removeServiceTemplates[i]);
- }
- _descriptor.serviceTemplates.putAll(desc.serviceTemplates);
- _serviceTemplates.update(desc.serviceTemplates,
- desc.removeServiceTemplates);
-
- //
- // Server templates
- //
- for(int i = 0; i < desc.removeServerTemplates.length; ++i)
- {
- _descriptor.serverTemplates.remove(desc.removeServerTemplates[i]);
- }
- _descriptor.serverTemplates.putAll(desc.serverTemplates);
- _serverTemplates.update(desc.serverTemplates,
- desc.removeServerTemplates,
- desc.serviceTemplates.keySet());
-
- //
- // Nodes
- //
- for(int i = 0; i < desc.removeNodes.length; ++i)
- {
- _descriptor.nodes.remove(desc.removeNodes[i]);
- }
-
- //
- // Updates also _descriptor.nodes
- //
- _nodes.update(desc.nodes, desc.removeNodes,
- desc.serverTemplates.keySet(),
- desc.serviceTemplates.keySet());
- }
- catch(UpdateFailedException e)
- {
- //
- // Received invalid update from IceGrid registry: a bug!
- //
- assert false;
- }
-
- return true;
- }
-
- public JTree getTree()
- {
- return _tree;
- }
-
- public DefaultTreeModel getTreeModel()
- {
- return _treeModel;
- }
-
- public Coordinator getCoordinator()
- {
- return _coordinator;
- }
-
- public boolean isSelectionListenerEnabled()
- {
- return _selectionListenerEnabled;
- }
-
- public void enableSelectionListener()
- {
- _selectionListenerEnabled = true;
- }
-
- public void disableSelectionListener()
- {
- _selectionListenerEnabled = false;
- }
-
- public void cancelEdit()
- {
- if(!_updated)
- {
- _registryUpdatesEnabled = true;
-
- //
- // Apply now any delayed concurrent update
- //
- java.util.Iterator p = _concurrentUpdates.iterator();
- while(p.hasNext())
- {
- ApplicationUpdateDescriptor d = (ApplicationUpdateDescriptor)p.next();
- boolean ok = update(d);
- assert ok;
- }
- _concurrentUpdates.clear();
- }
- }
-
- public boolean kill()
- {
- _live = false;
-
- if(_registryUpdatesEnabled || _discardMe)
- {
- return true;
- }
- else
- {
- _coordinator.getMainPane().resetIcon(this);
- _coordinator.getCurrentTab().selected(); // only needed when 'this'
- // corresponds to the current tab
- return false;
- }
- }
-
- public boolean isLive()
- {
- return _live;
- }
-
- public boolean hasFile()
- {
- return _file != null;
- }
-
- public boolean needsSaving()
- {
- return _updated;
- }
-
- Editor getEditor(Class c, TreeNode node)
- {
- Editor result = (Editor)_editorMap.get(c);
- if(result == null)
- {
- result = node.createEditor();
- _editorMap.put(c, result);
- }
- return result;
- }
-
- Object getDescriptor()
- {
- return _descriptor;
- }
-
- ApplicationDescriptor saveDescriptor()
- {
- ApplicationDescriptor clone = (ApplicationDescriptor)_descriptor.clone();
- clone.distrib = (IceGrid.DistributionDescriptor)clone.distrib.clone();
- return clone;
- }
-
- void restoreDescriptor(ApplicationDescriptor clone)
- {
- _descriptor.name = clone.name;
- _descriptor.variables = clone.variables;
- _descriptor.distrib.icepatch = clone.distrib.icepatch;
- _descriptor.distrib.directories = clone.distrib.directories;
- _descriptor.description = clone.description;
- }
-
- public void write(XMLWriter writer) throws java.io.IOException
- {
- writer.writeStartTag("icegrid");
-
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", _id));
-
- writer.writeStartTag("application", attributes);
-
- if(_descriptor.description.length() > 0)
- {
- writer.writeElement("description", _descriptor.description);
- }
- writeVariables(writer, _descriptor.variables);
- writeDistribution(writer, _descriptor.distrib);
-
- _serviceTemplates.write(writer);
- _serverTemplates.write(writer);
- _replicaGroups.write(writer);
- _propertySets.write(writer);
- _nodes.write(writer);
-
- writer.writeEndTag("application");
- writer.writeEndTag("icegrid");
- }
-
- //
- // Methods called by editors; see also cancelEdit() above
- //
- void disableRegistryUpdates()
- {
- _registryUpdatesEnabled = false;
- }
-
- void updated()
- {
- _updated = true;
- _registryUpdatesEnabled = false; // can be true before that when updated() is called by destroy()
-
- _concurrentUpdates.clear();
-
- _coordinator.getSaveAction().setEnabled(_live || _file != null);
- _coordinator.getDiscardUpdatesAction().setEnabled(_live || _file != null);
-
- _coordinator.getSaveToRegistryAction().setEnabled(_coordinator.getSession() != null);
- _coordinator.getSaveToFileAction().setEnabled(true);
- }
-
-
- void rebuild() throws UpdateFailedException
- {
- Utils.Resolver oldResolver = _resolver;
- String oldId = _id;
- _id = _descriptor.name;
- _resolver = new Utils.Resolver(_descriptor.variables);
- _resolver.put("application", _id);
-
- try
- {
- _nodes.rebuild();
- }
- catch(UpdateFailedException e)
- {
- _id = oldId;
- _resolver = oldResolver;
- throw e;
- }
- }
-
- //
- // Called when a server-template is deleted, to remove all
- // corresponding instances.
- //
- void removeServerInstances(String templateId)
- {
- _nodes.removeServerInstances(templateId);
- }
-
- //
- // Called when a service-template is deleted, to remove all
- // corresponding instances
- //
- void removeServiceInstances(String templateId)
- {
- _nodes.removeServiceInstances(templateId);
- _serverTemplates.removeServiceInstances(templateId);
- }
-
-
- ServerTemplate findServerTemplate(String id)
- {
- return (ServerTemplate)_serverTemplates.findChild(id);
- }
-
- ServiceTemplate findServiceTemplate(String id)
- {
- return (ServiceTemplate)_serviceTemplates.findChild(id);
- }
-
- ReplicaGroup findReplicaGroup(String id)
- {
- return (ReplicaGroup)_replicaGroups.findChild(id);
- }
-
- Node findNode(String id)
- {
- return (Node)_nodes.findChild(id);
- }
-
- java.util.List findServerInstances(String template)
- {
- return _nodes.findServerInstances(template);
- }
-
- java.util.List findServiceInstances(String template)
- {
- java.util.List result = _serverTemplates.findServiceInstances(template);
- result.addAll(_nodes.findServiceInstances(template));
- return result;
- }
-
- TemplateDescriptor findServerTemplateDescriptor(String templateName)
- {
- return (TemplateDescriptor)
- _descriptor.serverTemplates.get(templateName);
- }
-
- TemplateDescriptor findServiceTemplateDescriptor(String templateName)
- {
- return (TemplateDescriptor)
- _descriptor.serviceTemplates.get(templateName);
- }
-
- ServerTemplates getServerTemplates()
- {
- return _serverTemplates;
- }
-
- ServiceTemplates getServiceTemplates()
- {
- return _serviceTemplates;
- }
-
- ReplicaGroups getReplicaGroups()
- {
- return _replicaGroups;
- }
-
- Root getRoot()
- {
- return this;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- //
- // Should only be used for reading
- //
- java.util.Map getVariables()
- {
- return _descriptor.variables;
- }
-
- private boolean isSelected()
- {
- if(_coordinator.getCurrentTab() instanceof ApplicationPane)
- {
- return ((ApplicationPane)_coordinator.getCurrentTab()).getRoot() == Root.this;
- }
- else
- {
- return false;
- }
- }
-
- private Coordinator _coordinator;
-
- //
- // 'this' is the root of the tree
- //
- private JTree _tree;
- private DefaultTreeModel _treeModel;
- private Utils.Resolver _resolver;
-
- private boolean _live;
-
- //
- // null when this application is not tied to a file
- //
- private File _file;
-
- private ApplicationDescriptor _descriptor;
-
- //
- // Keeps original version (as shallow copies) to be able to build
- // ApplicationUpdateDescriptor. Only used when _live == true
- //
- private java.util.Map _origVariables;
- private String _origDescription;
- private DistributionDescriptor _origDistrib;
-
- //
- // When this application (and children) is being updated, we
- // no longer apply updates from the registry. Only meaningful when
- // _live == true
- //
- private boolean _registryUpdatesEnabled = true;
-
- private boolean _discardMe = false;
-
- //
- // True when any update was applies to this application
- // (including children)
- //
- private boolean _updated = false;
-
- //
- // Updates saved when _updated == false and
- // _registryUpdatesEnabled == false
- //
- private java.util.List _concurrentUpdates = new java.util.LinkedList();
-
- //
- // When _live is true and _canUseUpdateDescriptor is true, we can
- // save the updates using an ApplicationUpdateDescriptor
- //
- private boolean _canUseUpdateDescriptor = true;
- //
- // Updates to skip (because already applied locally)
- //
- private int _skipUpdates = 0;
-
-
- private Nodes _nodes;
- private PropertySets _propertySets;
- private ReplicaGroups _replicaGroups;
- private ServerTemplates _serverTemplates;
- private ServiceTemplates _serviceTemplates;
-
- private boolean _selectionListenerEnabled = true;
-
- private ApplicationEditor _editor;
-
- //
- // Map editor-class to Editor object
- //
- private java.util.Map _editorMap = new java.util.HashMap();
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import java.awt.Cursor;
+
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+import java.io.File;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+public class Root extends ListTreeNode
+{
+ //
+ // Construct a normal, existing Application
+ //
+ public Root(Coordinator coordinator, ApplicationDescriptor desc,
+ boolean live, File file)
+ {
+ super(false, null, desc.name);
+ _coordinator = coordinator;
+ _descriptor = desc;
+
+ _file = file;
+ _live = live;
+
+ try
+ {
+ init();
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Impossible
+ //
+ System.err.println(e.toString());
+ assert false;
+ }
+ }
+
+ //
+ // Construct a new Application
+ //
+ public Root(Coordinator coordinator, ApplicationDescriptor desc)
+ {
+ super(true, null, desc.name);
+ _coordinator = coordinator;
+ _descriptor = desc;
+
+ _file = null;
+ _live = false;
+
+ try
+ {
+ init();
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Impossible
+ //
+ assert false;
+ }
+ }
+
+
+ private void init() throws UpdateFailedException
+ {
+ _resolver = new Utils.Resolver(_descriptor.variables);
+ _resolver.put("application", _descriptor.name);
+
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
+ _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
+
+ _propertySets = new PropertySets(this, _descriptor.propertySets);
+ _replicaGroups = new ReplicaGroups(this, _descriptor.replicaGroups);
+ _serviceTemplates = new ServiceTemplates(this, _descriptor.serviceTemplates);
+ _serverTemplates = new ServerTemplates(this, _descriptor.serverTemplates);
+ _nodes = new Nodes(this, _descriptor.nodes);
+
+ _children.add(_nodes);
+ _children.add(_propertySets);
+ _children.add(_replicaGroups);
+ _children.add(_serverTemplates);
+ _children.add(_serviceTemplates);
+
+ _tree = new JTree(this, true);
+ _treeModel = (DefaultTreeModel)_tree.getModel();
+ }
+
+
+ static public ApplicationDescriptor
+ copyDescriptor(ApplicationDescriptor ad)
+ {
+ ApplicationDescriptor copy = (ApplicationDescriptor)ad.clone();
+
+ copy.propertySets = PropertySets.copyDescriptors(copy.propertySets);
+
+ copy.replicaGroups =
+ ReplicaGroups.copyDescriptors(copy.replicaGroups);
+
+ copy.serverTemplates =
+ ServerTemplates.copyDescriptors(copy.serverTemplates);
+
+ copy.serviceTemplates =
+ ServiceTemplates.copyDescriptors(copy.serviceTemplates);
+
+ copy.nodes = Nodes.copyDescriptors(copy.nodes);
+
+ copy.distrib = (DistributionDescriptor)copy.distrib.clone();
+ return copy;
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ApplicationEditor)
+ getEditor(ApplicationEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ApplicationEditor();
+ }
+
+ public TreeNode findNodeLike(TreePath path, boolean exactMatch)
+ {
+ TreeNode result = null;
+ if(path == null)
+ {
+ return null;
+ }
+
+ for(int i = 0; i < path.getPathCount(); ++i)
+ {
+ TreeNode node = (TreeNode)path.getPathComponent(i);
+
+ if(result == null)
+ {
+ if(node.getId().equals(_id))
+ {
+ result = this;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ TreeNode newNode = result.findChildLike(node);
+ if(newNode == null)
+ {
+ if(exactMatch)
+ {
+ return null;
+ }
+ else
+ {
+ return result;
+ }
+ }
+ else
+ {
+ result = newNode;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ //
+ // Check that this node is attached to the tree
+ //
+ public boolean hasNode(TreeNode node)
+ {
+ while(node != this)
+ {
+ TreeNode parent = (TreeNode)node.getParent();
+ if(parent == null || parent.getIndex(node) == -1)
+ {
+ return false;
+ }
+ else
+ {
+ node = parent;
+ }
+ }
+ return true;
+ }
+
+ public void setSelectedNode(TreeNode node)
+ {
+ _tree.setSelectionPath(node.getPath());
+ }
+
+ public TreeNode getSelectedNode()
+ {
+ TreePath path = _tree.getSelectionPath();
+ if(path == null)
+ {
+ return null;
+ }
+ else
+ {
+ return (TreeNode)path.getLastPathComponent();
+ }
+ }
+
+ public void selectServer(String nodeName, String serverId)
+ {
+ TreeNode target = _nodes;
+ if(target != null)
+ {
+ Node node = (Node)target.findChild(nodeName);
+ if(node != null)
+ {
+ target = node;
+ Server server = node.findServer(serverId);
+ if(server != null)
+ {
+ target = (TreeNode)server;
+ }
+ }
+ setSelectedNode(target);
+ }
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setOpenIcon(
+ Utils.getIcon("/icons/16x16/application_open.png"));
+ _cellRenderer.setClosedIcon(
+ Utils.getIcon("/icons/16x16/application_closed.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ actions[COPY] = true;
+ actions[DELETE] = true;
+
+ Object descriptor = _coordinator.getClipboard();
+ if(descriptor != null)
+ {
+ actions[PASTE] = descriptor instanceof ApplicationDescriptor;
+ }
+
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ actions[NEW_NODE] = true;
+ actions[NEW_PROPERTY_SET] = true;
+ actions[NEW_REPLICA_GROUP] = true;
+ actions[NEW_TEMPLATE_SERVER] = true;
+ actions[NEW_TEMPLATE_SERVER_ICEBOX] = true;
+ actions[NEW_TEMPLATE_SERVICE] = true;
+
+ return actions;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = _coordinator.getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_NODE));
+ _popup.add(actions.get(NEW_PROPERTY_SET));
+ _popup.add(actions.get(NEW_REPLICA_GROUP));
+ _popup.addSeparator();
+ _popup.add(actions.get(NEW_TEMPLATE_SERVER));
+ _popup.add(actions.get(NEW_TEMPLATE_SERVER_ICEBOX));
+ _popup.addSeparator();
+ _popup.add(actions.get(NEW_TEMPLATE_SERVICE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public void copy()
+ {
+ _coordinator.setClipboard(copyDescriptor(_descriptor));
+ _coordinator.getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ public void paste()
+ {
+ _coordinator.pasteApplication();
+ }
+ public void newNode()
+ {
+ _nodes.newNode();
+ }
+ public void newPropertySet()
+ {
+ _propertySets.newPropertySet();
+ }
+ public void newReplicaGroup()
+ {
+ _replicaGroups.newReplicaGroup();
+ }
+ public void newTemplateServer()
+ {
+ _serverTemplates.newTemplateServer();
+ }
+ public void newTemplateServerIceBox()
+ {
+ _serverTemplates.newTemplateServerIceBox();
+ }
+ public void newTemplateService()
+ {
+ _serviceTemplates.newTemplateService();
+ }
+
+ public void save()
+ {
+ if(_live)
+ {
+ saveToRegistry();
+ }
+ else if(_file != null)
+ {
+ File file = _coordinator.saveToFile(false, this, _file);
+ if(file != null)
+ {
+ _file = file;
+ commit();
+ _coordinator.getSaveAction().setEnabled(false);
+ _coordinator.getDiscardUpdatesAction().setEnabled(false);
+ }
+ }
+ else
+ {
+ assert false;
+ }
+ }
+
+ public void saveToRegistry()
+ {
+ //
+ // To be run in GUI thread when exclusive write access is acquired
+ //
+ Runnable runnable = new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try
+ {
+ if(_live && _canUseUpdateDescriptor)
+ {
+ ApplicationUpdateDescriptor updateDescriptor = createUpdateDescriptor();
+ if(updateDescriptor != null)
+ {
+ _coordinator.getAdmin().updateApplication(updateDescriptor);
+ commit();
+ _skipUpdates++;
+ }
+ }
+ else
+ {
+ //
+ // Add or sync application
+ //
+ if(_coordinator.getLiveDeploymentRoot().getApplicationDescriptor(_id) == null)
+ {
+ assert _live == false;
+ _coordinator.getAdmin().addApplication(_descriptor);
+ commit();
+ liveReset();
+ _coordinator.addLiveApplication(Root.this);
+ }
+ else
+ {
+ _coordinator.getAdmin().syncApplication(_descriptor);
+ commit();
+
+ if(_live)
+ {
+ liveReset();
+ _skipUpdates++;
+ }
+ else
+ {
+ //
+ // Make this tab live or close it if there is one already open
+ //
+ ApplicationPane app = _coordinator.getLiveApplication(_id);
+ if(app == null)
+ {
+ liveReset();
+ _coordinator.addLiveApplication(Root.this);
+ }
+ else
+ {
+ boolean selected = isSelected();
+ _coordinator.getMainPane().removeApplication(Root.this);
+ if(selected)
+ {
+ _coordinator.getMainPane().setSelectedComponent(app);
+ }
+ }
+ }
+ }
+ }
+ if(isSelected())
+ {
+ _coordinator.getSaveAction().setEnabled(false);
+ _coordinator.getSaveToRegistryAction().setEnabled(false);
+ _coordinator.getDiscardUpdatesAction().setEnabled(false);
+ }
+ }
+ catch(DeploymentException e)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "Application '" + _id + "': "+ e.reason,
+ "Deployment Exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ catch(ApplicationNotExistException e)
+ {
+ //
+ // Should never happen
+ //
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "Application '" + _id + "' was not found in the IceGrid registry",
+ "Deployment Exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ catch(AccessDeniedException e)
+ {
+ //
+ // Should never happen
+ //
+ _coordinator.accessDenied(e);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ e.toString(),
+ "Communication Exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ finally
+ {
+ _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ _coordinator.releaseExclusiveWriteAccess();
+ }
+ }
+ };
+
+ try
+ {
+ _coordinator.acquireExclusiveWriteAccess(runnable);
+ }
+ catch(AccessDeniedException e)
+ {
+ _coordinator.accessDenied(e);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ e.toString(),
+ "Communication Exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ public void saveToFile()
+ {
+ File file = _coordinator.saveToFile(true, this, _file);
+ if(file != null)
+ {
+ _file = file;
+ _live = false;
+
+ _coordinator.removeLiveApplication(_id);
+ _coordinator.getMainPane().resetIcon(this);
+
+ commit();
+ _coordinator.getSaveAction().setEnabled(false);
+ _coordinator.getDiscardUpdatesAction().setEnabled(false);
+ }
+ }
+
+ public void discardUpdates()
+ {
+ ApplicationDescriptor desc = null;
+
+ if(_live)
+ {
+ desc = _coordinator.getLiveDeploymentRoot().getApplicationDescriptor(_id);
+ assert desc != null;
+ desc = IceGridGUI.Application.Root.copyDescriptor(desc);
+ }
+ else if(_file != null)
+ {
+ desc = _coordinator.parseFile(_file);
+ if(desc == null)
+ {
+ return;
+ }
+ }
+ else
+ {
+ assert false;
+ }
+
+ Root newRoot = new Root(_coordinator, desc, _live, _file);
+ ApplicationPane app = _coordinator.getMainPane().findApplication(this);
+ assert app != null;
+ app.setRoot(newRoot);
+
+ TreeNode node = newRoot.findNodeLike(_tree.getSelectionPath(), false);
+ if(node == null)
+ {
+ newRoot.setSelectedNode(newRoot);
+ }
+ else
+ {
+ newRoot.setSelectedNode(node);
+ }
+ _coordinator.getCurrentTab().selected();
+ }
+
+ private void liveReset()
+ {
+ _live = true;
+ _file = null;
+ _coordinator.getMainPane().resetIcon(this);
+ }
+
+
+ private ApplicationUpdateDescriptor createUpdateDescriptor()
+ {
+ ApplicationUpdateDescriptor update = new ApplicationUpdateDescriptor();
+ update.name = _descriptor.name;
+ if(_editable.isModified())
+ {
+ //
+ // Diff description
+ //
+ if(!_descriptor.description.equals(_origDescription))
+ {
+ update.description =
+ new IceGrid.BoxedString(_descriptor.description);
+ }
+
+ //
+ // Diff variables
+ //
+ update.variables = new java.util.TreeMap(_descriptor.variables);
+ java.util.List removeVariables = new java.util.LinkedList();
+
+ java.util.Iterator p = _origVariables.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ Object key = entry.getKey();
+ Object newValue = update.variables.get(key);
+ if(newValue == null)
+ {
+ removeVariables.add(key);
+ }
+ else
+ {
+ Object value = entry.getValue();
+ if(newValue.equals(value))
+ {
+ update.variables.remove(key);
+ }
+ }
+ }
+ update.removeVariables = (String[])removeVariables.toArray(new String[0]);
+
+ //
+ // Diff distribution
+ //
+ if(!_descriptor.distrib.equals(_origDistrib))
+ {
+ update.distrib = new IceGrid.BoxedDistributionDescriptor(
+ _descriptor.distrib);
+ }
+ }
+ else
+ {
+ update.variables = new java.util.TreeMap();
+ update.removeVariables = new String[0];
+ }
+
+ //
+ // Property sets
+ //
+ update.removePropertySets = _propertySets.getEditable().
+ removedElements(PropertySet.class);
+ update.propertySets = _propertySets.getUpdates();
+
+ //
+ // Replica Groups
+ //
+ update.removeReplicaGroups = _replicaGroups.getEditable().
+ removedElements(ReplicaGroup.class);
+ update.replicaGroups = _replicaGroups.getUpdates();
+
+ //
+ // Server Templates
+ //
+ update.removeServerTemplates = _serverTemplates.getEditable().
+ removedElements(ServerTemplate.class);
+ update.serverTemplates = _serverTemplates.getUpdates();
+
+ //
+ // Service Templates
+ //
+ update.removeServiceTemplates = _serviceTemplates.getEditable().
+ removedElements(ServiceTemplate.class);
+ update.serviceTemplates =_serviceTemplates.getUpdates();
+
+ //
+ // Nodes
+ //
+ update.removeNodes = _nodes.getEditable().
+ removedElements(Node.class);
+ update.nodes = _nodes.getUpdates();
+
+
+ //
+ // Return null if nothing changed
+ //
+ if(!_editable.isModified() &&
+ update.removePropertySets.length == 0 &&
+ update.propertySets.size() == 0 &&
+ update.removeReplicaGroups.length == 0 &&
+ update.replicaGroups.size() == 0 &&
+ update.removeServerTemplates.length == 0 &&
+ update.serverTemplates.size() == 0 &&
+ update.removeServiceTemplates.length == 0 &&
+ update.serviceTemplates.size() == 0 &&
+ update.removeNodes.length == 0 &&
+ update.nodes.size() == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return update;
+ }
+ }
+
+ private void commit()
+ {
+ _updated = false;
+ _registryUpdatesEnabled = true;
+ _canUseUpdateDescriptor = true;
+
+ assert _concurrentUpdates.size() == 0;
+
+ _editable.commit();
+ _origVariables = _descriptor.variables;
+ _origDescription = _descriptor.description;
+ _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
+
+ _nodes.commit();
+ _propertySets.commit();
+ _replicaGroups.commit();
+ _serverTemplates.commit();
+ _serviceTemplates.commit();
+ }
+
+ public boolean isEphemeral()
+ {
+ return false;
+ }
+
+ public void destroy()
+ {
+ if(!_live && _file == null)
+ {
+ _coordinator.getMainPane().removeApplication(this);
+ }
+ else if(_live)
+ {
+ int confirm = JOptionPane.showConfirmDialog(
+ _coordinator.getMainFrame(),
+ "You are about to remove application '" + _id + "' from the IceGrid registry. "
+ + "Do you want to proceed?",
+ "Remove Confirmation",
+ JOptionPane.YES_NO_OPTION);
+
+ if(confirm == JOptionPane.YES_OPTION)
+ {
+ _coordinator.removeApplicationFromRegistry(_id);
+ _discardMe = true;
+ }
+ }
+ else
+ {
+ assert _file != null;
+
+ int confirm = JOptionPane.showConfirmDialog(
+ _coordinator.getMainFrame(),
+ "You are about to remove application '" + _id + "' and its associated file. "
+ + "Do you want to proceed?",
+ "Remove Confirmation",
+ JOptionPane.YES_NO_OPTION);
+
+ if(confirm == JOptionPane.YES_OPTION)
+ {
+ if(_file.delete())
+ {
+ _coordinator.getMainPane().removeApplication(this);
+ }
+ }
+ }
+ }
+
+ public boolean update(ApplicationUpdateDescriptor desc)
+ {
+ assert _live == true;
+
+ if(_skipUpdates > 0)
+ {
+ _skipUpdates--;
+ return false;
+ }
+
+ if(!_registryUpdatesEnabled)
+ {
+ if(_updated)
+ {
+ _canUseUpdateDescriptor = false;
+ }
+ else
+ {
+ _concurrentUpdates.add(desc);
+ }
+ return false;
+ }
+
+ try
+ {
+ //
+ // Description
+ //
+ if(desc.description != null)
+ {
+ _descriptor.description = desc.description.value;
+ _origDescription = _descriptor.description;
+ }
+
+ //
+ // Variables
+ //
+ for(int i = 0; i < desc.removeVariables.length; ++i)
+ {
+ _descriptor.variables.remove(desc.removeVariables[i]);
+ }
+ _descriptor.variables.putAll(desc.variables);
+
+ //
+ // Distrib
+ //
+ if(desc.distrib != null)
+ {
+ _descriptor.distrib = desc.distrib.value;
+ _origDistrib = (DistributionDescriptor)_descriptor.distrib.clone();
+ }
+
+ //
+ // Property Sets
+ //
+ for(int i = 0; i < desc.removePropertySets.length; ++i)
+ {
+ _descriptor.propertySets.remove(desc.removePropertySets[i]);
+ }
+ _descriptor.propertySets.putAll(desc.propertySets);
+ _propertySets.update(desc.propertySets,
+ desc.removePropertySets);
+
+ //
+ // Replica groups
+ //
+ for(int i = 0; i < desc.removeReplicaGroups.length; ++i)
+ {
+ _descriptor.replicaGroups.remove(desc.
+ removeReplicaGroups[i]);
+ }
+ _descriptor.replicaGroups.addAll(desc.replicaGroups);
+ _replicaGroups.update(desc.replicaGroups,
+ desc.removeReplicaGroups);
+
+
+ //
+ // Service templates
+ //
+ for(int i = 0; i < desc.removeServiceTemplates.length; ++i)
+ {
+ _descriptor.serviceTemplates.remove(desc.
+ removeServiceTemplates[i]);
+ }
+ _descriptor.serviceTemplates.putAll(desc.serviceTemplates);
+ _serviceTemplates.update(desc.serviceTemplates,
+ desc.removeServiceTemplates);
+
+ //
+ // Server templates
+ //
+ for(int i = 0; i < desc.removeServerTemplates.length; ++i)
+ {
+ _descriptor.serverTemplates.remove(desc.removeServerTemplates[i]);
+ }
+ _descriptor.serverTemplates.putAll(desc.serverTemplates);
+ _serverTemplates.update(desc.serverTemplates,
+ desc.removeServerTemplates,
+ desc.serviceTemplates.keySet());
+
+ //
+ // Nodes
+ //
+ for(int i = 0; i < desc.removeNodes.length; ++i)
+ {
+ _descriptor.nodes.remove(desc.removeNodes[i]);
+ }
+
+ //
+ // Updates also _descriptor.nodes
+ //
+ _nodes.update(desc.nodes, desc.removeNodes,
+ desc.serverTemplates.keySet(),
+ desc.serviceTemplates.keySet());
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Received invalid update from IceGrid registry: a bug!
+ //
+ assert false;
+ }
+
+ return true;
+ }
+
+ public JTree getTree()
+ {
+ return _tree;
+ }
+
+ public DefaultTreeModel getTreeModel()
+ {
+ return _treeModel;
+ }
+
+ public Coordinator getCoordinator()
+ {
+ return _coordinator;
+ }
+
+ public boolean isSelectionListenerEnabled()
+ {
+ return _selectionListenerEnabled;
+ }
+
+ public void enableSelectionListener()
+ {
+ _selectionListenerEnabled = true;
+ }
+
+ public void disableSelectionListener()
+ {
+ _selectionListenerEnabled = false;
+ }
+
+ public void cancelEdit()
+ {
+ if(!_updated)
+ {
+ _registryUpdatesEnabled = true;
+
+ //
+ // Apply now any delayed concurrent update
+ //
+ java.util.Iterator p = _concurrentUpdates.iterator();
+ while(p.hasNext())
+ {
+ ApplicationUpdateDescriptor d = (ApplicationUpdateDescriptor)p.next();
+ boolean ok = update(d);
+ assert ok;
+ }
+ _concurrentUpdates.clear();
+ }
+ }
+
+ public boolean kill()
+ {
+ _live = false;
+
+ if(_registryUpdatesEnabled || _discardMe)
+ {
+ return true;
+ }
+ else
+ {
+ _coordinator.getMainPane().resetIcon(this);
+ _coordinator.getCurrentTab().selected(); // only needed when 'this'
+ // corresponds to the current tab
+ return false;
+ }
+ }
+
+ public boolean isLive()
+ {
+ return _live;
+ }
+
+ public boolean hasFile()
+ {
+ return _file != null;
+ }
+
+ public boolean needsSaving()
+ {
+ return _updated;
+ }
+
+ Editor getEditor(Class c, TreeNode node)
+ {
+ Editor result = (Editor)_editorMap.get(c);
+ if(result == null)
+ {
+ result = node.createEditor();
+ _editorMap.put(c, result);
+ }
+ return result;
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ ApplicationDescriptor saveDescriptor()
+ {
+ ApplicationDescriptor clone = (ApplicationDescriptor)_descriptor.clone();
+ clone.distrib = (IceGrid.DistributionDescriptor)clone.distrib.clone();
+ return clone;
+ }
+
+ void restoreDescriptor(ApplicationDescriptor clone)
+ {
+ _descriptor.name = clone.name;
+ _descriptor.variables = clone.variables;
+ _descriptor.distrib.icepatch = clone.distrib.icepatch;
+ _descriptor.distrib.directories = clone.distrib.directories;
+ _descriptor.description = clone.description;
+ }
+
+ public void write(XMLWriter writer) throws java.io.IOException
+ {
+ writer.writeStartTag("icegrid");
+
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", _id));
+
+ writer.writeStartTag("application", attributes);
+
+ if(_descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", _descriptor.description);
+ }
+ writeVariables(writer, _descriptor.variables);
+ writeDistribution(writer, _descriptor.distrib);
+
+ _serviceTemplates.write(writer);
+ _serverTemplates.write(writer);
+ _replicaGroups.write(writer);
+ _propertySets.write(writer);
+ _nodes.write(writer);
+
+ writer.writeEndTag("application");
+ writer.writeEndTag("icegrid");
+ }
+
+ //
+ // Methods called by editors; see also cancelEdit() above
+ //
+ void disableRegistryUpdates()
+ {
+ _registryUpdatesEnabled = false;
+ }
+
+ void updated()
+ {
+ _updated = true;
+ _registryUpdatesEnabled = false; // can be true before that when updated() is called by destroy()
+
+ _concurrentUpdates.clear();
+
+ _coordinator.getSaveAction().setEnabled(_live || _file != null);
+ _coordinator.getDiscardUpdatesAction().setEnabled(_live || _file != null);
+
+ _coordinator.getSaveToRegistryAction().setEnabled(_coordinator.getSession() != null);
+ _coordinator.getSaveToFileAction().setEnabled(true);
+ }
+
+
+ void rebuild() throws UpdateFailedException
+ {
+ Utils.Resolver oldResolver = _resolver;
+ String oldId = _id;
+ _id = _descriptor.name;
+ _resolver = new Utils.Resolver(_descriptor.variables);
+ _resolver.put("application", _id);
+
+ try
+ {
+ _nodes.rebuild();
+ }
+ catch(UpdateFailedException e)
+ {
+ _id = oldId;
+ _resolver = oldResolver;
+ throw e;
+ }
+ }
+
+ //
+ // Called when a server-template is deleted, to remove all
+ // corresponding instances.
+ //
+ void removeServerInstances(String templateId)
+ {
+ _nodes.removeServerInstances(templateId);
+ }
+
+ //
+ // Called when a service-template is deleted, to remove all
+ // corresponding instances
+ //
+ void removeServiceInstances(String templateId)
+ {
+ _nodes.removeServiceInstances(templateId);
+ _serverTemplates.removeServiceInstances(templateId);
+ }
+
+
+ ServerTemplate findServerTemplate(String id)
+ {
+ return (ServerTemplate)_serverTemplates.findChild(id);
+ }
+
+ ServiceTemplate findServiceTemplate(String id)
+ {
+ return (ServiceTemplate)_serviceTemplates.findChild(id);
+ }
+
+ ReplicaGroup findReplicaGroup(String id)
+ {
+ return (ReplicaGroup)_replicaGroups.findChild(id);
+ }
+
+ Node findNode(String id)
+ {
+ return (Node)_nodes.findChild(id);
+ }
+
+ java.util.List findServerInstances(String template)
+ {
+ return _nodes.findServerInstances(template);
+ }
+
+ java.util.List findServiceInstances(String template)
+ {
+ java.util.List result = _serverTemplates.findServiceInstances(template);
+ result.addAll(_nodes.findServiceInstances(template));
+ return result;
+ }
+
+ TemplateDescriptor findServerTemplateDescriptor(String templateName)
+ {
+ return (TemplateDescriptor)
+ _descriptor.serverTemplates.get(templateName);
+ }
+
+ TemplateDescriptor findServiceTemplateDescriptor(String templateName)
+ {
+ return (TemplateDescriptor)
+ _descriptor.serviceTemplates.get(templateName);
+ }
+
+ ServerTemplates getServerTemplates()
+ {
+ return _serverTemplates;
+ }
+
+ ServiceTemplates getServiceTemplates()
+ {
+ return _serviceTemplates;
+ }
+
+ ReplicaGroups getReplicaGroups()
+ {
+ return _replicaGroups;
+ }
+
+ Root getRoot()
+ {
+ return this;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ //
+ // Should only be used for reading
+ //
+ java.util.Map getVariables()
+ {
+ return _descriptor.variables;
+ }
+
+ private boolean isSelected()
+ {
+ if(_coordinator.getCurrentTab() instanceof ApplicationPane)
+ {
+ return ((ApplicationPane)_coordinator.getCurrentTab()).getRoot() == Root.this;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private Coordinator _coordinator;
+
+ //
+ // 'this' is the root of the tree
+ //
+ private JTree _tree;
+ private DefaultTreeModel _treeModel;
+ private Utils.Resolver _resolver;
+
+ private boolean _live;
+
+ //
+ // null when this application is not tied to a file
+ //
+ private File _file;
+
+ private ApplicationDescriptor _descriptor;
+
+ //
+ // Keeps original version (as shallow copies) to be able to build
+ // ApplicationUpdateDescriptor. Only used when _live == true
+ //
+ private java.util.Map _origVariables;
+ private String _origDescription;
+ private DistributionDescriptor _origDistrib;
+
+ //
+ // When this application (and children) is being updated, we
+ // no longer apply updates from the registry. Only meaningful when
+ // _live == true
+ //
+ private boolean _registryUpdatesEnabled = true;
+
+ private boolean _discardMe = false;
+
+ //
+ // True when any update was applies to this application
+ // (including children)
+ //
+ private boolean _updated = false;
+
+ //
+ // Updates saved when _updated == false and
+ // _registryUpdatesEnabled == false
+ //
+ private java.util.List _concurrentUpdates = new java.util.LinkedList();
+
+ //
+ // When _live is true and _canUseUpdateDescriptor is true, we can
+ // save the updates using an ApplicationUpdateDescriptor
+ //
+ private boolean _canUseUpdateDescriptor = true;
+ //
+ // Updates to skip (because already applied locally)
+ //
+ private int _skipUpdates = 0;
+
+
+ private Nodes _nodes;
+ private PropertySets _propertySets;
+ private ReplicaGroups _replicaGroups;
+ private ServerTemplates _serverTemplates;
+ private ServiceTemplates _serviceTemplates;
+
+ private boolean _selectionListenerEnabled = true;
+
+ private ApplicationEditor _editor;
+
+ //
+ // Map editor-class to Editor object
+ //
+ private java.util.Map _editorMap = new java.util.HashMap();
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/Server.java b/java/src/IceGridGUI/Application/Server.java
index 30fa35e0c64..2297c5f308d 100755
--- a/java/src/IceGridGUI/Application/Server.java
+++ b/java/src/IceGridGUI/Application/Server.java
@@ -1,19 +1,19 @@
-// **********************************************************************
-//
-// 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;
-
-interface Server extends TemplateInstance
-{
- Editable getEditable();
-
- Object getDescriptor();
-
- Object saveDescriptor();
- void restoreDescriptor(Object descriptor);
-}
+// **********************************************************************
+//
+// 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;
+
+interface Server extends TemplateInstance
+{
+ Editable getEditable();
+
+ Object getDescriptor();
+
+ Object saveDescriptor();
+ void restoreDescriptor(Object descriptor);
+}
diff --git a/java/src/IceGridGUI/Application/ServerInstance.java b/java/src/IceGridGUI/Application/ServerInstance.java
index 380c6cc5621..0a1b03336f9 100755
--- a/java/src/IceGridGUI/Application/ServerInstance.java
+++ b/java/src/IceGridGUI/Application/ServerInstance.java
@@ -1,359 +1,359 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-
-import javax.swing.Icon;
-import javax.swing.JTree;
-
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServerInstance extends TreeNode implements Server
-{
- static public ServerInstanceDescriptor
- copyDescriptor(ServerInstanceDescriptor sid)
- {
- ServerInstanceDescriptor copy = (ServerInstanceDescriptor)sid.clone();
- copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
- return copy;
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- Object clipboard = getCoordinator().getClipboard();
- if(clipboard != null &&
- (clipboard instanceof ServerDescriptor
- || clipboard instanceof ServerInstanceDescriptor))
- {
- actions[PASTE] = true;
- }
-
- actions[DELETE] = true;
- if(!_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
-
- return actions;
- }
-
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ServerInstanceEditor)
- getRoot().getEditor(ServerInstanceEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ServerInstanceEditor();
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
-
- _serverIcon = Utils.getIcon("/icons/16x16/server_inactive.png");
- _iceboxServerIcon = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
- }
-
- _cellRenderer.setLeafIcon(_isIceBox ? _iceboxServerIcon : _serverIcon);
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public void destroy()
- {
- Node node = (Node)_parent;
-
- if(_ephemeral)
- {
- node.removeServer(this);
- }
- else
- {
- node.removeDescriptor(_descriptor);
- node.removeServer(this);
- node.getEditable().removeElement(_id, _editable, Server.class);
- getRoot().updated();
- }
- }
-
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object saveDescriptor()
- {
- return _descriptor.clone();
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- ServerInstanceDescriptor copy = (ServerInstanceDescriptor)savedDescriptor;
-
- _descriptor.template = copy.template;
- _descriptor.parameterValues = copy.parameterValues;
- _descriptor.propertySet = copy.propertySet;
- }
-
- //
- // Builds the server and all its sub-tree
- //
- ServerInstance(boolean brandNew, TreeNode parent, String serverId,
- Utils.Resolver resolver,
- ServerInstanceDescriptor instanceDescriptor,
- boolean isIceBox)
- throws UpdateFailedException
- {
- super(parent, serverId);
- _ephemeral = false;
- _editable = new Editable(brandNew);
- rebuild(resolver, instanceDescriptor, isIceBox);
- }
-
- ServerInstance(TreeNode parent, String serverId,
- ServerInstanceDescriptor instanceDescriptor)
- {
- super(parent, serverId);
- _ephemeral = true;
- _editable = null;
- rebuild(null, instanceDescriptor, false);
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- TemplateDescriptor templateDescriptor
- = getRoot().findServerTemplateDescriptor(_descriptor.template);
-
- java.util.LinkedList attributes = parameterValuesToAttributes(
- _descriptor.parameterValues, templateDescriptor.parameters);
- attributes.addFirst(createAttribute("template", _descriptor.template));
-
- if(_descriptor.propertySet.references.length == 0 &&
- _descriptor.propertySet.properties.size() == 0)
- {
- writer.writeElement("server-instance", attributes);
- }
- else
- {
- writer.writeStartTag("server-instance", attributes);
- writePropertySet(writer, "", _descriptor.propertySet, null);
- writer.writeEndTag("server-instance");
- }
- }
- }
-
-
- boolean isIceBox()
- {
- return _isIceBox;
- }
-
- void isIceBox(boolean newValue)
- {
- _isIceBox = newValue;
- }
-
- static private class Backup
- {
- Backup(Editable ne)
- {
- nodeEditable = ne;
- }
-
- Editable nodeEditable;
- java.util.Map parameterValues;
- }
-
- public Object rebuild(java.util.List editables) throws UpdateFailedException
- {
- Backup backup = new Backup(((Node)_parent).getEditable().save());
- Node node = (Node)_parent;
-
- TemplateDescriptor templateDescriptor
- = getRoot().findServerTemplateDescriptor(_descriptor.template);
-
- java.util.Set parameters = new java.util.HashSet(templateDescriptor.parameters);
- if(!parameters.equals(_descriptor.parameterValues.keySet()))
- {
- backup.parameterValues = _descriptor.parameterValues;
- _descriptor.parameterValues = Editor.makeParameterValues(
- _descriptor.parameterValues, templateDescriptor.parameters);
- }
- ServerInstance newServer = node.createServer(false, _descriptor);
-
-
- if(_id.equals(newServer.getId()))
- {
- //
- // A simple update. We can't simply rebuild server because
- // we need to keep a backup
- //
- if(_editable.isModified())
- {
- newServer.getEditable().markModified();
- }
-
- node.removeServer(this);
- try
- {
- node.insertServer(newServer, true);
- }
- catch(UpdateFailedException e)
- {
- assert false; // impossible, we just removed a child with
- // this id
- }
-
- if(backup.parameterValues != null)
- {
- editables.add(newServer.getEditable());
- }
- }
- else
- {
- newServer.getEditable().markNew();
- node.removeServer(this);
- node.getEditable().removeElement(_id, _editable, Server.class);
- try
- {
- node.insertServer(newServer, true);
- }
- catch(UpdateFailedException e)
- {
- restore(backup);
- throw e;
- }
- }
-
- return backup;
- }
-
- public void restore(Object backupObj)
- {
- Backup backup = (Backup)backupObj;
- Node node = (Node)_parent;
-
- node.getEditable().restore(backup.nodeEditable);
-
- if(backup.parameterValues != null)
- {
- _descriptor.parameterValues = backup.parameterValues;
- }
-
- TreeNode badServer = node.findChildWithDescriptor(_descriptor);
-
- if(badServer != null)
- {
- node.removeServer(badServer);
- }
-
- try
- {
- node.insertServer(this, true);
- }
- catch(UpdateFailedException e)
- {
- assert false; // impossible
- }
- }
-
- //
- // Update the server
- //
- void rebuild(Utils.Resolver resolver,
- ServerInstanceDescriptor instanceDescriptor,
- boolean isIceBox)
- {
- _resolver = resolver;
- _isIceBox = isIceBox;
- _descriptor = instanceDescriptor;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- public Editable getEditable()
- {
- return _editable;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- public String toString()
- {
- if(_ephemeral)
- {
- return super.toString();
- }
- else
- {
- return _id + ": " + _descriptor.template + "<>";
- }
- }
-
- private ServerInstanceDescriptor _descriptor;
- private final boolean _ephemeral;
- private boolean _isIceBox;
-
- private ServerInstanceEditor _editor;
-
- private Utils.Resolver _resolver;
- private Editable _editable;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon _serverIcon;
- static private Icon _iceboxServerIcon;
-
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+
+import javax.swing.Icon;
+import javax.swing.JTree;
+
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServerInstance extends TreeNode implements Server
+{
+ static public ServerInstanceDescriptor
+ copyDescriptor(ServerInstanceDescriptor sid)
+ {
+ ServerInstanceDescriptor copy = (ServerInstanceDescriptor)sid.clone();
+ copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
+ return copy;
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ Object clipboard = getCoordinator().getClipboard();
+ if(clipboard != null &&
+ (clipboard instanceof ServerDescriptor
+ || clipboard instanceof ServerInstanceDescriptor))
+ {
+ actions[PASTE] = true;
+ }
+
+ actions[DELETE] = true;
+ if(!_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+
+ return actions;
+ }
+
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ServerInstanceEditor)
+ getRoot().getEditor(ServerInstanceEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ServerInstanceEditor();
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+
+ _serverIcon = Utils.getIcon("/icons/16x16/server_inactive.png");
+ _iceboxServerIcon = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
+ }
+
+ _cellRenderer.setLeafIcon(_isIceBox ? _iceboxServerIcon : _serverIcon);
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public void destroy()
+ {
+ Node node = (Node)_parent;
+
+ if(_ephemeral)
+ {
+ node.removeServer(this);
+ }
+ else
+ {
+ node.removeDescriptor(_descriptor);
+ node.removeServer(this);
+ node.getEditable().removeElement(_id, _editable, Server.class);
+ getRoot().updated();
+ }
+ }
+
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object saveDescriptor()
+ {
+ return _descriptor.clone();
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ ServerInstanceDescriptor copy = (ServerInstanceDescriptor)savedDescriptor;
+
+ _descriptor.template = copy.template;
+ _descriptor.parameterValues = copy.parameterValues;
+ _descriptor.propertySet = copy.propertySet;
+ }
+
+ //
+ // Builds the server and all its sub-tree
+ //
+ ServerInstance(boolean brandNew, TreeNode parent, String serverId,
+ Utils.Resolver resolver,
+ ServerInstanceDescriptor instanceDescriptor,
+ boolean isIceBox)
+ throws UpdateFailedException
+ {
+ super(parent, serverId);
+ _ephemeral = false;
+ _editable = new Editable(brandNew);
+ rebuild(resolver, instanceDescriptor, isIceBox);
+ }
+
+ ServerInstance(TreeNode parent, String serverId,
+ ServerInstanceDescriptor instanceDescriptor)
+ {
+ super(parent, serverId);
+ _ephemeral = true;
+ _editable = null;
+ rebuild(null, instanceDescriptor, false);
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ TemplateDescriptor templateDescriptor
+ = getRoot().findServerTemplateDescriptor(_descriptor.template);
+
+ java.util.LinkedList attributes = parameterValuesToAttributes(
+ _descriptor.parameterValues, templateDescriptor.parameters);
+ attributes.addFirst(createAttribute("template", _descriptor.template));
+
+ if(_descriptor.propertySet.references.length == 0 &&
+ _descriptor.propertySet.properties.size() == 0)
+ {
+ writer.writeElement("server-instance", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("server-instance", attributes);
+ writePropertySet(writer, "", _descriptor.propertySet, null);
+ writer.writeEndTag("server-instance");
+ }
+ }
+ }
+
+
+ boolean isIceBox()
+ {
+ return _isIceBox;
+ }
+
+ void isIceBox(boolean newValue)
+ {
+ _isIceBox = newValue;
+ }
+
+ static private class Backup
+ {
+ Backup(Editable ne)
+ {
+ nodeEditable = ne;
+ }
+
+ Editable nodeEditable;
+ java.util.Map parameterValues;
+ }
+
+ public Object rebuild(java.util.List editables) throws UpdateFailedException
+ {
+ Backup backup = new Backup(((Node)_parent).getEditable().save());
+ Node node = (Node)_parent;
+
+ TemplateDescriptor templateDescriptor
+ = getRoot().findServerTemplateDescriptor(_descriptor.template);
+
+ java.util.Set parameters = new java.util.HashSet(templateDescriptor.parameters);
+ if(!parameters.equals(_descriptor.parameterValues.keySet()))
+ {
+ backup.parameterValues = _descriptor.parameterValues;
+ _descriptor.parameterValues = Editor.makeParameterValues(
+ _descriptor.parameterValues, templateDescriptor.parameters);
+ }
+ ServerInstance newServer = node.createServer(false, _descriptor);
+
+
+ if(_id.equals(newServer.getId()))
+ {
+ //
+ // A simple update. We can't simply rebuild server because
+ // we need to keep a backup
+ //
+ if(_editable.isModified())
+ {
+ newServer.getEditable().markModified();
+ }
+
+ node.removeServer(this);
+ try
+ {
+ node.insertServer(newServer, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false; // impossible, we just removed a child with
+ // this id
+ }
+
+ if(backup.parameterValues != null)
+ {
+ editables.add(newServer.getEditable());
+ }
+ }
+ else
+ {
+ newServer.getEditable().markNew();
+ node.removeServer(this);
+ node.getEditable().removeElement(_id, _editable, Server.class);
+ try
+ {
+ node.insertServer(newServer, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ restore(backup);
+ throw e;
+ }
+ }
+
+ return backup;
+ }
+
+ public void restore(Object backupObj)
+ {
+ Backup backup = (Backup)backupObj;
+ Node node = (Node)_parent;
+
+ node.getEditable().restore(backup.nodeEditable);
+
+ if(backup.parameterValues != null)
+ {
+ _descriptor.parameterValues = backup.parameterValues;
+ }
+
+ TreeNode badServer = node.findChildWithDescriptor(_descriptor);
+
+ if(badServer != null)
+ {
+ node.removeServer(badServer);
+ }
+
+ try
+ {
+ node.insertServer(this, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false; // impossible
+ }
+ }
+
+ //
+ // Update the server
+ //
+ void rebuild(Utils.Resolver resolver,
+ ServerInstanceDescriptor instanceDescriptor,
+ boolean isIceBox)
+ {
+ _resolver = resolver;
+ _isIceBox = isIceBox;
+ _descriptor = instanceDescriptor;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ public Editable getEditable()
+ {
+ return _editable;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ public String toString()
+ {
+ if(_ephemeral)
+ {
+ return super.toString();
+ }
+ else
+ {
+ return _id + ": " + _descriptor.template + "<>";
+ }
+ }
+
+ private ServerInstanceDescriptor _descriptor;
+ private final boolean _ephemeral;
+ private boolean _isIceBox;
+
+ private ServerInstanceEditor _editor;
+
+ private Utils.Resolver _resolver;
+ private Editable _editable;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private Icon _serverIcon;
+ static private Icon _iceboxServerIcon;
+
+}
diff --git a/java/src/IceGridGUI/Application/ServerInstanceEditor.java b/java/src/IceGridGUI/Application/ServerInstanceEditor.java
index 23f8da37aa9..99a802969d7 100755
--- a/java/src/IceGridGUI/Application/ServerInstanceEditor.java
+++ b/java/src/IceGridGUI/Application/ServerInstanceEditor.java
@@ -1,228 +1,228 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServerInstanceEditor extends AbstractServerEditor
-{
- protected void writeDescriptor()
- {
- ServerInstanceDescriptor descriptor = getDescriptor();
- ServerTemplate t = (ServerTemplate)_template.getSelectedItem();
-
- descriptor.template = t.getId();
- descriptor.parameterValues = _parameters.getValues();
-
- descriptor.propertySet.references =
- (String[])_propertySets.getList().toArray(new String[0]);
- descriptor.propertySet.properties = _properties.getProperties();
-
- ((ServerInstance)_target).isIceBox(
- ((TemplateDescriptor)t.getDescriptor()).descriptor instanceof IceBoxDescriptor);
- }
-
- protected boolean isSimpleUpdate()
- {
- ServerInstanceDescriptor descriptor = getDescriptor();
- ServerTemplate t = (ServerTemplate)_template.getSelectedItem();
-
- return descriptor.template.equals(t.getId())
- && descriptor.parameterValues.equals(_parameters.getValues());
- }
-
- ServerInstanceEditor()
- {
- _template.setToolTipText("Server template");
-
- //
- // Template
- //
- Action gotoTemplate = new AbstractAction(
- "", Utils.getIcon("/icons/16x16/goto.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- TreeNode t = (TreeNode)_template.getSelectedItem();
- if(t != null)
- {
- t.getRoot().setSelectedNode(t);
- }
- }
- };
- gotoTemplate.putValue(Action.SHORT_DESCRIPTION,
- "Goto this server template");
- _templateButton = new JButton(gotoTemplate);
-
- _parameters = new ParameterValuesField(this);
-
- _propertySets.getDocument().addDocumentListener(_updateListener);
- _propertySets.setToolTipText("Property Set References");
-
- _properties = new PropertiesField(this);
- }
-
- ServerInstanceDescriptor getDescriptor()
- {
- return (ServerInstanceDescriptor)_target.getDescriptor();
- }
-
- //
- // From Editor:
- //
-
- Utils.Resolver getDetailResolver()
- {
- if(_target.getCoordinator().substitute())
- {
- return _target.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Template", _template);
- builder.append(_templateButton);
- builder.nextLine();
-
- builder.append("Parameters");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- JScrollPane scrollPane = new JScrollPane(_parameters);
- CellConstraints cc = new CellConstraints();
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Property Sets");
- builder.append(_propertySets, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- void show(ServerInstance server)
- {
- detectUpdates(false);
- _target = server;
-
- ServerInstanceDescriptor descriptor = getDescriptor();
- Root root = server.getRoot();
- boolean isEditable = !root.getCoordinator().substitute();
-
- Utils.Resolver resolver = isEditable ? null :
- ((Node)_target.getParent()).getResolver();
-
- //
- // Need to make control enabled before changing it
- //
- _template.setEnabled(true);
-
- ServerTemplates serverTemplates = root.getServerTemplates();
- _template.setModel(serverTemplates.createComboBoxModel());
-
- ServerTemplate t = (ServerTemplate)
- serverTemplates.findChild(descriptor.template);
- assert t != null;
- _template.setSelectedItem(t);
-
- ListDataListener templateListener = new ListDataListener()
- {
- public void contentsChanged(ListDataEvent e)
- {
- updated();
-
- ServerTemplate t =
- (ServerTemplate)_template.getModel().getSelectedItem();
-
- TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
-
- //
- // Replace parameters but keep existing values
- //
- _parameters.set(td.parameters,
- makeParameterValues(_parameters.getValues(), td.parameters),
- td.parameterDefaults, null);
- }
-
- public void intervalAdded(ListDataEvent e)
- {}
-
- public void intervalRemoved(ListDataEvent e)
- {}
- };
-
- _template.getModel().addListDataListener(templateListener);
- _template.setEnabled(isEditable);
-
- TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
- _parameters.set(td.parameters, descriptor.parameterValues,
- td.parameterDefaults, resolver);
-
- _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
- getDetailResolver());
- _propertySets.setEditable(isEditable);
-
- _properties.setProperties(descriptor.propertySet.properties, null,
- getDetailResolver(), isEditable);
-
- _applyButton.setEnabled(server.isEphemeral());
- _discardButton.setEnabled(server.isEphemeral());
- detectUpdates(true);
- }
-
- private JComboBox _template = new JComboBox();
- private JButton _templateButton;
- private ParameterValuesField _parameters;
-
- private ListTextField _propertySets = new ListTextField(20);
- private PropertiesField _properties;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServerInstanceEditor extends AbstractServerEditor
+{
+ protected void writeDescriptor()
+ {
+ ServerInstanceDescriptor descriptor = getDescriptor();
+ ServerTemplate t = (ServerTemplate)_template.getSelectedItem();
+
+ descriptor.template = t.getId();
+ descriptor.parameterValues = _parameters.getValues();
+
+ descriptor.propertySet.references =
+ (String[])_propertySets.getList().toArray(new String[0]);
+ descriptor.propertySet.properties = _properties.getProperties();
+
+ ((ServerInstance)_target).isIceBox(
+ ((TemplateDescriptor)t.getDescriptor()).descriptor instanceof IceBoxDescriptor);
+ }
+
+ protected boolean isSimpleUpdate()
+ {
+ ServerInstanceDescriptor descriptor = getDescriptor();
+ ServerTemplate t = (ServerTemplate)_template.getSelectedItem();
+
+ return descriptor.template.equals(t.getId())
+ && descriptor.parameterValues.equals(_parameters.getValues());
+ }
+
+ ServerInstanceEditor()
+ {
+ _template.setToolTipText("Server template");
+
+ //
+ // Template
+ //
+ Action gotoTemplate = new AbstractAction(
+ "", Utils.getIcon("/icons/16x16/goto.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ TreeNode t = (TreeNode)_template.getSelectedItem();
+ if(t != null)
+ {
+ t.getRoot().setSelectedNode(t);
+ }
+ }
+ };
+ gotoTemplate.putValue(Action.SHORT_DESCRIPTION,
+ "Goto this server template");
+ _templateButton = new JButton(gotoTemplate);
+
+ _parameters = new ParameterValuesField(this);
+
+ _propertySets.getDocument().addDocumentListener(_updateListener);
+ _propertySets.setToolTipText("Property Set References");
+
+ _properties = new PropertiesField(this);
+ }
+
+ ServerInstanceDescriptor getDescriptor()
+ {
+ return (ServerInstanceDescriptor)_target.getDescriptor();
+ }
+
+ //
+ // From Editor:
+ //
+
+ Utils.Resolver getDetailResolver()
+ {
+ if(_target.getCoordinator().substitute())
+ {
+ return _target.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Template", _template);
+ builder.append(_templateButton);
+ builder.nextLine();
+
+ builder.append("Parameters");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ JScrollPane scrollPane = new JScrollPane(_parameters);
+ CellConstraints cc = new CellConstraints();
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Property Sets");
+ builder.append(_propertySets, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ void show(ServerInstance server)
+ {
+ detectUpdates(false);
+ _target = server;
+
+ ServerInstanceDescriptor descriptor = getDescriptor();
+ Root root = server.getRoot();
+ boolean isEditable = !root.getCoordinator().substitute();
+
+ Utils.Resolver resolver = isEditable ? null :
+ ((Node)_target.getParent()).getResolver();
+
+ //
+ // Need to make control enabled before changing it
+ //
+ _template.setEnabled(true);
+
+ ServerTemplates serverTemplates = root.getServerTemplates();
+ _template.setModel(serverTemplates.createComboBoxModel());
+
+ ServerTemplate t = (ServerTemplate)
+ serverTemplates.findChild(descriptor.template);
+ assert t != null;
+ _template.setSelectedItem(t);
+
+ ListDataListener templateListener = new ListDataListener()
+ {
+ public void contentsChanged(ListDataEvent e)
+ {
+ updated();
+
+ ServerTemplate t =
+ (ServerTemplate)_template.getModel().getSelectedItem();
+
+ TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
+
+ //
+ // Replace parameters but keep existing values
+ //
+ _parameters.set(td.parameters,
+ makeParameterValues(_parameters.getValues(), td.parameters),
+ td.parameterDefaults, null);
+ }
+
+ public void intervalAdded(ListDataEvent e)
+ {}
+
+ public void intervalRemoved(ListDataEvent e)
+ {}
+ };
+
+ _template.getModel().addListDataListener(templateListener);
+ _template.setEnabled(isEditable);
+
+ TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
+ _parameters.set(td.parameters, descriptor.parameterValues,
+ td.parameterDefaults, resolver);
+
+ _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
+ getDetailResolver());
+ _propertySets.setEditable(isEditable);
+
+ _properties.setProperties(descriptor.propertySet.properties, null,
+ getDetailResolver(), isEditable);
+
+ _applyButton.setEnabled(server.isEphemeral());
+ _discardButton.setEnabled(server.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private JComboBox _template = new JComboBox();
+ private JButton _templateButton;
+ private ParameterValuesField _parameters;
+
+ private ListTextField _propertySets = new ListTextField(20);
+ private PropertiesField _properties;
+}
diff --git a/java/src/IceGridGUI/Application/ServerSubEditor.java b/java/src/IceGridGUI/Application/ServerSubEditor.java
index 2be5ec9c1d3..9bc31db6943 100755
--- a/java/src/IceGridGUI/Application/ServerSubEditor.java
+++ b/java/src/IceGridGUI/Application/ServerSubEditor.java
@@ -1,396 +1,396 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServerSubEditor extends CommunicatorSubEditor
-{
- ServerSubEditor(Editor mainEditor)
- {
- super(mainEditor);
-
- _id.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _id.setToolTipText("Must be unique within this IceGrid deployment");
-
- _exe.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _exe.setToolTipText("<html>Path to this server's executable, e.g.:<br>"
- + "icebox<br>"
- + "java<br>"
- + "myHelloServer<br>"
- + "C:\\testbed\\hello\\server</html>");
-
- _pwd.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _pwd.setToolTipText(
- "<html>If not set, the server will start in "
- + "<i>node data dir</i>/servers/<i>server-id</i>;<br>"
- + "relative directories are relative to the current directory"
- + " of the icegridnode process.</html>");
-
- _options.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _options.setToolTipText(
- "<html>Command-line arguments for this server.<br>"
- + "Use whitespace as separator; use double-quotes around arguments containing whitespaces</html>");
-
- _user.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _user.setToolTipText(
- "<html>Run the server using this user account.<br>"
- + "This feature is only available on Unix/Linux, when the IceGrid node runs as root.</html>");
-
- _envs = new MapField(mainEditor, "Name", "Value", true);
-
- _activation = new JComboBox(new Object[]{ALWAYS, MANUAL, ON_DEMAND, SESSION});
- _activation.setToolTipText("<html>always: IceGrid starts and keeps the server up all the time<br>"
- + "manual: you start the server yourself<br>"
- + "on-demand: IceGrid starts the server when a client needs it<br>"
- + "session: IceGrid starts and shuts down the server for each session</html>");
-
- JTextField activationTextField = (JTextField)
- _activation.getEditor().getEditorComponent();
- activationTextField.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
-
- _activationTimeout.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _activationTimeout.setToolTipText("<html>Number of seconds; if not set or set to 0, "
- + "the IceGrid Node<br> uses the value of its "
- + "IceGrid.Node.WaitTime property</html>");
- _deactivationTimeout.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _deactivationTimeout.setToolTipText("<html>Number of seconds; if not set or set to 0, "
- + "the IceGrid Node<br> uses the value of its "
- + "IceGrid.Node.WaitTime property</html>");
-
- Action allocatable = new AbstractAction("Allocatable")
- {
- public void actionPerformed(ActionEvent e)
- {
- _mainEditor.updated();
- }
- };
- allocatable.putValue(Action.SHORT_DESCRIPTION,
- "<html>Check this box to ensure that the well-known objects<br>"
- + "of this server can only be allocated by one session at a time.</html>");
- _allocatable = new JCheckBox(allocatable);
-
-
- Action appDistrib = new AbstractAction("Depends on the application distribution")
- {
- public void actionPerformed(ActionEvent e)
- {
- _mainEditor.updated();
- }
- };
- appDistrib.putValue(Action.SHORT_DESCRIPTION,
- "<html>Check this box if this server needs to be restarted<br>"
- + "each time the distribution for your application is refreshed.</html>");
-
- _applicationDistrib = new JCheckBox(appDistrib);
-
- _distrib = new JComboBox(new Object[]{NO_DISTRIB, DEFAULT_DISTRIB});
- _distrib.setToolTipText(
- "The proxy to the IcePatch2 server holding your files");
-
- JTextField distribTextField = (JTextField)
- _distrib.getEditor().getEditorComponent();
- distribTextField.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
-
- _distribDirs.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _distribDirs.setToolTipText(
- "<html>Include only these directories when patching.<br>"
- + "Use whitespace as separator; use double-quotes around directories containing whitespaces</html>");
-
- }
-
- ServerDescriptor getServerDescriptor()
- {
- return (ServerDescriptor)
- _mainEditor.getSubDescriptor();
- }
-
- void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Server ID");
- builder.append(_id, 3);
- builder.nextLine();
-
- //
- // Add Communicator fields
- //
- super.appendProperties(builder);
-
- builder.appendSeparator("Activation");
- builder.append("Path to Executable");
- builder.append(_exe, 3);
- builder.nextLine();
- builder.append("Working Directory");
- builder.append(_pwd, 3);
- builder.nextLine();
- builder.append("Command Arguments");
- builder.append(_options, 3);
- builder.nextLine();
- builder.append("Run as");
- builder.append(_user, 3);
- builder.nextLine();
- builder.append("Environment Variables");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_envs);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Activation Mode");
- builder.append(_activation, 3);
- builder.nextLine();
- builder.append("Activation Timeout");
- builder.append(_activationTimeout, 3);
- builder.nextLine();
- builder.append("Deactivation Timeout");
- builder.append(_deactivationTimeout, 3);
- builder.nextLine();
- builder.append("", _allocatable);
- builder.nextLine();
-
- JComponent c = builder.appendSeparator("Distribution");
- c.setToolTipText("Files specific to this server");
-
- builder.append("", _applicationDistrib);
- builder.nextLine();
- builder.append("IcePatch2 Proxy");
- builder.append(_distrib, 3);
- builder.nextLine();
- builder.append("Directories");
- builder.append(_distribDirs, 3);
- builder.nextLine();
- }
-
- void writeDescriptor()
- {
- ServerDescriptor descriptor = getServerDescriptor();
- descriptor.id = _id.getText().trim();
- descriptor.exe = _exe.getText().trim();
- descriptor.pwd = _pwd.getText().trim();
-
- descriptor.options = _options.getList();
- descriptor.user = _user.getText().trim();
-
- descriptor.envs = new java.util.LinkedList();
- java.util.Iterator p = _envs.get().entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- descriptor.envs.add(entry.getKey().toString()
- + "=" + entry.getValue().toString());
- }
-
- descriptor.activation = _activation.getSelectedItem().toString().trim();
- descriptor.activationTimeout = _activationTimeout.getText().trim();
- descriptor.deactivationTimeout = _deactivationTimeout.getText().trim();
-
- descriptor.allocatable = _allocatable.isSelected();
-
- descriptor.applicationDistrib = _applicationDistrib.isSelected();
-
- if(_distrib.getSelectedItem() == NO_DISTRIB)
- {
- descriptor.distrib.icepatch = "";
- }
- else
- {
- descriptor.distrib.icepatch = _distrib.getSelectedItem().toString().trim();
- }
- descriptor.distrib.directories = _distribDirs.getList();
-
- super.writeDescriptor(descriptor);
- }
-
- boolean isSimpleUpdate()
- {
- return getServerDescriptor().id.equals(_id.getText().trim());
- }
-
- boolean validate()
- {
- return _mainEditor.check(new String[]{
- "Server ID", _id.getText().trim(),
- "Path to Executable", _exe.getText().trim()});
- }
-
- void show(boolean isEditable)
- {
- ServerDescriptor descriptor = getServerDescriptor();
- Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
-
- isEditable = isEditable && (detailResolver == null);
-
- if(detailResolver != null)
- {
- _id.setText(detailResolver.find("server"));
- }
- else
- {
- _id.setText(descriptor.id);
- }
- _id.setEditable(isEditable);
-
- _exe.setText(
- Utils.substitute(descriptor.exe, detailResolver));
- _exe.setEditable(isEditable);
- _pwd.setText(
- Utils.substitute(descriptor.pwd, detailResolver));
- _pwd.setEditable(isEditable);
-
- _options.setList(descriptor.options, detailResolver);
- _options.setEditable(isEditable);
-
- _user.setText(
- Utils.substitute(descriptor.user, detailResolver));
- _user.setEditable(isEditable);
-
- java.util.Map envMap = new java.util.TreeMap();
- java.util.Iterator p = descriptor.envs.iterator();
- while(p.hasNext())
- {
- String env = (String)p.next();
- int equal = env.indexOf('=');
- if(equal == -1 || equal == env.length() - 1)
- {
- envMap.put(env, "");
- }
- else
- {
- envMap.put(env.substring(0, equal),
- env.substring(equal + 1));
- }
- }
- _envs.set(envMap, detailResolver, isEditable);
-
- String activation = Utils.substitute(descriptor.activation,
- detailResolver);
-
- _activation.setEnabled(true);
- _activation.setEditable(true);
- if(activation.equals(ALWAYS))
- {
- _activation.setSelectedItem(ALWAYS);
- }
- else if(activation.equals(MANUAL))
- {
- _activation.setSelectedItem(MANUAL);
- }
- else if(activation.equals(ON_DEMAND))
- {
- _activation.setSelectedItem(ON_DEMAND);
- }
- else if(activation.equals(SESSION))
- {
- _activation.setSelectedItem(SESSION);
- }
- else
- {
- _activation.setSelectedItem(activation);
- }
- _activation.setEnabled(isEditable);
- _activation.setEditable(isEditable);
-
- _activationTimeout.setText(
- Utils.substitute(descriptor.activationTimeout, detailResolver));
- _activationTimeout.setEditable(isEditable);
-
- _deactivationTimeout.setText(
- Utils.substitute(descriptor.deactivationTimeout, detailResolver));
- _deactivationTimeout.setEditable(isEditable);
-
- _allocatable.setSelected(descriptor.allocatable);
- _allocatable.setEnabled(isEditable);
-
- _applicationDistrib.setSelected(descriptor.applicationDistrib);
- _applicationDistrib.setEnabled(isEditable);
-
- _distrib.setEnabled(true);
- _distrib.setEditable(true);
- String icepatch = Utils.substitute(descriptor.distrib.icepatch,
- detailResolver);
- if(icepatch.equals(""))
- {
- _distrib.setSelectedItem(NO_DISTRIB);
- }
- else
- {
- _distrib.setSelectedItem(icepatch);
- }
- _distrib.setEnabled(isEditable);
- _distrib.setEditable(isEditable);
-
- _distribDirs.setList(descriptor.distrib.directories, detailResolver);
- _distribDirs.setEditable(isEditable);
-
- show(descriptor, isEditable);
- }
-
- static private final String ALWAYS = "always";
- static private final String MANUAL = "manual";
- static private final String ON_DEMAND = "on-demand";
- static private final String SESSION = "session";
-
- static private final Object NO_DISTRIB = new Object()
- {
- public String toString()
- {
- return "None selected";
- }
- };
-
- static private final String DEFAULT_DISTRIB = "${application}.IcePatch2/server";
-
- private JTextField _id = new JTextField(20);
- private JTextField _exe = new JTextField(20);
- private JTextField _pwd = new JTextField(20);
- private ListTextField _options = new ListTextField(20);
- private JTextField _user = new JTextField(20);
- private MapField _envs;
-
- private JComboBox _activation;
- private JTextField _activationTimeout = new JTextField(20);
- private JTextField _deactivationTimeout = new JTextField(20);
- private JCheckBox _allocatable;
- private JCheckBox _applicationDistrib;
- private JComboBox _distrib;
- private ListTextField _distribDirs = new ListTextField(20);
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServerSubEditor extends CommunicatorSubEditor
+{
+ ServerSubEditor(Editor mainEditor)
+ {
+ super(mainEditor);
+
+ _id.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _id.setToolTipText("Must be unique within this IceGrid deployment");
+
+ _exe.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _exe.setToolTipText("<html>Path to this server's executable, e.g.:<br>"
+ + "icebox<br>"
+ + "java<br>"
+ + "myHelloServer<br>"
+ + "C:\\testbed\\hello\\server</html>");
+
+ _pwd.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _pwd.setToolTipText(
+ "<html>If not set, the server will start in "
+ + "<i>node data dir</i>/servers/<i>server-id</i>;<br>"
+ + "relative directories are relative to the current directory"
+ + " of the icegridnode process.</html>");
+
+ _options.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _options.setToolTipText(
+ "<html>Command-line arguments for this server.<br>"
+ + "Use whitespace as separator; use double-quotes around arguments containing whitespaces</html>");
+
+ _user.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _user.setToolTipText(
+ "<html>Run the server using this user account.<br>"
+ + "This feature is only available on Unix/Linux, when the IceGrid node runs as root.</html>");
+
+ _envs = new MapField(mainEditor, "Name", "Value", true);
+
+ _activation = new JComboBox(new Object[]{ALWAYS, MANUAL, ON_DEMAND, SESSION});
+ _activation.setToolTipText("<html>always: IceGrid starts and keeps the server up all the time<br>"
+ + "manual: you start the server yourself<br>"
+ + "on-demand: IceGrid starts the server when a client needs it<br>"
+ + "session: IceGrid starts and shuts down the server for each session</html>");
+
+ JTextField activationTextField = (JTextField)
+ _activation.getEditor().getEditorComponent();
+ activationTextField.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+
+ _activationTimeout.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _activationTimeout.setToolTipText("<html>Number of seconds; if not set or set to 0, "
+ + "the IceGrid Node<br> uses the value of its "
+ + "IceGrid.Node.WaitTime property</html>");
+ _deactivationTimeout.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _deactivationTimeout.setToolTipText("<html>Number of seconds; if not set or set to 0, "
+ + "the IceGrid Node<br> uses the value of its "
+ + "IceGrid.Node.WaitTime property</html>");
+
+ Action allocatable = new AbstractAction("Allocatable")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _mainEditor.updated();
+ }
+ };
+ allocatable.putValue(Action.SHORT_DESCRIPTION,
+ "<html>Check this box to ensure that the well-known objects<br>"
+ + "of this server can only be allocated by one session at a time.</html>");
+ _allocatable = new JCheckBox(allocatable);
+
+
+ Action appDistrib = new AbstractAction("Depends on the application distribution")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _mainEditor.updated();
+ }
+ };
+ appDistrib.putValue(Action.SHORT_DESCRIPTION,
+ "<html>Check this box if this server needs to be restarted<br>"
+ + "each time the distribution for your application is refreshed.</html>");
+
+ _applicationDistrib = new JCheckBox(appDistrib);
+
+ _distrib = new JComboBox(new Object[]{NO_DISTRIB, DEFAULT_DISTRIB});
+ _distrib.setToolTipText(
+ "The proxy to the IcePatch2 server holding your files");
+
+ JTextField distribTextField = (JTextField)
+ _distrib.getEditor().getEditorComponent();
+ distribTextField.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+
+ _distribDirs.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _distribDirs.setToolTipText(
+ "<html>Include only these directories when patching.<br>"
+ + "Use whitespace as separator; use double-quotes around directories containing whitespaces</html>");
+
+ }
+
+ ServerDescriptor getServerDescriptor()
+ {
+ return (ServerDescriptor)
+ _mainEditor.getSubDescriptor();
+ }
+
+ void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Server ID");
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ //
+ // Add Communicator fields
+ //
+ super.appendProperties(builder);
+
+ builder.appendSeparator("Activation");
+ builder.append("Path to Executable");
+ builder.append(_exe, 3);
+ builder.nextLine();
+ builder.append("Working Directory");
+ builder.append(_pwd, 3);
+ builder.nextLine();
+ builder.append("Command Arguments");
+ builder.append(_options, 3);
+ builder.nextLine();
+ builder.append("Run as");
+ builder.append(_user, 3);
+ builder.nextLine();
+ builder.append("Environment Variables");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_envs);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Activation Mode");
+ builder.append(_activation, 3);
+ builder.nextLine();
+ builder.append("Activation Timeout");
+ builder.append(_activationTimeout, 3);
+ builder.nextLine();
+ builder.append("Deactivation Timeout");
+ builder.append(_deactivationTimeout, 3);
+ builder.nextLine();
+ builder.append("", _allocatable);
+ builder.nextLine();
+
+ JComponent c = builder.appendSeparator("Distribution");
+ c.setToolTipText("Files specific to this server");
+
+ builder.append("", _applicationDistrib);
+ builder.nextLine();
+ builder.append("IcePatch2 Proxy");
+ builder.append(_distrib, 3);
+ builder.nextLine();
+ builder.append("Directories");
+ builder.append(_distribDirs, 3);
+ builder.nextLine();
+ }
+
+ void writeDescriptor()
+ {
+ ServerDescriptor descriptor = getServerDescriptor();
+ descriptor.id = _id.getText().trim();
+ descriptor.exe = _exe.getText().trim();
+ descriptor.pwd = _pwd.getText().trim();
+
+ descriptor.options = _options.getList();
+ descriptor.user = _user.getText().trim();
+
+ descriptor.envs = new java.util.LinkedList();
+ java.util.Iterator p = _envs.get().entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ descriptor.envs.add(entry.getKey().toString()
+ + "=" + entry.getValue().toString());
+ }
+
+ descriptor.activation = _activation.getSelectedItem().toString().trim();
+ descriptor.activationTimeout = _activationTimeout.getText().trim();
+ descriptor.deactivationTimeout = _deactivationTimeout.getText().trim();
+
+ descriptor.allocatable = _allocatable.isSelected();
+
+ descriptor.applicationDistrib = _applicationDistrib.isSelected();
+
+ if(_distrib.getSelectedItem() == NO_DISTRIB)
+ {
+ descriptor.distrib.icepatch = "";
+ }
+ else
+ {
+ descriptor.distrib.icepatch = _distrib.getSelectedItem().toString().trim();
+ }
+ descriptor.distrib.directories = _distribDirs.getList();
+
+ super.writeDescriptor(descriptor);
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return getServerDescriptor().id.equals(_id.getText().trim());
+ }
+
+ boolean validate()
+ {
+ return _mainEditor.check(new String[]{
+ "Server ID", _id.getText().trim(),
+ "Path to Executable", _exe.getText().trim()});
+ }
+
+ void show(boolean isEditable)
+ {
+ ServerDescriptor descriptor = getServerDescriptor();
+ Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
+
+ isEditable = isEditable && (detailResolver == null);
+
+ if(detailResolver != null)
+ {
+ _id.setText(detailResolver.find("server"));
+ }
+ else
+ {
+ _id.setText(descriptor.id);
+ }
+ _id.setEditable(isEditable);
+
+ _exe.setText(
+ Utils.substitute(descriptor.exe, detailResolver));
+ _exe.setEditable(isEditable);
+ _pwd.setText(
+ Utils.substitute(descriptor.pwd, detailResolver));
+ _pwd.setEditable(isEditable);
+
+ _options.setList(descriptor.options, detailResolver);
+ _options.setEditable(isEditable);
+
+ _user.setText(
+ Utils.substitute(descriptor.user, detailResolver));
+ _user.setEditable(isEditable);
+
+ java.util.Map envMap = new java.util.TreeMap();
+ java.util.Iterator p = descriptor.envs.iterator();
+ while(p.hasNext())
+ {
+ String env = (String)p.next();
+ int equal = env.indexOf('=');
+ if(equal == -1 || equal == env.length() - 1)
+ {
+ envMap.put(env, "");
+ }
+ else
+ {
+ envMap.put(env.substring(0, equal),
+ env.substring(equal + 1));
+ }
+ }
+ _envs.set(envMap, detailResolver, isEditable);
+
+ String activation = Utils.substitute(descriptor.activation,
+ detailResolver);
+
+ _activation.setEnabled(true);
+ _activation.setEditable(true);
+ if(activation.equals(ALWAYS))
+ {
+ _activation.setSelectedItem(ALWAYS);
+ }
+ else if(activation.equals(MANUAL))
+ {
+ _activation.setSelectedItem(MANUAL);
+ }
+ else if(activation.equals(ON_DEMAND))
+ {
+ _activation.setSelectedItem(ON_DEMAND);
+ }
+ else if(activation.equals(SESSION))
+ {
+ _activation.setSelectedItem(SESSION);
+ }
+ else
+ {
+ _activation.setSelectedItem(activation);
+ }
+ _activation.setEnabled(isEditable);
+ _activation.setEditable(isEditable);
+
+ _activationTimeout.setText(
+ Utils.substitute(descriptor.activationTimeout, detailResolver));
+ _activationTimeout.setEditable(isEditable);
+
+ _deactivationTimeout.setText(
+ Utils.substitute(descriptor.deactivationTimeout, detailResolver));
+ _deactivationTimeout.setEditable(isEditable);
+
+ _allocatable.setSelected(descriptor.allocatable);
+ _allocatable.setEnabled(isEditable);
+
+ _applicationDistrib.setSelected(descriptor.applicationDistrib);
+ _applicationDistrib.setEnabled(isEditable);
+
+ _distrib.setEnabled(true);
+ _distrib.setEditable(true);
+ String icepatch = Utils.substitute(descriptor.distrib.icepatch,
+ detailResolver);
+ if(icepatch.equals(""))
+ {
+ _distrib.setSelectedItem(NO_DISTRIB);
+ }
+ else
+ {
+ _distrib.setSelectedItem(icepatch);
+ }
+ _distrib.setEnabled(isEditable);
+ _distrib.setEditable(isEditable);
+
+ _distribDirs.setList(descriptor.distrib.directories, detailResolver);
+ _distribDirs.setEditable(isEditable);
+
+ show(descriptor, isEditable);
+ }
+
+ static private final String ALWAYS = "always";
+ static private final String MANUAL = "manual";
+ static private final String ON_DEMAND = "on-demand";
+ static private final String SESSION = "session";
+
+ static private final Object NO_DISTRIB = new Object()
+ {
+ public String toString()
+ {
+ return "None selected";
+ }
+ };
+
+ static private final String DEFAULT_DISTRIB = "${application}.IcePatch2/server";
+
+ private JTextField _id = new JTextField(20);
+ private JTextField _exe = new JTextField(20);
+ private JTextField _pwd = new JTextField(20);
+ private ListTextField _options = new ListTextField(20);
+ private JTextField _user = new JTextField(20);
+ private MapField _envs;
+
+ private JComboBox _activation;
+ private JTextField _activationTimeout = new JTextField(20);
+ private JTextField _deactivationTimeout = new JTextField(20);
+ private JCheckBox _allocatable;
+ private JCheckBox _applicationDistrib;
+ private JComboBox _distrib;
+ private ListTextField _distribDirs = new ListTextField(20);
+}
diff --git a/java/src/IceGridGUI/Application/ServerTemplate.java b/java/src/IceGridGUI/Application/ServerTemplate.java
index c2d01a2da6f..90a0501ece6 100755
--- a/java/src/IceGridGUI/Application/ServerTemplate.java
+++ b/java/src/IceGridGUI/Application/ServerTemplate.java
@@ -1,358 +1,358 @@
-// **********************************************************************
-//
-// 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 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.JComponent;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-
-class ServerTemplate extends Communicator
-{
- static public TemplateDescriptor
- copyDescriptor(TemplateDescriptor templateDescriptor)
- {
- TemplateDescriptor copy = (TemplateDescriptor)
- templateDescriptor.clone();
-
- copy.descriptor = PlainServer.copyDescriptor(
- (ServerDescriptor)copy.descriptor);
- return copy;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _plainIcon =
- Utils.getIcon("/icons/16x16/server_template.png");
- _iceboxIcon =
- Utils.getIcon("/icons/16x16/icebox_server_template.png");
- }
-
- if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
- {
- if(expanded)
- {
- _cellRenderer.setOpenIcon(_iceboxIcon);
- }
- else
- {
- _cellRenderer.setClosedIcon(_iceboxIcon);
- }
- }
- else
- {
- if(expanded)
- {
- _cellRenderer.setOpenIcon(_plainIcon);
- }
- else
- {
- _cellRenderer.setClosedIcon(_plainIcon);
- }
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
-
- actions[DELETE] = true;
-
- actions[NEW_ADAPTER] = !_services.initialized();
- actions[NEW_SERVICE] = _services.initialized();
- actions[NEW_SERVICE_FROM_TEMPLATE] = _services.initialized();
- actions[NEW_DBENV] = _dbEnvs.initialized();
-
- return actions;
- }
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_templateDescriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_ADAPTER));
- _popup.add(actions.get(NEW_DBENV));
- _popup.add(actions.get(NEW_SERVICE));
- _popup.add(actions.get(NEW_SERVICE_FROM_TEMPLATE));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ServerTemplateEditor)getRoot().
- getEditor(ServerTemplateEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ServerTemplateEditor();
- }
-
- public void destroy()
- {
- ServerTemplates serverTemplates = (ServerTemplates)_parent;
-
- if(_ephemeral)
- {
- serverTemplates.removeChild(this);
- }
- else
- {
- serverTemplates.removeDescriptor(_id);
- getRoot().removeServerInstances(_id);
- serverTemplates.removeChild(this);
- serverTemplates.getEditable().
- removeElement(_id, _editable, ServerTemplate.class);
- getRoot().updated();
- }
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- public Object getDescriptor()
- {
- return _templateDescriptor;
- }
-
- CommunicatorDescriptor getCommunicatorDescriptor()
- {
- return _templateDescriptor.descriptor;
- }
-
-
- public Object saveDescriptor()
- {
- //
- // Shallow copy
- //
- TemplateDescriptor clone = (TemplateDescriptor)_templateDescriptor.clone();
- clone.descriptor = (ServerDescriptor)_templateDescriptor.descriptor.clone();
- return clone;
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- TemplateDescriptor clone = (TemplateDescriptor)savedDescriptor;
- //
- // Keep the same object
- //
- _templateDescriptor.parameters = clone.parameters;
-
- PlainServer.shallowRestore((ServerDescriptor)clone.descriptor,
- (ServerDescriptor)_templateDescriptor.descriptor);
- }
-
- //
- // Application is needed to lookup service templates
- //
- ServerTemplate(boolean brandNew, ServerTemplates parent, String name, TemplateDescriptor descriptor)
- throws UpdateFailedException
- {
- super(parent, name);
- _editable = new Editable(brandNew);
- _ephemeral = false;
- rebuild(descriptor);
- }
-
- ServerTemplate(ServerTemplates parent, String name, TemplateDescriptor descriptor)
- {
- super(parent, name);
- _ephemeral = true;
- try
- {
- rebuild(descriptor);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("id", _id));
- writer.writeStartTag("server-template", attributes);
- writeParameters(writer, _templateDescriptor.parameters,
- _templateDescriptor.parameterDefaults);
-
- if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor descriptor = (IceBoxDescriptor)_templateDescriptor.descriptor;
-
- writer.writeStartTag("icebox",
- PlainServer.createAttributes(descriptor));
-
- if(descriptor.description.length() > 0)
- {
- writer.writeElement("description", descriptor.description);
- }
- PlainServer.writeOptions(writer, descriptor.options);
- PlainServer.writeEnvs(writer, descriptor.envs);
-
- writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
- writeDistribution(writer, descriptor.distrib);
-
- _adapters.write(writer);
- _services.write(writer);
- writer.writeEndTag("icebox");
- }
- else
- {
- ServerDescriptor descriptor = (ServerDescriptor)_templateDescriptor.descriptor;
-
- writer.writeStartTag("server",
- PlainServer.createAttributes(descriptor));
-
- if(descriptor.description.length() > 0)
- {
- writer.writeElement("description", descriptor.description);
- }
- PlainServer.writeOptions(writer, descriptor.options);
- PlainServer.writeEnvs(writer, descriptor.envs);
-
- writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
- writeDistribution(writer, descriptor.distrib);
-
- _adapters.write(writer);
- _dbEnvs.write(writer);
- writer.writeEndTag("server");
- }
- writer.writeEndTag("server-template");
- }
- }
-
-
- boolean isIceBox()
- {
- return _templateDescriptor.descriptor instanceof IceBoxDescriptor;
- }
-
- void rebuild(TemplateDescriptor descriptor) throws UpdateFailedException
- {
- _templateDescriptor = descriptor;
-
- _adapters.clear();
- _dbEnvs.clear();
- _services.clear();
-
- if(!_ephemeral)
- {
- _adapters.init(_templateDescriptor.descriptor.adapters);
-
- if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor iceBoxDescriptor =
- (IceBoxDescriptor)_templateDescriptor.descriptor;
-
- _services.init(iceBoxDescriptor.services);
-
- assert _templateDescriptor.descriptor.dbEnvs.size() == 0;
- }
- else
- {
- _dbEnvs.init(_templateDescriptor.descriptor.dbEnvs);
- }
- }
- }
-
- void rebuild() throws UpdateFailedException
- {
- rebuild(_templateDescriptor);
- }
-
- void commit()
- {
- _editable.commit();
- }
-
- Editable getEditable()
- {
- return _editable;
- }
-
- Editable getEnclosingEditable()
- {
- return _editable;
- }
-
- java.util.List findInstances()
- {
- return getRoot().findServerInstances(_id);
- }
-
- private TemplateDescriptor _templateDescriptor;
- private final boolean _ephemeral;
- private Editable _editable;
- private ServerTemplateEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon _plainIcon;
- static private Icon _iceboxIcon;
-
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 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.JComponent;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+
+class ServerTemplate extends Communicator
+{
+ static public TemplateDescriptor
+ copyDescriptor(TemplateDescriptor templateDescriptor)
+ {
+ TemplateDescriptor copy = (TemplateDescriptor)
+ templateDescriptor.clone();
+
+ copy.descriptor = PlainServer.copyDescriptor(
+ (ServerDescriptor)copy.descriptor);
+ return copy;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _plainIcon =
+ Utils.getIcon("/icons/16x16/server_template.png");
+ _iceboxIcon =
+ Utils.getIcon("/icons/16x16/icebox_server_template.png");
+ }
+
+ if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
+ {
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(_iceboxIcon);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(_iceboxIcon);
+ }
+ }
+ else
+ {
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(_plainIcon);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(_plainIcon);
+ }
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+
+ actions[DELETE] = true;
+
+ actions[NEW_ADAPTER] = !_services.initialized();
+ actions[NEW_SERVICE] = _services.initialized();
+ actions[NEW_SERVICE_FROM_TEMPLATE] = _services.initialized();
+ actions[NEW_DBENV] = _dbEnvs.initialized();
+
+ return actions;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_templateDescriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_ADAPTER));
+ _popup.add(actions.get(NEW_DBENV));
+ _popup.add(actions.get(NEW_SERVICE));
+ _popup.add(actions.get(NEW_SERVICE_FROM_TEMPLATE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ServerTemplateEditor)getRoot().
+ getEditor(ServerTemplateEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ServerTemplateEditor();
+ }
+
+ public void destroy()
+ {
+ ServerTemplates serverTemplates = (ServerTemplates)_parent;
+
+ if(_ephemeral)
+ {
+ serverTemplates.removeChild(this);
+ }
+ else
+ {
+ serverTemplates.removeDescriptor(_id);
+ getRoot().removeServerInstances(_id);
+ serverTemplates.removeChild(this);
+ serverTemplates.getEditable().
+ removeElement(_id, _editable, ServerTemplate.class);
+ getRoot().updated();
+ }
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ public Object getDescriptor()
+ {
+ return _templateDescriptor;
+ }
+
+ CommunicatorDescriptor getCommunicatorDescriptor()
+ {
+ return _templateDescriptor.descriptor;
+ }
+
+
+ public Object saveDescriptor()
+ {
+ //
+ // Shallow copy
+ //
+ TemplateDescriptor clone = (TemplateDescriptor)_templateDescriptor.clone();
+ clone.descriptor = (ServerDescriptor)_templateDescriptor.descriptor.clone();
+ return clone;
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ TemplateDescriptor clone = (TemplateDescriptor)savedDescriptor;
+ //
+ // Keep the same object
+ //
+ _templateDescriptor.parameters = clone.parameters;
+
+ PlainServer.shallowRestore((ServerDescriptor)clone.descriptor,
+ (ServerDescriptor)_templateDescriptor.descriptor);
+ }
+
+ //
+ // Application is needed to lookup service templates
+ //
+ ServerTemplate(boolean brandNew, ServerTemplates parent, String name, TemplateDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ super(parent, name);
+ _editable = new Editable(brandNew);
+ _ephemeral = false;
+ rebuild(descriptor);
+ }
+
+ ServerTemplate(ServerTemplates parent, String name, TemplateDescriptor descriptor)
+ {
+ super(parent, name);
+ _ephemeral = true;
+ try
+ {
+ rebuild(descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("id", _id));
+ writer.writeStartTag("server-template", attributes);
+ writeParameters(writer, _templateDescriptor.parameters,
+ _templateDescriptor.parameterDefaults);
+
+ if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor descriptor = (IceBoxDescriptor)_templateDescriptor.descriptor;
+
+ writer.writeStartTag("icebox",
+ PlainServer.createAttributes(descriptor));
+
+ if(descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", descriptor.description);
+ }
+ PlainServer.writeOptions(writer, descriptor.options);
+ PlainServer.writeEnvs(writer, descriptor.envs);
+
+ writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
+ writeDistribution(writer, descriptor.distrib);
+
+ _adapters.write(writer);
+ _services.write(writer);
+ writer.writeEndTag("icebox");
+ }
+ else
+ {
+ ServerDescriptor descriptor = (ServerDescriptor)_templateDescriptor.descriptor;
+
+ writer.writeStartTag("server",
+ PlainServer.createAttributes(descriptor));
+
+ if(descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", descriptor.description);
+ }
+ PlainServer.writeOptions(writer, descriptor.options);
+ PlainServer.writeEnvs(writer, descriptor.envs);
+
+ writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
+ writeDistribution(writer, descriptor.distrib);
+
+ _adapters.write(writer);
+ _dbEnvs.write(writer);
+ writer.writeEndTag("server");
+ }
+ writer.writeEndTag("server-template");
+ }
+ }
+
+
+ boolean isIceBox()
+ {
+ return _templateDescriptor.descriptor instanceof IceBoxDescriptor;
+ }
+
+ void rebuild(TemplateDescriptor descriptor) throws UpdateFailedException
+ {
+ _templateDescriptor = descriptor;
+
+ _adapters.clear();
+ _dbEnvs.clear();
+ _services.clear();
+
+ if(!_ephemeral)
+ {
+ _adapters.init(_templateDescriptor.descriptor.adapters);
+
+ if(_templateDescriptor.descriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor iceBoxDescriptor =
+ (IceBoxDescriptor)_templateDescriptor.descriptor;
+
+ _services.init(iceBoxDescriptor.services);
+
+ assert _templateDescriptor.descriptor.dbEnvs.size() == 0;
+ }
+ else
+ {
+ _dbEnvs.init(_templateDescriptor.descriptor.dbEnvs);
+ }
+ }
+ }
+
+ void rebuild() throws UpdateFailedException
+ {
+ rebuild(_templateDescriptor);
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ }
+
+ Editable getEditable()
+ {
+ return _editable;
+ }
+
+ Editable getEnclosingEditable()
+ {
+ return _editable;
+ }
+
+ java.util.List findInstances()
+ {
+ return getRoot().findServerInstances(_id);
+ }
+
+ private TemplateDescriptor _templateDescriptor;
+ private final boolean _ephemeral;
+ private Editable _editable;
+ private ServerTemplateEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private Icon _plainIcon;
+ static private Icon _iceboxIcon;
+
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/ServerTemplateEditor.java b/java/src/IceGridGUI/Application/ServerTemplateEditor.java
index d74211b7f28..5f9f8c36798 100755
--- a/java/src/IceGridGUI/Application/ServerTemplateEditor.java
+++ b/java/src/IceGridGUI/Application/ServerTemplateEditor.java
@@ -1,64 +1,64 @@
-// **********************************************************************
-//
-// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
-
-class ServerTemplateEditor extends TemplateEditor
-{
- ServerTemplateEditor()
- {
- _subEditor = new ServerSubEditor(this);
- }
-
- void writeDescriptor()
- {
- super.writeDescriptor();
- _subEditor.writeDescriptor();
- }
-
- boolean isSimpleUpdate()
- {
- return super.isSimpleUpdate() && _subEditor.isSimpleUpdate();
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- super.appendProperties(builder);
- builder.appendSeparator();
- builder.nextLine();
- _subEditor.appendProperties(builder);
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Server Template Properties");
- }
-
- protected boolean validate()
- {
- return super.validate() && _subEditor.validate();
- }
-
- void show(ServerTemplate t)
- {
- detectUpdates(false);
- _target = t;
-
- super.show();
- _subEditor.show(true);
-
- _applyButton.setEnabled(t.isEphemeral());
- _discardButton.setEnabled(t.isEphemeral());
- detectUpdates(true);
- }
-
- private ServerSubEditor _subEditor;
-}
+// **********************************************************************
+//
+// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
+
+class ServerTemplateEditor extends TemplateEditor
+{
+ ServerTemplateEditor()
+ {
+ _subEditor = new ServerSubEditor(this);
+ }
+
+ void writeDescriptor()
+ {
+ super.writeDescriptor();
+ _subEditor.writeDescriptor();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return super.isSimpleUpdate() && _subEditor.isSimpleUpdate();
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ super.appendProperties(builder);
+ builder.appendSeparator();
+ builder.nextLine();
+ _subEditor.appendProperties(builder);
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Server Template Properties");
+ }
+
+ protected boolean validate()
+ {
+ return super.validate() && _subEditor.validate();
+ }
+
+ void show(ServerTemplate t)
+ {
+ detectUpdates(false);
+ _target = t;
+
+ super.show();
+ _subEditor.show(true);
+
+ _applyButton.setEnabled(t.isEphemeral());
+ _discardButton.setEnabled(t.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private ServerSubEditor _subEditor;
+}
diff --git a/java/src/IceGridGUI/Application/ServerTemplates.java b/java/src/IceGridGUI/Application/ServerTemplates.java
index 940ec4628ce..d93eae4dd1c 100755
--- a/java/src/IceGridGUI/Application/ServerTemplates.java
+++ b/java/src/IceGridGUI/Application/ServerTemplates.java
@@ -1,274 +1,274 @@
-// **********************************************************************
-//
-// 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.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServerTemplates extends Templates
-{
- static public java.util.Map
- copyDescriptors(java.util.Map descriptors)
- {
- java.util.Map copy = new java.util.HashMap();
- java.util.Iterator p = descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- copy.put(entry.getKey(),
- ServerTemplate.copyDescriptor(
- (TemplateDescriptor)entry.getValue()));
- }
- return copy;
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[NEW_TEMPLATE_SERVER] = true;
- actions[NEW_TEMPLATE_SERVER_ICEBOX] = true;
-
- Object clipboard = getCoordinator().getClipboard();
- if(clipboard != null && clipboard instanceof TemplateDescriptor)
- {
- TemplateDescriptor d = (TemplateDescriptor)clipboard;
- actions[PASTE] = d.descriptor instanceof ServerDescriptor;
- }
- return actions;
- }
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_TEMPLATE_SERVER));
- _popup.add(actions.get(NEW_TEMPLATE_SERVER_ICEBOX));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public void newTemplateServer()
- {
- newServerTemplate(new TemplateDescriptor(
- PlainServer.newServerDescriptor(),
- new java.util.LinkedList(),
- new java.util.TreeMap()));
- }
- public void newTemplateServerIceBox()
- {
- newServerTemplate(new TemplateDescriptor(
- PlainServer.newIceBoxDescriptor(),
- new java.util.LinkedList(),
- new java.util.TreeMap()));
- }
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
- TemplateDescriptor td = (TemplateDescriptor)descriptor;
- newServerTemplate(td);
- }
-
-
- ServerTemplates(Root parent, java.util.Map descriptors)
- throws UpdateFailedException
- {
- super(parent, "Server templates");
-
- _descriptors = descriptors;
-
- java.util.Iterator p = _descriptors.entrySet().iterator();
-
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- insertChild(new ServerTemplate(false, this,
- (String)entry.getKey(),
- (TemplateDescriptor)entry.getValue()),
- false);
- }
- }
-
- //
- // Variable resolution does not make sense for templates / template children
- //
- Utils.Resolver getResolver()
- {
- return null;
- }
-
- java.util.Map getUpdates()
- {
- java.util.Map updates = new java.util.HashMap();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServerTemplate t = (ServerTemplate)p.next();
- if(t.getEditable().isNew() || t.getEditable().isModified())
- {
- updates.put(t.getId(), t.getDescriptor());
- }
- }
- return updates;
- }
-
- void commit()
- {
- _editable.commit();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServerTemplate st = (ServerTemplate)p.next();
- st.commit();
- }
- }
-
- java.util.List findServiceInstances(String template)
- {
- java.util.List result = new java.util.LinkedList();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServerTemplate t = (ServerTemplate)p.next();
- result.addAll(t.findServiceInstances(template));
- }
- return result;
- }
-
- void removeServiceInstances(String template)
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServerTemplate t = (ServerTemplate)p.next();
- t.removeServiceInstances(template);
- }
- }
-
- void newServerTemplate(TemplateDescriptor descriptor)
- {
- String id;
- if(descriptor.descriptor instanceof IceBoxDescriptor)
- {
- id = makeNewChildId("NewIceBoxTemplate");
- }
- else
- {
- id = makeNewChildId("NewServerTemplate");
- }
-
- ServerTemplate t = new ServerTemplate(this, id, descriptor);
- try
- {
- insertChild(t, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(t);
- }
-
- void tryAdd(String newId, TemplateDescriptor descriptor)
- throws UpdateFailedException
- {
- insertChild(new ServerTemplate(true, this, newId, descriptor),
- true);
- _descriptors.put(newId, descriptor);
- }
-
- void update(java.util.Map updates, String[] removeTemplates,
- java.util.Set serviceTemplates)
- throws UpdateFailedException
- {
- //
- // Note: _descriptors is updated by Root
- //
-
- Root root = getRoot();
-
- //
- // One big set of removes
- //
- removeChildren(removeTemplates);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
- java.util.Vector updatedChildren = new java.util.Vector();
-
- java.util.Iterator p = updates.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String name = (String)entry.getKey();
- TemplateDescriptor templateDescriptor
- = (TemplateDescriptor)entry.getValue();
- ServerTemplate child = (ServerTemplate)findChild(name);
- if(child == null)
- {
- newChildren.add(new ServerTemplate(false, this, name, templateDescriptor));
- }
- else
- {
- child.rebuild(templateDescriptor);
- updatedChildren.add(child);
- }
- }
-
- //
- // Rebuild template affected by service template updates
- //
- p = serviceTemplates.iterator();
- while(p.hasNext())
- {
- java.util.List serviceInstances =
- findServiceInstances((String)p.next());
- java.util.Iterator q = serviceInstances.iterator();
- while(q.hasNext())
- {
- ServiceInstance service = (ServiceInstance)q.next();
- ServerTemplate serverTemplate =
- (ServerTemplate)service.getParent();
-
- if(!updatedChildren.contains(serverTemplate) &&
- !newChildren.contains(serverTemplate))
- {
- serverTemplate.rebuild();
- updatedChildren.add(serverTemplate);
- }
- }
- }
-
- childrenChanged(updatedChildren);
- insertChildren(newChildren, true);
- }
-
- void removeDescriptor(String id)
- {
- _descriptors.remove(id);
- }
-
- Object getDescriptor()
- {
- return _descriptors;
- }
-
- private java.util.Map _descriptors;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServerTemplates extends Templates
+{
+ static public java.util.Map
+ copyDescriptors(java.util.Map descriptors)
+ {
+ java.util.Map copy = new java.util.HashMap();
+ java.util.Iterator p = descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ copy.put(entry.getKey(),
+ ServerTemplate.copyDescriptor(
+ (TemplateDescriptor)entry.getValue()));
+ }
+ return copy;
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[NEW_TEMPLATE_SERVER] = true;
+ actions[NEW_TEMPLATE_SERVER_ICEBOX] = true;
+
+ Object clipboard = getCoordinator().getClipboard();
+ if(clipboard != null && clipboard instanceof TemplateDescriptor)
+ {
+ TemplateDescriptor d = (TemplateDescriptor)clipboard;
+ actions[PASTE] = d.descriptor instanceof ServerDescriptor;
+ }
+ return actions;
+ }
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_TEMPLATE_SERVER));
+ _popup.add(actions.get(NEW_TEMPLATE_SERVER_ICEBOX));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public void newTemplateServer()
+ {
+ newServerTemplate(new TemplateDescriptor(
+ PlainServer.newServerDescriptor(),
+ new java.util.LinkedList(),
+ new java.util.TreeMap()));
+ }
+ public void newTemplateServerIceBox()
+ {
+ newServerTemplate(new TemplateDescriptor(
+ PlainServer.newIceBoxDescriptor(),
+ new java.util.LinkedList(),
+ new java.util.TreeMap()));
+ }
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+ TemplateDescriptor td = (TemplateDescriptor)descriptor;
+ newServerTemplate(td);
+ }
+
+
+ ServerTemplates(Root parent, java.util.Map descriptors)
+ throws UpdateFailedException
+ {
+ super(parent, "Server templates");
+
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.entrySet().iterator();
+
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ insertChild(new ServerTemplate(false, this,
+ (String)entry.getKey(),
+ (TemplateDescriptor)entry.getValue()),
+ false);
+ }
+ }
+
+ //
+ // Variable resolution does not make sense for templates / template children
+ //
+ Utils.Resolver getResolver()
+ {
+ return null;
+ }
+
+ java.util.Map getUpdates()
+ {
+ java.util.Map updates = new java.util.HashMap();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerTemplate t = (ServerTemplate)p.next();
+ if(t.getEditable().isNew() || t.getEditable().isModified())
+ {
+ updates.put(t.getId(), t.getDescriptor());
+ }
+ }
+ return updates;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerTemplate st = (ServerTemplate)p.next();
+ st.commit();
+ }
+ }
+
+ java.util.List findServiceInstances(String template)
+ {
+ java.util.List result = new java.util.LinkedList();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerTemplate t = (ServerTemplate)p.next();
+ result.addAll(t.findServiceInstances(template));
+ }
+ return result;
+ }
+
+ void removeServiceInstances(String template)
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServerTemplate t = (ServerTemplate)p.next();
+ t.removeServiceInstances(template);
+ }
+ }
+
+ void newServerTemplate(TemplateDescriptor descriptor)
+ {
+ String id;
+ if(descriptor.descriptor instanceof IceBoxDescriptor)
+ {
+ id = makeNewChildId("NewIceBoxTemplate");
+ }
+ else
+ {
+ id = makeNewChildId("NewServerTemplate");
+ }
+
+ ServerTemplate t = new ServerTemplate(this, id, descriptor);
+ try
+ {
+ insertChild(t, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(t);
+ }
+
+ void tryAdd(String newId, TemplateDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ insertChild(new ServerTemplate(true, this, newId, descriptor),
+ true);
+ _descriptors.put(newId, descriptor);
+ }
+
+ void update(java.util.Map updates, String[] removeTemplates,
+ java.util.Set serviceTemplates)
+ throws UpdateFailedException
+ {
+ //
+ // Note: _descriptors is updated by Root
+ //
+
+ Root root = getRoot();
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removeTemplates);
+
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+ java.util.Vector updatedChildren = new java.util.Vector();
+
+ java.util.Iterator p = updates.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ String name = (String)entry.getKey();
+ TemplateDescriptor templateDescriptor
+ = (TemplateDescriptor)entry.getValue();
+ ServerTemplate child = (ServerTemplate)findChild(name);
+ if(child == null)
+ {
+ newChildren.add(new ServerTemplate(false, this, name, templateDescriptor));
+ }
+ else
+ {
+ child.rebuild(templateDescriptor);
+ updatedChildren.add(child);
+ }
+ }
+
+ //
+ // Rebuild template affected by service template updates
+ //
+ p = serviceTemplates.iterator();
+ while(p.hasNext())
+ {
+ java.util.List serviceInstances =
+ findServiceInstances((String)p.next());
+ java.util.Iterator q = serviceInstances.iterator();
+ while(q.hasNext())
+ {
+ ServiceInstance service = (ServiceInstance)q.next();
+ ServerTemplate serverTemplate =
+ (ServerTemplate)service.getParent();
+
+ if(!updatedChildren.contains(serverTemplate) &&
+ !newChildren.contains(serverTemplate))
+ {
+ serverTemplate.rebuild();
+ updatedChildren.add(serverTemplate);
+ }
+ }
+ }
+
+ childrenChanged(updatedChildren);
+ insertChildren(newChildren, true);
+ }
+
+ void removeDescriptor(String id)
+ {
+ _descriptors.remove(id);
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptors;
+ }
+
+ private java.util.Map _descriptors;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/Service.java b/java/src/IceGridGUI/Application/Service.java
index 8ea476fda5c..f1e15ae15c4 100755
--- a/java/src/IceGridGUI/Application/Service.java
+++ b/java/src/IceGridGUI/Application/Service.java
@@ -1,12 +1,12 @@
-// **********************************************************************
-//
-// 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;
-
-interface Service extends TemplateInstance, DescriptorHolder
-{}
+// **********************************************************************
+//
+// 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;
+
+interface Service extends TemplateInstance, DescriptorHolder
+{}
diff --git a/java/src/IceGridGUI/Application/ServiceInstance.java b/java/src/IceGridGUI/Application/ServiceInstance.java
index 9122e091f1b..eb31872424d 100755
--- a/java/src/IceGridGUI/Application/ServiceInstance.java
+++ b/java/src/IceGridGUI/Application/ServiceInstance.java
@@ -1,358 +1,358 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceInstance extends TreeNode implements Service, Cloneable
-{
- static public ServiceInstanceDescriptor
- copyDescriptor(ServiceInstanceDescriptor instanceDescriptor)
- {
- ServiceInstanceDescriptor copy = (ServiceInstanceDescriptor)
- instanceDescriptor.clone();
-
- copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
-
- if(copy.descriptor != null)
- {
- copy.descriptor = PlainService.copyDescriptor((ServiceDescriptor)copy.descriptor);
- }
- return copy;
- }
-
- static public java.util.List
- copyDescriptors(java.util.List descriptors)
- {
- java.util.List copy = new java.util.LinkedList();
- java.util.Iterator p = descriptors.iterator();
- while(p.hasNext())
- {
- copy.add(copyDescriptor(
- (ServiceInstanceDescriptor)p.next()));
- }
- return copy;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(
- Utils.getIcon("/icons/16x16/service.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
-
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
-
- actions[DELETE] = true;
-
- if(_parent instanceof Server && !_ephemeral)
- {
- actions[SHOW_VARS] = true;
- actions[SUBSTITUTE_VARS] = true;
- }
-
- actions[MOVE_UP] = canMove(true);
- actions[MOVE_DOWN] = canMove(false);
- return actions;
- }
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(MOVE_UP));
- _popup.add(actions.get(MOVE_DOWN));
- }
- actions.setTarget(this);
- return _popup;
- }
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_descriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
-
- public void moveUp()
- {
- move(true);
- }
- public void moveDown()
- {
- move(false);
- }
-
- public Object getDescriptor()
- {
- return _descriptor;
- }
-
- public Object saveDescriptor()
- {
- //
- // Must be a shallow copy
- //
- ServiceInstanceDescriptor saved =
- (ServiceInstanceDescriptor)_descriptor.clone();
-
-
- assert saved.descriptor == null;
- return saved;
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- ServiceInstanceDescriptor sd = (ServiceInstanceDescriptor)savedDescriptor;
- _descriptor.template = sd.template;
- _descriptor.parameterValues = sd.parameterValues;
- _descriptor.propertySet = sd.propertySet;
- }
-
- public void destroy()
- {
- ((Communicator)_parent).getServices().destroyChild(this);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ServiceInstanceEditor)getRoot().
- getEditor(ServiceInstanceEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ServiceInstanceEditor();
- }
-
- public String toString()
- {
- if(_displayString != null)
- {
- return _displayString;
- }
- else
- {
- return super.toString();
- }
- }
-
- private boolean canMove(boolean up)
- {
- if(_ephemeral)
- {
- return false;
- }
- else
- {
- return ((Communicator)_parent).getServices().canMove(this, up);
- }
- }
-
- private void move(boolean up)
- {
- assert canMove(up);
- ((Communicator)_parent).getServices().move(this, up);
- }
-
- Editable getEnclosingEditable()
- {
- return ((Communicator)_parent).getEnclosingEditable();
- }
-
- static private class Backup
- {
- java.util.Map parameterValues;
- ServiceInstance clone;
- }
-
- public Object rebuild(java.util.List editables)
- throws UpdateFailedException
- {
- Backup backup = new Backup();
-
- //
- // Fix-up _descriptor if necessary
- //
- if(_descriptor.template.length() > 0)
- {
- TemplateDescriptor templateDescriptor
- = getRoot().findServiceTemplateDescriptor(_descriptor.template);
-
- java.util.Set parameters = new java.util.HashSet(templateDescriptor.parameters);
- if(!parameters.equals(_descriptor.parameterValues.keySet()))
- {
- backup.parameterValues = _descriptor.parameterValues;
- _descriptor.parameterValues = Editor.makeParameterValues(
- _descriptor.parameterValues, templateDescriptor.parameters);
- editables.add(getEnclosingEditable());
- }
- }
-
- Communicator communicator = (Communicator)_parent;
- Communicator.Services services = communicator.getServices();
- ServiceInstance newService = null;
-
- try
- {
- newService = (ServiceInstance)services.createChild(_descriptor);
- }
- catch(UpdateFailedException e)
- {
- if(backup.parameterValues != null)
- {
- _descriptor.parameterValues = backup.parameterValues;
- }
- throw e;
- }
-
- try
- {
- backup.clone = (ServiceInstance)clone();
- }
- catch(CloneNotSupportedException e)
- {
- assert false;
- }
-
- reset(newService);
-
- if(backup.parameterValues != null)
- {
- editables.add(getEnclosingEditable());
- }
- getRoot().getTreeModel().nodeChanged(this);
- return backup;
- }
-
- public void restore(Object backupObj)
- {
- Backup backup = (Backup)backupObj;
-
- if(backup.parameterValues != null)
- {
- _descriptor.parameterValues = backup.parameterValues;
- }
-
- reset(backup.clone);
- getRoot().getTreeModel().nodeChanged(this);
- }
-
- private void reset(ServiceInstance from)
- {
- _id = from._id;
- _displayString = from._displayString;
- _resolver = from._resolver;
- }
-
- ServiceInstance(Communicator parent,
- String name,
- String displayString,
- ServiceInstanceDescriptor instanceDescriptor,
- Utils.Resolver resolver)
- throws UpdateFailedException
- {
- super(parent, name);
- _displayString = displayString;
- _descriptor = instanceDescriptor;
- _ephemeral = false;
- _resolver = resolver;
- }
-
- //
- // New temporary object
- //
- ServiceInstance(Communicator parent, String name,
- ServiceInstanceDescriptor instanceDescriptor)
- {
- super(parent, name);
- _descriptor = instanceDescriptor;
- _ephemeral = true;
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- TemplateDescriptor templateDescriptor
- = getRoot().findServiceTemplateDescriptor(_descriptor.template);
-
- java.util.LinkedList attributes = parameterValuesToAttributes(
- _descriptor.parameterValues, templateDescriptor.parameters);
- attributes.addFirst(createAttribute("template", _descriptor.template));
-
- if(_descriptor.propertySet.references.length == 0 &&
- _descriptor.propertySet.properties.size() == 0)
- {
- writer.writeElement("service-instance", attributes);
- }
- else
- {
- writer.writeStartTag("service-instance", attributes);
- writePropertySet(writer, "", _descriptor.propertySet, null);
- writer.writeEndTag("service-instance");
- }
- }
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- private ServiceInstanceDescriptor _descriptor;
-
- private String _displayString;
- private final boolean _ephemeral;
-
- private Utils.Resolver _resolver;
- private ServiceInstanceEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceInstance extends TreeNode implements Service, Cloneable
+{
+ static public ServiceInstanceDescriptor
+ copyDescriptor(ServiceInstanceDescriptor instanceDescriptor)
+ {
+ ServiceInstanceDescriptor copy = (ServiceInstanceDescriptor)
+ instanceDescriptor.clone();
+
+ copy.propertySet = PropertySet.copyDescriptor(copy.propertySet);
+
+ if(copy.descriptor != null)
+ {
+ copy.descriptor = PlainService.copyDescriptor((ServiceDescriptor)copy.descriptor);
+ }
+ return copy;
+ }
+
+ static public java.util.List
+ copyDescriptors(java.util.List descriptors)
+ {
+ java.util.List copy = new java.util.LinkedList();
+ java.util.Iterator p = descriptors.iterator();
+ while(p.hasNext())
+ {
+ copy.add(copyDescriptor(
+ (ServiceInstanceDescriptor)p.next()));
+ }
+ return copy;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(
+ Utils.getIcon("/icons/16x16/service.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+
+ actions[DELETE] = true;
+
+ if(_parent instanceof Server && !_ephemeral)
+ {
+ actions[SHOW_VARS] = true;
+ actions[SUBSTITUTE_VARS] = true;
+ }
+
+ actions[MOVE_UP] = canMove(true);
+ actions[MOVE_DOWN] = canMove(false);
+ return actions;
+ }
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(MOVE_UP));
+ _popup.add(actions.get(MOVE_DOWN));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_descriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+
+ public void moveUp()
+ {
+ move(true);
+ }
+ public void moveDown()
+ {
+ move(false);
+ }
+
+ public Object getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ public Object saveDescriptor()
+ {
+ //
+ // Must be a shallow copy
+ //
+ ServiceInstanceDescriptor saved =
+ (ServiceInstanceDescriptor)_descriptor.clone();
+
+
+ assert saved.descriptor == null;
+ return saved;
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ ServiceInstanceDescriptor sd = (ServiceInstanceDescriptor)savedDescriptor;
+ _descriptor.template = sd.template;
+ _descriptor.parameterValues = sd.parameterValues;
+ _descriptor.propertySet = sd.propertySet;
+ }
+
+ public void destroy()
+ {
+ ((Communicator)_parent).getServices().destroyChild(this);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ServiceInstanceEditor)getRoot().
+ getEditor(ServiceInstanceEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ServiceInstanceEditor();
+ }
+
+ public String toString()
+ {
+ if(_displayString != null)
+ {
+ return _displayString;
+ }
+ else
+ {
+ return super.toString();
+ }
+ }
+
+ private boolean canMove(boolean up)
+ {
+ if(_ephemeral)
+ {
+ return false;
+ }
+ else
+ {
+ return ((Communicator)_parent).getServices().canMove(this, up);
+ }
+ }
+
+ private void move(boolean up)
+ {
+ assert canMove(up);
+ ((Communicator)_parent).getServices().move(this, up);
+ }
+
+ Editable getEnclosingEditable()
+ {
+ return ((Communicator)_parent).getEnclosingEditable();
+ }
+
+ static private class Backup
+ {
+ java.util.Map parameterValues;
+ ServiceInstance clone;
+ }
+
+ public Object rebuild(java.util.List editables)
+ throws UpdateFailedException
+ {
+ Backup backup = new Backup();
+
+ //
+ // Fix-up _descriptor if necessary
+ //
+ if(_descriptor.template.length() > 0)
+ {
+ TemplateDescriptor templateDescriptor
+ = getRoot().findServiceTemplateDescriptor(_descriptor.template);
+
+ java.util.Set parameters = new java.util.HashSet(templateDescriptor.parameters);
+ if(!parameters.equals(_descriptor.parameterValues.keySet()))
+ {
+ backup.parameterValues = _descriptor.parameterValues;
+ _descriptor.parameterValues = Editor.makeParameterValues(
+ _descriptor.parameterValues, templateDescriptor.parameters);
+ editables.add(getEnclosingEditable());
+ }
+ }
+
+ Communicator communicator = (Communicator)_parent;
+ Communicator.Services services = communicator.getServices();
+ ServiceInstance newService = null;
+
+ try
+ {
+ newService = (ServiceInstance)services.createChild(_descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ if(backup.parameterValues != null)
+ {
+ _descriptor.parameterValues = backup.parameterValues;
+ }
+ throw e;
+ }
+
+ try
+ {
+ backup.clone = (ServiceInstance)clone();
+ }
+ catch(CloneNotSupportedException e)
+ {
+ assert false;
+ }
+
+ reset(newService);
+
+ if(backup.parameterValues != null)
+ {
+ editables.add(getEnclosingEditable());
+ }
+ getRoot().getTreeModel().nodeChanged(this);
+ return backup;
+ }
+
+ public void restore(Object backupObj)
+ {
+ Backup backup = (Backup)backupObj;
+
+ if(backup.parameterValues != null)
+ {
+ _descriptor.parameterValues = backup.parameterValues;
+ }
+
+ reset(backup.clone);
+ getRoot().getTreeModel().nodeChanged(this);
+ }
+
+ private void reset(ServiceInstance from)
+ {
+ _id = from._id;
+ _displayString = from._displayString;
+ _resolver = from._resolver;
+ }
+
+ ServiceInstance(Communicator parent,
+ String name,
+ String displayString,
+ ServiceInstanceDescriptor instanceDescriptor,
+ Utils.Resolver resolver)
+ throws UpdateFailedException
+ {
+ super(parent, name);
+ _displayString = displayString;
+ _descriptor = instanceDescriptor;
+ _ephemeral = false;
+ _resolver = resolver;
+ }
+
+ //
+ // New temporary object
+ //
+ ServiceInstance(Communicator parent, String name,
+ ServiceInstanceDescriptor instanceDescriptor)
+ {
+ super(parent, name);
+ _descriptor = instanceDescriptor;
+ _ephemeral = true;
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ TemplateDescriptor templateDescriptor
+ = getRoot().findServiceTemplateDescriptor(_descriptor.template);
+
+ java.util.LinkedList attributes = parameterValuesToAttributes(
+ _descriptor.parameterValues, templateDescriptor.parameters);
+ attributes.addFirst(createAttribute("template", _descriptor.template));
+
+ if(_descriptor.propertySet.references.length == 0 &&
+ _descriptor.propertySet.properties.size() == 0)
+ {
+ writer.writeElement("service-instance", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("service-instance", attributes);
+ writePropertySet(writer, "", _descriptor.propertySet, null);
+ writer.writeEndTag("service-instance");
+ }
+ }
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ private ServiceInstanceDescriptor _descriptor;
+
+ private String _displayString;
+ private final boolean _ephemeral;
+
+ private Utils.Resolver _resolver;
+ private ServiceInstanceEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/ServiceInstanceEditor.java b/java/src/IceGridGUI/Application/ServiceInstanceEditor.java
index 5d03bdadffa..b59efc5d853 100755
--- a/java/src/IceGridGUI/Application/ServiceInstanceEditor.java
+++ b/java/src/IceGridGUI/Application/ServiceInstanceEditor.java
@@ -1,238 +1,238 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceInstanceEditor extends CommunicatorChildEditor
-{
- ServiceInstanceEditor()
- {
- //
- // Template
- //
- Action gotoTemplate = new AbstractAction(
- "", Utils.getIcon("/icons/16x16/goto.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- TreeNode t = (TreeNode)_template.getSelectedItem();
- if(t != null)
- {
- t.getRoot().setSelectedNode(t);
- }
- }
- };
- gotoTemplate.putValue(Action.SHORT_DESCRIPTION,
- "Goto this service template");
- _templateButton = new JButton(gotoTemplate);
-
- _parameters = new ParameterValuesField(this);
-
- _propertySets.getDocument().addDocumentListener(_updateListener);
- _propertySets.setToolTipText("Property Set References");
- _properties = new PropertiesField(this);
- }
-
- ServiceInstanceDescriptor getDescriptor()
- {
- return (ServiceInstanceDescriptor)_target.getDescriptor();
- }
-
- //
- // From Editor:
- //
- Utils.Resolver getDetailResolver()
- {
- ServiceInstance service = (ServiceInstance)_target;
- if(service.getCoordinator().substitute())
- {
- return service.getResolver();
- }
- else
- {
- return null;
- }
- }
-
- void writeDescriptor()
- {
- ServiceInstanceDescriptor descriptor = getDescriptor();
- descriptor.template = ((ServiceTemplate)_template.getSelectedItem()).getId();
- descriptor.parameterValues = _parameters.getValues();
-
- descriptor.propertySet.references =
- (String[])_propertySets.getList().toArray(new String[0]);
- descriptor.propertySet.properties = _properties.getProperties();
- }
-
- boolean isSimpleUpdate()
- {
- ServiceInstanceDescriptor descriptor = getDescriptor();
- ServiceTemplate t = (ServiceTemplate)_template.getSelectedItem();
-
- return descriptor.template.equals(t.getId())
- && descriptor.parameterValues.equals(_parameters.getValues());
- }
-
- Communicator.ChildList getChildList()
- {
- return ((Communicator)_target.getParent()).getServices();
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Template", _template);
- builder.append(_templateButton);
- builder.nextLine();
-
- builder.append("Parameters");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- JScrollPane scrollPane = new JScrollPane(_parameters);
- CellConstraints cc = new CellConstraints();
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Property Sets");
- builder.append(_propertySets, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Service Properties");
- }
-
- void show(ServiceInstance service)
- {
- detectUpdates(false);
- _target = service;
-
- //
- // If it's not a template instance, it's shown using
- // ServiceEditor.show()
- //
- assert getDescriptor().template.length() > 0;
-
- ServiceInstanceDescriptor descriptor =
- (ServiceInstanceDescriptor)service.getDescriptor();
- Coordinator coordinator = service.getCoordinator();
- boolean isEditable = !coordinator.substitute();
-
- Utils.Resolver resolver = isEditable ? null :
- ((TreeNode)service.getParent()).getResolver();
-
- //
- // Need to make control enabled before changing it
- //
- _template.setEnabled(true);
-
- ServiceTemplates serviceTemplates =
- service.getRoot().getServiceTemplates();
- _template.setModel(serviceTemplates.createComboBoxModel());
-
- ServiceTemplate t = (ServiceTemplate)
- serviceTemplates.findChild(descriptor.template);
- assert t != null;
- _template.setSelectedItem(t);
-
- ListDataListener templateListener = new ListDataListener()
- {
- public void contentsChanged(ListDataEvent e)
- {
- updated();
-
- ServiceTemplate t =
- (ServiceTemplate)_template.getModel().getSelectedItem();
-
- TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
-
- //
- // Replace parameters but keep existing values
- //
- _parameters.set(td.parameters,
- makeParameterValues(_parameters.getValues(), td.parameters),
- td.parameterDefaults, null);
- }
-
- public void intervalAdded(ListDataEvent e)
- {}
-
- public void intervalRemoved(ListDataEvent e)
- {}
- };
-
- _template.getModel().addListDataListener(templateListener);
- _template.setEnabled(isEditable);
-
- TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
- _parameters.set(td.parameters, descriptor.parameterValues,
- td.parameterDefaults, resolver);
-
- _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
- getDetailResolver());
- _propertySets.setEditable(isEditable);
-
- _properties.setProperties(descriptor.propertySet.properties, null,
- getDetailResolver(), isEditable);
-
- _applyButton.setEnabled(service.isEphemeral());
- _discardButton.setEnabled(service.isEphemeral());
- detectUpdates(true);
- }
-
- private JComboBox _template = new JComboBox();
- private JButton _templateButton;
- private ParameterValuesField _parameters;
- private ListTextField _propertySets = new ListTextField(20);
- private PropertiesField _properties;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceInstanceEditor extends CommunicatorChildEditor
+{
+ ServiceInstanceEditor()
+ {
+ //
+ // Template
+ //
+ Action gotoTemplate = new AbstractAction(
+ "", Utils.getIcon("/icons/16x16/goto.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ TreeNode t = (TreeNode)_template.getSelectedItem();
+ if(t != null)
+ {
+ t.getRoot().setSelectedNode(t);
+ }
+ }
+ };
+ gotoTemplate.putValue(Action.SHORT_DESCRIPTION,
+ "Goto this service template");
+ _templateButton = new JButton(gotoTemplate);
+
+ _parameters = new ParameterValuesField(this);
+
+ _propertySets.getDocument().addDocumentListener(_updateListener);
+ _propertySets.setToolTipText("Property Set References");
+ _properties = new PropertiesField(this);
+ }
+
+ ServiceInstanceDescriptor getDescriptor()
+ {
+ return (ServiceInstanceDescriptor)_target.getDescriptor();
+ }
+
+ //
+ // From Editor:
+ //
+ Utils.Resolver getDetailResolver()
+ {
+ ServiceInstance service = (ServiceInstance)_target;
+ if(service.getCoordinator().substitute())
+ {
+ return service.getResolver();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ void writeDescriptor()
+ {
+ ServiceInstanceDescriptor descriptor = getDescriptor();
+ descriptor.template = ((ServiceTemplate)_template.getSelectedItem()).getId();
+ descriptor.parameterValues = _parameters.getValues();
+
+ descriptor.propertySet.references =
+ (String[])_propertySets.getList().toArray(new String[0]);
+ descriptor.propertySet.properties = _properties.getProperties();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ ServiceInstanceDescriptor descriptor = getDescriptor();
+ ServiceTemplate t = (ServiceTemplate)_template.getSelectedItem();
+
+ return descriptor.template.equals(t.getId())
+ && descriptor.parameterValues.equals(_parameters.getValues());
+ }
+
+ Communicator.ChildList getChildList()
+ {
+ return ((Communicator)_target.getParent()).getServices();
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Template", _template);
+ builder.append(_templateButton);
+ builder.nextLine();
+
+ builder.append("Parameters");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ JScrollPane scrollPane = new JScrollPane(_parameters);
+ CellConstraints cc = new CellConstraints();
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Property Sets");
+ builder.append(_propertySets, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Service Properties");
+ }
+
+ void show(ServiceInstance service)
+ {
+ detectUpdates(false);
+ _target = service;
+
+ //
+ // If it's not a template instance, it's shown using
+ // ServiceEditor.show()
+ //
+ assert getDescriptor().template.length() > 0;
+
+ ServiceInstanceDescriptor descriptor =
+ (ServiceInstanceDescriptor)service.getDescriptor();
+ Coordinator coordinator = service.getCoordinator();
+ boolean isEditable = !coordinator.substitute();
+
+ Utils.Resolver resolver = isEditable ? null :
+ ((TreeNode)service.getParent()).getResolver();
+
+ //
+ // Need to make control enabled before changing it
+ //
+ _template.setEnabled(true);
+
+ ServiceTemplates serviceTemplates =
+ service.getRoot().getServiceTemplates();
+ _template.setModel(serviceTemplates.createComboBoxModel());
+
+ ServiceTemplate t = (ServiceTemplate)
+ serviceTemplates.findChild(descriptor.template);
+ assert t != null;
+ _template.setSelectedItem(t);
+
+ ListDataListener templateListener = new ListDataListener()
+ {
+ public void contentsChanged(ListDataEvent e)
+ {
+ updated();
+
+ ServiceTemplate t =
+ (ServiceTemplate)_template.getModel().getSelectedItem();
+
+ TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
+
+ //
+ // Replace parameters but keep existing values
+ //
+ _parameters.set(td.parameters,
+ makeParameterValues(_parameters.getValues(), td.parameters),
+ td.parameterDefaults, null);
+ }
+
+ public void intervalAdded(ListDataEvent e)
+ {}
+
+ public void intervalRemoved(ListDataEvent e)
+ {}
+ };
+
+ _template.getModel().addListDataListener(templateListener);
+ _template.setEnabled(isEditable);
+
+ TemplateDescriptor td = (TemplateDescriptor)t.getDescriptor();
+ _parameters.set(td.parameters, descriptor.parameterValues,
+ td.parameterDefaults, resolver);
+
+ _propertySets.setList(java.util.Arrays.asList(descriptor.propertySet.references),
+ getDetailResolver());
+ _propertySets.setEditable(isEditable);
+
+ _properties.setProperties(descriptor.propertySet.properties, null,
+ getDetailResolver(), isEditable);
+
+ _applyButton.setEnabled(service.isEphemeral());
+ _discardButton.setEnabled(service.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private JComboBox _template = new JComboBox();
+ private JButton _templateButton;
+ private ParameterValuesField _parameters;
+ private ListTextField _propertySets = new ListTextField(20);
+ private PropertiesField _properties;
+}
diff --git a/java/src/IceGridGUI/Application/ServiceSubEditor.java b/java/src/IceGridGUI/Application/ServiceSubEditor.java
index d1a5d249f07..c92c4dff909 100755
--- a/java/src/IceGridGUI/Application/ServiceSubEditor.java
+++ b/java/src/IceGridGUI/Application/ServiceSubEditor.java
@@ -1,110 +1,110 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceSubEditor extends CommunicatorSubEditor
-{
- ServiceSubEditor(Editor mainEditor)
- {
- super(mainEditor);
-
- _name.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _name.setToolTipText("Identifies this service within an IceBox server");
-
- _entry.getDocument().addDocumentListener(
- _mainEditor.getUpdateListener());
- _entry.setToolTipText(
- "<html>The service entry point and optional arguments.<br>"
- + "C++: <i>shared object:function-name arg1 arg2 ...</i><br>"
- + "Java: <i>class-name arg1 arg2 ...</i><br>"
- + "C#, Visual Basic: <i>assembly:class-name arg1 arg2 ...</i>"
- + "</html>");
- }
-
- ServiceDescriptor getServiceDescriptor()
- {
- return (ServiceDescriptor)
- _mainEditor.getSubDescriptor();
- }
-
- void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Service Name");
- builder.append(_name, 3);
- builder.nextLine();
-
- //
- // Add Communicator fields
- //
- super.appendProperties(builder);
-
- builder.append("Entry Point");
- builder.append(_entry, 3);
- builder.nextLine();
- }
-
- void writeDescriptor()
- {
- ServiceDescriptor descriptor = getServiceDescriptor();
- descriptor.name = _name.getText().trim();
- descriptor.entry = _entry.getText().trim();
- super.writeDescriptor(descriptor);
- }
-
- boolean isSimpleUpdate()
- {
- return getServiceDescriptor().name.equals(_name.getText().trim());
- }
-
- boolean validate()
- {
- return _mainEditor.check(new String[]{
- "Service Name", _name.getText().trim(),
- "Entry Point", _entry.getText().trim()});
- }
-
- void show(boolean isEditable)
- {
- ServiceDescriptor descriptor = getServiceDescriptor();
- Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
-
- isEditable = isEditable && (detailResolver == null);
-
- if(detailResolver != null)
- {
- _name.setText(detailResolver.find("service"));
- }
- else
- {
- _name.setText(descriptor.name);
- }
- _name.setEditable(isEditable);
-
- _entry.setText(
- Utils.substitute(descriptor.entry, detailResolver));
- _entry.setEditable(isEditable);
-
- show(descriptor, isEditable);
- }
-
- private JTextField _name = new JTextField(20);
- private JTextField _entry = new JTextField(20);
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceSubEditor extends CommunicatorSubEditor
+{
+ ServiceSubEditor(Editor mainEditor)
+ {
+ super(mainEditor);
+
+ _name.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _name.setToolTipText("Identifies this service within an IceBox server");
+
+ _entry.getDocument().addDocumentListener(
+ _mainEditor.getUpdateListener());
+ _entry.setToolTipText(
+ "<html>The service entry point and optional arguments.<br>"
+ + "C++: <i>shared object:function-name arg1 arg2 ...</i><br>"
+ + "Java: <i>class-name arg1 arg2 ...</i><br>"
+ + "C#, Visual Basic: <i>assembly:class-name arg1 arg2 ...</i>"
+ + "</html>");
+ }
+
+ ServiceDescriptor getServiceDescriptor()
+ {
+ return (ServiceDescriptor)
+ _mainEditor.getSubDescriptor();
+ }
+
+ void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Service Name");
+ builder.append(_name, 3);
+ builder.nextLine();
+
+ //
+ // Add Communicator fields
+ //
+ super.appendProperties(builder);
+
+ builder.append("Entry Point");
+ builder.append(_entry, 3);
+ builder.nextLine();
+ }
+
+ void writeDescriptor()
+ {
+ ServiceDescriptor descriptor = getServiceDescriptor();
+ descriptor.name = _name.getText().trim();
+ descriptor.entry = _entry.getText().trim();
+ super.writeDescriptor(descriptor);
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return getServiceDescriptor().name.equals(_name.getText().trim());
+ }
+
+ boolean validate()
+ {
+ return _mainEditor.check(new String[]{
+ "Service Name", _name.getText().trim(),
+ "Entry Point", _entry.getText().trim()});
+ }
+
+ void show(boolean isEditable)
+ {
+ ServiceDescriptor descriptor = getServiceDescriptor();
+ Utils.Resolver detailResolver = _mainEditor.getDetailResolver();
+
+ isEditable = isEditable && (detailResolver == null);
+
+ if(detailResolver != null)
+ {
+ _name.setText(detailResolver.find("service"));
+ }
+ else
+ {
+ _name.setText(descriptor.name);
+ }
+ _name.setEditable(isEditable);
+
+ _entry.setText(
+ Utils.substitute(descriptor.entry, detailResolver));
+ _entry.setEditable(isEditable);
+
+ show(descriptor, isEditable);
+ }
+
+ private JTextField _name = new JTextField(20);
+ private JTextField _entry = new JTextField(20);
+}
diff --git a/java/src/IceGridGUI/Application/ServiceTemplate.java b/java/src/IceGridGUI/Application/ServiceTemplate.java
index c88d20bd3bc..4859c5b6c30 100755
--- a/java/src/IceGridGUI/Application/ServiceTemplate.java
+++ b/java/src/IceGridGUI/Application/ServiceTemplate.java
@@ -1,261 +1,261 @@
-// **********************************************************************
-//
-// 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 java.awt.Component;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceTemplate extends Communicator
-{
- static public TemplateDescriptor
- copyDescriptor(TemplateDescriptor templateDescriptor)
- {
- TemplateDescriptor copy = (TemplateDescriptor)
- templateDescriptor.clone();
-
- copy.descriptor = PlainService.copyDescriptor(
- (ServiceDescriptor)copy.descriptor);
-
- return copy;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setOpenIcon(
- Utils.getIcon("/icons/16x16/service_template.png"));
- _cellRenderer.setClosedIcon(
- Utils.getIcon("/icons/16x16/service_template.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[COPY] = true;
- if(((TreeNode)_parent).getAvailableActions()[PASTE])
- {
- actions[PASTE] = true;
- }
- actions[DELETE] = true;
-
- actions[NEW_ADAPTER] = !_ephemeral;
- actions[NEW_DBENV] = !_ephemeral;
-
- return actions;
- }
- public void copy()
- {
- getCoordinator().setClipboard(copyDescriptor(_templateDescriptor));
- getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
- }
- public void paste()
- {
- ((TreeNode)_parent).paste();
- }
-
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_ADAPTER));
- _popup.add(actions.get(NEW_DBENV));
- }
- actions.setTarget(this);
- return _popup;
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = (ServiceTemplateEditor)getRoot().getEditor(ServiceTemplateEditor.class, this);
- }
- _editor.show(this);
- return _editor;
- }
-
- protected Editor createEditor()
- {
- return new ServiceTemplateEditor();
- }
-
- ServiceTemplate(boolean brandNew, ServiceTemplates parent,
- String name, TemplateDescriptor descriptor)
- throws UpdateFailedException
- {
- super(parent, name);
- _editable = new Editable(brandNew);
- _ephemeral = false;
- rebuild(descriptor);
- }
-
- ServiceTemplate(ServiceTemplates parent, String name, TemplateDescriptor descriptor)
- {
- super(parent, name);
- _ephemeral = true;
- _editable = null;
- _templateDescriptor = descriptor;
- }
-
- void write(XMLWriter writer) throws java.io.IOException
- {
- if(!_ephemeral)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("id", _id));
- writer.writeStartTag("service-template", attributes);
- writeParameters(writer, _templateDescriptor.parameters,
- _templateDescriptor.parameterDefaults);
-
- ServiceDescriptor descriptor = (ServiceDescriptor)_templateDescriptor.descriptor;
-
- writer.writeStartTag("service", PlainService.createAttributes(descriptor));
-
- if(descriptor.description.length() > 0)
- {
- writer.writeElement("description", descriptor.description);
- }
-
- writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
- _adapters.write(writer);
- _dbEnvs.write(writer);
- writer.writeEndTag("service");
- writer.writeEndTag("service-template");
- }
- }
-
- void rebuild(TemplateDescriptor descriptor)
- throws UpdateFailedException
- {
- _templateDescriptor = descriptor;
-
- _adapters.clear();
- _dbEnvs.clear();
-
- if(!_ephemeral)
- {
- _adapters.init(_templateDescriptor.descriptor.adapters);
- _dbEnvs.init(_templateDescriptor.descriptor.dbEnvs);
- }
- }
-
- void commit()
- {
- _editable.commit();
- }
-
- public Object getDescriptor()
- {
- return _templateDescriptor;
- }
-
- CommunicatorDescriptor getCommunicatorDescriptor()
- {
- return _templateDescriptor.descriptor;
- }
-
- public boolean isEphemeral()
- {
- return _ephemeral;
- }
-
- public void destroy()
- {
- ServiceTemplates serviceTemplates = (ServiceTemplates)_parent;
-
- if(_ephemeral)
- {
- serviceTemplates.removeChild(this);
- }
- else
- {
- serviceTemplates.removeDescriptor(_id);
- getRoot().removeServiceInstances(_id);
- serviceTemplates.removeChild(this);
- serviceTemplates.getEditable().
- removeElement(_id, _editable, ServiceTemplate.class);
- getRoot().updated();
- }
- }
-
- java.util.List findInstances()
- {
- return getRoot().findServiceInstances(_id);
- }
-
- Editable getEditable()
- {
- return _editable;
- }
-
- Editable getEnclosingEditable()
- {
- return _editable;
- }
-
- public Object saveDescriptor()
- {
- //
- // Shallow copy
- //
- TemplateDescriptor clone = (TemplateDescriptor)_templateDescriptor.clone();
- clone.descriptor = (ServiceDescriptor)_templateDescriptor.descriptor.clone();
- return clone;
- }
-
- public void restoreDescriptor(Object savedDescriptor)
- {
- TemplateDescriptor clone = (TemplateDescriptor)savedDescriptor;
- //
- // Keep the same object
- //
- _templateDescriptor.parameters = clone.parameters;
-
- ServiceDescriptor sd = (ServiceDescriptor)_templateDescriptor.descriptor;
- ServiceDescriptor csd = (ServiceDescriptor)clone.descriptor;
-
- sd.propertySet = csd.propertySet;
- sd.description = csd.description;
- sd.name = csd.name;
- sd.entry = csd.entry;
- }
-
- private TemplateDescriptor _templateDescriptor;
- private final boolean _ephemeral;
- private Editable _editable;
- private ServiceTemplateEditor _editor;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.Component;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceTemplate extends Communicator
+{
+ static public TemplateDescriptor
+ copyDescriptor(TemplateDescriptor templateDescriptor)
+ {
+ TemplateDescriptor copy = (TemplateDescriptor)
+ templateDescriptor.clone();
+
+ copy.descriptor = PlainService.copyDescriptor(
+ (ServiceDescriptor)copy.descriptor);
+
+ return copy;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setOpenIcon(
+ Utils.getIcon("/icons/16x16/service_template.png"));
+ _cellRenderer.setClosedIcon(
+ Utils.getIcon("/icons/16x16/service_template.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[COPY] = true;
+ if(((TreeNode)_parent).getAvailableActions()[PASTE])
+ {
+ actions[PASTE] = true;
+ }
+ actions[DELETE] = true;
+
+ actions[NEW_ADAPTER] = !_ephemeral;
+ actions[NEW_DBENV] = !_ephemeral;
+
+ return actions;
+ }
+ public void copy()
+ {
+ getCoordinator().setClipboard(copyDescriptor(_templateDescriptor));
+ getCoordinator().getActionsForMenu().get(PASTE).setEnabled(true);
+ }
+ public void paste()
+ {
+ ((TreeNode)_parent).paste();
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_ADAPTER));
+ _popup.add(actions.get(NEW_DBENV));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = (ServiceTemplateEditor)getRoot().getEditor(ServiceTemplateEditor.class, this);
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ protected Editor createEditor()
+ {
+ return new ServiceTemplateEditor();
+ }
+
+ ServiceTemplate(boolean brandNew, ServiceTemplates parent,
+ String name, TemplateDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ super(parent, name);
+ _editable = new Editable(brandNew);
+ _ephemeral = false;
+ rebuild(descriptor);
+ }
+
+ ServiceTemplate(ServiceTemplates parent, String name, TemplateDescriptor descriptor)
+ {
+ super(parent, name);
+ _ephemeral = true;
+ _editable = null;
+ _templateDescriptor = descriptor;
+ }
+
+ void write(XMLWriter writer) throws java.io.IOException
+ {
+ if(!_ephemeral)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("id", _id));
+ writer.writeStartTag("service-template", attributes);
+ writeParameters(writer, _templateDescriptor.parameters,
+ _templateDescriptor.parameterDefaults);
+
+ ServiceDescriptor descriptor = (ServiceDescriptor)_templateDescriptor.descriptor;
+
+ writer.writeStartTag("service", PlainService.createAttributes(descriptor));
+
+ if(descriptor.description.length() > 0)
+ {
+ writer.writeElement("description", descriptor.description);
+ }
+
+ writePropertySet(writer, "", descriptor.propertySet, descriptor.adapters);
+ _adapters.write(writer);
+ _dbEnvs.write(writer);
+ writer.writeEndTag("service");
+ writer.writeEndTag("service-template");
+ }
+ }
+
+ void rebuild(TemplateDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ _templateDescriptor = descriptor;
+
+ _adapters.clear();
+ _dbEnvs.clear();
+
+ if(!_ephemeral)
+ {
+ _adapters.init(_templateDescriptor.descriptor.adapters);
+ _dbEnvs.init(_templateDescriptor.descriptor.dbEnvs);
+ }
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ }
+
+ public Object getDescriptor()
+ {
+ return _templateDescriptor;
+ }
+
+ CommunicatorDescriptor getCommunicatorDescriptor()
+ {
+ return _templateDescriptor.descriptor;
+ }
+
+ public boolean isEphemeral()
+ {
+ return _ephemeral;
+ }
+
+ public void destroy()
+ {
+ ServiceTemplates serviceTemplates = (ServiceTemplates)_parent;
+
+ if(_ephemeral)
+ {
+ serviceTemplates.removeChild(this);
+ }
+ else
+ {
+ serviceTemplates.removeDescriptor(_id);
+ getRoot().removeServiceInstances(_id);
+ serviceTemplates.removeChild(this);
+ serviceTemplates.getEditable().
+ removeElement(_id, _editable, ServiceTemplate.class);
+ getRoot().updated();
+ }
+ }
+
+ java.util.List findInstances()
+ {
+ return getRoot().findServiceInstances(_id);
+ }
+
+ Editable getEditable()
+ {
+ return _editable;
+ }
+
+ Editable getEnclosingEditable()
+ {
+ return _editable;
+ }
+
+ public Object saveDescriptor()
+ {
+ //
+ // Shallow copy
+ //
+ TemplateDescriptor clone = (TemplateDescriptor)_templateDescriptor.clone();
+ clone.descriptor = (ServiceDescriptor)_templateDescriptor.descriptor.clone();
+ return clone;
+ }
+
+ public void restoreDescriptor(Object savedDescriptor)
+ {
+ TemplateDescriptor clone = (TemplateDescriptor)savedDescriptor;
+ //
+ // Keep the same object
+ //
+ _templateDescriptor.parameters = clone.parameters;
+
+ ServiceDescriptor sd = (ServiceDescriptor)_templateDescriptor.descriptor;
+ ServiceDescriptor csd = (ServiceDescriptor)clone.descriptor;
+
+ sd.propertySet = csd.propertySet;
+ sd.description = csd.description;
+ sd.name = csd.name;
+ sd.entry = csd.entry;
+ }
+
+ private TemplateDescriptor _templateDescriptor;
+ private final boolean _ephemeral;
+ private Editable _editable;
+ private ServiceTemplateEditor _editor;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/ServiceTemplateEditor.java b/java/src/IceGridGUI/Application/ServiceTemplateEditor.java
index 5f1eab836db..ec104ee8d0e 100755
--- a/java/src/IceGridGUI/Application/ServiceTemplateEditor.java
+++ b/java/src/IceGridGUI/Application/ServiceTemplateEditor.java
@@ -1,64 +1,64 @@
-// **********************************************************************
-//
-// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
-
-class ServiceTemplateEditor extends TemplateEditor
-{
- ServiceTemplateEditor()
- {
- _subEditor = new ServiceSubEditor(this);
- }
-
- void writeDescriptor()
- {
- super.writeDescriptor();
- _subEditor.writeDescriptor();
- }
-
- boolean isSimpleUpdate()
- {
- return super.isSimpleUpdate() && _subEditor.isSimpleUpdate();
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- super.appendProperties(builder);
- builder.appendSeparator();
- builder.nextLine();
- _subEditor.appendProperties(builder);
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Service Template Properties");
- }
-
- protected boolean validate()
- {
- return super.validate() && _subEditor.validate();
- }
-
- void show(ServiceTemplate t)
- {
- detectUpdates(false);
- _target = t;
-
- super.show();
- _subEditor.show(true);
-
- _applyButton.setEnabled(t.isEphemeral());
- _discardButton.setEnabled(t.isEphemeral());
- detectUpdates(true);
- }
-
- private ServiceSubEditor _subEditor;
-}
+// **********************************************************************
+//
+// 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 com.jgoodies.forms.builder.DefaultFormBuilder;
+
+class ServiceTemplateEditor extends TemplateEditor
+{
+ ServiceTemplateEditor()
+ {
+ _subEditor = new ServiceSubEditor(this);
+ }
+
+ void writeDescriptor()
+ {
+ super.writeDescriptor();
+ _subEditor.writeDescriptor();
+ }
+
+ boolean isSimpleUpdate()
+ {
+ return super.isSimpleUpdate() && _subEditor.isSimpleUpdate();
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ super.appendProperties(builder);
+ builder.appendSeparator();
+ builder.nextLine();
+ _subEditor.appendProperties(builder);
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Service Template Properties");
+ }
+
+ protected boolean validate()
+ {
+ return super.validate() && _subEditor.validate();
+ }
+
+ void show(ServiceTemplate t)
+ {
+ detectUpdates(false);
+ _target = t;
+
+ super.show();
+ _subEditor.show(true);
+
+ _applyButton.setEnabled(t.isEphemeral());
+ _discardButton.setEnabled(t.isEphemeral());
+ detectUpdates(true);
+ }
+
+ private ServiceSubEditor _subEditor;
+}
diff --git a/java/src/IceGridGUI/Application/ServiceTemplates.java b/java/src/IceGridGUI/Application/ServiceTemplates.java
index dfdb02cceea..3decb5c948c 100755
--- a/java/src/IceGridGUI/Application/ServiceTemplates.java
+++ b/java/src/IceGridGUI/Application/ServiceTemplates.java
@@ -1,221 +1,221 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceTemplates extends Templates
-{
- static public java.util.Map
- copyDescriptors(java.util.Map descriptors)
- {
- java.util.Map copy = new java.util.HashMap();
- java.util.Iterator p = descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- copy.put(entry.getKey(),
- ServiceTemplate.copyDescriptor(
- (TemplateDescriptor)entry.getValue()));
- }
- return copy;
- }
-
-
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[NEW_TEMPLATE_SERVICE] = true;
-
- Object clipboard = getCoordinator().getClipboard();
- if(clipboard != null && clipboard instanceof TemplateDescriptor)
- {
- TemplateDescriptor d = (TemplateDescriptor)clipboard;
- actions[PASTE] = d.descriptor instanceof ServiceDescriptor;
- }
- return actions;
- }
- public JPopupMenu getPopupMenu()
- {
- ApplicationActions actions = getCoordinator().getActionsForPopup();
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(actions.get(NEW_TEMPLATE_SERVICE));
- }
- actions.setTarget(this);
- return _popup;
- }
- public void newTemplateService()
- {
- ServiceDescriptor sd = new ServiceDescriptor(
- new java.util.LinkedList(),
- new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
- new java.util.LinkedList(),
- "",
- "",
- "");
-
- newServiceTemplate(new TemplateDescriptor(sd, new java.util.LinkedList(), new java.util.TreeMap()));
-
- }
- public void paste()
- {
- Object descriptor = getCoordinator().getClipboard();
- TemplateDescriptor td = (TemplateDescriptor)descriptor;
- newServiceTemplate(td);
- }
-
-
- ServiceTemplates(Root parent, java.util.Map descriptors)
- throws UpdateFailedException
- {
- super(parent, "Service templates");
-
- _descriptors = descriptors;
-
- java.util.Iterator p = _descriptors.entrySet().iterator();
-
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- insertChild(new ServiceTemplate(false, this,
- (String)entry.getKey(),
- (TemplateDescriptor)entry.getValue()),
- false);
- }
- }
-
- //
- // Variable resolution does not make sense for templates / template children
- //
- Utils.Resolver getResolver()
- {
- return null;
- }
-
- void newServiceTemplate(TemplateDescriptor descriptor)
- {
- String id = makeNewChildId("NewServiceTemplate");
-
- ServiceTemplate t = new ServiceTemplate(this, id, descriptor);
- try
- {
- insertChild(t, true);
- }
- catch(UpdateFailedException e)
- {
- assert false;
- }
- getRoot().setSelectedNode(t);
- }
-
- void tryAdd(String newId, TemplateDescriptor descriptor)
- throws UpdateFailedException
- {
- insertChild(new ServiceTemplate(true, this, newId, descriptor),
- true);
- _descriptors.put(newId, descriptor);
- }
-
- java.util.Map getUpdates()
- {
- java.util.Map updates = new java.util.HashMap();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServiceTemplate t = (ServiceTemplate)p.next();
- if(t.getEditable().isNew() || t.getEditable().isModified())
- {
- updates.put(t.getId(), t.getDescriptor());
- }
- }
- return updates;
- }
-
- void commit()
- {
- _editable.commit();
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- ServiceTemplate st = (ServiceTemplate)p.next();
- st.commit();
- }
- }
-
-
- void update(java.util.Map descriptors, String[] removeTemplates)
- throws UpdateFailedException
- {
- //
- // Note: _descriptors is updated by Application
- //
-
- //
- // One big set of removes
- //
- removeChildren(removeTemplates);
-
- //
- // One big set of updates, followed by inserts
- //
- java.util.Vector newChildren = new java.util.Vector();
- java.util.Vector updatedChildren = new java.util.Vector();
-
- java.util.Iterator p = descriptors.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String name = (String)entry.getKey();
- TemplateDescriptor templateDescriptor
- = (TemplateDescriptor)entry.getValue();
- ServiceTemplate child = (ServiceTemplate)findChild(name);
- if(child == null)
- {
- newChildren.add(new ServiceTemplate(false, this, name,
- templateDescriptor));
- }
- else
- {
- child.rebuild(templateDescriptor);
- updatedChildren.add(child);
- }
- }
-
- childrenChanged(updatedChildren);
- insertChildren(newChildren, true);
- }
-
- void removeDescriptor(String id)
- {
- _descriptors.remove(id);
- }
-
- Object getDescriptor()
- {
- return _descriptors;
- }
-
- private java.util.Map _descriptors;
-
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceTemplates extends Templates
+{
+ static public java.util.Map
+ copyDescriptors(java.util.Map descriptors)
+ {
+ java.util.Map copy = new java.util.HashMap();
+ java.util.Iterator p = descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ copy.put(entry.getKey(),
+ ServiceTemplate.copyDescriptor(
+ (TemplateDescriptor)entry.getValue()));
+ }
+ return copy;
+ }
+
+
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[NEW_TEMPLATE_SERVICE] = true;
+
+ Object clipboard = getCoordinator().getClipboard();
+ if(clipboard != null && clipboard instanceof TemplateDescriptor)
+ {
+ TemplateDescriptor d = (TemplateDescriptor)clipboard;
+ actions[PASTE] = d.descriptor instanceof ServiceDescriptor;
+ }
+ return actions;
+ }
+ public JPopupMenu getPopupMenu()
+ {
+ ApplicationActions actions = getCoordinator().getActionsForPopup();
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(actions.get(NEW_TEMPLATE_SERVICE));
+ }
+ actions.setTarget(this);
+ return _popup;
+ }
+ public void newTemplateService()
+ {
+ ServiceDescriptor sd = new ServiceDescriptor(
+ new java.util.LinkedList(),
+ new PropertySetDescriptor(new String[0], new java.util.LinkedList()),
+ new java.util.LinkedList(),
+ "",
+ "",
+ "");
+
+ newServiceTemplate(new TemplateDescriptor(sd, new java.util.LinkedList(), new java.util.TreeMap()));
+
+ }
+ public void paste()
+ {
+ Object descriptor = getCoordinator().getClipboard();
+ TemplateDescriptor td = (TemplateDescriptor)descriptor;
+ newServiceTemplate(td);
+ }
+
+
+ ServiceTemplates(Root parent, java.util.Map descriptors)
+ throws UpdateFailedException
+ {
+ super(parent, "Service templates");
+
+ _descriptors = descriptors;
+
+ java.util.Iterator p = _descriptors.entrySet().iterator();
+
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ insertChild(new ServiceTemplate(false, this,
+ (String)entry.getKey(),
+ (TemplateDescriptor)entry.getValue()),
+ false);
+ }
+ }
+
+ //
+ // Variable resolution does not make sense for templates / template children
+ //
+ Utils.Resolver getResolver()
+ {
+ return null;
+ }
+
+ void newServiceTemplate(TemplateDescriptor descriptor)
+ {
+ String id = makeNewChildId("NewServiceTemplate");
+
+ ServiceTemplate t = new ServiceTemplate(this, id, descriptor);
+ try
+ {
+ insertChild(t, true);
+ }
+ catch(UpdateFailedException e)
+ {
+ assert false;
+ }
+ getRoot().setSelectedNode(t);
+ }
+
+ void tryAdd(String newId, TemplateDescriptor descriptor)
+ throws UpdateFailedException
+ {
+ insertChild(new ServiceTemplate(true, this, newId, descriptor),
+ true);
+ _descriptors.put(newId, descriptor);
+ }
+
+ java.util.Map getUpdates()
+ {
+ java.util.Map updates = new java.util.HashMap();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServiceTemplate t = (ServiceTemplate)p.next();
+ if(t.getEditable().isNew() || t.getEditable().isModified())
+ {
+ updates.put(t.getId(), t.getDescriptor());
+ }
+ }
+ return updates;
+ }
+
+ void commit()
+ {
+ _editable.commit();
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ ServiceTemplate st = (ServiceTemplate)p.next();
+ st.commit();
+ }
+ }
+
+
+ void update(java.util.Map descriptors, String[] removeTemplates)
+ throws UpdateFailedException
+ {
+ //
+ // Note: _descriptors is updated by Application
+ //
+
+ //
+ // One big set of removes
+ //
+ removeChildren(removeTemplates);
+
+ //
+ // One big set of updates, followed by inserts
+ //
+ java.util.Vector newChildren = new java.util.Vector();
+ java.util.Vector updatedChildren = new java.util.Vector();
+
+ java.util.Iterator p = descriptors.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ String name = (String)entry.getKey();
+ TemplateDescriptor templateDescriptor
+ = (TemplateDescriptor)entry.getValue();
+ ServiceTemplate child = (ServiceTemplate)findChild(name);
+ if(child == null)
+ {
+ newChildren.add(new ServiceTemplate(false, this, name,
+ templateDescriptor));
+ }
+ else
+ {
+ child.rebuild(templateDescriptor);
+ updatedChildren.add(child);
+ }
+ }
+
+ childrenChanged(updatedChildren);
+ insertChildren(newChildren, true);
+ }
+
+ void removeDescriptor(String id)
+ {
+ _descriptors.remove(id);
+ }
+
+ Object getDescriptor()
+ {
+ return _descriptors;
+ }
+
+ private java.util.Map _descriptors;
+
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/Application/TemplateEditor.java b/java/src/IceGridGUI/Application/TemplateEditor.java
index d06f37f0ac6..7f40fe78b22 100755
--- a/java/src/IceGridGUI/Application/TemplateEditor.java
+++ b/java/src/IceGridGUI/Application/TemplateEditor.java
@@ -1,208 +1,208 @@
-// **********************************************************************
-//
-// 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 java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class TemplateEditor extends Editor
-{
- TemplateEditor()
- {
- _template.getDocument().addDocumentListener(_updateListener);
- _template.setToolTipText("Must be unique within the enclosing application");
-
- _parameters = new ParametersField(this);
- }
-
- TemplateDescriptor getDescriptor()
- {
- return (TemplateDescriptor)_target.getDescriptor();
- }
-
- Object getSubDescriptor()
- {
- return getDescriptor().descriptor;
- }
-
- void writeDescriptor()
- {
- TemplateDescriptor descriptor = getDescriptor();
- java.util.LinkedList parameters = new java.util.LinkedList();
- descriptor.parameterDefaults = _parameters.get(parameters);
- descriptor.parameters = parameters;
- }
-
- boolean isSimpleUpdate()
- {
- TemplateDescriptor descriptor = getDescriptor();
- java.util.List parameters = new java.util.LinkedList();
- java.util.Map defaultValues = _parameters.get(parameters);
-
- return descriptor.parameters.equals(parameters)
- && descriptor.parameterDefaults.equals(defaultValues);
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Template ID");
- builder.append(_template, 3);
- builder.nextLine();
-
- builder.append("Parameters");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- JScrollPane scrollPane = new JScrollPane(_parameters);
- CellConstraints cc = new CellConstraints();
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected boolean validate()
- {
- return check(new String[]{"Template ID", _template.getText().trim()});
- }
-
- void show()
- {
- TemplateDescriptor descriptor = getDescriptor();
- _template.setText(_target.getId());
- _template.setEditable(_target.isEphemeral());
-
- _parameters.set(descriptor.parameters, descriptor.parameterDefaults);
- }
-
- protected boolean applyUpdate()
- {
- Root root = _target.getRoot();
- root.disableSelectionListener();
-
- try
- {
- if(_target.isEphemeral())
- {
- writeDescriptor();
- TemplateDescriptor descriptor = getDescriptor();
- Templates parent = (Templates)_target.getParent();
- _target.destroy(); // just removes the child
-
- try
- {
- parent.tryAdd(_template.getText().trim(), descriptor);
- }
- catch(UpdateFailedException e)
- {
- //
- // Re-add ephemeral child
- //
- try
- {
- parent.insertChild(_target, true);
- }
- catch(UpdateFailedException die)
- {
- assert false;
- }
- root.setSelectedNode(_target);
-
- JOptionPane.showMessageDialog(
- _target.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- //
- // Success
- //
- _target = parent.findChildWithDescriptor(descriptor);
- root.updated();
- root.setSelectedNode(_target);
- _template.setEditable(false);
- }
- else if(isSimpleUpdate())
- {
- writeDescriptor();
- ((Communicator)_target).getEnclosingEditable().markModified();
- root.updated();
-
- }
- else
- {
- //
- // Save to be able to rollback
- //
- Object savedDescriptor = ((Communicator)_target).saveDescriptor();
- Templates parent = (Templates)_target.getParent();
- writeDescriptor();
-
- try
- {
- parent.tryUpdate((Communicator)_target);
- }
- catch(UpdateFailedException e)
- {
- ((Communicator)_target).restoreDescriptor(savedDescriptor);
-
- JOptionPane.showMessageDialog(
- _target.getCoordinator().getMainFrame(),
- e.toString(),
- "Apply failed",
- JOptionPane.ERROR_MESSAGE);
- //
- // Everything was restored, user must deal with error
- //
- return false;
- }
-
- //
- // Success
- //
- ((Communicator)_target).getEnclosingEditable().markModified();
- root.updated();
-
- _target = parent.findChildWithDescriptor(getDescriptor());
- root.setSelectedNode(_target);
- }
-
- root.getCoordinator().getCurrentTab().showNode(_target);
- _applyButton.setEnabled(false);
- _discardButton.setEnabled(false);
- return true;
- }
- finally
- {
- root.enableSelectionListener();
- }
- }
-
- private JTextField _template = new JTextField(20);
- private ParametersField _parameters;
-}
+// **********************************************************************
+//
+// 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 java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class TemplateEditor extends Editor
+{
+ TemplateEditor()
+ {
+ _template.getDocument().addDocumentListener(_updateListener);
+ _template.setToolTipText("Must be unique within the enclosing application");
+
+ _parameters = new ParametersField(this);
+ }
+
+ TemplateDescriptor getDescriptor()
+ {
+ return (TemplateDescriptor)_target.getDescriptor();
+ }
+
+ Object getSubDescriptor()
+ {
+ return getDescriptor().descriptor;
+ }
+
+ void writeDescriptor()
+ {
+ TemplateDescriptor descriptor = getDescriptor();
+ java.util.LinkedList parameters = new java.util.LinkedList();
+ descriptor.parameterDefaults = _parameters.get(parameters);
+ descriptor.parameters = parameters;
+ }
+
+ boolean isSimpleUpdate()
+ {
+ TemplateDescriptor descriptor = getDescriptor();
+ java.util.List parameters = new java.util.LinkedList();
+ java.util.Map defaultValues = _parameters.get(parameters);
+
+ return descriptor.parameters.equals(parameters)
+ && descriptor.parameterDefaults.equals(defaultValues);
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Template ID");
+ builder.append(_template, 3);
+ builder.nextLine();
+
+ builder.append("Parameters");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ JScrollPane scrollPane = new JScrollPane(_parameters);
+ CellConstraints cc = new CellConstraints();
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected boolean validate()
+ {
+ return check(new String[]{"Template ID", _template.getText().trim()});
+ }
+
+ void show()
+ {
+ TemplateDescriptor descriptor = getDescriptor();
+ _template.setText(_target.getId());
+ _template.setEditable(_target.isEphemeral());
+
+ _parameters.set(descriptor.parameters, descriptor.parameterDefaults);
+ }
+
+ protected boolean applyUpdate()
+ {
+ Root root = _target.getRoot();
+ root.disableSelectionListener();
+
+ try
+ {
+ if(_target.isEphemeral())
+ {
+ writeDescriptor();
+ TemplateDescriptor descriptor = getDescriptor();
+ Templates parent = (Templates)_target.getParent();
+ _target.destroy(); // just removes the child
+
+ try
+ {
+ parent.tryAdd(_template.getText().trim(), descriptor);
+ }
+ catch(UpdateFailedException e)
+ {
+ //
+ // Re-add ephemeral child
+ //
+ try
+ {
+ parent.insertChild(_target, true);
+ }
+ catch(UpdateFailedException die)
+ {
+ assert false;
+ }
+ root.setSelectedNode(_target);
+
+ JOptionPane.showMessageDialog(
+ _target.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ //
+ // Success
+ //
+ _target = parent.findChildWithDescriptor(descriptor);
+ root.updated();
+ root.setSelectedNode(_target);
+ _template.setEditable(false);
+ }
+ else if(isSimpleUpdate())
+ {
+ writeDescriptor();
+ ((Communicator)_target).getEnclosingEditable().markModified();
+ root.updated();
+
+ }
+ else
+ {
+ //
+ // Save to be able to rollback
+ //
+ Object savedDescriptor = ((Communicator)_target).saveDescriptor();
+ Templates parent = (Templates)_target.getParent();
+ writeDescriptor();
+
+ try
+ {
+ parent.tryUpdate((Communicator)_target);
+ }
+ catch(UpdateFailedException e)
+ {
+ ((Communicator)_target).restoreDescriptor(savedDescriptor);
+
+ JOptionPane.showMessageDialog(
+ _target.getCoordinator().getMainFrame(),
+ e.toString(),
+ "Apply failed",
+ JOptionPane.ERROR_MESSAGE);
+ //
+ // Everything was restored, user must deal with error
+ //
+ return false;
+ }
+
+ //
+ // Success
+ //
+ ((Communicator)_target).getEnclosingEditable().markModified();
+ root.updated();
+
+ _target = parent.findChildWithDescriptor(getDescriptor());
+ root.setSelectedNode(_target);
+ }
+
+ root.getCoordinator().getCurrentTab().showNode(_target);
+ _applyButton.setEnabled(false);
+ _discardButton.setEnabled(false);
+ return true;
+ }
+ finally
+ {
+ root.enableSelectionListener();
+ }
+ }
+
+ private JTextField _template = new JTextField(20);
+ private ParametersField _parameters;
+}
diff --git a/java/src/IceGridGUI/Application/TemplateInstance.java b/java/src/IceGridGUI/Application/TemplateInstance.java
index c4492c61882..8179cd3974b 100755
--- a/java/src/IceGridGUI/Application/TemplateInstance.java
+++ b/java/src/IceGridGUI/Application/TemplateInstance.java
@@ -1,16 +1,16 @@
-// **********************************************************************
-//
-// 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;
-
-interface TemplateInstance
-{
- Object rebuild(java.util.List editables) throws UpdateFailedException;
- void restore(Object backupObj);
-}
-
+// **********************************************************************
+//
+// 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;
+
+interface TemplateInstance
+{
+ Object rebuild(java.util.List editables) throws UpdateFailedException;
+ void restore(Object backupObj);
+}
+
diff --git a/java/src/IceGridGUI/Application/Templates.java b/java/src/IceGridGUI/Application/Templates.java
index 48f7905aeef..c05ccee33fd 100755
--- a/java/src/IceGridGUI/Application/Templates.java
+++ b/java/src/IceGridGUI/Application/Templates.java
@@ -1,61 +1,61 @@
-// **********************************************************************
-//
-// 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.JOptionPane;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-abstract class Templates extends ListTreeNode
-{
- abstract void tryAdd(String newId, TemplateDescriptor descriptor)
- throws UpdateFailedException;
-
- protected Templates(Root parent, String id)
- {
- super(false, parent, id);
- }
-
- void tryUpdate(Communicator child)
- throws UpdateFailedException
- {
- java.util.List instanceList = child.findInstances();
- java.util.List backupList = new java.util.Vector();
-
- java.util.List editables = new java.util.LinkedList();
-
- java.util.Iterator p = instanceList.iterator();
- while(p.hasNext())
- {
- TemplateInstance instance = (TemplateInstance)p.next();
-
- try
- {
- backupList.add(instance.rebuild(editables));
- }
- catch(UpdateFailedException e)
- {
- for(int i = backupList.size() - 1; i >= 0; --i)
- {
- instance = (TemplateInstance)instanceList.get(i);
- instance.restore(backupList.get(i));
- }
- throw e;
- }
- }
-
- p = editables.iterator();
- while(p.hasNext())
- {
- Editable editable = (Editable)p.next();
- editable.markModified();
- }
- }
-}
+// **********************************************************************
+//
+// 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.JOptionPane;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+abstract class Templates extends ListTreeNode
+{
+ abstract void tryAdd(String newId, TemplateDescriptor descriptor)
+ throws UpdateFailedException;
+
+ protected Templates(Root parent, String id)
+ {
+ super(false, parent, id);
+ }
+
+ void tryUpdate(Communicator child)
+ throws UpdateFailedException
+ {
+ java.util.List instanceList = child.findInstances();
+ java.util.List backupList = new java.util.Vector();
+
+ java.util.List editables = new java.util.LinkedList();
+
+ java.util.Iterator p = instanceList.iterator();
+ while(p.hasNext())
+ {
+ TemplateInstance instance = (TemplateInstance)p.next();
+
+ try
+ {
+ backupList.add(instance.rebuild(editables));
+ }
+ catch(UpdateFailedException e)
+ {
+ for(int i = backupList.size() - 1; i >= 0; --i)
+ {
+ instance = (TemplateInstance)instanceList.get(i);
+ instance.restore(backupList.get(i));
+ }
+ throw e;
+ }
+ }
+
+ p = editables.iterator();
+ while(p.hasNext())
+ {
+ Editable editable = (Editable)p.next();
+ editable.markModified();
+ }
+ }
+}
diff --git a/java/src/IceGridGUI/Application/TreeNode.java b/java/src/IceGridGUI/Application/TreeNode.java
index 75f33819ea7..54e5d68ea44 100755
--- a/java/src/IceGridGUI/Application/TreeNode.java
+++ b/java/src/IceGridGUI/Application/TreeNode.java
@@ -1,379 +1,379 @@
-// **********************************************************************
-//
-// 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.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-public abstract class TreeNode extends TreeNodeBase
-{
- abstract public Editor getEditor();
- abstract protected Editor createEditor();
- abstract Object getDescriptor();
-
- abstract void write(XMLWriter writer) throws java.io.IOException;
-
- //
- // Ephemeral objects are destroyed when you switch selection
- // without "apply"ing the changes.
- //
- public boolean isEphemeral()
- {
- return false;
- }
-
- //
- // Destroys this node
- //
- public void destroy()
- {
- assert false;
- }
-
- TreeNode(TreeNode parent, String id)
- {
- super(parent, id);
- }
-
- Root getRoot()
- {
- assert _parent != null;
- return ((TreeNode)_parent).getRoot();
- }
-
- TreeNode findChildLike(TreeNode other)
- {
- //
- // Default implementation just use id; not always appropriate
- //
- return (TreeNode)findChild(other.getId());
- }
-
- //
- // Get variable-resolver
- //
- Utils.Resolver getResolver()
- {
- if(isEphemeral())
- {
- return null;
- }
- else
- {
- return ((TreeNode)_parent).getResolver();
- }
- }
-
- //
- // Find child whose descriptor == the given descriptor
- //
- TreeNode findChildWithDescriptor(Object descriptor)
- {
- Enumeration p = children();
- while(p.hasMoreElements())
- {
- TreeNode node = (TreeNode)p.nextElement();
- if(node.getDescriptor() == descriptor)
- {
- return node;
- }
- }
- return null;
- }
-
- static String[] createAttribute(String name, String value)
- {
- return new String[]{name, value};
- }
-
- static void writeVariables(XMLWriter writer,
- java.util.Map variables)
- throws java.io.IOException
- {
- java.util.Iterator p = variables.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", entry.getKey().toString()));
- attributes.add(createAttribute("value", entry.getValue().toString()));
-
- writer.writeElement("variable", attributes);
- }
- }
-
- static void writePropertySet(XMLWriter writer, String id,
- PropertySetDescriptor psd, java.util.List adapters)
- throws java.io.IOException
- {
- if(id.length() == 0 && psd.references.length == 0 && psd.properties.size() == 0)
- {
- return;
- }
-
- //
- // We don't show the .Endpoint and .PublishedEndpoints of adapters,
- // since they already appear in the Adapter descriptors
- //
- java.util.Set hiddenPropertyNames = new java.util.HashSet();
-
- if(adapters != null)
- {
- java.util.Iterator p = adapters.iterator();
- while(p.hasNext())
- {
- AdapterDescriptor ad = (AdapterDescriptor)p.next();
- hiddenPropertyNames.add(ad.name + ".Endpoints");
- }
- }
-
- java.util.List attributes = new java.util.LinkedList();
- if(id.length() > 0)
- {
- attributes.add(createAttribute("id", id));
- }
- if(psd.references.length == 0 && psd.properties.size() == 0)
- {
- writer.writeElement("properties", attributes);
- }
- else
- {
- writer.writeStartTag("properties", attributes);
-
- for(int i = 0; i < psd.references.length; ++i)
- {
- attributes.clear();
- attributes.add(createAttribute("refid", psd.references[i]));
- writer.writeElement("properties", attributes);
- }
-
- java.util.Iterator p = psd.properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- if(hiddenPropertyNames.contains(pd.name))
- {
- //
- // We hide only the first occurence
- //
- hiddenPropertyNames.remove(pd.name);
- }
- else
- {
- attributes.clear();
- attributes.add(createAttribute("name", pd.name));
- attributes.add(createAttribute("value", pd.value));
- writer.writeElement("property", attributes);
- }
- }
- writer.writeEndTag("properties");
- }
- }
-
- static void writeDistribution(XMLWriter writer,
- DistributionDescriptor descriptor)
- throws java.io.IOException
- {
- if(descriptor.icepatch.length() > 0)
- {
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("icepatch", descriptor.icepatch));
-
- if(descriptor.directories.isEmpty())
- {
- writer.writeElement("distrib", attributes);
- }
- else
- {
- writer.writeStartTag("distrib", attributes);
- java.util.Iterator p = descriptor.directories.iterator();
- while(p.hasNext())
- {
- writer.writeElement("directory", p.next().toString());
- }
- writer.writeEndTag("distrib");
- }
- }
- }
-
- static void writeObjects(String elt, XMLWriter writer, java.util.List objects)
- throws java.io.IOException
- {
- java.util.Iterator p = objects.iterator();
- while(p.hasNext())
- {
- ObjectDescriptor od = (ObjectDescriptor)p.next();
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("identity", Ice.Util.identityToString(od.id)));
- if(od.type.length() > 0)
- {
- attributes.add(createAttribute("type", od.type));
- }
- writer.writeElement(elt, attributes);
- }
- }
-
- static void writeParameters(XMLWriter writer, java.util.List parameters,
- java.util.Map defaultValues)
- throws java.io.IOException
- {
- java.util.Iterator p = new java.util.LinkedHashSet(parameters).iterator();
- while(p.hasNext())
- {
- String parameter = (String)p.next();
- String val = (String)defaultValues.get(parameter);
- java.util.List attributes = new java.util.LinkedList();
- attributes.add(createAttribute("name", parameter));
- if(val != null)
- {
- attributes.add(createAttribute("default", val));
- }
- writer.writeElement("parameter", attributes);
- }
- }
-
- static java.util.LinkedList
- parameterValuesToAttributes(java.util.Map parameterValues,
- java.util.List parameters)
- {
- java.util.LinkedList result = new java.util.LinkedList();
-
- //
- // We use a LinkedHashSet to maintain order while eliminating duplicates
- //
- java.util.Iterator p = new java.util.LinkedHashSet(parameters).iterator();
- while(p.hasNext())
- {
- String param = (String)p.next();
- String val = (String)parameterValues.get(param);
- if(val != null)
- {
- result.add(createAttribute(param, val));
- }
- }
- return result;
- }
-
- //
- // Actions
- //
- public static final int NEW_ADAPTER = 0;
- public static final int NEW_DBENV = 1;
- public static final int NEW_NODE = 2;
- public static final int NEW_PROPERTY_SET = 3;
- public static final int NEW_REPLICA_GROUP = 4;
- public static final int NEW_SERVER = 5;
- public static final int NEW_SERVER_ICEBOX = 6;
- public static final int NEW_SERVER_FROM_TEMPLATE = 7;
- public static final int NEW_SERVICE = 8;
- public static final int NEW_SERVICE_FROM_TEMPLATE = 9;
- public static final int NEW_TEMPLATE_SERVER = 10;
- public static final int NEW_TEMPLATE_SERVER_ICEBOX = 11;
- public static final int NEW_TEMPLATE_SERVICE = 12;
-
- public static final int COPY = 13;
- public static final int PASTE = 14;
- public static final int DELETE = 15;
-
- public static final int SHOW_VARS = 16;
- public static final int SUBSTITUTE_VARS = 17;
-
- public static final int MOVE_UP = 18;
- public static final int MOVE_DOWN = 19;
-
- static public final int ACTION_COUNT = 20;
-
- public boolean[] getAvailableActions()
- {
- return new boolean[ACTION_COUNT];
- }
- public void newAdapter()
- {
- assert false;
- }
- public void newDbEnv()
- {
- assert false;
- }
- public void newNode()
- {
- assert false;
- }
- public void newPropertySet()
- {
- assert false;
- }
- public void newReplicaGroup()
- {
- assert false;
- }
- public void newServer()
- {
- assert false;
- }
- public void newServerIceBox()
- {
- assert false;
- }
- public void newServerFromTemplate()
- {
- assert false;
- }
- public void newService()
- {
- assert false;
- }
- public void newServiceFromTemplate()
- {
- assert false;
- }
- public void newTemplateServer()
- {
- assert false;
- }
- public void newTemplateServerIceBox()
- {
- assert false;
- }
- public void newTemplateService()
- {
- assert false;
- }
- public void copy()
- {
- assert false;
- }
- public void paste()
- {
- assert false;
- }
- public void delete()
- {
- destroy();
- if(_parent != null)
- {
- getRoot().setSelectedNode((TreeNode)_parent);
- }
- }
- public void moveUp()
- {
- assert false;
- }
- public void moveDown()
- {
- assert false;
- }
-}
+// **********************************************************************
+//
+// 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.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+public abstract class TreeNode extends TreeNodeBase
+{
+ abstract public Editor getEditor();
+ abstract protected Editor createEditor();
+ abstract Object getDescriptor();
+
+ abstract void write(XMLWriter writer) throws java.io.IOException;
+
+ //
+ // Ephemeral objects are destroyed when you switch selection
+ // without "apply"ing the changes.
+ //
+ public boolean isEphemeral()
+ {
+ return false;
+ }
+
+ //
+ // Destroys this node
+ //
+ public void destroy()
+ {
+ assert false;
+ }
+
+ TreeNode(TreeNode parent, String id)
+ {
+ super(parent, id);
+ }
+
+ Root getRoot()
+ {
+ assert _parent != null;
+ return ((TreeNode)_parent).getRoot();
+ }
+
+ TreeNode findChildLike(TreeNode other)
+ {
+ //
+ // Default implementation just use id; not always appropriate
+ //
+ return (TreeNode)findChild(other.getId());
+ }
+
+ //
+ // Get variable-resolver
+ //
+ Utils.Resolver getResolver()
+ {
+ if(isEphemeral())
+ {
+ return null;
+ }
+ else
+ {
+ return ((TreeNode)_parent).getResolver();
+ }
+ }
+
+ //
+ // Find child whose descriptor == the given descriptor
+ //
+ TreeNode findChildWithDescriptor(Object descriptor)
+ {
+ Enumeration p = children();
+ while(p.hasMoreElements())
+ {
+ TreeNode node = (TreeNode)p.nextElement();
+ if(node.getDescriptor() == descriptor)
+ {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ static String[] createAttribute(String name, String value)
+ {
+ return new String[]{name, value};
+ }
+
+ static void writeVariables(XMLWriter writer,
+ java.util.Map variables)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = variables.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", entry.getKey().toString()));
+ attributes.add(createAttribute("value", entry.getValue().toString()));
+
+ writer.writeElement("variable", attributes);
+ }
+ }
+
+ static void writePropertySet(XMLWriter writer, String id,
+ PropertySetDescriptor psd, java.util.List adapters)
+ throws java.io.IOException
+ {
+ if(id.length() == 0 && psd.references.length == 0 && psd.properties.size() == 0)
+ {
+ return;
+ }
+
+ //
+ // We don't show the .Endpoint and .PublishedEndpoints of adapters,
+ // since they already appear in the Adapter descriptors
+ //
+ java.util.Set hiddenPropertyNames = new java.util.HashSet();
+
+ if(adapters != null)
+ {
+ java.util.Iterator p = adapters.iterator();
+ while(p.hasNext())
+ {
+ AdapterDescriptor ad = (AdapterDescriptor)p.next();
+ hiddenPropertyNames.add(ad.name + ".Endpoints");
+ }
+ }
+
+ java.util.List attributes = new java.util.LinkedList();
+ if(id.length() > 0)
+ {
+ attributes.add(createAttribute("id", id));
+ }
+ if(psd.references.length == 0 && psd.properties.size() == 0)
+ {
+ writer.writeElement("properties", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("properties", attributes);
+
+ for(int i = 0; i < psd.references.length; ++i)
+ {
+ attributes.clear();
+ attributes.add(createAttribute("refid", psd.references[i]));
+ writer.writeElement("properties", attributes);
+ }
+
+ java.util.Iterator p = psd.properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ if(hiddenPropertyNames.contains(pd.name))
+ {
+ //
+ // We hide only the first occurence
+ //
+ hiddenPropertyNames.remove(pd.name);
+ }
+ else
+ {
+ attributes.clear();
+ attributes.add(createAttribute("name", pd.name));
+ attributes.add(createAttribute("value", pd.value));
+ writer.writeElement("property", attributes);
+ }
+ }
+ writer.writeEndTag("properties");
+ }
+ }
+
+ static void writeDistribution(XMLWriter writer,
+ DistributionDescriptor descriptor)
+ throws java.io.IOException
+ {
+ if(descriptor.icepatch.length() > 0)
+ {
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("icepatch", descriptor.icepatch));
+
+ if(descriptor.directories.isEmpty())
+ {
+ writer.writeElement("distrib", attributes);
+ }
+ else
+ {
+ writer.writeStartTag("distrib", attributes);
+ java.util.Iterator p = descriptor.directories.iterator();
+ while(p.hasNext())
+ {
+ writer.writeElement("directory", p.next().toString());
+ }
+ writer.writeEndTag("distrib");
+ }
+ }
+ }
+
+ static void writeObjects(String elt, XMLWriter writer, java.util.List objects)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = objects.iterator();
+ while(p.hasNext())
+ {
+ ObjectDescriptor od = (ObjectDescriptor)p.next();
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("identity", Ice.Util.identityToString(od.id)));
+ if(od.type.length() > 0)
+ {
+ attributes.add(createAttribute("type", od.type));
+ }
+ writer.writeElement(elt, attributes);
+ }
+ }
+
+ static void writeParameters(XMLWriter writer, java.util.List parameters,
+ java.util.Map defaultValues)
+ throws java.io.IOException
+ {
+ java.util.Iterator p = new java.util.LinkedHashSet(parameters).iterator();
+ while(p.hasNext())
+ {
+ String parameter = (String)p.next();
+ String val = (String)defaultValues.get(parameter);
+ java.util.List attributes = new java.util.LinkedList();
+ attributes.add(createAttribute("name", parameter));
+ if(val != null)
+ {
+ attributes.add(createAttribute("default", val));
+ }
+ writer.writeElement("parameter", attributes);
+ }
+ }
+
+ static java.util.LinkedList
+ parameterValuesToAttributes(java.util.Map parameterValues,
+ java.util.List parameters)
+ {
+ java.util.LinkedList result = new java.util.LinkedList();
+
+ //
+ // We use a LinkedHashSet to maintain order while eliminating duplicates
+ //
+ java.util.Iterator p = new java.util.LinkedHashSet(parameters).iterator();
+ while(p.hasNext())
+ {
+ String param = (String)p.next();
+ String val = (String)parameterValues.get(param);
+ if(val != null)
+ {
+ result.add(createAttribute(param, val));
+ }
+ }
+ return result;
+ }
+
+ //
+ // Actions
+ //
+ public static final int NEW_ADAPTER = 0;
+ public static final int NEW_DBENV = 1;
+ public static final int NEW_NODE = 2;
+ public static final int NEW_PROPERTY_SET = 3;
+ public static final int NEW_REPLICA_GROUP = 4;
+ public static final int NEW_SERVER = 5;
+ public static final int NEW_SERVER_ICEBOX = 6;
+ public static final int NEW_SERVER_FROM_TEMPLATE = 7;
+ public static final int NEW_SERVICE = 8;
+ public static final int NEW_SERVICE_FROM_TEMPLATE = 9;
+ public static final int NEW_TEMPLATE_SERVER = 10;
+ public static final int NEW_TEMPLATE_SERVER_ICEBOX = 11;
+ public static final int NEW_TEMPLATE_SERVICE = 12;
+
+ public static final int COPY = 13;
+ public static final int PASTE = 14;
+ public static final int DELETE = 15;
+
+ public static final int SHOW_VARS = 16;
+ public static final int SUBSTITUTE_VARS = 17;
+
+ public static final int MOVE_UP = 18;
+ public static final int MOVE_DOWN = 19;
+
+ static public final int ACTION_COUNT = 20;
+
+ public boolean[] getAvailableActions()
+ {
+ return new boolean[ACTION_COUNT];
+ }
+ public void newAdapter()
+ {
+ assert false;
+ }
+ public void newDbEnv()
+ {
+ assert false;
+ }
+ public void newNode()
+ {
+ assert false;
+ }
+ public void newPropertySet()
+ {
+ assert false;
+ }
+ public void newReplicaGroup()
+ {
+ assert false;
+ }
+ public void newServer()
+ {
+ assert false;
+ }
+ public void newServerIceBox()
+ {
+ assert false;
+ }
+ public void newServerFromTemplate()
+ {
+ assert false;
+ }
+ public void newService()
+ {
+ assert false;
+ }
+ public void newServiceFromTemplate()
+ {
+ assert false;
+ }
+ public void newTemplateServer()
+ {
+ assert false;
+ }
+ public void newTemplateServerIceBox()
+ {
+ assert false;
+ }
+ public void newTemplateService()
+ {
+ assert false;
+ }
+ public void copy()
+ {
+ assert false;
+ }
+ public void paste()
+ {
+ assert false;
+ }
+ public void delete()
+ {
+ destroy();
+ if(_parent != null)
+ {
+ getRoot().setSelectedNode((TreeNode)_parent);
+ }
+ }
+ public void moveUp()
+ {
+ assert false;
+ }
+ public void moveDown()
+ {
+ assert false;
+ }
+}
diff --git a/java/src/IceGridGUI/Application/UpdateFailedException.java b/java/src/IceGridGUI/Application/UpdateFailedException.java
index c1c27aea078..3f148185fcf 100755
--- a/java/src/IceGridGUI/Application/UpdateFailedException.java
+++ b/java/src/IceGridGUI/Application/UpdateFailedException.java
@@ -1,26 +1,26 @@
-// **********************************************************************
-//
-// 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;
-
-class UpdateFailedException extends Exception
-{
- UpdateFailedException(TreeNode parent, String id)
- {
- _parent = parent;
- _id = id;
- }
-
- public String toString()
- {
- return _parent.getFullId().toString() + " has already a child with '" + _id + "' as ID.";
- }
-
- private TreeNode _parent;
- private String _id;
-}
+// **********************************************************************
+//
+// 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;
+
+class UpdateFailedException extends Exception
+{
+ UpdateFailedException(TreeNode parent, String id)
+ {
+ _parent = parent;
+ _id = id;
+ }
+
+ public String toString()
+ {
+ return _parent.getFullId().toString() + " has already a child with '" + _id + "' as ID.";
+ }
+
+ private TreeNode _parent;
+ private String _id;
+}
diff --git a/java/src/IceGridGUI/ApplicationActions.java b/java/src/IceGridGUI/ApplicationActions.java
index b3a48f3afcf..4468b20dc80 100755
--- a/java/src/IceGridGUI/ApplicationActions.java
+++ b/java/src/IceGridGUI/ApplicationActions.java
@@ -1,255 +1,255 @@
-// **********************************************************************
-//
-// 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;
-
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-
-import IceGrid.*;
-import IceGridGUI.Application.*;
-
-//
-// Holds all actions for the Application view
-//
-public class ApplicationActions
-{
- public Action get(int index)
- {
- return _array[index];
- }
-
- public boolean[] setTarget(TreeNode target)
- {
- _target = target;
-
- boolean[] availableActions;
- if(_target == null)
- {
- availableActions = new boolean[TreeNode.ACTION_COUNT];
- }
- else
- {
- availableActions = _target.getAvailableActions();
- }
-
- for(int i = 0; i < _array.length; ++i)
- {
- _array[i].setEnabled(availableActions[i]);
- }
-
- return availableActions;
- }
-
- ApplicationActions(boolean popup)
- {
- final int MENU_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-
- _array[TreeNode.NEW_ADAPTER] = new AbstractAction(
- popup ? "New adapter" : "Adapter")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newAdapter();
- }
- };
-
- _array[TreeNode.NEW_DBENV] = new AbstractAction(
- popup ? "New database environment" : "Database environment")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newDbEnv();
- }
- };
-
- _array[TreeNode.NEW_NODE] = new AbstractAction(
- popup ? "New node" : "Node")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newNode();
- }
- };
-
- _array[TreeNode.NEW_PROPERTY_SET] = new AbstractAction(
- popup ? "New property set" : "Property set")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newPropertySet();
- }
- };
-
- _array[TreeNode.NEW_REPLICA_GROUP] = new AbstractAction(
- popup ? "New replica group" : "Replica group" )
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newReplicaGroup();
- }
- };
-
- _array[TreeNode.NEW_SERVER] = new AbstractAction(
- popup ? "New server" : "Server")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newServer();
- }
- };
-
- _array[TreeNode.NEW_SERVER_ICEBOX] = new AbstractAction(
- popup ? "New IceBox server" : "IceBox server")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newServerIceBox();
- }
- };
-
- _array[TreeNode.NEW_SERVER_FROM_TEMPLATE] = new AbstractAction(
- popup ? "New server from template" : "Server from template")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newServerFromTemplate();
- }
- };
-
-
- _array[TreeNode.NEW_SERVICE] = new AbstractAction(
- popup ? "New service" : "Service")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newService();
- }
- };
-
- _array[TreeNode.NEW_SERVICE_FROM_TEMPLATE] = new AbstractAction(
- popup ? "New service from template" : "Service from template")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newServiceFromTemplate();
- }
- };
-
- _array[TreeNode.NEW_TEMPLATE_SERVER] = new AbstractAction(
- popup ? "New Server template" : "Server template")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newTemplateServer();
- }
- };
-
- _array[TreeNode.NEW_TEMPLATE_SERVER_ICEBOX] = new AbstractAction(
- popup ? "New IceBox server template" : "IceBox server template")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newTemplateServerIceBox();
- }
- };
-
-
- _array[TreeNode.NEW_TEMPLATE_SERVICE] = new AbstractAction(
- popup ? "New service template" : "Service template")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.newTemplateService();
- }
- };
-
- _array[TreeNode.COPY] = new AbstractAction("Copy")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.copy();
- }
- };
- _array[TreeNode.COPY].putValue(Action.ACCELERATOR_KEY,
- KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK));
- _array[TreeNode.COPY].putValue(Action.SHORT_DESCRIPTION, "Copy");
-
- _array[TreeNode.PASTE] = new AbstractAction("Paste")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.paste();
- }
- };
- _array[TreeNode.PASTE].putValue(Action.ACCELERATOR_KEY,
- KeyStroke.getKeyStroke(KeyEvent.VK_V, MENU_MASK));
- _array[TreeNode.PASTE].putValue(Action.SHORT_DESCRIPTION, "Paste");
-
- _array[TreeNode.DELETE] = new AbstractAction("Delete")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.delete();
- }
- };
- _array[TreeNode.DELETE].putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE"));
- _array[TreeNode.DELETE].putValue(Action.SHORT_DESCRIPTION, "Delete");
-
- _array[TreeNode.SHOW_VARS] = new
- AbstractAction("Show variables")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.getCoordinator().showVars();
- }
- };
- _array[TreeNode.SHOW_VARS].putValue(
- Action.SHORT_DESCRIPTION,
- "Show variables and parameters in the Properties pane");
-
-
- _array[TreeNode.SUBSTITUTE_VARS] = new
- AbstractAction("Substitute variables")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.getCoordinator().substituteVars();
- }
- };
-
- _array[TreeNode.SUBSTITUTE_VARS].putValue(
- Action.SHORT_DESCRIPTION,
- "Substitute variables and parameters with their values in the Properties pane");
-
-
- _array[TreeNode.MOVE_UP] = new AbstractAction("Move up")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.moveUp();
- }
- };
-
- _array[TreeNode.MOVE_DOWN] = new AbstractAction("Move down")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.moveDown();
- }
- };
- }
-
- private TreeNode _target;
- private Action[] _array = new Action[TreeNode.ACTION_COUNT];
-}
+// **********************************************************************
+//
+// 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;
+
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+
+import IceGrid.*;
+import IceGridGUI.Application.*;
+
+//
+// Holds all actions for the Application view
+//
+public class ApplicationActions
+{
+ public Action get(int index)
+ {
+ return _array[index];
+ }
+
+ public boolean[] setTarget(TreeNode target)
+ {
+ _target = target;
+
+ boolean[] availableActions;
+ if(_target == null)
+ {
+ availableActions = new boolean[TreeNode.ACTION_COUNT];
+ }
+ else
+ {
+ availableActions = _target.getAvailableActions();
+ }
+
+ for(int i = 0; i < _array.length; ++i)
+ {
+ _array[i].setEnabled(availableActions[i]);
+ }
+
+ return availableActions;
+ }
+
+ ApplicationActions(boolean popup)
+ {
+ final int MENU_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+
+ _array[TreeNode.NEW_ADAPTER] = new AbstractAction(
+ popup ? "New adapter" : "Adapter")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newAdapter();
+ }
+ };
+
+ _array[TreeNode.NEW_DBENV] = new AbstractAction(
+ popup ? "New database environment" : "Database environment")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newDbEnv();
+ }
+ };
+
+ _array[TreeNode.NEW_NODE] = new AbstractAction(
+ popup ? "New node" : "Node")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newNode();
+ }
+ };
+
+ _array[TreeNode.NEW_PROPERTY_SET] = new AbstractAction(
+ popup ? "New property set" : "Property set")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newPropertySet();
+ }
+ };
+
+ _array[TreeNode.NEW_REPLICA_GROUP] = new AbstractAction(
+ popup ? "New replica group" : "Replica group" )
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newReplicaGroup();
+ }
+ };
+
+ _array[TreeNode.NEW_SERVER] = new AbstractAction(
+ popup ? "New server" : "Server")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newServer();
+ }
+ };
+
+ _array[TreeNode.NEW_SERVER_ICEBOX] = new AbstractAction(
+ popup ? "New IceBox server" : "IceBox server")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newServerIceBox();
+ }
+ };
+
+ _array[TreeNode.NEW_SERVER_FROM_TEMPLATE] = new AbstractAction(
+ popup ? "New server from template" : "Server from template")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newServerFromTemplate();
+ }
+ };
+
+
+ _array[TreeNode.NEW_SERVICE] = new AbstractAction(
+ popup ? "New service" : "Service")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newService();
+ }
+ };
+
+ _array[TreeNode.NEW_SERVICE_FROM_TEMPLATE] = new AbstractAction(
+ popup ? "New service from template" : "Service from template")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newServiceFromTemplate();
+ }
+ };
+
+ _array[TreeNode.NEW_TEMPLATE_SERVER] = new AbstractAction(
+ popup ? "New Server template" : "Server template")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newTemplateServer();
+ }
+ };
+
+ _array[TreeNode.NEW_TEMPLATE_SERVER_ICEBOX] = new AbstractAction(
+ popup ? "New IceBox server template" : "IceBox server template")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newTemplateServerIceBox();
+ }
+ };
+
+
+ _array[TreeNode.NEW_TEMPLATE_SERVICE] = new AbstractAction(
+ popup ? "New service template" : "Service template")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.newTemplateService();
+ }
+ };
+
+ _array[TreeNode.COPY] = new AbstractAction("Copy")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.copy();
+ }
+ };
+ _array[TreeNode.COPY].putValue(Action.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK));
+ _array[TreeNode.COPY].putValue(Action.SHORT_DESCRIPTION, "Copy");
+
+ _array[TreeNode.PASTE] = new AbstractAction("Paste")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.paste();
+ }
+ };
+ _array[TreeNode.PASTE].putValue(Action.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_V, MENU_MASK));
+ _array[TreeNode.PASTE].putValue(Action.SHORT_DESCRIPTION, "Paste");
+
+ _array[TreeNode.DELETE] = new AbstractAction("Delete")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.delete();
+ }
+ };
+ _array[TreeNode.DELETE].putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE"));
+ _array[TreeNode.DELETE].putValue(Action.SHORT_DESCRIPTION, "Delete");
+
+ _array[TreeNode.SHOW_VARS] = new
+ AbstractAction("Show variables")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.getCoordinator().showVars();
+ }
+ };
+ _array[TreeNode.SHOW_VARS].putValue(
+ Action.SHORT_DESCRIPTION,
+ "Show variables and parameters in the Properties pane");
+
+
+ _array[TreeNode.SUBSTITUTE_VARS] = new
+ AbstractAction("Substitute variables")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.getCoordinator().substituteVars();
+ }
+ };
+
+ _array[TreeNode.SUBSTITUTE_VARS].putValue(
+ Action.SHORT_DESCRIPTION,
+ "Substitute variables and parameters with their values in the Properties pane");
+
+
+ _array[TreeNode.MOVE_UP] = new AbstractAction("Move up")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.moveUp();
+ }
+ };
+
+ _array[TreeNode.MOVE_DOWN] = new AbstractAction("Move down")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.moveDown();
+ }
+ };
+ }
+
+ private TreeNode _target;
+ private Action[] _array = new Action[TreeNode.ACTION_COUNT];
+}
diff --git a/java/src/IceGridGUI/BareBonesBrowserLaunch.java b/java/src/IceGridGUI/BareBonesBrowserLaunch.java
index 37a219a8dcf..eab9ab4e085 100755
--- a/java/src/IceGridGUI/BareBonesBrowserLaunch.java
+++ b/java/src/IceGridGUI/BareBonesBrowserLaunch.java
@@ -1,54 +1,54 @@
-//
-// From http://www.centerkey.com/java/browser
-//
-
-////////////////////////////////////////////////////////
-// Bare Bones Browser Launch //
-// Version 1.1 //
-// July 8, 2005 //
-// Supports: Mac OS X, GNU/Linux, Unix, Windows XP //
-// Example Usage: //
-// String url = "http://www.centerkey.com/"; //
-// BareBonesBrowserLaunch.openURL(url); //
-// Public Domain Software -- Free to Use as You Like //
-////////////////////////////////////////////////////////
-
-package IceGridGUI;
-
-import java.lang.reflect.Method;
-import javax.swing.JOptionPane;
-
-public class BareBonesBrowserLaunch {
-
- private static final String errMsg = "Error attempting to launch web browser";
-
- public static void openURL(String url) {
- String osName = System.getProperty("os.name");
- try {
- if (osName.startsWith("Mac OS")) {
- Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
- Method openURL = macUtils.getDeclaredMethod("openURL",
- new Class[] {String.class});
- openURL.invoke(null, new Object[] {url});
- }
- else if (osName.startsWith("Windows"))
- Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
- else { //assume Unix or Linux
- String[] browsers = {
- "firefox", "opera", "konqueror", "mozilla", "netscape" };
- String browser = null;
- for (int count = 0; count < browsers.length && browser == null; count++)
- if (Runtime.getRuntime().exec(
- new String[] {"which", browsers[count]}).waitFor() == 0)
- browser = browsers[count];
- if (browser == null)
- throw new Exception("Could not find web browser.");
- else
- Runtime.getRuntime().exec(new String[] {browser, url});
- }
- }
- catch (Exception e) {
- JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
- }
- }
-}
+//
+// From http://www.centerkey.com/java/browser
+//
+
+////////////////////////////////////////////////////////
+// Bare Bones Browser Launch //
+// Version 1.1 //
+// July 8, 2005 //
+// Supports: Mac OS X, GNU/Linux, Unix, Windows XP //
+// Example Usage: //
+// String url = "http://www.centerkey.com/"; //
+// BareBonesBrowserLaunch.openURL(url); //
+// Public Domain Software -- Free to Use as You Like //
+////////////////////////////////////////////////////////
+
+package IceGridGUI;
+
+import java.lang.reflect.Method;
+import javax.swing.JOptionPane;
+
+public class BareBonesBrowserLaunch {
+
+ private static final String errMsg = "Error attempting to launch web browser";
+
+ public static void openURL(String url) {
+ String osName = System.getProperty("os.name");
+ try {
+ if (osName.startsWith("Mac OS")) {
+ Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils");
+ Method openURL = macUtils.getDeclaredMethod("openURL",
+ new Class[] {String.class});
+ openURL.invoke(null, new Object[] {url});
+ }
+ else if (osName.startsWith("Windows"))
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
+ else { //assume Unix or Linux
+ String[] browsers = {
+ "firefox", "opera", "konqueror", "mozilla", "netscape" };
+ String browser = null;
+ for (int count = 0; count < browsers.length && browser == null; count++)
+ if (Runtime.getRuntime().exec(
+ new String[] {"which", browsers[count]}).waitFor() == 0)
+ browser = browsers[count];
+ if (browser == null)
+ throw new Exception("Could not find web browser.");
+ else
+ Runtime.getRuntime().exec(new String[] {browser, url});
+ }
+ }
+ catch (Exception e) {
+ JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
+ }
+ }
+}
diff --git a/java/src/IceGridGUI/CellRenderer.java b/java/src/IceGridGUI/CellRenderer.java
index 8079c182d61..c067d2b6720 100755
--- a/java/src/IceGridGUI/CellRenderer.java
+++ b/java/src/IceGridGUI/CellRenderer.java
@@ -1,40 +1,40 @@
-// **********************************************************************
-//
-// 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;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.tree.DefaultTreeCellRenderer;
-
-class CellRenderer implements TreeCellRenderer
-{
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- TreeCellRenderer node = (TreeCellRenderer)value;
- Component result = node.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
-
- if(result == null)
- {
- result = _defaultRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
- return result;
- }
-
- private TreeCellRenderer _defaultRenderer = new DefaultTreeCellRenderer();
-}
+// **********************************************************************
+//
+// 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;
+
+import java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.tree.DefaultTreeCellRenderer;
+
+class CellRenderer implements TreeCellRenderer
+{
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ TreeCellRenderer node = (TreeCellRenderer)value;
+ Component result = node.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+
+ if(result == null)
+ {
+ result = _defaultRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+ return result;
+ }
+
+ private TreeCellRenderer _defaultRenderer = new DefaultTreeCellRenderer();
+}
diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java
index ece3ed0ea1f..37b042a6dae 100755
--- a/java/src/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/Coordinator.java
@@ -1,2016 +1,2016 @@
-// **********************************************************************
-//
-// 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;
-
-import java.util.prefs.Preferences;
-import java.util.prefs.BackingStoreException;
-
-import java.awt.BorderLayout;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Rectangle;
-import java.awt.Container;
-import java.awt.Component;
-import java.awt.Toolkit;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.File;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonGroup;
-import javax.swing.JButton;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JToggleButton;
-import javax.swing.JToolBar;
-import javax.swing.JTree;
-import javax.swing.KeyStroke;
-import javax.swing.SwingConstants;
-import javax.swing.SwingUtilities;
-
-import javax.swing.border.EmptyBorder;
-import javax.swing.filechooser.FileFilter;
-
-import com.jgoodies.looks.Options;
-import com.jgoodies.looks.HeaderStyle;
-import com.jgoodies.looks.BorderStyle;
-import com.jgoodies.looks.plastic.PlasticLookAndFeel;
-
-import IceGrid.*;
-
-//
-// This class coordinates the communications between the various objects
-// that make up the IceGrid GUI.
-// It also provides both the menu bar and tool bar.
-//
-public class Coordinator
-{
- private class StatusBarI extends JPanel implements StatusBar
- {
- StatusBarI()
- {
- super(new BorderLayout());
- setBorder(new EmptyBorder(0, 13, 10, 13));
-
- _text = new JLabel();
- _text.setHorizontalAlignment(SwingConstants.LEFT);
- add(_text, BorderLayout.LINE_START);
-
- _connectedLabel = new JLabel("Working Offline");
- _connectedLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- add(_connectedLabel, BorderLayout.LINE_END);
- }
-
- public void setText(String text)
- {
- _text.setText(text);
- }
-
- public void setConnected(boolean connected)
- {
- if(connected)
- {
- _connectedLabel.setText("Working Online");
- }
- else
- {
- _connectedLabel.setText("Working Offline");
- }
- }
-
- JLabel _connectedLabel;
- JLabel _text;
- }
-
- private class MenuBar extends JMenuBar
- {
- private MenuBar()
- {
- putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
- putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
-
- //
- // File menu
- //
- JMenu fileMenu = new JMenu("File");
- fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);
- add(fileMenu);
-
- //
- // New sub-menu
- //
- _newMenu = new JMenu("New");
- fileMenu.add(_newMenu);
- _newMenu.add(_newApplication);
- _newMenu.add(_newApplicationWithDefaultTemplates);
- _newMenu.addSeparator();
-
- _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_ADAPTER));
- _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_DBENV));
- _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_NODE));
- _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_PROPERTY_SET));
- _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_REPLICA_GROUP));
-
-
- //
- // Open sub-menu
- //
- JMenu openMenu = new JMenu("Open");
- openMenu.add(_openApplicationFromFile);
- openMenu.add(_openApplicationFromRegistry);
-
-
- //
- // New server sub-sub-menu
- //
- _newServerMenu = new JMenu("Server");
- _newServerMenu.setEnabled(false);
- _newMenu.add(_newServerMenu);
- _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER));
- _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER_ICEBOX));
- _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER_FROM_TEMPLATE));
-
- //
- // New service sub-sub-menu
- //
- _newServiceMenu = new JMenu("Service");
- _newServiceMenu.setEnabled(false);
- _newMenu.add(_newServiceMenu);
- _newServiceMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVICE));
- _newServiceMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVICE_FROM_TEMPLATE));
-
- //
- // New template sub-sub-menu
- //
- _newTemplateMenu = new JMenu("Template");
- _newTemplateMenu.setEnabled(false);
- _newMenu.add(_newTemplateMenu);
- _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER));
- _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER_ICEBOX));
- _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVICE));
-
- fileMenu.addSeparator();
- fileMenu.add(_login);
- fileMenu.add(_logout);
- fileMenu.addSeparator();
- fileMenu.add(_acquireExclusiveWriteAccess);
- fileMenu.add(_releaseExclusiveWriteAccess);
- fileMenu.addSeparator();
- fileMenu.add(openMenu);
- fileMenu.add(_closeApplication);
- fileMenu.add(_save);
- fileMenu.add(_saveToFile);
- fileMenu.add(_saveToRegistry);
- fileMenu.addSeparator();
- fileMenu.add(_discardUpdates);
- fileMenu.addSeparator();
- fileMenu.add(_exit);
-
- //
- // Edit menu
- //
- JMenu editMenu = new JMenu("Edit");
- editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E);
- add(editMenu);
- editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.COPY));
- editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.PASTE));
- editMenu.addSeparator();
- editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.DELETE));
- editMenu.addSeparator();
- editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.MOVE_UP));
- editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.MOVE_DOWN));
-
- //
- // View menu
- //
- JMenu viewMenu = new JMenu("View");
- viewMenu.setMnemonic(java.awt.event.KeyEvent.VK_V);
- add(viewMenu);
- viewMenu.add(_showVarsMenuItem);
- viewMenu.add(_substituteMenuItem);
- viewMenu.addSeparator();
- viewMenu.add(_back);
- viewMenu.add(_forward);
-
- //
- // Tools menu
- //
- JMenu toolsMenu = new JMenu("Tools");
- toolsMenu.setMnemonic(java.awt.event.KeyEvent.VK_T);
- add(toolsMenu);
-
- //
- // Application sub-menu
- //
- _appMenu = new JMenu("Application");
- _appMenu.setEnabled(false);
- toolsMenu.add(_appMenu);
- _appMenu.add(_patchApplication);
- _appMenu.setEnabled(false);
-
- //
- // Node sub-menu
- //
- _nodeMenu = new JMenu("Node");
- _nodeMenu.setEnabled(false);
- toolsMenu.add(_nodeMenu);
- _nodeMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.SHUTDOWN_NODE));
-
- //
- // Registry sub-menu
- //
- _registryMenu = new JMenu("Registry");
- _registryMenu.setEnabled(false);
- toolsMenu.add(_registryMenu);
- _registryMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.ADD_OBJECT));
-
- //
- // Server sub-menu
- //
- _serverMenu = new JMenu("Server");
- _serverMenu.setEnabled(false);
- toolsMenu.add(_serverMenu);
- _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.START));
- _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.STOP));
- _serverMenu.addSeparator();
- _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.ENABLE));
- _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.DISABLE));
- _serverMenu.addSeparator();
- _serverMenu.add(_liveActionsForMenu.get(
- IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER));
-
- //
- // Help menu
- //
- JMenu helpMenu = new JMenu("Help");
- helpMenu.setMnemonic(java.awt.event.KeyEvent.VK_H);
- add(helpMenu);
-
- helpMenu.add(_helpContents);
-
- helpMenu.addSeparator();
- helpMenu.add(_about);
- }
- }
-
- private class ToolBar extends JToolBar
- {
- private ToolBar()
- {
- putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
- putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
- setFloatable(false);
- putClientProperty("JToolBar.isRollover", Boolean.TRUE);
-
- JButton button = new JButton(_login);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/login.png"));
- add(button);
- button = new JButton(_logout);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/logout.png"));
- add(button);
-
- addSeparator();
-
- button = new JButton(_back);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/back.png"));
- add(button);
- button = new JButton(_forward);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/forward.png"));
- add(button);
-
- addSeparator();
-
- button = new JButton(_openApplicationFromRegistry);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/open_from_registry.png"));
- add(button);
- button = new JButton(_openApplicationFromFile);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/open_from_file.png"));
- add(button);
-
- addSeparator();
-
- button = new JButton(_save);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/save.png"));
- add(button);
- button = new JButton(_saveToRegistry);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/save_to_registry.png"));
- add(button);
- button = new JButton(_saveToFile);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/save_to_file.png"));
- add(button);
- button = new JButton(_discardUpdates);
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/discard.png"));
- add(button);
-
- addSeparator();
-
- button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.COPY));
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/copy.png"));
- add(button);
- button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.PASTE));
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/paste.png"));
- add(button);
- button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.DELETE));
- button.setText(null);
- button.setIcon(Utils.getIcon("/icons/24x24/delete.png"));
- add(button);
-
- addSeparator();
-
- add(_showVarsTool);
- add(_substituteTool);
- }
- }
-
- //
- // All Coordinator's methods run in the UI thread
- //
- public Ice.Communicator getCommunicator()
- {
- if(_communicator == null)
- {
- try
- {
- _communicator = Ice.Util.initialize(_initData);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(null,
- e.toString(),
- "Communicator initialization failed",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- return _communicator;
- }
-
- public Ice.Properties getProperties()
- {
- return _initData.properties;
- }
-
- public Tab getCurrentTab()
- {
- return (Tab)_mainPane.getSelectedComponent();
- }
-
- public Action getBackAction()
- {
- return _back;
- }
-
- public Action getForwardAction()
- {
- return _forward;
- }
-
- public Action getCloseApplicationAction()
- {
- return _closeApplication;
- }
-
- public Action getSaveAction()
- {
- return _save;
- }
-
- public Action getSaveToRegistryAction()
- {
- return _saveToRegistry;
- }
-
- public Action getSaveToFileAction()
- {
- return _saveToFile;
- }
-
- public Action getDiscardUpdatesAction()
- {
- return _discardUpdates;
- }
-
- //
- // Open live application and select application tab
- //
- public ApplicationPane openLiveApplication(String applicationName)
- {
- ApplicationPane app = (ApplicationPane)_liveApplications.get(applicationName);
- if(app == null)
- {
- ApplicationDescriptor desc =
- _liveDeploymentRoot.getApplicationDescriptor(applicationName);
- if(desc == null)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "The application '" + applicationName + "' was not found in the registry.",
- "No such application",
- JOptionPane.ERROR_MESSAGE);
- }
- //
- // Essential: deep-copy desc!
- //
- desc = IceGridGUI.Application.Root.copyDescriptor(desc);
- app = new ApplicationPane(new IceGridGUI.Application.Root(this, desc, true, null));
- _mainPane.addApplication(app);
- _liveApplications.put(applicationName, app);
- }
- _mainPane.setSelectedComponent(app);
- return app;
- }
-
- public void removeLiveApplication(String name)
- {
- _liveApplications.remove(name);
- }
-
- public void addLiveApplication(IceGridGUI.Application.Root root)
- {
- ApplicationPane app = _mainPane.findApplication(root);
- assert app != null;
- _liveApplications.put(app.getRoot().getId(), app);
- }
-
- public ApplicationPane getLiveApplication(String name)
- {
- return (ApplicationPane)_liveApplications.get(name);
- }
-
-
- //
- // From the Application observer:
- //
- void applicationInit(String instanceName, int serial, java.util.List applications)
- {
- assert _latestSerial == -1;
- _latestSerial = serial;
-
- _liveDeploymentRoot.applicationInit(instanceName, applications);
- //
- // When we get this init, we can't have any live Application yet.
- //
- }
-
- void applicationAdded(int serial, ApplicationDescriptor desc)
- {
- _liveDeploymentRoot.applicationAdded(desc);
- _statusBar.setText(
- "Last update: new application '" + desc.name + "'");
- updateSerial(serial);
- }
-
- void applicationRemoved(int serial, String name)
- {
- _liveDeploymentRoot.applicationRemoved(name);
- _statusBar.setText(
- "Last update: application '" + name + "' was removed");
-
- ApplicationPane app =
- (ApplicationPane)_liveApplications.get(name);
-
- if(app != null)
- {
- if(app.getRoot().kill())
- {
- _mainPane.remove(app);
- }
- _liveApplications.remove(name);
- }
- updateSerial(serial);
- }
-
- void applicationUpdated(int serial, ApplicationUpdateDescriptor desc)
- {
- _liveDeploymentRoot.applicationUpdated(desc);
- _liveDeploymentPane.refresh();
-
- _statusBar.setText("Last update: application '" + desc.name + "' was updated");
-
- ApplicationPane app =
- (ApplicationPane)_liveApplications.get(desc.name);
-
- if(app != null)
- {
- if(app.getRoot().update(desc))
- {
- app.refresh();
- }
- }
- updateSerial(serial);
- }
-
- //
- // From the Adapter observer:
- //
- void adapterInit(AdapterInfo[] adapters)
- {
- _liveDeploymentRoot.adapterInit(adapters);
- // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
- }
-
- void adapterAdded(AdapterInfo info)
- {
- _liveDeploymentRoot.adapterAdded(info);
- _liveDeploymentPane.refresh();
- }
-
- void adapterUpdated(AdapterInfo info)
- {
- _liveDeploymentRoot.adapterUpdated(info);
- _liveDeploymentPane.refresh();
- }
-
- void adapterRemoved(String id)
- {
- _liveDeploymentRoot.adapterRemoved(id);
- _liveDeploymentPane.refresh();
- }
-
- //
- // From the Object observer:
- //
- void objectInit(ObjectInfo[] objects)
- {
- _liveDeploymentRoot.objectInit(objects);
- // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
- }
-
- void objectAdded(ObjectInfo info)
- {
- _liveDeploymentRoot.objectAdded(info);
- _liveDeploymentPane.refresh();
- }
-
- void objectUpdated(ObjectInfo info)
- {
- _liveDeploymentRoot.objectUpdated(info);
- _liveDeploymentPane.refresh();
- }
-
- void objectRemoved(Ice.Identity id)
- {
- _liveDeploymentRoot.objectRemoved(id);
- _liveDeploymentPane.refresh();
- }
-
- public void accessDenied(AccessDeniedException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Another session (username = " + e.lockUserId
- + ") has exclusive write access to the registry",
- "Access Denied",
- JOptionPane.ERROR_MESSAGE);
- }
-
- public void pasteApplication()
- {
- Object descriptor = getClipboard();
- ApplicationDescriptor desc =
- IceGridGUI.Application.Root.copyDescriptor((ApplicationDescriptor)descriptor);
-
- IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, desc);
- ApplicationPane app = new ApplicationPane(root);
- _mainPane.addApplication(app);
- _mainPane.setSelectedComponent(app);
- root.setSelectedNode(root);
- }
-
- public void removeApplicationFromRegistry(String name)
- {
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- boolean acquired = false;
- try
- {
- acquireExclusiveWriteAccess(null);
- acquired = true;
- _sessionKeeper.getAdmin().removeApplication(name);
- }
- catch(AccessDeniedException e)
- {
- accessDenied(e);
- }
- catch(DeploymentException e)
- {
- //
- // TODO: XXX: The application couldn't be removed (probably because we tried to remove it from a slave).
- //
- }
- catch(ApplicationNotExistException e)
- {
- //
- // Somebody else deleted this application at about the same time
- //
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Could not remove application '" + name +
- "' from IceGrid registry:\n" + e.toString(),
- "Trouble with IceGrid registry",
- JOptionPane.ERROR_MESSAGE);
- }
- finally
- {
- if(acquired)
- {
- releaseExclusiveWriteAccess();
- }
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public void acquireExclusiveWriteAccess(Runnable runnable)
- throws AccessDeniedException
- {
- if(_writeSerial == -1)
- {
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try
- {
- _writeSerial = _sessionKeeper.getSession().startUpdate();
- }
- finally
- {
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- assert _onExclusiveWrite == null;
-
- //
- // Must increment now since run() can call releaseExclusiveWriteAccess()
- //
- _writeAccessCount++;
-
- if(runnable != null)
- {
- if(_writeSerial <= _latestSerial)
- {
- runnable.run();
- }
- else
- {
- _onExclusiveWrite = runnable;
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- //
- // TODO: start a thread to check we don't wait forever
- //
- }
- }
- }
-
- public void releaseExclusiveWriteAccess()
- {
- if(--_writeAccessCount == 0)
- {
- try
- {
- _writeSerial = -1;
- _sessionKeeper.getSession().finishUpdate();
- }
- catch(AccessDeniedException e)
- {
- accessDenied(e);
- }
- catch(Ice.ObjectNotExistException e)
- {
- //
- // Ignored, the session is gone, and so is the exclusive access.
- //
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Could not release exclusive write access on the IceGrid registry:\n"
- + e.toString(),
- "Trouble with IceGrid registry",
- JOptionPane.ERROR_MESSAGE);
- }
- }
- }
-
- private void updateSerial(int serial)
- {
- assert serial == _latestSerial + 1;
- _latestSerial = serial;
-
- if(_writeAccessCount > 0 &&
- _writeSerial <= _latestSerial &&
- _onExclusiveWrite != null)
- {
- Runnable runnable = _onExclusiveWrite;
- _onExclusiveWrite = null;
- runnable.run();
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- //
- // From the Node observer:
- //
- void nodeUp(NodeDynamicInfo updatedInfo)
- {
- _liveDeploymentRoot.nodeUp(updatedInfo);
- _liveDeploymentPane.refresh();
- }
-
- void nodeDown(String node)
- {
- _liveDeploymentRoot.nodeDown(node);
- _liveDeploymentPane.refresh();
- }
-
- void updateServer(String node, ServerDynamicInfo updatedInfo)
- {
- _liveDeploymentRoot.updateServer(node, updatedInfo);
- _liveDeploymentPane.refresh();
- }
-
- void updateAdapter(String node, AdapterDynamicInfo updatedInfo)
- {
- _liveDeploymentRoot.updateAdapter(node, updatedInfo);
- _liveDeploymentPane.refresh();
- }
-
- void sessionLost()
- {
- _latestSerial = -1;
- _writeSerial = -1;
- _writeAccessCount = 0;
- _onExclusiveWrite = null;
- _liveDeploymentRoot.clear();
-
- //
- // Kill all live applications
- //
- java.util.Iterator p = _liveApplications.values().iterator();
- while(p.hasNext())
- {
- ApplicationPane app = (ApplicationPane)p.next();
- if(app.getRoot().kill())
- {
- _mainPane.remove(app);
- }
- }
- _liveApplications.clear();
-
- _logout.setEnabled(false);
- _openApplicationFromRegistry.setEnabled(false);
- _patchApplication.setEnabled(false);
- _appMenu.setEnabled(false);
- _newApplicationWithDefaultTemplates.setEnabled(false);
- _acquireExclusiveWriteAccess.setEnabled(false);
- _releaseExclusiveWriteAccess.setEnabled(false);
- _saveToRegistry.setEnabled(false);
- }
-
- AdminSessionPrx login(SessionKeeper.LoginInfo info, Component parent)
- {
- _liveDeploymentRoot.clear();
-
- AdminSessionPrx session = null;
-
- destroyCommunicator();
-
- Ice.InitializationData initData = _initData;
- if(info.routed && info.routerSSLEnabled || !info.routed && info.registrySSLEnabled)
- {
- initData = (Ice.InitializationData)initData.clone();
- initData.properties = initData.properties._clone();
- initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory");
-
- //
- // Transform SSL info into properties
- //
- initData.properties.setProperty("IceSSL.Keystore", info.keystore);
- initData.properties.setProperty("IceSSL.Password", new String(info.keyPassword));
- initData.properties.setProperty("IceSSL.KeystorePassword", new String(info.keystorePassword));
- initData.properties.setProperty("IceSSL.Alias", info.alias);
- initData.properties.setProperty("IceSSL.Truststore", info.truststore);
- initData.properties.setProperty("IceSSL.TruststorePassword", new String(info.truststorePassword));
- }
-
- try
- {
- _communicator = Ice.Util.initialize(initData);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(parent,
- e.toString(),
- "Communicator initialization failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
-
- if(info.routed)
- {
- //
- // Router
- //
-
-
- Ice.Identity routerId = new Ice.Identity();
- routerId.category = info.routerInstanceName;
- routerId.name = "router";
- String str = "\"" + _communicator.identityToString(routerId) + "\"";
-
- if(!info.routerEndpoints.equals(""))
- {
- str += ":" + info.routerEndpoints;
- }
-
- try
- {
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.
- uncheckedCast(_communicator.stringToProxy(str));
-
- //
- // The session must be routed through this router
- //
- _communicator.setDefaultRouter(router);
-
- Glacier2.SessionPrx s;
- if(info.routerUseSSL)
- {
- router = Glacier2.RouterPrxHelper.
- uncheckedCast(router.ice_secure(true));
-
- s = router.createSessionFromSecureConnection();
-
- if(s == null)
- {
- JOptionPane.showMessageDialog(
- parent,
- "createSessionFromSecureConnection returned a null session: \n"
- + "verify that Glacier2.SSLSessionManager is set to "
- + "<IceGridInstanceName>/AdminSSLSessionManager in your Glacier2 router configuration",
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
-
- return null;
- }
- }
- else
- {
- s = router.createSession(
- info.routerUsername, new String(info.routerPassword));
-
- if(s == null)
- {
- JOptionPane.showMessageDialog(
- parent,
- "createSession returned a null session: \n"
- + "verify that Glacier2.SessionManager is set to "
- + "<IceGridInstanceName>/AdminSessionManager in your Glacier2 router configuration",
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
-
- return null;
- }
- }
-
- session = AdminSessionPrxHelper.uncheckedCast(s);
- }
- catch(Glacier2.PermissionDeniedException e)
- {
- if(e.reason.length() == 0)
- {
- e.reason = info.routerUseSSL ? "Invalid credentials" : "Invalid username/password";
- }
- JOptionPane.showMessageDialog(parent,
- "Permission denied: "
- + e.reason,
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- catch(Glacier2.CannotCreateSessionException e)
- {
- JOptionPane.showMessageDialog(parent,
- "Could not create session: "
- + e.reason,
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(parent,
- "Could not create session: "
- + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- }
- else
- {
- //
- // The client uses the locator only without routing
- //
- Ice.Identity locatorId = new Ice.Identity();
- locatorId.category = info.registryInstanceName;
- locatorId.name = "Locator";
- String str = "\"" + _communicator.identityToString(locatorId) + "\"";
- if(!info.registryEndpoints.equals(""))
- {
- str += ":" + info.registryEndpoints;
- }
-
- try
- {
- Ice.LocatorPrx defaultLocator = Ice.LocatorPrxHelper.
- checkedCast(_communicator.stringToProxy(str));
- _communicator.setDefaultLocator(defaultLocator);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- parent,
- "Could not contact '" + str + "': " + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
-
- //
- // Local session
- //
- Ice.Identity registryId = new Ice.Identity();
- registryId.category = info.registryInstanceName;
- registryId.name = "Registry";
-
- RegistryPrx registry = RegistryPrxHelper.
- uncheckedCast(_communicator.stringToProxy("\"" + _communicator.identityToString(registryId) + "\""));
-
- try
- {
- if(info.registryUseSSL)
- {
- registry = RegistryPrxHelper.
- uncheckedCast(registry.ice_secure(true));
-
- session = AdminSessionPrxHelper.uncheckedCast(
- registry.createAdminSessionFromSecureConnection());
- }
- else
- {
- session = AdminSessionPrxHelper.uncheckedCast(
- registry.createAdminSession(info.registryUsername,
- new String(info.registryPassword)));
- }
- }
- catch(IceGrid.PermissionDeniedException e)
- {
- JOptionPane.showMessageDialog(parent,
- "Permission denied: "
- + e.reason,
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(parent,
- "Could not create session: "
- + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- }
-
- _logout.setEnabled(true);
- _openApplicationFromRegistry.setEnabled(true);
- _patchApplication.setEnabled(true);
- _appMenu.setEnabled(true);
- _newApplicationWithDefaultTemplates.setEnabled(true);
- _acquireExclusiveWriteAccess.setEnabled(true);
-
- _mainPane.setSelectedComponent(_liveDeploymentPane);
-
- return session;
- }
-
-
- void destroySession(AdminSessionPrx session)
- {
- Ice.RouterPrx router = _communicator.getDefaultRouter();
-
- try
- {
- if(router == null)
- {
- session.destroy();
- }
- else
- {
- Glacier2.RouterPrx gr
- = Glacier2.RouterPrxHelper.uncheckedCast(router);
- gr.destroySession();
- }
- }
- catch(Glacier2.SessionNotExistException e)
- {
- // Ignored
- }
- catch(Ice.LocalException e)
- {
- // Ignored
- }
- }
-
- void showVars()
- {
- substitute(false);
- }
-
- void substituteVars()
- {
- substitute(true);
- }
-
- private void substitute(boolean newValue)
- {
- if(_substitute != newValue)
- {
- _substitute = newValue;
-
- if(_substitute)
- {
- _substituteMenuItem.setSelected(true);
- _substituteTool.setSelected(true);
- }
- else
- {
- _showVarsMenuItem.setSelected(true);
- _showVarsTool.setSelected(true);
- }
- getCurrentTab().refresh();
- }
- }
-
- public boolean substitute()
- {
- return _substitute;
- }
-
- public AdminPrx getAdmin()
- {
- return _sessionKeeper.getAdmin();
- }
-
- public StatusBar getStatusBar()
- {
- return _statusBar;
- }
-
- public JFrame getMainFrame()
- {
- return _mainFrame;
- }
-
- public MainPane getMainPane()
- {
- return _mainPane;
- }
-
- public ApplicationDescriptor parseFile(File file)
- {
- if(_icegridadminProcess == null)
- {
- //
- // Start icegridadmin server
- //
- try
- {
- _icegridadminProcess = Runtime.getRuntime().exec("icegridadmin --server");
- }
- catch(java.io.IOException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Failed to start icegridadmin subprocess: " + e.toString(),
- "IO Exception",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
-
- try
- {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(_icegridadminProcess.getInputStream(),
- "US-ASCII"));
-
- String str = reader.readLine();
- reader.close();
-
- if(str == null || str.length() == 0)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "The icegridadmin subprocess failed",
- "Subprocess failure",
- JOptionPane.ERROR_MESSAGE);
- destroyIceGridAdmin();
- return null;
- }
- _fileParser = str;
- }
- catch(java.io.UnsupportedEncodingException e)
- {
- assert false;
- }
- catch(java.io.IOException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "IO Exception: " + e.toString(),
- "IO Exception",
- JOptionPane.ERROR_MESSAGE);
-
- destroyIceGridAdmin();
- return null;
- }
- }
-
- try
- {
- FileParserPrx fileParser = FileParserPrxHelper.checkedCast(
- getCommunicator().stringToProxy(_fileParser).ice_router(null));
- return fileParser.parse(file.getAbsolutePath(),
- _sessionKeeper.getRoutedAdmin());
- }
- catch(ParseException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Failed to parse file '" + file.getAbsolutePath() + "':\n" + e.toString(),
- "Parse error",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Operation on FileParser failed:\n" + e.toString(),
- "Communication error",
- JOptionPane.ERROR_MESSAGE);
- destroyIceGridAdmin();
- return null;
- }
- }
-
- private void destroyIceGridAdmin()
- {
- if(_icegridadminProcess != null)
- {
- try
- {
- _icegridadminProcess.destroy();
- }
- catch(Exception e)
- {}
- _icegridadminProcess = null;
- _fileParser = null;
- }
- }
-
-
- public File saveToFile(boolean ask, IceGridGUI.Application.Root root,
- File file)
- {
- if(ask || file == null)
- {
- if(file != null)
- {
- _fileChooser.setSelectedFile(file);
- }
- int result = _fileChooser.showSaveDialog(_mainFrame);
- if(result == JFileChooser.APPROVE_OPTION)
- {
- file = _fileChooser.getSelectedFile();
- }
- else
- {
- file = null;
- }
- }
- if(file != null)
- {
- try
- {
- XMLWriter writer = new XMLWriter(file);
- root.write(writer);
- writer.close();
- _statusBar.setText(
- "Saved application '" + root.getId() + "' to "
- + file.getAbsolutePath());
- }
- catch(java.io.FileNotFoundException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Cannot use the selected file for writing.",
- "File Not Found",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- catch(java.io.IOException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "IO Exception: " + e.toString(),
- "IO Exception",
- JOptionPane.ERROR_MESSAGE);
- return null;
- }
- }
- return file;
- }
-
-
- static private Ice.Properties createProperties(Ice.StringSeqHolder args)
- {
- Ice.Properties properties = Ice.Util.createProperties();
-
- //
- // Set various default values
- //
- properties.setProperty("Ice.Override.ConnectTimeout", "5000");
-
- properties.setProperty("Ice.ThreadPerConnection", "1");
-
- //
- // For Glacier
- //
- properties.setProperty("Ice.ACM.Client", "0");
- properties.setProperty("Ice.MonitorConnections", "5");
-
- //
- // Disable retries
- //
- properties.setProperty("Ice.RetryIntervals", "-1");
-
- return Ice.Util.createProperties(args, properties);
- }
-
- Coordinator(JFrame mainFrame, Ice.StringSeqHolder args, Preferences prefs)
- {
- _mainFrame = mainFrame;
- _prefs = prefs;
- _initData = new Ice.InitializationData();
-
- _initData.properties = createProperties(args);
-
- if(args.value.length > 0)
- {
- //
- // TODO: use proper logging
- //
- System.err.println("WARNING: extra command-line arguments");
- for(int i = 0; i < args.value.length; ++i)
- {
- System.err.println(args.value[i]);
- }
- }
-
- _liveDeploymentRoot = new IceGridGUI.LiveDeployment.Root(this);
-
- _sessionKeeper = new SessionKeeper(this);
-
- _shutdownHook = new Thread("Shutdown hook")
- {
- public void run()
- {
- destroyIceGridAdmin();
- destroyCommunicator();
- }
- };
- Runtime.getRuntime().addShutdownHook(_shutdownHook);
-
- _fileChooser = new JFileChooser();
- _fileChooser.addChoosableFileFilter(new FileFilter()
- {
- public boolean accept(File f)
- {
- return f.isDirectory() || f.getName().endsWith(".xml");
- }
-
- public String getDescription()
- {
- return ".xml files";
- }
- });
-
-
- final int MENU_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-
- //
- // Common actions (nodes not involved)
- //
- _newApplication = new AbstractAction("Application")
- {
- public void actionPerformed(ActionEvent e)
- {
- newApplication();
- }
- };
-
- _newApplicationWithDefaultTemplates =
- new AbstractAction("Application with default templates from registry")
- {
- public void actionPerformed(ActionEvent e)
- {
- newApplicationWithDefaultTemplates();
- }
- };
- _newApplicationWithDefaultTemplates.setEnabled(false);
-
- _login = new AbstractAction("Login...")
- {
- public void actionPerformed(ActionEvent e)
- {
- _sessionKeeper.relog(true);
- }
- };
- _login.putValue(Action.SHORT_DESCRIPTION,
- "Log into an IceGrid registry");
-
- _logout = new AbstractAction("Logout")
- {
- public void actionPerformed(ActionEvent e)
- {
- _sessionKeeper.logout(true);
- }
- };
- _logout.putValue(Action.SHORT_DESCRIPTION, "Logout");
- _logout.setEnabled(false);
-
- _acquireExclusiveWriteAccess = new AbstractAction("Acquire exclusive write access")
- {
- public void actionPerformed(ActionEvent e)
- {
- try
- {
- acquireExclusiveWriteAccess(null);
- _releaseExclusiveWriteAccess.setEnabled(true);
- _acquireExclusiveWriteAccess.setEnabled(false);
- }
- catch(AccessDeniedException ade)
- {
- accessDenied(ade);
- }
- }
- };
- _acquireExclusiveWriteAccess.putValue(Action.SHORT_DESCRIPTION,
- "Acquire exclusive write access on the registry");
- _acquireExclusiveWriteAccess.setEnabled(false);
-
-
- _releaseExclusiveWriteAccess = new AbstractAction("Release exclusive write access")
- {
- public void actionPerformed(ActionEvent e)
- {
- releaseExclusiveWriteAccess();
- _acquireExclusiveWriteAccess.setEnabled(true);
- _releaseExclusiveWriteAccess.setEnabled(false);
- }
- };
- _releaseExclusiveWriteAccess.putValue(Action.SHORT_DESCRIPTION,
- "Release exclusive write access on the registry");
- _releaseExclusiveWriteAccess.setEnabled(false);
-
- _openApplicationFromFile = new AbstractAction("Application from file")
- {
- public void actionPerformed(ActionEvent e)
- {
- int result = _fileChooser.showOpenDialog(_mainFrame);
- if(result == JFileChooser.APPROVE_OPTION)
- {
- File file = _fileChooser.getSelectedFile();
-
- ApplicationDescriptor desc = parseFile(file);
-
- if(desc != null)
- {
- IceGridGUI.Application.Root root =
- new IceGridGUI.Application.Root(Coordinator.this, desc, false, file);
- ApplicationPane app = new ApplicationPane(root);
- _mainPane.addApplication(app);
- _mainPane.setSelectedComponent(app);
- root.setSelectedNode(root);
- }
- }
- }
- };
- _openApplicationFromFile.putValue(Action.SHORT_DESCRIPTION, "Open application from file");
- _openApplicationFromFile.setEnabled(true);
-
- _openApplicationFromRegistry = new AbstractAction("Application from registry")
- {
- public void actionPerformed(ActionEvent e)
- {
- Object[] applicationNames = _liveDeploymentRoot.getApplicationNames();
-
- if(applicationNames.length == 0)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "The registry does not contain any application",
- "Empty registry",
- JOptionPane.INFORMATION_MESSAGE);
- }
- else
- {
- String appName = (String)JOptionPane.showInputDialog(
- _mainFrame, "Which Application do you want to open?",
- "Open Application from registry",
- JOptionPane.QUESTION_MESSAGE, null,
- applicationNames, applicationNames[0]);
-
- if(appName != null)
- {
- IceGridGUI.Application.Root root = openLiveApplication(appName).getRoot();
- if(root.getSelectedNode() == null)
- {
- root.setSelectedNode(root);
- }
- }
- }
- }
- };
- _openApplicationFromRegistry.putValue(Action.SHORT_DESCRIPTION, "Open application from registry");
- _openApplicationFromRegistry.setEnabled(false);
-
- _closeApplication = new AbstractAction("Close application")
- {
- public void actionPerformed(ActionEvent e)
- {
- Tab tab = getCurrentTab();
- if(tab.close())
- {
- String id = ((ApplicationPane)tab).getRoot().getId();
- _liveApplications.remove(id);
- }
- }
- };
- _closeApplication.putValue(Action.SHORT_DESCRIPTION, "Close application");
- _closeApplication.setEnabled(false);
-
- _save = new AbstractAction("Save")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().save();
- }
- };
- _save.setEnabled(false);
- _save.putValue(Action.ACCELERATOR_KEY,
- KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK));
- _save.putValue(Action.SHORT_DESCRIPTION, "Save");
-
-
- _saveToRegistry = new AbstractAction("Save to registry")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().saveToRegistry();
- }
- };
- _saveToRegistry.setEnabled(false);
- _saveToRegistry.putValue(Action.SHORT_DESCRIPTION, "Save to registry");
-
-
- _saveToFile = new AbstractAction("Save to file")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().saveToFile();
- }
- };
- _saveToFile.setEnabled(false);
- _saveToFile.putValue(Action.SHORT_DESCRIPTION, "Save to file");
-
-
- _discardUpdates = new AbstractAction("Discard updates...")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().discardUpdates();
- }
- };
- _discardUpdates.setEnabled(false);
- _discardUpdates.putValue(Action.SHORT_DESCRIPTION, "Discard updates");
-
-
- _exit = new AbstractAction("Exit")
- {
- public void actionPerformed(ActionEvent e)
- {
- exit(0);
- }
- };
- _exit.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt F4"));
-
-
- _back = new AbstractAction("Go back to the previous node")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().back();
- }
- };
- _back.setEnabled(false);
- _back.putValue(Action.SHORT_DESCRIPTION, "Go back to the previous node");
-
- _forward = new AbstractAction("Go to the next node")
- {
- public void actionPerformed(ActionEvent e)
- {
- getCurrentTab().forward();
- }
- };
- _forward.setEnabled(false);
- _forward.putValue(Action.SHORT_DESCRIPTION, "Go to the next node");
-
- _helpContents = new AbstractAction("Contents")
- {
- public void actionPerformed(ActionEvent e)
- {
- helpContents();
- }
- };
-
- _about = new AbstractAction("About")
- {
- public void actionPerformed(ActionEvent e)
- {
- about();
- }
- };
-
- _patchApplication = new AbstractAction("Patch distribution")
- {
- public void actionPerformed(ActionEvent e)
- {
- Object[] applicationNames = _liveDeploymentRoot.getPatchableApplicationNames();
-
- if(applicationNames.length == 0)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "No application in this IceGrid registry can be patched",
- "No application",
- JOptionPane.INFORMATION_MESSAGE);
- }
- else
- {
- String appName = (String)JOptionPane.showInputDialog(
- _mainFrame, "Which Application do you want to patch?",
- "Patch application",
- JOptionPane.QUESTION_MESSAGE, null,
- applicationNames, applicationNames[0]);
-
- if(appName != null)
- {
- _liveDeploymentRoot.patch(appName);
- }
- }
- }
- };
- _patchApplication.setEnabled(false);
-
- _showVarsMenuItem = new
- JCheckBoxMenuItem(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SHOW_VARS));
- _showVarsTool = new
- JToggleButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SHOW_VARS));
- _showVarsTool.setIcon(Utils.getIcon("/icons/24x24/show_vars.png"));
- _showVarsTool.setText("");
-
- _substituteMenuItem = new
- JCheckBoxMenuItem(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SUBSTITUTE_VARS));
- _substituteTool = new
- JToggleButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SUBSTITUTE_VARS));
- _substituteTool.setIcon(Utils.getIcon("/icons/24x24/substitute.png"));
- _substituteTool.setText("");
-
-
- ButtonGroup group = new ButtonGroup();
- group.add(_showVarsMenuItem);
- group.add(_substituteMenuItem);
- group = new ButtonGroup();
- group.add(_showVarsTool);
- group.add(_substituteTool);
-
- _showVarsMenuItem.setSelected(true);
- _showVarsTool.setSelected(true);
-
- _mainFrame.setJMenuBar(new MenuBar());
-
- _mainFrame.getContentPane().add(new ToolBar(),
- BorderLayout.PAGE_START);
-
- _mainFrame.getContentPane().add((StatusBarI)_statusBar,
- BorderLayout.PAGE_END);
-
- _liveDeploymentPane = new LiveDeploymentPane(_liveDeploymentRoot);
- _mainPane = new MainPane(this);
- _mainFrame.getContentPane().add(_mainPane, BorderLayout.CENTER);
- }
-
- JComponent getLiveDeploymentPane()
- {
- return _liveDeploymentPane;
- }
-
- public IceGridGUI.LiveDeployment.Root getLiveDeploymentRoot()
- {
- return _liveDeploymentRoot;
- }
-
- private void newApplication()
- {
- ApplicationDescriptor desc = new ApplicationDescriptor("NewApplication",
- new java.util.TreeMap(),
- new java.util.LinkedList(),
- new java.util.HashMap(),
- new java.util.HashMap(),
- new java.util.HashMap(),
- new IceGrid.DistributionDescriptor(
- "", new java.util.LinkedList()),
- "",
- new java.util.HashMap());
- IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, desc);
- ApplicationPane app = new ApplicationPane(root);
- _mainPane.addApplication(app);
- _mainPane.setSelectedComponent(app);
- root.setSelectedNode(root);
- }
-
- private void newApplicationWithDefaultTemplates()
- {
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try
- {
- ApplicationDescriptor descriptor = getAdmin().getDefaultApplicationDescriptor();
- descriptor.name = "NewApplication";
- IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, descriptor);
- ApplicationPane app = new ApplicationPane(root);
- _mainPane.addApplication(app);
- _mainPane.setSelectedComponent(app);
- root.setSelectedNode(root);
- }
- catch(DeploymentException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "The default application descriptor from the IceGrid registry is invalid:\n"
- + e.reason,
- "Deployment Exception",
- JOptionPane.ERROR_MESSAGE);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _mainFrame,
- "Could not retrieve the default application descriptor from the IceGrid registry: \n"
- + e.toString(),
- "Trouble with IceGrid registry",
- JOptionPane.ERROR_MESSAGE);
- }
- finally
- {
- _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- private void helpContents()
- {
- BareBonesBrowserLaunch.openURL(
- "http://www.zeroc.com/help/IceGridAdmin/");
- }
-
- private void about()
- {
- String text = "IceGrid Admin version "
- + IceUtil.Version.ICE_STRING_VERSION + "\n"
- + "Copyright \u00A9 2005-2006 ZeroC, Inc. All rights reserved.\n";
-
- JOptionPane.showMessageDialog(
- _mainFrame,
- text,
- "About - IceGrid Admin",
- JOptionPane.INFORMATION_MESSAGE);
- }
-
- public void setClipboard(Object copy)
- {
- _clipboard = copy;
- }
-
- public Object getClipboard()
- {
- return _clipboard;
- }
-
- void showMainFrame()
- {
- if(!loadWindowPrefs())
- {
- _mainFrame.setLocation(100, 100);
- _mainFrame.pack();
- }
- _mainFrame.setVisible(true);
- }
-
- void exit(int status)
- {
- storeWindowPrefs();
- destroyIceGridAdmin();
- destroyCommunicator();
- Runtime.getRuntime().removeShutdownHook(_shutdownHook);
- _mainFrame.dispose();
- Runtime.getRuntime().exit(status);
- }
-
- //
- // Can be called by the shutdown hook thread
- //
- private void destroyCommunicator()
- {
- if(_communicator != null)
- {
- try
- {
- _communicator.destroy();
- }
- catch(Ice.LocalException e)
- {
- System.err.println("_communicator.destroy() raised "
- + e.toString());
- e.printStackTrace();
- }
- _communicator = null;
- }
- }
-
- private boolean loadWindowPrefs()
- {
- try
- {
- if(!_prefs.nodeExists("Window"))
- {
- return false;
- }
- }
- catch(BackingStoreException e)
- {
- return false;
- }
-
- Preferences windowPrefs = _prefs.node("Window");
- int x = windowPrefs.getInt("x", 0);
- int y = windowPrefs.getInt("y", 0);
- int width = windowPrefs.getInt("width", 0);
- int height = windowPrefs.getInt("height", 0);
- _mainFrame.setBounds(new Rectangle(x, y, width, height));
- if(windowPrefs.getBoolean("maximized", false))
- {
- _mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
- }
- return true;
- }
-
- private void storeWindowPrefs()
- {
- Preferences windowPrefs = _prefs.node("Window");
- Rectangle rect = _mainFrame.getBounds();
- windowPrefs.putInt("x", rect.x);
- windowPrefs.putInt("y", rect.y);
- windowPrefs.putInt("width", rect.width);
- windowPrefs.putInt("height", rect.height);
- windowPrefs.putBoolean("maximized",
- _mainFrame.getExtendedState() == Frame.MAXIMIZED_BOTH);
- }
-
-
- public AdminSessionPrx getSession()
- {
- return _sessionKeeper.getSession();
- }
-
- SessionKeeper getSessionKeeper()
- {
- return _sessionKeeper;
- }
-
- Preferences getPrefs()
- {
- return _prefs;
- }
-
- public LiveActions getLiveActionsForPopup()
- {
- return _liveActionsForPopup;
- }
-
- public LiveActions getLiveActionsForMenu()
- {
- return _liveActionsForMenu;
- }
-
- public ApplicationActions getActionsForMenu()
- {
- return _appActionsForMenu;
- }
-
- public ApplicationActions getActionsForPopup()
- {
- return _appActionsForPopup;
- }
-
- public void showActions(IceGridGUI.LiveDeployment.TreeNode node)
- {
- boolean[] availableActions = _liveActionsForMenu.setTarget(node);
- _appActionsForMenu.setTarget(null);
-
- _newServerMenu.setEnabled(false);
- _newServiceMenu.setEnabled(false);
- _newTemplateMenu.setEnabled(false);
-
- _appMenu.setEnabled(true);
-
- _nodeMenu.setEnabled(
- availableActions[IceGridGUI.LiveDeployment.TreeNode.SHUTDOWN_NODE]);
-
- _registryMenu.setEnabled(
- availableActions[IceGridGUI.LiveDeployment.TreeNode.ADD_OBJECT]);
-
- _serverMenu.setEnabled(
- availableActions[IceGridGUI.LiveDeployment.TreeNode.START] ||
- availableActions[IceGridGUI.LiveDeployment.TreeNode.STOP] ||
- availableActions[IceGridGUI.LiveDeployment.TreeNode.ENABLE] ||
- availableActions[IceGridGUI.LiveDeployment.TreeNode.DISABLE] ||
- availableActions[IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER]);
- }
-
- public void showActions(IceGridGUI.Application.TreeNode node)
- {
- boolean[] availableActions = _appActionsForMenu.setTarget(node);
- _liveActionsForMenu.setTarget(null);
-
- _newServerMenu.setEnabled(
- availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER] ||
- availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER_ICEBOX] ||
- availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER_FROM_TEMPLATE]);
-
- _newServiceMenu.setEnabled(
- availableActions[IceGridGUI.Application.TreeNode.NEW_SERVICE] ||
- availableActions[IceGridGUI.Application.TreeNode.NEW_SERVICE_FROM_TEMPLATE]);
-
- _newTemplateMenu.setEnabled(
- availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER] ||
- availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER_ICEBOX] ||
- availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVICE]);
-
- _appMenu.setEnabled(false);
- _nodeMenu.setEnabled(false);
- _registryMenu.setEnabled(false);
- _serverMenu.setEnabled(false);
- }
-
-
- private final Ice.InitializationData _initData;
- private Ice.Communicator _communicator;
-
- private Preferences _prefs;
- private StatusBarI _statusBar = new StatusBarI();
-
- private IceGridGUI.LiveDeployment.Root _liveDeploymentRoot;
- private LiveDeploymentPane _liveDeploymentPane;
-
- //
- // Maps application-name to ApplicationPane (only for 'live' applications)
- //
- private java.util.Map _liveApplications = new java.util.HashMap();
-
- private MainPane _mainPane;
-
- //
- // Keep tracks of serial number when viewing/editing application definitions
- // (not used for displaying live deployment)
- //
- private int _latestSerial = -1;
- private int _writeSerial = -1;
-
- private Runnable _onExclusiveWrite;
- private int _writeAccessCount = 0;
-
- private boolean _substitute = false;
-
- private JFrame _mainFrame;
- private SessionKeeper _sessionKeeper;
-
- private Object _clipboard;
-
- //
- // Actions
- //
- private Action _newApplication;
- private Action _newApplicationWithDefaultTemplates;
- private Action _login;
- private Action _logout;
- private Action _acquireExclusiveWriteAccess;
- private Action _releaseExclusiveWriteAccess;
-
- private Action _openApplicationFromFile;
- private Action _openApplicationFromRegistry;
- private Action _closeApplication;
- private Action _save;
- private Action _saveToRegistry;
- private Action _saveToFile;
- private Action _discardUpdates;
- private Action _exit;
- private Action _back;
- private Action _forward;
- private Action _helpContents;
- private Action _about;
- private Action _patchApplication;
-
- //
- // Two sets of actions because the popup's target and the menu/toolbar's target
- // can be different.
- //
- private LiveActions _liveActionsForMenu = new LiveActions();
- private LiveActions _liveActionsForPopup = new LiveActions();
- private ApplicationActions _appActionsForMenu = new ApplicationActions(false);
- private ApplicationActions _appActionsForPopup = new ApplicationActions(true);
-
-
- private JToggleButton _showVarsTool;
- private JToggleButton _substituteTool;
- private JCheckBoxMenuItem _substituteMenuItem;
- private JCheckBoxMenuItem _showVarsMenuItem;
-
-
- private JMenu _newMenu;
- private JMenu _newServerMenu;
- private JMenu _newServiceMenu;
- private JMenu _newTemplateMenu;
- private JMenu _appMenu;
- private JMenu _nodeMenu;
- private JMenu _registryMenu;
- private JMenu _serverMenu;
-
- private final Thread _shutdownHook;
-
- private JFileChooser _fileChooser;
-
- private Process _icegridadminProcess;
- private String _fileParser;
-
- static private final int HISTORY_MAX_SIZE = 20;
-}
+// **********************************************************************
+//
+// 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;
+
+import java.util.prefs.Preferences;
+import java.util.prefs.BackingStoreException;
+
+import java.awt.BorderLayout;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Rectangle;
+import java.awt.Container;
+import java.awt.Component;
+import java.awt.Toolkit;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.File;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JToggleButton;
+import javax.swing.JToolBar;
+import javax.swing.JTree;
+import javax.swing.KeyStroke;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+
+import javax.swing.border.EmptyBorder;
+import javax.swing.filechooser.FileFilter;
+
+import com.jgoodies.looks.Options;
+import com.jgoodies.looks.HeaderStyle;
+import com.jgoodies.looks.BorderStyle;
+import com.jgoodies.looks.plastic.PlasticLookAndFeel;
+
+import IceGrid.*;
+
+//
+// This class coordinates the communications between the various objects
+// that make up the IceGrid GUI.
+// It also provides both the menu bar and tool bar.
+//
+public class Coordinator
+{
+ private class StatusBarI extends JPanel implements StatusBar
+ {
+ StatusBarI()
+ {
+ super(new BorderLayout());
+ setBorder(new EmptyBorder(0, 13, 10, 13));
+
+ _text = new JLabel();
+ _text.setHorizontalAlignment(SwingConstants.LEFT);
+ add(_text, BorderLayout.LINE_START);
+
+ _connectedLabel = new JLabel("Working Offline");
+ _connectedLabel.setHorizontalAlignment(SwingConstants.RIGHT);
+ add(_connectedLabel, BorderLayout.LINE_END);
+ }
+
+ public void setText(String text)
+ {
+ _text.setText(text);
+ }
+
+ public void setConnected(boolean connected)
+ {
+ if(connected)
+ {
+ _connectedLabel.setText("Working Online");
+ }
+ else
+ {
+ _connectedLabel.setText("Working Offline");
+ }
+ }
+
+ JLabel _connectedLabel;
+ JLabel _text;
+ }
+
+ private class MenuBar extends JMenuBar
+ {
+ private MenuBar()
+ {
+ putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
+ putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
+
+ //
+ // File menu
+ //
+ JMenu fileMenu = new JMenu("File");
+ fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);
+ add(fileMenu);
+
+ //
+ // New sub-menu
+ //
+ _newMenu = new JMenu("New");
+ fileMenu.add(_newMenu);
+ _newMenu.add(_newApplication);
+ _newMenu.add(_newApplicationWithDefaultTemplates);
+ _newMenu.addSeparator();
+
+ _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_ADAPTER));
+ _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_DBENV));
+ _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_NODE));
+ _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_PROPERTY_SET));
+ _newMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_REPLICA_GROUP));
+
+
+ //
+ // Open sub-menu
+ //
+ JMenu openMenu = new JMenu("Open");
+ openMenu.add(_openApplicationFromFile);
+ openMenu.add(_openApplicationFromRegistry);
+
+
+ //
+ // New server sub-sub-menu
+ //
+ _newServerMenu = new JMenu("Server");
+ _newServerMenu.setEnabled(false);
+ _newMenu.add(_newServerMenu);
+ _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER));
+ _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER_ICEBOX));
+ _newServerMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVER_FROM_TEMPLATE));
+
+ //
+ // New service sub-sub-menu
+ //
+ _newServiceMenu = new JMenu("Service");
+ _newServiceMenu.setEnabled(false);
+ _newMenu.add(_newServiceMenu);
+ _newServiceMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVICE));
+ _newServiceMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_SERVICE_FROM_TEMPLATE));
+
+ //
+ // New template sub-sub-menu
+ //
+ _newTemplateMenu = new JMenu("Template");
+ _newTemplateMenu.setEnabled(false);
+ _newMenu.add(_newTemplateMenu);
+ _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER));
+ _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER_ICEBOX));
+ _newTemplateMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVICE));
+
+ fileMenu.addSeparator();
+ fileMenu.add(_login);
+ fileMenu.add(_logout);
+ fileMenu.addSeparator();
+ fileMenu.add(_acquireExclusiveWriteAccess);
+ fileMenu.add(_releaseExclusiveWriteAccess);
+ fileMenu.addSeparator();
+ fileMenu.add(openMenu);
+ fileMenu.add(_closeApplication);
+ fileMenu.add(_save);
+ fileMenu.add(_saveToFile);
+ fileMenu.add(_saveToRegistry);
+ fileMenu.addSeparator();
+ fileMenu.add(_discardUpdates);
+ fileMenu.addSeparator();
+ fileMenu.add(_exit);
+
+ //
+ // Edit menu
+ //
+ JMenu editMenu = new JMenu("Edit");
+ editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E);
+ add(editMenu);
+ editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.COPY));
+ editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.PASTE));
+ editMenu.addSeparator();
+ editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.DELETE));
+ editMenu.addSeparator();
+ editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.MOVE_UP));
+ editMenu.add(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.MOVE_DOWN));
+
+ //
+ // View menu
+ //
+ JMenu viewMenu = new JMenu("View");
+ viewMenu.setMnemonic(java.awt.event.KeyEvent.VK_V);
+ add(viewMenu);
+ viewMenu.add(_showVarsMenuItem);
+ viewMenu.add(_substituteMenuItem);
+ viewMenu.addSeparator();
+ viewMenu.add(_back);
+ viewMenu.add(_forward);
+
+ //
+ // Tools menu
+ //
+ JMenu toolsMenu = new JMenu("Tools");
+ toolsMenu.setMnemonic(java.awt.event.KeyEvent.VK_T);
+ add(toolsMenu);
+
+ //
+ // Application sub-menu
+ //
+ _appMenu = new JMenu("Application");
+ _appMenu.setEnabled(false);
+ toolsMenu.add(_appMenu);
+ _appMenu.add(_patchApplication);
+ _appMenu.setEnabled(false);
+
+ //
+ // Node sub-menu
+ //
+ _nodeMenu = new JMenu("Node");
+ _nodeMenu.setEnabled(false);
+ toolsMenu.add(_nodeMenu);
+ _nodeMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.SHUTDOWN_NODE));
+
+ //
+ // Registry sub-menu
+ //
+ _registryMenu = new JMenu("Registry");
+ _registryMenu.setEnabled(false);
+ toolsMenu.add(_registryMenu);
+ _registryMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.ADD_OBJECT));
+
+ //
+ // Server sub-menu
+ //
+ _serverMenu = new JMenu("Server");
+ _serverMenu.setEnabled(false);
+ toolsMenu.add(_serverMenu);
+ _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.START));
+ _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.STOP));
+ _serverMenu.addSeparator();
+ _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.ENABLE));
+ _serverMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.DISABLE));
+ _serverMenu.addSeparator();
+ _serverMenu.add(_liveActionsForMenu.get(
+ IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER));
+
+ //
+ // Help menu
+ //
+ JMenu helpMenu = new JMenu("Help");
+ helpMenu.setMnemonic(java.awt.event.KeyEvent.VK_H);
+ add(helpMenu);
+
+ helpMenu.add(_helpContents);
+
+ helpMenu.addSeparator();
+ helpMenu.add(_about);
+ }
+ }
+
+ private class ToolBar extends JToolBar
+ {
+ private ToolBar()
+ {
+ putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
+ putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
+ setFloatable(false);
+ putClientProperty("JToolBar.isRollover", Boolean.TRUE);
+
+ JButton button = new JButton(_login);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/login.png"));
+ add(button);
+ button = new JButton(_logout);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/logout.png"));
+ add(button);
+
+ addSeparator();
+
+ button = new JButton(_back);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/back.png"));
+ add(button);
+ button = new JButton(_forward);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/forward.png"));
+ add(button);
+
+ addSeparator();
+
+ button = new JButton(_openApplicationFromRegistry);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/open_from_registry.png"));
+ add(button);
+ button = new JButton(_openApplicationFromFile);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/open_from_file.png"));
+ add(button);
+
+ addSeparator();
+
+ button = new JButton(_save);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/save.png"));
+ add(button);
+ button = new JButton(_saveToRegistry);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/save_to_registry.png"));
+ add(button);
+ button = new JButton(_saveToFile);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/save_to_file.png"));
+ add(button);
+ button = new JButton(_discardUpdates);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/discard.png"));
+ add(button);
+
+ addSeparator();
+
+ button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.COPY));
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/copy.png"));
+ add(button);
+ button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.PASTE));
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/paste.png"));
+ add(button);
+ button = new JButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.DELETE));
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/delete.png"));
+ add(button);
+
+ addSeparator();
+
+ add(_showVarsTool);
+ add(_substituteTool);
+ }
+ }
+
+ //
+ // All Coordinator's methods run in the UI thread
+ //
+ public Ice.Communicator getCommunicator()
+ {
+ if(_communicator == null)
+ {
+ try
+ {
+ _communicator = Ice.Util.initialize(_initData);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(null,
+ e.toString(),
+ "Communicator initialization failed",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ return _communicator;
+ }
+
+ public Ice.Properties getProperties()
+ {
+ return _initData.properties;
+ }
+
+ public Tab getCurrentTab()
+ {
+ return (Tab)_mainPane.getSelectedComponent();
+ }
+
+ public Action getBackAction()
+ {
+ return _back;
+ }
+
+ public Action getForwardAction()
+ {
+ return _forward;
+ }
+
+ public Action getCloseApplicationAction()
+ {
+ return _closeApplication;
+ }
+
+ public Action getSaveAction()
+ {
+ return _save;
+ }
+
+ public Action getSaveToRegistryAction()
+ {
+ return _saveToRegistry;
+ }
+
+ public Action getSaveToFileAction()
+ {
+ return _saveToFile;
+ }
+
+ public Action getDiscardUpdatesAction()
+ {
+ return _discardUpdates;
+ }
+
+ //
+ // Open live application and select application tab
+ //
+ public ApplicationPane openLiveApplication(String applicationName)
+ {
+ ApplicationPane app = (ApplicationPane)_liveApplications.get(applicationName);
+ if(app == null)
+ {
+ ApplicationDescriptor desc =
+ _liveDeploymentRoot.getApplicationDescriptor(applicationName);
+ if(desc == null)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "The application '" + applicationName + "' was not found in the registry.",
+ "No such application",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ //
+ // Essential: deep-copy desc!
+ //
+ desc = IceGridGUI.Application.Root.copyDescriptor(desc);
+ app = new ApplicationPane(new IceGridGUI.Application.Root(this, desc, true, null));
+ _mainPane.addApplication(app);
+ _liveApplications.put(applicationName, app);
+ }
+ _mainPane.setSelectedComponent(app);
+ return app;
+ }
+
+ public void removeLiveApplication(String name)
+ {
+ _liveApplications.remove(name);
+ }
+
+ public void addLiveApplication(IceGridGUI.Application.Root root)
+ {
+ ApplicationPane app = _mainPane.findApplication(root);
+ assert app != null;
+ _liveApplications.put(app.getRoot().getId(), app);
+ }
+
+ public ApplicationPane getLiveApplication(String name)
+ {
+ return (ApplicationPane)_liveApplications.get(name);
+ }
+
+
+ //
+ // From the Application observer:
+ //
+ void applicationInit(String instanceName, int serial, java.util.List applications)
+ {
+ assert _latestSerial == -1;
+ _latestSerial = serial;
+
+ _liveDeploymentRoot.applicationInit(instanceName, applications);
+ //
+ // When we get this init, we can't have any live Application yet.
+ //
+ }
+
+ void applicationAdded(int serial, ApplicationDescriptor desc)
+ {
+ _liveDeploymentRoot.applicationAdded(desc);
+ _statusBar.setText(
+ "Last update: new application '" + desc.name + "'");
+ updateSerial(serial);
+ }
+
+ void applicationRemoved(int serial, String name)
+ {
+ _liveDeploymentRoot.applicationRemoved(name);
+ _statusBar.setText(
+ "Last update: application '" + name + "' was removed");
+
+ ApplicationPane app =
+ (ApplicationPane)_liveApplications.get(name);
+
+ if(app != null)
+ {
+ if(app.getRoot().kill())
+ {
+ _mainPane.remove(app);
+ }
+ _liveApplications.remove(name);
+ }
+ updateSerial(serial);
+ }
+
+ void applicationUpdated(int serial, ApplicationUpdateDescriptor desc)
+ {
+ _liveDeploymentRoot.applicationUpdated(desc);
+ _liveDeploymentPane.refresh();
+
+ _statusBar.setText("Last update: application '" + desc.name + "' was updated");
+
+ ApplicationPane app =
+ (ApplicationPane)_liveApplications.get(desc.name);
+
+ if(app != null)
+ {
+ if(app.getRoot().update(desc))
+ {
+ app.refresh();
+ }
+ }
+ updateSerial(serial);
+ }
+
+ //
+ // From the Adapter observer:
+ //
+ void adapterInit(AdapterInfo[] adapters)
+ {
+ _liveDeploymentRoot.adapterInit(adapters);
+ // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
+ }
+
+ void adapterAdded(AdapterInfo info)
+ {
+ _liveDeploymentRoot.adapterAdded(info);
+ _liveDeploymentPane.refresh();
+ }
+
+ void adapterUpdated(AdapterInfo info)
+ {
+ _liveDeploymentRoot.adapterUpdated(info);
+ _liveDeploymentPane.refresh();
+ }
+
+ void adapterRemoved(String id)
+ {
+ _liveDeploymentRoot.adapterRemoved(id);
+ _liveDeploymentPane.refresh();
+ }
+
+ //
+ // From the Object observer:
+ //
+ void objectInit(ObjectInfo[] objects)
+ {
+ _liveDeploymentRoot.objectInit(objects);
+ // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
+ }
+
+ void objectAdded(ObjectInfo info)
+ {
+ _liveDeploymentRoot.objectAdded(info);
+ _liveDeploymentPane.refresh();
+ }
+
+ void objectUpdated(ObjectInfo info)
+ {
+ _liveDeploymentRoot.objectUpdated(info);
+ _liveDeploymentPane.refresh();
+ }
+
+ void objectRemoved(Ice.Identity id)
+ {
+ _liveDeploymentRoot.objectRemoved(id);
+ _liveDeploymentPane.refresh();
+ }
+
+ public void accessDenied(AccessDeniedException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Another session (username = " + e.lockUserId
+ + ") has exclusive write access to the registry",
+ "Access Denied",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ public void pasteApplication()
+ {
+ Object descriptor = getClipboard();
+ ApplicationDescriptor desc =
+ IceGridGUI.Application.Root.copyDescriptor((ApplicationDescriptor)descriptor);
+
+ IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, desc);
+ ApplicationPane app = new ApplicationPane(root);
+ _mainPane.addApplication(app);
+ _mainPane.setSelectedComponent(app);
+ root.setSelectedNode(root);
+ }
+
+ public void removeApplicationFromRegistry(String name)
+ {
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ boolean acquired = false;
+ try
+ {
+ acquireExclusiveWriteAccess(null);
+ acquired = true;
+ _sessionKeeper.getAdmin().removeApplication(name);
+ }
+ catch(AccessDeniedException e)
+ {
+ accessDenied(e);
+ }
+ catch(DeploymentException e)
+ {
+ //
+ // TODO: XXX: The application couldn't be removed (probably because we tried to remove it from a slave).
+ //
+ }
+ catch(ApplicationNotExistException e)
+ {
+ //
+ // Somebody else deleted this application at about the same time
+ //
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Could not remove application '" + name +
+ "' from IceGrid registry:\n" + e.toString(),
+ "Trouble with IceGrid registry",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ finally
+ {
+ if(acquired)
+ {
+ releaseExclusiveWriteAccess();
+ }
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ public void acquireExclusiveWriteAccess(Runnable runnable)
+ throws AccessDeniedException
+ {
+ if(_writeSerial == -1)
+ {
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try
+ {
+ _writeSerial = _sessionKeeper.getSession().startUpdate();
+ }
+ finally
+ {
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ assert _onExclusiveWrite == null;
+
+ //
+ // Must increment now since run() can call releaseExclusiveWriteAccess()
+ //
+ _writeAccessCount++;
+
+ if(runnable != null)
+ {
+ if(_writeSerial <= _latestSerial)
+ {
+ runnable.run();
+ }
+ else
+ {
+ _onExclusiveWrite = runnable;
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ //
+ // TODO: start a thread to check we don't wait forever
+ //
+ }
+ }
+ }
+
+ public void releaseExclusiveWriteAccess()
+ {
+ if(--_writeAccessCount == 0)
+ {
+ try
+ {
+ _writeSerial = -1;
+ _sessionKeeper.getSession().finishUpdate();
+ }
+ catch(AccessDeniedException e)
+ {
+ accessDenied(e);
+ }
+ catch(Ice.ObjectNotExistException e)
+ {
+ //
+ // Ignored, the session is gone, and so is the exclusive access.
+ //
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Could not release exclusive write access on the IceGrid registry:\n"
+ + e.toString(),
+ "Trouble with IceGrid registry",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+
+ private void updateSerial(int serial)
+ {
+ assert serial == _latestSerial + 1;
+ _latestSerial = serial;
+
+ if(_writeAccessCount > 0 &&
+ _writeSerial <= _latestSerial &&
+ _onExclusiveWrite != null)
+ {
+ Runnable runnable = _onExclusiveWrite;
+ _onExclusiveWrite = null;
+ runnable.run();
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ //
+ // From the Node observer:
+ //
+ void nodeUp(NodeDynamicInfo updatedInfo)
+ {
+ _liveDeploymentRoot.nodeUp(updatedInfo);
+ _liveDeploymentPane.refresh();
+ }
+
+ void nodeDown(String node)
+ {
+ _liveDeploymentRoot.nodeDown(node);
+ _liveDeploymentPane.refresh();
+ }
+
+ void updateServer(String node, ServerDynamicInfo updatedInfo)
+ {
+ _liveDeploymentRoot.updateServer(node, updatedInfo);
+ _liveDeploymentPane.refresh();
+ }
+
+ void updateAdapter(String node, AdapterDynamicInfo updatedInfo)
+ {
+ _liveDeploymentRoot.updateAdapter(node, updatedInfo);
+ _liveDeploymentPane.refresh();
+ }
+
+ void sessionLost()
+ {
+ _latestSerial = -1;
+ _writeSerial = -1;
+ _writeAccessCount = 0;
+ _onExclusiveWrite = null;
+ _liveDeploymentRoot.clear();
+
+ //
+ // Kill all live applications
+ //
+ java.util.Iterator p = _liveApplications.values().iterator();
+ while(p.hasNext())
+ {
+ ApplicationPane app = (ApplicationPane)p.next();
+ if(app.getRoot().kill())
+ {
+ _mainPane.remove(app);
+ }
+ }
+ _liveApplications.clear();
+
+ _logout.setEnabled(false);
+ _openApplicationFromRegistry.setEnabled(false);
+ _patchApplication.setEnabled(false);
+ _appMenu.setEnabled(false);
+ _newApplicationWithDefaultTemplates.setEnabled(false);
+ _acquireExclusiveWriteAccess.setEnabled(false);
+ _releaseExclusiveWriteAccess.setEnabled(false);
+ _saveToRegistry.setEnabled(false);
+ }
+
+ AdminSessionPrx login(SessionKeeper.LoginInfo info, Component parent)
+ {
+ _liveDeploymentRoot.clear();
+
+ AdminSessionPrx session = null;
+
+ destroyCommunicator();
+
+ Ice.InitializationData initData = _initData;
+ if(info.routed && info.routerSSLEnabled || !info.routed && info.registrySSLEnabled)
+ {
+ initData = (Ice.InitializationData)initData.clone();
+ initData.properties = initData.properties._clone();
+ initData.properties.setProperty("Ice.Plugin.IceSSL", "IceSSL.PluginFactory");
+
+ //
+ // Transform SSL info into properties
+ //
+ initData.properties.setProperty("IceSSL.Keystore", info.keystore);
+ initData.properties.setProperty("IceSSL.Password", new String(info.keyPassword));
+ initData.properties.setProperty("IceSSL.KeystorePassword", new String(info.keystorePassword));
+ initData.properties.setProperty("IceSSL.Alias", info.alias);
+ initData.properties.setProperty("IceSSL.Truststore", info.truststore);
+ initData.properties.setProperty("IceSSL.TruststorePassword", new String(info.truststorePassword));
+ }
+
+ try
+ {
+ _communicator = Ice.Util.initialize(initData);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ e.toString(),
+ "Communicator initialization failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+
+ if(info.routed)
+ {
+ //
+ // Router
+ //
+
+
+ Ice.Identity routerId = new Ice.Identity();
+ routerId.category = info.routerInstanceName;
+ routerId.name = "router";
+ String str = "\"" + _communicator.identityToString(routerId) + "\"";
+
+ if(!info.routerEndpoints.equals(""))
+ {
+ str += ":" + info.routerEndpoints;
+ }
+
+ try
+ {
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.
+ uncheckedCast(_communicator.stringToProxy(str));
+
+ //
+ // The session must be routed through this router
+ //
+ _communicator.setDefaultRouter(router);
+
+ Glacier2.SessionPrx s;
+ if(info.routerUseSSL)
+ {
+ router = Glacier2.RouterPrxHelper.
+ uncheckedCast(router.ice_secure(true));
+
+ s = router.createSessionFromSecureConnection();
+
+ if(s == null)
+ {
+ JOptionPane.showMessageDialog(
+ parent,
+ "createSessionFromSecureConnection returned a null session: \n"
+ + "verify that Glacier2.SSLSessionManager is set to "
+ + "<IceGridInstanceName>/AdminSSLSessionManager in your Glacier2 router configuration",
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+
+ return null;
+ }
+ }
+ else
+ {
+ s = router.createSession(
+ info.routerUsername, new String(info.routerPassword));
+
+ if(s == null)
+ {
+ JOptionPane.showMessageDialog(
+ parent,
+ "createSession returned a null session: \n"
+ + "verify that Glacier2.SessionManager is set to "
+ + "<IceGridInstanceName>/AdminSessionManager in your Glacier2 router configuration",
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+
+ return null;
+ }
+ }
+
+ session = AdminSessionPrxHelper.uncheckedCast(s);
+ }
+ catch(Glacier2.PermissionDeniedException e)
+ {
+ if(e.reason.length() == 0)
+ {
+ e.reason = info.routerUseSSL ? "Invalid credentials" : "Invalid username/password";
+ }
+ JOptionPane.showMessageDialog(parent,
+ "Permission denied: "
+ + e.reason,
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Glacier2.CannotCreateSessionException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.reason,
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
+ else
+ {
+ //
+ // The client uses the locator only without routing
+ //
+ Ice.Identity locatorId = new Ice.Identity();
+ locatorId.category = info.registryInstanceName;
+ locatorId.name = "Locator";
+ String str = "\"" + _communicator.identityToString(locatorId) + "\"";
+ if(!info.registryEndpoints.equals(""))
+ {
+ str += ":" + info.registryEndpoints;
+ }
+
+ try
+ {
+ Ice.LocatorPrx defaultLocator = Ice.LocatorPrxHelper.
+ checkedCast(_communicator.stringToProxy(str));
+ _communicator.setDefaultLocator(defaultLocator);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ parent,
+ "Could not contact '" + str + "': " + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+
+ //
+ // Local session
+ //
+ Ice.Identity registryId = new Ice.Identity();
+ registryId.category = info.registryInstanceName;
+ registryId.name = "Registry";
+
+ RegistryPrx registry = RegistryPrxHelper.
+ uncheckedCast(_communicator.stringToProxy("\"" + _communicator.identityToString(registryId) + "\""));
+
+ try
+ {
+ if(info.registryUseSSL)
+ {
+ registry = RegistryPrxHelper.
+ uncheckedCast(registry.ice_secure(true));
+
+ session = AdminSessionPrxHelper.uncheckedCast(
+ registry.createAdminSessionFromSecureConnection());
+ }
+ else
+ {
+ session = AdminSessionPrxHelper.uncheckedCast(
+ registry.createAdminSession(info.registryUsername,
+ new String(info.registryPassword)));
+ }
+ }
+ catch(IceGrid.PermissionDeniedException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Permission denied: "
+ + e.reason,
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(parent,
+ "Could not create session: "
+ + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
+
+ _logout.setEnabled(true);
+ _openApplicationFromRegistry.setEnabled(true);
+ _patchApplication.setEnabled(true);
+ _appMenu.setEnabled(true);
+ _newApplicationWithDefaultTemplates.setEnabled(true);
+ _acquireExclusiveWriteAccess.setEnabled(true);
+
+ _mainPane.setSelectedComponent(_liveDeploymentPane);
+
+ return session;
+ }
+
+
+ void destroySession(AdminSessionPrx session)
+ {
+ Ice.RouterPrx router = _communicator.getDefaultRouter();
+
+ try
+ {
+ if(router == null)
+ {
+ session.destroy();
+ }
+ else
+ {
+ Glacier2.RouterPrx gr
+ = Glacier2.RouterPrxHelper.uncheckedCast(router);
+ gr.destroySession();
+ }
+ }
+ catch(Glacier2.SessionNotExistException e)
+ {
+ // Ignored
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored
+ }
+ }
+
+ void showVars()
+ {
+ substitute(false);
+ }
+
+ void substituteVars()
+ {
+ substitute(true);
+ }
+
+ private void substitute(boolean newValue)
+ {
+ if(_substitute != newValue)
+ {
+ _substitute = newValue;
+
+ if(_substitute)
+ {
+ _substituteMenuItem.setSelected(true);
+ _substituteTool.setSelected(true);
+ }
+ else
+ {
+ _showVarsMenuItem.setSelected(true);
+ _showVarsTool.setSelected(true);
+ }
+ getCurrentTab().refresh();
+ }
+ }
+
+ public boolean substitute()
+ {
+ return _substitute;
+ }
+
+ public AdminPrx getAdmin()
+ {
+ return _sessionKeeper.getAdmin();
+ }
+
+ public StatusBar getStatusBar()
+ {
+ return _statusBar;
+ }
+
+ public JFrame getMainFrame()
+ {
+ return _mainFrame;
+ }
+
+ public MainPane getMainPane()
+ {
+ return _mainPane;
+ }
+
+ public ApplicationDescriptor parseFile(File file)
+ {
+ if(_icegridadminProcess == null)
+ {
+ //
+ // Start icegridadmin server
+ //
+ try
+ {
+ _icegridadminProcess = Runtime.getRuntime().exec("icegridadmin --server");
+ }
+ catch(java.io.IOException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Failed to start icegridadmin subprocess: " + e.toString(),
+ "IO Exception",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+
+ try
+ {
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(_icegridadminProcess.getInputStream(),
+ "US-ASCII"));
+
+ String str = reader.readLine();
+ reader.close();
+
+ if(str == null || str.length() == 0)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "The icegridadmin subprocess failed",
+ "Subprocess failure",
+ JOptionPane.ERROR_MESSAGE);
+ destroyIceGridAdmin();
+ return null;
+ }
+ _fileParser = str;
+ }
+ catch(java.io.UnsupportedEncodingException e)
+ {
+ assert false;
+ }
+ catch(java.io.IOException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "IO Exception: " + e.toString(),
+ "IO Exception",
+ JOptionPane.ERROR_MESSAGE);
+
+ destroyIceGridAdmin();
+ return null;
+ }
+ }
+
+ try
+ {
+ FileParserPrx fileParser = FileParserPrxHelper.checkedCast(
+ getCommunicator().stringToProxy(_fileParser).ice_router(null));
+ return fileParser.parse(file.getAbsolutePath(),
+ _sessionKeeper.getRoutedAdmin());
+ }
+ catch(ParseException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Failed to parse file '" + file.getAbsolutePath() + "':\n" + e.toString(),
+ "Parse error",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Operation on FileParser failed:\n" + e.toString(),
+ "Communication error",
+ JOptionPane.ERROR_MESSAGE);
+ destroyIceGridAdmin();
+ return null;
+ }
+ }
+
+ private void destroyIceGridAdmin()
+ {
+ if(_icegridadminProcess != null)
+ {
+ try
+ {
+ _icegridadminProcess.destroy();
+ }
+ catch(Exception e)
+ {}
+ _icegridadminProcess = null;
+ _fileParser = null;
+ }
+ }
+
+
+ public File saveToFile(boolean ask, IceGridGUI.Application.Root root,
+ File file)
+ {
+ if(ask || file == null)
+ {
+ if(file != null)
+ {
+ _fileChooser.setSelectedFile(file);
+ }
+ int result = _fileChooser.showSaveDialog(_mainFrame);
+ if(result == JFileChooser.APPROVE_OPTION)
+ {
+ file = _fileChooser.getSelectedFile();
+ }
+ else
+ {
+ file = null;
+ }
+ }
+ if(file != null)
+ {
+ try
+ {
+ XMLWriter writer = new XMLWriter(file);
+ root.write(writer);
+ writer.close();
+ _statusBar.setText(
+ "Saved application '" + root.getId() + "' to "
+ + file.getAbsolutePath());
+ }
+ catch(java.io.FileNotFoundException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Cannot use the selected file for writing.",
+ "File Not Found",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ catch(java.io.IOException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "IO Exception: " + e.toString(),
+ "IO Exception",
+ JOptionPane.ERROR_MESSAGE);
+ return null;
+ }
+ }
+ return file;
+ }
+
+
+ static private Ice.Properties createProperties(Ice.StringSeqHolder args)
+ {
+ Ice.Properties properties = Ice.Util.createProperties();
+
+ //
+ // Set various default values
+ //
+ properties.setProperty("Ice.Override.ConnectTimeout", "5000");
+
+ properties.setProperty("Ice.ThreadPerConnection", "1");
+
+ //
+ // For Glacier
+ //
+ properties.setProperty("Ice.ACM.Client", "0");
+ properties.setProperty("Ice.MonitorConnections", "5");
+
+ //
+ // Disable retries
+ //
+ properties.setProperty("Ice.RetryIntervals", "-1");
+
+ return Ice.Util.createProperties(args, properties);
+ }
+
+ Coordinator(JFrame mainFrame, Ice.StringSeqHolder args, Preferences prefs)
+ {
+ _mainFrame = mainFrame;
+ _prefs = prefs;
+ _initData = new Ice.InitializationData();
+
+ _initData.properties = createProperties(args);
+
+ if(args.value.length > 0)
+ {
+ //
+ // TODO: use proper logging
+ //
+ System.err.println("WARNING: extra command-line arguments");
+ for(int i = 0; i < args.value.length; ++i)
+ {
+ System.err.println(args.value[i]);
+ }
+ }
+
+ _liveDeploymentRoot = new IceGridGUI.LiveDeployment.Root(this);
+
+ _sessionKeeper = new SessionKeeper(this);
+
+ _shutdownHook = new Thread("Shutdown hook")
+ {
+ public void run()
+ {
+ destroyIceGridAdmin();
+ destroyCommunicator();
+ }
+ };
+ Runtime.getRuntime().addShutdownHook(_shutdownHook);
+
+ _fileChooser = new JFileChooser();
+ _fileChooser.addChoosableFileFilter(new FileFilter()
+ {
+ public boolean accept(File f)
+ {
+ return f.isDirectory() || f.getName().endsWith(".xml");
+ }
+
+ public String getDescription()
+ {
+ return ".xml files";
+ }
+ });
+
+
+ final int MENU_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+
+ //
+ // Common actions (nodes not involved)
+ //
+ _newApplication = new AbstractAction("Application")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ newApplication();
+ }
+ };
+
+ _newApplicationWithDefaultTemplates =
+ new AbstractAction("Application with default templates from registry")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ newApplicationWithDefaultTemplates();
+ }
+ };
+ _newApplicationWithDefaultTemplates.setEnabled(false);
+
+ _login = new AbstractAction("Login...")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _sessionKeeper.relog(true);
+ }
+ };
+ _login.putValue(Action.SHORT_DESCRIPTION,
+ "Log into an IceGrid registry");
+
+ _logout = new AbstractAction("Logout")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _sessionKeeper.logout(true);
+ }
+ };
+ _logout.putValue(Action.SHORT_DESCRIPTION, "Logout");
+ _logout.setEnabled(false);
+
+ _acquireExclusiveWriteAccess = new AbstractAction("Acquire exclusive write access")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ acquireExclusiveWriteAccess(null);
+ _releaseExclusiveWriteAccess.setEnabled(true);
+ _acquireExclusiveWriteAccess.setEnabled(false);
+ }
+ catch(AccessDeniedException ade)
+ {
+ accessDenied(ade);
+ }
+ }
+ };
+ _acquireExclusiveWriteAccess.putValue(Action.SHORT_DESCRIPTION,
+ "Acquire exclusive write access on the registry");
+ _acquireExclusiveWriteAccess.setEnabled(false);
+
+
+ _releaseExclusiveWriteAccess = new AbstractAction("Release exclusive write access")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ releaseExclusiveWriteAccess();
+ _acquireExclusiveWriteAccess.setEnabled(true);
+ _releaseExclusiveWriteAccess.setEnabled(false);
+ }
+ };
+ _releaseExclusiveWriteAccess.putValue(Action.SHORT_DESCRIPTION,
+ "Release exclusive write access on the registry");
+ _releaseExclusiveWriteAccess.setEnabled(false);
+
+ _openApplicationFromFile = new AbstractAction("Application from file")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ int result = _fileChooser.showOpenDialog(_mainFrame);
+ if(result == JFileChooser.APPROVE_OPTION)
+ {
+ File file = _fileChooser.getSelectedFile();
+
+ ApplicationDescriptor desc = parseFile(file);
+
+ if(desc != null)
+ {
+ IceGridGUI.Application.Root root =
+ new IceGridGUI.Application.Root(Coordinator.this, desc, false, file);
+ ApplicationPane app = new ApplicationPane(root);
+ _mainPane.addApplication(app);
+ _mainPane.setSelectedComponent(app);
+ root.setSelectedNode(root);
+ }
+ }
+ }
+ };
+ _openApplicationFromFile.putValue(Action.SHORT_DESCRIPTION, "Open application from file");
+ _openApplicationFromFile.setEnabled(true);
+
+ _openApplicationFromRegistry = new AbstractAction("Application from registry")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Object[] applicationNames = _liveDeploymentRoot.getApplicationNames();
+
+ if(applicationNames.length == 0)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "The registry does not contain any application",
+ "Empty registry",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+ else
+ {
+ String appName = (String)JOptionPane.showInputDialog(
+ _mainFrame, "Which Application do you want to open?",
+ "Open Application from registry",
+ JOptionPane.QUESTION_MESSAGE, null,
+ applicationNames, applicationNames[0]);
+
+ if(appName != null)
+ {
+ IceGridGUI.Application.Root root = openLiveApplication(appName).getRoot();
+ if(root.getSelectedNode() == null)
+ {
+ root.setSelectedNode(root);
+ }
+ }
+ }
+ }
+ };
+ _openApplicationFromRegistry.putValue(Action.SHORT_DESCRIPTION, "Open application from registry");
+ _openApplicationFromRegistry.setEnabled(false);
+
+ _closeApplication = new AbstractAction("Close application")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Tab tab = getCurrentTab();
+ if(tab.close())
+ {
+ String id = ((ApplicationPane)tab).getRoot().getId();
+ _liveApplications.remove(id);
+ }
+ }
+ };
+ _closeApplication.putValue(Action.SHORT_DESCRIPTION, "Close application");
+ _closeApplication.setEnabled(false);
+
+ _save = new AbstractAction("Save")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().save();
+ }
+ };
+ _save.setEnabled(false);
+ _save.putValue(Action.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK));
+ _save.putValue(Action.SHORT_DESCRIPTION, "Save");
+
+
+ _saveToRegistry = new AbstractAction("Save to registry")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().saveToRegistry();
+ }
+ };
+ _saveToRegistry.setEnabled(false);
+ _saveToRegistry.putValue(Action.SHORT_DESCRIPTION, "Save to registry");
+
+
+ _saveToFile = new AbstractAction("Save to file")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().saveToFile();
+ }
+ };
+ _saveToFile.setEnabled(false);
+ _saveToFile.putValue(Action.SHORT_DESCRIPTION, "Save to file");
+
+
+ _discardUpdates = new AbstractAction("Discard updates...")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().discardUpdates();
+ }
+ };
+ _discardUpdates.setEnabled(false);
+ _discardUpdates.putValue(Action.SHORT_DESCRIPTION, "Discard updates");
+
+
+ _exit = new AbstractAction("Exit")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ exit(0);
+ }
+ };
+ _exit.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("alt F4"));
+
+
+ _back = new AbstractAction("Go back to the previous node")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().back();
+ }
+ };
+ _back.setEnabled(false);
+ _back.putValue(Action.SHORT_DESCRIPTION, "Go back to the previous node");
+
+ _forward = new AbstractAction("Go to the next node")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ getCurrentTab().forward();
+ }
+ };
+ _forward.setEnabled(false);
+ _forward.putValue(Action.SHORT_DESCRIPTION, "Go to the next node");
+
+ _helpContents = new AbstractAction("Contents")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ helpContents();
+ }
+ };
+
+ _about = new AbstractAction("About")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ about();
+ }
+ };
+
+ _patchApplication = new AbstractAction("Patch distribution")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ Object[] applicationNames = _liveDeploymentRoot.getPatchableApplicationNames();
+
+ if(applicationNames.length == 0)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "No application in this IceGrid registry can be patched",
+ "No application",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+ else
+ {
+ String appName = (String)JOptionPane.showInputDialog(
+ _mainFrame, "Which Application do you want to patch?",
+ "Patch application",
+ JOptionPane.QUESTION_MESSAGE, null,
+ applicationNames, applicationNames[0]);
+
+ if(appName != null)
+ {
+ _liveDeploymentRoot.patch(appName);
+ }
+ }
+ }
+ };
+ _patchApplication.setEnabled(false);
+
+ _showVarsMenuItem = new
+ JCheckBoxMenuItem(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SHOW_VARS));
+ _showVarsTool = new
+ JToggleButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SHOW_VARS));
+ _showVarsTool.setIcon(Utils.getIcon("/icons/24x24/show_vars.png"));
+ _showVarsTool.setText("");
+
+ _substituteMenuItem = new
+ JCheckBoxMenuItem(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SUBSTITUTE_VARS));
+ _substituteTool = new
+ JToggleButton(_appActionsForMenu.get(IceGridGUI.Application.TreeNode.SUBSTITUTE_VARS));
+ _substituteTool.setIcon(Utils.getIcon("/icons/24x24/substitute.png"));
+ _substituteTool.setText("");
+
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(_showVarsMenuItem);
+ group.add(_substituteMenuItem);
+ group = new ButtonGroup();
+ group.add(_showVarsTool);
+ group.add(_substituteTool);
+
+ _showVarsMenuItem.setSelected(true);
+ _showVarsTool.setSelected(true);
+
+ _mainFrame.setJMenuBar(new MenuBar());
+
+ _mainFrame.getContentPane().add(new ToolBar(),
+ BorderLayout.PAGE_START);
+
+ _mainFrame.getContentPane().add((StatusBarI)_statusBar,
+ BorderLayout.PAGE_END);
+
+ _liveDeploymentPane = new LiveDeploymentPane(_liveDeploymentRoot);
+ _mainPane = new MainPane(this);
+ _mainFrame.getContentPane().add(_mainPane, BorderLayout.CENTER);
+ }
+
+ JComponent getLiveDeploymentPane()
+ {
+ return _liveDeploymentPane;
+ }
+
+ public IceGridGUI.LiveDeployment.Root getLiveDeploymentRoot()
+ {
+ return _liveDeploymentRoot;
+ }
+
+ private void newApplication()
+ {
+ ApplicationDescriptor desc = new ApplicationDescriptor("NewApplication",
+ new java.util.TreeMap(),
+ new java.util.LinkedList(),
+ new java.util.HashMap(),
+ new java.util.HashMap(),
+ new java.util.HashMap(),
+ new IceGrid.DistributionDescriptor(
+ "", new java.util.LinkedList()),
+ "",
+ new java.util.HashMap());
+ IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, desc);
+ ApplicationPane app = new ApplicationPane(root);
+ _mainPane.addApplication(app);
+ _mainPane.setSelectedComponent(app);
+ root.setSelectedNode(root);
+ }
+
+ private void newApplicationWithDefaultTemplates()
+ {
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try
+ {
+ ApplicationDescriptor descriptor = getAdmin().getDefaultApplicationDescriptor();
+ descriptor.name = "NewApplication";
+ IceGridGUI.Application.Root root = new IceGridGUI.Application.Root(this, descriptor);
+ ApplicationPane app = new ApplicationPane(root);
+ _mainPane.addApplication(app);
+ _mainPane.setSelectedComponent(app);
+ root.setSelectedNode(root);
+ }
+ catch(DeploymentException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "The default application descriptor from the IceGrid registry is invalid:\n"
+ + e.reason,
+ "Deployment Exception",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "Could not retrieve the default application descriptor from the IceGrid registry: \n"
+ + e.toString(),
+ "Trouble with IceGrid registry",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ finally
+ {
+ _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ private void helpContents()
+ {
+ BareBonesBrowserLaunch.openURL(
+ "http://www.zeroc.com/help/IceGridAdmin/");
+ }
+
+ private void about()
+ {
+ String text = "IceGrid Admin version "
+ + IceUtil.Version.ICE_STRING_VERSION + "\n"
+ + "Copyright \u00A9 2005-2006 ZeroC, Inc. All rights reserved.\n";
+
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ text,
+ "About - IceGrid Admin",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ public void setClipboard(Object copy)
+ {
+ _clipboard = copy;
+ }
+
+ public Object getClipboard()
+ {
+ return _clipboard;
+ }
+
+ void showMainFrame()
+ {
+ if(!loadWindowPrefs())
+ {
+ _mainFrame.setLocation(100, 100);
+ _mainFrame.pack();
+ }
+ _mainFrame.setVisible(true);
+ }
+
+ void exit(int status)
+ {
+ storeWindowPrefs();
+ destroyIceGridAdmin();
+ destroyCommunicator();
+ Runtime.getRuntime().removeShutdownHook(_shutdownHook);
+ _mainFrame.dispose();
+ Runtime.getRuntime().exit(status);
+ }
+
+ //
+ // Can be called by the shutdown hook thread
+ //
+ private void destroyCommunicator()
+ {
+ if(_communicator != null)
+ {
+ try
+ {
+ _communicator.destroy();
+ }
+ catch(Ice.LocalException e)
+ {
+ System.err.println("_communicator.destroy() raised "
+ + e.toString());
+ e.printStackTrace();
+ }
+ _communicator = null;
+ }
+ }
+
+ private boolean loadWindowPrefs()
+ {
+ try
+ {
+ if(!_prefs.nodeExists("Window"))
+ {
+ return false;
+ }
+ }
+ catch(BackingStoreException e)
+ {
+ return false;
+ }
+
+ Preferences windowPrefs = _prefs.node("Window");
+ int x = windowPrefs.getInt("x", 0);
+ int y = windowPrefs.getInt("y", 0);
+ int width = windowPrefs.getInt("width", 0);
+ int height = windowPrefs.getInt("height", 0);
+ _mainFrame.setBounds(new Rectangle(x, y, width, height));
+ if(windowPrefs.getBoolean("maximized", false))
+ {
+ _mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
+ }
+ return true;
+ }
+
+ private void storeWindowPrefs()
+ {
+ Preferences windowPrefs = _prefs.node("Window");
+ Rectangle rect = _mainFrame.getBounds();
+ windowPrefs.putInt("x", rect.x);
+ windowPrefs.putInt("y", rect.y);
+ windowPrefs.putInt("width", rect.width);
+ windowPrefs.putInt("height", rect.height);
+ windowPrefs.putBoolean("maximized",
+ _mainFrame.getExtendedState() == Frame.MAXIMIZED_BOTH);
+ }
+
+
+ public AdminSessionPrx getSession()
+ {
+ return _sessionKeeper.getSession();
+ }
+
+ SessionKeeper getSessionKeeper()
+ {
+ return _sessionKeeper;
+ }
+
+ Preferences getPrefs()
+ {
+ return _prefs;
+ }
+
+ public LiveActions getLiveActionsForPopup()
+ {
+ return _liveActionsForPopup;
+ }
+
+ public LiveActions getLiveActionsForMenu()
+ {
+ return _liveActionsForMenu;
+ }
+
+ public ApplicationActions getActionsForMenu()
+ {
+ return _appActionsForMenu;
+ }
+
+ public ApplicationActions getActionsForPopup()
+ {
+ return _appActionsForPopup;
+ }
+
+ public void showActions(IceGridGUI.LiveDeployment.TreeNode node)
+ {
+ boolean[] availableActions = _liveActionsForMenu.setTarget(node);
+ _appActionsForMenu.setTarget(null);
+
+ _newServerMenu.setEnabled(false);
+ _newServiceMenu.setEnabled(false);
+ _newTemplateMenu.setEnabled(false);
+
+ _appMenu.setEnabled(true);
+
+ _nodeMenu.setEnabled(
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.SHUTDOWN_NODE]);
+
+ _registryMenu.setEnabled(
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.ADD_OBJECT]);
+
+ _serverMenu.setEnabled(
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.START] ||
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.STOP] ||
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.ENABLE] ||
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.DISABLE] ||
+ availableActions[IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER]);
+ }
+
+ public void showActions(IceGridGUI.Application.TreeNode node)
+ {
+ boolean[] availableActions = _appActionsForMenu.setTarget(node);
+ _liveActionsForMenu.setTarget(null);
+
+ _newServerMenu.setEnabled(
+ availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER] ||
+ availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER_ICEBOX] ||
+ availableActions[IceGridGUI.Application.TreeNode.NEW_SERVER_FROM_TEMPLATE]);
+
+ _newServiceMenu.setEnabled(
+ availableActions[IceGridGUI.Application.TreeNode.NEW_SERVICE] ||
+ availableActions[IceGridGUI.Application.TreeNode.NEW_SERVICE_FROM_TEMPLATE]);
+
+ _newTemplateMenu.setEnabled(
+ availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER] ||
+ availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVER_ICEBOX] ||
+ availableActions[IceGridGUI.Application.TreeNode.NEW_TEMPLATE_SERVICE]);
+
+ _appMenu.setEnabled(false);
+ _nodeMenu.setEnabled(false);
+ _registryMenu.setEnabled(false);
+ _serverMenu.setEnabled(false);
+ }
+
+
+ private final Ice.InitializationData _initData;
+ private Ice.Communicator _communicator;
+
+ private Preferences _prefs;
+ private StatusBarI _statusBar = new StatusBarI();
+
+ private IceGridGUI.LiveDeployment.Root _liveDeploymentRoot;
+ private LiveDeploymentPane _liveDeploymentPane;
+
+ //
+ // Maps application-name to ApplicationPane (only for 'live' applications)
+ //
+ private java.util.Map _liveApplications = new java.util.HashMap();
+
+ private MainPane _mainPane;
+
+ //
+ // Keep tracks of serial number when viewing/editing application definitions
+ // (not used for displaying live deployment)
+ //
+ private int _latestSerial = -1;
+ private int _writeSerial = -1;
+
+ private Runnable _onExclusiveWrite;
+ private int _writeAccessCount = 0;
+
+ private boolean _substitute = false;
+
+ private JFrame _mainFrame;
+ private SessionKeeper _sessionKeeper;
+
+ private Object _clipboard;
+
+ //
+ // Actions
+ //
+ private Action _newApplication;
+ private Action _newApplicationWithDefaultTemplates;
+ private Action _login;
+ private Action _logout;
+ private Action _acquireExclusiveWriteAccess;
+ private Action _releaseExclusiveWriteAccess;
+
+ private Action _openApplicationFromFile;
+ private Action _openApplicationFromRegistry;
+ private Action _closeApplication;
+ private Action _save;
+ private Action _saveToRegistry;
+ private Action _saveToFile;
+ private Action _discardUpdates;
+ private Action _exit;
+ private Action _back;
+ private Action _forward;
+ private Action _helpContents;
+ private Action _about;
+ private Action _patchApplication;
+
+ //
+ // Two sets of actions because the popup's target and the menu/toolbar's target
+ // can be different.
+ //
+ private LiveActions _liveActionsForMenu = new LiveActions();
+ private LiveActions _liveActionsForPopup = new LiveActions();
+ private ApplicationActions _appActionsForMenu = new ApplicationActions(false);
+ private ApplicationActions _appActionsForPopup = new ApplicationActions(true);
+
+
+ private JToggleButton _showVarsTool;
+ private JToggleButton _substituteTool;
+ private JCheckBoxMenuItem _substituteMenuItem;
+ private JCheckBoxMenuItem _showVarsMenuItem;
+
+
+ private JMenu _newMenu;
+ private JMenu _newServerMenu;
+ private JMenu _newServiceMenu;
+ private JMenu _newTemplateMenu;
+ private JMenu _appMenu;
+ private JMenu _nodeMenu;
+ private JMenu _registryMenu;
+ private JMenu _serverMenu;
+
+ private final Thread _shutdownHook;
+
+ private JFileChooser _fileChooser;
+
+ private Process _icegridadminProcess;
+ private String _fileParser;
+
+ static private final int HISTORY_MAX_SIZE = 20;
+}
diff --git a/java/src/IceGridGUI/EditorBase.java b/java/src/IceGridGUI/EditorBase.java
index b9c8ac4d712..f17e5f26727 100755
--- a/java/src/IceGridGUI/EditorBase.java
+++ b/java/src/IceGridGUI/EditorBase.java
@@ -1,71 +1,71 @@
-// **********************************************************************
-//
-// 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;
-
-import java.awt.BorderLayout;
-
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JToolBar;
-
-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 IceGrid.*;
-
-//
-// Base class for all editors
-//
-public abstract class EditorBase
-{
- public JComponent getProperties()
- {
- if(_propertiesPanel == null)
- {
- buildPropertiesPanel();
- }
- return _propertiesPanel;
- }
-
- public JToolBar getToolBar()
- {
- return null;
- }
-
- protected abstract void appendProperties(DefaultFormBuilder builder);
-
- protected void buildPropertiesPanel()
- {
- 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());
-
- appendProperties(builder);
-
- JScrollPane scrollPane =
- new JScrollPane(builder.getPanel(),
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
-
- scrollPane.setBorder(Borders.DIALOG_BORDER);
-
- _propertiesPanel = new JPanel(new BorderLayout());
- _propertiesPanel.add(scrollPane, BorderLayout.CENTER);
- _propertiesPanel.setBorder(Borders.EMPTY_BORDER);
- }
-
- protected JPanel _propertiesPanel;
-}
+// **********************************************************************
+//
+// 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;
+
+import java.awt.BorderLayout;
+
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JToolBar;
+
+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 IceGrid.*;
+
+//
+// Base class for all editors
+//
+public abstract class EditorBase
+{
+ public JComponent getProperties()
+ {
+ if(_propertiesPanel == null)
+ {
+ buildPropertiesPanel();
+ }
+ return _propertiesPanel;
+ }
+
+ public JToolBar getToolBar()
+ {
+ return null;
+ }
+
+ protected abstract void appendProperties(DefaultFormBuilder builder);
+
+ protected void buildPropertiesPanel()
+ {
+ 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());
+
+ appendProperties(builder);
+
+ JScrollPane scrollPane =
+ new JScrollPane(builder.getPanel(),
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+
+ scrollPane.setBorder(Borders.DIALOG_BORDER);
+
+ _propertiesPanel = new JPanel(new BorderLayout());
+ _propertiesPanel.add(scrollPane, BorderLayout.CENTER);
+ _propertiesPanel.setBorder(Borders.EMPTY_BORDER);
+ }
+
+ protected JPanel _propertiesPanel;
+}
diff --git a/java/src/IceGridGUI/LiveActions.java b/java/src/IceGridGUI/LiveActions.java
index 4ec98b3f3ae..27194bfa333 100755
--- a/java/src/IceGridGUI/LiveActions.java
+++ b/java/src/IceGridGUI/LiveActions.java
@@ -1,127 +1,127 @@
-// **********************************************************************
-//
-// 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;
-
-import java.awt.event.ActionEvent;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-
-import IceGrid.*;
-import IceGridGUI.LiveDeployment.*;
-
-//
-// Holds all actions for the "Live Deployment" view
-//
-public class LiveActions
-{
- public Action get(int index)
- {
- return _array[index];
- }
-
- public boolean[] setTarget(TreeNode target)
- {
- _target = target;
-
- boolean[] availableActions;
- if(_target == null)
- {
- availableActions = new boolean[TreeNode.ACTION_COUNT];
- }
- else
- {
- availableActions = _target.getAvailableActions();
- }
-
- for(int i = 0; i < _array.length; ++i)
- {
- _array[i].setEnabled(availableActions[i]);
- }
-
- return availableActions;
- }
-
- LiveActions()
- {
- _array[TreeNode.START] = new AbstractAction(
- "Start", Utils.getIcon("/icons/16x16/start.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.start();
- }
- };
- _array[TreeNode.START].putValue(Action.SHORT_DESCRIPTION,
- "Start this server");
-
- _array[TreeNode.STOP] = new AbstractAction(
- "Stop", Utils.getIcon("/icons/16x16/stop.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.stop();
- }
- };
- _array[TreeNode.STOP].putValue(Action.SHORT_DESCRIPTION,
- "Stop this server");
-
-
- _array[TreeNode.ENABLE] = new AbstractAction(
- "Enable", Utils.getIcon("/icons/16x16/enable.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.enable();
- }
- };
- _array[TreeNode.ENABLE].putValue(Action.SHORT_DESCRIPTION,
- "Enable this server");
-
- _array[TreeNode.DISABLE] = new AbstractAction(
- "Disable", Utils.getIcon("/icons/16x16/disable.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.disable();
- }
- };
- _array[TreeNode.DISABLE].putValue(Action.SHORT_DESCRIPTION,
- "Disable this server");
-
-
- _array[TreeNode.SHUTDOWN_NODE] = new AbstractAction("Shutdown")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.shutdownNode();
- }
- };
-
- _array[TreeNode.PATCH_SERVER] =
- new AbstractAction("Patch distribution")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.patchServer();
- }
- };
-
- _array[TreeNode.ADD_OBJECT] =
- new AbstractAction("Add well-known object")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.addObject();
- }
- };
- }
-
- private TreeNode _target;
- private Action[] _array = new Action[TreeNode.ACTION_COUNT];
-}
+// **********************************************************************
+//
+// 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;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+
+import IceGrid.*;
+import IceGridGUI.LiveDeployment.*;
+
+//
+// Holds all actions for the "Live Deployment" view
+//
+public class LiveActions
+{
+ public Action get(int index)
+ {
+ return _array[index];
+ }
+
+ public boolean[] setTarget(TreeNode target)
+ {
+ _target = target;
+
+ boolean[] availableActions;
+ if(_target == null)
+ {
+ availableActions = new boolean[TreeNode.ACTION_COUNT];
+ }
+ else
+ {
+ availableActions = _target.getAvailableActions();
+ }
+
+ for(int i = 0; i < _array.length; ++i)
+ {
+ _array[i].setEnabled(availableActions[i]);
+ }
+
+ return availableActions;
+ }
+
+ LiveActions()
+ {
+ _array[TreeNode.START] = new AbstractAction(
+ "Start", Utils.getIcon("/icons/16x16/start.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.start();
+ }
+ };
+ _array[TreeNode.START].putValue(Action.SHORT_DESCRIPTION,
+ "Start this server");
+
+ _array[TreeNode.STOP] = new AbstractAction(
+ "Stop", Utils.getIcon("/icons/16x16/stop.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.stop();
+ }
+ };
+ _array[TreeNode.STOP].putValue(Action.SHORT_DESCRIPTION,
+ "Stop this server");
+
+
+ _array[TreeNode.ENABLE] = new AbstractAction(
+ "Enable", Utils.getIcon("/icons/16x16/enable.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.enable();
+ }
+ };
+ _array[TreeNode.ENABLE].putValue(Action.SHORT_DESCRIPTION,
+ "Enable this server");
+
+ _array[TreeNode.DISABLE] = new AbstractAction(
+ "Disable", Utils.getIcon("/icons/16x16/disable.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.disable();
+ }
+ };
+ _array[TreeNode.DISABLE].putValue(Action.SHORT_DESCRIPTION,
+ "Disable this server");
+
+
+ _array[TreeNode.SHUTDOWN_NODE] = new AbstractAction("Shutdown")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.shutdownNode();
+ }
+ };
+
+ _array[TreeNode.PATCH_SERVER] =
+ new AbstractAction("Patch distribution")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.patchServer();
+ }
+ };
+
+ _array[TreeNode.ADD_OBJECT] =
+ new AbstractAction("Add well-known object")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.addObject();
+ }
+ };
+ }
+
+ private TreeNode _target;
+ private Action[] _array = new Action[TreeNode.ACTION_COUNT];
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/Adapter.java b/java/src/IceGridGUI/LiveDeployment/Adapter.java
index e22761a93a2..b738b6fbeed 100755
--- a/java/src/IceGridGUI/LiveDeployment/Adapter.java
+++ b/java/src/IceGridGUI/LiveDeployment/Adapter.java
@@ -1,175 +1,175 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-
-import javax.swing.Icon;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-
-class Adapter extends TreeNode
-{
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new AdapterEditor();
- }
- _editor.show(this);
- return _editor;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _activeIcon = Utils.getIcon("/icons/16x16/adapter_active.png");
- _inactiveIcon = Utils.getIcon("/icons/16x16/adapter_inactive.png");
- }
-
- if(_currentEndpoints == null || _currentEndpoints.length() == 0)
- {
- _cellRenderer.setLeafIcon(_inactiveIcon);
- }
- else
- {
- _cellRenderer.setLeafIcon(_activeIcon);
- }
-
- _cellRenderer.setToolTipText(_toolTip);
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- Adapter(TreeNode parent, String adapterName, Utils.Resolver resolver,
- String adapterId, AdapterDescriptor descriptor, Ice.ObjectPrx proxy)
- {
- super(parent, adapterName);
- _resolver = resolver;
- _adapterId = adapterId;
- _descriptor = descriptor;
-
- setCurrentEndpoints(proxy);
- }
-
- AdapterDescriptor getDescriptor()
- {
- return _descriptor;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- String getCurrentEndpoints()
- {
- return _currentEndpoints;
- }
-
- java.util.Map getProperties()
- {
- if(_parent instanceof Server)
- {
- return ((Server)_parent).getProperties();
- }
- else
- {
- return ((Service)_parent).getProperties();
- }
- }
-
- boolean update(AdapterDynamicInfo info)
- {
- if(info == null)
- {
- setCurrentEndpoints(null);
- getRoot().getTreeModel().nodeChanged(this);
- return true;
- }
- else if(info.id.equals(_adapterId))
- {
- setCurrentEndpoints(info.proxy);
- getRoot().getTreeModel().nodeChanged(this);
- return true;
- }
- else
- {
- return false;
- }
- }
-
- boolean update(java.util.List infoList)
- {
- java.util.Iterator p = infoList.iterator();
- while(p.hasNext())
- {
- AdapterDynamicInfo info = (AdapterDynamicInfo)p.next();
- if(update(info))
- {
- return true;
- }
- }
- return false;
- }
-
- private void setCurrentEndpoints(Ice.ObjectPrx proxy)
- {
- if(proxy == null)
- {
- _currentEndpoints = null;
- _toolTip = "Inactive";
- }
- else
- {
- String str = proxy.toString();
- int index = str.indexOf(':');
- if(index == -1 || index == str.length() - 1)
- {
- _currentEndpoints = "";
- }
- else
- {
- _currentEndpoints = str.substring(index + 1);
- }
- _toolTip = "Published endpoints: " + _currentEndpoints;
- }
- }
-
-
- private AdapterDescriptor _descriptor;
- private Utils.Resolver _resolver;
- private String _adapterId;
-
- private String _currentEndpoints;
- private String _toolTip;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon _activeIcon;
- static private Icon _inactiveIcon;
-
- static private AdapterEditor _editor;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+
+import javax.swing.Icon;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+
+class Adapter extends TreeNode
+{
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new AdapterEditor();
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _activeIcon = Utils.getIcon("/icons/16x16/adapter_active.png");
+ _inactiveIcon = Utils.getIcon("/icons/16x16/adapter_inactive.png");
+ }
+
+ if(_currentEndpoints == null || _currentEndpoints.length() == 0)
+ {
+ _cellRenderer.setLeafIcon(_inactiveIcon);
+ }
+ else
+ {
+ _cellRenderer.setLeafIcon(_activeIcon);
+ }
+
+ _cellRenderer.setToolTipText(_toolTip);
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ Adapter(TreeNode parent, String adapterName, Utils.Resolver resolver,
+ String adapterId, AdapterDescriptor descriptor, Ice.ObjectPrx proxy)
+ {
+ super(parent, adapterName);
+ _resolver = resolver;
+ _adapterId = adapterId;
+ _descriptor = descriptor;
+
+ setCurrentEndpoints(proxy);
+ }
+
+ AdapterDescriptor getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ String getCurrentEndpoints()
+ {
+ return _currentEndpoints;
+ }
+
+ java.util.Map getProperties()
+ {
+ if(_parent instanceof Server)
+ {
+ return ((Server)_parent).getProperties();
+ }
+ else
+ {
+ return ((Service)_parent).getProperties();
+ }
+ }
+
+ boolean update(AdapterDynamicInfo info)
+ {
+ if(info == null)
+ {
+ setCurrentEndpoints(null);
+ getRoot().getTreeModel().nodeChanged(this);
+ return true;
+ }
+ else if(info.id.equals(_adapterId))
+ {
+ setCurrentEndpoints(info.proxy);
+ getRoot().getTreeModel().nodeChanged(this);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ boolean update(java.util.List infoList)
+ {
+ java.util.Iterator p = infoList.iterator();
+ while(p.hasNext())
+ {
+ AdapterDynamicInfo info = (AdapterDynamicInfo)p.next();
+ if(update(info))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void setCurrentEndpoints(Ice.ObjectPrx proxy)
+ {
+ if(proxy == null)
+ {
+ _currentEndpoints = null;
+ _toolTip = "Inactive";
+ }
+ else
+ {
+ String str = proxy.toString();
+ int index = str.indexOf(':');
+ if(index == -1 || index == str.length() - 1)
+ {
+ _currentEndpoints = "";
+ }
+ else
+ {
+ _currentEndpoints = str.substring(index + 1);
+ }
+ _toolTip = "Published endpoints: " + _currentEndpoints;
+ }
+ }
+
+
+ private AdapterDescriptor _descriptor;
+ private Utils.Resolver _resolver;
+ private String _adapterId;
+
+ private String _currentEndpoints;
+ private String _toolTip;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private Icon _activeIcon;
+ static private Icon _inactiveIcon;
+
+ static private AdapterEditor _editor;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java b/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java
index 475e090cf2d..9d685a090e3 100755
--- a/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java
@@ -1,178 +1,178 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import javax.swing.AbstractAction;
-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.JFrame;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class AdapterEditor extends Editor
-{
- AdapterEditor()
- {
- _currentStatus.setEditable(false);
- _currentEndpoints.setEditable(false);
- _description.setEditable(false);
- _description.setOpaque(false);
- _id.setEditable(false);
- _replicaGroupId.setEditable(false);
- _endpoints.setEditable(false);
- _publishedEndpoints.setEditable(false);
- _registerProcess.setEnabled(false);
- _waitForActivation.setEnabled(false);
- }
-
-
- void show(Adapter adapter)
- {
- AdapterDescriptor descriptor = adapter.getDescriptor();
- Utils.Resolver resolver = adapter.getResolver();
-
- _id.setText(resolver.substitute(descriptor.id));
-
- String currentEndpoints = adapter.getCurrentEndpoints();
-
- if(currentEndpoints == null)
- {
- _currentStatus.setText("Inactive");
- _currentEndpoints.setText("");
- }
- else
- {
- _currentStatus.setText("Active");
- _currentEndpoints.setText(currentEndpoints);
- }
-
- _description.setText(resolver.substitute(descriptor.description));
- _replicaGroupId.setText(resolver.substitute(descriptor.replicaGroupId));
-
- java.util.Map properties = adapter.getProperties();
-
- // getId() returns the name of the adapter!
- _endpoints.setText(resolver.substitute((String)properties.get(adapter.getId() + ".Endpoints")));
- _publishedEndpoints.setText(
- resolver.substitute((String)properties.get(adapter.getId() + ".PublishedEndpoints")));
-
- _registerProcess.setSelected(descriptor.registerProcess);
- _waitForActivation.setSelected(descriptor.waitForActivation);
-
- _objects.setObjects(descriptor.objects, resolver);
- _allocatables.setObjects(descriptor.allocatables, resolver);
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.appendSeparator("Runtime Status");
-
- builder.append("Status" );
- builder.append(_currentStatus, 3);
- builder.nextLine();
-
- builder.append("Published Endpoints" );
- builder.append(_currentEndpoints, 3);
- builder.nextLine();
-
- builder.appendSeparator("Configuration");
-
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Adapter ID");
- builder.append(_id, 3);
- builder.nextLine();
-
- builder.append("Replica Group");
- builder.append(_replicaGroupId, 3);
- builder.nextLine();
-
- builder.append("Endpoints");
- builder.append(_endpoints, 3);
- builder.nextLine();
-
- builder.append("Published Endpoints");
- builder.append(_publishedEndpoints, 3);
- builder.nextLine();
-
- builder.append("", _registerProcess);
- builder.nextLine();
- builder.append("", _waitForActivation);
- builder.nextLine();
-
- builder.append("Well-known Objects");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_objects);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Allocatable Objects");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_allocatables);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Adapter Properties");
- }
-
- private JTextField _currentStatus = new JTextField(20);
- private JTextField _currentEndpoints = new JTextField(20);
-
- private JTextArea _description = new JTextArea(3, 20);
- private JTextField _id = new JTextField(20);
- private JTextField _replicaGroupId = new JTextField(20);
- private JTextField _endpoints = new JTextField(20);
- private JTextField _publishedEndpoints = new JTextField(20);
-
- private JCheckBox _registerProcess = new JCheckBox("Register Process");
- private JCheckBox _waitForActivation = new JCheckBox("Wait for Activation");
-
- private TableField _objects = new TableField("Identity", "Type");
- private TableField _allocatables = new TableField("Identity", "Type");
-}
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import javax.swing.AbstractAction;
+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.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class AdapterEditor extends Editor
+{
+ AdapterEditor()
+ {
+ _currentStatus.setEditable(false);
+ _currentEndpoints.setEditable(false);
+ _description.setEditable(false);
+ _description.setOpaque(false);
+ _id.setEditable(false);
+ _replicaGroupId.setEditable(false);
+ _endpoints.setEditable(false);
+ _publishedEndpoints.setEditable(false);
+ _registerProcess.setEnabled(false);
+ _waitForActivation.setEnabled(false);
+ }
+
+
+ void show(Adapter adapter)
+ {
+ AdapterDescriptor descriptor = adapter.getDescriptor();
+ Utils.Resolver resolver = adapter.getResolver();
+
+ _id.setText(resolver.substitute(descriptor.id));
+
+ String currentEndpoints = adapter.getCurrentEndpoints();
+
+ if(currentEndpoints == null)
+ {
+ _currentStatus.setText("Inactive");
+ _currentEndpoints.setText("");
+ }
+ else
+ {
+ _currentStatus.setText("Active");
+ _currentEndpoints.setText(currentEndpoints);
+ }
+
+ _description.setText(resolver.substitute(descriptor.description));
+ _replicaGroupId.setText(resolver.substitute(descriptor.replicaGroupId));
+
+ java.util.Map properties = adapter.getProperties();
+
+ // getId() returns the name of the adapter!
+ _endpoints.setText(resolver.substitute((String)properties.get(adapter.getId() + ".Endpoints")));
+ _publishedEndpoints.setText(
+ resolver.substitute((String)properties.get(adapter.getId() + ".PublishedEndpoints")));
+
+ _registerProcess.setSelected(descriptor.registerProcess);
+ _waitForActivation.setSelected(descriptor.waitForActivation);
+
+ _objects.setObjects(descriptor.objects, resolver);
+ _allocatables.setObjects(descriptor.allocatables, resolver);
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.appendSeparator("Runtime Status");
+
+ builder.append("Status" );
+ builder.append(_currentStatus, 3);
+ builder.nextLine();
+
+ builder.append("Published Endpoints" );
+ builder.append(_currentEndpoints, 3);
+ builder.nextLine();
+
+ builder.appendSeparator("Configuration");
+
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Adapter ID");
+ builder.append(_id, 3);
+ builder.nextLine();
+
+ builder.append("Replica Group");
+ builder.append(_replicaGroupId, 3);
+ builder.nextLine();
+
+ builder.append("Endpoints");
+ builder.append(_endpoints, 3);
+ builder.nextLine();
+
+ builder.append("Published Endpoints");
+ builder.append(_publishedEndpoints, 3);
+ builder.nextLine();
+
+ builder.append("", _registerProcess);
+ builder.nextLine();
+ builder.append("", _waitForActivation);
+ builder.nextLine();
+
+ builder.append("Well-known Objects");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_objects);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Allocatable Objects");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_allocatables);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Adapter Properties");
+ }
+
+ private JTextField _currentStatus = new JTextField(20);
+ private JTextField _currentEndpoints = new JTextField(20);
+
+ private JTextArea _description = new JTextArea(3, 20);
+ private JTextField _id = new JTextField(20);
+ private JTextField _replicaGroupId = new JTextField(20);
+ private JTextField _endpoints = new JTextField(20);
+ private JTextField _publishedEndpoints = new JTextField(20);
+
+ private JCheckBox _registerProcess = new JCheckBox("Register Process");
+ private JCheckBox _waitForActivation = new JCheckBox("Wait for Activation");
+
+ private TableField _objects = new TableField("Identity", "Type");
+ private TableField _allocatables = new TableField("Identity", "Type");
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java b/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java
index b37b25a2da7..c3592e639bf 100755
--- a/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java
@@ -1,69 +1,69 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class CommunicatorEditor extends Editor
-{
- protected CommunicatorEditor()
- {
- _description.setEditable(false);
- _description.setOpaque(false);
- }
-
- protected void show(CommunicatorDescriptor descriptor,
- java.util.SortedMap properties,
- Utils.Resolver resolver)
- {
- _description.setText(resolver.substitute(descriptor.description));
- _properties.setSortedMap(properties);
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
-
- builder.nextLine();
- builder.append("");
-
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- private JTextArea _description = new JTextArea(3, 20);
- private TableField _properties = new TableField("Name", "Value");
-}
-
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class CommunicatorEditor extends Editor
+{
+ protected CommunicatorEditor()
+ {
+ _description.setEditable(false);
+ _description.setOpaque(false);
+ }
+
+ protected void show(CommunicatorDescriptor descriptor,
+ java.util.SortedMap properties,
+ Utils.Resolver resolver)
+ {
+ _description.setText(resolver.substitute(descriptor.description));
+ _properties.setSortedMap(properties);
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextLine();
+ builder.append("");
+
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ private JTextArea _description = new JTextArea(3, 20);
+ private TableField _properties = new TableField("Name", "Value");
+}
+
diff --git a/java/src/IceGridGUI/LiveDeployment/DbEnv.java b/java/src/IceGridGUI/LiveDeployment/DbEnv.java
index 88e89222c5e..233826af330 100755
--- a/java/src/IceGridGUI/LiveDeployment/DbEnv.java
+++ b/java/src/IceGridGUI/LiveDeployment/DbEnv.java
@@ -1,75 +1,75 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class DbEnv extends TreeNode
-{
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/database.png"));
- }
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new DbEnvEditor();
- }
- _editor.show(this);
- return _editor;
- }
-
- DbEnv(TreeNode parent, String dbEnvName, Utils.Resolver resolver,
- DbEnvDescriptor descriptor)
- {
- super(parent, dbEnvName);
- _resolver = resolver;
- _descriptor = descriptor;
-
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- DbEnvDescriptor getDescriptor()
- {
- return _descriptor;
- }
-
- private Utils.Resolver _resolver;
- private DbEnvDescriptor _descriptor;
-
- static private DbEnvEditor _editor;
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class DbEnv extends TreeNode
+{
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/database.png"));
+ }
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new DbEnvEditor();
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ DbEnv(TreeNode parent, String dbEnvName, Utils.Resolver resolver,
+ DbEnvDescriptor descriptor)
+ {
+ super(parent, dbEnvName);
+ _resolver = resolver;
+ _descriptor = descriptor;
+
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ DbEnvDescriptor getDescriptor()
+ {
+ return _descriptor;
+ }
+
+ private Utils.Resolver _resolver;
+ private DbEnvDescriptor _descriptor;
+
+ static private DbEnvEditor _editor;
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java b/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java
index b7a9c6d78c9..dd417cca067 100755
--- a/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java
@@ -1,96 +1,96 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextArea;
-import javax.swing.JTextField;
-
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.DefaultTableCellRenderer;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class DbEnvEditor extends Editor
-{
- DbEnvEditor()
- {
- _description.setEditable(false);
- _description.setOpaque(false);
- _dbHome.setEditable(false);
- }
-
- void show(DbEnv dbEnv)
- {
- DbEnvDescriptor descriptor = dbEnv.getDescriptor();
- Utils.Resolver resolver = dbEnv.getResolver();
- _description.setText(resolver.substitute(descriptor.description));
-
- if(descriptor.dbHome.length() == 0)
- {
- _dbHome.setText("Created by the IceGrid Node");
- }
- else
- {
- _dbHome.setText(resolver.substitute(descriptor.dbHome));
- }
-
- _properties.setProperties(descriptor.properties, resolver);
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.append("Description");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-2);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_description);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
- builder.nextRow(2);
- builder.nextLine();
-
- builder.append("DB Home" );
- builder.append(_dbHome, 3);
- builder.nextLine();
-
- builder.append("Properties");
- builder.nextLine();
-
- builder.append("");
- builder.nextLine();
-
- builder.append("");
- builder.nextLine();
-
- builder.append("");
- builder.nextRow(-6);
- scrollPane = new JScrollPane(_properties);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("DbEnv Properties");
- }
-
- private JTextArea _description = new JTextArea(3, 20);
- private JTextField _dbHome = new JTextField(20);
- private TableField _properties = new TableField("Name", "Value");
-}
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class DbEnvEditor extends Editor
+{
+ DbEnvEditor()
+ {
+ _description.setEditable(false);
+ _description.setOpaque(false);
+ _dbHome.setEditable(false);
+ }
+
+ void show(DbEnv dbEnv)
+ {
+ DbEnvDescriptor descriptor = dbEnv.getDescriptor();
+ Utils.Resolver resolver = dbEnv.getResolver();
+ _description.setText(resolver.substitute(descriptor.description));
+
+ if(descriptor.dbHome.length() == 0)
+ {
+ _dbHome.setText("Created by the IceGrid Node");
+ }
+ else
+ {
+ _dbHome.setText(resolver.substitute(descriptor.dbHome));
+ }
+
+ _properties.setProperties(descriptor.properties, resolver);
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.append("Description");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-2);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_description);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 3));
+ builder.nextRow(2);
+ builder.nextLine();
+
+ builder.append("DB Home" );
+ builder.append(_dbHome, 3);
+ builder.nextLine();
+
+ builder.append("Properties");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextRow(-6);
+ scrollPane = new JScrollPane(_properties);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("DbEnv Properties");
+ }
+
+ private JTextArea _description = new JTextArea(3, 20);
+ private JTextField _dbHome = new JTextField(20);
+ private TableField _properties = new TableField("Name", "Value");
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/Editor.java b/java/src/IceGridGUI/LiveDeployment/Editor.java
index d212ac4bf28..c63b9fef0b4 100755
--- a/java/src/IceGridGUI/LiveDeployment/Editor.java
+++ b/java/src/IceGridGUI/LiveDeployment/Editor.java
@@ -1,18 +1,18 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import IceGridGUI.*;
-import IceGrid.*;
-
-public abstract class Editor extends EditorBase
-{
-}
-
-
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import IceGridGUI.*;
+import IceGrid.*;
+
+public abstract class Editor extends EditorBase
+{
+}
+
+
diff --git a/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java b/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java
index d8a7d452dae..a1c2206c06a 100755
--- a/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java
+++ b/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java
@@ -1,140 +1,140 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// A TreeNode that holds an array of list of children
-//
-abstract class ListArrayTreeNode extends TreeNode
-{
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- if(_p.hasNext())
- {
- return true;
- }
-
- while(++_index < _childrenArray.length)
- {
- _p = _childrenArray[_index].iterator();
- if(_p.hasNext())
- {
- return true;
- }
- }
- return false;
- }
-
- public Object nextElement()
- {
- try
- {
- return _p.next();
- }
- catch(java.util.NoSuchElementException nse)
- {
- if(hasMoreElements())
- {
- return _p.next();
- }
- else
- {
- throw nse;
- }
- }
- }
-
- private int _index = 0;
- private java.util.Iterator _p = _childrenArray[0].iterator();
- };
- }
-
- public boolean getAllowsChildren()
- {
- return true;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- if(childIndex < 0)
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- int offset = 0;
- for(int i = 0; i < _childrenArray.length; ++i)
- {
- if(childIndex < offset + _childrenArray[i].size())
- {
- return (javax.swing.tree.TreeNode)_childrenArray[i].get(childIndex - offset);
- }
- else
- {
- offset += _childrenArray[i].size();
- }
- }
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
-
- public int getChildCount()
- {
- int result = 0;
- for(int i = 0; i < _childrenArray.length; ++i)
- {
- result += _childrenArray[i].size();
- }
- return result;
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- int offset = 0;
- for(int i = 0; i < _childrenArray.length; ++i)
- {
- int index = _childrenArray[i].indexOf(node);
- if(index == -1)
- {
- offset += _childrenArray[i].size();
- }
- else
- {
- return offset + index;
- }
- }
- return -1;
- }
-
- public boolean isLeaf()
- {
- for(int i = 0; i < _childrenArray.length; ++i)
- {
- if(!_childrenArray[i].isEmpty())
- {
- return false;
- }
- }
- return true;
- }
-
- protected ListArrayTreeNode(TreeNode parent, String id, int arraySize)
- {
- super(parent, id);
- _childrenArray = new java.util.List[arraySize];
- }
-
- protected final java.util.List[] _childrenArray;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// A TreeNode that holds an array of list of children
+//
+abstract class ListArrayTreeNode extends TreeNode
+{
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ if(_p.hasNext())
+ {
+ return true;
+ }
+
+ while(++_index < _childrenArray.length)
+ {
+ _p = _childrenArray[_index].iterator();
+ if(_p.hasNext())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ try
+ {
+ return _p.next();
+ }
+ catch(java.util.NoSuchElementException nse)
+ {
+ if(hasMoreElements())
+ {
+ return _p.next();
+ }
+ else
+ {
+ throw nse;
+ }
+ }
+ }
+
+ private int _index = 0;
+ private java.util.Iterator _p = _childrenArray[0].iterator();
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ if(childIndex < 0)
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ int offset = 0;
+ for(int i = 0; i < _childrenArray.length; ++i)
+ {
+ if(childIndex < offset + _childrenArray[i].size())
+ {
+ return (javax.swing.tree.TreeNode)_childrenArray[i].get(childIndex - offset);
+ }
+ else
+ {
+ offset += _childrenArray[i].size();
+ }
+ }
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+
+ public int getChildCount()
+ {
+ int result = 0;
+ for(int i = 0; i < _childrenArray.length; ++i)
+ {
+ result += _childrenArray[i].size();
+ }
+ return result;
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ int offset = 0;
+ for(int i = 0; i < _childrenArray.length; ++i)
+ {
+ int index = _childrenArray[i].indexOf(node);
+ if(index == -1)
+ {
+ offset += _childrenArray[i].size();
+ }
+ else
+ {
+ return offset + index;
+ }
+ }
+ return -1;
+ }
+
+ public boolean isLeaf()
+ {
+ for(int i = 0; i < _childrenArray.length; ++i)
+ {
+ if(!_childrenArray[i].isEmpty())
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected ListArrayTreeNode(TreeNode parent, String id, int arraySize)
+ {
+ super(parent, id);
+ _childrenArray = new java.util.List[arraySize];
+ }
+
+ protected final java.util.List[] _childrenArray;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java b/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java
index bea3d9463dc..50ec1315481 100755
--- a/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java
+++ b/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java
@@ -1,81 +1,81 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// An TreeNode that holds a list of children
-//
-abstract class ListTreeNode extends TreeNode
-{
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- return _p.hasNext();
- }
-
- public Object nextElement()
- {
- return _p.next();
- }
-
- private java.util.Iterator _p = _children.iterator();
- };
- }
-
- public boolean getAllowsChildren()
- {
- return true;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- if(childIndex < 0)
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- else if(childIndex < _children.size())
- {
- return (javax.swing.tree.TreeNode)_children.get(childIndex);
- }
- else
- {
- throw new ArrayIndexOutOfBoundsException(childIndex);
- }
- }
-
- public int getChildCount()
- {
- return _children.size();
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- return _children.indexOf(node);
- }
-
- public boolean isLeaf()
- {
- return _children.isEmpty();
- }
-
- protected ListTreeNode(TreeNode parent, String id)
- {
- super(parent, id);
- }
-
- protected final java.util.List _children = new java.util.LinkedList();
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// An TreeNode that holds a list of children
+//
+abstract class ListTreeNode extends TreeNode
+{
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return _p.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return _p.next();
+ }
+
+ private java.util.Iterator _p = _children.iterator();
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return true;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ if(childIndex < 0)
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ else if(childIndex < _children.size())
+ {
+ return (javax.swing.tree.TreeNode)_children.get(childIndex);
+ }
+ else
+ {
+ throw new ArrayIndexOutOfBoundsException(childIndex);
+ }
+ }
+
+ public int getChildCount()
+ {
+ return _children.size();
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ return _children.indexOf(node);
+ }
+
+ public boolean isLeaf()
+ {
+ return _children.isEmpty();
+ }
+
+ protected ListTreeNode(TreeNode parent, String id)
+ {
+ super(parent, id);
+ }
+
+ protected final java.util.List _children = new java.util.LinkedList();
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/Node.java b/java/src/IceGridGUI/LiveDeployment/Node.java
index db8b03b4426..3ba6ecb9122 100755
--- a/java/src/IceGridGUI/LiveDeployment/Node.java
+++ b/java/src/IceGridGUI/LiveDeployment/Node.java
@@ -1,869 +1,869 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-import java.awt.Cursor;
-
-import javax.swing.Icon;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.SwingUtilities;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import java.text.NumberFormat;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Node extends ListTreeNode
-{
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[SHUTDOWN_NODE] = _up;
- return actions;
- }
-
- public void shutdownNode()
- {
- final String prefix = "Shutting down node '" + _id + "'...";
- getCoordinator().getStatusBar().setText(prefix);
-
- AMI_Admin_shutdownNode cb = new AMI_Admin_shutdownNode()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to shutdown " + _id, e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to shutdown " + _id,
- e.toString());
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- getCoordinator().getAdmin().shutdownNode_async(cb, _id);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to shutdown " + _id, e.toString());
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public JPopupMenu getPopupMenu()
- {
- LiveActions la = getCoordinator().getLiveActionsForPopup();
-
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(la.get(SHUTDOWN_NODE));
- }
-
- la.setTarget(this);
- return _popup;
- }
-
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new NodeEditor();
- }
- _editor.show(this);
- return _editor;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
- _nodeUp = Utils.getIcon("/icons/16x16/node_up.png");
- _nodeDown = Utils.getIcon("/icons/16x16/node_down.png");
- }
-
- if(_up)
- {
- _cellRenderer.setToolTipText("Up and running");
- if(expanded)
- {
- _cellRenderer.setOpenIcon(_nodeUp);
- }
- else
- {
- _cellRenderer.setClosedIcon(_nodeUp);
- }
- }
- else
- {
- _cellRenderer.setToolTipText("Not running");
- if(expanded)
- {
- _cellRenderer.setOpenIcon(_nodeDown);
- }
- else
- {
- _cellRenderer.setClosedIcon(_nodeDown);
- }
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- Node(Root parent, NodeDynamicInfo info)
- {
- super(parent, info.info.name);
- up(info, false);
- }
-
-
- Node(Root parent, ApplicationDescriptor appDesc,
- String nodeName, NodeDescriptor nodeDesc)
- {
- super(parent, nodeName);
- add(appDesc, nodeDesc);
- }
-
- Node(Root parent, ApplicationDescriptor appDesc, NodeUpdateDescriptor update)
- {
- super(parent, update.name);
-
- NodeDescriptor nodeDesc = new NodeDescriptor(
- update.variables,
- update.serverInstances,
- update.servers,
- update.loadFactor == null ? "" : update.loadFactor.value,
- update.description == null ? "" : update.description.value,
- update.propertySets);
-
- appDesc.nodes.put(_id, nodeDesc);
- add(appDesc, nodeDesc);
- }
-
- Utils.ExpandedPropertySet expand(PropertySetDescriptor descriptor,
- String applicationName, Utils.Resolver resolver)
- {
- Utils.ExpandedPropertySet result = new Utils.ExpandedPropertySet();
- result.references = new Utils.ExpandedPropertySet[descriptor.references.length];
-
- for(int i = 0; i < descriptor.references.length; ++i)
- {
- result.references[i] = expand(
- findNamedPropertySet(resolver.substitute(descriptor.references[i]),
- applicationName),
- applicationName, resolver);
- }
-
- result.properties = descriptor.properties;
- return result;
- }
-
- PropertySetDescriptor findNamedPropertySet(String name, String applicationName)
- {
- ApplicationData appData = (ApplicationData)_map.get(applicationName);
- if(appData != null)
- {
- NodeDescriptor descriptor = appData.descriptor;
- PropertySetDescriptor result = (PropertySetDescriptor)descriptor.propertySets.get(name);
- if(result != null)
- {
- return result;
- }
- }
- return getRoot().findNamedPropertySet(name, applicationName);
- }
-
- void add(ApplicationDescriptor appDesc, NodeDescriptor nodeDesc)
- {
- ApplicationData data = new ApplicationData();
- data.descriptor = nodeDesc;
- data.resolver = new Utils.Resolver(new java.util.Map[]{appDesc.variables, nodeDesc.variables});
- data.resolver.put("application", appDesc.name);
- data.resolver.put("node", _id);
-
- _map.put(appDesc.name, data);
-
- java.util.Iterator p = nodeDesc.serverInstances.iterator();
- while(p.hasNext())
- {
- ServerInstanceDescriptor desc = (ServerInstanceDescriptor)p.next();
- insertServer(createServer(appDesc, data.resolver, desc));
- }
-
- p = nodeDesc.servers.iterator();
- while(p.hasNext())
- {
- ServerDescriptor desc = (ServerDescriptor)p.next();
- insertServer(createServer(appDesc, data.resolver, desc));
- }
- }
-
-
-
- boolean remove(String appName)
- {
- _map.remove(appName);
- if(_map.isEmpty() && !_up)
- {
- return true;
- }
-
- java.util.List toRemove = new java.util.LinkedList();
- int[] toRemoveIndices = new int[_children.size()];
- int i = 0;
-
- for(int index = 0; index < _children.size(); ++index)
- {
- Server server = (Server)_children.get(i);
- if(server.getApplication().name.equals(appName))
- {
- toRemove.add(server);
- toRemoveIndices[i++] = index;
- }
- }
- toRemoveIndices = resize(toRemoveIndices, toRemove.size());
- _children.removeAll(toRemove);
- getRoot().getTreeModel().nodesWereRemoved(this, toRemoveIndices, toRemove.toArray());
-
- return false;
- }
-
- void update(ApplicationDescriptor appDesc, NodeUpdateDescriptor update,
- boolean variablesChanged, java.util.Set serviceTemplates,
- java.util.Set serverTemplates)
- {
- ApplicationData data = (ApplicationData)_map.get(appDesc.name);
-
- if(data == null)
- {
- if(update != null)
- {
- NodeDescriptor nodeDesc = new NodeDescriptor(
- update.variables,
- update.serverInstances,
- update.servers,
- update.loadFactor == null ? "" : update.loadFactor.value,
- update.description == null ? "" : update.description.value,
- update.propertySets);
-
- appDesc.nodes.put(_id, nodeDesc);
- add(appDesc, nodeDesc);
- }
- //
- // Else, nothing to do.
- //
-
- return;
- }
-
- NodeDescriptor nodeDesc = data.descriptor;
- java.util.Set freshServers = new java.util.HashSet();
-
- if(update != null)
- {
- //
- // Update various fields of nodeDesc
- //
- if(update.description != null)
- {
- nodeDesc.description = update.description.value;
- }
- if(update.loadFactor != null)
- {
- nodeDesc.loadFactor = update.loadFactor.value;
- }
-
- nodeDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.removeVariables));
- nodeDesc.variables.putAll(update.variables);
-
- if(!variablesChanged)
- {
- variablesChanged = update.removeVariables.length > 0 ||
- !update.variables.isEmpty();
- }
-
- nodeDesc.propertySets.keySet().removeAll(
- java.util.Arrays.asList(update.removePropertySets));
- nodeDesc.propertySets.putAll(update.propertySets);
-
- //
- // Remove servers
- //
- for(int i = 0; i < update.removeServers.length; ++i)
- {
- Server server = findServer(update.removeServers[i]);
- removeDescriptor(nodeDesc, server);
- int index = getIndex(server);
- _children.remove(server);
- getRoot().getTreeModel().nodesWereRemoved(this, new int[]{index}, new Object[]{server});
- }
-
- //
- // Add/update servers
- //
- java.util.Iterator p = update.serverInstances.iterator();
- while(p.hasNext())
- {
- ServerInstanceDescriptor desc = (ServerInstanceDescriptor)p.next();
- Server server = createServer(appDesc, data.resolver, desc);
-
- Server oldServer = findServer(server.getId());
- if(oldServer == null)
- {
- insertServer(server);
- freshServers.add(server);
- nodeDesc.serverInstances.add(desc);
- }
- else
- {
- removeDescriptor(nodeDesc, oldServer);
- oldServer.rebuild(server);
- freshServers.add(oldServer);
- nodeDesc.serverInstances.add(desc);
- }
- }
-
- p = update.servers.iterator();
- while(p.hasNext())
- {
- ServerDescriptor desc = (ServerDescriptor)p.next();
-
- Server server = createServer(appDesc, data.resolver, desc);
-
- Server oldServer = findServer(server.getId());
- if(oldServer == null)
- {
- insertServer(server);
- freshServers.add(server);
- nodeDesc.servers.add(desc);
- }
- else
- {
- removeDescriptor(nodeDesc, oldServer);
- oldServer.rebuild(server);
- freshServers.add(oldServer);
- nodeDesc.servers.add(desc);
- }
- }
- }
-
- if(variablesChanged || !serviceTemplates.isEmpty() || !serverTemplates.isEmpty())
- {
- //
- // Rebuild every other server
- //
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- if(!freshServers.contains(server))
- {
- server.rebuild(data.resolver,
- variablesChanged,
- serviceTemplates, serverTemplates);
- }
- }
- }
- }
-
- NodeInfo getStaticInfo()
- {
- if(_info == null)
- {
- return null;
- }
- else
- {
- return _info.info;
- }
- }
-
- boolean isRunningWindows()
- {
- return _windows;
- }
-
- void up(NodeDynamicInfo info, boolean fireEvent)
- {
- _up = true;
- _info = info;
- _windows = info.info.os.toLowerCase().startsWith("windows");
-
- //
- // Tell every server on this node
- //
- java.util.Set updatedServers = new java.util.HashSet();
- java.util.Iterator p = _info.servers.iterator();
- while(p.hasNext())
- {
- ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
- Server server = findServer(sinfo.id);
- if(server != null)
- {
- server.update(sinfo.state, sinfo.pid, sinfo.enabled, true);
- updatedServers.add(server);
- }
- }
- p = _children.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- if(!updatedServers.contains(server))
- {
- server.update(ServerState.Inactive, 0, true, true);
- }
- }
-
- //
- // Tell adapters
- //
- p = _children.iterator();
- int updateCount = 0;
- while(p.hasNext() && updateCount < _info.adapters.size())
- {
- Server server = (Server)p.next();
- updateCount += server.updateAdapters(_info.adapters);
- }
-
- if(fireEvent)
- {
- getRoot().getTreeModel().nodeChanged(this);
- }
- }
-
- boolean down()
- {
- _up = false;
- _info.servers.clear();
- _info.adapters.clear();
-
- if(_children.isEmpty())
- {
- return true;
- }
- else
- {
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- server.nodeDown();
- }
-
- getRoot().getTreeModel().nodeChanged(this);
- return false;
- }
- }
-
- void updateServer(ServerDynamicInfo updatedInfo)
- {
- if(_info != null)
- {
- java.util.ListIterator p = _info.servers.listIterator();
- while(p.hasNext())
- {
- ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
- if(sinfo.id.equals(updatedInfo.id))
- {
- p.set(updatedInfo);
- break;
- }
- }
- }
-
- Server server = findServer(updatedInfo.id);
- if(server != null)
- {
- server.update(updatedInfo.state, updatedInfo.pid,
- updatedInfo.enabled, true);
- }
- }
-
- void updateAdapter(AdapterDynamicInfo updatedInfo)
- {
- if(_info != null)
- {
- java.util.ListIterator p = _info.adapters.listIterator();
- while(p.hasNext())
- {
- AdapterDynamicInfo ainfo = (AdapterDynamicInfo)p.next();
- if(ainfo.id.equals(updatedInfo.id))
- {
- p.set(updatedInfo);
- break;
- }
- }
- }
-
- java.util.Iterator p = _children.iterator();
- while(p.hasNext())
- {
- Server server = (Server)p.next();
- if(server.updateAdapter(updatedInfo))
- {
- break;
- }
- }
- }
-
- Ice.ObjectPrx getProxy(String adapterId)
- {
- if(_info != null)
- {
- java.util.ListIterator p = _info.adapters.listIterator();
- while(p.hasNext())
- {
- AdapterDynamicInfo ainfo = (AdapterDynamicInfo)p.next();
- if(ainfo.equals(adapterId))
- {
- return ainfo.proxy;
- }
- }
- }
- return null;
- }
-
- java.util.SortedMap getLoadFactors()
- {
- java.util.SortedMap result = new java.util.TreeMap();
-
- java.util.Iterator p = _map.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- ApplicationData ad = (ApplicationData)entry.getValue();
-
- String val = ad.resolver.substitute(ad.descriptor.loadFactor);
- if(val.length() == 0)
- {
- val = "Default";
- }
-
- result.put(entry.getKey(), val);
- }
- return result;
- }
-
-
- void showLoad()
- {
- AMI_Admin_getNodeLoad cb = new AMI_Admin_getNodeLoad()
- {
- public void ice_response(LoadInfo loadInfo)
- {
- NumberFormat format;
- if(_windows)
- {
- format = NumberFormat.getPercentInstance();
- format.setMaximumFractionDigits(1);
- format.setMinimumFractionDigits(1);
- }
- else
- {
- format = NumberFormat.getNumberInstance();
- format.setMaximumFractionDigits(2);
- format.setMinimumFractionDigits(2);
- }
-
- final String load =
- format.format(loadInfo.avg1) + " " +
- format.format(loadInfo.avg5) + " " +
- format.format(loadInfo.avg15);
-
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _editor.setLoad(load, Node.this);
- }
- });
- }
-
- public void ice_exception(final Ice.UserException e)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- if(e instanceof IceGrid.NodeNotExistException)
- {
- _editor.setLoad(
- "Error: this node is not known to this IceGrid Registry",
- Node.this);
- }
- else if(e instanceof IceGrid.NodeUnreachableException)
- {
- _editor.setLoad("Error: cannot reach this node", Node.this);
- }
- else
- {
- _editor.setLoad("Error: " + e.toString(), Node.this);
- }
- }
- });
- }
-
- public void ice_exception(final Ice.LocalException e)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _editor.setLoad("Error: " + e.toString(), Node.this);
- }
- });
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- IceGrid.AdminPrx admin = getCoordinator().getAdmin();
- if(admin == null)
- {
- _editor.setLoad("Unknown", this);
- }
- else
- {
- admin.getNodeLoad_async(cb, _id);
- }
- }
- catch(Ice.LocalException e)
- {
- _editor.setLoad("Error: " + e.toString(), this);
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
-
- private Server createServer(ApplicationDescriptor application,
- Utils.Resolver resolver, ServerInstanceDescriptor instanceDescriptor)
- {
- //
- // Find template
- //
- TemplateDescriptor templateDescriptor =
- (TemplateDescriptor)application.serverTemplates.get(instanceDescriptor.template);
- assert templateDescriptor != null;
-
- ServerDescriptor serverDescriptor =
- (ServerDescriptor)templateDescriptor.descriptor;
-
- assert serverDescriptor != null;
-
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver =
- new Utils.Resolver(resolver,
- instanceDescriptor.parameterValues,
- templateDescriptor.parameterDefaults);
-
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Lookup dynamic info
- //
- ServerState serverState = _up ? ServerState.Inactive : null;
- int pid = 0;
- boolean enabled = true;
- if(_info != null)
- {
- java.util.Iterator p = _info.servers.iterator();
- while(p.hasNext())
- {
- ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
- if(sinfo.id.equals(serverId))
- {
- serverState = sinfo.state;
- pid = sinfo.pid;
- enabled = sinfo.enabled;
- break;
- }
- }
- }
-
- //
- // Create server
- //
- return new Server(this, serverId, instanceResolver, instanceDescriptor,
- serverDescriptor, application,
- serverState, pid, enabled);
-
- }
-
- private Server createServer(ApplicationDescriptor application,
- Utils.Resolver resolver, ServerDescriptor serverDescriptor)
- {
- //
- // Build resolver
- //
- Utils.Resolver instanceResolver = new Utils.Resolver(resolver);
- String serverId = instanceResolver.substitute(serverDescriptor.id);
- instanceResolver.put("server", serverId);
-
- //
- // Lookup dynamic info
- //
- ServerState serverState = _up ? ServerState.Inactive : null;
- int pid = 0;
- boolean enabled = true;
- if(_info != null)
- {
- java.util.Iterator p = _info.servers.iterator();
- while(p.hasNext())
- {
- ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
- if(sinfo.id.equals(serverId))
- {
- serverState = sinfo.state;
- pid = sinfo.pid;
- enabled = sinfo.enabled;
- break;
- }
- }
- }
-
- //
- // Create server
- //
- return new Server(this, serverId, instanceResolver, null, serverDescriptor,
- application, serverState, pid, enabled);
-
- }
-
- private void insertServer(Server server)
- {
- insertSortedChild(server, _children, getRoot().getTreeModel());
- }
-
- private Server findServer(String id)
- {
- return (Server)find(id, _children);
- }
-
-
- private void removeDescriptor(NodeDescriptor nodeDesc, Server server)
- {
- ServerInstanceDescriptor instanceDescriptor =
- server.getInstanceDescriptor();
- if(instanceDescriptor != null)
- {
- removeDescriptor(nodeDesc, instanceDescriptor);
- }
- else
- {
- removeDescriptor(nodeDesc, server.getServerDescriptor());
- }
- }
-
- private void removeDescriptor(NodeDescriptor nodeDesc, ServerDescriptor sd)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = nodeDesc.servers.iterator();
- while(p.hasNext())
- {
- if(sd == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
- private void removeDescriptor(NodeDescriptor nodeDesc, ServerInstanceDescriptor sd)
- {
- //
- // A straight remove uses equals(), which is not the desired behavior
- //
- java.util.Iterator p = nodeDesc.serverInstances.iterator();
- while(p.hasNext())
- {
- if(sd == p.next())
- {
- p.remove();
- break;
- }
- }
- }
-
-
- static class ApplicationData
- {
- NodeDescriptor descriptor;
- Utils.Resolver resolver;
- }
-
- //
- // Application name to ApplicationData
- //
- private final java.util.SortedMap _map = new java.util.TreeMap();
-
- private boolean _up = false;
- private NodeDynamicInfo _info;
- private boolean _windows = false;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon _nodeUp;
- static private Icon _nodeDown;
-
- static private NodeEditor _editor;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+import java.awt.Cursor;
+
+import javax.swing.Icon;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import java.text.NumberFormat;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Node extends ListTreeNode
+{
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[SHUTDOWN_NODE] = _up;
+ return actions;
+ }
+
+ public void shutdownNode()
+ {
+ final String prefix = "Shutting down node '" + _id + "'...";
+ getCoordinator().getStatusBar().setText(prefix);
+
+ AMI_Admin_shutdownNode cb = new AMI_Admin_shutdownNode()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to shutdown " + _id, e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to shutdown " + _id,
+ e.toString());
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ getCoordinator().getAdmin().shutdownNode_async(cb, _id);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to shutdown " + _id, e.toString());
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ LiveActions la = getCoordinator().getLiveActionsForPopup();
+
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(la.get(SHUTDOWN_NODE));
+ }
+
+ la.setTarget(this);
+ return _popup;
+ }
+
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new NodeEditor();
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _nodeUp = Utils.getIcon("/icons/16x16/node_up.png");
+ _nodeDown = Utils.getIcon("/icons/16x16/node_down.png");
+ }
+
+ if(_up)
+ {
+ _cellRenderer.setToolTipText("Up and running");
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(_nodeUp);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(_nodeUp);
+ }
+ }
+ else
+ {
+ _cellRenderer.setToolTipText("Not running");
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(_nodeDown);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(_nodeDown);
+ }
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ Node(Root parent, NodeDynamicInfo info)
+ {
+ super(parent, info.info.name);
+ up(info, false);
+ }
+
+
+ Node(Root parent, ApplicationDescriptor appDesc,
+ String nodeName, NodeDescriptor nodeDesc)
+ {
+ super(parent, nodeName);
+ add(appDesc, nodeDesc);
+ }
+
+ Node(Root parent, ApplicationDescriptor appDesc, NodeUpdateDescriptor update)
+ {
+ super(parent, update.name);
+
+ NodeDescriptor nodeDesc = new NodeDescriptor(
+ update.variables,
+ update.serverInstances,
+ update.servers,
+ update.loadFactor == null ? "" : update.loadFactor.value,
+ update.description == null ? "" : update.description.value,
+ update.propertySets);
+
+ appDesc.nodes.put(_id, nodeDesc);
+ add(appDesc, nodeDesc);
+ }
+
+ Utils.ExpandedPropertySet expand(PropertySetDescriptor descriptor,
+ String applicationName, Utils.Resolver resolver)
+ {
+ Utils.ExpandedPropertySet result = new Utils.ExpandedPropertySet();
+ result.references = new Utils.ExpandedPropertySet[descriptor.references.length];
+
+ for(int i = 0; i < descriptor.references.length; ++i)
+ {
+ result.references[i] = expand(
+ findNamedPropertySet(resolver.substitute(descriptor.references[i]),
+ applicationName),
+ applicationName, resolver);
+ }
+
+ result.properties = descriptor.properties;
+ return result;
+ }
+
+ PropertySetDescriptor findNamedPropertySet(String name, String applicationName)
+ {
+ ApplicationData appData = (ApplicationData)_map.get(applicationName);
+ if(appData != null)
+ {
+ NodeDescriptor descriptor = appData.descriptor;
+ PropertySetDescriptor result = (PropertySetDescriptor)descriptor.propertySets.get(name);
+ if(result != null)
+ {
+ return result;
+ }
+ }
+ return getRoot().findNamedPropertySet(name, applicationName);
+ }
+
+ void add(ApplicationDescriptor appDesc, NodeDescriptor nodeDesc)
+ {
+ ApplicationData data = new ApplicationData();
+ data.descriptor = nodeDesc;
+ data.resolver = new Utils.Resolver(new java.util.Map[]{appDesc.variables, nodeDesc.variables});
+ data.resolver.put("application", appDesc.name);
+ data.resolver.put("node", _id);
+
+ _map.put(appDesc.name, data);
+
+ java.util.Iterator p = nodeDesc.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor desc = (ServerInstanceDescriptor)p.next();
+ insertServer(createServer(appDesc, data.resolver, desc));
+ }
+
+ p = nodeDesc.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDescriptor desc = (ServerDescriptor)p.next();
+ insertServer(createServer(appDesc, data.resolver, desc));
+ }
+ }
+
+
+
+ boolean remove(String appName)
+ {
+ _map.remove(appName);
+ if(_map.isEmpty() && !_up)
+ {
+ return true;
+ }
+
+ java.util.List toRemove = new java.util.LinkedList();
+ int[] toRemoveIndices = new int[_children.size()];
+ int i = 0;
+
+ for(int index = 0; index < _children.size(); ++index)
+ {
+ Server server = (Server)_children.get(i);
+ if(server.getApplication().name.equals(appName))
+ {
+ toRemove.add(server);
+ toRemoveIndices[i++] = index;
+ }
+ }
+ toRemoveIndices = resize(toRemoveIndices, toRemove.size());
+ _children.removeAll(toRemove);
+ getRoot().getTreeModel().nodesWereRemoved(this, toRemoveIndices, toRemove.toArray());
+
+ return false;
+ }
+
+ void update(ApplicationDescriptor appDesc, NodeUpdateDescriptor update,
+ boolean variablesChanged, java.util.Set serviceTemplates,
+ java.util.Set serverTemplates)
+ {
+ ApplicationData data = (ApplicationData)_map.get(appDesc.name);
+
+ if(data == null)
+ {
+ if(update != null)
+ {
+ NodeDescriptor nodeDesc = new NodeDescriptor(
+ update.variables,
+ update.serverInstances,
+ update.servers,
+ update.loadFactor == null ? "" : update.loadFactor.value,
+ update.description == null ? "" : update.description.value,
+ update.propertySets);
+
+ appDesc.nodes.put(_id, nodeDesc);
+ add(appDesc, nodeDesc);
+ }
+ //
+ // Else, nothing to do.
+ //
+
+ return;
+ }
+
+ NodeDescriptor nodeDesc = data.descriptor;
+ java.util.Set freshServers = new java.util.HashSet();
+
+ if(update != null)
+ {
+ //
+ // Update various fields of nodeDesc
+ //
+ if(update.description != null)
+ {
+ nodeDesc.description = update.description.value;
+ }
+ if(update.loadFactor != null)
+ {
+ nodeDesc.loadFactor = update.loadFactor.value;
+ }
+
+ nodeDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.removeVariables));
+ nodeDesc.variables.putAll(update.variables);
+
+ if(!variablesChanged)
+ {
+ variablesChanged = update.removeVariables.length > 0 ||
+ !update.variables.isEmpty();
+ }
+
+ nodeDesc.propertySets.keySet().removeAll(
+ java.util.Arrays.asList(update.removePropertySets));
+ nodeDesc.propertySets.putAll(update.propertySets);
+
+ //
+ // Remove servers
+ //
+ for(int i = 0; i < update.removeServers.length; ++i)
+ {
+ Server server = findServer(update.removeServers[i]);
+ removeDescriptor(nodeDesc, server);
+ int index = getIndex(server);
+ _children.remove(server);
+ getRoot().getTreeModel().nodesWereRemoved(this, new int[]{index}, new Object[]{server});
+ }
+
+ //
+ // Add/update servers
+ //
+ java.util.Iterator p = update.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ ServerInstanceDescriptor desc = (ServerInstanceDescriptor)p.next();
+ Server server = createServer(appDesc, data.resolver, desc);
+
+ Server oldServer = findServer(server.getId());
+ if(oldServer == null)
+ {
+ insertServer(server);
+ freshServers.add(server);
+ nodeDesc.serverInstances.add(desc);
+ }
+ else
+ {
+ removeDescriptor(nodeDesc, oldServer);
+ oldServer.rebuild(server);
+ freshServers.add(oldServer);
+ nodeDesc.serverInstances.add(desc);
+ }
+ }
+
+ p = update.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDescriptor desc = (ServerDescriptor)p.next();
+
+ Server server = createServer(appDesc, data.resolver, desc);
+
+ Server oldServer = findServer(server.getId());
+ if(oldServer == null)
+ {
+ insertServer(server);
+ freshServers.add(server);
+ nodeDesc.servers.add(desc);
+ }
+ else
+ {
+ removeDescriptor(nodeDesc, oldServer);
+ oldServer.rebuild(server);
+ freshServers.add(oldServer);
+ nodeDesc.servers.add(desc);
+ }
+ }
+ }
+
+ if(variablesChanged || !serviceTemplates.isEmpty() || !serverTemplates.isEmpty())
+ {
+ //
+ // Rebuild every other server
+ //
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ if(!freshServers.contains(server))
+ {
+ server.rebuild(data.resolver,
+ variablesChanged,
+ serviceTemplates, serverTemplates);
+ }
+ }
+ }
+ }
+
+ NodeInfo getStaticInfo()
+ {
+ if(_info == null)
+ {
+ return null;
+ }
+ else
+ {
+ return _info.info;
+ }
+ }
+
+ boolean isRunningWindows()
+ {
+ return _windows;
+ }
+
+ void up(NodeDynamicInfo info, boolean fireEvent)
+ {
+ _up = true;
+ _info = info;
+ _windows = info.info.os.toLowerCase().startsWith("windows");
+
+ //
+ // Tell every server on this node
+ //
+ java.util.Set updatedServers = new java.util.HashSet();
+ java.util.Iterator p = _info.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
+ Server server = findServer(sinfo.id);
+ if(server != null)
+ {
+ server.update(sinfo.state, sinfo.pid, sinfo.enabled, true);
+ updatedServers.add(server);
+ }
+ }
+ p = _children.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ if(!updatedServers.contains(server))
+ {
+ server.update(ServerState.Inactive, 0, true, true);
+ }
+ }
+
+ //
+ // Tell adapters
+ //
+ p = _children.iterator();
+ int updateCount = 0;
+ while(p.hasNext() && updateCount < _info.adapters.size())
+ {
+ Server server = (Server)p.next();
+ updateCount += server.updateAdapters(_info.adapters);
+ }
+
+ if(fireEvent)
+ {
+ getRoot().getTreeModel().nodeChanged(this);
+ }
+ }
+
+ boolean down()
+ {
+ _up = false;
+ _info.servers.clear();
+ _info.adapters.clear();
+
+ if(_children.isEmpty())
+ {
+ return true;
+ }
+ else
+ {
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ server.nodeDown();
+ }
+
+ getRoot().getTreeModel().nodeChanged(this);
+ return false;
+ }
+ }
+
+ void updateServer(ServerDynamicInfo updatedInfo)
+ {
+ if(_info != null)
+ {
+ java.util.ListIterator p = _info.servers.listIterator();
+ while(p.hasNext())
+ {
+ ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
+ if(sinfo.id.equals(updatedInfo.id))
+ {
+ p.set(updatedInfo);
+ break;
+ }
+ }
+ }
+
+ Server server = findServer(updatedInfo.id);
+ if(server != null)
+ {
+ server.update(updatedInfo.state, updatedInfo.pid,
+ updatedInfo.enabled, true);
+ }
+ }
+
+ void updateAdapter(AdapterDynamicInfo updatedInfo)
+ {
+ if(_info != null)
+ {
+ java.util.ListIterator p = _info.adapters.listIterator();
+ while(p.hasNext())
+ {
+ AdapterDynamicInfo ainfo = (AdapterDynamicInfo)p.next();
+ if(ainfo.id.equals(updatedInfo.id))
+ {
+ p.set(updatedInfo);
+ break;
+ }
+ }
+ }
+
+ java.util.Iterator p = _children.iterator();
+ while(p.hasNext())
+ {
+ Server server = (Server)p.next();
+ if(server.updateAdapter(updatedInfo))
+ {
+ break;
+ }
+ }
+ }
+
+ Ice.ObjectPrx getProxy(String adapterId)
+ {
+ if(_info != null)
+ {
+ java.util.ListIterator p = _info.adapters.listIterator();
+ while(p.hasNext())
+ {
+ AdapterDynamicInfo ainfo = (AdapterDynamicInfo)p.next();
+ if(ainfo.equals(adapterId))
+ {
+ return ainfo.proxy;
+ }
+ }
+ }
+ return null;
+ }
+
+ java.util.SortedMap getLoadFactors()
+ {
+ java.util.SortedMap result = new java.util.TreeMap();
+
+ java.util.Iterator p = _map.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ ApplicationData ad = (ApplicationData)entry.getValue();
+
+ String val = ad.resolver.substitute(ad.descriptor.loadFactor);
+ if(val.length() == 0)
+ {
+ val = "Default";
+ }
+
+ result.put(entry.getKey(), val);
+ }
+ return result;
+ }
+
+
+ void showLoad()
+ {
+ AMI_Admin_getNodeLoad cb = new AMI_Admin_getNodeLoad()
+ {
+ public void ice_response(LoadInfo loadInfo)
+ {
+ NumberFormat format;
+ if(_windows)
+ {
+ format = NumberFormat.getPercentInstance();
+ format.setMaximumFractionDigits(1);
+ format.setMinimumFractionDigits(1);
+ }
+ else
+ {
+ format = NumberFormat.getNumberInstance();
+ format.setMaximumFractionDigits(2);
+ format.setMinimumFractionDigits(2);
+ }
+
+ final String load =
+ format.format(loadInfo.avg1) + " " +
+ format.format(loadInfo.avg5) + " " +
+ format.format(loadInfo.avg15);
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _editor.setLoad(load, Node.this);
+ }
+ });
+ }
+
+ public void ice_exception(final Ice.UserException e)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if(e instanceof IceGrid.NodeNotExistException)
+ {
+ _editor.setLoad(
+ "Error: this node is not known to this IceGrid Registry",
+ Node.this);
+ }
+ else if(e instanceof IceGrid.NodeUnreachableException)
+ {
+ _editor.setLoad("Error: cannot reach this node", Node.this);
+ }
+ else
+ {
+ _editor.setLoad("Error: " + e.toString(), Node.this);
+ }
+ }
+ });
+ }
+
+ public void ice_exception(final Ice.LocalException e)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _editor.setLoad("Error: " + e.toString(), Node.this);
+ }
+ });
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ IceGrid.AdminPrx admin = getCoordinator().getAdmin();
+ if(admin == null)
+ {
+ _editor.setLoad("Unknown", this);
+ }
+ else
+ {
+ admin.getNodeLoad_async(cb, _id);
+ }
+ }
+ catch(Ice.LocalException e)
+ {
+ _editor.setLoad("Error: " + e.toString(), this);
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+
+ private Server createServer(ApplicationDescriptor application,
+ Utils.Resolver resolver, ServerInstanceDescriptor instanceDescriptor)
+ {
+ //
+ // Find template
+ //
+ TemplateDescriptor templateDescriptor =
+ (TemplateDescriptor)application.serverTemplates.get(instanceDescriptor.template);
+ assert templateDescriptor != null;
+
+ ServerDescriptor serverDescriptor =
+ (ServerDescriptor)templateDescriptor.descriptor;
+
+ assert serverDescriptor != null;
+
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver =
+ new Utils.Resolver(resolver,
+ instanceDescriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Lookup dynamic info
+ //
+ ServerState serverState = _up ? ServerState.Inactive : null;
+ int pid = 0;
+ boolean enabled = true;
+ if(_info != null)
+ {
+ java.util.Iterator p = _info.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
+ if(sinfo.id.equals(serverId))
+ {
+ serverState = sinfo.state;
+ pid = sinfo.pid;
+ enabled = sinfo.enabled;
+ break;
+ }
+ }
+ }
+
+ //
+ // Create server
+ //
+ return new Server(this, serverId, instanceResolver, instanceDescriptor,
+ serverDescriptor, application,
+ serverState, pid, enabled);
+
+ }
+
+ private Server createServer(ApplicationDescriptor application,
+ Utils.Resolver resolver, ServerDescriptor serverDescriptor)
+ {
+ //
+ // Build resolver
+ //
+ Utils.Resolver instanceResolver = new Utils.Resolver(resolver);
+ String serverId = instanceResolver.substitute(serverDescriptor.id);
+ instanceResolver.put("server", serverId);
+
+ //
+ // Lookup dynamic info
+ //
+ ServerState serverState = _up ? ServerState.Inactive : null;
+ int pid = 0;
+ boolean enabled = true;
+ if(_info != null)
+ {
+ java.util.Iterator p = _info.servers.iterator();
+ while(p.hasNext())
+ {
+ ServerDynamicInfo sinfo = (ServerDynamicInfo)p.next();
+ if(sinfo.id.equals(serverId))
+ {
+ serverState = sinfo.state;
+ pid = sinfo.pid;
+ enabled = sinfo.enabled;
+ break;
+ }
+ }
+ }
+
+ //
+ // Create server
+ //
+ return new Server(this, serverId, instanceResolver, null, serverDescriptor,
+ application, serverState, pid, enabled);
+
+ }
+
+ private void insertServer(Server server)
+ {
+ insertSortedChild(server, _children, getRoot().getTreeModel());
+ }
+
+ private Server findServer(String id)
+ {
+ return (Server)find(id, _children);
+ }
+
+
+ private void removeDescriptor(NodeDescriptor nodeDesc, Server server)
+ {
+ ServerInstanceDescriptor instanceDescriptor =
+ server.getInstanceDescriptor();
+ if(instanceDescriptor != null)
+ {
+ removeDescriptor(nodeDesc, instanceDescriptor);
+ }
+ else
+ {
+ removeDescriptor(nodeDesc, server.getServerDescriptor());
+ }
+ }
+
+ private void removeDescriptor(NodeDescriptor nodeDesc, ServerDescriptor sd)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = nodeDesc.servers.iterator();
+ while(p.hasNext())
+ {
+ if(sd == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+ private void removeDescriptor(NodeDescriptor nodeDesc, ServerInstanceDescriptor sd)
+ {
+ //
+ // A straight remove uses equals(), which is not the desired behavior
+ //
+ java.util.Iterator p = nodeDesc.serverInstances.iterator();
+ while(p.hasNext())
+ {
+ if(sd == p.next())
+ {
+ p.remove();
+ break;
+ }
+ }
+ }
+
+
+ static class ApplicationData
+ {
+ NodeDescriptor descriptor;
+ Utils.Resolver resolver;
+ }
+
+ //
+ // Application name to ApplicationData
+ //
+ private final java.util.SortedMap _map = new java.util.TreeMap();
+
+ private boolean _up = false;
+ private NodeDynamicInfo _info;
+ private boolean _windows = false;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private Icon _nodeUp;
+ static private Icon _nodeDown;
+
+ static private NodeEditor _editor;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/NodeEditor.java b/java/src/IceGridGUI/LiveDeployment/NodeEditor.java
index eda518520fd..f8b89e7d12b 100755
--- a/java/src/IceGridGUI/LiveDeployment/NodeEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/NodeEditor.java
@@ -1,154 +1,154 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class NodeEditor extends Editor
-{
- NodeEditor()
- {
- _hostname.setEditable(false);
- _os.setEditable(false);
- _machineType.setEditable(false);
- _loadAverage.setEditable(false);
-
- Action refresh = new AbstractAction("Refresh")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.showLoad();
- }
- };
- refresh.putValue(Action.SHORT_DESCRIPTION,
- "Fetch the latest values from this IceGrid Node");
- _refreshButton = new JButton(refresh);
- }
-
- void show(Node node)
- {
- _target = node;
-
- NodeInfo info = node.getStaticInfo();
-
- if(info == null)
- {
- _hostname.setText("Unknown");
- _os.setText("Unknown");
- _machineType.setText("Unknown");
- _loadAverageLabel.setText("Load Average");
- _loadAverage.setText("Unknown");
- }
- else
- {
- _hostname.setText(info.hostname);
- _os.setText(info.os + " " + info.release + " " + info.version);
- _machineType.setText(info.machine + " with " +
- info.nProcessors
- + " CPU"
- + (info.nProcessors >= 2 ? "s" : ""));
-
- if(node.isRunningWindows())
- {
- _loadAverageLabel.setText("CPU Usage");
- _loadAverage.setToolTipText(
- "CPU usage in the past 1 min, 5 min and 15 min period");
- }
- else
- {
- _loadAverageLabel.setText("Load Average");
- _loadAverage.setToolTipText(
- "Load average in the past 1 min, 5 min and 15 min period");
- }
- _loadAverage.setText("Refreshing...");
- node.showLoad();
- }
-
- _loadFactor.setSortedMap(node.getLoadFactors());
- }
-
- void setLoad(String load, Node node)
- {
- if(node == _target)
- {
- _loadAverage.setText(load);
- }
- //
- // Otherwise, we've already moved to another node
- //
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.appendSeparator("System Information");
-
- builder.append("Hostname");
- builder.append(_hostname, 3);
- builder.nextLine();
- builder.append("Operating System");
- builder.append(_os, 3);
- builder.nextLine();
- builder.append("Machine Type");
- builder.append(_machineType, 3);
- builder.append(_loadAverageLabel, _loadAverage);
- builder.append(_refreshButton);
- builder.nextLine();
-
- builder.appendSeparator("Configuration");
-
- builder.append("Load Factor");
- builder.nextLine();
-
- builder.append("");
- builder.nextLine();
-
- builder.append("");
- builder.nextLine();
-
- builder.append("");
- builder.nextRow(-6);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_loadFactor);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Node Properties");
- }
-
- private JTextField _hostname = new JTextField(20);
- private JTextField _os = new JTextField(20);
- private JTextField _machineType = new JTextField(20);
- private JLabel _loadAverageLabel = new JLabel();
- private JTextField _loadAverage = new JTextField(20);
- private JButton _refreshButton;
-
- private TableField _loadFactor = new TableField("Application", "Value");
-
- private Node _target;
-}
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class NodeEditor extends Editor
+{
+ NodeEditor()
+ {
+ _hostname.setEditable(false);
+ _os.setEditable(false);
+ _machineType.setEditable(false);
+ _loadAverage.setEditable(false);
+
+ Action refresh = new AbstractAction("Refresh")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.showLoad();
+ }
+ };
+ refresh.putValue(Action.SHORT_DESCRIPTION,
+ "Fetch the latest values from this IceGrid Node");
+ _refreshButton = new JButton(refresh);
+ }
+
+ void show(Node node)
+ {
+ _target = node;
+
+ NodeInfo info = node.getStaticInfo();
+
+ if(info == null)
+ {
+ _hostname.setText("Unknown");
+ _os.setText("Unknown");
+ _machineType.setText("Unknown");
+ _loadAverageLabel.setText("Load Average");
+ _loadAverage.setText("Unknown");
+ }
+ else
+ {
+ _hostname.setText(info.hostname);
+ _os.setText(info.os + " " + info.release + " " + info.version);
+ _machineType.setText(info.machine + " with " +
+ info.nProcessors
+ + " CPU"
+ + (info.nProcessors >= 2 ? "s" : ""));
+
+ if(node.isRunningWindows())
+ {
+ _loadAverageLabel.setText("CPU Usage");
+ _loadAverage.setToolTipText(
+ "CPU usage in the past 1 min, 5 min and 15 min period");
+ }
+ else
+ {
+ _loadAverageLabel.setText("Load Average");
+ _loadAverage.setToolTipText(
+ "Load average in the past 1 min, 5 min and 15 min period");
+ }
+ _loadAverage.setText("Refreshing...");
+ node.showLoad();
+ }
+
+ _loadFactor.setSortedMap(node.getLoadFactors());
+ }
+
+ void setLoad(String load, Node node)
+ {
+ if(node == _target)
+ {
+ _loadAverage.setText(load);
+ }
+ //
+ // Otherwise, we've already moved to another node
+ //
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.appendSeparator("System Information");
+
+ builder.append("Hostname");
+ builder.append(_hostname, 3);
+ builder.nextLine();
+ builder.append("Operating System");
+ builder.append(_os, 3);
+ builder.nextLine();
+ builder.append("Machine Type");
+ builder.append(_machineType, 3);
+ builder.append(_loadAverageLabel, _loadAverage);
+ builder.append(_refreshButton);
+ builder.nextLine();
+
+ builder.appendSeparator("Configuration");
+
+ builder.append("Load Factor");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextLine();
+
+ builder.append("");
+ builder.nextRow(-6);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_loadFactor);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Node Properties");
+ }
+
+ private JTextField _hostname = new JTextField(20);
+ private JTextField _os = new JTextField(20);
+ private JTextField _machineType = new JTextField(20);
+ private JLabel _loadAverageLabel = new JLabel();
+ private JTextField _loadAverage = new JTextField(20);
+ private JButton _refreshButton;
+
+ private TableField _loadFactor = new TableField("Application", "Value");
+
+ private Node _target;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java
index ee9dee78cd5..d1379d8f6cc 100755
--- a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java
+++ b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java
@@ -1,120 +1,120 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Frame;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.factories.Borders;
-import com.jgoodies.forms.factories.ButtonBarFactory;
-import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.util.LayoutStyle;
-
-class ObjectDialog extends JDialog
-{
- ObjectDialog(final Root root)
- {
- super(root.getCoordinator().getMainFrame(),
- "New Well-Known Object - IceGrid Admin", true);
- setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
- _mainFrame = root.getCoordinator().getMainFrame();
-
- _type.setEditable(true);
-
- JButton okButton = new JButton("OK");
- ActionListener okListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- String type = null;
- if(_type.getSelectedItem() != QUERY_OBJECT)
- {
- type = _type.getSelectedItem().toString();
- }
-
- if(root.addObject(_proxy.getText(),type))
- {
- setVisible(false);
- }
- }
- };
- okButton.addActionListener(okListener);
- getRootPane().setDefaultButton(okButton);
-
- JButton cancelButton = new JButton("Cancel");
- ActionListener cancelListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- setVisible(false);
- }
- };
- cancelButton.addActionListener(cancelListener);
-
- FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
- builder.setRowGroupingEnabled(true);
- builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
-
- builder.append("Proxy", _proxy);
- builder.nextLine();
- builder.append("Type", _type);
- builder.nextLine();
-
- JComponent buttonBar =
- ButtonBarFactory.buildOKCancelBar(okButton, cancelButton);
- buttonBar.setBorder(Borders.DIALOG_BORDER);
-
- Container contentPane = getContentPane();
- contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
- contentPane.add(builder.getPanel());
- contentPane.add(buttonBar);
-
- pack();
- setResizable(false);
- }
-
- void showDialog()
- {
- _proxy.setText("");
- _type.setSelectedItem(QUERY_OBJECT);
- setLocationRelativeTo(_mainFrame);
- setVisible(true);
- }
-
- private JTextField _proxy = new JTextField(60);
- private JComboBox _type = new JComboBox(new Object[]{QUERY_OBJECT});
- private JFrame _mainFrame;
-
- static private final Object QUERY_OBJECT = new Object()
- {
- public String toString()
- {
- return "Query object to retrieve type";
- }
- };
-
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Frame;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.factories.ButtonBarFactory;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.util.LayoutStyle;
+
+class ObjectDialog extends JDialog
+{
+ ObjectDialog(final Root root)
+ {
+ super(root.getCoordinator().getMainFrame(),
+ "New Well-Known Object - IceGrid Admin", true);
+ setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
+ _mainFrame = root.getCoordinator().getMainFrame();
+
+ _type.setEditable(true);
+
+ JButton okButton = new JButton("OK");
+ ActionListener okListener = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ String type = null;
+ if(_type.getSelectedItem() != QUERY_OBJECT)
+ {
+ type = _type.getSelectedItem().toString();
+ }
+
+ if(root.addObject(_proxy.getText(),type))
+ {
+ setVisible(false);
+ }
+ }
+ };
+ okButton.addActionListener(okListener);
+ getRootPane().setDefaultButton(okButton);
+
+ JButton cancelButton = new JButton("Cancel");
+ ActionListener cancelListener = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ setVisible(false);
+ }
+ };
+ cancelButton.addActionListener(cancelListener);
+
+ FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+ builder.setRowGroupingEnabled(true);
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ builder.append("Proxy", _proxy);
+ builder.nextLine();
+ builder.append("Type", _type);
+ builder.nextLine();
+
+ JComponent buttonBar =
+ ButtonBarFactory.buildOKCancelBar(okButton, cancelButton);
+ buttonBar.setBorder(Borders.DIALOG_BORDER);
+
+ Container contentPane = getContentPane();
+ contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
+ contentPane.add(builder.getPanel());
+ contentPane.add(buttonBar);
+
+ pack();
+ setResizable(false);
+ }
+
+ void showDialog()
+ {
+ _proxy.setText("");
+ _type.setSelectedItem(QUERY_OBJECT);
+ setLocationRelativeTo(_mainFrame);
+ setVisible(true);
+ }
+
+ private JTextField _proxy = new JTextField(60);
+ private JComboBox _type = new JComboBox(new Object[]{QUERY_OBJECT});
+ private JFrame _mainFrame;
+
+ static private final Object QUERY_OBJECT = new Object()
+ {
+ public String toString()
+ {
+ return "Query object to retrieve type";
+ }
+ };
+
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java b/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java
index 81165abfa8b..9b4c9e2b811 100755
--- a/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java
@@ -1,153 +1,153 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class RegistryEditor extends Editor
-{
- RegistryEditor()
- {
- Action deleteObject = new AbstractAction("Remove selected object")
- {
- public void actionPerformed(ActionEvent e)
- {
- int selectedRow = _objects.getSelectedRow();
- if(selectedRow != -1)
- {
- _target.removeObject((String)_objects.getValueAt(selectedRow, 0));
- }
- }
- };
- _objects.getActionMap().put("delete", deleteObject);
- _objects.getInputMap().put(
- KeyStroke.getKeyStroke("DELETE"), "delete");
-
-
- Action addObject = new AbstractAction("Add a new well-known object")
- {
- public void actionPerformed(ActionEvent e)
- {
- _target.addObject();
- }
- };
- _objects.getActionMap().put("insert", addObject);
- _objects.getInputMap().put(
- KeyStroke.getKeyStroke("INSERT"), "insert");
-
- _objects.setToolTipText("<html>Well-known objects registered through the Admin interface.<br>"
- + "Well-known objects registered using Adapter or Replica Group<br>"
- + "definitions are not displayed here.</html>");
-
- Action deleteAdapter = new AbstractAction("Remove selected adapter")
- {
- public void actionPerformed(ActionEvent e)
- {
- int selectedRow = _adapters.getSelectedRow();
- if(selectedRow != -1)
- {
- _target.removeAdapter((String)_adapters.getValueAt(selectedRow, 0));
- }
- }
- };
- _adapters.getActionMap().put("delete", deleteAdapter);
- _adapters.getInputMap().put(
- KeyStroke.getKeyStroke("DELETE"), "delete");
- _adapters.setToolTipText("<html>Object adapters registered at run time.</html>");
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- CellConstraints cc = new CellConstraints();
-
- builder.appendSeparator("Dynamic Well-Known Objects");
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-14);
- JScrollPane scrollPane = new JScrollPane(_objects);
- scrollPane.setToolTipText(_objects.getToolTipText());
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 14));
- builder.nextRow(14);
- builder.nextLine();
-
- builder.appendSeparator("Dynamic Object Adapters");
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-14);
- scrollPane = new JScrollPane(_adapters);
- scrollPane.setToolTipText(_adapters.getToolTipText());
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 14));
- builder.nextRow(14);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Registry Properties");
- }
-
- void show(Root root)
- {
- _target = root;
- _objects.setObjects(root.getObjects());
- _adapters.setAdapters(root.getAdapters());
- }
-
-
- private TableField _objects = new TableField("Proxy", "Type");
- private TableField _adapters = new TableField("ID", "Endpoints", "Replica Group");
- private Root _target;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class RegistryEditor extends Editor
+{
+ RegistryEditor()
+ {
+ Action deleteObject = new AbstractAction("Remove selected object")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ int selectedRow = _objects.getSelectedRow();
+ if(selectedRow != -1)
+ {
+ _target.removeObject((String)_objects.getValueAt(selectedRow, 0));
+ }
+ }
+ };
+ _objects.getActionMap().put("delete", deleteObject);
+ _objects.getInputMap().put(
+ KeyStroke.getKeyStroke("DELETE"), "delete");
+
+
+ Action addObject = new AbstractAction("Add a new well-known object")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _target.addObject();
+ }
+ };
+ _objects.getActionMap().put("insert", addObject);
+ _objects.getInputMap().put(
+ KeyStroke.getKeyStroke("INSERT"), "insert");
+
+ _objects.setToolTipText("<html>Well-known objects registered through the Admin interface.<br>"
+ + "Well-known objects registered using Adapter or Replica Group<br>"
+ + "definitions are not displayed here.</html>");
+
+ Action deleteAdapter = new AbstractAction("Remove selected adapter")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ int selectedRow = _adapters.getSelectedRow();
+ if(selectedRow != -1)
+ {
+ _target.removeAdapter((String)_adapters.getValueAt(selectedRow, 0));
+ }
+ }
+ };
+ _adapters.getActionMap().put("delete", deleteAdapter);
+ _adapters.getInputMap().put(
+ KeyStroke.getKeyStroke("DELETE"), "delete");
+ _adapters.setToolTipText("<html>Object adapters registered at run time.</html>");
+ }
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ CellConstraints cc = new CellConstraints();
+
+ builder.appendSeparator("Dynamic Well-Known Objects");
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-14);
+ JScrollPane scrollPane = new JScrollPane(_objects);
+ scrollPane.setToolTipText(_objects.getToolTipText());
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 14));
+ builder.nextRow(14);
+ builder.nextLine();
+
+ builder.appendSeparator("Dynamic Object Adapters");
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-14);
+ scrollPane = new JScrollPane(_adapters);
+ scrollPane.setToolTipText(_adapters.getToolTipText());
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 14));
+ builder.nextRow(14);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Registry Properties");
+ }
+
+ void show(Root root)
+ {
+ _target = root;
+ _objects.setObjects(root.getObjects());
+ _adapters.setAdapters(root.getAdapters());
+ }
+
+
+ private TableField _objects = new TableField("Proxy", "Type");
+ private TableField _adapters = new TableField("ID", "Endpoints", "Replica Group");
+ private Root _target;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java
index 6c75bdd90dd..27336574fee 100755
--- a/java/src/IceGridGUI/LiveDeployment/Root.java
+++ b/java/src/IceGridGUI/LiveDeployment/Root.java
@@ -1,815 +1,815 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-import java.awt.Cursor;
-
-import javax.swing.Icon;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-//
-// The Root node of the Live Deployment view
-//
-public class Root extends ListTreeNode
-{
- public Root(Coordinator coordinator)
- {
- super(null, "Root");
- _coordinator = coordinator;
-
- _tree = new JTree(this, true);
- _treeModel = (DefaultTreeModel)_tree.getModel();
- _objectDialog = new ObjectDialog(this);
- }
-
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
- actions[ADD_OBJECT] = true;
- return actions;
- }
-
- public ApplicationDescriptor getApplicationDescriptor(String name)
- {
- return (ApplicationDescriptor)_descriptorMap.get(name);
- }
-
- public Object[] getApplicationNames()
- {
- return _descriptorMap.keySet().toArray();
- }
-
- public Object[] getPatchableApplicationNames()
- {
- java.util.List result = new java.util.ArrayList();
-
- java.util.Iterator p = _descriptorMap.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
-
- ApplicationDescriptor app = (ApplicationDescriptor)entry.getValue();
- if(app.distrib.icepatch.length() > 0)
- {
- result.add(entry.getKey());
- }
- }
- return result.toArray();
- }
-
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new RegistryEditor();
- }
- _editor.show(this);
- return _editor;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
-
- Icon icon = Utils.getIcon("/icons/16x16/registry.png");
- _cellRenderer.setOpenIcon(icon);
- _cellRenderer.setClosedIcon(icon);
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
-
- public void applicationInit(String instanceName, java.util.List applications)
- {
- _label = instanceName;
- _tree.setRootVisible(true);
-
- java.util.Iterator p = applications.iterator();
- while(p.hasNext())
- {
- applicationAdded((ApplicationDescriptor)p.next());
- }
- }
-
- //
- // Called when the session to the IceGrid Registry is closed
- //
- public void clear()
- {
- _adapters.clear();
- _objects.clear();
-
- _descriptorMap.clear();
- _children.clear();
- _treeModel.nodeStructureChanged(this);
- _tree.setRootVisible(false);
- }
-
- public void patch(final String applicationName)
- {
- int shutdown = JOptionPane.showConfirmDialog(
- getCoordinator().getMainFrame(),
- "You are about to install or refresh your"
- + " application distribution.\n"
- + " Do you want shut down all servers affected by this update?",
- "Patch Confirmation",
- JOptionPane.YES_NO_CANCEL_OPTION);
-
- if(shutdown == JOptionPane.CANCEL_OPTION)
- {
- return;
- }
-
- final String prefix = "Patching application '" + applicationName + "'...";
-
- _coordinator.getStatusBar().setText(prefix);
- AMI_Admin_patchApplication cb = new AMI_Admin_patchApplication()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to patch '"
- + applicationName + "'", e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to patch '" +
- applicationName + "'", e.toString());
- }
- };
-
- try
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- _coordinator.getAdmin().
- patchApplication_async(cb, applicationName,
- shutdown == JOptionPane.YES_OPTION);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to patch " + _id, e.toString());
- }
- finally
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
-
- //
- // From the Registry Observer:
- //
- public void applicationAdded(ApplicationDescriptor desc)
- {
- _descriptorMap.put(desc.name, desc);
-
- java.util.Iterator p = desc.nodes.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- String nodeName = (String)entry.getKey();
- NodeDescriptor nodeDesc = (NodeDescriptor)entry.getValue();
-
- Node node = findNode(nodeName);
- if(node == null)
- {
- insertNode(new Node(this, desc, nodeName, nodeDesc));
- }
- else
- {
- node.add(desc, nodeDesc);
- }
- }
- }
-
- public void applicationRemoved(String name)
- {
- _descriptorMap.remove(name);
-
- java.util.List toRemove = new java.util.LinkedList();
- int[] toRemoveIndices = new int[_children.size()];
-
- int i = 0;
- for(int index = 0; index < _children.size(); ++index)
- {
- Node node = (Node)_children.get(index);
- if(node.remove(name))
- {
- toRemove.add(node);
- toRemoveIndices[i++] = index;
- }
- }
-
- removeNodes(resize(toRemoveIndices, toRemove.size()), toRemove);
- }
-
- public void applicationUpdated(ApplicationUpdateDescriptor update)
- {
- ApplicationDescriptor appDesc = (ApplicationDescriptor)_descriptorMap.get(update.name);
-
- //
- // Update various fields of appDesc
- //
- if(update.description != null)
- {
- appDesc.description = update.description.value;
- }
- if(update.distrib != null)
- {
- appDesc.distrib = update.distrib.value;
- }
-
- appDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.removeVariables));
- appDesc.variables.putAll(update.variables);
- boolean variablesChanged = update.removeVariables.length > 0 || !update.variables.isEmpty();
-
- //
- // Update only descriptors (no tree node shown in this view)
- //
- appDesc.propertySets.keySet().
- removeAll(java.util.Arrays.asList(update.removePropertySets));
- appDesc.propertySets.putAll(update.propertySets);
-
- for(int i = 0; i < update.removeReplicaGroups.length; ++i)
- {
- for(int j = 0; j < appDesc.replicaGroups.size(); ++j)
- {
- ReplicaGroupDescriptor rgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j);
- if(rgd.id.equals(update.removeReplicaGroups[i]))
- {
- appDesc.replicaGroups.remove(j);
- break; // for
- }
- }
- }
-
- for(int i = 0; i < update.replicaGroups.size(); ++i)
- {
- ReplicaGroupDescriptor newRgd = (ReplicaGroupDescriptor)update.replicaGroups.get(i);
-
- boolean replaced = false;
- int j = 0;
- while(j < appDesc.replicaGroups.size() && !replaced)
- {
- ReplicaGroupDescriptor oldRgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j);
-
- if(newRgd.id.equals(oldRgd.id))
- {
- appDesc.replicaGroups.set(j, newRgd);
- replaced = true;
- }
- j++;
- }
-
- if(!replaced)
- {
- appDesc.replicaGroups.add(newRgd);
- }
- }
-
- appDesc.serviceTemplates.keySet().
- removeAll(java.util.Arrays.asList(update.removeServiceTemplates));
- appDesc.serviceTemplates.putAll(update.serviceTemplates);
-
- appDesc.serverTemplates.keySet().
- removeAll(java.util.Arrays.asList(update.removeServerTemplates));
- appDesc.serverTemplates.putAll(update.serverTemplates);
-
- //
- // Nodes
- //
-
- //
- // Removal
- //
- appDesc.nodes.keySet().removeAll(java.util.Arrays.asList(update.removeNodes));
-
- for(int i = 0; i < update.removeNodes.length; ++i)
- {
- Node node = findNode(update.removeNodes[i]);
- if(node.remove(update.name))
- {
- int index = getIndex(node);
- _children.remove(node);
- _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node});
- }
- }
-
- //
- // Add/update
- //
- java.util.Iterator p = update.nodes.iterator();
- java.util.Set freshNodes = new java.util.HashSet();
- while(p.hasNext())
- {
- NodeUpdateDescriptor nodeUpdateDesc = (NodeUpdateDescriptor)p.next();
-
- String nodeName = nodeUpdateDesc.name;
-
- Node node = findNode(nodeName);
- if(node == null)
- {
- node = new Node(this, appDesc, nodeUpdateDesc);
- insertNode(node);
- }
- else
- {
- node.update(appDesc, nodeUpdateDesc, variablesChanged,
- update.serviceTemplates.keySet(), update.serverTemplates.keySet());
- }
- freshNodes.add(node);
- }
-
- //
- // Notify non-fresh nodes if needed
- //
- if(variablesChanged || !update.serviceTemplates.isEmpty() || !update.serverTemplates.isEmpty())
- {
- p = _children.iterator();
- while(p.hasNext())
- {
- Node node = (Node)p.next();
- if(!freshNodes.contains(node))
- {
- node.update(appDesc, null, variablesChanged,
- update.serviceTemplates.keySet(), update.serverTemplates.keySet());
- }
- }
- }
- }
-
- public void adapterInit(AdapterInfo[] adapters)
- {
- //
- // TODO: XXX: REVIEW
- //
- for(int i = 0; i < adapters.length; ++i)
- {
- _adapters.put(adapters[i].id, adapters[i]);
- }
- }
-
- public void adapterAdded(AdapterInfo info)
- {
- _adapters.put(info.id, info);
- }
-
- public void adapterUpdated(AdapterInfo info)
- {
- _adapters.put(info.id, info);
- }
-
- public void adapterRemoved(String id)
- {
- _adapters.remove(id);
- }
-
- public void objectInit(ObjectInfo[] objects)
- {
- //
- // TODO: XXX: REVIEW
- //
- for(int i = 0; i < objects.length; ++i)
- {
- _objects.put(Ice.Util.identityToString(objects[i].proxy.ice_getIdentity()), objects[i]);
- }
- }
-
- public void objectAdded(ObjectInfo info)
- {
- _objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info);
- }
-
- public void objectUpdated(ObjectInfo info)
- {
- _objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info);
- }
-
- public void objectRemoved(Ice.Identity id)
- {
- _objects.remove(Ice.Util.identityToString(id));
- }
-
-
- //
- // From the Node Observer:
- //
- public void nodeUp(NodeDynamicInfo updatedInfo)
- {
- Node node = findNode(updatedInfo.info.name);
- if(node != null)
- {
- node.up(updatedInfo, true);
- }
- else
- {
- insertNode(new Node(this, updatedInfo));
- }
- }
-
- public void nodeDown(String nodeName)
- {
- Node node = findNode(nodeName);
- if(node != null)
- {
- if(node.down())
- {
- int index = getIndex(node);
- _children.remove(node);
- _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node});
- }
- }
- }
-
- public void updateServer(String nodeName, ServerDynamicInfo updatedInfo)
- {
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.updateServer(updatedInfo);
- }
- }
-
- public void updateAdapter(String nodeName, AdapterDynamicInfo updatedInfo)
- {
- Node node = findNode(nodeName);
- if(node != null)
- {
- node.updateAdapter(updatedInfo);
- }
- }
-
- public JPopupMenu getPopupMenu()
- {
- LiveActions la = _coordinator.getLiveActionsForPopup();
-
- if(_popup == null)
- {
- _popup = new JPopupMenu();
- _popup.add(la.get(ADD_OBJECT));
- }
-
- la.setTarget(this);
- return _popup;
- }
-
- public void setSelectedNode(TreeNode node)
- {
- _tree.setSelectionPath(node.getPath());
- }
-
- public JTree getTree()
- {
- return _tree;
- }
-
- public DefaultTreeModel getTreeModel()
- {
- return _treeModel;
- }
-
- public Coordinator getCoordinator()
- {
- return _coordinator;
- }
-
- public String toString()
- {
- return _label;
- }
-
- //
- // Check that this node is attached to the tree
- //
- public boolean hasNode(TreeNode node)
- {
- while(node != this)
- {
- TreeNode parent = (TreeNode)node.getParent();
- if(parent.getIndex(node) == -1)
- {
- return false;
- }
- else
- {
- node = parent;
- }
- }
- return true;
- }
-
- public void addObject()
- {
- _objectDialog.showDialog();
- }
-
-
- Root getRoot()
- {
- return this;
- }
-
- java.util.SortedMap getObjects()
- {
- return _objects;
- }
-
- java.util.SortedMap getAdapters()
- {
- return _adapters;
- }
-
-
- boolean addObject(String strProxy, String type)
- {
- Ice.ObjectPrx proxy = null;
-
- try
- {
- proxy = _coordinator.getCommunicator().stringToProxy(strProxy);
- }
- catch(Ice.LocalException e)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "Cannot parse proxy '" + strProxy + "'",
- "addObject failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- if(proxy == null)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "You must provide a non-null proxy",
- "addObject failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
-
- String strIdentity = Ice.Util.identityToString(proxy.ice_getIdentity());
-
- String prefix = "Adding well-known object '" + strIdentity + "'...";
- try
- {
- _coordinator.getStatusBar().setText(prefix);
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- if(type == null)
- {
- _coordinator.getAdmin().addObject(proxy);
- }
- else
- {
- _coordinator.getAdmin().addObjectWithType(proxy, type);
- }
- }
- catch(ObjectExistsException e)
- {
- _coordinator.getStatusBar().setText(prefix + "failed.");
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "An object with this identity is already registered as a well-known object",
- "addObject failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- catch(DeploymentException e)
- {
- _coordinator.getStatusBar().setText(prefix + "failed.");
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- "Deployment exception: " + e.reason,
- "addObject failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- catch(Ice.LocalException e)
- {
- _coordinator.getStatusBar().setText(prefix + "failed.");
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- e.toString(),
- "addObject failed",
- JOptionPane.ERROR_MESSAGE);
- return false;
- }
- finally
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- _coordinator.getStatusBar().setText(prefix + "done.");
- return true;
- }
-
-
- void removeObject(String strProxy)
- {
- Ice.ObjectPrx proxy = _coordinator.getCommunicator().stringToProxy(strProxy);
- Ice.Identity identity = proxy.ice_getIdentity();
- final String strIdentity = Ice.Util.identityToString(identity);
-
- final String prefix = "Removing well-known object '" + strIdentity + "'...";
- _coordinator.getStatusBar().setText(prefix);
-
- AMI_Admin_removeObject cb = new AMI_Admin_removeObject()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to remove object '" + strIdentity + "'", e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to remove object '" + strIdentity + "'",
- e.toString());
- }
- };
-
- try
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- _coordinator.getAdmin().removeObject_async(cb, identity);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to remove object '" + strIdentity + "'",
- e.toString());
- }
- finally
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- void removeAdapter(final String adapterId)
- {
- final String prefix = "Removing adapter '" + adapterId + "'...";
- _coordinator.getStatusBar().setText(prefix);
-
- AMI_Admin_removeAdapter cb = new AMI_Admin_removeAdapter()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'", e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'",
- e.toString());
- }
- };
-
- try
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- _coordinator.getAdmin().removeAdapter_async(cb, adapterId);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to remove adapter '" + adapterId + "'", e.toString());
- }
- finally
- {
- _coordinator.getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
-
- PropertySetDescriptor findNamedPropertySet(String name, String applicationName)
- {
- ApplicationDescriptor descriptor = (ApplicationDescriptor)
- _descriptorMap.get(applicationName);
- return (PropertySetDescriptor)descriptor.propertySets.get(name);
- }
-
- private Node findNode(String nodeName)
- {
- return (Node)find(nodeName, _children);
- }
-
- private void insertNode(Node node)
- {
- String nodeName = node.toString();
- int i;
- for(i = 0; i < _children.size(); ++i)
- {
- String otherNodeName = _children.get(i).toString();
- if(nodeName.compareTo(otherNodeName) > 0)
- {
- i++;
- break;
- }
- }
- _children.add(i, node);
- _treeModel.nodesWereInserted(this, new int[]{i});
- }
-
- private void removeNodes(int[] toRemoveIndices, java.util.List toRemove)
- {
- if(toRemove.size() > 0)
- {
- _children.removeAll(toRemove);
- _treeModel.nodesWereRemoved(this, toRemoveIndices, toRemove.toArray());
- }
- }
-
- private final Coordinator _coordinator;
-
- //
- // Maps application name to current application descriptor
- //
- private final java.util.Map _descriptorMap = new java.util.TreeMap();
-
- //
- // Map AdapterId => AdapterInfo
- //
- private java.util.SortedMap _adapters = new java.util.TreeMap();
-
- //
- // Map stringified identity => ObjectInfo
- //
- private java.util.SortedMap _objects = new java.util.TreeMap();
-
- //
- // 'this' is the root of the tree
- //
- private final JTree _tree;
- private final DefaultTreeModel _treeModel;
-
- private String _label;
-
- private ObjectDialog _objectDialog;
-
- static private RegistryEditor _editor;
- static private JPopupMenu _popup;
- static private DefaultTreeCellRenderer _cellRenderer;
-
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+import java.awt.Cursor;
+
+import javax.swing.Icon;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+//
+// The Root node of the Live Deployment view
+//
+public class Root extends ListTreeNode
+{
+ public Root(Coordinator coordinator)
+ {
+ super(null, "Root");
+ _coordinator = coordinator;
+
+ _tree = new JTree(this, true);
+ _treeModel = (DefaultTreeModel)_tree.getModel();
+ _objectDialog = new ObjectDialog(this);
+ }
+
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+ actions[ADD_OBJECT] = true;
+ return actions;
+ }
+
+ public ApplicationDescriptor getApplicationDescriptor(String name)
+ {
+ return (ApplicationDescriptor)_descriptorMap.get(name);
+ }
+
+ public Object[] getApplicationNames()
+ {
+ return _descriptorMap.keySet().toArray();
+ }
+
+ public Object[] getPatchableApplicationNames()
+ {
+ java.util.List result = new java.util.ArrayList();
+
+ java.util.Iterator p = _descriptorMap.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+
+ ApplicationDescriptor app = (ApplicationDescriptor)entry.getValue();
+ if(app.distrib.icepatch.length() > 0)
+ {
+ result.add(entry.getKey());
+ }
+ }
+ return result.toArray();
+ }
+
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new RegistryEditor();
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+
+ Icon icon = Utils.getIcon("/icons/16x16/registry.png");
+ _cellRenderer.setOpenIcon(icon);
+ _cellRenderer.setClosedIcon(icon);
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+
+ public void applicationInit(String instanceName, java.util.List applications)
+ {
+ _label = instanceName;
+ _tree.setRootVisible(true);
+
+ java.util.Iterator p = applications.iterator();
+ while(p.hasNext())
+ {
+ applicationAdded((ApplicationDescriptor)p.next());
+ }
+ }
+
+ //
+ // Called when the session to the IceGrid Registry is closed
+ //
+ public void clear()
+ {
+ _adapters.clear();
+ _objects.clear();
+
+ _descriptorMap.clear();
+ _children.clear();
+ _treeModel.nodeStructureChanged(this);
+ _tree.setRootVisible(false);
+ }
+
+ public void patch(final String applicationName)
+ {
+ int shutdown = JOptionPane.showConfirmDialog(
+ getCoordinator().getMainFrame(),
+ "You are about to install or refresh your"
+ + " application distribution.\n"
+ + " Do you want shut down all servers affected by this update?",
+ "Patch Confirmation",
+ JOptionPane.YES_NO_CANCEL_OPTION);
+
+ if(shutdown == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
+
+ final String prefix = "Patching application '" + applicationName + "'...";
+
+ _coordinator.getStatusBar().setText(prefix);
+ AMI_Admin_patchApplication cb = new AMI_Admin_patchApplication()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to patch '"
+ + applicationName + "'", e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to patch '" +
+ applicationName + "'", e.toString());
+ }
+ };
+
+ try
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ _coordinator.getAdmin().
+ patchApplication_async(cb, applicationName,
+ shutdown == JOptionPane.YES_OPTION);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to patch " + _id, e.toString());
+ }
+ finally
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+
+ //
+ // From the Registry Observer:
+ //
+ public void applicationAdded(ApplicationDescriptor desc)
+ {
+ _descriptorMap.put(desc.name, desc);
+
+ java.util.Iterator p = desc.nodes.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ String nodeName = (String)entry.getKey();
+ NodeDescriptor nodeDesc = (NodeDescriptor)entry.getValue();
+
+ Node node = findNode(nodeName);
+ if(node == null)
+ {
+ insertNode(new Node(this, desc, nodeName, nodeDesc));
+ }
+ else
+ {
+ node.add(desc, nodeDesc);
+ }
+ }
+ }
+
+ public void applicationRemoved(String name)
+ {
+ _descriptorMap.remove(name);
+
+ java.util.List toRemove = new java.util.LinkedList();
+ int[] toRemoveIndices = new int[_children.size()];
+
+ int i = 0;
+ for(int index = 0; index < _children.size(); ++index)
+ {
+ Node node = (Node)_children.get(index);
+ if(node.remove(name))
+ {
+ toRemove.add(node);
+ toRemoveIndices[i++] = index;
+ }
+ }
+
+ removeNodes(resize(toRemoveIndices, toRemove.size()), toRemove);
+ }
+
+ public void applicationUpdated(ApplicationUpdateDescriptor update)
+ {
+ ApplicationDescriptor appDesc = (ApplicationDescriptor)_descriptorMap.get(update.name);
+
+ //
+ // Update various fields of appDesc
+ //
+ if(update.description != null)
+ {
+ appDesc.description = update.description.value;
+ }
+ if(update.distrib != null)
+ {
+ appDesc.distrib = update.distrib.value;
+ }
+
+ appDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.removeVariables));
+ appDesc.variables.putAll(update.variables);
+ boolean variablesChanged = update.removeVariables.length > 0 || !update.variables.isEmpty();
+
+ //
+ // Update only descriptors (no tree node shown in this view)
+ //
+ appDesc.propertySets.keySet().
+ removeAll(java.util.Arrays.asList(update.removePropertySets));
+ appDesc.propertySets.putAll(update.propertySets);
+
+ for(int i = 0; i < update.removeReplicaGroups.length; ++i)
+ {
+ for(int j = 0; j < appDesc.replicaGroups.size(); ++j)
+ {
+ ReplicaGroupDescriptor rgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j);
+ if(rgd.id.equals(update.removeReplicaGroups[i]))
+ {
+ appDesc.replicaGroups.remove(j);
+ break; // for
+ }
+ }
+ }
+
+ for(int i = 0; i < update.replicaGroups.size(); ++i)
+ {
+ ReplicaGroupDescriptor newRgd = (ReplicaGroupDescriptor)update.replicaGroups.get(i);
+
+ boolean replaced = false;
+ int j = 0;
+ while(j < appDesc.replicaGroups.size() && !replaced)
+ {
+ ReplicaGroupDescriptor oldRgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j);
+
+ if(newRgd.id.equals(oldRgd.id))
+ {
+ appDesc.replicaGroups.set(j, newRgd);
+ replaced = true;
+ }
+ j++;
+ }
+
+ if(!replaced)
+ {
+ appDesc.replicaGroups.add(newRgd);
+ }
+ }
+
+ appDesc.serviceTemplates.keySet().
+ removeAll(java.util.Arrays.asList(update.removeServiceTemplates));
+ appDesc.serviceTemplates.putAll(update.serviceTemplates);
+
+ appDesc.serverTemplates.keySet().
+ removeAll(java.util.Arrays.asList(update.removeServerTemplates));
+ appDesc.serverTemplates.putAll(update.serverTemplates);
+
+ //
+ // Nodes
+ //
+
+ //
+ // Removal
+ //
+ appDesc.nodes.keySet().removeAll(java.util.Arrays.asList(update.removeNodes));
+
+ for(int i = 0; i < update.removeNodes.length; ++i)
+ {
+ Node node = findNode(update.removeNodes[i]);
+ if(node.remove(update.name))
+ {
+ int index = getIndex(node);
+ _children.remove(node);
+ _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node});
+ }
+ }
+
+ //
+ // Add/update
+ //
+ java.util.Iterator p = update.nodes.iterator();
+ java.util.Set freshNodes = new java.util.HashSet();
+ while(p.hasNext())
+ {
+ NodeUpdateDescriptor nodeUpdateDesc = (NodeUpdateDescriptor)p.next();
+
+ String nodeName = nodeUpdateDesc.name;
+
+ Node node = findNode(nodeName);
+ if(node == null)
+ {
+ node = new Node(this, appDesc, nodeUpdateDesc);
+ insertNode(node);
+ }
+ else
+ {
+ node.update(appDesc, nodeUpdateDesc, variablesChanged,
+ update.serviceTemplates.keySet(), update.serverTemplates.keySet());
+ }
+ freshNodes.add(node);
+ }
+
+ //
+ // Notify non-fresh nodes if needed
+ //
+ if(variablesChanged || !update.serviceTemplates.isEmpty() || !update.serverTemplates.isEmpty())
+ {
+ p = _children.iterator();
+ while(p.hasNext())
+ {
+ Node node = (Node)p.next();
+ if(!freshNodes.contains(node))
+ {
+ node.update(appDesc, null, variablesChanged,
+ update.serviceTemplates.keySet(), update.serverTemplates.keySet());
+ }
+ }
+ }
+ }
+
+ public void adapterInit(AdapterInfo[] adapters)
+ {
+ //
+ // TODO: XXX: REVIEW
+ //
+ for(int i = 0; i < adapters.length; ++i)
+ {
+ _adapters.put(adapters[i].id, adapters[i]);
+ }
+ }
+
+ public void adapterAdded(AdapterInfo info)
+ {
+ _adapters.put(info.id, info);
+ }
+
+ public void adapterUpdated(AdapterInfo info)
+ {
+ _adapters.put(info.id, info);
+ }
+
+ public void adapterRemoved(String id)
+ {
+ _adapters.remove(id);
+ }
+
+ public void objectInit(ObjectInfo[] objects)
+ {
+ //
+ // TODO: XXX: REVIEW
+ //
+ for(int i = 0; i < objects.length; ++i)
+ {
+ _objects.put(Ice.Util.identityToString(objects[i].proxy.ice_getIdentity()), objects[i]);
+ }
+ }
+
+ public void objectAdded(ObjectInfo info)
+ {
+ _objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info);
+ }
+
+ public void objectUpdated(ObjectInfo info)
+ {
+ _objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info);
+ }
+
+ public void objectRemoved(Ice.Identity id)
+ {
+ _objects.remove(Ice.Util.identityToString(id));
+ }
+
+
+ //
+ // From the Node Observer:
+ //
+ public void nodeUp(NodeDynamicInfo updatedInfo)
+ {
+ Node node = findNode(updatedInfo.info.name);
+ if(node != null)
+ {
+ node.up(updatedInfo, true);
+ }
+ else
+ {
+ insertNode(new Node(this, updatedInfo));
+ }
+ }
+
+ public void nodeDown(String nodeName)
+ {
+ Node node = findNode(nodeName);
+ if(node != null)
+ {
+ if(node.down())
+ {
+ int index = getIndex(node);
+ _children.remove(node);
+ _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node});
+ }
+ }
+ }
+
+ public void updateServer(String nodeName, ServerDynamicInfo updatedInfo)
+ {
+ Node node = findNode(nodeName);
+ if(node != null)
+ {
+ node.updateServer(updatedInfo);
+ }
+ }
+
+ public void updateAdapter(String nodeName, AdapterDynamicInfo updatedInfo)
+ {
+ Node node = findNode(nodeName);
+ if(node != null)
+ {
+ node.updateAdapter(updatedInfo);
+ }
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ LiveActions la = _coordinator.getLiveActionsForPopup();
+
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+ _popup.add(la.get(ADD_OBJECT));
+ }
+
+ la.setTarget(this);
+ return _popup;
+ }
+
+ public void setSelectedNode(TreeNode node)
+ {
+ _tree.setSelectionPath(node.getPath());
+ }
+
+ public JTree getTree()
+ {
+ return _tree;
+ }
+
+ public DefaultTreeModel getTreeModel()
+ {
+ return _treeModel;
+ }
+
+ public Coordinator getCoordinator()
+ {
+ return _coordinator;
+ }
+
+ public String toString()
+ {
+ return _label;
+ }
+
+ //
+ // Check that this node is attached to the tree
+ //
+ public boolean hasNode(TreeNode node)
+ {
+ while(node != this)
+ {
+ TreeNode parent = (TreeNode)node.getParent();
+ if(parent.getIndex(node) == -1)
+ {
+ return false;
+ }
+ else
+ {
+ node = parent;
+ }
+ }
+ return true;
+ }
+
+ public void addObject()
+ {
+ _objectDialog.showDialog();
+ }
+
+
+ Root getRoot()
+ {
+ return this;
+ }
+
+ java.util.SortedMap getObjects()
+ {
+ return _objects;
+ }
+
+ java.util.SortedMap getAdapters()
+ {
+ return _adapters;
+ }
+
+
+ boolean addObject(String strProxy, String type)
+ {
+ Ice.ObjectPrx proxy = null;
+
+ try
+ {
+ proxy = _coordinator.getCommunicator().stringToProxy(strProxy);
+ }
+ catch(Ice.LocalException e)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "Cannot parse proxy '" + strProxy + "'",
+ "addObject failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ if(proxy == null)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "You must provide a non-null proxy",
+ "addObject failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ String strIdentity = Ice.Util.identityToString(proxy.ice_getIdentity());
+
+ String prefix = "Adding well-known object '" + strIdentity + "'...";
+ try
+ {
+ _coordinator.getStatusBar().setText(prefix);
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ if(type == null)
+ {
+ _coordinator.getAdmin().addObject(proxy);
+ }
+ else
+ {
+ _coordinator.getAdmin().addObjectWithType(proxy, type);
+ }
+ }
+ catch(ObjectExistsException e)
+ {
+ _coordinator.getStatusBar().setText(prefix + "failed.");
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "An object with this identity is already registered as a well-known object",
+ "addObject failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ catch(DeploymentException e)
+ {
+ _coordinator.getStatusBar().setText(prefix + "failed.");
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ "Deployment exception: " + e.reason,
+ "addObject failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ catch(Ice.LocalException e)
+ {
+ _coordinator.getStatusBar().setText(prefix + "failed.");
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ e.toString(),
+ "addObject failed",
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ finally
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ _coordinator.getStatusBar().setText(prefix + "done.");
+ return true;
+ }
+
+
+ void removeObject(String strProxy)
+ {
+ Ice.ObjectPrx proxy = _coordinator.getCommunicator().stringToProxy(strProxy);
+ Ice.Identity identity = proxy.ice_getIdentity();
+ final String strIdentity = Ice.Util.identityToString(identity);
+
+ final String prefix = "Removing well-known object '" + strIdentity + "'...";
+ _coordinator.getStatusBar().setText(prefix);
+
+ AMI_Admin_removeObject cb = new AMI_Admin_removeObject()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to remove object '" + strIdentity + "'", e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to remove object '" + strIdentity + "'",
+ e.toString());
+ }
+ };
+
+ try
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ _coordinator.getAdmin().removeObject_async(cb, identity);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to remove object '" + strIdentity + "'",
+ e.toString());
+ }
+ finally
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ void removeAdapter(final String adapterId)
+ {
+ final String prefix = "Removing adapter '" + adapterId + "'...";
+ _coordinator.getStatusBar().setText(prefix);
+
+ AMI_Admin_removeAdapter cb = new AMI_Admin_removeAdapter()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'", e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'",
+ e.toString());
+ }
+ };
+
+ try
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ _coordinator.getAdmin().removeAdapter_async(cb, adapterId);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to remove adapter '" + adapterId + "'", e.toString());
+ }
+ finally
+ {
+ _coordinator.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+
+ PropertySetDescriptor findNamedPropertySet(String name, String applicationName)
+ {
+ ApplicationDescriptor descriptor = (ApplicationDescriptor)
+ _descriptorMap.get(applicationName);
+ return (PropertySetDescriptor)descriptor.propertySets.get(name);
+ }
+
+ private Node findNode(String nodeName)
+ {
+ return (Node)find(nodeName, _children);
+ }
+
+ private void insertNode(Node node)
+ {
+ String nodeName = node.toString();
+ int i;
+ for(i = 0; i < _children.size(); ++i)
+ {
+ String otherNodeName = _children.get(i).toString();
+ if(nodeName.compareTo(otherNodeName) > 0)
+ {
+ i++;
+ break;
+ }
+ }
+ _children.add(i, node);
+ _treeModel.nodesWereInserted(this, new int[]{i});
+ }
+
+ private void removeNodes(int[] toRemoveIndices, java.util.List toRemove)
+ {
+ if(toRemove.size() > 0)
+ {
+ _children.removeAll(toRemove);
+ _treeModel.nodesWereRemoved(this, toRemoveIndices, toRemove.toArray());
+ }
+ }
+
+ private final Coordinator _coordinator;
+
+ //
+ // Maps application name to current application descriptor
+ //
+ private final java.util.Map _descriptorMap = new java.util.TreeMap();
+
+ //
+ // Map AdapterId => AdapterInfo
+ //
+ private java.util.SortedMap _adapters = new java.util.TreeMap();
+
+ //
+ // Map stringified identity => ObjectInfo
+ //
+ private java.util.SortedMap _objects = new java.util.TreeMap();
+
+ //
+ // 'this' is the root of the tree
+ //
+ private final JTree _tree;
+ private final DefaultTreeModel _treeModel;
+
+ private String _label;
+
+ private ObjectDialog _objectDialog;
+
+ static private RegistryEditor _editor;
+ static private JPopupMenu _popup;
+ static private DefaultTreeCellRenderer _cellRenderer;
+
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java
index fc0e7cc6f47..cd16ddf4e17 100755
--- a/java/src/IceGridGUI/LiveDeployment/Server.java
+++ b/java/src/IceGridGUI/LiveDeployment/Server.java
@@ -1,734 +1,734 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-import java.awt.Cursor;
-
-import javax.swing.Icon;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Server extends ListArrayTreeNode
-{
- //
- // Actions
- //
- public boolean[] getAvailableActions()
- {
- boolean[] actions = new boolean[ACTION_COUNT];
-
- if(_state != null)
- {
- actions[START] = _state == ServerState.Inactive && _enabled
- && !_resolver.substitute(_serverDescriptor.activation).equals("session");
-
- actions[STOP] = _state != ServerState.Inactive;
- actions[ENABLE] = !_enabled;
- actions[DISABLE] = _enabled;
- actions[PATCH_SERVER] =
- !_serverDescriptor.distrib.icepatch.equals("");
- }
-
- return actions;
- }
-
- public void start()
- {
- final String prefix = "Starting server '" + _id + "'...";
- getCoordinator().getStatusBar().setText(prefix);
-
- AMI_Admin_startServer cb = new AMI_Admin_startServer()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to start " + _id, e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to start " + _id, e.toString());
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- getCoordinator().getAdmin().startServer_async(cb, _id);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to start " + _id, e.toString());
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public void stop()
- {
- final String prefix = "Stopping server '" + _id + "'...";
- getCoordinator().getStatusBar().setText(prefix);
-
- AMI_Admin_stopServer cb = new AMI_Admin_stopServer()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to stop " + _id, e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to stop " + _id, e.toString());
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- getCoordinator().getAdmin().stopServer_async(cb, _id);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to stop " + _id, e.toString());
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public void enable()
- {
- enableServer(true);
- }
-
- public void disable()
- {
- enableServer(false);
- }
-
- public void patchServer()
- {
- int shutdown = JOptionPane.showConfirmDialog(
- getCoordinator().getMainFrame(),
- "You are about to install or refresh your"
- + " server distribution and your application distribution onto this node.\n"
- + " Do you want shut down all servers affected by this update?",
- "Patch Confirmation",
- JOptionPane.YES_NO_CANCEL_OPTION);
-
- if(shutdown == JOptionPane.CANCEL_OPTION)
- {
- return;
- }
-
- final String prefix = "Patching server '" + _id + "'...";
- getCoordinator().getStatusBar().setText(prefix);
-
- AMI_Admin_patchServer cb = new AMI_Admin_patchServer()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to patch " + _id, e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to patch " + _id, e.toString());
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- getCoordinator().getAdmin().
- patchServer_async(cb, _id,
- shutdown == JOptionPane.YES_OPTION);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to patch " + _id, e.toString());
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- private void enableServer(boolean enable)
- {
- final String prefix = (enable ?
- "Enabling" : "Disabling") + " server '" + _id + "'...";
-
- final String action = enable ? "enable" : "disable";
-
- getCoordinator().getStatusBar().setText(prefix);
-
- AMI_Admin_enableServer cb = new AMI_Admin_enableServer()
- {
- //
- // Called by another thread!
- //
- public void ice_response()
- {
- amiSuccess(prefix);
- }
-
- public void ice_exception(Ice.UserException e)
- {
- amiFailure(prefix, "Failed to " + action + " " + _id, e);
- }
-
- public void ice_exception(Ice.LocalException e)
- {
- amiFailure(prefix, "Failed to " + action + " " + _id, e.toString());
- }
- };
-
- try
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- getCoordinator().getAdmin().enableServer_async(cb, _id, enable);
- }
- catch(Ice.LocalException e)
- {
- failure(prefix, "Failed to " + action + " " + _id, e.toString());
- }
- finally
- {
- getCoordinator().getMainFrame().setCursor(
- Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- }
- }
-
- public JPopupMenu getPopupMenu()
- {
- LiveActions la = getCoordinator().getLiveActionsForPopup();
-
- if(_popup == null)
- {
- _popup = new JPopupMenu();
-
- _popup.add(la.get(START));
- _popup.add(la.get(STOP));
- _popup.addSeparator();
- _popup.add(la.get(ENABLE));
- _popup.add(la.get(DISABLE));
- _popup.addSeparator();
- _popup.add(la.get(PATCH_SERVER));
- }
-
- la.setTarget(this);
- return _popup;
- }
-
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new ServerEditor(getCoordinator());
- }
- _editor.show(this);
- return _editor;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- //
- // Initialization
- //
- _cellRenderer = new DefaultTreeCellRenderer();
-
- //
- // Regular servers
- //
- _icons = new Icon[7][2][2];
- _icons[0][0][0] = Utils.getIcon("/icons/16x16/server_unknown.png");
- _icons[ServerState.Inactive.value() + 1][0][0]
- = Utils.getIcon("/icons/16x16/server_inactive.png");
- _icons[ServerState.Activating.value() + 1][0][0] =
- Utils.getIcon("/icons/16x16/server_activating.png");
- _icons[ServerState.Active.value() + 1][0][0] =
- Utils.getIcon("/icons/16x16/server_active.png");
- _icons[ServerState.Deactivating.value() + 1][0][0] =
- Utils.getIcon("/icons/16x16/server_deactivating.png");
- _icons[ServerState.Destroying.value() + 1][0][0] =
- Utils.getIcon("/icons/16x16/server_destroying.png");
- _icons[ServerState.Destroyed.value() + 1][0][0] =
- Utils.getIcon("/icons/16x16/server_destroyed.png");
-
- //
- // IceBox servers
- //
- _icons[0][1][0] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
- _icons[ServerState.Inactive.value() + 1][1][0]
- = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
- _icons[ServerState.Activating.value() + 1][1][0] =
- Utils.getIcon("/icons/16x16/icebox_server_activating.png");
- _icons[ServerState.Active.value() + 1][1][0] =
- Utils.getIcon("/icons/16x16/icebox_server_active.png");
- _icons[ServerState.Deactivating.value() + 1][1][0] =
- Utils.getIcon("/icons/16x16/icebox_server_deactivating.png");
- _icons[ServerState.Destroying.value() + 1][1][0] =
- Utils.getIcon("/icons/16x16/icebox_server_destroying.png");
- _icons[ServerState.Destroyed.value() + 1][1][0] =
- Utils.getIcon("/icons/16x16/icebox_server_destroyed.png");
-
- //
- // Regular servers (disabled)
- //
- _icons[0][0][1] = Utils.getIcon("/icons/16x16/server_unknown.png");
- _icons[ServerState.Inactive.value() + 1][0][1]
- = Utils.getIcon("/icons/16x16/server_disabled_inactive.png");
- _icons[ServerState.Activating.value() + 1][0][1] =
- Utils.getIcon("/icons/16x16/server_disabled_activating.png");
- _icons[ServerState.Active.value() + 1][0][1] =
- Utils.getIcon("/icons/16x16/server_disabled_active.png");
- _icons[ServerState.Deactivating.value() + 1][0][1] =
- Utils.getIcon("/icons/16x16/server_disabled_deactivating.png");
- _icons[ServerState.Destroying.value() + 1][0][1] =
- Utils.getIcon("/icons/16x16/server_disabled_destroying.png");
- _icons[ServerState.Destroyed.value() + 1][0][1] =
- Utils.getIcon("/icons/16x16/server_disabled_destroyed.png");
-
- //
- // IceBox servers (disabled)
- //
- _icons[0][1][1] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
- _icons[ServerState.Inactive.value() + 1][1][1]
- = Utils.getIcon("/icons/16x16/icebox_server_disabled_inactive.png");
- _icons[ServerState.Activating.value() + 1][1][1] =
- Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
- _icons[ServerState.Active.value() + 1][1][1] =
- Utils.getIcon("/icons/16x16/icebox_server_disabled_active.png");
- _icons[ServerState.Deactivating.value() + 1][1][1] =
- Utils.getIcon("/icons/16x16/icebox_server_disabled_deactivating.png");
- _icons[ServerState.Destroying.value() + 1][1][1] =
- Utils.getIcon("/icons/16x16/icebox_server_disabled_destroying.png");
- _icons[ServerState.Destroyed.value() + 1][1][1] =
- Utils.getIcon("/icons/16x16/icebox_server_disabled_destroyed.png");
-
- }
-
- int icebox = _serverDescriptor instanceof IceBoxDescriptor ? 1 : 0;
- int disabled = _enabled ? 0 : 1;
-
- if(expanded)
- {
- _cellRenderer.setOpenIcon(_icons[_stateIconIndex][icebox][disabled]);
- }
- else
- {
- _cellRenderer.setClosedIcon(_icons[_stateIconIndex][icebox][disabled]);
- }
-
- _cellRenderer.setToolTipText(_toolTip);
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
-
- Server(Node parent, String serverId, Utils.Resolver resolver,
- ServerInstanceDescriptor instanceDescriptor,
- ServerDescriptor serverDescriptor, ApplicationDescriptor application,
- ServerState state, int pid, boolean enabled)
- {
- super(parent, serverId, 3);
- _resolver = resolver;
-
- _instanceDescriptor = instanceDescriptor;
- _serverDescriptor = serverDescriptor;
- _application = application;
-
- _childrenArray[0] = _adapters;
- _childrenArray[1] = _dbEnvs;
- _childrenArray[2] = _services;
-
- update(state, pid, enabled, false);
-
- createAdapters();
- createDbEnvs();
- createServices();
- }
-
- ApplicationDescriptor getApplication()
- {
- return _application;
- }
-
- ServerInstanceDescriptor getInstanceDescriptor()
- {
- return _instanceDescriptor;
- }
-
- ServerDescriptor getServerDescriptor()
- {
- return _serverDescriptor;
- }
-
- ServerState getState()
- {
- return _state;
- }
-
- int getPid()
- {
- return _pid;
- }
-
- boolean isEnabled()
- {
- return _enabled;
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- void rebuild(Server server)
- {
- _resolver = server._resolver;
- _instanceDescriptor = server._instanceDescriptor;
- _serverDescriptor = server._serverDescriptor;
- _application = server._application;
- _adapters = server._adapters;
- _dbEnvs = server._dbEnvs;
-
- _services = server._services;
-
- _childrenArray[0] = _adapters;
- _childrenArray[1] = _dbEnvs;
- _childrenArray[2] = _services;
-
- getRoot().getTreeModel().nodeStructureChanged(this);
- }
-
- void rebuild(Utils.Resolver resolver, boolean variablesChanged, java.util.Set serviceTemplates,
- java.util.Set serverTemplates)
- {
- if(variablesChanged ||
- (_instanceDescriptor != null && serverTemplates.contains(_instanceDescriptor.template)))
- {
- if(_instanceDescriptor != null)
- {
- TemplateDescriptor templateDescriptor =
- (TemplateDescriptor)_application.serverTemplates.get(_instanceDescriptor.template);
- assert templateDescriptor != null;
-
- _resolver.reset(resolver, _instanceDescriptor.parameterValues,
- templateDescriptor.parameterDefaults);
- _resolver.put("server", _id);
- _serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
- }
-
- _adapters.clear();
- createAdapters();
- _dbEnvs.clear();
- createDbEnvs();
- _services.clear();
- createServices();
-
- getRoot().getTreeModel().nodeStructureChanged(this);
- }
- else if(serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor)
- {
- _services.clear();
- createServices();
- getRoot().getTreeModel().nodeStructureChanged(this);
- }
- }
-
- void update(ServerState state, int pid, boolean enabled, boolean fireEvent)
- {
- if(state != _state || pid != _pid || enabled != _enabled)
- {
- _state = state;
- _pid = pid;
- _enabled = enabled;
-
- _toolTip = toolTip(_state, _pid, _enabled);
- if(_state == null)
- {
- _stateIconIndex = 0;
- }
- else
- {
- _stateIconIndex = _state.value() + 1;
- }
-
- if(fireEvent)
- {
- getRoot().getTreeModel().nodeChanged(this);
- }
- }
- }
-
- boolean updateAdapter(AdapterDynamicInfo info)
- {
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext())
- {
- Adapter adapter = (Adapter)p.next();
- if(adapter.update(info))
- {
- return true;
- }
- }
-
- //
- // Could be in one of the services as well
- //
- p = _services.iterator();
- while(p.hasNext())
- {
- Service service = (Service)p.next();
- if(service.updateAdapter(info))
- {
- return true;
- }
- }
- return false;
- }
-
- int updateAdapters(java.util.List infoList)
- {
- int result = 0;
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext() && result < infoList.size())
- {
- Adapter adapter = (Adapter)p.next();
- if(adapter.update(infoList))
- {
- result++;
- }
- }
-
- //
- // Could be in one of the services as well
- //
- p = _services.iterator();
- while(p.hasNext() && result < infoList.size())
- {
- Service service = (Service)p.next();
- result += service.updateAdapters(infoList);
- }
- return result;
- }
-
- void nodeDown()
- {
- update(null, 0, true, true);
-
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext())
- {
- Adapter adapter = (Adapter)p.next();
- adapter.update((AdapterDynamicInfo)null);
- }
-
- p = _services.iterator();
- while(p.hasNext())
- {
- Service service = (Service)p.next();
- service.nodeDown();
- }
- }
-
- java.util.SortedMap getProperties()
- {
- Utils.ExpandedPropertySet instancePropertySet = null;
- Node node = (Node)_parent;
-
- if(_instanceDescriptor != null)
- {
- instancePropertySet = node.expand(_instanceDescriptor.propertySet,
- _application.name, _resolver);
- }
-
- Utils.ExpandedPropertySet propertySet =
- node.expand(_serverDescriptor.propertySet,
- _application.name, _resolver);
-
- return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver);
- }
-
- private void createAdapters()
- {
- java.util.Iterator p = _serverDescriptor.adapters.iterator();
- while(p.hasNext())
- {
- AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
- String adapterName = Utils.substitute(descriptor.name, _resolver);
- String adapterId = Utils.substitute(descriptor.id, _resolver);
- Ice.ObjectPrx proxy = null;
- if(adapterId.length() > 0)
- {
- proxy = ((Node)_parent).getProxy(adapterId);
- }
-
- insertSortedChild(new Adapter(this, adapterName,
- _resolver, adapterId, descriptor, proxy),
- _adapters, null);
- }
- }
-
- private void createDbEnvs()
- {
- java.util.Iterator p = _serverDescriptor.dbEnvs.iterator();
- while(p.hasNext())
- {
- DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
- String dbEnvName = Utils.substitute(descriptor.name, _resolver);
-
- insertSortedChild(new DbEnv(this, dbEnvName, _resolver, descriptor),
- _dbEnvs, null);
- }
- }
-
- private void createServices()
- {
- if(_serverDescriptor instanceof IceBoxDescriptor)
- {
- IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor;
-
- java.util.Iterator p = iceBoxDescriptor.services.iterator();
- while(p.hasNext())
- {
- ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)p.next();
- createService(descriptor);
- }
- }
- }
-
- private void createService(ServiceInstanceDescriptor descriptor)
- {
- ServiceDescriptor serviceDescriptor = null;
- String serviceName = null;
- Utils.Resolver serviceResolver = null;
-
- if(descriptor.template.length() > 0)
- {
- TemplateDescriptor templateDescriptor
- = (TemplateDescriptor)_application.serviceTemplates.get(descriptor.template);
-
- assert templateDescriptor != null;
-
- serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
- assert serviceDescriptor != null;
-
- serviceResolver = new Utils.Resolver(_resolver,
- descriptor.parameterValues,
- templateDescriptor.parameterDefaults);
- serviceName = serviceResolver.substitute(serviceDescriptor.name);
- serviceResolver.put("service", serviceName);
- }
- else
- {
- serviceDescriptor = descriptor.descriptor;
- assert serviceDescriptor != null;
-
- serviceResolver = new Utils.Resolver(_resolver);
- serviceName = _resolver.substitute(serviceDescriptor.name);
- serviceResolver.put("service", serviceName);
- }
-
- _services.add(new Service(this, serviceName, serviceResolver,
- descriptor, serviceDescriptor));
- }
-
- static private String toolTip(ServerState state, int pid, boolean enabled)
- {
- String result = (state == null ? "Unknown" : state.toString());
-
- if(!enabled)
- {
- result += ", disabled";
- }
-
- if(pid != 0)
- {
- result += ", pid: " + pid;
- }
- return result;
- }
-
-
- private ServerInstanceDescriptor _instanceDescriptor;
- private ServerDescriptor _serverDescriptor;
- private ApplicationDescriptor _application;
-
- private Utils.Resolver _resolver;
- private java.util.List _adapters = new java.util.LinkedList();
- private java.util.List _dbEnvs = new java.util.LinkedList();
- private java.util.List _services = new java.util.LinkedList();
-
- private ServerState _state;
- private boolean _enabled;
- private int _stateIconIndex;
- private int _pid;
- private String _toolTip;
-
- static private DefaultTreeCellRenderer _cellRenderer;
- static private Icon[][][] _icons;
-
- static private ServerEditor _editor;
- static private JPopupMenu _popup;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+import java.awt.Cursor;
+
+import javax.swing.Icon;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Server extends ListArrayTreeNode
+{
+ //
+ // Actions
+ //
+ public boolean[] getAvailableActions()
+ {
+ boolean[] actions = new boolean[ACTION_COUNT];
+
+ if(_state != null)
+ {
+ actions[START] = _state == ServerState.Inactive && _enabled
+ && !_resolver.substitute(_serverDescriptor.activation).equals("session");
+
+ actions[STOP] = _state != ServerState.Inactive;
+ actions[ENABLE] = !_enabled;
+ actions[DISABLE] = _enabled;
+ actions[PATCH_SERVER] =
+ !_serverDescriptor.distrib.icepatch.equals("");
+ }
+
+ return actions;
+ }
+
+ public void start()
+ {
+ final String prefix = "Starting server '" + _id + "'...";
+ getCoordinator().getStatusBar().setText(prefix);
+
+ AMI_Admin_startServer cb = new AMI_Admin_startServer()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to start " + _id, e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to start " + _id, e.toString());
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ getCoordinator().getAdmin().startServer_async(cb, _id);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to start " + _id, e.toString());
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ public void stop()
+ {
+ final String prefix = "Stopping server '" + _id + "'...";
+ getCoordinator().getStatusBar().setText(prefix);
+
+ AMI_Admin_stopServer cb = new AMI_Admin_stopServer()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to stop " + _id, e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to stop " + _id, e.toString());
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ getCoordinator().getAdmin().stopServer_async(cb, _id);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to stop " + _id, e.toString());
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ public void enable()
+ {
+ enableServer(true);
+ }
+
+ public void disable()
+ {
+ enableServer(false);
+ }
+
+ public void patchServer()
+ {
+ int shutdown = JOptionPane.showConfirmDialog(
+ getCoordinator().getMainFrame(),
+ "You are about to install or refresh your"
+ + " server distribution and your application distribution onto this node.\n"
+ + " Do you want shut down all servers affected by this update?",
+ "Patch Confirmation",
+ JOptionPane.YES_NO_CANCEL_OPTION);
+
+ if(shutdown == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
+
+ final String prefix = "Patching server '" + _id + "'...";
+ getCoordinator().getStatusBar().setText(prefix);
+
+ AMI_Admin_patchServer cb = new AMI_Admin_patchServer()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to patch " + _id, e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to patch " + _id, e.toString());
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ getCoordinator().getAdmin().
+ patchServer_async(cb, _id,
+ shutdown == JOptionPane.YES_OPTION);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to patch " + _id, e.toString());
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ private void enableServer(boolean enable)
+ {
+ final String prefix = (enable ?
+ "Enabling" : "Disabling") + " server '" + _id + "'...";
+
+ final String action = enable ? "enable" : "disable";
+
+ getCoordinator().getStatusBar().setText(prefix);
+
+ AMI_Admin_enableServer cb = new AMI_Admin_enableServer()
+ {
+ //
+ // Called by another thread!
+ //
+ public void ice_response()
+ {
+ amiSuccess(prefix);
+ }
+
+ public void ice_exception(Ice.UserException e)
+ {
+ amiFailure(prefix, "Failed to " + action + " " + _id, e);
+ }
+
+ public void ice_exception(Ice.LocalException e)
+ {
+ amiFailure(prefix, "Failed to " + action + " " + _id, e.toString());
+ }
+ };
+
+ try
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ getCoordinator().getAdmin().enableServer_async(cb, _id, enable);
+ }
+ catch(Ice.LocalException e)
+ {
+ failure(prefix, "Failed to " + action + " " + _id, e.toString());
+ }
+ finally
+ {
+ getCoordinator().getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ LiveActions la = getCoordinator().getLiveActionsForPopup();
+
+ if(_popup == null)
+ {
+ _popup = new JPopupMenu();
+
+ _popup.add(la.get(START));
+ _popup.add(la.get(STOP));
+ _popup.addSeparator();
+ _popup.add(la.get(ENABLE));
+ _popup.add(la.get(DISABLE));
+ _popup.addSeparator();
+ _popup.add(la.get(PATCH_SERVER));
+ }
+
+ la.setTarget(this);
+ return _popup;
+ }
+
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new ServerEditor(getCoordinator());
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ //
+ // Initialization
+ //
+ _cellRenderer = new DefaultTreeCellRenderer();
+
+ //
+ // Regular servers
+ //
+ _icons = new Icon[7][2][2];
+ _icons[0][0][0] = Utils.getIcon("/icons/16x16/server_unknown.png");
+ _icons[ServerState.Inactive.value() + 1][0][0]
+ = Utils.getIcon("/icons/16x16/server_inactive.png");
+ _icons[ServerState.Activating.value() + 1][0][0] =
+ Utils.getIcon("/icons/16x16/server_activating.png");
+ _icons[ServerState.Active.value() + 1][0][0] =
+ Utils.getIcon("/icons/16x16/server_active.png");
+ _icons[ServerState.Deactivating.value() + 1][0][0] =
+ Utils.getIcon("/icons/16x16/server_deactivating.png");
+ _icons[ServerState.Destroying.value() + 1][0][0] =
+ Utils.getIcon("/icons/16x16/server_destroying.png");
+ _icons[ServerState.Destroyed.value() + 1][0][0] =
+ Utils.getIcon("/icons/16x16/server_destroyed.png");
+
+ //
+ // IceBox servers
+ //
+ _icons[0][1][0] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
+ _icons[ServerState.Inactive.value() + 1][1][0]
+ = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
+ _icons[ServerState.Activating.value() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_activating.png");
+ _icons[ServerState.Active.value() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_active.png");
+ _icons[ServerState.Deactivating.value() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_deactivating.png");
+ _icons[ServerState.Destroying.value() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_destroying.png");
+ _icons[ServerState.Destroyed.value() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_destroyed.png");
+
+ //
+ // Regular servers (disabled)
+ //
+ _icons[0][0][1] = Utils.getIcon("/icons/16x16/server_unknown.png");
+ _icons[ServerState.Inactive.value() + 1][0][1]
+ = Utils.getIcon("/icons/16x16/server_disabled_inactive.png");
+ _icons[ServerState.Activating.value() + 1][0][1] =
+ Utils.getIcon("/icons/16x16/server_disabled_activating.png");
+ _icons[ServerState.Active.value() + 1][0][1] =
+ Utils.getIcon("/icons/16x16/server_disabled_active.png");
+ _icons[ServerState.Deactivating.value() + 1][0][1] =
+ Utils.getIcon("/icons/16x16/server_disabled_deactivating.png");
+ _icons[ServerState.Destroying.value() + 1][0][1] =
+ Utils.getIcon("/icons/16x16/server_disabled_destroying.png");
+ _icons[ServerState.Destroyed.value() + 1][0][1] =
+ Utils.getIcon("/icons/16x16/server_disabled_destroyed.png");
+
+ //
+ // IceBox servers (disabled)
+ //
+ _icons[0][1][1] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
+ _icons[ServerState.Inactive.value() + 1][1][1]
+ = Utils.getIcon("/icons/16x16/icebox_server_disabled_inactive.png");
+ _icons[ServerState.Activating.value() + 1][1][1] =
+ Utils.getIcon("/icons/16x16/icebox_server_disabled_activating.png");
+ _icons[ServerState.Active.value() + 1][1][1] =
+ Utils.getIcon("/icons/16x16/icebox_server_disabled_active.png");
+ _icons[ServerState.Deactivating.value() + 1][1][1] =
+ Utils.getIcon("/icons/16x16/icebox_server_disabled_deactivating.png");
+ _icons[ServerState.Destroying.value() + 1][1][1] =
+ Utils.getIcon("/icons/16x16/icebox_server_disabled_destroying.png");
+ _icons[ServerState.Destroyed.value() + 1][1][1] =
+ Utils.getIcon("/icons/16x16/icebox_server_disabled_destroyed.png");
+
+ }
+
+ int icebox = _serverDescriptor instanceof IceBoxDescriptor ? 1 : 0;
+ int disabled = _enabled ? 0 : 1;
+
+ if(expanded)
+ {
+ _cellRenderer.setOpenIcon(_icons[_stateIconIndex][icebox][disabled]);
+ }
+ else
+ {
+ _cellRenderer.setClosedIcon(_icons[_stateIconIndex][icebox][disabled]);
+ }
+
+ _cellRenderer.setToolTipText(_toolTip);
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+
+ Server(Node parent, String serverId, Utils.Resolver resolver,
+ ServerInstanceDescriptor instanceDescriptor,
+ ServerDescriptor serverDescriptor, ApplicationDescriptor application,
+ ServerState state, int pid, boolean enabled)
+ {
+ super(parent, serverId, 3);
+ _resolver = resolver;
+
+ _instanceDescriptor = instanceDescriptor;
+ _serverDescriptor = serverDescriptor;
+ _application = application;
+
+ _childrenArray[0] = _adapters;
+ _childrenArray[1] = _dbEnvs;
+ _childrenArray[2] = _services;
+
+ update(state, pid, enabled, false);
+
+ createAdapters();
+ createDbEnvs();
+ createServices();
+ }
+
+ ApplicationDescriptor getApplication()
+ {
+ return _application;
+ }
+
+ ServerInstanceDescriptor getInstanceDescriptor()
+ {
+ return _instanceDescriptor;
+ }
+
+ ServerDescriptor getServerDescriptor()
+ {
+ return _serverDescriptor;
+ }
+
+ ServerState getState()
+ {
+ return _state;
+ }
+
+ int getPid()
+ {
+ return _pid;
+ }
+
+ boolean isEnabled()
+ {
+ return _enabled;
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ void rebuild(Server server)
+ {
+ _resolver = server._resolver;
+ _instanceDescriptor = server._instanceDescriptor;
+ _serverDescriptor = server._serverDescriptor;
+ _application = server._application;
+ _adapters = server._adapters;
+ _dbEnvs = server._dbEnvs;
+
+ _services = server._services;
+
+ _childrenArray[0] = _adapters;
+ _childrenArray[1] = _dbEnvs;
+ _childrenArray[2] = _services;
+
+ getRoot().getTreeModel().nodeStructureChanged(this);
+ }
+
+ void rebuild(Utils.Resolver resolver, boolean variablesChanged, java.util.Set serviceTemplates,
+ java.util.Set serverTemplates)
+ {
+ if(variablesChanged ||
+ (_instanceDescriptor != null && serverTemplates.contains(_instanceDescriptor.template)))
+ {
+ if(_instanceDescriptor != null)
+ {
+ TemplateDescriptor templateDescriptor =
+ (TemplateDescriptor)_application.serverTemplates.get(_instanceDescriptor.template);
+ assert templateDescriptor != null;
+
+ _resolver.reset(resolver, _instanceDescriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+ _resolver.put("server", _id);
+ _serverDescriptor = (ServerDescriptor)templateDescriptor.descriptor;
+ }
+
+ _adapters.clear();
+ createAdapters();
+ _dbEnvs.clear();
+ createDbEnvs();
+ _services.clear();
+ createServices();
+
+ getRoot().getTreeModel().nodeStructureChanged(this);
+ }
+ else if(serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor)
+ {
+ _services.clear();
+ createServices();
+ getRoot().getTreeModel().nodeStructureChanged(this);
+ }
+ }
+
+ void update(ServerState state, int pid, boolean enabled, boolean fireEvent)
+ {
+ if(state != _state || pid != _pid || enabled != _enabled)
+ {
+ _state = state;
+ _pid = pid;
+ _enabled = enabled;
+
+ _toolTip = toolTip(_state, _pid, _enabled);
+ if(_state == null)
+ {
+ _stateIconIndex = 0;
+ }
+ else
+ {
+ _stateIconIndex = _state.value() + 1;
+ }
+
+ if(fireEvent)
+ {
+ getRoot().getTreeModel().nodeChanged(this);
+ }
+ }
+ }
+
+ boolean updateAdapter(AdapterDynamicInfo info)
+ {
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext())
+ {
+ Adapter adapter = (Adapter)p.next();
+ if(adapter.update(info))
+ {
+ return true;
+ }
+ }
+
+ //
+ // Could be in one of the services as well
+ //
+ p = _services.iterator();
+ while(p.hasNext())
+ {
+ Service service = (Service)p.next();
+ if(service.updateAdapter(info))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ int updateAdapters(java.util.List infoList)
+ {
+ int result = 0;
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext() && result < infoList.size())
+ {
+ Adapter adapter = (Adapter)p.next();
+ if(adapter.update(infoList))
+ {
+ result++;
+ }
+ }
+
+ //
+ // Could be in one of the services as well
+ //
+ p = _services.iterator();
+ while(p.hasNext() && result < infoList.size())
+ {
+ Service service = (Service)p.next();
+ result += service.updateAdapters(infoList);
+ }
+ return result;
+ }
+
+ void nodeDown()
+ {
+ update(null, 0, true, true);
+
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext())
+ {
+ Adapter adapter = (Adapter)p.next();
+ adapter.update((AdapterDynamicInfo)null);
+ }
+
+ p = _services.iterator();
+ while(p.hasNext())
+ {
+ Service service = (Service)p.next();
+ service.nodeDown();
+ }
+ }
+
+ java.util.SortedMap getProperties()
+ {
+ Utils.ExpandedPropertySet instancePropertySet = null;
+ Node node = (Node)_parent;
+
+ if(_instanceDescriptor != null)
+ {
+ instancePropertySet = node.expand(_instanceDescriptor.propertySet,
+ _application.name, _resolver);
+ }
+
+ Utils.ExpandedPropertySet propertySet =
+ node.expand(_serverDescriptor.propertySet,
+ _application.name, _resolver);
+
+ return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver);
+ }
+
+ private void createAdapters()
+ {
+ java.util.Iterator p = _serverDescriptor.adapters.iterator();
+ while(p.hasNext())
+ {
+ AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
+ String adapterName = Utils.substitute(descriptor.name, _resolver);
+ String adapterId = Utils.substitute(descriptor.id, _resolver);
+ Ice.ObjectPrx proxy = null;
+ if(adapterId.length() > 0)
+ {
+ proxy = ((Node)_parent).getProxy(adapterId);
+ }
+
+ insertSortedChild(new Adapter(this, adapterName,
+ _resolver, adapterId, descriptor, proxy),
+ _adapters, null);
+ }
+ }
+
+ private void createDbEnvs()
+ {
+ java.util.Iterator p = _serverDescriptor.dbEnvs.iterator();
+ while(p.hasNext())
+ {
+ DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
+ String dbEnvName = Utils.substitute(descriptor.name, _resolver);
+
+ insertSortedChild(new DbEnv(this, dbEnvName, _resolver, descriptor),
+ _dbEnvs, null);
+ }
+ }
+
+ private void createServices()
+ {
+ if(_serverDescriptor instanceof IceBoxDescriptor)
+ {
+ IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor;
+
+ java.util.Iterator p = iceBoxDescriptor.services.iterator();
+ while(p.hasNext())
+ {
+ ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)p.next();
+ createService(descriptor);
+ }
+ }
+ }
+
+ private void createService(ServiceInstanceDescriptor descriptor)
+ {
+ ServiceDescriptor serviceDescriptor = null;
+ String serviceName = null;
+ Utils.Resolver serviceResolver = null;
+
+ if(descriptor.template.length() > 0)
+ {
+ TemplateDescriptor templateDescriptor
+ = (TemplateDescriptor)_application.serviceTemplates.get(descriptor.template);
+
+ assert templateDescriptor != null;
+
+ serviceDescriptor = (ServiceDescriptor)templateDescriptor.descriptor;
+ assert serviceDescriptor != null;
+
+ serviceResolver = new Utils.Resolver(_resolver,
+ descriptor.parameterValues,
+ templateDescriptor.parameterDefaults);
+ serviceName = serviceResolver.substitute(serviceDescriptor.name);
+ serviceResolver.put("service", serviceName);
+ }
+ else
+ {
+ serviceDescriptor = descriptor.descriptor;
+ assert serviceDescriptor != null;
+
+ serviceResolver = new Utils.Resolver(_resolver);
+ serviceName = _resolver.substitute(serviceDescriptor.name);
+ serviceResolver.put("service", serviceName);
+ }
+
+ _services.add(new Service(this, serviceName, serviceResolver,
+ descriptor, serviceDescriptor));
+ }
+
+ static private String toolTip(ServerState state, int pid, boolean enabled)
+ {
+ String result = (state == null ? "Unknown" : state.toString());
+
+ if(!enabled)
+ {
+ result += ", disabled";
+ }
+
+ if(pid != 0)
+ {
+ result += ", pid: " + pid;
+ }
+ return result;
+ }
+
+
+ private ServerInstanceDescriptor _instanceDescriptor;
+ private ServerDescriptor _serverDescriptor;
+ private ApplicationDescriptor _application;
+
+ private Utils.Resolver _resolver;
+ private java.util.List _adapters = new java.util.LinkedList();
+ private java.util.List _dbEnvs = new java.util.LinkedList();
+ private java.util.List _services = new java.util.LinkedList();
+
+ private ServerState _state;
+ private boolean _enabled;
+ private int _stateIconIndex;
+ private int _pid;
+ private String _toolTip;
+
+ static private DefaultTreeCellRenderer _cellRenderer;
+ static private Icon[][][] _icons;
+
+ static private ServerEditor _editor;
+ static private JPopupMenu _popup;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java
index 80f2c2ac878..2cf9b9f5729 100755
--- a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java
@@ -1,299 +1,299 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComponent;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-
-import com.jgoodies.looks.Options;
-import com.jgoodies.looks.HeaderStyle;
-import com.jgoodies.looks.BorderStyle;
-import com.jgoodies.looks.plastic.PlasticLookAndFeel;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServerEditor extends CommunicatorEditor
-{
- public JToolBar getToolBar()
- {
- if(_toolBar == null)
- {
- _toolBar = new ToolBar();
- }
- return _toolBar;
- }
-
-
- ServerEditor(Coordinator c)
- {
- _coordinator = c;
- _currentState.setEditable(false);
- _currentPid.setEditable(false);
- _enabled.setEnabled(false);
-
- _application.setEditable(false);
- _exe.setEditable(false);
- _pwd.setEditable(false);
-
- _activation.setEditable(false);
- _activationTimeout.setEditable(false);
- _deactivationTimeout.setEditable(false);
-
- _options.setEditable(false);
- _user.setEditable(false);
-
- _allocatable.setEnabled(false);
- _applicationDistrib.setEnabled(false);
- _icepatch.setEditable(false);
- _directories.setEditable(false);
-
- Action gotoApplication = new AbstractAction(
- "", Utils.getIcon("/icons/16x16/goto.png"))
- {
- public void actionPerformed(ActionEvent e)
- {
- _coordinator.openLiveApplication(_application.getText()).getRoot().
- selectServer(((Node)_target.getParent()).getId(), _target.getId());
- }
- };
- gotoApplication.putValue(Action.SHORT_DESCRIPTION,
- "View/Edit this application");
- _gotoApplication = new JButton(gotoApplication);
- }
-
-
- void show(Server server)
- {
- _target = server;
-
- ServerState state = server.getState();
- if(state == null)
- {
- _currentState.setText("Unknown");
- _currentPid.setText("");
- _enabled.setSelected(false);
- }
- else
- {
- _currentState.setText(state.toString());
- int pid = server.getPid();
- if(pid == 0)
- {
- _currentPid.setText("");
- }
- else
- {
- _currentPid.setText(Integer.toString(pid));
- }
- _enabled.setSelected(server.isEnabled());
- }
-
- ServerDescriptor descriptor = server.getServerDescriptor();
- final Utils.Resolver resolver = server.getResolver();
-
- _application.setText(resolver.find("application"));
-
- super.show(descriptor, server.getProperties(), resolver);
-
- _exe.setText(resolver.substitute(descriptor.exe));
- _pwd.setText(resolver.substitute(descriptor.pwd));
-
- Ice.StringHolder toolTipHolder = new Ice.StringHolder();
- Utils.Stringifier stringifier = new Utils.Stringifier()
- {
- public String toString(Object obj)
- {
- return resolver.substitute((String)obj);
- }
- };
-
- _options.setText(
- Utils.stringify(descriptor.options, stringifier, " ", toolTipHolder));
- _options.setToolTipText(toolTipHolder.value);
-
- _envs.setEnvs(descriptor.envs, resolver);
-
- _user.setText(resolver.substitute(descriptor.user));
-
- _activation.setText(resolver.substitute(descriptor.activation));
- _activationTimeout.setText(resolver.substitute(descriptor.activationTimeout));
- _deactivationTimeout.setText(resolver.substitute(descriptor.deactivationTimeout));
-
- _allocatable.setSelected(descriptor.allocatable);
-
- _applicationDistrib.setSelected(descriptor.applicationDistrib);
- _icepatch.setText(resolver.substitute(resolver.substitute(descriptor.distrib.icepatch)));
-
- toolTipHolder = new Ice.StringHolder();
-
- _directories.setText(
- Utils.stringify(descriptor.distrib.directories, stringifier, ", ",
- toolTipHolder));
-
- String toolTip = "<html>Include only these directories";
-
- if(toolTipHolder.value != null)
- {
- toolTip += ":<br>" + toolTipHolder.value;
- }
- toolTip += "</html>";
- _directories.setToolTipText(toolTip);
- }
-
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- builder.appendSeparator("Runtime Status");
-
- builder.append("State");
- builder.append(_currentState, 3);
- builder.nextLine();
-
- builder.append("Process ID");
- builder.append(_currentPid, 3);
- builder.nextLine();
-
- builder.append("", _enabled);
- builder.nextLine();
-
- builder.appendSeparator("Configuration");
-
- builder.append("Application");
- builder.append(_application);
- builder.append(_gotoApplication);
- builder.nextLine();
-
- //
- // Add Communicator fields
- //
- super.appendProperties(builder);
-
- builder.appendSeparator("Activation");
- builder.append("Path to Executable");
- builder.append(_exe, 3);
- builder.nextLine();
- builder.append("Working Directory");
- builder.append(_pwd, 3);
- builder.nextLine();
- builder.append("Command Arguments");
- builder.append(_options, 3);
- builder.nextLine();
- builder.append("Run as");
- builder.append(_user, 3);
- builder.nextLine();
- builder.append("Environment Variables");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextLine();
- builder.append("");
- builder.nextRow(-6);
- CellConstraints cc = new CellConstraints();
- JScrollPane scrollPane = new JScrollPane(_envs);
- builder.add(scrollPane,
- cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
- builder.nextRow(6);
- builder.nextLine();
-
- builder.append("Activation Mode");
- builder.append(_activation, 3);
- builder.nextLine();
- builder.append("Activation Timeout");
- builder.append(_activationTimeout, 3);
- builder.nextLine();
- builder.append("Deactivation Timeout");
- builder.append(_deactivationTimeout, 3);
- builder.nextLine();
- builder.append("", _allocatable);
- builder.nextLine();
-
- JComponent c = builder.appendSeparator("Distribution");
- c.setToolTipText("Files specific to this server");
-
- builder.append("", _applicationDistrib);
- builder.nextLine();
- builder.append("IcePatch2 Proxy");
- builder.append(_icepatch, 3);
- builder.nextLine();
- builder.append("Directories");
- builder.append(_directories, 3);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Server Properties");
- }
-
-
- private class ToolBar extends JToolBar
- {
- private ToolBar()
- {
- putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
- putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
- setFloatable(false);
- putClientProperty("JToolBar.isRollover", Boolean.TRUE);
-
- LiveActions la = _coordinator.getLiveActionsForMenu();
-
- add(la.get(TreeNode.START));
- add(la.get(TreeNode.STOP));
- addSeparator();
- add(la.get(TreeNode.ENABLE));
- add(la.get(TreeNode.DISABLE));
- }
- }
-
-
- private Coordinator _coordinator;
- private Server _target;
-
- private JTextField _currentState = new JTextField(20);
- private JTextField _currentPid = new JTextField(20);
- private JCheckBox _enabled = new JCheckBox("Enabled");
-
- private JTextField _application = new JTextField(20);
- private JButton _gotoApplication;
-
- private JTextField _exe = new JTextField(20);
- private JTextField _pwd = new JTextField(20);
- private JTextField _user = new JTextField(20);
-
- private JTextField _activation = new JTextField(20);
- private JTextField _activationTimeout = new JTextField(20);
- private JTextField _deactivationTimeout = new JTextField(20);
- private JCheckBox _allocatable = new JCheckBox("Allocatable");
-
-
- private TableField _envs = new TableField("Name", "Value");
-
- private JTextField _options = new JTextField(20);
- private JCheckBox _applicationDistrib = new JCheckBox("Depends on the application distribution");
-
- private JTextField _icepatch = new JTextField(20);
- private JTextField _directories = new JTextField(20);
-
- private JToolBar _toolBar;
-}
-
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.JToolBar;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+
+import com.jgoodies.looks.Options;
+import com.jgoodies.looks.HeaderStyle;
+import com.jgoodies.looks.BorderStyle;
+import com.jgoodies.looks.plastic.PlasticLookAndFeel;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServerEditor extends CommunicatorEditor
+{
+ public JToolBar getToolBar()
+ {
+ if(_toolBar == null)
+ {
+ _toolBar = new ToolBar();
+ }
+ return _toolBar;
+ }
+
+
+ ServerEditor(Coordinator c)
+ {
+ _coordinator = c;
+ _currentState.setEditable(false);
+ _currentPid.setEditable(false);
+ _enabled.setEnabled(false);
+
+ _application.setEditable(false);
+ _exe.setEditable(false);
+ _pwd.setEditable(false);
+
+ _activation.setEditable(false);
+ _activationTimeout.setEditable(false);
+ _deactivationTimeout.setEditable(false);
+
+ _options.setEditable(false);
+ _user.setEditable(false);
+
+ _allocatable.setEnabled(false);
+ _applicationDistrib.setEnabled(false);
+ _icepatch.setEditable(false);
+ _directories.setEditable(false);
+
+ Action gotoApplication = new AbstractAction(
+ "", Utils.getIcon("/icons/16x16/goto.png"))
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ _coordinator.openLiveApplication(_application.getText()).getRoot().
+ selectServer(((Node)_target.getParent()).getId(), _target.getId());
+ }
+ };
+ gotoApplication.putValue(Action.SHORT_DESCRIPTION,
+ "View/Edit this application");
+ _gotoApplication = new JButton(gotoApplication);
+ }
+
+
+ void show(Server server)
+ {
+ _target = server;
+
+ ServerState state = server.getState();
+ if(state == null)
+ {
+ _currentState.setText("Unknown");
+ _currentPid.setText("");
+ _enabled.setSelected(false);
+ }
+ else
+ {
+ _currentState.setText(state.toString());
+ int pid = server.getPid();
+ if(pid == 0)
+ {
+ _currentPid.setText("");
+ }
+ else
+ {
+ _currentPid.setText(Integer.toString(pid));
+ }
+ _enabled.setSelected(server.isEnabled());
+ }
+
+ ServerDescriptor descriptor = server.getServerDescriptor();
+ final Utils.Resolver resolver = server.getResolver();
+
+ _application.setText(resolver.find("application"));
+
+ super.show(descriptor, server.getProperties(), resolver);
+
+ _exe.setText(resolver.substitute(descriptor.exe));
+ _pwd.setText(resolver.substitute(descriptor.pwd));
+
+ Ice.StringHolder toolTipHolder = new Ice.StringHolder();
+ Utils.Stringifier stringifier = new Utils.Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ return resolver.substitute((String)obj);
+ }
+ };
+
+ _options.setText(
+ Utils.stringify(descriptor.options, stringifier, " ", toolTipHolder));
+ _options.setToolTipText(toolTipHolder.value);
+
+ _envs.setEnvs(descriptor.envs, resolver);
+
+ _user.setText(resolver.substitute(descriptor.user));
+
+ _activation.setText(resolver.substitute(descriptor.activation));
+ _activationTimeout.setText(resolver.substitute(descriptor.activationTimeout));
+ _deactivationTimeout.setText(resolver.substitute(descriptor.deactivationTimeout));
+
+ _allocatable.setSelected(descriptor.allocatable);
+
+ _applicationDistrib.setSelected(descriptor.applicationDistrib);
+ _icepatch.setText(resolver.substitute(resolver.substitute(descriptor.distrib.icepatch)));
+
+ toolTipHolder = new Ice.StringHolder();
+
+ _directories.setText(
+ Utils.stringify(descriptor.distrib.directories, stringifier, ", ",
+ toolTipHolder));
+
+ String toolTip = "<html>Include only these directories";
+
+ if(toolTipHolder.value != null)
+ {
+ toolTip += ":<br>" + toolTipHolder.value;
+ }
+ toolTip += "</html>";
+ _directories.setToolTipText(toolTip);
+ }
+
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ builder.appendSeparator("Runtime Status");
+
+ builder.append("State");
+ builder.append(_currentState, 3);
+ builder.nextLine();
+
+ builder.append("Process ID");
+ builder.append(_currentPid, 3);
+ builder.nextLine();
+
+ builder.append("", _enabled);
+ builder.nextLine();
+
+ builder.appendSeparator("Configuration");
+
+ builder.append("Application");
+ builder.append(_application);
+ builder.append(_gotoApplication);
+ builder.nextLine();
+
+ //
+ // Add Communicator fields
+ //
+ super.appendProperties(builder);
+
+ builder.appendSeparator("Activation");
+ builder.append("Path to Executable");
+ builder.append(_exe, 3);
+ builder.nextLine();
+ builder.append("Working Directory");
+ builder.append(_pwd, 3);
+ builder.nextLine();
+ builder.append("Command Arguments");
+ builder.append(_options, 3);
+ builder.nextLine();
+ builder.append("Run as");
+ builder.append(_user, 3);
+ builder.nextLine();
+ builder.append("Environment Variables");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextLine();
+ builder.append("");
+ builder.nextRow(-6);
+ CellConstraints cc = new CellConstraints();
+ JScrollPane scrollPane = new JScrollPane(_envs);
+ builder.add(scrollPane,
+ cc.xywh(builder.getColumn(), builder.getRow(), 3, 7));
+ builder.nextRow(6);
+ builder.nextLine();
+
+ builder.append("Activation Mode");
+ builder.append(_activation, 3);
+ builder.nextLine();
+ builder.append("Activation Timeout");
+ builder.append(_activationTimeout, 3);
+ builder.nextLine();
+ builder.append("Deactivation Timeout");
+ builder.append(_deactivationTimeout, 3);
+ builder.nextLine();
+ builder.append("", _allocatable);
+ builder.nextLine();
+
+ JComponent c = builder.appendSeparator("Distribution");
+ c.setToolTipText("Files specific to this server");
+
+ builder.append("", _applicationDistrib);
+ builder.nextLine();
+ builder.append("IcePatch2 Proxy");
+ builder.append(_icepatch, 3);
+ builder.nextLine();
+ builder.append("Directories");
+ builder.append(_directories, 3);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Server Properties");
+ }
+
+
+ private class ToolBar extends JToolBar
+ {
+ private ToolBar()
+ {
+ putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.SINGLE);
+ putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
+ setFloatable(false);
+ putClientProperty("JToolBar.isRollover", Boolean.TRUE);
+
+ LiveActions la = _coordinator.getLiveActionsForMenu();
+
+ add(la.get(TreeNode.START));
+ add(la.get(TreeNode.STOP));
+ addSeparator();
+ add(la.get(TreeNode.ENABLE));
+ add(la.get(TreeNode.DISABLE));
+ }
+ }
+
+
+ private Coordinator _coordinator;
+ private Server _target;
+
+ private JTextField _currentState = new JTextField(20);
+ private JTextField _currentPid = new JTextField(20);
+ private JCheckBox _enabled = new JCheckBox("Enabled");
+
+ private JTextField _application = new JTextField(20);
+ private JButton _gotoApplication;
+
+ private JTextField _exe = new JTextField(20);
+ private JTextField _pwd = new JTextField(20);
+ private JTextField _user = new JTextField(20);
+
+ private JTextField _activation = new JTextField(20);
+ private JTextField _activationTimeout = new JTextField(20);
+ private JTextField _deactivationTimeout = new JTextField(20);
+ private JCheckBox _allocatable = new JCheckBox("Allocatable");
+
+
+ private TableField _envs = new TableField("Name", "Value");
+
+ private JTextField _options = new JTextField(20);
+ private JCheckBox _applicationDistrib = new JCheckBox("Depends on the application distribution");
+
+ private JTextField _icepatch = new JTextField(20);
+ private JTextField _directories = new JTextField(20);
+
+ private JToolBar _toolBar;
+}
+
diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java
index 814f4d74ba3..28c6e72d887 100755
--- a/java/src/IceGridGUI/LiveDeployment/Service.java
+++ b/java/src/IceGridGUI/LiveDeployment/Service.java
@@ -1,191 +1,191 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import java.util.Enumeration;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class Service extends ListArrayTreeNode
-{
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- if(_cellRenderer == null)
- {
- _cellRenderer = new DefaultTreeCellRenderer();
- _cellRenderer.setOpenIcon(
- Utils.getIcon("/icons/16x16/service.png"));
-
- _cellRenderer.setClosedIcon(
- Utils.getIcon("/icons/16x16/service.png"));
- }
-
- return _cellRenderer.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- }
-
- public Editor getEditor()
- {
- if(_editor == null)
- {
- _editor = new ServiceEditor();
- }
- _editor.show(this);
- return _editor;
- }
-
-
- Service(Server parent, String serviceName, Utils.Resolver resolver,
- ServiceInstanceDescriptor descriptor,
- ServiceDescriptor serviceDescriptor)
- {
- super(parent, serviceName, 2);
- _resolver = resolver;
-
- _instanceDescriptor = descriptor;
- _serviceDescriptor = serviceDescriptor;
-
- _childrenArray[0] = _adapters;
- _childrenArray[1] = _dbEnvs;
-
- createAdapters();
- createDbEnvs();
- }
-
- boolean updateAdapter(AdapterDynamicInfo info)
- {
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext())
- {
- Adapter adapter = (Adapter)p.next();
- if(adapter.update(info))
- {
- return true;
- }
- }
- return false;
- }
-
- int updateAdapters(java.util.List infoList)
- {
- int result = 0;
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext() && result < infoList.size())
- {
- Adapter adapter = (Adapter)p.next();
- if(adapter.update(infoList))
- {
- result++;
- }
- }
- return result;
- }
-
- void nodeDown()
- {
- java.util.Iterator p = _adapters.iterator();
- while(p.hasNext())
- {
- Adapter adapter = (Adapter)p.next();
- adapter.update((AdapterDynamicInfo)null);
- }
- }
-
- Utils.Resolver getResolver()
- {
- return _resolver;
- }
-
- ServiceDescriptor getServiceDescriptor()
- {
- return _serviceDescriptor;
- }
-
- ServiceInstanceDescriptor getInstanceDescriptor()
- {
- return _instanceDescriptor;
- }
-
- java.util.SortedMap getProperties()
- {
- Utils.ExpandedPropertySet instancePropertySet = null;
- Node node = (Node)_parent.getParent();
-
- String applicationName = ((Server)_parent).getApplication().name;
-
- if(_instanceDescriptor != null)
- {
- instancePropertySet = node.expand(_instanceDescriptor.propertySet,
- applicationName, _resolver);
- }
-
- Utils.ExpandedPropertySet propertySet =
- node.expand(_serviceDescriptor.propertySet,
- applicationName, _resolver);
-
- return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver);
- }
-
- private void createAdapters()
- {
- java.util.Iterator p = _serviceDescriptor.adapters.iterator();
- while(p.hasNext())
- {
- AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
- String adapterName = Utils.substitute(descriptor.name, _resolver);
-
- String adapterId = Utils.substitute(descriptor.id, _resolver);
- Ice.ObjectPrx proxy = null;
- if(adapterId.length() > 0)
- {
- proxy = ((Node)_parent.getParent()).getProxy(adapterId);
- }
-
- insertSortedChild(
- new Adapter(this, adapterName,
- _resolver, adapterId, descriptor, proxy),
- _adapters, null);
- }
- }
-
- private void createDbEnvs()
- {
- java.util.Iterator p = _serviceDescriptor.dbEnvs.iterator();
- while(p.hasNext())
- {
- DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
- String dbEnvName = Utils.substitute(descriptor.name, _resolver);
- insertSortedChild(
- new DbEnv(this, dbEnvName, _resolver, descriptor), _dbEnvs, null);
- }
- }
-
- private ServiceInstanceDescriptor _instanceDescriptor;
- private ServiceDescriptor _serviceDescriptor;
- private Utils.Resolver _resolver;
-
- private java.util.List _adapters = new java.util.LinkedList();
- private java.util.List _dbEnvs = new java.util.LinkedList();
-
- static private ServiceEditor _editor;
- static private DefaultTreeCellRenderer _cellRenderer;
-}
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.util.Enumeration;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class Service extends ListArrayTreeNode
+{
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ if(_cellRenderer == null)
+ {
+ _cellRenderer = new DefaultTreeCellRenderer();
+ _cellRenderer.setOpenIcon(
+ Utils.getIcon("/icons/16x16/service.png"));
+
+ _cellRenderer.setClosedIcon(
+ Utils.getIcon("/icons/16x16/service.png"));
+ }
+
+ return _cellRenderer.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ public Editor getEditor()
+ {
+ if(_editor == null)
+ {
+ _editor = new ServiceEditor();
+ }
+ _editor.show(this);
+ return _editor;
+ }
+
+
+ Service(Server parent, String serviceName, Utils.Resolver resolver,
+ ServiceInstanceDescriptor descriptor,
+ ServiceDescriptor serviceDescriptor)
+ {
+ super(parent, serviceName, 2);
+ _resolver = resolver;
+
+ _instanceDescriptor = descriptor;
+ _serviceDescriptor = serviceDescriptor;
+
+ _childrenArray[0] = _adapters;
+ _childrenArray[1] = _dbEnvs;
+
+ createAdapters();
+ createDbEnvs();
+ }
+
+ boolean updateAdapter(AdapterDynamicInfo info)
+ {
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext())
+ {
+ Adapter adapter = (Adapter)p.next();
+ if(adapter.update(info))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ int updateAdapters(java.util.List infoList)
+ {
+ int result = 0;
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext() && result < infoList.size())
+ {
+ Adapter adapter = (Adapter)p.next();
+ if(adapter.update(infoList))
+ {
+ result++;
+ }
+ }
+ return result;
+ }
+
+ void nodeDown()
+ {
+ java.util.Iterator p = _adapters.iterator();
+ while(p.hasNext())
+ {
+ Adapter adapter = (Adapter)p.next();
+ adapter.update((AdapterDynamicInfo)null);
+ }
+ }
+
+ Utils.Resolver getResolver()
+ {
+ return _resolver;
+ }
+
+ ServiceDescriptor getServiceDescriptor()
+ {
+ return _serviceDescriptor;
+ }
+
+ ServiceInstanceDescriptor getInstanceDescriptor()
+ {
+ return _instanceDescriptor;
+ }
+
+ java.util.SortedMap getProperties()
+ {
+ Utils.ExpandedPropertySet instancePropertySet = null;
+ Node node = (Node)_parent.getParent();
+
+ String applicationName = ((Server)_parent).getApplication().name;
+
+ if(_instanceDescriptor != null)
+ {
+ instancePropertySet = node.expand(_instanceDescriptor.propertySet,
+ applicationName, _resolver);
+ }
+
+ Utils.ExpandedPropertySet propertySet =
+ node.expand(_serviceDescriptor.propertySet,
+ applicationName, _resolver);
+
+ return Utils.propertySetToMap(propertySet, instancePropertySet, _resolver);
+ }
+
+ private void createAdapters()
+ {
+ java.util.Iterator p = _serviceDescriptor.adapters.iterator();
+ while(p.hasNext())
+ {
+ AdapterDescriptor descriptor = (AdapterDescriptor)p.next();
+ String adapterName = Utils.substitute(descriptor.name, _resolver);
+
+ String adapterId = Utils.substitute(descriptor.id, _resolver);
+ Ice.ObjectPrx proxy = null;
+ if(adapterId.length() > 0)
+ {
+ proxy = ((Node)_parent.getParent()).getProxy(adapterId);
+ }
+
+ insertSortedChild(
+ new Adapter(this, adapterName,
+ _resolver, adapterId, descriptor, proxy),
+ _adapters, null);
+ }
+ }
+
+ private void createDbEnvs()
+ {
+ java.util.Iterator p = _serviceDescriptor.dbEnvs.iterator();
+ while(p.hasNext())
+ {
+ DbEnvDescriptor descriptor = (DbEnvDescriptor)p.next();
+ String dbEnvName = Utils.substitute(descriptor.name, _resolver);
+ insertSortedChild(
+ new DbEnv(this, dbEnvName, _resolver, descriptor), _dbEnvs, null);
+ }
+ }
+
+ private ServiceInstanceDescriptor _instanceDescriptor;
+ private ServiceDescriptor _serviceDescriptor;
+ private Utils.Resolver _resolver;
+
+ private java.util.List _adapters = new java.util.LinkedList();
+ private java.util.List _dbEnvs = new java.util.LinkedList();
+
+ static private ServiceEditor _editor;
+ static private DefaultTreeCellRenderer _cellRenderer;
+}
diff --git a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java
index 802df44cdcb..47fce65b24b 100755
--- a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java
+++ b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java
@@ -1,51 +1,51 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import javax.swing.JTextField;
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-class ServiceEditor extends CommunicatorEditor
-{
- ServiceEditor()
- {
- _entry.setEditable(false);
- }
-
- void show(Service service)
- {
- ServiceDescriptor descriptor = service.getServiceDescriptor();
- Utils.Resolver resolver = service.getResolver();
-
- show(descriptor, service.getProperties(), resolver);
- _entry.setText(resolver.substitute(descriptor.entry));
- }
-
-
- protected void appendProperties(DefaultFormBuilder builder)
- {
- super.appendProperties(builder);
-
- builder.append("Entry Point");
- builder.append(_entry, 3);
- builder.nextLine();
- }
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- _propertiesPanel.setName("Service Properties");
- }
-
- private JTextField _entry = new JTextField(20);
-}
-
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import javax.swing.JTextField;
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+class ServiceEditor extends CommunicatorEditor
+{
+ ServiceEditor()
+ {
+ _entry.setEditable(false);
+ }
+
+ void show(Service service)
+ {
+ ServiceDescriptor descriptor = service.getServiceDescriptor();
+ Utils.Resolver resolver = service.getResolver();
+
+ show(descriptor, service.getProperties(), resolver);
+ _entry.setText(resolver.substitute(descriptor.entry));
+ }
+
+
+ protected void appendProperties(DefaultFormBuilder builder)
+ {
+ super.appendProperties(builder);
+
+ builder.append("Entry Point");
+ builder.append(_entry, 3);
+ builder.nextLine();
+ }
+
+ protected void buildPropertiesPanel()
+ {
+ super.buildPropertiesPanel();
+ _propertiesPanel.setName("Service Properties");
+ }
+
+ private JTextField _entry = new JTextField(20);
+}
+
diff --git a/java/src/IceGridGUI/LiveDeployment/TableField.java b/java/src/IceGridGUI/LiveDeployment/TableField.java
index 4b907bfa9b1..fb9d4e17c8b 100755
--- a/java/src/IceGridGUI/LiveDeployment/TableField.java
+++ b/java/src/IceGridGUI/LiveDeployment/TableField.java
@@ -1,196 +1,196 @@
-// **********************************************************************
-//
-// 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.LiveDeployment;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.KeyStroke;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.DefaultTableModel;
-
-
-//
-// A special field used to show a map or list
-//
-
-public class TableField extends JTable
-{
- public TableField(String headKey, String headValue)
- {
- _columnNames = new java.util.Vector(2);
- _columnNames.add(headKey);
- _columnNames.add(headValue);
- init();
- }
-
- public TableField(String headKey, String headValue1, String headValue2)
- {
- _columnNames = new java.util.Vector(3);
- _columnNames.add(headKey);
- _columnNames.add(headValue1);
- _columnNames.add(headValue2);
- init();
- }
-
- private void init()
- {
- _model = new DefaultTableModel()
- {
- public boolean isCellEditable(int row, int column)
- {
- return false;
- }
- };
- setModel(_model);
-
- setCellSelectionEnabled(false);
- setOpaque(false);
- setPreferredScrollableViewportSize(getPreferredSize());
- }
-
- public void setProperties(java.util.List properties, Utils.Resolver resolver)
- {
- java.util.SortedMap map = new java.util.TreeMap();
- java.util.Iterator p = properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- map.put(resolver.substitute(pd.name), resolver.substitute(pd.value));
- }
- setSortedMap(map);
- }
-
- public void setObjects(java.util.List objects, Utils.Resolver resolver)
- {
- java.util.SortedMap map = new java.util.TreeMap();
- java.util.Iterator p = objects.iterator();
- while(p.hasNext())
- {
- ObjectDescriptor od = (ObjectDescriptor)p.next();
- Ice.Identity id = new Ice.Identity(
- resolver.substitute(od.id.name),
- resolver.substitute(od.id.category));
-
- map.put(Ice.Util.identityToString(id), resolver.substitute(od.type));
- }
- setSortedMap(map);
- }
-
- public void setObjects(java.util.SortedMap objects)
- {
- java.util.SortedMap map = new java.util.TreeMap();
- java.util.Iterator p = objects.values().iterator();
- while(p.hasNext())
- {
- ObjectInfo oi = (ObjectInfo)p.next();
- map.put(oi.proxy.toString(), oi.type);
- }
- setSortedMap(map);
- }
-
- public void setEnvs(java.util.List envs, Utils.Resolver resolver)
- {
- java.util.SortedMap map = new java.util.TreeMap();
-
- java.util.Iterator p = envs.iterator();
- while(p.hasNext())
- {
- String env = resolver.substitute((String)p.next());
-
- int equal = env.indexOf('=');
- if(equal == -1 || equal == env.length() - 1)
- {
- map.put(env, "");
- }
- else
- {
- map.put(env.substring(0, equal),
- env.substring(equal + 1));
- }
- }
- setSortedMap(map);
- }
-
- public void setAdapters(java.util.SortedMap adapters)
- {
- java.util.Vector vector = new java.util.Vector(adapters.size());
- java.util.Iterator p = adapters.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Vector row = new java.util.Vector(3);
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- row.add((String)entry.getKey());
-
- AdapterInfo ai = (AdapterInfo)entry.getValue();
-
- if(ai.proxy == null)
- {
- row.add("");
- }
- else
- {
- String str = ai.proxy.toString();
- int index = str.indexOf(':');
- if(index == -1 || index == str.length() - 1)
- {
- row.add("");
- }
- else
- {
- row.add(str.substring(index + 1));
- }
- }
-
- row.add(ai.replicaGroupId);
- vector.add(row);
- }
-
- _model.setDataVector(vector, _columnNames);
-
- DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
- getDefaultRenderer(String.class);
- cr.setOpaque(false);
- }
-
-
- public void setSortedMap(java.util.SortedMap map)
- {
- java.util.Vector vector = new java.util.Vector(map.size());
- java.util.Iterator p = map.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Vector row = new java.util.Vector(2);
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- row.add((String)entry.getKey());
- row.add((String)entry.getValue());
- vector.add(row);
- }
-
- _model.setDataVector(vector, _columnNames);
-
- DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
- getDefaultRenderer(String.class);
- cr.setOpaque(false);
- }
-
- private DefaultTableModel _model;
- private java.util.Vector _columnNames;
-}
-
-
+// **********************************************************************
+//
+// 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.LiveDeployment;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+
+
+//
+// A special field used to show a map or list
+//
+
+public class TableField extends JTable
+{
+ public TableField(String headKey, String headValue)
+ {
+ _columnNames = new java.util.Vector(2);
+ _columnNames.add(headKey);
+ _columnNames.add(headValue);
+ init();
+ }
+
+ public TableField(String headKey, String headValue1, String headValue2)
+ {
+ _columnNames = new java.util.Vector(3);
+ _columnNames.add(headKey);
+ _columnNames.add(headValue1);
+ _columnNames.add(headValue2);
+ init();
+ }
+
+ private void init()
+ {
+ _model = new DefaultTableModel()
+ {
+ public boolean isCellEditable(int row, int column)
+ {
+ return false;
+ }
+ };
+ setModel(_model);
+
+ setCellSelectionEnabled(false);
+ setOpaque(false);
+ setPreferredScrollableViewportSize(getPreferredSize());
+ }
+
+ public void setProperties(java.util.List properties, Utils.Resolver resolver)
+ {
+ java.util.SortedMap map = new java.util.TreeMap();
+ java.util.Iterator p = properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ map.put(resolver.substitute(pd.name), resolver.substitute(pd.value));
+ }
+ setSortedMap(map);
+ }
+
+ public void setObjects(java.util.List objects, Utils.Resolver resolver)
+ {
+ java.util.SortedMap map = new java.util.TreeMap();
+ java.util.Iterator p = objects.iterator();
+ while(p.hasNext())
+ {
+ ObjectDescriptor od = (ObjectDescriptor)p.next();
+ Ice.Identity id = new Ice.Identity(
+ resolver.substitute(od.id.name),
+ resolver.substitute(od.id.category));
+
+ map.put(Ice.Util.identityToString(id), resolver.substitute(od.type));
+ }
+ setSortedMap(map);
+ }
+
+ public void setObjects(java.util.SortedMap objects)
+ {
+ java.util.SortedMap map = new java.util.TreeMap();
+ java.util.Iterator p = objects.values().iterator();
+ while(p.hasNext())
+ {
+ ObjectInfo oi = (ObjectInfo)p.next();
+ map.put(oi.proxy.toString(), oi.type);
+ }
+ setSortedMap(map);
+ }
+
+ public void setEnvs(java.util.List envs, Utils.Resolver resolver)
+ {
+ java.util.SortedMap map = new java.util.TreeMap();
+
+ java.util.Iterator p = envs.iterator();
+ while(p.hasNext())
+ {
+ String env = resolver.substitute((String)p.next());
+
+ int equal = env.indexOf('=');
+ if(equal == -1 || equal == env.length() - 1)
+ {
+ map.put(env, "");
+ }
+ else
+ {
+ map.put(env.substring(0, equal),
+ env.substring(equal + 1));
+ }
+ }
+ setSortedMap(map);
+ }
+
+ public void setAdapters(java.util.SortedMap adapters)
+ {
+ java.util.Vector vector = new java.util.Vector(adapters.size());
+ java.util.Iterator p = adapters.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = new java.util.Vector(3);
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ row.add((String)entry.getKey());
+
+ AdapterInfo ai = (AdapterInfo)entry.getValue();
+
+ if(ai.proxy == null)
+ {
+ row.add("");
+ }
+ else
+ {
+ String str = ai.proxy.toString();
+ int index = str.indexOf(':');
+ if(index == -1 || index == str.length() - 1)
+ {
+ row.add("");
+ }
+ else
+ {
+ row.add(str.substring(index + 1));
+ }
+ }
+
+ row.add(ai.replicaGroupId);
+ vector.add(row);
+ }
+
+ _model.setDataVector(vector, _columnNames);
+
+ DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
+ getDefaultRenderer(String.class);
+ cr.setOpaque(false);
+ }
+
+
+ public void setSortedMap(java.util.SortedMap map)
+ {
+ java.util.Vector vector = new java.util.Vector(map.size());
+ java.util.Iterator p = map.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Vector row = new java.util.Vector(2);
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ row.add((String)entry.getKey());
+ row.add((String)entry.getValue());
+ vector.add(row);
+ }
+
+ _model.setDataVector(vector, _columnNames);
+
+ DefaultTableCellRenderer cr = (DefaultTableCellRenderer)
+ getDefaultRenderer(String.class);
+ cr.setOpaque(false);
+ }
+
+ private DefaultTableModel _model;
+ private java.util.Vector _columnNames;
+}
+
+
diff --git a/java/src/IceGridGUI/LiveDeployment/TreeNode.java b/java/src/IceGridGUI/LiveDeployment/TreeNode.java
index cfa948d0a81..82d64437343 100755
--- a/java/src/IceGridGUI/LiveDeployment/TreeNode.java
+++ b/java/src/IceGridGUI/LiveDeployment/TreeNode.java
@@ -1,181 +1,181 @@
-// **********************************************************************
-//
-// 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 IceGridGUI.LiveDeployment;
-
-import javax.swing.SwingUtilities;
-import javax.swing.JOptionPane;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-public abstract class TreeNode extends TreeNodeBase
-{
- public abstract Editor getEditor();
-
- TreeNode(TreeNode parent, String id)
- {
- super(parent, id);
- }
-
- Root getRoot()
- {
- assert _parent != null;
- return ((TreeNode)_parent).getRoot();
- }
-
- //
- // Actions
- //
- public static final int START = 0;
- public static final int STOP = 1;
- public static final int ENABLE = 2;
- public static final int DISABLE = 3;
-
- public static final int SHUTDOWN_NODE = 4;
- public static final int PATCH_SERVER = 5;
-
- public static final int ADD_OBJECT = 6;
-
- static public final int ACTION_COUNT = 7;
-
- public boolean[] getAvailableActions()
- {
- return new boolean[ACTION_COUNT];
- }
-
- public void start()
- {
- assert false;
- }
- public void stop()
- {
- assert false;
- }
- public void enable()
- {
- assert false;
- }
- public void disable()
- {
- assert false;
- }
- public void shutdownNode()
- {
- assert false;
- }
- public void patchServer()
- {
- assert false;
- }
- public void addObject()
- {
- assert false;
- }
-
- //
- // Helpers
- //
- protected void amiSuccess(final String prefix)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- getCoordinator().getStatusBar().setText(prefix + "done.");
- }
- });
- }
-
- protected void amiFailure(String prefix, String title, Ice.UserException e)
- {
- if(e instanceof IceGrid.ServerNotExistException)
- {
- IceGrid.ServerNotExistException sne =
- (IceGrid.ServerNotExistException)e;
-
- amiFailure(prefix, title,
- "Server '" + sne.id +
- "' was not registered with the IceGrid Registry");
- }
- else if(e instanceof IceGrid.ServerStartException)
- {
- IceGrid.ServerStartException ste = (IceGrid.ServerStartException)e;
- amiFailure(prefix, title, "Server '" +
- ste.id + "' did not start: " + ste.reason);
- }
- else if(e instanceof IceGrid.ApplicationNotExistException)
- {
- amiFailure(prefix, title,
- "This application was not registered with the IceGrid Registry");
- }
- else if(e instanceof IceGrid.PatchException)
- {
- IceGrid.PatchException pe = (IceGrid.PatchException)e;
-
- String message = "";
- for(int i = 0; i < pe.reasons.length; ++i)
- {
- if(message.length() == 0)
- {
- message += "\n";
- message += pe.reasons[i];
- }
- }
- amiFailure(prefix, title, message);
- }
- else if(e instanceof IceGrid.NodeNotExistException)
- {
- IceGrid.NodeNotExistException nnee =
- (IceGrid.NodeNotExistException)e;
-
- amiFailure(prefix, title,
- "Node '" + nnee.name +
- " 'was not registered with the IceGrid Registry.");
- }
- else if(e instanceof IceGrid.NodeUnreachableException)
- {
- IceGrid.NodeUnreachableException nue =
- (IceGrid.NodeUnreachableException)e;
- amiFailure(prefix, title, "Node '" +
- nue.name + "' is unreachable: " + nue.reason);
- }
- else if(e instanceof IceGrid.DeploymentException)
- {
- IceGrid.DeploymentException de = (IceGrid.DeploymentException)e;
- amiFailure(prefix, title, "Deployment exception: " + de.reason);
- }
- else
- {
- amiFailure(prefix, title, e.toString());
- }
- }
-
- protected void amiFailure(final String prefix,
- final String title, final String message)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- failure(prefix, title, message);
- }
- });
- }
-
- protected void failure(String prefix, String title, String message)
- {
- getCoordinator().getStatusBar().setText(prefix + "failed!");
-
- JOptionPane.showMessageDialog(
- getCoordinator().getMainFrame(),
- message,
- title,
- JOptionPane.ERROR_MESSAGE);
- }
-}
+// **********************************************************************
+//
+// 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 IceGridGUI.LiveDeployment;
+
+import javax.swing.SwingUtilities;
+import javax.swing.JOptionPane;
+
+import IceGrid.*;
+import IceGridGUI.*;
+
+public abstract class TreeNode extends TreeNodeBase
+{
+ public abstract Editor getEditor();
+
+ TreeNode(TreeNode parent, String id)
+ {
+ super(parent, id);
+ }
+
+ Root getRoot()
+ {
+ assert _parent != null;
+ return ((TreeNode)_parent).getRoot();
+ }
+
+ //
+ // Actions
+ //
+ public static final int START = 0;
+ public static final int STOP = 1;
+ public static final int ENABLE = 2;
+ public static final int DISABLE = 3;
+
+ public static final int SHUTDOWN_NODE = 4;
+ public static final int PATCH_SERVER = 5;
+
+ public static final int ADD_OBJECT = 6;
+
+ static public final int ACTION_COUNT = 7;
+
+ public boolean[] getAvailableActions()
+ {
+ return new boolean[ACTION_COUNT];
+ }
+
+ public void start()
+ {
+ assert false;
+ }
+ public void stop()
+ {
+ assert false;
+ }
+ public void enable()
+ {
+ assert false;
+ }
+ public void disable()
+ {
+ assert false;
+ }
+ public void shutdownNode()
+ {
+ assert false;
+ }
+ public void patchServer()
+ {
+ assert false;
+ }
+ public void addObject()
+ {
+ assert false;
+ }
+
+ //
+ // Helpers
+ //
+ protected void amiSuccess(final String prefix)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ getCoordinator().getStatusBar().setText(prefix + "done.");
+ }
+ });
+ }
+
+ protected void amiFailure(String prefix, String title, Ice.UserException e)
+ {
+ if(e instanceof IceGrid.ServerNotExistException)
+ {
+ IceGrid.ServerNotExistException sne =
+ (IceGrid.ServerNotExistException)e;
+
+ amiFailure(prefix, title,
+ "Server '" + sne.id +
+ "' was not registered with the IceGrid Registry");
+ }
+ else if(e instanceof IceGrid.ServerStartException)
+ {
+ IceGrid.ServerStartException ste = (IceGrid.ServerStartException)e;
+ amiFailure(prefix, title, "Server '" +
+ ste.id + "' did not start: " + ste.reason);
+ }
+ else if(e instanceof IceGrid.ApplicationNotExistException)
+ {
+ amiFailure(prefix, title,
+ "This application was not registered with the IceGrid Registry");
+ }
+ else if(e instanceof IceGrid.PatchException)
+ {
+ IceGrid.PatchException pe = (IceGrid.PatchException)e;
+
+ String message = "";
+ for(int i = 0; i < pe.reasons.length; ++i)
+ {
+ if(message.length() == 0)
+ {
+ message += "\n";
+ message += pe.reasons[i];
+ }
+ }
+ amiFailure(prefix, title, message);
+ }
+ else if(e instanceof IceGrid.NodeNotExistException)
+ {
+ IceGrid.NodeNotExistException nnee =
+ (IceGrid.NodeNotExistException)e;
+
+ amiFailure(prefix, title,
+ "Node '" + nnee.name +
+ " 'was not registered with the IceGrid Registry.");
+ }
+ else if(e instanceof IceGrid.NodeUnreachableException)
+ {
+ IceGrid.NodeUnreachableException nue =
+ (IceGrid.NodeUnreachableException)e;
+ amiFailure(prefix, title, "Node '" +
+ nue.name + "' is unreachable: " + nue.reason);
+ }
+ else if(e instanceof IceGrid.DeploymentException)
+ {
+ IceGrid.DeploymentException de = (IceGrid.DeploymentException)e;
+ amiFailure(prefix, title, "Deployment exception: " + de.reason);
+ }
+ else
+ {
+ amiFailure(prefix, title, e.toString());
+ }
+ }
+
+ protected void amiFailure(final String prefix,
+ final String title, final String message)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ failure(prefix, title, message);
+ }
+ });
+ }
+
+ protected void failure(String prefix, String title, String message)
+ {
+ getCoordinator().getStatusBar().setText(prefix + "failed!");
+
+ JOptionPane.showMessageDialog(
+ getCoordinator().getMainFrame(),
+ message,
+ title,
+ JOptionPane.ERROR_MESSAGE);
+ }
+}
diff --git a/java/src/IceGridGUI/Main.java b/java/src/IceGridGUI/Main.java
index 9f6d151f46a..47e314ed833 100755
--- a/java/src/IceGridGUI/Main.java
+++ b/java/src/IceGridGUI/Main.java
@@ -1,94 +1,94 @@
-// **********************************************************************
-//
-// 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;
-
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import javax.swing.Icon;
-import javax.swing.JFrame;
-
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-
-import java.util.prefs.Preferences;
-
-public class Main extends JFrame
-{
- public static void main(final String[] args)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- createAndShowGUI(args);
- }
- });
- }
-
- Main(String[] args)
- {
- super("IceGrid Admin");
- javax.swing.ImageIcon icon = Utils.getIcon("/icons/16x16/grid.png");
- if(icon != null)
- {
- setIconImage(icon.getImage());
- }
-
- setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- if(_coordinator != null)
- {
- _coordinator.exit(0);
- }
- }
- });
-
- _coordinator =
- new Coordinator(this, new Ice.StringSeqHolder(args),
- Preferences.userNodeForPackage(getClass()));
-
- _coordinator.showMainFrame();
- }
-
- private static void createAndShowGUI(String[] args)
- {
- try
- {
- if(UIManager.getSystemLookAndFeelClassName().equals("apple.laf.AquaLookAndFeel"))
- {
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- UIManager.setLookAndFeel("apple.laf.AquaLookAndFeel");
- }
- else // JGoodies L&F
- {
- UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
- }
- }
- catch(Exception e)
- {
- System.err.println(e.toString());
- }
-
- //
- // Create and set up the window.
- //
- new Main(args);
-
- }
-
- private Coordinator _coordinator;
-}
-
-
+// **********************************************************************
+//
+// 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;
+
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.Icon;
+import javax.swing.JFrame;
+
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+import java.util.prefs.Preferences;
+
+public class Main extends JFrame
+{
+ public static void main(final String[] args)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ createAndShowGUI(args);
+ }
+ });
+ }
+
+ Main(String[] args)
+ {
+ super("IceGrid Admin");
+ javax.swing.ImageIcon icon = Utils.getIcon("/icons/16x16/grid.png");
+ if(icon != null)
+ {
+ setIconImage(icon.getImage());
+ }
+
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ addWindowListener(new WindowAdapter()
+ {
+ public void windowClosing(WindowEvent e)
+ {
+ if(_coordinator != null)
+ {
+ _coordinator.exit(0);
+ }
+ }
+ });
+
+ _coordinator =
+ new Coordinator(this, new Ice.StringSeqHolder(args),
+ Preferences.userNodeForPackage(getClass()));
+
+ _coordinator.showMainFrame();
+ }
+
+ private static void createAndShowGUI(String[] args)
+ {
+ try
+ {
+ if(UIManager.getSystemLookAndFeelClassName().equals("apple.laf.AquaLookAndFeel"))
+ {
+ System.setProperty("apple.laf.useScreenMenuBar", "true");
+ UIManager.setLookAndFeel("apple.laf.AquaLookAndFeel");
+ }
+ else // JGoodies L&F
+ {
+ UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
+ }
+ }
+ catch(Exception e)
+ {
+ System.err.println(e.toString());
+ }
+
+ //
+ // Create and set up the window.
+ //
+ new Main(args);
+
+ }
+
+ private Coordinator _coordinator;
+}
+
+
diff --git a/java/src/IceGridGUI/NodeObserverI.java b/java/src/IceGridGUI/NodeObserverI.java
index 98c16e66e38..f5d389c492e 100755
--- a/java/src/IceGridGUI/NodeObserverI.java
+++ b/java/src/IceGridGUI/NodeObserverI.java
@@ -1,82 +1,82 @@
-// **********************************************************************
-//
-// 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;
-
-import javax.swing.SwingUtilities;
-import IceGrid.*;
-
-class NodeObserverI extends _NodeObserverDisp
-{
- NodeObserverI(Coordinator coordinator)
- {
- _coordinator = coordinator;
- }
-
- public void nodeInit(final NodeDynamicInfo[] nodes, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- for(int i = 0; i < nodes.length; ++i)
- {
- _coordinator.nodeUp(nodes[i]);
- }
- }
- });
- }
-
- public void nodeUp(final NodeDynamicInfo nodeInfo, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.nodeUp(nodeInfo);
- }
- });
- }
-
- public void nodeDown(final String nodeName, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.nodeDown(nodeName);
- }
- });
- }
-
- public void updateServer(final String node, final ServerDynamicInfo updatedInfo,
- Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.updateServer(node, updatedInfo);
- }
- });
- }
-
- public void updateAdapter(final String node, final AdapterDynamicInfo updatedInfo,
- Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.updateAdapter(node, updatedInfo);
- }
- });
- }
-
- private Coordinator _coordinator;
-};
+// **********************************************************************
+//
+// 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;
+
+import javax.swing.SwingUtilities;
+import IceGrid.*;
+
+class NodeObserverI extends _NodeObserverDisp
+{
+ NodeObserverI(Coordinator coordinator)
+ {
+ _coordinator = coordinator;
+ }
+
+ public void nodeInit(final NodeDynamicInfo[] nodes, Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ for(int i = 0; i < nodes.length; ++i)
+ {
+ _coordinator.nodeUp(nodes[i]);
+ }
+ }
+ });
+ }
+
+ public void nodeUp(final NodeDynamicInfo nodeInfo, Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.nodeUp(nodeInfo);
+ }
+ });
+ }
+
+ public void nodeDown(final String nodeName, Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.nodeDown(nodeName);
+ }
+ });
+ }
+
+ public void updateServer(final String node, final ServerDynamicInfo updatedInfo,
+ Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.updateServer(node, updatedInfo);
+ }
+ });
+ }
+
+ public void updateAdapter(final String node, final AdapterDynamicInfo updatedInfo,
+ Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.updateAdapter(node, updatedInfo);
+ }
+ });
+ }
+
+ private Coordinator _coordinator;
+};
diff --git a/java/src/IceGridGUI/RegistryObserverI.java b/java/src/IceGridGUI/RegistryObserverI.java
index e8634fee905..67193aaf714 100755
--- a/java/src/IceGridGUI/RegistryObserverI.java
+++ b/java/src/IceGridGUI/RegistryObserverI.java
@@ -1,52 +1,52 @@
-// **********************************************************************
-//
-// 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;
-
-import javax.swing.SwingUtilities;
-import IceGrid.*;
-
-class RegistryObserverI extends _RegistryObserverDisp
-{
-
- RegistryObserverI(Coordinator coordinator)
- {
- _coordinator = coordinator;
- }
-
- public void registryInit(final RegistryInfo[] registries, Ice.Current current)
- {
- // TODO: XXX
- }
-
- public void registryUp(final RegistryInfo registryInfo, Ice.Current current)
- {
- // TODO: XXX
-// SwingUtilities.invokeLater(new Runnable()
-// {
-// public void run()
-// {
-// _coordinator.registryUp(registryInfo);
-// }
-// });
- }
-
- public void registryDown(final String registryName, Ice.Current current)
- {
- // TODO: XXX
-// SwingUtilities.invokeLater(new Runnable()
-// {
-// public void run()
-// {
-// _coordinator.registryDown(registryName);
-// }
-// });
- }
-
- private final Coordinator _coordinator;
-};
+// **********************************************************************
+//
+// 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;
+
+import javax.swing.SwingUtilities;
+import IceGrid.*;
+
+class RegistryObserverI extends _RegistryObserverDisp
+{
+
+ RegistryObserverI(Coordinator coordinator)
+ {
+ _coordinator = coordinator;
+ }
+
+ public void registryInit(final RegistryInfo[] registries, Ice.Current current)
+ {
+ // TODO: XXX
+ }
+
+ public void registryUp(final RegistryInfo registryInfo, Ice.Current current)
+ {
+ // TODO: XXX
+// SwingUtilities.invokeLater(new Runnable()
+// {
+// public void run()
+// {
+// _coordinator.registryUp(registryInfo);
+// }
+// });
+ }
+
+ public void registryDown(final String registryName, Ice.Current current)
+ {
+ // TODO: XXX
+// SwingUtilities.invokeLater(new Runnable()
+// {
+// public void run()
+// {
+// _coordinator.registryDown(registryName);
+// }
+// });
+ }
+
+ private final Coordinator _coordinator;
+};
diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java
index 1e8ec498993..62df5463fd1 100755
--- a/java/src/IceGridGUI/SessionKeeper.java
+++ b/java/src/IceGridGUI/SessionKeeper.java
@@ -1,1263 +1,1263 @@
-// **********************************************************************
-//
-// 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;
-
-import javax.swing.*;
-import javax.swing.border.TitledBorder;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.File;
-import java.security.KeyStore;
-
-import java.awt.Container;
-import java.awt.Frame;
-import java.awt.Component;
-import java.awt.Cursor;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.factories.Borders;
-import com.jgoodies.forms.factories.ButtonBarFactory;
-import com.jgoodies.forms.factories.DefaultComponentFactory;
-import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.util.LayoutStyle;
-
-import java.util.prefs.Preferences;
-
-import IceGrid.*;
-
-//
-// The SessionKeeper is responsible for establishing sessions (one at a time)
-// and keeping them alive.
-//
-
-class SessionKeeper
-{
- //
- // An AdminSessionPrx and various objects associated with that session
- //
- private class Session
- {
- Session(AdminSessionPrx session, Component parent)
- {
- _session = session;
-
- try
- {
- _admin = session.getAdmin();
- }
- catch(Ice.LocalException e)
- {
- logout(true);
- JOptionPane.showMessageDialog(
- parent,
- "Could not retrieve Admin proxy: " + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- throw e;
- }
-
- long period = 0;
-
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
- _coordinator.getCommunicator().getDefaultRouter());
- if(router != null)
- {
- period = router.getSessionTimeout() * 1000 / 2;
- }
- else
- {
- String str = _admin.ice_getIdentity().category + "/Registry";
- RegistryPrx registry = RegistryPrxHelper.
- uncheckedCast(_coordinator.getCommunicator().stringToProxy(str));
-
- period = registry.getSessionTimeout() * 1000 / 2;
- }
-
- _thread = new Pinger(_session, period);
- _thread.start();
-
- try
- {
- registerObservers();
- }
- catch(Ice.LocalException e)
- {
- logout(true);
- JOptionPane.showMessageDialog(parent,
- "Could not register observers: "
- + e.toString(),
- "Login failed",
- JOptionPane.ERROR_MESSAGE);
- throw e;
- }
- }
-
- AdminSessionPrx getSession()
- {
- return _session;
- }
-
- AdminPrx getAdmin()
- {
- return _admin;
- }
-
- AdminPrx getRoutedAdmin()
- {
- assert _admin != null;
-
- if(_routedAdmin == null)
- {
- //
- // Create a local Admin object used to route some operations to the real
- // Admin.
- // Routing admin calls is even necessary when we don't through Glacier2
- // since the Admin object provided by the registry is a well-known object
- // (indirect, locator-dependent).
- //
- Ice.ObjectAdapter adminRouterAdapter = _coordinator.getCommunicator().
- createObjectAdapterWithEndpoints("IceGrid.AdminRouter", "tcp -h localhost");
-
- _routedAdmin = AdminPrxHelper.uncheckedCast(
- adminRouterAdapter.addWithUUID(new AdminRouter(_admin)));
-
- adminRouterAdapter.activate();
- }
- return _routedAdmin;
- }
-
- void close(boolean destroySession)
- {
- if(_thread != null)
- {
- _thread.done();
-
- for(;;)
- {
- try
- {
- _thread.join();
- break;
- }
- catch(InterruptedException e)
- {
- }
- }
- }
-
- if(_adapter != null)
- {
- try
- {
- _adapter.remove(_applicationObserverIdentity);
- }
- catch(Ice.NotRegisteredException e)
- {
- }
-
- try
- {
- _adapter.remove(_adapterObserverIdentity);
- }
- catch(Ice.NotRegisteredException e)
- {
- }
-
- try
- {
- _adapter.remove(_objectObserverIdentity);
- }
- catch(Ice.NotRegisteredException e)
- {
- }
-
- try
- {
- _adapter.remove(_registryObserverIdentity);
- }
- catch(Ice.NotRegisteredException e)
- {
- }
-
- try
- {
- _adapter.remove(_nodeObserverIdentity);
- }
- catch(Ice.NotRegisteredException e)
- {
- }
- }
-
- if(destroySession)
- {
- _coordinator.destroySession(_session);
- }
- _coordinator.getStatusBar().setConnected(false);
- }
-
- private void registerObservers()
- {
- //
- // Create the object adapter for the observers
- //
- String category;
-
- Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
- _coordinator.getCommunicator().getDefaultRouter());
- if(router == null)
- {
- category = "observer";
-
- _adapter =
- _coordinator.getCommunicator().createObjectAdapter("IceGrid.AdminGUI");
- _adapter.activate();
- _session.ice_getConnection().setAdapter(_adapter);
- }
- else
- {
- category = router.getCategoryForClient();
-
- _adapter =
- _coordinator.getCommunicator().createObjectAdapterWithRouter("RoutedAdapter", router);
- _adapter.activate();
- }
-
- //
- // Create servants and proxies
- //
- _applicationObserverIdentity.name = "application";
- _applicationObserverIdentity.category = category;
- _adapterObserverIdentity.name = "adapter";
- _adapterObserverIdentity.category = category;
- _objectObserverIdentity.name = "object";
- _objectObserverIdentity.category = category;
- _registryObserverIdentity.name = "registry";
- _registryObserverIdentity.category = category;
- _nodeObserverIdentity.name = "node";
- _nodeObserverIdentity.category = category;
-
- ApplicationObserverI applicationObserverServant = new ApplicationObserverI(
- _admin.ice_getIdentity().category, _coordinator);
-
- ApplicationObserverPrx applicationObserver =
- ApplicationObserverPrxHelper.uncheckedCast(
- _adapter.add(
- applicationObserverServant, _applicationObserverIdentity));
-
- AdapterObserverPrx adapterObserver =
- AdapterObserverPrxHelper.uncheckedCast(
- _adapter.add(
- new AdapterObserverI(_coordinator), _adapterObserverIdentity));
-
- ObjectObserverPrx objectObserver =
- ObjectObserverPrxHelper.uncheckedCast(
- _adapter.add(
- new ObjectObserverI(_coordinator), _objectObserverIdentity));
-
- RegistryObserverPrx registryObserver =
- RegistryObserverPrxHelper.uncheckedCast(
- _adapter.add(
- new RegistryObserverI(_coordinator), _registryObserverIdentity));
-
- NodeObserverPrx nodeObserver =
- NodeObserverPrxHelper.uncheckedCast(
- _adapter.add(
- new NodeObserverI(_coordinator), _nodeObserverIdentity));
-
- if(router != null)
- {
- _session.setObservers(registryObserver,
- nodeObserver,
- applicationObserver,
- adapterObserver,
- objectObserver);
- }
- else
- {
- _session.setObserversByIdentity(
- _registryObserverIdentity,
- _nodeObserverIdentity,
- _applicationObserverIdentity,
- _adapterObserverIdentity,
- _objectObserverIdentity);
- }
-
- applicationObserverServant.waitForInit();
- }
-
-
- private final AdminSessionPrx _session;
- private Pinger _thread;
-
- private Ice.ObjectAdapter _adapter;
- private AdminPrx _admin;
- private AdminPrx _routedAdmin;
- private Ice.Identity _applicationObserverIdentity = new Ice.Identity();
- private Ice.Identity _adapterObserverIdentity = new Ice.Identity();
- private Ice.Identity _objectObserverIdentity = new Ice.Identity();
- private Ice.Identity _registryObserverIdentity = new Ice.Identity();
- private Ice.Identity _nodeObserverIdentity = new Ice.Identity();
- }
-
-
- static public class LoginInfo
- {
- LoginInfo(Preferences connectionPrefs, Coordinator coordinator)
- {
- _connectionPrefs = connectionPrefs;
-
- String prop = System.getProperty("java.net.ssl.keyStorePassword");
- if(prop != null)
- {
- keystorePassword = prop.toCharArray();
- }
- prop = System.getProperty("java.net.ssl.trustStorePassword");
- if(prop != null)
- {
- truststorePassword = prop.toCharArray();
- }
-
- Ice.Properties properties = coordinator.getProperties();
-
- //
- // Registry properties
- //
- String defaultLocator = properties.getProperty("Ice.Default.Locator");
- Ice.ObjectPrx defaultLocatorProxy = null;
- if(!defaultLocator.equals(""))
- {
- try
- {
- defaultLocatorProxy = coordinator.getCommunicator().stringToProxy(defaultLocator);
- }
- catch(Ice.LocalException e)
- {
- }
- }
- if(defaultLocatorProxy != null)
- {
- //
- // Set new defaults
- //
- registryInstanceName = defaultLocatorProxy.ice_getIdentity().category;
- registryEndpoints = "";
- Ice.Endpoint[] endpoints = defaultLocatorProxy.ice_getEndpoints();
- for(int i = 0; i < endpoints.length; ++i)
- {
- if(i > 0)
- {
- registryEndpoints += ":";
- }
- registryEndpoints += endpoints[i].toString();
- }
- }
- else
- {
- registryInstanceName =
- _connectionPrefs.get("registry.instanceName", registryInstanceName);
- registryEndpoints =
- _connectionPrefs.get("registry.endpoints", registryEndpoints);
- }
-
- //
- // Glacier2 properties
- //
- String defaultRouter = properties.getProperty("Ice.Default.Router");
- Ice.ObjectPrx defaultRouterProxy = null;
- if(!defaultRouter.equals(""))
- {
- try
- {
- defaultRouterProxy = coordinator.getCommunicator().stringToProxy(defaultRouter);
- }
- catch(Ice.LocalException e)
- {
- // Ignored, keep null defaultRouterProxy
- }
- }
- if(defaultRouterProxy != null)
- {
- //
- // Set new defaults
- //
- routerInstanceName = defaultRouterProxy.ice_getIdentity().category;
- routerEndpoints = "";
- Ice.Endpoint[] endpoints = defaultRouterProxy.ice_getEndpoints();
- for(int i = 0; i < endpoints.length; ++i)
- {
- if(i > 0)
- {
- routerEndpoints += ":";
- }
- routerEndpoints += endpoints[i].toString();
- }
- }
- else
- {
- routerInstanceName =
- _connectionPrefs.get("router.instanceName", routerInstanceName);
- routerEndpoints =
- _connectionPrefs.get("router.endpoints", routerEndpoints);
- }
- registrySSLEnabled = _connectionPrefs.getBoolean("routerSSLEnabled", registrySSLEnabled);
-
- registryUsername = _connectionPrefs.get("registry.username", registryUsername);
- registryUseSSL = _connectionPrefs.getBoolean("registry.useSSL", registryUseSSL);
- registrySSLEnabled = _connectionPrefs.getBoolean("registry.sslEnabled", registryUseSSL); // not a typo!
-
- routerUsername = _connectionPrefs.get("router.username", routerUsername);
- routerUseSSL = _connectionPrefs.getBoolean("router.useSSL", routerUseSSL);
- routerSSLEnabled = _connectionPrefs.getBoolean("router.sslEnabled", routerUseSSL); // not a typo!
-
- routed = _connectionPrefs.getBoolean("routed", routed);
-
- //
- // SSL Configuration
- //
- String val = properties.getProperty("IceSSL.Keystore");
- if(val.length() > 0)
- {
- keystore = val;
- }
- else
- {
- keystore = _connectionPrefs.get("keystore", keystore);
- }
-
- val = properties.getProperty("IceSSL.Alias");
- if(val.length() > 0)
- {
- alias = val;
- }
- else
- {
- alias = _connectionPrefs.get("alias", "");
- }
-
- val = properties.getProperty("IceSSL.Truststore");
- if(val.length() > 0)
- {
- truststore = val;
- }
- else
- {
- truststore = _connectionPrefs.get("truststore", keystore);
- }
- }
-
- void save()
- {
- _connectionPrefs.putBoolean("routed", routed);
-
- if(routed)
- {
- _connectionPrefs.put("router.username", routerUsername);
- _connectionPrefs.putBoolean("router.useSSL", routerUseSSL);
- _connectionPrefs.putBoolean("router.sslEnabled", routerSSLEnabled);
- _connectionPrefs.put("router.instanceName", routerInstanceName);
- _connectionPrefs.put("router.endpoints", routerEndpoints);
- }
- else
- {
- _connectionPrefs.put("registry.username", registryUsername);
- _connectionPrefs.putBoolean("registry.useSSL", registryUseSSL);
- _connectionPrefs.putBoolean("registry.sslEnabled", registrySSLEnabled);
- _connectionPrefs.put("registry.instanceName", registryInstanceName);
- _connectionPrefs.put("registry.endpoints", registryEndpoints);
- }
-
- //
- // SSL Configuration
- //
- _connectionPrefs.put("keystore", keystore);
- _connectionPrefs.put("alias", alias);
- _connectionPrefs.put("truststore", truststore);
- }
-
- boolean routed = false;
-
- String registryUsername = System.getProperty("user.name");
- char[] registryPassword;
- boolean registryUseSSL = false;
- boolean registrySSLEnabled = false;
- String registryInstanceName = "IceGrid";
- String registryEndpoints = "";
-
- String routerUsername = System.getProperty("user.name");
- char[] routerPassword;
- boolean routerUseSSL = false;
- boolean routerSSLEnabled = false;
- String routerInstanceName = "Glacier2";
- String routerEndpoints = "";
-
- //
- // SSL Configuration
- //
- String keystore = System.getProperty("java.net.ssl.keyStore");
- char[] keyPassword;
- char[] keystorePassword;
- String alias;
- String truststore = System.getProperty("java.net.ssl.trustStore");
- char[] truststorePassword;
- private Preferences _connectionPrefs;
- }
-
- private class LoginDialog extends JDialog
- {
- LoginDialog()
- {
- super(_coordinator.getMainFrame(), "Login - IceGrid Admin", true);
- setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
-
- final File defaultDir = new java.io.File(_coordinator.getProperties().getProperty("IceSSL.DefaultDir"));
- _keystoreType =
- _coordinator.getProperties().getPropertyWithDefault("IceSSL.KeystoreType",
- java.security.KeyStore.getDefaultType());
-
- JButton okButton = new JButton("OK");
- ActionListener okListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- writeInfo();
-
- if(login(LoginDialog.this))
- {
- setVisible(false);
- }
- //
- // Otherwise go back to the dialog
- //
- }
- };
- okButton.addActionListener(okListener);
- getRootPane().setDefaultButton(okButton);
-
- JButton cancelButton = new JButton("Cancel");
- ActionListener cancelListener = new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- setVisible(false);
- }
- };
- cancelButton.addActionListener(cancelListener);
-
- Action registryUseSSL = new AbstractAction("Use SSL for authentication")
- {
- public void actionPerformed(ActionEvent e)
- {
- selectRegistryUseSSL(_registryUseSSL.isSelected());
- }
- };
- _registryUseSSL = new JCheckBox(registryUseSSL);
-
-
- Action routerUseSSL = new AbstractAction("Use SSL for authentication")
- {
- public void actionPerformed(ActionEvent e)
- {
- selectRouterUseSSL(_routerUseSSL.isSelected());
- }
- };
- _routerUseSSL = new JCheckBox(routerUseSSL);
-
- Action registrySSLEnabled = new AbstractAction("Enable IceSSL")
- {
- public void actionPerformed(ActionEvent e)
- {
- selectRegistrySSLEnabled(_registrySSLEnabled.isSelected());
- }
- };
- _registrySSLEnabled = new JCheckBox(registrySSLEnabled);
-
- Action routerSSLEnabled = new AbstractAction("Enable IceSSL")
- {
- public void actionPerformed(ActionEvent e)
- {
- selectRouterSSLEnabled(_routerSSLEnabled.isSelected());
- }
- };
- _routerSSLEnabled = new JCheckBox(routerSSLEnabled);
-
-
- _keystore.setEditable(false);
- _advancedKeystore.setEditable(false);
- Action chooseKeystore = new AbstractAction("...")
- {
- public void actionPerformed(ActionEvent e)
- {
- String store = _keystore.getText();
- if(store == null || store.length() == 0)
- {
- _fileChooser.setCurrentDirectory(defaultDir);
- }
- else
- {
- File file = new File(store);
- if(file.isAbsolute())
- {
- _fileChooser.setSelectedFile(file);
- }
- else
- {
- _fileChooser.setSelectedFile(new File(defaultDir, store));
- }
- }
-
- int result = _fileChooser.showOpenDialog(LoginDialog.this);
- if(result == JFileChooser.APPROVE_OPTION)
- {
- File file = _fileChooser.getSelectedFile();
- _keystore.setText(file.getAbsolutePath());
- updateAlias(file, _alias.getSelectedItem());
- }
- }
- private JFileChooser _fileChooser = new JFileChooser();
- };
-
- _truststore.setEditable(false);
- Action chooseTruststore = new AbstractAction("...")
- {
- public void actionPerformed(ActionEvent e)
- {
- String store = _truststore.getText();
- if(store == null || store.length() == 0)
- {
- _fileChooser.setCurrentDirectory(defaultDir);
- }
- else
- {
- File file = new File(store);
- if(file.isAbsolute())
- {
- _fileChooser.setSelectedFile(file);
- }
- else
- {
- _fileChooser.setSelectedFile(new File(defaultDir, store));
- }
- }
-
- int result = _fileChooser.showOpenDialog(LoginDialog.this);
- if(result == JFileChooser.APPROVE_OPTION)
- {
- File file = _fileChooser.getSelectedFile();
- _truststore.setText(file.getAbsolutePath());
- }
- }
-
- private JFileChooser _fileChooser = new JFileChooser();
- };
-
-
- _registryUsername.setToolTipText("Your username");
- _registryPassword.setToolTipText("Your password in this IceGrid registry");
- _registryUseSSL.setToolTipText("Do you want to use SSL instead of username/password for authentication?");
- _registryInstanceName.setToolTipText("The instance name of your IceGrid registry. For example: DemoIceGrid");
- _registryEndpoints.setToolTipText("<html>Corresponds to the client endpoints of this IceGrid registry.<br>"
- + "For example: tcp -h registry.domain.com -p 12000</html>");
-
- _routerUsername.setToolTipText("Your username");
- _routerPassword.setToolTipText("Your password in this Glacier2 router");
- _routerUseSSL.setToolTipText("Do you want to use SSL instead of username/password for authentication?");
- _routerInstanceName.setToolTipText("The instance name of your Glacier2 router. For example: DemoGlacier2");
- _routerEndpoints.setToolTipText("<html>Corresponds to client endpoints of this Glacier2 router.<br>"
- + "For example: ssl -h glacier2router.domain.com -p 11000</html>");
-
- _keystore.setToolTipText("SSL keystore file");
- _keyPassword.setToolTipText("Password for keys in the selected keystore file");
- _advancedKeystore.setToolTipText("SSL keystore file");
- _advancedKeyPassword.setToolTipText("Password for keys in the selected keystore file");
-
- _keystorePassword.setToolTipText("Password used to check the integrity of the keystore");
- _alias.setToolTipText("Use this alias when authenticating IceGrid Admin with the IceGrid registry or Glacier2 router");
-
- _truststore.setToolTipText("SSL truststore file");
- _truststorePassword.setToolTipText("Password used to check the integrity of the truststore");
-
-
- JPanel directPanel = null;
- {
- FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
-
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
- builder.setRowGroupingEnabled(true);
- builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
-
- _registryUsernameLabel = builder.append("Username", _registryUsername);
- builder.nextLine();
- _registryPasswordLabel = builder.append("Password", _registryPassword);
- builder.nextLine();
- builder.append("", _registryUseSSL);
- builder.nextLine();
- builder.append("", _registrySSLEnabled);
- builder.nextLine();
- builder.append("IceGrid Instance Name", _registryInstanceName);
- builder.nextLine();
- builder.append("IceGrid Registry Endpoint(s)", _registryEndpoints);
- builder.nextLine();
-
- directPanel = builder.getPanel();
- }
-
-
- JPanel routedPanel = null;
- {
- FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
-
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
- builder.setRowGroupingEnabled(true);
- builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
-
- _routerUsernameLabel = builder.append("Username", _routerUsername);
- builder.nextLine();
- _routerPasswordLabel = builder.append("Password", _routerPassword);
- builder.nextLine();
- builder.append("", _routerUseSSL);
- builder.nextLine();
- builder.append("", _routerSSLEnabled);
- builder.nextLine();
- builder.append("Glacier2 Instance Name", _routerInstanceName);
- builder.nextLine();
- builder.append("Glacier2 Router Endpoint(s)", _routerEndpoints);
- builder.nextLine();
-
- routedPanel = builder.getPanel();
- }
-
- _mainPane.addTab("Direct", null, directPanel, "Log directly into the IceGrid registry");
- _mainPane.addTab("Routed", null, routedPanel, "Log into the IceGrid registry through a Glacier2 router");
- _mainPane.setBorder(Borders.DIALOG_BORDER);
-
- _mainPane.addChangeListener(new javax.swing.event.ChangeListener()
- {
- public void stateChanged(javax.swing.event.ChangeEvent e)
- {
- if(_mainPane.getSelectedIndex() == 0)
- {
- directTabSelected();
- }
- else
- {
- routedTabSelected();
- }
- }
- });
-
- JPanel basicSSLPanel = null;
- {
- FormLayout layout = new FormLayout(
- "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
-
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
- builder.setRowGroupingEnabled(true);
- builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
-
- builder.appendSeparator("Keystore");
- builder.append("File", _keystore);
- builder.append(new JButton(chooseKeystore));
- builder.nextLine();
- builder.append("Key Password");
- builder.append(_keyPassword, 3);
- builder.nextLine();
-
- basicSSLPanel = builder.getPanel();
- }
-
- JPanel advancedSSLPanel = null;
- {
- FormLayout layout = new FormLayout(
- "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
-
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
- builder.setRowGroupingEnabled(true);
- builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
-
- builder.appendSeparator("Keystore");
- builder.append("File", _advancedKeystore);
- builder.append(new JButton(chooseKeystore));
- builder.nextLine();
- builder.append("Key Password");
- builder.append(_advancedKeyPassword, 3);
- builder.nextLine();
- builder.append("Integrity Password");
- builder.append(_keystorePassword, 3);
- builder.nextLine();
- builder.append("Alias");
- builder.append(_alias, 3);
- builder.nextLine();
-
- builder.appendSeparator("Truststore");
- builder.append("File", _truststore);
- builder.append(new JButton(chooseTruststore));;
- builder.nextLine();
- builder.append("Integrity Password");
- builder.append(_truststorePassword, 3);
- builder.nextLine();
-
- advancedSSLPanel = builder.getPanel();
- }
-
-
- _sslPane.addTab("Basic", basicSSLPanel);
- _sslPane.addTab("Advanced", advancedSSLPanel);
- TitledBorder titledBorder = BorderFactory.createTitledBorder(Borders.DIALOG_BORDER,
- "SSL Configuration");
- _sslPane.setBorder(titledBorder);
-
- JComponent buttonBar =
- ButtonBarFactory.buildOKCancelBar(okButton, cancelButton);
- buttonBar.setBorder(Borders.DIALOG_BORDER);
-
- Container contentPane = getContentPane();
- contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
- contentPane.add(_mainPane);
- contentPane.add(_sslPane);
- contentPane.add(buttonBar);
-
- pack();
- setResizable(false);
- }
-
- void showDialog()
- {
- if(isVisible() == false)
- {
- _mainPane.setSelectedIndex(_loginInfo.routed ? 1 : 0);
-
- _registryUsername.setText(_loginInfo.registryUsername);
- selectRegistryUseSSL(_loginInfo.registryUseSSL);
-
- _registryInstanceName.setText(_loginInfo.registryInstanceName);
- _registryEndpoints.setText(_loginInfo.registryEndpoints);
- _registrySSLEnabled.setSelected(_loginInfo.routerSSLEnabled);
-
- _routerUsername.setText(_loginInfo.routerUsername);
- selectRouterUseSSL(_loginInfo.routerUseSSL);
-
- _routerInstanceName.setText(_loginInfo.routerInstanceName);
- _routerEndpoints.setText(_loginInfo.routerEndpoints);
- _routerSSLEnabled.setSelected(_loginInfo.routerSSLEnabled);
-
- _keystore.setText(_loginInfo.keystore);
- if(_loginInfo.keystore == null)
- {
- clearAlias();
- }
- else
- {
- updateAlias(new File(_loginInfo.keystore), _loginInfo.alias);
- }
- _truststore.setText(_loginInfo.truststore);
-
- if(_loginInfo.routed)
- {
- routedTabSelected();
- }
- else
- {
- directTabSelected();
- }
-
- setLocationRelativeTo(_coordinator.getMainFrame());
- setVisible(true);
- }
-
- //
- // Otherwise it was already on the screen!
- //
- }
-
- private void writeInfo()
- {
- _loginInfo.routed = (_mainPane.getSelectedIndex() == 1);
-
- _loginInfo.registryUsername = _registryUsername.getText();
- _loginInfo.registryPassword = _registryPassword.getPassword();
- _loginInfo.registryUseSSL = _registryUseSSL.isSelected();
- _loginInfo.registrySSLEnabled = _registrySSLEnabled.isSelected();
- _loginInfo.registryInstanceName = _registryInstanceName.getText();
- _loginInfo.registryEndpoints = _registryEndpoints.getText();
-
- _loginInfo.routerUsername = _routerUsername.getText();
- _loginInfo.routerPassword = _routerPassword.getPassword();
- _loginInfo.routerUseSSL = _routerUseSSL.isSelected();
- _loginInfo.routerSSLEnabled = _routerSSLEnabled.isSelected();
- _loginInfo.routerInstanceName = _routerInstanceName.getText();
- _loginInfo.routerEndpoints = _routerEndpoints.getText();
-
- _loginInfo.keystore = _keystore.getText();
- _loginInfo.keyPassword = _keyPassword.getPassword();
- _loginInfo.keystorePassword = _keystorePassword.getPassword();
- if(_alias.getSelectedItem() == null)
- {
- _loginInfo.alias = "";
- }
- else
- {
- _loginInfo.alias = _alias.getSelectedItem().toString();
- }
- _loginInfo.truststore = _truststore.getText();
- _loginInfo.truststorePassword = _truststorePassword.getPassword();
- }
-
- private void updateAlias(File file, Object selectedAlias)
- {
- if(file.isFile())
- {
- InputStream is = null;
- try
- {
- is = new FileInputStream(file);
- }
- catch(java.io.IOException e)
- {
- clearAlias();
- return;
- }
-
- java.util.Vector aliasVector = new java.util.Vector();
-
- try
- {
- KeyStore ks = KeyStore.getInstance(_keystoreType);
- ks.load(is, null);
- java.util.Enumeration p = ks.aliases();
- while(p.hasMoreElements())
- {
- aliasVector.add(p.nextElement());
- }
- }
- catch(Exception e)
- {
- clearAlias();
- return;
- }
- finally
- {
- try
- {
- is.close();
- }
- catch(java.io.IOException e)
- {}
- }
- _alias.setModel(new DefaultComboBoxModel(aliasVector));
- if(selectedAlias != null)
- {
- _alias.setSelectedItem(selectedAlias);
- }
- }
- else
- {
- clearAlias();
- }
- }
-
- private void clearAlias()
- {
- _alias.setModel(new DefaultComboBoxModel());
- }
-
- private void selectRegistryUseSSL(boolean selected)
- {
- _registryUseSSL.setSelected(selected);
- _registryUsername.setEnabled(!selected);
- _registryUsernameLabel.setEnabled(!selected);
- _registryPassword.setEnabled(!selected);
- _registryPasswordLabel.setEnabled(!selected);
-
- if(selected && _registrySSLEnabled.isSelected() == false)
- {
- selectRegistrySSLEnabled(selected);
- }
- }
-
- private void selectRouterUseSSL(boolean selected)
- {
- _routerUseSSL.setSelected(selected);
- _routerUsername.setEnabled(!selected);
- _routerUsernameLabel.setEnabled(!selected);
- _routerPassword.setEnabled(!selected);
- _routerPasswordLabel.setEnabled(!selected);
-
- if(selected && _routerSSLEnabled.isSelected() == false)
- {
- selectRouterSSLEnabled(selected);
- }
- }
-
- private void selectRegistrySSLEnabled(boolean selected)
- {
- _registrySSLEnabled.setSelected(selected);
- recursiveSetEnabled(_sslPane, selected);
- if(!selected && _registryUseSSL.isSelected())
- {
- selectRegistryUseSSL(selected);
- }
- }
-
- private void selectRouterSSLEnabled(boolean selected)
- {
- _routerSSLEnabled.setSelected(selected);
- recursiveSetEnabled(_sslPane, selected);
- if(!selected && _routerUseSSL.isSelected())
- {
- selectRouterUseSSL(selected);
- }
- }
-
- private void recursiveSetEnabled(java.awt.Container c, boolean enabled)
- {
- for(int i = 0; i < c.getComponentCount(); ++i)
- {
- java.awt.Component comp = c.getComponent(i);
- if(comp instanceof java.awt.Container)
- {
- recursiveSetEnabled((java.awt.Container)comp, enabled);
- }
- comp.setEnabled(enabled);
- }
- c.setEnabled(enabled);
- }
-
- private void directTabSelected()
- {
- recursiveSetEnabled(_sslPane, _registrySSLEnabled.isSelected());
- }
-
- private void routedTabSelected()
- {
- recursiveSetEnabled(_sslPane, _routerSSLEnabled.isSelected());
- }
-
- private JTabbedPane _mainPane = new JTabbedPane();
- private JTextField _registryUsername = new JTextField(30);
- private JLabel _registryUsernameLabel;
- private JPasswordField _registryPassword = new JPasswordField(30);
- private JLabel _registryPasswordLabel;
- private JCheckBox _registryUseSSL;
- private JCheckBox _registrySSLEnabled;
- private JTextField _registryInstanceName = new JTextField(30);
- private JTextField _registryEndpoints = new JTextField(30);
-
- private JTextField _routerUsername = new JTextField(30);
- private JLabel _routerUsernameLabel;
- private JPasswordField _routerPassword = new JPasswordField(30);
- private JLabel _routerPasswordLabel;
- private JCheckBox _routerUseSSL;
- private JCheckBox _routerSSLEnabled;
- private JTextField _routerInstanceName = new JTextField(30);
- private JTextField _routerEndpoints = new JTextField(30);
-
- private JTabbedPane _sslPane = new JTabbedPane();
- private JTextField _keystore = new JTextField(30);
- private JPasswordField _keyPassword = new JPasswordField(30);
-
- private JTextField _advancedKeystore = new JTextField(
- _keystore.getDocument(), null, 30);
- private JPasswordField _advancedKeyPassword = new JPasswordField(
- _keyPassword.getDocument(), null, 30);
-
- private JPasswordField _keystorePassword = new JPasswordField(30);
- private JComboBox _alias = new JComboBox();
-
- private JTextField _truststore = new JTextField(30);
- private JPasswordField _truststorePassword = new JPasswordField(30);
-
- private String _keystoreType;
- }
-
-
- //
- // We create a brand new Pinger thread for each session
- //
- class Pinger extends Thread
- {
- Pinger(AdminSessionPrx session, long period)
- {
- _session = session;
- _period = period;
- }
-
- public synchronized void run()
- {
- do
- {
- try
- {
- _session.keepAlive();
- }
- catch(final Ice.LocalException e)
- {
- _done = true;
-
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- sessionLost("Failed to contact the IceGrid registry: "
- + e.toString());
- }
- });
- }
-
- if(!_done)
- {
- try
- {
- wait(_period);
- }
- catch(InterruptedException e)
- {
- // Ignored
- }
- }
- } while(!_done);
- }
-
- public synchronized void done()
- {
- if(!_done)
- {
- _done = true;
- notify();
- }
- }
-
- private AdminSessionPrx _session;
- private long _period;
- private boolean _done = false;
- }
-
-
-
- SessionKeeper(Coordinator coordinator)
- {
- _coordinator = coordinator;
- _loginDialog = new LoginDialog();
- _loginPrefs = coordinator.getPrefs().node("Connection");
- }
-
- //
- // Runs in UI thread
- //
- void createSession()
- {
- _loginInfo = new LoginInfo(_loginPrefs, _coordinator);
- _loginDialog.showDialog();
- }
-
- void relog(boolean showDialog)
- {
- if(_loginInfo == null)
- {
- createSession();
- }
- else
- {
- if(showDialog || !login(_coordinator.getMainFrame()))
- {
- _loginDialog.showDialog();
- }
- }
- }
-
- private boolean login(Component parent)
- {
- if(_session != null)
- {
- logout(true);
- }
- assert _session == null;
-
- Cursor oldCursor = parent.getCursor();
- try
- {
- parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- AdminSessionPrx session = _coordinator.login(_loginInfo, parent);
- if(session == null)
- {
- return false;
- }
- _coordinator.getStatusBar().setConnected(true);
-
- try
- {
- _session = new Session(session, parent);
- }
- catch(Ice.LocalException e)
- {
- return false;
- }
- _loginInfo.save();
- }
- finally
- {
- parent.setCursor(oldCursor);
- }
- return true;
- }
-
- void sessionLost(String message)
- {
- JOptionPane.showMessageDialog(
- _coordinator.getMainFrame(),
- message,
- "Session lost",
- JOptionPane.ERROR_MESSAGE);
-
- logout(false);
- }
-
- void logout(boolean destroySession)
- {
- if(_session != null) // TODO: XXX: Review: The Session constructor might throw
- {
- _session.close(destroySession);
- _coordinator.sessionLost();
- _session = null;
- }
- }
-
- AdminSessionPrx getSession()
- {
- return _session == null ? null : _session.getSession();
- }
-
- AdminPrx getAdmin()
- {
- return _session == null ? null : _session.getAdmin();
- }
-
- AdminPrx getRoutedAdmin()
- {
- return _session == null ? null : _session.getRoutedAdmin();
- }
-
- private LoginDialog _loginDialog;
- private LoginInfo _loginInfo;
-
- private Coordinator _coordinator;
- private Preferences _loginPrefs;
-
- private Session _session;
-}
+// **********************************************************************
+//
+// 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;
+
+import javax.swing.*;
+import javax.swing.border.TitledBorder;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.File;
+import java.security.KeyStore;
+
+import java.awt.Container;
+import java.awt.Frame;
+import java.awt.Component;
+import java.awt.Cursor;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemListener;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.factories.Borders;
+import com.jgoodies.forms.factories.ButtonBarFactory;
+import com.jgoodies.forms.factories.DefaultComponentFactory;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.util.LayoutStyle;
+
+import java.util.prefs.Preferences;
+
+import IceGrid.*;
+
+//
+// The SessionKeeper is responsible for establishing sessions (one at a time)
+// and keeping them alive.
+//
+
+class SessionKeeper
+{
+ //
+ // An AdminSessionPrx and various objects associated with that session
+ //
+ private class Session
+ {
+ Session(AdminSessionPrx session, Component parent)
+ {
+ _session = session;
+
+ try
+ {
+ _admin = session.getAdmin();
+ }
+ catch(Ice.LocalException e)
+ {
+ logout(true);
+ JOptionPane.showMessageDialog(
+ parent,
+ "Could not retrieve Admin proxy: " + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ throw e;
+ }
+
+ long period = 0;
+
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
+ _coordinator.getCommunicator().getDefaultRouter());
+ if(router != null)
+ {
+ period = router.getSessionTimeout() * 1000 / 2;
+ }
+ else
+ {
+ String str = _admin.ice_getIdentity().category + "/Registry";
+ RegistryPrx registry = RegistryPrxHelper.
+ uncheckedCast(_coordinator.getCommunicator().stringToProxy(str));
+
+ period = registry.getSessionTimeout() * 1000 / 2;
+ }
+
+ _thread = new Pinger(_session, period);
+ _thread.start();
+
+ try
+ {
+ registerObservers();
+ }
+ catch(Ice.LocalException e)
+ {
+ logout(true);
+ JOptionPane.showMessageDialog(parent,
+ "Could not register observers: "
+ + e.toString(),
+ "Login failed",
+ JOptionPane.ERROR_MESSAGE);
+ throw e;
+ }
+ }
+
+ AdminSessionPrx getSession()
+ {
+ return _session;
+ }
+
+ AdminPrx getAdmin()
+ {
+ return _admin;
+ }
+
+ AdminPrx getRoutedAdmin()
+ {
+ assert _admin != null;
+
+ if(_routedAdmin == null)
+ {
+ //
+ // Create a local Admin object used to route some operations to the real
+ // Admin.
+ // Routing admin calls is even necessary when we don't through Glacier2
+ // since the Admin object provided by the registry is a well-known object
+ // (indirect, locator-dependent).
+ //
+ Ice.ObjectAdapter adminRouterAdapter = _coordinator.getCommunicator().
+ createObjectAdapterWithEndpoints("IceGrid.AdminRouter", "tcp -h localhost");
+
+ _routedAdmin = AdminPrxHelper.uncheckedCast(
+ adminRouterAdapter.addWithUUID(new AdminRouter(_admin)));
+
+ adminRouterAdapter.activate();
+ }
+ return _routedAdmin;
+ }
+
+ void close(boolean destroySession)
+ {
+ if(_thread != null)
+ {
+ _thread.done();
+
+ for(;;)
+ {
+ try
+ {
+ _thread.join();
+ break;
+ }
+ catch(InterruptedException e)
+ {
+ }
+ }
+ }
+
+ if(_adapter != null)
+ {
+ try
+ {
+ _adapter.remove(_applicationObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_adapterObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_objectObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_registryObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_nodeObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+ }
+
+ if(destroySession)
+ {
+ _coordinator.destroySession(_session);
+ }
+ _coordinator.getStatusBar().setConnected(false);
+ }
+
+ private void registerObservers()
+ {
+ //
+ // Create the object adapter for the observers
+ //
+ String category;
+
+ Glacier2.RouterPrx router = Glacier2.RouterPrxHelper.uncheckedCast(
+ _coordinator.getCommunicator().getDefaultRouter());
+ if(router == null)
+ {
+ category = "observer";
+
+ _adapter =
+ _coordinator.getCommunicator().createObjectAdapter("IceGrid.AdminGUI");
+ _adapter.activate();
+ _session.ice_getConnection().setAdapter(_adapter);
+ }
+ else
+ {
+ category = router.getCategoryForClient();
+
+ _adapter =
+ _coordinator.getCommunicator().createObjectAdapterWithRouter("RoutedAdapter", router);
+ _adapter.activate();
+ }
+
+ //
+ // Create servants and proxies
+ //
+ _applicationObserverIdentity.name = "application";
+ _applicationObserverIdentity.category = category;
+ _adapterObserverIdentity.name = "adapter";
+ _adapterObserverIdentity.category = category;
+ _objectObserverIdentity.name = "object";
+ _objectObserverIdentity.category = category;
+ _registryObserverIdentity.name = "registry";
+ _registryObserverIdentity.category = category;
+ _nodeObserverIdentity.name = "node";
+ _nodeObserverIdentity.category = category;
+
+ ApplicationObserverI applicationObserverServant = new ApplicationObserverI(
+ _admin.ice_getIdentity().category, _coordinator);
+
+ ApplicationObserverPrx applicationObserver =
+ ApplicationObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ applicationObserverServant, _applicationObserverIdentity));
+
+ AdapterObserverPrx adapterObserver =
+ AdapterObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new AdapterObserverI(_coordinator), _adapterObserverIdentity));
+
+ ObjectObserverPrx objectObserver =
+ ObjectObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new ObjectObserverI(_coordinator), _objectObserverIdentity));
+
+ RegistryObserverPrx registryObserver =
+ RegistryObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new RegistryObserverI(_coordinator), _registryObserverIdentity));
+
+ NodeObserverPrx nodeObserver =
+ NodeObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new NodeObserverI(_coordinator), _nodeObserverIdentity));
+
+ if(router != null)
+ {
+ _session.setObservers(registryObserver,
+ nodeObserver,
+ applicationObserver,
+ adapterObserver,
+ objectObserver);
+ }
+ else
+ {
+ _session.setObserversByIdentity(
+ _registryObserverIdentity,
+ _nodeObserverIdentity,
+ _applicationObserverIdentity,
+ _adapterObserverIdentity,
+ _objectObserverIdentity);
+ }
+
+ applicationObserverServant.waitForInit();
+ }
+
+
+ private final AdminSessionPrx _session;
+ private Pinger _thread;
+
+ private Ice.ObjectAdapter _adapter;
+ private AdminPrx _admin;
+ private AdminPrx _routedAdmin;
+ private Ice.Identity _applicationObserverIdentity = new Ice.Identity();
+ private Ice.Identity _adapterObserverIdentity = new Ice.Identity();
+ private Ice.Identity _objectObserverIdentity = new Ice.Identity();
+ private Ice.Identity _registryObserverIdentity = new Ice.Identity();
+ private Ice.Identity _nodeObserverIdentity = new Ice.Identity();
+ }
+
+
+ static public class LoginInfo
+ {
+ LoginInfo(Preferences connectionPrefs, Coordinator coordinator)
+ {
+ _connectionPrefs = connectionPrefs;
+
+ String prop = System.getProperty("java.net.ssl.keyStorePassword");
+ if(prop != null)
+ {
+ keystorePassword = prop.toCharArray();
+ }
+ prop = System.getProperty("java.net.ssl.trustStorePassword");
+ if(prop != null)
+ {
+ truststorePassword = prop.toCharArray();
+ }
+
+ Ice.Properties properties = coordinator.getProperties();
+
+ //
+ // Registry properties
+ //
+ String defaultLocator = properties.getProperty("Ice.Default.Locator");
+ Ice.ObjectPrx defaultLocatorProxy = null;
+ if(!defaultLocator.equals(""))
+ {
+ try
+ {
+ defaultLocatorProxy = coordinator.getCommunicator().stringToProxy(defaultLocator);
+ }
+ catch(Ice.LocalException e)
+ {
+ }
+ }
+ if(defaultLocatorProxy != null)
+ {
+ //
+ // Set new defaults
+ //
+ registryInstanceName = defaultLocatorProxy.ice_getIdentity().category;
+ registryEndpoints = "";
+ Ice.Endpoint[] endpoints = defaultLocatorProxy.ice_getEndpoints();
+ for(int i = 0; i < endpoints.length; ++i)
+ {
+ if(i > 0)
+ {
+ registryEndpoints += ":";
+ }
+ registryEndpoints += endpoints[i].toString();
+ }
+ }
+ else
+ {
+ registryInstanceName =
+ _connectionPrefs.get("registry.instanceName", registryInstanceName);
+ registryEndpoints =
+ _connectionPrefs.get("registry.endpoints", registryEndpoints);
+ }
+
+ //
+ // Glacier2 properties
+ //
+ String defaultRouter = properties.getProperty("Ice.Default.Router");
+ Ice.ObjectPrx defaultRouterProxy = null;
+ if(!defaultRouter.equals(""))
+ {
+ try
+ {
+ defaultRouterProxy = coordinator.getCommunicator().stringToProxy(defaultRouter);
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored, keep null defaultRouterProxy
+ }
+ }
+ if(defaultRouterProxy != null)
+ {
+ //
+ // Set new defaults
+ //
+ routerInstanceName = defaultRouterProxy.ice_getIdentity().category;
+ routerEndpoints = "";
+ Ice.Endpoint[] endpoints = defaultRouterProxy.ice_getEndpoints();
+ for(int i = 0; i < endpoints.length; ++i)
+ {
+ if(i > 0)
+ {
+ routerEndpoints += ":";
+ }
+ routerEndpoints += endpoints[i].toString();
+ }
+ }
+ else
+ {
+ routerInstanceName =
+ _connectionPrefs.get("router.instanceName", routerInstanceName);
+ routerEndpoints =
+ _connectionPrefs.get("router.endpoints", routerEndpoints);
+ }
+ registrySSLEnabled = _connectionPrefs.getBoolean("routerSSLEnabled", registrySSLEnabled);
+
+ registryUsername = _connectionPrefs.get("registry.username", registryUsername);
+ registryUseSSL = _connectionPrefs.getBoolean("registry.useSSL", registryUseSSL);
+ registrySSLEnabled = _connectionPrefs.getBoolean("registry.sslEnabled", registryUseSSL); // not a typo!
+
+ routerUsername = _connectionPrefs.get("router.username", routerUsername);
+ routerUseSSL = _connectionPrefs.getBoolean("router.useSSL", routerUseSSL);
+ routerSSLEnabled = _connectionPrefs.getBoolean("router.sslEnabled", routerUseSSL); // not a typo!
+
+ routed = _connectionPrefs.getBoolean("routed", routed);
+
+ //
+ // SSL Configuration
+ //
+ String val = properties.getProperty("IceSSL.Keystore");
+ if(val.length() > 0)
+ {
+ keystore = val;
+ }
+ else
+ {
+ keystore = _connectionPrefs.get("keystore", keystore);
+ }
+
+ val = properties.getProperty("IceSSL.Alias");
+ if(val.length() > 0)
+ {
+ alias = val;
+ }
+ else
+ {
+ alias = _connectionPrefs.get("alias", "");
+ }
+
+ val = properties.getProperty("IceSSL.Truststore");
+ if(val.length() > 0)
+ {
+ truststore = val;
+ }
+ else
+ {
+ truststore = _connectionPrefs.get("truststore", keystore);
+ }
+ }
+
+ void save()
+ {
+ _connectionPrefs.putBoolean("routed", routed);
+
+ if(routed)
+ {
+ _connectionPrefs.put("router.username", routerUsername);
+ _connectionPrefs.putBoolean("router.useSSL", routerUseSSL);
+ _connectionPrefs.putBoolean("router.sslEnabled", routerSSLEnabled);
+ _connectionPrefs.put("router.instanceName", routerInstanceName);
+ _connectionPrefs.put("router.endpoints", routerEndpoints);
+ }
+ else
+ {
+ _connectionPrefs.put("registry.username", registryUsername);
+ _connectionPrefs.putBoolean("registry.useSSL", registryUseSSL);
+ _connectionPrefs.putBoolean("registry.sslEnabled", registrySSLEnabled);
+ _connectionPrefs.put("registry.instanceName", registryInstanceName);
+ _connectionPrefs.put("registry.endpoints", registryEndpoints);
+ }
+
+ //
+ // SSL Configuration
+ //
+ _connectionPrefs.put("keystore", keystore);
+ _connectionPrefs.put("alias", alias);
+ _connectionPrefs.put("truststore", truststore);
+ }
+
+ boolean routed = false;
+
+ String registryUsername = System.getProperty("user.name");
+ char[] registryPassword;
+ boolean registryUseSSL = false;
+ boolean registrySSLEnabled = false;
+ String registryInstanceName = "IceGrid";
+ String registryEndpoints = "";
+
+ String routerUsername = System.getProperty("user.name");
+ char[] routerPassword;
+ boolean routerUseSSL = false;
+ boolean routerSSLEnabled = false;
+ String routerInstanceName = "Glacier2";
+ String routerEndpoints = "";
+
+ //
+ // SSL Configuration
+ //
+ String keystore = System.getProperty("java.net.ssl.keyStore");
+ char[] keyPassword;
+ char[] keystorePassword;
+ String alias;
+ String truststore = System.getProperty("java.net.ssl.trustStore");
+ char[] truststorePassword;
+ private Preferences _connectionPrefs;
+ }
+
+ private class LoginDialog extends JDialog
+ {
+ LoginDialog()
+ {
+ super(_coordinator.getMainFrame(), "Login - IceGrid Admin", true);
+ setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
+
+ final File defaultDir = new java.io.File(_coordinator.getProperties().getProperty("IceSSL.DefaultDir"));
+ _keystoreType =
+ _coordinator.getProperties().getPropertyWithDefault("IceSSL.KeystoreType",
+ java.security.KeyStore.getDefaultType());
+
+ JButton okButton = new JButton("OK");
+ ActionListener okListener = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ writeInfo();
+
+ if(login(LoginDialog.this))
+ {
+ setVisible(false);
+ }
+ //
+ // Otherwise go back to the dialog
+ //
+ }
+ };
+ okButton.addActionListener(okListener);
+ getRootPane().setDefaultButton(okButton);
+
+ JButton cancelButton = new JButton("Cancel");
+ ActionListener cancelListener = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ setVisible(false);
+ }
+ };
+ cancelButton.addActionListener(cancelListener);
+
+ Action registryUseSSL = new AbstractAction("Use SSL for authentication")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ selectRegistryUseSSL(_registryUseSSL.isSelected());
+ }
+ };
+ _registryUseSSL = new JCheckBox(registryUseSSL);
+
+
+ Action routerUseSSL = new AbstractAction("Use SSL for authentication")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ selectRouterUseSSL(_routerUseSSL.isSelected());
+ }
+ };
+ _routerUseSSL = new JCheckBox(routerUseSSL);
+
+ Action registrySSLEnabled = new AbstractAction("Enable IceSSL")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ selectRegistrySSLEnabled(_registrySSLEnabled.isSelected());
+ }
+ };
+ _registrySSLEnabled = new JCheckBox(registrySSLEnabled);
+
+ Action routerSSLEnabled = new AbstractAction("Enable IceSSL")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ selectRouterSSLEnabled(_routerSSLEnabled.isSelected());
+ }
+ };
+ _routerSSLEnabled = new JCheckBox(routerSSLEnabled);
+
+
+ _keystore.setEditable(false);
+ _advancedKeystore.setEditable(false);
+ Action chooseKeystore = new AbstractAction("...")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ String store = _keystore.getText();
+ if(store == null || store.length() == 0)
+ {
+ _fileChooser.setCurrentDirectory(defaultDir);
+ }
+ else
+ {
+ File file = new File(store);
+ if(file.isAbsolute())
+ {
+ _fileChooser.setSelectedFile(file);
+ }
+ else
+ {
+ _fileChooser.setSelectedFile(new File(defaultDir, store));
+ }
+ }
+
+ int result = _fileChooser.showOpenDialog(LoginDialog.this);
+ if(result == JFileChooser.APPROVE_OPTION)
+ {
+ File file = _fileChooser.getSelectedFile();
+ _keystore.setText(file.getAbsolutePath());
+ updateAlias(file, _alias.getSelectedItem());
+ }
+ }
+ private JFileChooser _fileChooser = new JFileChooser();
+ };
+
+ _truststore.setEditable(false);
+ Action chooseTruststore = new AbstractAction("...")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ String store = _truststore.getText();
+ if(store == null || store.length() == 0)
+ {
+ _fileChooser.setCurrentDirectory(defaultDir);
+ }
+ else
+ {
+ File file = new File(store);
+ if(file.isAbsolute())
+ {
+ _fileChooser.setSelectedFile(file);
+ }
+ else
+ {
+ _fileChooser.setSelectedFile(new File(defaultDir, store));
+ }
+ }
+
+ int result = _fileChooser.showOpenDialog(LoginDialog.this);
+ if(result == JFileChooser.APPROVE_OPTION)
+ {
+ File file = _fileChooser.getSelectedFile();
+ _truststore.setText(file.getAbsolutePath());
+ }
+ }
+
+ private JFileChooser _fileChooser = new JFileChooser();
+ };
+
+
+ _registryUsername.setToolTipText("Your username");
+ _registryPassword.setToolTipText("Your password in this IceGrid registry");
+ _registryUseSSL.setToolTipText("Do you want to use SSL instead of username/password for authentication?");
+ _registryInstanceName.setToolTipText("The instance name of your IceGrid registry. For example: DemoIceGrid");
+ _registryEndpoints.setToolTipText("<html>Corresponds to the client endpoints of this IceGrid registry.<br>"
+ + "For example: tcp -h registry.domain.com -p 12000</html>");
+
+ _routerUsername.setToolTipText("Your username");
+ _routerPassword.setToolTipText("Your password in this Glacier2 router");
+ _routerUseSSL.setToolTipText("Do you want to use SSL instead of username/password for authentication?");
+ _routerInstanceName.setToolTipText("The instance name of your Glacier2 router. For example: DemoGlacier2");
+ _routerEndpoints.setToolTipText("<html>Corresponds to client endpoints of this Glacier2 router.<br>"
+ + "For example: ssl -h glacier2router.domain.com -p 11000</html>");
+
+ _keystore.setToolTipText("SSL keystore file");
+ _keyPassword.setToolTipText("Password for keys in the selected keystore file");
+ _advancedKeystore.setToolTipText("SSL keystore file");
+ _advancedKeyPassword.setToolTipText("Password for keys in the selected keystore file");
+
+ _keystorePassword.setToolTipText("Password used to check the integrity of the keystore");
+ _alias.setToolTipText("Use this alias when authenticating IceGrid Admin with the IceGrid registry or Glacier2 router");
+
+ _truststore.setToolTipText("SSL truststore file");
+ _truststorePassword.setToolTipText("Password used to check the integrity of the truststore");
+
+
+ JPanel directPanel = null;
+ {
+ FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
+
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+ builder.setRowGroupingEnabled(true);
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ _registryUsernameLabel = builder.append("Username", _registryUsername);
+ builder.nextLine();
+ _registryPasswordLabel = builder.append("Password", _registryPassword);
+ builder.nextLine();
+ builder.append("", _registryUseSSL);
+ builder.nextLine();
+ builder.append("", _registrySSLEnabled);
+ builder.nextLine();
+ builder.append("IceGrid Instance Name", _registryInstanceName);
+ builder.nextLine();
+ builder.append("IceGrid Registry Endpoint(s)", _registryEndpoints);
+ builder.nextLine();
+
+ directPanel = builder.getPanel();
+ }
+
+
+ JPanel routedPanel = null;
+ {
+ FormLayout layout = new FormLayout("right:pref, 3dlu, pref", "");
+
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+ builder.setRowGroupingEnabled(true);
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ _routerUsernameLabel = builder.append("Username", _routerUsername);
+ builder.nextLine();
+ _routerPasswordLabel = builder.append("Password", _routerPassword);
+ builder.nextLine();
+ builder.append("", _routerUseSSL);
+ builder.nextLine();
+ builder.append("", _routerSSLEnabled);
+ builder.nextLine();
+ builder.append("Glacier2 Instance Name", _routerInstanceName);
+ builder.nextLine();
+ builder.append("Glacier2 Router Endpoint(s)", _routerEndpoints);
+ builder.nextLine();
+
+ routedPanel = builder.getPanel();
+ }
+
+ _mainPane.addTab("Direct", null, directPanel, "Log directly into the IceGrid registry");
+ _mainPane.addTab("Routed", null, routedPanel, "Log into the IceGrid registry through a Glacier2 router");
+ _mainPane.setBorder(Borders.DIALOG_BORDER);
+
+ _mainPane.addChangeListener(new javax.swing.event.ChangeListener()
+ {
+ public void stateChanged(javax.swing.event.ChangeEvent e)
+ {
+ if(_mainPane.getSelectedIndex() == 0)
+ {
+ directTabSelected();
+ }
+ else
+ {
+ routedTabSelected();
+ }
+ }
+ });
+
+ JPanel basicSSLPanel = null;
+ {
+ FormLayout layout = new FormLayout(
+ "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
+
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+ builder.setRowGroupingEnabled(true);
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ builder.appendSeparator("Keystore");
+ builder.append("File", _keystore);
+ builder.append(new JButton(chooseKeystore));
+ builder.nextLine();
+ builder.append("Key Password");
+ builder.append(_keyPassword, 3);
+ builder.nextLine();
+
+ basicSSLPanel = builder.getPanel();
+ }
+
+ JPanel advancedSSLPanel = null;
+ {
+ FormLayout layout = new FormLayout(
+ "right:pref, 3dlu, fill:pref:grow, 3dlu, pref", "");
+
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout);
+ builder.setDefaultDialogBorder();
+ builder.setRowGroupingEnabled(true);
+ builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad());
+
+ builder.appendSeparator("Keystore");
+ builder.append("File", _advancedKeystore);
+ builder.append(new JButton(chooseKeystore));
+ builder.nextLine();
+ builder.append("Key Password");
+ builder.append(_advancedKeyPassword, 3);
+ builder.nextLine();
+ builder.append("Integrity Password");
+ builder.append(_keystorePassword, 3);
+ builder.nextLine();
+ builder.append("Alias");
+ builder.append(_alias, 3);
+ builder.nextLine();
+
+ builder.appendSeparator("Truststore");
+ builder.append("File", _truststore);
+ builder.append(new JButton(chooseTruststore));;
+ builder.nextLine();
+ builder.append("Integrity Password");
+ builder.append(_truststorePassword, 3);
+ builder.nextLine();
+
+ advancedSSLPanel = builder.getPanel();
+ }
+
+
+ _sslPane.addTab("Basic", basicSSLPanel);
+ _sslPane.addTab("Advanced", advancedSSLPanel);
+ TitledBorder titledBorder = BorderFactory.createTitledBorder(Borders.DIALOG_BORDER,
+ "SSL Configuration");
+ _sslPane.setBorder(titledBorder);
+
+ JComponent buttonBar =
+ ButtonBarFactory.buildOKCancelBar(okButton, cancelButton);
+ buttonBar.setBorder(Borders.DIALOG_BORDER);
+
+ Container contentPane = getContentPane();
+ contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
+ contentPane.add(_mainPane);
+ contentPane.add(_sslPane);
+ contentPane.add(buttonBar);
+
+ pack();
+ setResizable(false);
+ }
+
+ void showDialog()
+ {
+ if(isVisible() == false)
+ {
+ _mainPane.setSelectedIndex(_loginInfo.routed ? 1 : 0);
+
+ _registryUsername.setText(_loginInfo.registryUsername);
+ selectRegistryUseSSL(_loginInfo.registryUseSSL);
+
+ _registryInstanceName.setText(_loginInfo.registryInstanceName);
+ _registryEndpoints.setText(_loginInfo.registryEndpoints);
+ _registrySSLEnabled.setSelected(_loginInfo.routerSSLEnabled);
+
+ _routerUsername.setText(_loginInfo.routerUsername);
+ selectRouterUseSSL(_loginInfo.routerUseSSL);
+
+ _routerInstanceName.setText(_loginInfo.routerInstanceName);
+ _routerEndpoints.setText(_loginInfo.routerEndpoints);
+ _routerSSLEnabled.setSelected(_loginInfo.routerSSLEnabled);
+
+ _keystore.setText(_loginInfo.keystore);
+ if(_loginInfo.keystore == null)
+ {
+ clearAlias();
+ }
+ else
+ {
+ updateAlias(new File(_loginInfo.keystore), _loginInfo.alias);
+ }
+ _truststore.setText(_loginInfo.truststore);
+
+ if(_loginInfo.routed)
+ {
+ routedTabSelected();
+ }
+ else
+ {
+ directTabSelected();
+ }
+
+ setLocationRelativeTo(_coordinator.getMainFrame());
+ setVisible(true);
+ }
+
+ //
+ // Otherwise it was already on the screen!
+ //
+ }
+
+ private void writeInfo()
+ {
+ _loginInfo.routed = (_mainPane.getSelectedIndex() == 1);
+
+ _loginInfo.registryUsername = _registryUsername.getText();
+ _loginInfo.registryPassword = _registryPassword.getPassword();
+ _loginInfo.registryUseSSL = _registryUseSSL.isSelected();
+ _loginInfo.registrySSLEnabled = _registrySSLEnabled.isSelected();
+ _loginInfo.registryInstanceName = _registryInstanceName.getText();
+ _loginInfo.registryEndpoints = _registryEndpoints.getText();
+
+ _loginInfo.routerUsername = _routerUsername.getText();
+ _loginInfo.routerPassword = _routerPassword.getPassword();
+ _loginInfo.routerUseSSL = _routerUseSSL.isSelected();
+ _loginInfo.routerSSLEnabled = _routerSSLEnabled.isSelected();
+ _loginInfo.routerInstanceName = _routerInstanceName.getText();
+ _loginInfo.routerEndpoints = _routerEndpoints.getText();
+
+ _loginInfo.keystore = _keystore.getText();
+ _loginInfo.keyPassword = _keyPassword.getPassword();
+ _loginInfo.keystorePassword = _keystorePassword.getPassword();
+ if(_alias.getSelectedItem() == null)
+ {
+ _loginInfo.alias = "";
+ }
+ else
+ {
+ _loginInfo.alias = _alias.getSelectedItem().toString();
+ }
+ _loginInfo.truststore = _truststore.getText();
+ _loginInfo.truststorePassword = _truststorePassword.getPassword();
+ }
+
+ private void updateAlias(File file, Object selectedAlias)
+ {
+ if(file.isFile())
+ {
+ InputStream is = null;
+ try
+ {
+ is = new FileInputStream(file);
+ }
+ catch(java.io.IOException e)
+ {
+ clearAlias();
+ return;
+ }
+
+ java.util.Vector aliasVector = new java.util.Vector();
+
+ try
+ {
+ KeyStore ks = KeyStore.getInstance(_keystoreType);
+ ks.load(is, null);
+ java.util.Enumeration p = ks.aliases();
+ while(p.hasMoreElements())
+ {
+ aliasVector.add(p.nextElement());
+ }
+ }
+ catch(Exception e)
+ {
+ clearAlias();
+ return;
+ }
+ finally
+ {
+ try
+ {
+ is.close();
+ }
+ catch(java.io.IOException e)
+ {}
+ }
+ _alias.setModel(new DefaultComboBoxModel(aliasVector));
+ if(selectedAlias != null)
+ {
+ _alias.setSelectedItem(selectedAlias);
+ }
+ }
+ else
+ {
+ clearAlias();
+ }
+ }
+
+ private void clearAlias()
+ {
+ _alias.setModel(new DefaultComboBoxModel());
+ }
+
+ private void selectRegistryUseSSL(boolean selected)
+ {
+ _registryUseSSL.setSelected(selected);
+ _registryUsername.setEnabled(!selected);
+ _registryUsernameLabel.setEnabled(!selected);
+ _registryPassword.setEnabled(!selected);
+ _registryPasswordLabel.setEnabled(!selected);
+
+ if(selected && _registrySSLEnabled.isSelected() == false)
+ {
+ selectRegistrySSLEnabled(selected);
+ }
+ }
+
+ private void selectRouterUseSSL(boolean selected)
+ {
+ _routerUseSSL.setSelected(selected);
+ _routerUsername.setEnabled(!selected);
+ _routerUsernameLabel.setEnabled(!selected);
+ _routerPassword.setEnabled(!selected);
+ _routerPasswordLabel.setEnabled(!selected);
+
+ if(selected && _routerSSLEnabled.isSelected() == false)
+ {
+ selectRouterSSLEnabled(selected);
+ }
+ }
+
+ private void selectRegistrySSLEnabled(boolean selected)
+ {
+ _registrySSLEnabled.setSelected(selected);
+ recursiveSetEnabled(_sslPane, selected);
+ if(!selected && _registryUseSSL.isSelected())
+ {
+ selectRegistryUseSSL(selected);
+ }
+ }
+
+ private void selectRouterSSLEnabled(boolean selected)
+ {
+ _routerSSLEnabled.setSelected(selected);
+ recursiveSetEnabled(_sslPane, selected);
+ if(!selected && _routerUseSSL.isSelected())
+ {
+ selectRouterUseSSL(selected);
+ }
+ }
+
+ private void recursiveSetEnabled(java.awt.Container c, boolean enabled)
+ {
+ for(int i = 0; i < c.getComponentCount(); ++i)
+ {
+ java.awt.Component comp = c.getComponent(i);
+ if(comp instanceof java.awt.Container)
+ {
+ recursiveSetEnabled((java.awt.Container)comp, enabled);
+ }
+ comp.setEnabled(enabled);
+ }
+ c.setEnabled(enabled);
+ }
+
+ private void directTabSelected()
+ {
+ recursiveSetEnabled(_sslPane, _registrySSLEnabled.isSelected());
+ }
+
+ private void routedTabSelected()
+ {
+ recursiveSetEnabled(_sslPane, _routerSSLEnabled.isSelected());
+ }
+
+ private JTabbedPane _mainPane = new JTabbedPane();
+ private JTextField _registryUsername = new JTextField(30);
+ private JLabel _registryUsernameLabel;
+ private JPasswordField _registryPassword = new JPasswordField(30);
+ private JLabel _registryPasswordLabel;
+ private JCheckBox _registryUseSSL;
+ private JCheckBox _registrySSLEnabled;
+ private JTextField _registryInstanceName = new JTextField(30);
+ private JTextField _registryEndpoints = new JTextField(30);
+
+ private JTextField _routerUsername = new JTextField(30);
+ private JLabel _routerUsernameLabel;
+ private JPasswordField _routerPassword = new JPasswordField(30);
+ private JLabel _routerPasswordLabel;
+ private JCheckBox _routerUseSSL;
+ private JCheckBox _routerSSLEnabled;
+ private JTextField _routerInstanceName = new JTextField(30);
+ private JTextField _routerEndpoints = new JTextField(30);
+
+ private JTabbedPane _sslPane = new JTabbedPane();
+ private JTextField _keystore = new JTextField(30);
+ private JPasswordField _keyPassword = new JPasswordField(30);
+
+ private JTextField _advancedKeystore = new JTextField(
+ _keystore.getDocument(), null, 30);
+ private JPasswordField _advancedKeyPassword = new JPasswordField(
+ _keyPassword.getDocument(), null, 30);
+
+ private JPasswordField _keystorePassword = new JPasswordField(30);
+ private JComboBox _alias = new JComboBox();
+
+ private JTextField _truststore = new JTextField(30);
+ private JPasswordField _truststorePassword = new JPasswordField(30);
+
+ private String _keystoreType;
+ }
+
+
+ //
+ // We create a brand new Pinger thread for each session
+ //
+ class Pinger extends Thread
+ {
+ Pinger(AdminSessionPrx session, long period)
+ {
+ _session = session;
+ _period = period;
+ }
+
+ public synchronized void run()
+ {
+ do
+ {
+ try
+ {
+ _session.keepAlive();
+ }
+ catch(final Ice.LocalException e)
+ {
+ _done = true;
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ sessionLost("Failed to contact the IceGrid registry: "
+ + e.toString());
+ }
+ });
+ }
+
+ if(!_done)
+ {
+ try
+ {
+ wait(_period);
+ }
+ catch(InterruptedException e)
+ {
+ // Ignored
+ }
+ }
+ } while(!_done);
+ }
+
+ public synchronized void done()
+ {
+ if(!_done)
+ {
+ _done = true;
+ notify();
+ }
+ }
+
+ private AdminSessionPrx _session;
+ private long _period;
+ private boolean _done = false;
+ }
+
+
+
+ SessionKeeper(Coordinator coordinator)
+ {
+ _coordinator = coordinator;
+ _loginDialog = new LoginDialog();
+ _loginPrefs = coordinator.getPrefs().node("Connection");
+ }
+
+ //
+ // Runs in UI thread
+ //
+ void createSession()
+ {
+ _loginInfo = new LoginInfo(_loginPrefs, _coordinator);
+ _loginDialog.showDialog();
+ }
+
+ void relog(boolean showDialog)
+ {
+ if(_loginInfo == null)
+ {
+ createSession();
+ }
+ else
+ {
+ if(showDialog || !login(_coordinator.getMainFrame()))
+ {
+ _loginDialog.showDialog();
+ }
+ }
+ }
+
+ private boolean login(Component parent)
+ {
+ if(_session != null)
+ {
+ logout(true);
+ }
+ assert _session == null;
+
+ Cursor oldCursor = parent.getCursor();
+ try
+ {
+ parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ AdminSessionPrx session = _coordinator.login(_loginInfo, parent);
+ if(session == null)
+ {
+ return false;
+ }
+ _coordinator.getStatusBar().setConnected(true);
+
+ try
+ {
+ _session = new Session(session, parent);
+ }
+ catch(Ice.LocalException e)
+ {
+ return false;
+ }
+ _loginInfo.save();
+ }
+ finally
+ {
+ parent.setCursor(oldCursor);
+ }
+ return true;
+ }
+
+ void sessionLost(String message)
+ {
+ JOptionPane.showMessageDialog(
+ _coordinator.getMainFrame(),
+ message,
+ "Session lost",
+ JOptionPane.ERROR_MESSAGE);
+
+ logout(false);
+ }
+
+ void logout(boolean destroySession)
+ {
+ if(_session != null) // TODO: XXX: Review: The Session constructor might throw
+ {
+ _session.close(destroySession);
+ _coordinator.sessionLost();
+ _session = null;
+ }
+ }
+
+ AdminSessionPrx getSession()
+ {
+ return _session == null ? null : _session.getSession();
+ }
+
+ AdminPrx getAdmin()
+ {
+ return _session == null ? null : _session.getAdmin();
+ }
+
+ AdminPrx getRoutedAdmin()
+ {
+ return _session == null ? null : _session.getRoutedAdmin();
+ }
+
+ private LoginDialog _loginDialog;
+ private LoginInfo _loginInfo;
+
+ private Coordinator _coordinator;
+ private Preferences _loginPrefs;
+
+ private Session _session;
+}
diff --git a/java/src/IceGridGUI/StatusBar.java b/java/src/IceGridGUI/StatusBar.java
index 31164ceeab8..04787157b8e 100755
--- a/java/src/IceGridGUI/StatusBar.java
+++ b/java/src/IceGridGUI/StatusBar.java
@@ -1,15 +1,15 @@
-// **********************************************************************
-//
-// 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;
-
-public interface StatusBar
-{
- void setText(String text);
- void setConnected(boolean connected);
-}
+// **********************************************************************
+//
+// 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;
+
+public interface StatusBar
+{
+ void setText(String text);
+ void setConnected(boolean connected);
+}
diff --git a/java/src/IceGridGUI/Tab.java b/java/src/IceGridGUI/Tab.java
index 0c4e14c1fbe..e8edce7a68d 100755
--- a/java/src/IceGridGUI/Tab.java
+++ b/java/src/IceGridGUI/Tab.java
@@ -1,27 +1,27 @@
-// **********************************************************************
-//
-// 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;
-
-public interface Tab
-{
- void selected();
-
- void showNode(TreeNodeBase node);
- void refresh();
-
- void back();
- void forward();
-
- boolean close();
-
- void save();
- void saveToRegistry();
- void saveToFile();
- void discardUpdates();
-}
+// **********************************************************************
+//
+// 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;
+
+public interface Tab
+{
+ void selected();
+
+ void showNode(TreeNodeBase node);
+ void refresh();
+
+ void back();
+ void forward();
+
+ boolean close();
+
+ void save();
+ void saveToRegistry();
+ void saveToFile();
+ void discardUpdates();
+}
diff --git a/java/src/IceGridGUI/TreeNodeBase.java b/java/src/IceGridGUI/TreeNodeBase.java
index c46d807737c..b9d52629983 100755
--- a/java/src/IceGridGUI/TreeNodeBase.java
+++ b/java/src/IceGridGUI/TreeNodeBase.java
@@ -1,350 +1,350 @@
-// **********************************************************************
-//
-// 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;
-
-import java.util.Enumeration;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.JPopupMenu;
-
-//
-// This class behaves like a leaf; derived class that represent non-leaf nodes must
-// override various methods.
-//
-public class TreeNodeBase implements javax.swing.tree.TreeNode, TreeCellRenderer
-{
- public Coordinator getCoordinator()
- {
- return _parent.getCoordinator();
- }
-
- public Enumeration children()
- {
- return new Enumeration()
- {
- public boolean hasMoreElements()
- {
- return false;
- }
-
- public Object nextElement()
- {
- throw new java.util.NoSuchElementException();
- }
- };
- }
-
- public boolean getAllowsChildren()
- {
- return false;
- }
-
- public javax.swing.tree.TreeNode getChildAt(int childIndex)
- {
- return null;
- }
-
- public int getChildCount()
- {
- return 0;
- }
-
- public int getIndex(javax.swing.tree.TreeNode node)
- {
- return -1;
- }
-
- public javax.swing.tree.TreeNode getParent()
- {
- return _parent;
- }
-
- public boolean isLeaf()
- {
- return true;
- }
-
- public Component getTreeCellRendererComponent(
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus)
- {
- return null;
- }
-
- public String toString()
- {
- return _id;
- }
-
- public JPopupMenu getPopupMenu()
- {
- return null;
- }
-
- public String getId()
- {
- return _id;
- }
-
- public TreePath getPath()
- {
- if(_parent == null)
- {
- return new TreePath(this);
- }
- else
- {
- return _parent.getPath().pathByAddingChild(this);
- }
- }
-
- public java.util.LinkedList getFullId()
- {
- java.util.LinkedList result = _parent == null ?
- new java.util.LinkedList() :
- _parent.getFullId();
-
- result.add(_id);
- return result;
- }
-
- public TreeNodeBase findChild(String id)
- {
- Enumeration p = children();
- while(p.hasMoreElements())
- {
- TreeNodeBase child = (TreeNodeBase)p.nextElement();
- if(child.getId().equals(id))
- {
- return child;
- }
- }
- return null;
- }
-
- protected String makeNewChildId(String base)
- {
- String id = base;
- int i = 0;
- while(findChild(id) != null)
- {
- id = base + "-" + (++i);
- }
- return id;
- }
-
- protected TreeNodeBase(TreeNodeBase parent, String id)
- {
- _parent = parent;
- _id = id;
- }
-
- //
- // Helper functions
- //
- protected boolean insertSortedChild(TreeNodeBase newChild, java.util.List children,
- DefaultTreeModel treeModel)
- {
- String id = newChild.getId();
- int i;
- for(i = 0; i < children.size(); ++i)
- {
- String otherId = ((TreeNodeBase)children.get(i)).getId();
- int cmp = id.compareTo(otherId);
-
- if(cmp == 0)
- {
- return false;
- }
- else if(cmp < 0)
- {
- break;
- }
- }
- children.add(i, newChild);
-
- if(treeModel != null)
- {
- treeModel.nodesWereInserted(this, new int[]{getIndex(newChild)});
- }
- return true;
- }
-
- protected String insertSortedChildren(java.util.List newChildren,
- java.util.List intoChildren,
- DefaultTreeModel treeModel)
- {
- TreeNodeBase[] children = (TreeNodeBase[])newChildren.toArray(new TreeNodeBase[0]);
- java.util.Arrays.sort(children, _childComparator);
-
- int[] indices = new int[children.length];
-
- int offset = -1;
-
- int i = 0;
- boolean checkInsert = true;
- for(int j = 0; j < children.length; ++j)
- {
- String id = children[j].getId();
-
- if(checkInsert)
- {
- while(i < intoChildren.size())
- {
- TreeNodeBase existingChild = (TreeNodeBase)intoChildren.get(i);
- int cmp = id.compareTo(existingChild.getId());
- if(cmp == 0)
- {
- return id;
- }
- if(cmp < 0)
- {
- break; // while
- }
- i++;
- }
-
- if(i < intoChildren.size())
- {
- // Insert here, and increment i (since children is sorted)
- intoChildren.add(i, children[j]);
- if(offset == -1)
- {
- offset = getIndex((TreeNodeBase)intoChildren.get(0));
- }
-
- indices[j] = offset + i;
- i++; continue; // for
- }
- else
- {
- checkInsert = false;
- }
- }
-
- //
- // Append
- //
- intoChildren.add(children[j]);
- if(offset == -1)
- {
- offset = getIndex((TreeNodeBase)intoChildren.get(0));
- }
- indices[j] = offset + i;
- i++;
- }
-
- if(treeModel != null)
- {
- treeModel.nodesWereInserted(this, indices);
- }
-
- return null;
- }
-
- protected void removeSortedChildren(String[] childIds,
- java.util.List fromChildren,
- DefaultTreeModel treeModel)
- {
- if(childIds.length == 0)
- {
- return; // nothing to do
- }
- assert fromChildren.size() > 0;
-
- String[] ids = (String[])childIds.clone();
- java.util.Arrays.sort(ids);
-
- Object[] childrenToRemove = new Object[ids.length];
- int[] indices = new int[ids.length];
-
- int i = getIndex((TreeNodeBase)fromChildren.get(0));
- int j = 0;
- java.util.Iterator p = fromChildren.iterator();
-
- while(p.hasNext() && j < ids.length)
- {
- TreeNodeBase child = (TreeNodeBase)p.next();
- if(ids[j].equals(child.getId()))
- {
- childrenToRemove[j] = child;
- indices[j] = i;
- p.remove();
- ++j;
- }
- ++i;
- }
-
- //
- // Should be all removed
- //
- assert(j == ids.length);
-
- if(treeModel != null)
- {
- treeModel.nodesWereRemoved(this, indices, childrenToRemove);
- }
- }
-
- protected void childrenChanged(java.util.List children, DefaultTreeModel treeModel)
- {
- int[] indices = new int[children.size()];
- int i = 0;
- java.util.Iterator p = children.iterator();
- while(p.hasNext())
- {
- TreeNodeBase child = (TreeNodeBase)p.next();
- indices[i++] = getIndex(child);
- }
- treeModel.nodesChanged(this, indices);
- }
-
- public int[] resize(int[] array, int size)
- {
- int[] result = new int[size];
- System.arraycopy(array, 0, result, 0, size);
- return result;
- }
-
- protected TreeNodeBase find(String id, java.util.List inList)
- {
- java.util.Iterator p = inList.iterator();
- while(p.hasNext())
- {
- TreeNodeBase node = (TreeNodeBase)p.next();
- if(node.getId().equals(id))
- {
- return node;
- }
- }
- return null;
- }
-
- protected TreeNodeBase _parent;
- protected String _id;
-
- protected java.util.Comparator _childComparator = new java.util.Comparator()
- {
- public int compare(Object o1, Object o2)
- {
- TreeNodeBase child1 = (TreeNodeBase)o1;
- TreeNodeBase child2 = (TreeNodeBase)o2;
- return child1.getId().compareTo(child2.getId());
- }
- };
-}
+// **********************************************************************
+//
+// 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;
+
+import java.util.Enumeration;
+
+import java.awt.Component;
+import javax.swing.JTree;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeCellRenderer;
+import javax.swing.JPopupMenu;
+
+//
+// This class behaves like a leaf; derived class that represent non-leaf nodes must
+// override various methods.
+//
+public class TreeNodeBase implements javax.swing.tree.TreeNode, TreeCellRenderer
+{
+ public Coordinator getCoordinator()
+ {
+ return _parent.getCoordinator();
+ }
+
+ public Enumeration children()
+ {
+ return new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ throw new java.util.NoSuchElementException();
+ }
+ };
+ }
+
+ public boolean getAllowsChildren()
+ {
+ return false;
+ }
+
+ public javax.swing.tree.TreeNode getChildAt(int childIndex)
+ {
+ return null;
+ }
+
+ public int getChildCount()
+ {
+ return 0;
+ }
+
+ public int getIndex(javax.swing.tree.TreeNode node)
+ {
+ return -1;
+ }
+
+ public javax.swing.tree.TreeNode getParent()
+ {
+ return _parent;
+ }
+
+ public boolean isLeaf()
+ {
+ return true;
+ }
+
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus)
+ {
+ return null;
+ }
+
+ public String toString()
+ {
+ return _id;
+ }
+
+ public JPopupMenu getPopupMenu()
+ {
+ return null;
+ }
+
+ public String getId()
+ {
+ return _id;
+ }
+
+ public TreePath getPath()
+ {
+ if(_parent == null)
+ {
+ return new TreePath(this);
+ }
+ else
+ {
+ return _parent.getPath().pathByAddingChild(this);
+ }
+ }
+
+ public java.util.LinkedList getFullId()
+ {
+ java.util.LinkedList result = _parent == null ?
+ new java.util.LinkedList() :
+ _parent.getFullId();
+
+ result.add(_id);
+ return result;
+ }
+
+ public TreeNodeBase findChild(String id)
+ {
+ Enumeration p = children();
+ while(p.hasMoreElements())
+ {
+ TreeNodeBase child = (TreeNodeBase)p.nextElement();
+ if(child.getId().equals(id))
+ {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ protected String makeNewChildId(String base)
+ {
+ String id = base;
+ int i = 0;
+ while(findChild(id) != null)
+ {
+ id = base + "-" + (++i);
+ }
+ return id;
+ }
+
+ protected TreeNodeBase(TreeNodeBase parent, String id)
+ {
+ _parent = parent;
+ _id = id;
+ }
+
+ //
+ // Helper functions
+ //
+ protected boolean insertSortedChild(TreeNodeBase newChild, java.util.List children,
+ DefaultTreeModel treeModel)
+ {
+ String id = newChild.getId();
+ int i;
+ for(i = 0; i < children.size(); ++i)
+ {
+ String otherId = ((TreeNodeBase)children.get(i)).getId();
+ int cmp = id.compareTo(otherId);
+
+ if(cmp == 0)
+ {
+ return false;
+ }
+ else if(cmp < 0)
+ {
+ break;
+ }
+ }
+ children.add(i, newChild);
+
+ if(treeModel != null)
+ {
+ treeModel.nodesWereInserted(this, new int[]{getIndex(newChild)});
+ }
+ return true;
+ }
+
+ protected String insertSortedChildren(java.util.List newChildren,
+ java.util.List intoChildren,
+ DefaultTreeModel treeModel)
+ {
+ TreeNodeBase[] children = (TreeNodeBase[])newChildren.toArray(new TreeNodeBase[0]);
+ java.util.Arrays.sort(children, _childComparator);
+
+ int[] indices = new int[children.length];
+
+ int offset = -1;
+
+ int i = 0;
+ boolean checkInsert = true;
+ for(int j = 0; j < children.length; ++j)
+ {
+ String id = children[j].getId();
+
+ if(checkInsert)
+ {
+ while(i < intoChildren.size())
+ {
+ TreeNodeBase existingChild = (TreeNodeBase)intoChildren.get(i);
+ int cmp = id.compareTo(existingChild.getId());
+ if(cmp == 0)
+ {
+ return id;
+ }
+ if(cmp < 0)
+ {
+ break; // while
+ }
+ i++;
+ }
+
+ if(i < intoChildren.size())
+ {
+ // Insert here, and increment i (since children is sorted)
+ intoChildren.add(i, children[j]);
+ if(offset == -1)
+ {
+ offset = getIndex((TreeNodeBase)intoChildren.get(0));
+ }
+
+ indices[j] = offset + i;
+ i++; continue; // for
+ }
+ else
+ {
+ checkInsert = false;
+ }
+ }
+
+ //
+ // Append
+ //
+ intoChildren.add(children[j]);
+ if(offset == -1)
+ {
+ offset = getIndex((TreeNodeBase)intoChildren.get(0));
+ }
+ indices[j] = offset + i;
+ i++;
+ }
+
+ if(treeModel != null)
+ {
+ treeModel.nodesWereInserted(this, indices);
+ }
+
+ return null;
+ }
+
+ protected void removeSortedChildren(String[] childIds,
+ java.util.List fromChildren,
+ DefaultTreeModel treeModel)
+ {
+ if(childIds.length == 0)
+ {
+ return; // nothing to do
+ }
+ assert fromChildren.size() > 0;
+
+ String[] ids = (String[])childIds.clone();
+ java.util.Arrays.sort(ids);
+
+ Object[] childrenToRemove = new Object[ids.length];
+ int[] indices = new int[ids.length];
+
+ int i = getIndex((TreeNodeBase)fromChildren.get(0));
+ int j = 0;
+ java.util.Iterator p = fromChildren.iterator();
+
+ while(p.hasNext() && j < ids.length)
+ {
+ TreeNodeBase child = (TreeNodeBase)p.next();
+ if(ids[j].equals(child.getId()))
+ {
+ childrenToRemove[j] = child;
+ indices[j] = i;
+ p.remove();
+ ++j;
+ }
+ ++i;
+ }
+
+ //
+ // Should be all removed
+ //
+ assert(j == ids.length);
+
+ if(treeModel != null)
+ {
+ treeModel.nodesWereRemoved(this, indices, childrenToRemove);
+ }
+ }
+
+ protected void childrenChanged(java.util.List children, DefaultTreeModel treeModel)
+ {
+ int[] indices = new int[children.size()];
+ int i = 0;
+ java.util.Iterator p = children.iterator();
+ while(p.hasNext())
+ {
+ TreeNodeBase child = (TreeNodeBase)p.next();
+ indices[i++] = getIndex(child);
+ }
+ treeModel.nodesChanged(this, indices);
+ }
+
+ public int[] resize(int[] array, int size)
+ {
+ int[] result = new int[size];
+ System.arraycopy(array, 0, result, 0, size);
+ return result;
+ }
+
+ protected TreeNodeBase find(String id, java.util.List inList)
+ {
+ java.util.Iterator p = inList.iterator();
+ while(p.hasNext())
+ {
+ TreeNodeBase node = (TreeNodeBase)p.next();
+ if(node.getId().equals(id))
+ {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ protected TreeNodeBase _parent;
+ protected String _id;
+
+ protected java.util.Comparator _childComparator = new java.util.Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ TreeNodeBase child1 = (TreeNodeBase)o1;
+ TreeNodeBase child2 = (TreeNodeBase)o2;
+ return child1.getId().compareTo(child2.getId());
+ }
+ };
+}
diff --git a/java/src/IceGridGUI/Utils.java b/java/src/IceGridGUI/Utils.java
index 6deaca51d24..2abcbe3b519 100755
--- a/java/src/IceGridGUI/Utils.java
+++ b/java/src/IceGridGUI/Utils.java
@@ -1,416 +1,416 @@
-// **********************************************************************
-//
-// 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;
-
-import javax.swing.ImageIcon;
-import IceGrid.*;
-
-public class Utils
-{
- static public ImageIcon getIcon(String path)
- {
- java.net.URL imgURL = Utils.class.getResource(path);
- if(imgURL == null)
- {
- System.err.println("Could not find icon " + path);
- return null;
- }
- else
- {
- return new ImageIcon(imgURL);
- }
- }
-
- static public interface Stringifier
- {
- public String toString(Object obj);
- }
-
- //
- // Stringify helpers
- //
- static public String stringify(java.util.Collection col,
- Stringifier stringifier,
- String separator,
- Ice.StringHolder toolTipHolder)
- {
- String result = "";
- if(toolTipHolder != null)
- {
- toolTipHolder.value = null;
- }
-
- java.util.Iterator p = col.iterator();
-
- boolean firstElement = true;
- while(p.hasNext())
- {
- String elt = stringifier.toString(p.next());
- if(elt != null)
- {
- if(firstElement)
- {
- firstElement = false;
- if(toolTipHolder != null)
- {
- toolTipHolder.value = "<html>";
- }
- }
- else
- {
- result += separator;
- if(toolTipHolder != null)
- {
- toolTipHolder.value += "<br>";
- }
- }
-
- if(elt.length() == 0)
- {
- result += "\"\"";
- }
- else if(elt.matches("\\S*"))
- {
- //
- // Only non-whitespace characters
- //
- result += elt;
- }
- else
- {
- result += '"' + elt + '"';
- }
-
- if(toolTipHolder != null)
- {
- toolTipHolder.value += elt;
- }
- }
- }
- if(toolTipHolder != null && toolTipHolder.value != null)
- {
- toolTipHolder.value += "</html>";
- }
-
- return result;
- }
-
- static public String stringify(java.util.Collection col,
- String separator,
- Ice.StringHolder toolTipHolder)
- {
-
- Stringifier stringifier = new Stringifier()
- {
- public String toString(Object obj)
- {
- return (String)obj;
- }
- };
- return stringify(col, stringifier, separator, toolTipHolder);
-
- }
-
- static public String stringify(String[] stringSeq, String separator,
- Ice.StringHolder toolTipHolder)
- {
-
- return stringify(java.util.Arrays.asList(stringSeq), separator, toolTipHolder);
- }
-
- static public String stringify(java.util.Map stringMap,
- final String pairSeparator,
- String separator,
- Ice.StringHolder toolTipHolder)
- {
- Stringifier stringifier = new Stringifier()
- {
- public String toString(Object obj)
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)obj;
- return (String)entry.getKey() + pairSeparator + (String)entry.getValue();
- }
- };
-
- return stringify(stringMap.entrySet(), stringifier, separator, toolTipHolder);
- }
-
- static public class Resolver
- {
- //
- // Application-level resolver
- //
- public Resolver(java.util.Map variables)
- {
- this(new java.util.Map[]{variables});
- }
-
- public Resolver(java.util.Map[] variables)
- {
- _variables = variables;
- _predefinedVariables = new java.util.HashMap();
-
- _parameters = null;
- _subResolver = this;
- }
-
- //
- // Resolver for instance; in-parameters are not yet substituted
- //
- public Resolver(Resolver parent, java.util.Map parameters,
- java.util.Map defaults)
- {
- _variables = parent._variables;
-
- //
- // Whenever the parent's predefined variables change, the resolver
- // must be recreated
- //
- reset(parent, parameters, defaults);
- }
-
- //
- // Resolver for plain server or service
- //
- public Resolver(Resolver parent)
- {
- _variables = parent._variables;
- _predefinedVariables = new java.util.HashMap(parent._predefinedVariables);
- _parameters = parent._parameters;
- if(_parameters == null)
- {
- _subResolver = this;
- }
- else
- {
- _subResolver = new Resolver(_variables, _predefinedVariables);
- }
- }
-
- private Resolver(java.util.Map[] variables,
- java.util.Map predefinedVariables)
- {
- _variables = variables;
- _predefinedVariables = _predefinedVariables;
-
- _parameters = null;
- _subResolver = this;
- }
-
- public String find(String name)
- {
- if(_parameters != null)
- {
- Object obj = _parameters.get(name);
- if(obj != null)
- {
- return (String)obj;
- }
- }
-
- Object obj = _predefinedVariables.get(name);
- if(obj != null)
- {
- return (String)obj;
- }
-
- for(int i = 0; i < _variables.length; ++i)
- {
- obj = _variables[i].get(name);
- if(obj != null)
- {
- return _subResolver.substitute((String)obj);
- }
- }
- return null;
- }
-
- //
- // Set a pre-defined variable
- //
- public void put(String name, String value)
- {
- _predefinedVariables.put(name, value);
- }
-
- //
- // Reset parameters and pre-defined variables
- //
- public void reset(Resolver parent, java.util.Map parameters,
- java.util.Map defaults)
- {
- assert _variables == parent._variables;
- _predefinedVariables = new java.util.HashMap(parent._predefinedVariables);
-
- _parameters = parent.substituteParameterValues(parameters, defaults);
- _subResolver = new Resolver(_variables, _predefinedVariables);
- }
-
- //
- // The sorted substituted parameters
- //
- public java.util.Map getParameters()
- {
- return _parameters;
- }
-
- public String substitute(String input)
- {
- if(input == null)
- {
- return input;
- }
-
- int beg = 0;
- int end = 0;
-
- while((beg = input.indexOf("${", beg)) != -1)
- {
- if(beg > 0 && input.charAt(beg - 1) == '$')
- {
- int escape = beg - 1;
- while(escape > 0 && input.charAt(escape - 1) == '$')
- {
- --escape;
- }
-
- input = input.substring(0, escape) + input.substring(beg - (beg - escape) / 2);
- if((beg - escape) % 2 != 0)
- {
- ++beg;
- continue;
- }
- else
- {
- beg -= (beg - escape) / 2;
- }
- }
-
- end = input.indexOf('}', beg);
- if(end == -1)
- {
- //
- // Malformed variable, can't substitute anything else
- //
- return input;
- }
-
- String name = input.substring(beg + 2, end);
-
- //
- // Resolve name
- //
- String val = find(name);
- if(val != null)
- {
- input = input.substring(0, beg) + val + input.substring(end + 1);
- beg += val.length();
- }
- else
- {
- //
- // No substitution, keep ${name} in the result
- //
- ++beg;
- }
- }
- return input;
- }
-
- //
- // Substitute all the values from the input map
- //
- public java.util.Map substituteParameterValues(java.util.Map input,
- java.util.Map defaults)
- {
- 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(), substitute((String)entry.getValue()));
- }
- p = defaults.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
- if(!result.containsKey(entry.getKey()))
- {
- result.put(entry.getKey(), substitute((String)entry.getValue()));
- }
- }
- return result;
- }
-
- private java.util.Map[] _variables;
- private java.util.Map _parameters;
- private java.util.Map _predefinedVariables;
-
- private Resolver _subResolver;
- }
-
-
- static public String substitute(String input, Resolver resolver)
- {
- if(resolver != null)
- {
- return resolver.substitute(input);
- }
- else
- {
- return input;
- }
- }
-
- //
- // An expanded property set (i.e. containing other property sets)
- //
- static public class ExpandedPropertySet
- {
- public ExpandedPropertySet[] references;
- public java.util.List properties; // list of PropertyDescriptor
- }
-
- static public java.util.SortedMap propertySetToMap(
- ExpandedPropertySet propertySet,
- ExpandedPropertySet instancePropertySet, // can be null
- Resolver resolver)
- {
- java.util.SortedMap toMap = new java.util.TreeMap();
-
- addSet(propertySet, resolver, toMap);
- if(instancePropertySet != null)
- {
- addSet(instancePropertySet, resolver, toMap);
- }
- return toMap;
- }
-
- static private void addSet(ExpandedPropertySet set, Resolver resolver,
- java.util.SortedMap toMap)
- {
- for(int i = 0; i < set.references.length; ++i)
- {
- addSet(set.references[i], resolver, toMap);
- }
-
- java.util.Iterator p = set.properties.iterator();
- while(p.hasNext())
- {
- PropertyDescriptor pd = (PropertyDescriptor)p.next();
- String name = (String)pd.name;
- String val = (String)pd.value;
-
- name = substitute(pd.name, resolver);
- val = substitute(pd.value, resolver);
-
- toMap.put(name, val);
- }
- }
-}
+// **********************************************************************
+//
+// 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;
+
+import javax.swing.ImageIcon;
+import IceGrid.*;
+
+public class Utils
+{
+ static public ImageIcon getIcon(String path)
+ {
+ java.net.URL imgURL = Utils.class.getResource(path);
+ if(imgURL == null)
+ {
+ System.err.println("Could not find icon " + path);
+ return null;
+ }
+ else
+ {
+ return new ImageIcon(imgURL);
+ }
+ }
+
+ static public interface Stringifier
+ {
+ public String toString(Object obj);
+ }
+
+ //
+ // Stringify helpers
+ //
+ static public String stringify(java.util.Collection col,
+ Stringifier stringifier,
+ String separator,
+ Ice.StringHolder toolTipHolder)
+ {
+ String result = "";
+ if(toolTipHolder != null)
+ {
+ toolTipHolder.value = null;
+ }
+
+ java.util.Iterator p = col.iterator();
+
+ boolean firstElement = true;
+ while(p.hasNext())
+ {
+ String elt = stringifier.toString(p.next());
+ if(elt != null)
+ {
+ if(firstElement)
+ {
+ firstElement = false;
+ if(toolTipHolder != null)
+ {
+ toolTipHolder.value = "<html>";
+ }
+ }
+ else
+ {
+ result += separator;
+ if(toolTipHolder != null)
+ {
+ toolTipHolder.value += "<br>";
+ }
+ }
+
+ if(elt.length() == 0)
+ {
+ result += "\"\"";
+ }
+ else if(elt.matches("\\S*"))
+ {
+ //
+ // Only non-whitespace characters
+ //
+ result += elt;
+ }
+ else
+ {
+ result += '"' + elt + '"';
+ }
+
+ if(toolTipHolder != null)
+ {
+ toolTipHolder.value += elt;
+ }
+ }
+ }
+ if(toolTipHolder != null && toolTipHolder.value != null)
+ {
+ toolTipHolder.value += "</html>";
+ }
+
+ return result;
+ }
+
+ static public String stringify(java.util.Collection col,
+ String separator,
+ Ice.StringHolder toolTipHolder)
+ {
+
+ Stringifier stringifier = new Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ return (String)obj;
+ }
+ };
+ return stringify(col, stringifier, separator, toolTipHolder);
+
+ }
+
+ static public String stringify(String[] stringSeq, String separator,
+ Ice.StringHolder toolTipHolder)
+ {
+
+ return stringify(java.util.Arrays.asList(stringSeq), separator, toolTipHolder);
+ }
+
+ static public String stringify(java.util.Map stringMap,
+ final String pairSeparator,
+ String separator,
+ Ice.StringHolder toolTipHolder)
+ {
+ Stringifier stringifier = new Stringifier()
+ {
+ public String toString(Object obj)
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)obj;
+ return (String)entry.getKey() + pairSeparator + (String)entry.getValue();
+ }
+ };
+
+ return stringify(stringMap.entrySet(), stringifier, separator, toolTipHolder);
+ }
+
+ static public class Resolver
+ {
+ //
+ // Application-level resolver
+ //
+ public Resolver(java.util.Map variables)
+ {
+ this(new java.util.Map[]{variables});
+ }
+
+ public Resolver(java.util.Map[] variables)
+ {
+ _variables = variables;
+ _predefinedVariables = new java.util.HashMap();
+
+ _parameters = null;
+ _subResolver = this;
+ }
+
+ //
+ // Resolver for instance; in-parameters are not yet substituted
+ //
+ public Resolver(Resolver parent, java.util.Map parameters,
+ java.util.Map defaults)
+ {
+ _variables = parent._variables;
+
+ //
+ // Whenever the parent's predefined variables change, the resolver
+ // must be recreated
+ //
+ reset(parent, parameters, defaults);
+ }
+
+ //
+ // Resolver for plain server or service
+ //
+ public Resolver(Resolver parent)
+ {
+ _variables = parent._variables;
+ _predefinedVariables = new java.util.HashMap(parent._predefinedVariables);
+ _parameters = parent._parameters;
+ if(_parameters == null)
+ {
+ _subResolver = this;
+ }
+ else
+ {
+ _subResolver = new Resolver(_variables, _predefinedVariables);
+ }
+ }
+
+ private Resolver(java.util.Map[] variables,
+ java.util.Map predefinedVariables)
+ {
+ _variables = variables;
+ _predefinedVariables = _predefinedVariables;
+
+ _parameters = null;
+ _subResolver = this;
+ }
+
+ public String find(String name)
+ {
+ if(_parameters != null)
+ {
+ Object obj = _parameters.get(name);
+ if(obj != null)
+ {
+ return (String)obj;
+ }
+ }
+
+ Object obj = _predefinedVariables.get(name);
+ if(obj != null)
+ {
+ return (String)obj;
+ }
+
+ for(int i = 0; i < _variables.length; ++i)
+ {
+ obj = _variables[i].get(name);
+ if(obj != null)
+ {
+ return _subResolver.substitute((String)obj);
+ }
+ }
+ return null;
+ }
+
+ //
+ // Set a pre-defined variable
+ //
+ public void put(String name, String value)
+ {
+ _predefinedVariables.put(name, value);
+ }
+
+ //
+ // Reset parameters and pre-defined variables
+ //
+ public void reset(Resolver parent, java.util.Map parameters,
+ java.util.Map defaults)
+ {
+ assert _variables == parent._variables;
+ _predefinedVariables = new java.util.HashMap(parent._predefinedVariables);
+
+ _parameters = parent.substituteParameterValues(parameters, defaults);
+ _subResolver = new Resolver(_variables, _predefinedVariables);
+ }
+
+ //
+ // The sorted substituted parameters
+ //
+ public java.util.Map getParameters()
+ {
+ return _parameters;
+ }
+
+ public String substitute(String input)
+ {
+ if(input == null)
+ {
+ return input;
+ }
+
+ int beg = 0;
+ int end = 0;
+
+ while((beg = input.indexOf("${", beg)) != -1)
+ {
+ if(beg > 0 && input.charAt(beg - 1) == '$')
+ {
+ int escape = beg - 1;
+ while(escape > 0 && input.charAt(escape - 1) == '$')
+ {
+ --escape;
+ }
+
+ input = input.substring(0, escape) + input.substring(beg - (beg - escape) / 2);
+ if((beg - escape) % 2 != 0)
+ {
+ ++beg;
+ continue;
+ }
+ else
+ {
+ beg -= (beg - escape) / 2;
+ }
+ }
+
+ end = input.indexOf('}', beg);
+ if(end == -1)
+ {
+ //
+ // Malformed variable, can't substitute anything else
+ //
+ return input;
+ }
+
+ String name = input.substring(beg + 2, end);
+
+ //
+ // Resolve name
+ //
+ String val = find(name);
+ if(val != null)
+ {
+ input = input.substring(0, beg) + val + input.substring(end + 1);
+ beg += val.length();
+ }
+ else
+ {
+ //
+ // No substitution, keep ${name} in the result
+ //
+ ++beg;
+ }
+ }
+ return input;
+ }
+
+ //
+ // Substitute all the values from the input map
+ //
+ public java.util.Map substituteParameterValues(java.util.Map input,
+ java.util.Map defaults)
+ {
+ 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(), substitute((String)entry.getValue()));
+ }
+ p = defaults.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry entry = (java.util.Map.Entry)p.next();
+ if(!result.containsKey(entry.getKey()))
+ {
+ result.put(entry.getKey(), substitute((String)entry.getValue()));
+ }
+ }
+ return result;
+ }
+
+ private java.util.Map[] _variables;
+ private java.util.Map _parameters;
+ private java.util.Map _predefinedVariables;
+
+ private Resolver _subResolver;
+ }
+
+
+ static public String substitute(String input, Resolver resolver)
+ {
+ if(resolver != null)
+ {
+ return resolver.substitute(input);
+ }
+ else
+ {
+ return input;
+ }
+ }
+
+ //
+ // An expanded property set (i.e. containing other property sets)
+ //
+ static public class ExpandedPropertySet
+ {
+ public ExpandedPropertySet[] references;
+ public java.util.List properties; // list of PropertyDescriptor
+ }
+
+ static public java.util.SortedMap propertySetToMap(
+ ExpandedPropertySet propertySet,
+ ExpandedPropertySet instancePropertySet, // can be null
+ Resolver resolver)
+ {
+ java.util.SortedMap toMap = new java.util.TreeMap();
+
+ addSet(propertySet, resolver, toMap);
+ if(instancePropertySet != null)
+ {
+ addSet(instancePropertySet, resolver, toMap);
+ }
+ return toMap;
+ }
+
+ static private void addSet(ExpandedPropertySet set, Resolver resolver,
+ java.util.SortedMap toMap)
+ {
+ for(int i = 0; i < set.references.length; ++i)
+ {
+ addSet(set.references[i], resolver, toMap);
+ }
+
+ java.util.Iterator p = set.properties.iterator();
+ while(p.hasNext())
+ {
+ PropertyDescriptor pd = (PropertyDescriptor)p.next();
+ String name = (String)pd.name;
+ String val = (String)pd.value;
+
+ name = substitute(pd.name, resolver);
+ val = substitute(pd.value, resolver);
+
+ toMap.put(name, val);
+ }
+ }
+}
diff --git a/java/src/IceGridGUI/XMLWriter.java b/java/src/IceGridGUI/XMLWriter.java
index a572455402c..ff5be8555f2 100755
--- a/java/src/IceGridGUI/XMLWriter.java
+++ b/java/src/IceGridGUI/XMLWriter.java
@@ -1,171 +1,171 @@
-// **********************************************************************
-//
-// 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;
-
-import java.io.*;
-
-//
-// Helper class to write XML files
-//
-public class XMLWriter
-{
- public XMLWriter(File file) throws FileNotFoundException, IOException
- {
- try
- {
- _writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
- }
- catch(UnsupportedEncodingException e)
- {
- assert false;
- }
- _writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + _newline);
- _writer.write("<!-- This file was written by IceGrid Admin -->" + _newline);
- }
-
- public void writeElement(String name, java.util.List attributes)
- throws IOException
- {
- _writer.write(_indent);
- _writer.write("<" + name);
- writeAttributes(attributes);
- _writer.write("/>" + _newline);
- }
-
- public void writeElement(String name) throws IOException
- {
- writeElement(name, (java.util.List)null);
- }
-
- public void writeElement(String name, String content) throws IOException
- {
- _writer.write(_indent);
- _writer.write("<" + name + ">" + escape(content) +
- "</" + name + ">" + _newline);
- }
-
- public void writeStartTag(String name, java.util.List attributes)
- throws IOException
- {
- _writer.write(_indent);
- _writer.write("<" + name);
- writeAttributes(attributes);
- _writer.write(">");
- _writer.write(_newline);
- increaseIndent();
- }
-
- public void writeStartTag(String name) throws IOException
- {
- writeStartTag(name, null);
- }
-
- public void writeEndTag(String name) throws IOException
- {
- decreaseIndent();
- _writer.write(_indent);
- _writer.write("</" + name + ">" + _newline);
- }
-
- public void close() throws IOException
- {
- _writer.close();
- }
-
- public void flush() throws IOException
- {
- _writer.flush();
- }
-
- private void writeAttributes(java.util.List attributes)
- throws IOException
- {
- if(attributes != null)
- {
- java.util.Iterator p = attributes.iterator();
- while(p.hasNext())
- {
- String[] pair = (String[])p.next();
- _writer.write(" " + pair[0] + "=\"" + pair[1] + "\"");
- }
- }
- }
-
- private void increaseIndent()
- {
- _indent += " ";
- }
-
- private void decreaseIndent()
- {
- if(_indent.length() > 0)
- {
- _indent = _indent.substring(3);
- }
- }
-
- private String
- escape(String input)
- {
- String v = input;
-
- //
- // Find out whether there is a reserved character to avoid
- // conversion if not necessary.
- //
- final String allReserved = "<>'\"&";
- boolean hasReserved = false;
- char[] arr = input.toCharArray();
- for(int i = 0; i < arr.length; i++)
- {
- if(allReserved.indexOf(arr[i]) != -1)
- {
- hasReserved = true;
- break;
- }
- }
- if(hasReserved)
- {
- //
- // First convert all & to &amp;
- //
- if(v.indexOf('&') != -1)
- {
- v = v.replaceAll("&", "&amp;");
- }
-
- //
- // Next convert remaining reserved characters.
- //
- if(v.indexOf('>') != -1)
- {
- v = v.replaceAll(">", "&gt;");
- }
- if(v.indexOf('<') != -1)
- {
- v = v.replaceAll("<", "&lt;");
- }
- if(v.indexOf('\'') != -1)
- {
- v = v.replaceAll("'", "&apos;");
- }
- if(v.indexOf('"') != -1)
- {
- v = v.replaceAll("\"", "&quot;");
- }
- }
- return v;
- }
-
-
- private Writer _writer;
- private String _indent = "";
- private static String _newline = System.getProperty("line.separator");
-}
+// **********************************************************************
+//
+// 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;
+
+import java.io.*;
+
+//
+// Helper class to write XML files
+//
+public class XMLWriter
+{
+ public XMLWriter(File file) throws FileNotFoundException, IOException
+ {
+ try
+ {
+ _writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ assert false;
+ }
+ _writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + _newline);
+ _writer.write("<!-- This file was written by IceGrid Admin -->" + _newline);
+ }
+
+ public void writeElement(String name, java.util.List attributes)
+ throws IOException
+ {
+ _writer.write(_indent);
+ _writer.write("<" + name);
+ writeAttributes(attributes);
+ _writer.write("/>" + _newline);
+ }
+
+ public void writeElement(String name) throws IOException
+ {
+ writeElement(name, (java.util.List)null);
+ }
+
+ public void writeElement(String name, String content) throws IOException
+ {
+ _writer.write(_indent);
+ _writer.write("<" + name + ">" + escape(content) +
+ "</" + name + ">" + _newline);
+ }
+
+ public void writeStartTag(String name, java.util.List attributes)
+ throws IOException
+ {
+ _writer.write(_indent);
+ _writer.write("<" + name);
+ writeAttributes(attributes);
+ _writer.write(">");
+ _writer.write(_newline);
+ increaseIndent();
+ }
+
+ public void writeStartTag(String name) throws IOException
+ {
+ writeStartTag(name, null);
+ }
+
+ public void writeEndTag(String name) throws IOException
+ {
+ decreaseIndent();
+ _writer.write(_indent);
+ _writer.write("</" + name + ">" + _newline);
+ }
+
+ public void close() throws IOException
+ {
+ _writer.close();
+ }
+
+ public void flush() throws IOException
+ {
+ _writer.flush();
+ }
+
+ private void writeAttributes(java.util.List attributes)
+ throws IOException
+ {
+ if(attributes != null)
+ {
+ java.util.Iterator p = attributes.iterator();
+ while(p.hasNext())
+ {
+ String[] pair = (String[])p.next();
+ _writer.write(" " + pair[0] + "=\"" + pair[1] + "\"");
+ }
+ }
+ }
+
+ private void increaseIndent()
+ {
+ _indent += " ";
+ }
+
+ private void decreaseIndent()
+ {
+ if(_indent.length() > 0)
+ {
+ _indent = _indent.substring(3);
+ }
+ }
+
+ private String
+ escape(String input)
+ {
+ String v = input;
+
+ //
+ // Find out whether there is a reserved character to avoid
+ // conversion if not necessary.
+ //
+ final String allReserved = "<>'\"&";
+ boolean hasReserved = false;
+ char[] arr = input.toCharArray();
+ for(int i = 0; i < arr.length; i++)
+ {
+ if(allReserved.indexOf(arr[i]) != -1)
+ {
+ hasReserved = true;
+ break;
+ }
+ }
+ if(hasReserved)
+ {
+ //
+ // First convert all & to &amp;
+ //
+ if(v.indexOf('&') != -1)
+ {
+ v = v.replaceAll("&", "&amp;");
+ }
+
+ //
+ // Next convert remaining reserved characters.
+ //
+ if(v.indexOf('>') != -1)
+ {
+ v = v.replaceAll(">", "&gt;");
+ }
+ if(v.indexOf('<') != -1)
+ {
+ v = v.replaceAll("<", "&lt;");
+ }
+ if(v.indexOf('\'') != -1)
+ {
+ v = v.replaceAll("'", "&apos;");
+ }
+ if(v.indexOf('"') != -1)
+ {
+ v = v.replaceAll("\"", "&quot;");
+ }
+ }
+ return v;
+ }
+
+
+ private Writer _writer;
+ private String _indent = "";
+ private static String _newline = System.getProperty("line.separator");
+}