diff options
Diffstat (limited to 'java/src/IceGridGUI/LiveDeployment')
24 files changed, 4790 insertions, 4790 deletions
diff --git a/java/src/IceGridGUI/LiveDeployment/Adapter.java b/java/src/IceGridGUI/LiveDeployment/Adapter.java index 546f9ffa43c..48cd5e4d1e2 100755 --- a/java/src/IceGridGUI/LiveDeployment/Adapter.java +++ b/java/src/IceGridGUI/LiveDeployment/Adapter.java @@ -26,137 +26,137 @@ class Adapter extends TreeNode { public Editor getEditor() { - if(_editor == null) - { - _editor = new AdapterEditor(); - } - _editor.show(this); - return _editor; + 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) + 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); + 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) + String adapterId, AdapterDescriptor descriptor, Ice.ObjectPrx proxy) { - super(parent, adapterName); - _resolver = resolver; - _adapterId = adapterId; - _descriptor = descriptor; + super(parent, adapterName); + _resolver = resolver; + _adapterId = adapterId; + _descriptor = descriptor; - setCurrentEndpoints(proxy); + setCurrentEndpoints(proxy); } AdapterDescriptor getDescriptor() { - return _descriptor; + return _descriptor; } Utils.Resolver getResolver() { - return _resolver; + return _resolver; } String getCurrentEndpoints() { - return _currentEndpoints; + return _currentEndpoints; } java.util.Map getProperties() { - if(_parent instanceof Server) - { - return ((Server)_parent).getProperties(); - } - else - { - return ((Service)_parent).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; - } + 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; + 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; - } + 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; + } } diff --git a/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java b/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java index 2e77071fdba..f4b64e8a23d 100755 --- a/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/AdapterEditor.java @@ -30,141 +30,141 @@ class AdapterEditor extends Editor { AdapterEditor() { - _currentStatus.setEditable(false); - _currentEndpoints.setEditable(false); - _description.setEditable(false); - _description.setOpaque(false); - _id.setEditable(false); - _replicaGroupId.setEditable(false); - _priority.setEditable(false); - _endpoints.setEditable(false); - _publishedEndpoints.setEditable(false); - _registerProcess.setEnabled(false); - _serverLifetime.setEnabled(false); + _currentStatus.setEditable(false); + _currentEndpoints.setEditable(false); + _description.setEditable(false); + _description.setOpaque(false); + _id.setEditable(false); + _replicaGroupId.setEditable(false); + _priority.setEditable(false); + _endpoints.setEditable(false); + _publishedEndpoints.setEditable(false); + _registerProcess.setEnabled(false); + _serverLifetime.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)); - _priority.setText(resolver.substitute(descriptor.priority)); - - java.util.Map properties = adapter.getProperties(); - - // getId() returns the name of the adapter! - _endpoints.setText(resolver.substitute((String)properties.get("Ice.OA." + adapter.getId() + ".Endpoints"))); - _publishedEndpoints.setText( - resolver.substitute((String)properties.get("Ice.OA." + adapter.getId() + ".PublishedEndpoints"))); - - _registerProcess.setSelected(descriptor.registerProcess); - _serverLifetime.setSelected(descriptor.serverLifetime); - - _objects.setObjects(descriptor.objects, resolver); - _allocatables.setObjects(descriptor.allocatables, resolver); + 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)); + _priority.setText(resolver.substitute(descriptor.priority)); + + java.util.Map properties = adapter.getProperties(); + + // getId() returns the name of the adapter! + _endpoints.setText(resolver.substitute((String)properties.get("Ice.OA." + adapter.getId() + ".Endpoints"))); + _publishedEndpoints.setText( + resolver.substitute((String)properties.get("Ice.OA." + adapter.getId() + ".PublishedEndpoints"))); + + _registerProcess.setSelected(descriptor.registerProcess); + _serverLifetime.setSelected(descriptor.serverLifetime); + + _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("Priority"); - builder.append(_priority, 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("", _serverLifetime); - 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(); + 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("Priority"); + builder.append(_priority, 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("", _serverLifetime); + 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"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Adapter Properties"); } private JTextField _currentStatus = new JTextField(20); diff --git a/java/src/IceGridGUI/LiveDeployment/ApplicationDetailsDialog.java b/java/src/IceGridGUI/LiveDeployment/ApplicationDetailsDialog.java index e6865e63bc2..3f8ac8ba611 100644 --- a/java/src/IceGridGUI/LiveDeployment/ApplicationDetailsDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ApplicationDetailsDialog.java @@ -38,59 +38,59 @@ class ApplicationDetailsDialog extends JDialog { ApplicationDetailsDialog(final Root root) { - super(root.getCoordinator().getMainFrame(), - "Application Details - IceGrid Admin", true); - setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); - _mainFrame = root.getCoordinator().getMainFrame(); + super(root.getCoordinator().getMainFrame(), + "Application Details - IceGrid Admin", true); + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + _mainFrame = root.getCoordinator().getMainFrame(); - _name.setEditable(false); - _uuid.setEditable(false); - _createTime.setEditable(false); - _createUser.setEditable(false); - _updateTime.setEditable(false); - _updateUser.setEditable(false); - _revision.setEditable(false); - - 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("Name", _name); - builder.nextLine(); - builder.append("UUID", _uuid); - builder.nextLine(); - builder.append("Created", _createTime); - builder.nextLine(); - builder.append("Created by", _createUser); - builder.nextLine(); - builder.append("Last Update", _updateTime); - builder.nextLine(); - builder.append("Updated by", _updateUser); - builder.nextLine(); - builder.append("Revision", _revision); - builder.nextLine(); + _name.setEditable(false); + _uuid.setEditable(false); + _createTime.setEditable(false); + _createUser.setEditable(false); + _updateTime.setEditable(false); + _updateUser.setEditable(false); + _revision.setEditable(false); + + 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("Name", _name); + builder.nextLine(); + builder.append("UUID", _uuid); + builder.nextLine(); + builder.append("Created", _createTime); + builder.nextLine(); + builder.append("Created by", _createUser); + builder.nextLine(); + builder.append("Last Update", _updateTime); + builder.nextLine(); + builder.append("Updated by", _updateUser); + builder.nextLine(); + builder.append("Revision", _revision); + builder.nextLine(); - Container contentPane = getContentPane(); - contentPane.add(builder.getPanel()); - - pack(); - setResizable(false); + Container contentPane = getContentPane(); + contentPane.add(builder.getPanel()); + + pack(); + setResizable(false); } void showDialog(ApplicationInfo info) { - _name.setText(info.descriptor.name); - _uuid.setText(info.uuid); - _createTime.setText(java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(info.createTime))); - _createUser.setText(info.createUser); - _updateTime.setText(java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(info.updateTime))); - _updateUser.setText(info.updateUser); - _revision.setText(Integer.toString(info.revision)); + _name.setText(info.descriptor.name); + _uuid.setText(info.uuid); + _createTime.setText(java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(info.createTime))); + _createUser.setText(info.createUser); + _updateTime.setText(java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(info.updateTime))); + _updateUser.setText(info.updateUser); + _revision.setText(Integer.toString(info.revision)); - setLocationRelativeTo(_mainFrame); - setVisible(true); + setLocationRelativeTo(_mainFrame); + setVisible(true); } private JTextField _name = new JTextField(30); diff --git a/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java b/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java index d356d00f249..a443db8949d 100755 --- a/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/CommunicatorEditor.java @@ -21,46 +21,46 @@ class CommunicatorEditor extends Editor { protected CommunicatorEditor() { - _description.setEditable(false); - _description.setOpaque(false); + _description.setEditable(false); + _description.setOpaque(false); } protected void show(CommunicatorDescriptor descriptor, - java.util.SortedMap properties, - Utils.Resolver resolver) + java.util.SortedMap properties, + Utils.Resolver resolver) { - _description.setText(resolver.substitute(descriptor.description)); - _properties.setSortedMap(properties); + _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.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.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(); + 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); diff --git a/java/src/IceGridGUI/LiveDeployment/DbEnv.java b/java/src/IceGridGUI/LiveDeployment/DbEnv.java index c6656dbeeb6..98a98051fb7 100755 --- a/java/src/IceGridGUI/LiveDeployment/DbEnv.java +++ b/java/src/IceGridGUI/LiveDeployment/DbEnv.java @@ -21,50 +21,50 @@ import IceGridGUI.*; class DbEnv extends TreeNode { public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + 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); + 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; + if(_editor == null) + { + _editor = new DbEnvEditor(); + } + _editor.show(this); + return _editor; } DbEnv(TreeNode parent, String dbEnvName, Utils.Resolver resolver, - DbEnvDescriptor descriptor) + DbEnvDescriptor descriptor) { - super(parent, dbEnvName); - _resolver = resolver; - _descriptor = descriptor; + super(parent, dbEnvName); + _resolver = resolver; + _descriptor = descriptor; } Utils.Resolver getResolver() { - return _resolver; + return _resolver; } DbEnvDescriptor getDescriptor() { - return _descriptor; + return _descriptor; } private Utils.Resolver _resolver; diff --git a/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java b/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java index 76e9b8870cb..d97f22668ad 100755 --- a/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/DbEnvEditor.java @@ -26,68 +26,68 @@ class DbEnvEditor extends Editor { DbEnvEditor() { - _description.setEditable(false); - _description.setOpaque(false); - _dbHome.setEditable(false); + _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)); + 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)); - } + if(descriptor.dbHome.length() == 0) + { + _dbHome.setText("Created by the IceGrid Node"); + } + else + { + _dbHome.setText(resolver.substitute(descriptor.dbHome)); + } - _properties.setProperties(descriptor.properties, resolver); + _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("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("Properties"); + builder.nextLine(); - builder.append(""); - builder.nextLine(); + builder.append(""); + 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(); + 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"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Database Environment Properties"); } private JTextArea _description = new JTextArea(3, 20); diff --git a/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java b/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java index 5835e1a1ece..2428af55fa4 100755 --- a/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java +++ b/java/src/IceGridGUI/LiveDeployment/ListArrayTreeNode.java @@ -20,120 +20,120 @@ 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; - } + 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 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; + 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); + 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; + 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; + 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; + 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]; + 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 96275ac1af1..ae7bebdd1ef 100755 --- a/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java +++ b/java/src/IceGridGUI/LiveDeployment/ListTreeNode.java @@ -20,61 +20,61 @@ abstract class ListTreeNode extends TreeNode { public Enumeration children() { - return new Enumeration() - { - public boolean hasMoreElements() - { - return _p.hasNext(); - } + return new Enumeration() + { + public boolean hasMoreElements() + { + return _p.hasNext(); + } - public Object nextElement() - { - return _p.next(); - } - - private java.util.Iterator _p = _children.iterator(); - }; + public Object nextElement() + { + return _p.next(); + } + + private java.util.Iterator _p = _children.iterator(); + }; } public boolean getAllowsChildren() { - return true; + 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); - } + 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(); + return _children.size(); } public int getIndex(javax.swing.tree.TreeNode node) { - return _children.indexOf(node); + return _children.indexOf(node); } public boolean isLeaf() { - return _children.isEmpty(); + return _children.isEmpty(); } protected ListTreeNode(TreeNode parent, String id) { - super(parent, 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 0b238b47206..704a7dfc8ed 100755 --- a/java/src/IceGridGUI/LiveDeployment/Node.java +++ b/java/src/IceGridGUI/LiveDeployment/Node.java @@ -34,902 +34,902 @@ class Node extends ListTreeNode // public boolean[] getAvailableActions() { - boolean[] actions = new boolean[ACTION_COUNT]; - actions[SHUTDOWN_NODE] = _up; - actions[RETRIEVE_STDOUT] = _up; - actions[RETRIEVE_STDERR] = _up; - return actions; + boolean[] actions = new boolean[ACTION_COUNT]; + actions[SHUTDOWN_NODE] = _up; + actions[RETRIEVE_STDOUT] = _up; + actions[RETRIEVE_STDERR] = _up; + return actions; } public void retrieveOutput(final boolean stdout) { - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, NodeNotExistException, NodeUnreachableException - { - AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); - - if(stdout) - { - return adminSession.openNodeStdOut(_id, count); - } - else - { - return adminSession.openNodeStdErr(_id, count); - } - } - - public String getTitle() - { - return "Node " + _id + " " + (stdout ? "stdout" : "stderr"); - } - - public String getDefaultFilename() - { - return _id + (stdout ? ".out" : ".err"); - } - }); + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, NodeNotExistException, NodeUnreachableException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + + if(stdout) + { + return adminSession.openNodeStdOut(_id, count); + } + else + { + return adminSession.openNodeStdErr(_id, count); + } + } + + public String getTitle() + { + return "Node " + _id + " " + (stdout ? "stdout" : "stderr"); + } + + public String getDefaultFilename() + { + return _id + (stdout ? ".out" : ".err"); + } + }); } 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)); - } + 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(RETRIEVE_STDOUT)); - _popup.add(la.get(RETRIEVE_STDERR)); - _popup.addSeparator(); - _popup.add(la.get(SHUTDOWN_NODE)); - } - - la.setTarget(this); - return _popup; + LiveActions la = getCoordinator().getLiveActionsForPopup(); + + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(la.get(RETRIEVE_STDOUT)); + _popup.add(la.get(RETRIEVE_STDERR)); + _popup.addSeparator(); + _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; + 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); + 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); + super(parent, info.info.name); + up(info, false); } Node(Root parent, ApplicationDescriptor appDesc, - String nodeName, NodeDescriptor nodeDesc) + String nodeName, NodeDescriptor nodeDesc) { - super(parent, nodeName); - add(appDesc, 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); + 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; + 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); + 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); - putInfoVariables(data.resolver); - - _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)); - } + 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); + putInfoVariables(data.resolver); + + _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(index); - 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; + _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(index); + 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 in this application - // - java.util.Iterator p = _children.iterator(); - while(p.hasNext()) - { - Server server = (Server)p.next(); - if(server.getApplication() == appDesc) - { - if(!freshServers.contains(server)) - { - server.rebuild(data.resolver, - variablesChanged, - serviceTemplates, serverTemplates); - } - } - } - } + 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 in this application + // + java.util.Iterator p = _children.iterator(); + while(p.hasNext()) + { + Server server = (Server)p.next(); + if(server.getApplication() == appDesc) + { + if(!freshServers.contains(server)) + { + server.rebuild(data.resolver, + variablesChanged, + serviceTemplates, serverTemplates); + } + } + } + } } NodeInfo getStaticInfo() { - if(_info == null) - { - return null; - } - else - { - return _info.info; - } + if(_info == null) + { + return null; + } + else + { + return _info.info; + } } boolean isRunningWindows() { - return _windows; + return _windows; } private boolean putInfoVariables(Utils.Resolver resolver) { - if(_info == null) - { - return false; - } - else - { - boolean updated = resolver.put("node.os", _info.info.os); - updated = resolver.put("node.hostname", _info.info.hostname) || updated; - updated = resolver.put("node.release", _info.info.release) || updated; - updated = resolver.put("node.version", _info.info.version) || updated; - updated = resolver.put("node.machine", _info.info.machine) || updated; - updated = resolver.put("node.datadir", _info.info.dataDir) || updated; - return updated; - } + if(_info == null) + { + return false; + } + else + { + boolean updated = resolver.put("node.os", _info.info.os); + updated = resolver.put("node.hostname", _info.info.hostname) || updated; + updated = resolver.put("node.release", _info.info.release) || updated; + updated = resolver.put("node.version", _info.info.version) || updated; + updated = resolver.put("node.machine", _info.info.machine) || updated; + updated = resolver.put("node.datadir", _info.info.dataDir) || updated; + return updated; + } } void up(NodeDynamicInfo info, boolean fireEvent) { - _up = true; - _info = info; - _windows = info.info.os.toLowerCase().startsWith("windows"); - - // - // Update variables and rebuild all affected servers - // - java.util.Iterator p = _map.values().iterator(); - while(p.hasNext()) - { - ApplicationData data = (ApplicationData)p.next(); - - if(putInfoVariables(data.resolver)) - { - String appName = data.resolver.find("application"); - - java.util.Iterator q = _children.iterator(); - while(q.hasNext()) - { - Server server = (Server)q.next(); - if(server.getApplication().name.equals(appName)) - { - server.rebuild(data.resolver, true, null, null); - } - } - } - } - - // - // Tell every server on this node - // - java.util.Set updatedServers = new java.util.HashSet(); - 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); - } + _up = true; + _info = info; + _windows = info.info.os.toLowerCase().startsWith("windows"); + + // + // Update variables and rebuild all affected servers + // + java.util.Iterator p = _map.values().iterator(); + while(p.hasNext()) + { + ApplicationData data = (ApplicationData)p.next(); + + if(putInfoVariables(data.resolver)) + { + String appName = data.resolver.find("application"); + + java.util.Iterator q = _children.iterator(); + while(q.hasNext()) + { + Server server = (Server)q.next(); + if(server.getApplication().name.equals(appName)) + { + server.rebuild(data.resolver, true, null, null); + } + } + } + } + + // + // Tell every server on this node + // + java.util.Set updatedServers = new java.util.HashSet(); + 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; - } + _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); - } + 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; - } - } + 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.id.equals(adapterId)) - { - return ainfo.proxy; - } - } - } - return null; + if(_info != null) + { + java.util.ListIterator p = _info.adapters.listIterator(); + while(p.hasNext()) + { + AdapterDynamicInfo ainfo = (AdapterDynamicInfo)p.next(); + if(ainfo.id.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; + 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)); - } + 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); + 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); + 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()); + insertSortedChild(server, _children, getRoot().getTreeModel()); } private Server findServer(String id) { - return (Server)find(id, _children); + 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()); - } + 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; - } - } + // + // 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; - } - } + // + // 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; + NodeDescriptor descriptor; + Utils.Resolver resolver; } // diff --git a/java/src/IceGridGUI/LiveDeployment/NodeEditor.java b/java/src/IceGridGUI/LiveDeployment/NodeEditor.java index 9011062e08c..d036f936ddb 100755 --- a/java/src/IceGridGUI/LiveDeployment/NodeEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/NodeEditor.java @@ -28,119 +28,119 @@ 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); + _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); + _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); _os.setCaretPosition(0); - _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()); + _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 - // + 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(); + 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"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Node Properties"); } private JTextField _hostname = new JTextField(20); diff --git a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java index 1d54b5bc70d..b5c5e742727 100755 --- a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java @@ -38,12 +38,12 @@ class ObjectDialog extends JDialog { ObjectDialog(final Root root, boolean readOnly) { - super(root.getCoordinator().getMainFrame(), + super(root.getCoordinator().getMainFrame(), (readOnly ? "" : "New ") + "Dynamic Well-Known Object - IceGrid Admin", true); - setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); - _mainFrame = root.getCoordinator().getMainFrame(); - + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + _mainFrame = root.getCoordinator().getMainFrame(); + _proxy.setLineWrap(true); if(readOnly) @@ -73,7 +73,7 @@ class ObjectDialog extends JDialog cc.xywh(builder.getColumn(), builder.getRow(), 1, 3)); builder.nextRow(2); builder.nextLine(); - + if(readOnly) { builder.append("Type", _type); @@ -94,9 +94,9 @@ class ObjectDialog extends JDialog { JButton okButton = new JButton("OK"); ActionListener okListener = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { + { + public void actionPerformed(ActionEvent e) + { if(_proxy.isEditable()) { String type = null; @@ -114,11 +114,11 @@ class ObjectDialog extends JDialog { setVisible(false); } - } - }; + } + }; okButton.addActionListener(okListener); getRootPane().setDefaultButton(okButton); - + JButton cancelButton = new JButton("Cancel"); ActionListener cancelListener = new ActionListener() { @@ -132,11 +132,11 @@ class ObjectDialog extends JDialog JComponent buttonBar = ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); - buttonBar.setBorder(Borders.DIALOG_BORDER); + buttonBar.setBorder(Borders.DIALOG_BORDER); - contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); - contentPane.add(builder.getPanel()); - contentPane.add(buttonBar); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(builder.getPanel()); + contentPane.add(buttonBar); } pack(); @@ -147,10 +147,10 @@ class ObjectDialog extends JDialog { assert _proxy.isEditable(); - _proxy.setText(""); + _proxy.setText(""); _typeCombo.setSelectedItem(QUERY_OBJECT); - setLocationRelativeTo(_mainFrame); - setVisible(true); + setLocationRelativeTo(_mainFrame); + setVisible(true); } void showDialog(String proxy, String type) @@ -161,7 +161,7 @@ class ObjectDialog extends JDialog _type.setText(type); setLocationRelativeTo(_mainFrame); - setVisible(true); + setVisible(true); } private JTextArea _proxy = new JTextArea(3, 40); @@ -170,10 +170,10 @@ class ObjectDialog extends JDialog private JFrame _mainFrame; static private final Object QUERY_OBJECT = new Object() - { - public String toString() - { - return "Query object to retrieve type"; - } - }; + { + 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 dc3f9ac57e6..6856e6f12ec 100755 --- a/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/RegistryEditor.java @@ -35,93 +35,93 @@ class RegistryEditor extends Editor { RegistryEditor() { - _hostname.setEditable(false); - - Action openDefinition = new AbstractAction("Open definition") - { - public void actionPerformed(ActionEvent e) - { - int selectedRow = _applications.getSelectedRow(); - if(selectedRow != -1) - { - String appName = (String)_applications.getValueAt(selectedRow, 0); - ApplicationPane app = _target.getCoordinator().openLiveApplication(appName); - - if(app != null && app.getRoot().getSelectedNode() == null) - { - app.getRoot().setSelectedNode(app.getRoot()); - } - } - } - }; - - Action showDetails = new AbstractAction("Show details") - { - public void actionPerformed(ActionEvent e) - { - int selectedRow = _applications.getSelectedRow(); - if(selectedRow != -1) - { - String appName = (String)_applications.getValueAt(selectedRow, 0); - _target.showApplicationDetails(appName); - } - } - }; + _hostname.setEditable(false); + + Action openDefinition = new AbstractAction("Open definition") + { + public void actionPerformed(ActionEvent e) + { + int selectedRow = _applications.getSelectedRow(); + if(selectedRow != -1) + { + String appName = (String)_applications.getValueAt(selectedRow, 0); + ApplicationPane app = _target.getCoordinator().openLiveApplication(appName); + + if(app != null && app.getRoot().getSelectedNode() == null) + { + app.getRoot().setSelectedNode(app.getRoot()); + } + } + } + }; + + Action showDetails = new AbstractAction("Show details") + { + public void actionPerformed(ActionEvent e) + { + int selectedRow = _applications.getSelectedRow(); + if(selectedRow != -1) + { + String appName = (String)_applications.getValueAt(selectedRow, 0); + _target.showApplicationDetails(appName); + } + } + }; final Action patch = new AbstractAction("Patch distribution") - { - public void actionPerformed(ActionEvent e) - { - int selectedRow = _applications.getSelectedRow(); - if(selectedRow != -1) - { - String appName = (String)_applications.getValueAt(selectedRow, 0); - _target.patch(appName); - } - } - }; - - Action removeApplication = new AbstractAction("Remove from registry") - { - public void actionPerformed(ActionEvent e) - { - int selectedRow = _applications.getSelectedRow(); - if(selectedRow != -1) - { - String appName = (String)_applications.getValueAt(selectedRow, 0); - - int confirm = JOptionPane.showConfirmDialog( - _target.getCoordinator().getMainFrame(), - "You are about to remove application '" + appName + "' from the IceGrid registry. " - + "Do you want to proceed?", - "Remove Confirmation", - JOptionPane.YES_NO_OPTION); - - if(confirm == JOptionPane.YES_OPTION) - { - _target.getCoordinator().removeApplicationFromRegistry(appName); - } - } - } - }; - - removeApplication.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke("DELETE")); - - _applications.getActionMap().put("delete", removeApplication); - _applications.getInputMap().put( - KeyStroke.getKeyStroke("DELETE"), "delete"); - - final JPopupMenu appPopup = new JPopupMenu(); - appPopup.add(openDefinition); - appPopup.add(showDetails); - appPopup.addSeparator(); - appPopup.add(patch); + { + public void actionPerformed(ActionEvent e) + { + int selectedRow = _applications.getSelectedRow(); + if(selectedRow != -1) + { + String appName = (String)_applications.getValueAt(selectedRow, 0); + _target.patch(appName); + } + } + }; + + Action removeApplication = new AbstractAction("Remove from registry") + { + public void actionPerformed(ActionEvent e) + { + int selectedRow = _applications.getSelectedRow(); + if(selectedRow != -1) + { + String appName = (String)_applications.getValueAt(selectedRow, 0); + + int confirm = JOptionPane.showConfirmDialog( + _target.getCoordinator().getMainFrame(), + "You are about to remove application '" + appName + "' from the IceGrid registry. " + + "Do you want to proceed?", + "Remove Confirmation", + JOptionPane.YES_NO_OPTION); + + if(confirm == JOptionPane.YES_OPTION) + { + _target.getCoordinator().removeApplicationFromRegistry(appName); + } + } + } + }; + + removeApplication.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke("DELETE")); + + _applications.getActionMap().put("delete", removeApplication); + _applications.getInputMap().put( + KeyStroke.getKeyStroke("DELETE"), "delete"); + + final JPopupMenu appPopup = new JPopupMenu(); + appPopup.add(openDefinition); + appPopup.add(showDetails); + appPopup.addSeparator(); + appPopup.add(patch); appPopup.addSeparator(); - appPopup.add(removeApplication); + appPopup.add(removeApplication); - _applications.addMouseListener(new MouseAdapter() - { + _applications.addMouseListener(new MouseAdapter() + { public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2) @@ -135,56 +135,56 @@ class RegistryEditor extends Editor } } - public void mousePressed(MouseEvent e) - { - maybeShowPopup(e); - } - - public void mouseReleased(MouseEvent e) - { - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { + public void mousePressed(MouseEvent e) + { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) + { + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) + { int selectedRow = _applications.getSelectedRow(); - if (e.isPopupTrigger() && selectedRow != -1) - { + if (e.isPopupTrigger() && selectedRow != -1) + { String appName = (String)_applications.getValueAt(selectedRow, 0); ApplicationDescriptor desc = _target.getApplicationDescriptor(appName); patch.setEnabled(desc != null && desc.distrib.icepatch.length() > 0); - appPopup.show(_applications, e.getX(), e.getY()); - } - } - }); - - - Action deleteObject = new AbstractAction("Remove selected object") - { - public void actionPerformed(ActionEvent e) - { - if(_target.getCoordinator().connectedToMaster()) - { - int selectedRow = _objects.getSelectedRow(); - if(selectedRow != -1) - { - _target.removeObject((String)_objects.getValueAt(selectedRow, 0)); - } - } - } - }; - deleteObject.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke("DELETE")); - - _objects.getActionMap().put("delete", deleteObject); - _objects.getInputMap().put( - KeyStroke.getKeyStroke("DELETE"), "delete"); - - + appPopup.show(_applications, e.getX(), e.getY()); + } + } + }); + + + Action deleteObject = new AbstractAction("Remove selected object") + { + public void actionPerformed(ActionEvent e) + { + if(_target.getCoordinator().connectedToMaster()) + { + int selectedRow = _objects.getSelectedRow(); + if(selectedRow != -1) + { + _target.removeObject((String)_objects.getValueAt(selectedRow, 0)); + } + } + } + }; + deleteObject.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke("DELETE")); + + _objects.getActionMap().put("delete", deleteObject); + _objects.getInputMap().put( + KeyStroke.getKeyStroke("DELETE"), "delete"); + + Action showObject = new AbstractAction("Show details") { public void actionPerformed(ActionEvent e) - { + { int selectedRow = _objects.getSelectedRow(); if(selectedRow != -1) { @@ -192,40 +192,40 @@ class RegistryEditor extends Editor String type = (String)_objects.getValueAt(selectedRow, 1); _target.showObject(proxy, type); } - } + } }; - Action addObject = new AbstractAction("Add a new well-known object") - { - public void actionPerformed(ActionEvent e) - { - if(_target.getCoordinator().connectedToMaster()) - { - _target.addObject(); - } - } - }; - addObject.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke("INSERT")); - - _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>"); - - - final JPopupMenu objectsPopup = new JPopupMenu(); - objectsPopup.add(addObject); - objectsPopup.addSeparator(); - final JMenuItem deleteObjectMenuItem = objectsPopup.add(deleteObject); + Action addObject = new AbstractAction("Add a new well-known object") + { + public void actionPerformed(ActionEvent e) + { + if(_target.getCoordinator().connectedToMaster()) + { + _target.addObject(); + } + } + }; + addObject.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke("INSERT")); + + _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>"); + + + final JPopupMenu objectsPopup = new JPopupMenu(); + objectsPopup.add(addObject); + objectsPopup.addSeparator(); + final JMenuItem deleteObjectMenuItem = objectsPopup.add(deleteObject); objectsPopup.addSeparator(); final JMenuItem showObjectMenuItem = objectsPopup.add(showObject); - _objects.addMouseListener(new MouseAdapter() - { + _objects.addMouseListener(new MouseAdapter() + { public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2) @@ -240,168 +240,168 @@ class RegistryEditor extends Editor } } - public void mousePressed(MouseEvent e) - { - maybeShowPopup(e); - } - - public void mouseReleased(MouseEvent e) - { - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { - if (e.isPopupTrigger()) - { + public void mousePressed(MouseEvent e) + { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) + { + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) + { + if (e.isPopupTrigger()) + { showObjectMenuItem.setEnabled(_objects.getSelectedRow() != -1); - deleteObjectMenuItem.setEnabled(_objects.getSelectedRow() != -1); - objectsPopup.show(_objects, e.getX(), e.getY()); - } - } - }); + deleteObjectMenuItem.setEnabled(_objects.getSelectedRow() != -1); + objectsPopup.show(_objects, e.getX(), e.getY()); + } + } + }); - Action deleteAdapter = new AbstractAction("Remove selected adapter") - { - public void actionPerformed(ActionEvent e) - { - if(_target.getCoordinator().connectedToMaster()) - { - int selectedRow = _adapters.getSelectedRow(); - if(selectedRow != -1) - { - _target.removeAdapter((String)_adapters.getValueAt(selectedRow, 0)); - } - } - } - }; - deleteAdapter.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke("DELETE")); - - _adapters.getActionMap().put("delete", deleteAdapter); - _adapters.getInputMap().put( - KeyStroke.getKeyStroke("DELETE"), "delete"); - _adapters.setToolTipText("<html>Object adapters registered at run time.</html>"); - - final JPopupMenu adaptersPopup = new JPopupMenu(); - adaptersPopup.add(deleteAdapter); - - _adapters.addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - maybeShowPopup(e); - } - - public void mouseReleased(MouseEvent e) - { - maybeShowPopup(e); - } - - private void maybeShowPopup(MouseEvent e) - { - if (e.isPopupTrigger() && _adapters.getSelectedRow() != -1) - { - adaptersPopup.show(_adapters, e.getX(), e.getY()); - } - } - }); + Action deleteAdapter = new AbstractAction("Remove selected adapter") + { + public void actionPerformed(ActionEvent e) + { + if(_target.getCoordinator().connectedToMaster()) + { + int selectedRow = _adapters.getSelectedRow(); + if(selectedRow != -1) + { + _target.removeAdapter((String)_adapters.getValueAt(selectedRow, 0)); + } + } + } + }; + deleteAdapter.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke("DELETE")); + + _adapters.getActionMap().put("delete", deleteAdapter); + _adapters.getInputMap().put( + KeyStroke.getKeyStroke("DELETE"), "delete"); + _adapters.setToolTipText("<html>Object adapters registered at run time.</html>"); + + final JPopupMenu adaptersPopup = new JPopupMenu(); + adaptersPopup.add(deleteAdapter); + + _adapters.addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + maybeShowPopup(e); + } + + public void mouseReleased(MouseEvent e) + { + maybeShowPopup(e); + } + + private void maybeShowPopup(MouseEvent e) + { + if (e.isPopupTrigger() && _adapters.getSelectedRow() != -1) + { + adaptersPopup.show(_adapters, e.getX(), e.getY()); + } + } + }); } protected void appendProperties(DefaultFormBuilder builder) { - CellConstraints cc = new CellConstraints(); - - builder.append("Hostname" ); - builder.append(_hostname, 3); - builder.nextLine(); - - builder.appendSeparator("Deployed Applications"); - 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(_applications); - scrollPane.setToolTipText(_applications.getToolTipText()); - builder.add(scrollPane, - cc.xywh(builder.getColumn(), builder.getRow(), 3, 14)); - builder.nextRow(14); - builder.nextLine(); - - 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.nextRow(-14); - 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.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(); + CellConstraints cc = new CellConstraints(); + + builder.append("Hostname" ); + builder.append(_hostname, 3); + builder.nextLine(); + + builder.appendSeparator("Deployed Applications"); + 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(_applications); + scrollPane.setToolTipText(_applications.getToolTipText()); + builder.add(scrollPane, + cc.xywh(builder.getColumn(), builder.getRow(), 3, 14)); + builder.nextRow(14); + builder.nextLine(); + + 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.nextRow(-14); + 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.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"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Registry Properties"); } void show(Root root) { - _target = root; - _hostname.setText(root.getRegistryInfo().hostname); - _applications.setSortedMap(root.getApplicationMap()); - _objects.setObjects(root.getObjects()); - _adapters.setAdapters(root.getAdapters()); + _target = root; + _hostname.setText(root.getRegistryInfo().hostname); + _applications.setSortedMap(root.getApplicationMap()); + _objects.setObjects(root.getObjects()); + _adapters.setAdapters(root.getAdapters()); } private JTextField _hostname = new JTextField(20); diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java index c67c97b9a2a..f7433b44968 100755 --- a/java/src/IceGridGUI/LiveDeployment/Root.java +++ b/java/src/IceGridGUI/LiveDeployment/Root.java @@ -33,195 +33,195 @@ public class Root extends ListArrayTreeNode { public Root(Coordinator coordinator) { - super(null, "Root", 2); - _coordinator = coordinator; - _childrenArray[0] = _slaves; - _childrenArray[1] = _nodes; - _messageSizeMax = Ice.Util.getInstance(_coordinator.getCommunicator()).messageSizeMax(); - - _tree = new JTree(this, true); - _treeModel = (DefaultTreeModel)_tree.getModel(); - _addObjectDialog = new ObjectDialog(this, false); + super(null, "Root", 2); + _coordinator = coordinator; + _childrenArray[0] = _slaves; + _childrenArray[1] = _nodes; + _messageSizeMax = Ice.Util.getInstance(_coordinator.getCommunicator()).messageSizeMax(); + + _tree = new JTree(this, true); + _treeModel = (DefaultTreeModel)_tree.getModel(); + _addObjectDialog = new ObjectDialog(this, false); _showObjectDialog = new ObjectDialog(this, true); - _tree.addTreeWillExpandListener(new javax.swing.event.TreeWillExpandListener() - { - public void treeWillExpand(javax.swing.event.TreeExpansionEvent event) - { - } - - public void treeWillCollapse(javax.swing.event.TreeExpansionEvent event) - throws javax.swing.tree.ExpandVetoException - { - if(event.getPath().getLastPathComponent() == Root.this) - { - throw new javax.swing.tree.ExpandVetoException(event); - } - } - }); - - loadLogPrefs(); + _tree.addTreeWillExpandListener(new javax.swing.event.TreeWillExpandListener() + { + public void treeWillExpand(javax.swing.event.TreeExpansionEvent event) + { + } + + public void treeWillCollapse(javax.swing.event.TreeExpansionEvent event) + throws javax.swing.tree.ExpandVetoException + { + if(event.getPath().getLastPathComponent() == Root.this) + { + throw new javax.swing.tree.ExpandVetoException(event); + } + } + }); + + loadLogPrefs(); } public boolean[] getAvailableActions() { - boolean[] actions = new boolean[ACTION_COUNT]; - actions[ADD_OBJECT] = _coordinator.connectedToMaster(); - actions[SHUTDOWN_REGISTRY] = true; - actions[RETRIEVE_STDOUT] = true; - actions[RETRIEVE_STDERR] = true; - return actions; + boolean[] actions = new boolean[ACTION_COUNT]; + actions[ADD_OBJECT] = _coordinator.connectedToMaster(); + actions[SHUTDOWN_REGISTRY] = true; + actions[RETRIEVE_STDOUT] = true; + actions[RETRIEVE_STDERR] = true; + return actions; } public void shutdownRegistry() { - final String prefix = "Shutting down registry '" + _replicaName + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - AMI_Admin_shutdownRegistry cb = new AMI_Admin_shutdownRegistry() - { - // - // Called by another thread! - // - public void ice_response() - { - amiSuccess(prefix); - } - - public void ice_exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to shutdown " + _replicaName, e); - } - - public void ice_exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to shutdown " + _replicaName, - e.toString()); - } - }; - - try - { - _coordinator.getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - _coordinator.getAdmin().shutdownRegistry_async(cb, _replicaName); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to shutdown " + _replicaName, e.toString()); - } - finally - { - _coordinator.getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + final String prefix = "Shutting down registry '" + _replicaName + "'..."; + getCoordinator().getStatusBar().setText(prefix); + + AMI_Admin_shutdownRegistry cb = new AMI_Admin_shutdownRegistry() + { + // + // Called by another thread! + // + public void ice_response() + { + amiSuccess(prefix); + } + + public void ice_exception(Ice.UserException e) + { + amiFailure(prefix, "Failed to shutdown " + _replicaName, e); + } + + public void ice_exception(Ice.LocalException e) + { + amiFailure(prefix, "Failed to shutdown " + _replicaName, + e.toString()); + } + }; + + try + { + _coordinator.getMainFrame().setCursor( + Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + _coordinator.getAdmin().shutdownRegistry_async(cb, _replicaName); + } + catch(Ice.LocalException e) + { + failure(prefix, "Failed to shutdown " + _replicaName, e.toString()); + } + finally + { + _coordinator.getMainFrame().setCursor( + Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } } public ApplicationDescriptor getApplicationDescriptor(String name) { - ApplicationInfo app = (ApplicationInfo)_infoMap.get(name); - if(app == null) - { - return null; - } - else - { - return app.descriptor; - } + ApplicationInfo app = (ApplicationInfo)_infoMap.get(name); + if(app == null) + { + return null; + } + else + { + return app.descriptor; + } } public Object[] getApplicationNames() { - return _infoMap.keySet().toArray(); + return _infoMap.keySet().toArray(); } public Object[] getPatchableApplicationNames() { - java.util.List result = new java.util.ArrayList(); - - java.util.Iterator p = _infoMap.entrySet().iterator(); - while(p.hasNext()) - { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - - ApplicationInfo app = (ApplicationInfo)entry.getValue(); - if(app.descriptor.distrib.icepatch.length() > 0) - { - result.add(entry.getKey()); - } - } - return result.toArray(); + java.util.List result = new java.util.ArrayList(); + + java.util.Iterator p = _infoMap.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + + ApplicationInfo app = (ApplicationInfo)entry.getValue(); + if(app.descriptor.distrib.icepatch.length() > 0) + { + result.add(entry.getKey()); + } + } + return result.toArray(); } public java.util.SortedMap getApplicationMap() { - java.util.SortedMap r = new java.util.TreeMap(); - - java.util.Iterator p = _infoMap.entrySet().iterator(); - while(p.hasNext()) - { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - - ApplicationInfo app = (ApplicationInfo)entry.getValue(); - - r.put(entry.getKey(), - java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(app.updateTime))); - } - return r; + java.util.SortedMap r = new java.util.TreeMap(); + + java.util.Iterator p = _infoMap.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + + ApplicationInfo app = (ApplicationInfo)entry.getValue(); + + r.put(entry.getKey(), + java.text.DateFormat.getDateTimeInstance().format(new java.util.Date(app.updateTime))); + } + return r; } public Editor getEditor() { - if(_editor == null) - { - _editor = new RegistryEditor(); - } - _editor.show(this); - return _editor; + 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) + 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); + 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, String replicaName, java.util.List applications) { - closeAllShowLogDialogs(); - - _replicaName = replicaName; - _label = instanceName + " (" + _replicaName + ")"; - _tree.setRootVisible(true); - - java.util.Iterator p = applications.iterator(); - while(p.hasNext()) - { - applicationAdded((ApplicationInfo)p.next()); - } + closeAllShowLogDialogs(); + + _replicaName = replicaName; + _label = instanceName + " (" + _replicaName + ")"; + _tree.setRootVisible(true); + + java.util.Iterator p = applications.iterator(); + while(p.hasNext()) + { + applicationAdded((ApplicationInfo)p.next()); + } } // @@ -229,89 +229,89 @@ public class Root extends ListArrayTreeNode // public void clear() { - _adapters.clear(); - _objects.clear(); - _replicaName = null; - - _infoMap.clear(); - _nodes.clear(); - _slaves.clear(); - _treeModel.nodeStructureChanged(this); - _tree.setRootVisible(false); + _adapters.clear(); + _objects.clear(); + _replicaName = null; + + _infoMap.clear(); + _nodes.clear(); + _slaves.clear(); + _treeModel.nodeStructureChanged(this); + _tree.setRootVisible(false); } public void patch(final String applicationName) { - int shutdown = JOptionPane.showConfirmDialog( - _coordinator.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); + int shutdown = JOptionPane.showConfirmDialog( + _coordinator.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)); + 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)); - } + } + catch(Ice.LocalException e) + { + failure(prefix, "Failed to patch " + _id, e.toString()); + } + finally + { + _coordinator.getMainFrame().setCursor( + Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } } public void showApplicationDetails(String appName) { - ApplicationInfo app = (ApplicationInfo)_infoMap.get(appName); - if(app != null) - { - if(_applicationDetailsDialog == null) - { - _applicationDetailsDialog = new ApplicationDetailsDialog(this); - } - - _applicationDetailsDialog.showDialog(app); - } + ApplicationInfo app = (ApplicationInfo)_infoMap.get(appName); + if(app != null) + { + if(_applicationDetailsDialog == null) + { + _applicationDetailsDialog = new ApplicationDetailsDialog(this); + } + + _applicationDetailsDialog.showDialog(app); + } } // @@ -319,233 +319,233 @@ public class Root extends ListArrayTreeNode // public void applicationAdded(ApplicationInfo info) { - _infoMap.put(info.descriptor.name, info); - - java.util.Iterator p = info.descriptor.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, info.descriptor, nodeName, nodeDesc)); - } - else - { - node.add(info.descriptor, nodeDesc); - } - } + _infoMap.put(info.descriptor.name, info); + + java.util.Iterator p = info.descriptor.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, info.descriptor, nodeName, nodeDesc)); + } + else + { + node.add(info.descriptor, nodeDesc); + } + } } public void applicationRemoved(String name) { - _infoMap.remove(name); - - java.util.List toRemove = new java.util.LinkedList(); - int[] toRemoveIndices = new int[_nodes.size()]; - - int i = 0; - for(int index = 0; index < _nodes.size(); ++index) - { - Node node = (Node)_nodes.get(index); - if(node.remove(name)) - { - toRemove.add(node); - toRemoveIndices[i++] = _slaves.size() + index; - } - } - - removeNodes(resize(toRemoveIndices, toRemove.size()), toRemove); + _infoMap.remove(name); + + java.util.List toRemove = new java.util.LinkedList(); + int[] toRemoveIndices = new int[_nodes.size()]; + + int i = 0; + for(int index = 0; index < _nodes.size(); ++index) + { + Node node = (Node)_nodes.get(index); + if(node.remove(name)) + { + toRemove.add(node); + toRemoveIndices[i++] = _slaves.size() + index; + } + } + + removeNodes(resize(toRemoveIndices, toRemove.size()), toRemove); } public void applicationUpdated(ApplicationUpdateInfo update) { - ApplicationInfo app = (ApplicationInfo)_infoMap.get(update.descriptor.name); - - app.updateTime = update.updateTime; - app.updateUser = update.updateUser; - app.revision = update.revision; - - ApplicationDescriptor appDesc = app.descriptor; - - // - // Update various fields of appDesc - // - if(update.descriptor.description != null) - { - appDesc.description = update.descriptor.description.value; - } - if(update.descriptor.distrib != null) - { - appDesc.distrib = update.descriptor.distrib.value; - } - - appDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.descriptor.removeVariables)); - appDesc.variables.putAll(update.descriptor.variables); - boolean variablesChanged = update.descriptor.removeVariables.length > 0 || !update.descriptor.variables.isEmpty(); - - // - // Update only descriptors (no tree node shown in this view) - // - appDesc.propertySets.keySet(). - removeAll(java.util.Arrays.asList(update.descriptor.removePropertySets)); - appDesc.propertySets.putAll(update.descriptor.propertySets); - - for(int i = 0; i < update.descriptor.removeReplicaGroups.length; ++i) - { - for(int j = 0; j < appDesc.replicaGroups.size(); ++j) - { - ReplicaGroupDescriptor rgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j); - if(rgd.id.equals(update.descriptor.removeReplicaGroups[i])) - { - appDesc.replicaGroups.remove(j); - break; // for - } - } - } - - for(int i = 0; i < update.descriptor.replicaGroups.size(); ++i) - { - ReplicaGroupDescriptor newRgd = (ReplicaGroupDescriptor)update.descriptor.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); - } - } + ApplicationInfo app = (ApplicationInfo)_infoMap.get(update.descriptor.name); + + app.updateTime = update.updateTime; + app.updateUser = update.updateUser; + app.revision = update.revision; + + ApplicationDescriptor appDesc = app.descriptor; + + // + // Update various fields of appDesc + // + if(update.descriptor.description != null) + { + appDesc.description = update.descriptor.description.value; + } + if(update.descriptor.distrib != null) + { + appDesc.distrib = update.descriptor.distrib.value; + } + + appDesc.variables.keySet().removeAll(java.util.Arrays.asList(update.descriptor.removeVariables)); + appDesc.variables.putAll(update.descriptor.variables); + boolean variablesChanged = update.descriptor.removeVariables.length > 0 || !update.descriptor.variables.isEmpty(); + + // + // Update only descriptors (no tree node shown in this view) + // + appDesc.propertySets.keySet(). + removeAll(java.util.Arrays.asList(update.descriptor.removePropertySets)); + appDesc.propertySets.putAll(update.descriptor.propertySets); + + for(int i = 0; i < update.descriptor.removeReplicaGroups.length; ++i) + { + for(int j = 0; j < appDesc.replicaGroups.size(); ++j) + { + ReplicaGroupDescriptor rgd = (ReplicaGroupDescriptor)appDesc.replicaGroups.get(j); + if(rgd.id.equals(update.descriptor.removeReplicaGroups[i])) + { + appDesc.replicaGroups.remove(j); + break; // for + } + } + } + + for(int i = 0; i < update.descriptor.replicaGroups.size(); ++i) + { + ReplicaGroupDescriptor newRgd = (ReplicaGroupDescriptor)update.descriptor.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.descriptor.removeServiceTemplates)); - appDesc.serviceTemplates.putAll(update.descriptor.serviceTemplates); - - appDesc.serverTemplates.keySet(). - removeAll(java.util.Arrays.asList(update.descriptor.removeServerTemplates)); - appDesc.serverTemplates.putAll(update.descriptor.serverTemplates); - - // - // Nodes - // - - // - // Removal - // - appDesc.nodes.keySet().removeAll(java.util.Arrays.asList(update.descriptor.removeNodes)); - - for(int i = 0; i < update.descriptor.removeNodes.length; ++i) - { - Node node = findNode(update.descriptor.removeNodes[i]); - if(node.remove(update.descriptor.name)) - { - int index = getIndex(node); - _nodes.remove(node); - _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node}); - } - } - - // - // Add/update - // - java.util.Iterator p = update.descriptor.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.descriptor.serviceTemplates.keySet(), update.descriptor.serverTemplates.keySet()); - } - freshNodes.add(node); - } - - // - // Notify non-fresh nodes if needed - // - if(variablesChanged || !update.descriptor.serviceTemplates.isEmpty() || !update.descriptor.serverTemplates.isEmpty()) - { - p = _nodes.iterator(); - while(p.hasNext()) - { - Node node = (Node)p.next(); - if(!freshNodes.contains(node)) - { - node.update(appDesc, null, variablesChanged, - update.descriptor.serviceTemplates.keySet(), update.descriptor.serverTemplates.keySet()); - } - } - } + appDesc.serviceTemplates.keySet(). + removeAll(java.util.Arrays.asList(update.descriptor.removeServiceTemplates)); + appDesc.serviceTemplates.putAll(update.descriptor.serviceTemplates); + + appDesc.serverTemplates.keySet(). + removeAll(java.util.Arrays.asList(update.descriptor.removeServerTemplates)); + appDesc.serverTemplates.putAll(update.descriptor.serverTemplates); + + // + // Nodes + // + + // + // Removal + // + appDesc.nodes.keySet().removeAll(java.util.Arrays.asList(update.descriptor.removeNodes)); + + for(int i = 0; i < update.descriptor.removeNodes.length; ++i) + { + Node node = findNode(update.descriptor.removeNodes[i]); + if(node.remove(update.descriptor.name)) + { + int index = getIndex(node); + _nodes.remove(node); + _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node}); + } + } + + // + // Add/update + // + java.util.Iterator p = update.descriptor.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.descriptor.serviceTemplates.keySet(), update.descriptor.serverTemplates.keySet()); + } + freshNodes.add(node); + } + + // + // Notify non-fresh nodes if needed + // + if(variablesChanged || !update.descriptor.serviceTemplates.isEmpty() || !update.descriptor.serverTemplates.isEmpty()) + { + p = _nodes.iterator(); + while(p.hasNext()) + { + Node node = (Node)p.next(); + if(!freshNodes.contains(node)) + { + node.update(appDesc, null, variablesChanged, + update.descriptor.serviceTemplates.keySet(), update.descriptor.serverTemplates.keySet()); + } + } + } } public void adapterInit(AdapterInfo[] adapters) { - for(int i = 0; i < adapters.length; ++i) - { - _adapters.put(adapters[i].id, adapters[i]); - } + 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); + _adapters.put(info.id, info); } public void adapterUpdated(AdapterInfo info) { - _adapters.put(info.id, info); + _adapters.put(info.id, info); } public void adapterRemoved(String id) { - _adapters.remove(id); + _adapters.remove(id); } public void objectInit(ObjectInfo[] objects) { - for(int i = 0; i < objects.length; ++i) - { - _objects.put(Ice.Util.identityToString(objects[i].proxy.ice_getIdentity()), objects[i]); - } + 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); + _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); + _objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info); } public void objectRemoved(Ice.Identity id) { - _objects.remove(Ice.Util.identityToString(id)); + _objects.remove(Ice.Util.identityToString(id)); } @@ -554,38 +554,38 @@ public class Root extends ListArrayTreeNode // public void registryUp(RegistryInfo info) { - if(info.name.equals(_replicaName)) - { - _info = info; - } - else - { - Slave newSlave = new Slave(this, info, _replicaName); - - int i; - for(i = 0; i < _slaves.size(); ++i) - { - String otherName = _slaves.get(i).toString(); - if(info.name.compareTo(otherName) > 0) - { - i++; - break; - } - } - _slaves.add(i, newSlave); - _treeModel.nodesWereInserted(this, new int[]{i}); - } + if(info.name.equals(_replicaName)) + { + _info = info; + } + else + { + Slave newSlave = new Slave(this, info, _replicaName); + + int i; + for(i = 0; i < _slaves.size(); ++i) + { + String otherName = _slaves.get(i).toString(); + if(info.name.compareTo(otherName) > 0) + { + i++; + break; + } + } + _slaves.add(i, newSlave); + _treeModel.nodesWereInserted(this, new int[]{i}); + } } public void registryDown(String name) { - TreeNodeBase registry = find(name, _slaves); - if(registry != null) - { - int index = getIndex(registry); - _slaves.remove(registry); - _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{registry}); - } + TreeNodeBase registry = find(name, _slaves); + if(registry != null) + { + int index = getIndex(registry); + _slaves.remove(registry); + _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{registry}); + } } // @@ -593,91 +593,91 @@ public class Root extends ListArrayTreeNode // public void nodeUp(NodeDynamicInfo updatedInfo) { - Node node = findNode(updatedInfo.info.name); - if(node != null) - { - node.up(updatedInfo, true); - } - else - { - insertNode(new Node(this, 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); - _nodes.remove(node); - _treeModel.nodesWereRemoved(this, new int[]{index}, new Object[]{node}); - } - } + Node node = findNode(nodeName); + if(node != null) + { + if(node.down()) + { + int index = getIndex(node); + _nodes.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); - } + 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); - } + 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)); - _popup.addSeparator(); - _popup.add(la.get(RETRIEVE_STDOUT)); - _popup.add(la.get(RETRIEVE_STDERR)); - _popup.addSeparator(); - _popup.add(la.get(SHUTDOWN_REGISTRY)); - } - - la.setTarget(this); - return _popup; + LiveActions la = _coordinator.getLiveActionsForPopup(); + + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(la.get(ADD_OBJECT)); + _popup.addSeparator(); + _popup.add(la.get(RETRIEVE_STDOUT)); + _popup.add(la.get(RETRIEVE_STDERR)); + _popup.addSeparator(); + _popup.add(la.get(SHUTDOWN_REGISTRY)); + } + + la.setTarget(this); + return _popup; } public void setSelectedNode(TreeNode node) { - _tree.setSelectionPath(node.getPath()); + _tree.setSelectionPath(node.getPath()); } public JTree getTree() { - return _tree; + return _tree; } public DefaultTreeModel getTreeModel() { - return _treeModel; + return _treeModel; } public Coordinator getCoordinator() { - return _coordinator; + return _coordinator; } public String toString() { - return _label; + return _label; } // @@ -685,24 +685,24 @@ public class Root extends ListArrayTreeNode // 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; + while(node != this) + { + TreeNode parent = (TreeNode)node.getParent(); + if(parent.getIndex(node) == -1) + { + return false; + } + else + { + node = parent; + } + } + return true; } public void addObject() { - _addObjectDialog.showDialog(); + _addObjectDialog.showDialog(); } public void showObject(String proxy, String type) @@ -712,347 +712,347 @@ public class Root extends ListArrayTreeNode Root getRoot() { - return this; + return this; } java.util.SortedMap getObjects() { - return _objects; + return _objects; } java.util.SortedMap getAdapters() { - return _adapters; + return _adapters; } RegistryInfo getRegistryInfo() { - return _info; + return _info; } 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; + 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)); - } + 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)); - } + 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)); + } } public void retrieveOutput(final boolean stdout) { - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, RegistryNotExistException, RegistryUnreachableException - { - AdminSessionPrx session = _coordinator.getSession(); - - if(stdout) - { - return session.openRegistryStdOut(_replicaName, count); - } - else - { - return session.openRegistryStdErr(_replicaName, count); - } - } - - public String getTitle() - { - return "Registry " + _label + " " + (stdout ? "stdout" : "stderr"); - } - - public String getDefaultFilename() - { - return _replicaName + (stdout ? ".out" : ".err"); - } - }); + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, RegistryNotExistException, RegistryUnreachableException + { + AdminSessionPrx session = _coordinator.getSession(); + + if(stdout) + { + return session.openRegistryStdOut(_replicaName, count); + } + else + { + return session.openRegistryStdErr(_replicaName, count); + } + } + + public String getTitle() + { + return "Registry " + _label + " " + (stdout ? "stdout" : "stderr"); + } + + public String getDefaultFilename() + { + return _replicaName + (stdout ? ".out" : ".err"); + } + }); } PropertySetDescriptor findNamedPropertySet(String name, String applicationName) { - ApplicationInfo app = (ApplicationInfo) - _infoMap.get(applicationName); - return (PropertySetDescriptor)app.descriptor.propertySets.get(name); + ApplicationInfo app = (ApplicationInfo) + _infoMap.get(applicationName); + return (PropertySetDescriptor)app.descriptor.propertySets.get(name); } void openShowLogDialog(ShowLogDialog.FileIteratorFactory factory) { - ShowLogDialog d = (ShowLogDialog)_showLogDialogMap.get(factory.getTitle()); - if(d == null) - { - d = new ShowLogDialog(this, factory, - _logMaxLines, _logMaxSize, _logInitialLines, _logMaxReadSize, _logPeriod); - - _showLogDialogMap.put(factory.getTitle(), d); - } - else - { - d.toFront(); - } + ShowLogDialog d = (ShowLogDialog)_showLogDialogMap.get(factory.getTitle()); + if(d == null) + { + d = new ShowLogDialog(this, factory, + _logMaxLines, _logMaxSize, _logInitialLines, _logMaxReadSize, _logPeriod); + + _showLogDialogMap.put(factory.getTitle(), d); + } + else + { + d.toFront(); + } } void removeShowLogDialog(String title) { - _showLogDialogMap.remove(title); + _showLogDialogMap.remove(title); } public void closeAllShowLogDialogs() { - java.util.Iterator p = _showLogDialogMap.values().iterator(); - while(p.hasNext()) - { - ShowLogDialog d = (ShowLogDialog)p.next(); - d.close(false); - } - _showLogDialogMap.clear(); + java.util.Iterator p = _showLogDialogMap.values().iterator(); + while(p.hasNext()) + { + ShowLogDialog d = (ShowLogDialog)p.next(); + d.close(false); + } + _showLogDialogMap.clear(); } public int getMessageSizeMax() { - return _messageSizeMax; + return _messageSizeMax; } public void setLogPrefs(int maxLines, int maxSize, int initialLines, int maxReadSize, int period) { - _logMaxLines = maxLines; - _logMaxSize = maxSize; - _logInitialLines = initialLines; - _logMaxReadSize = maxReadSize; - _logPeriod = period; + _logMaxLines = maxLines; + _logMaxSize = maxSize; + _logInitialLines = initialLines; + _logMaxReadSize = maxReadSize; + _logPeriod = period; - storeLogPrefs(); + storeLogPrefs(); } private void loadLogPrefs() { - Preferences logPrefs = _coordinator.getPrefs().node("Log"); - _logMaxLines = logPrefs.getInt("maxLines", 500); - _logMaxSize = logPrefs.getInt("maxSize", 20000); - _logInitialLines = logPrefs.getInt("initialLines", 10); - _logMaxReadSize = logPrefs.getInt("maxReadSize", 10000); - _logPeriod = logPrefs.getInt("period", 300); - - if(_logMaxReadSize + 512 > _messageSizeMax) - { - _logMaxReadSize = _messageSizeMax - 512; - } + Preferences logPrefs = _coordinator.getPrefs().node("Log"); + _logMaxLines = logPrefs.getInt("maxLines", 500); + _logMaxSize = logPrefs.getInt("maxSize", 20000); + _logInitialLines = logPrefs.getInt("initialLines", 10); + _logMaxReadSize = logPrefs.getInt("maxReadSize", 10000); + _logPeriod = logPrefs.getInt("period", 300); + + if(_logMaxReadSize + 512 > _messageSizeMax) + { + _logMaxReadSize = _messageSizeMax - 512; + } } private void storeLogPrefs() { - Preferences logPrefs = _coordinator.getPrefs().node("Log"); - logPrefs.putInt("maxLines", _logMaxLines); - logPrefs.putInt("maxSize", _logMaxSize); - logPrefs.putInt("initialLines", _logInitialLines); - logPrefs.putInt("maxReadSize", _logMaxReadSize); - logPrefs.putInt("period", _logPeriod); + Preferences logPrefs = _coordinator.getPrefs().node("Log"); + logPrefs.putInt("maxLines", _logMaxLines); + logPrefs.putInt("maxSize", _logMaxSize); + logPrefs.putInt("initialLines", _logInitialLines); + logPrefs.putInt("maxReadSize", _logMaxReadSize); + logPrefs.putInt("period", _logPeriod); } private Node findNode(String nodeName) { - return (Node)find(nodeName, _nodes); + return (Node)find(nodeName, _nodes); } private void insertNode(Node node) { - String nodeName = node.toString(); - int i; - for(i = 0; i < _nodes.size(); ++i) - { - String otherNodeName = _nodes.get(i).toString(); - if(nodeName.compareTo(otherNodeName) > 0) - { - i++; - break; - } - } - _nodes.add(i, node); - _treeModel.nodesWereInserted(this, new int[]{_slaves.size() + i}); + String nodeName = node.toString(); + int i; + for(i = 0; i < _nodes.size(); ++i) + { + String otherNodeName = _nodes.get(i).toString(); + if(nodeName.compareTo(otherNodeName) > 0) + { + i++; + break; + } + } + _nodes.add(i, node); + _treeModel.nodesWereInserted(this, new int[]{_slaves.size() + i}); } private void removeNodes(int[] toRemoveIndices, java.util.List toRemove) { - if(toRemove.size() > 0) - { - _nodes.removeAll(toRemove); - _treeModel.nodesWereRemoved(this, toRemoveIndices, toRemove.toArray()); - } + if(toRemove.size() > 0) + { + _nodes.removeAll(toRemove); + _treeModel.nodesWereRemoved(this, toRemoveIndices, toRemove.toArray()); + } } private final Coordinator _coordinator; diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index e2bdab1af37..275bc022f46 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -31,888 +31,888 @@ class Server extends ListArrayTreeNode // 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[WRITE_MESSAGE] = _state != ServerState.Inactive; - actions[RETRIEVE_STDOUT] = true; - actions[RETRIEVE_STDERR] = true; - actions[RETRIEVE_LOG] = _serverDescriptor.logs.length > 0; - - actions[PATCH_SERVER] = - !_serverDescriptor.distrib.icepatch.equals(""); - - if(_state != ServerState.Inactive) - { - Node node = (Node)_parent; - if(!node.isRunningWindows()) - { - for(int i = SIGHUP; i <= SIGTERM; ++i) - { - actions[i] = true; - } - } - } - } - - return actions; + 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[WRITE_MESSAGE] = _state != ServerState.Inactive; + actions[RETRIEVE_STDOUT] = true; + actions[RETRIEVE_STDERR] = true; + actions[RETRIEVE_LOG] = _serverDescriptor.logs.length > 0; + + actions[PATCH_SERVER] = + !_serverDescriptor.distrib.icepatch.equals(""); + + if(_state != ServerState.Inactive) + { + Node node = (Node)_parent; + if(!node.isRunningWindows()) + { + for(int i = SIGHUP; i <= SIGTERM; ++i) + { + actions[i] = true; + } + } + } + } + + 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)); - } + 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)); - } + 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); + enableServer(true); } public void disable() { - enableServer(false); + enableServer(false); } public void writeMessage() { - if(_writeMessageDialog == null) - { - _writeMessageDialog = new WriteMessageDialog(getRoot()); - } - _writeMessageDialog.showDialog(_id); + if(_writeMessageDialog == null) + { + _writeMessageDialog = new WriteMessageDialog(getRoot()); + } + _writeMessageDialog.showDialog(_id); } public void retrieveOutput(final boolean stdout) { - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, DeploymentException - { - AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); - - if(stdout) - { - return adminSession.openServerStdOut(_id, count); - } - else - { - return adminSession.openServerStdErr(_id, count); - } - } - - public String getTitle() - { - return "Server " + _id + " " + (stdout ? "stdout" : "stderr"); - } - - public String getDefaultFilename() - { - return _id + (stdout ? ".out" : ".err"); - } - }); + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, DeploymentException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + + if(stdout) + { + return adminSession.openServerStdOut(_id, count); + } + else + { + return adminSession.openServerStdErr(_id, count); + } + } + + public String getTitle() + { + return "Server " + _id + " " + (stdout ? "stdout" : "stderr"); + } + + public String getDefaultFilename() + { + return _id + (stdout ? ".out" : ".err"); + } + }); } public void retrieveLog() { - assert _serverDescriptor.logs.length > 0; - - String path = null; - - if(_serverDescriptor.logs.length == 1) - { - path = _resolver.substitute(_serverDescriptor.logs[0]); - } - else - { - Object[] pathArray = new Object[_serverDescriptor.logs.length]; - for(int i = 0; i < _serverDescriptor.logs.length; ++i) - { - pathArray[i] = _resolver.substitute(_serverDescriptor.logs[i]); - } - - path = (String)JOptionPane.showInputDialog( - getCoordinator().getMainFrame(), - "Which log file do you want to retrieve?", - "Retrieve Log File", - JOptionPane.QUESTION_MESSAGE, null, - pathArray, pathArray[0]); - } + assert _serverDescriptor.logs.length > 0; + + String path = null; + + if(_serverDescriptor.logs.length == 1) + { + path = _resolver.substitute(_serverDescriptor.logs[0]); + } + else + { + Object[] pathArray = new Object[_serverDescriptor.logs.length]; + for(int i = 0; i < _serverDescriptor.logs.length; ++i) + { + pathArray[i] = _resolver.substitute(_serverDescriptor.logs[i]); + } + + path = (String)JOptionPane.showInputDialog( + getCoordinator().getMainFrame(), + "Which log file do you want to retrieve?", + "Retrieve Log File", + JOptionPane.QUESTION_MESSAGE, null, + pathArray, pathArray[0]); + } - if(path != null) - { - final String fPath = path; - - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, - DeploymentException - { - AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); - return adminSession.openServerLog(_id, fPath, count); - } - - public String getTitle() - { - return "Server " + _id + " " + new java.io.File(fPath).getName(); - } - - public String getDefaultFilename() - { - return new java.io.File(fPath).getName(); - } - }); - } + if(path != null) + { + final String fPath = path; + + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, + DeploymentException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + return adminSession.openServerLog(_id, fPath, count); + } + + public String getTitle() + { + return "Server " + _id + " " + new java.io.File(fPath).getName(); + } + + public String getDefaultFilename() + { + return new java.io.File(fPath).getName(); + } + }); + } } public void signal(final String s) { - final String prefix = "Sending '" + s + "' to server '" + _id + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - AMI_Admin_sendSignal cb = new AMI_Admin_sendSignal() - { - // - // Called by another thread! - // - public void ice_response() - { - amiSuccess(prefix); - } - - public void ice_exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e); - } - - public void ice_exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); - } - }; - - try - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().sendSignal_async(cb, _id, s); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); - } - finally - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + final String prefix = "Sending '" + s + "' to server '" + _id + "'..."; + getCoordinator().getStatusBar().setText(prefix); + + AMI_Admin_sendSignal cb = new AMI_Admin_sendSignal() + { + // + // Called by another thread! + // + public void ice_response() + { + amiSuccess(prefix); + } + + public void ice_exception(Ice.UserException e) + { + amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e); + } + + public void ice_exception(Ice.LocalException e) + { + amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); + } + }; + + try + { + getCoordinator().getMainFrame().setCursor( + Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + getCoordinator().getAdmin().sendSignal_async(cb, _id, s); + } + catch(Ice.LocalException e) + { + failure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); + } + finally + { + getCoordinator().getMainFrame().setCursor( + Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } } public void patchServer() { - String message = _serverDescriptor.applicationDistrib ? - "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?" : - "You are about to install or refresh the distribution for this server.\n" - + "Do you want to shut down the server for this update?"; - - int shutdown = JOptionPane.showConfirmDialog( - getCoordinator().getMainFrame(), - message, - "Patch Confirmation", - JOptionPane.YES_NO_CANCEL_OPTION); + String message = _serverDescriptor.applicationDistrib ? + "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?" : + "You are about to install or refresh the distribution for this server.\n" + + "Do you want to shut down the server for this update?"; + + int shutdown = JOptionPane.showConfirmDialog( + getCoordinator().getMainFrame(), + message, + "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)); - } + 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)); - } + 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)); - _popup.addSeparator(); - _popup.add(la.get(WRITE_MESSAGE)); - _popup.add(la.get(RETRIEVE_STDOUT)); - _popup.add(la.get(RETRIEVE_STDERR)); - _popup.add(la.get(RETRIEVE_LOG)); - _popup.addSeparator(); - - _signalMenu = new JMenu("Send Signal"); - _popup.add(_signalMenu); - - _signalMenu.add(la.get(SIGHUP)); - _signalMenu.add(la.get(SIGINT)); - _signalMenu.add(la.get(SIGQUIT)); - _signalMenu.add(la.get(SIGKILL)); - _signalMenu.add(la.get(SIGUSR1)); - _signalMenu.add(la.get(SIGUSR2)); - _signalMenu.add(la.get(SIGTERM)); - } - - la.setTarget(this); - _signalMenu.setEnabled(la.get(SIGHUP).isEnabled()); - return _popup; + 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)); + _popup.addSeparator(); + _popup.add(la.get(WRITE_MESSAGE)); + _popup.add(la.get(RETRIEVE_STDOUT)); + _popup.add(la.get(RETRIEVE_STDERR)); + _popup.add(la.get(RETRIEVE_LOG)); + _popup.addSeparator(); + + _signalMenu = new JMenu("Send Signal"); + _popup.add(_signalMenu); + + _signalMenu.add(la.get(SIGHUP)); + _signalMenu.add(la.get(SIGINT)); + _signalMenu.add(la.get(SIGQUIT)); + _signalMenu.add(la.get(SIGKILL)); + _signalMenu.add(la.get(SIGUSR1)); + _signalMenu.add(la.get(SIGUSR2)); + _signalMenu.add(la.get(SIGTERM)); + } + + la.setTarget(this); + _signalMenu.setEnabled(la.get(SIGHUP).isEnabled()); + return _popup; } public Editor getEditor() { - if(_editor == null) - { - _editor = new ServerEditor(getCoordinator()); - } - _editor.show(this); - return _editor; + 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[8][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.ActivationTimedOut.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.ActivationTimedOut.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.ActivationTimedOut.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.ActivationTimedOut.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); + 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[8][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.ActivationTimedOut.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.ActivationTimedOut.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.ActivationTimedOut.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.ActivationTimedOut.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(); + 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; + return _application; } ServerInstanceDescriptor getInstanceDescriptor() { - return _instanceDescriptor; + return _instanceDescriptor; } ServerDescriptor getServerDescriptor() { - return _serverDescriptor; + return _serverDescriptor; } ServerState getState() { - return _state; + return _state; } int getPid() { - return _pid; + return _pid; } boolean isEnabled() { - return _enabled; + return _enabled; } Utils.Resolver getResolver() { - return _resolver; + return _resolver; } void rebuild(Server server) - { - _resolver = server._resolver; - _instanceDescriptor = server._instanceDescriptor; - _serverDescriptor = server._serverDescriptor; - _application = server._application; - _adapters = server._adapters; - _dbEnvs = server._dbEnvs; + { + _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; + _services = server._services; + + _childrenArray[0] = _adapters; + _childrenArray[1] = _dbEnvs; + _childrenArray[2] = _services; - getRoot().getTreeModel().nodeStructureChanged(this); + getRoot().getTreeModel().nodeStructureChanged(this); } void rebuild(Utils.Resolver resolver, boolean variablesChanged, java.util.Set serviceTemplates, - java.util.Set serverTemplates) - { - if(variablesChanged || - (_instanceDescriptor != null && serverTemplates != 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; - } - else - { - _resolver.reset(resolver); - _resolver.put("server", _id); - } - - _adapters.clear(); - createAdapters(); - _dbEnvs.clear(); - createDbEnvs(); - _services.clear(); - _servicePropertySets.clear(); - createServices(); - - getRoot().getTreeModel().nodeStructureChanged(this); - } - else if(serviceTemplates != null && serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor) - { - _services.clear(); - _servicePropertySets.clear(); - createServices(); - getRoot().getTreeModel().nodeStructureChanged(this); - } + java.util.Set serverTemplates) + { + if(variablesChanged || + (_instanceDescriptor != null && serverTemplates != 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; + } + else + { + _resolver.reset(resolver); + _resolver.put("server", _id); + } + + _adapters.clear(); + createAdapters(); + _dbEnvs.clear(); + createDbEnvs(); + _services.clear(); + _servicePropertySets.clear(); + createServices(); + + getRoot().getTreeModel().nodeStructureChanged(this); + } + else if(serviceTemplates != null && serviceTemplates.size() > 0 && _serverDescriptor instanceof IceBoxDescriptor) + { + _services.clear(); + _servicePropertySets.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); - } - } + 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; + 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; + 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); + 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.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() { - java.util.List psList = new java.util.LinkedList(); - Node node = (Node)_parent; + java.util.List psList = new java.util.LinkedList(); + Node node = (Node)_parent; - - psList.add(node.expand(_serverDescriptor.propertySet, - _application.name, _resolver)); + + psList.add(node.expand(_serverDescriptor.propertySet, + _application.name, _resolver)); - if(_instanceDescriptor != null) - { - psList.add(node.expand(_instanceDescriptor.propertySet, - _application.name, _resolver)); - } + if(_instanceDescriptor != null) + { + psList.add(node.expand(_instanceDescriptor.propertySet, + _application.name, _resolver)); + } - return Utils.propertySetsToMap(psList, _resolver); + return Utils.propertySetsToMap(psList, _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); - } + 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); - } + 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) - { - if(_instanceDescriptor != null) - { - java.util.Iterator p = _instanceDescriptor.servicePropertySets.entrySet().iterator(); - while(p.hasNext()) - { - java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); - _servicePropertySets.put(_resolver.substitute((String)entry.getKey()), entry.getValue()); - } - } - - IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor; - - java.util.Iterator p = iceBoxDescriptor.services.iterator(); - while(p.hasNext()) - { - ServiceInstanceDescriptor descriptor = (ServiceInstanceDescriptor)p.next(); - createService(descriptor); - } - } + if(_serverDescriptor instanceof IceBoxDescriptor) + { + if(_instanceDescriptor != null) + { + java.util.Iterator p = _instanceDescriptor.servicePropertySets.entrySet().iterator(); + while(p.hasNext()) + { + java.util.Map.Entry entry = (java.util.Map.Entry)p.next(); + _servicePropertySets.put(_resolver.substitute((String)entry.getKey()), entry.getValue()); + } + } + + IceBoxDescriptor iceBoxDescriptor = (IceBoxDescriptor)_serverDescriptor; + + java.util.Iterator p = iceBoxDescriptor.services.iterator(); + while(p.hasNext()) + { + 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); - } - - PropertySetDescriptor serverInstancePSDescriptor = - (PropertySetDescriptor)_servicePropertySets.get(serviceName); - - _services.add(new Service(this, serviceName, serviceResolver, - descriptor, serviceDescriptor, serverInstancePSDescriptor)); + 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); + } + + PropertySetDescriptor serverInstancePSDescriptor = + (PropertySetDescriptor)_servicePropertySets.get(serviceName); + + _services.add(new Service(this, serviceName, serviceResolver, + descriptor, serviceDescriptor, serverInstancePSDescriptor)); } 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; + String result = (state == null ? "Unknown" : state.toString()); + + if(!enabled) + { + result += ", disabled"; + } + + if(pid != 0) + { + result += ", pid: " + pid; + } + return result; } diff --git a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java index 16a6d05f888..37299ce5be2 100755 --- a/java/src/IceGridGUI/LiveDeployment/ServerEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServerEditor.java @@ -34,244 +34,244 @@ class ServerEditor extends CommunicatorEditor { public JToolBar getToolBar() { - if(_toolBar == null) - { - _toolBar = new ToolBar(); - } - return _toolBar; + 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); - _iceVersion.setEditable(false); - _exe.setEditable(false); - _pwd.setEditable(false); + _coordinator = c; + _currentState.setEditable(false); + _currentPid.setEditable(false); + _enabled.setEnabled(false); + + _application.setEditable(false); + _iceVersion.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) - { - ApplicationPane app = _coordinator.openLiveApplication(_application.getText()); - if(app != null) - { - app.getRoot(). - selectServer(((Node)_target.getParent()).getId(), _target.getId()); - } - } - }; - gotoApplication.putValue(Action.SHORT_DESCRIPTION, - "View/Edit this application"); - _gotoApplication = new JButton(gotoApplication); + _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) + { + ApplicationPane app = _coordinator.openLiveApplication(_application.getText()); + if(app != null) + { + app.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")); - _iceVersion.setText(resolver.substitute(descriptor.iceVersion)); - - 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); + _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")); + _iceVersion.setText(resolver.substitute(descriptor.iceVersion)); + + 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(); - builder.append("Ice Version"); - builder.append(_iceVersion, 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(_icepatch, 3); - builder.nextLine(); - builder.append("Directories"); - builder.append(_directories, 3); - builder.nextLine(); + 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(); + builder.append("Ice Version"); + builder.append(_iceVersion, 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(_icepatch, 3); + builder.nextLine(); + builder.append("Directories"); + builder.append(_directories, 3); + builder.nextLine(); } protected void buildPropertiesPanel() { - super.buildPropertiesPanel(); - _propertiesPanel.setName("Server Properties"); + 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 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)); + } } diff --git a/java/src/IceGridGUI/LiveDeployment/Service.java b/java/src/IceGridGUI/LiveDeployment/Service.java index dae7bd628a4..5fd67100a4f 100755 --- a/java/src/IceGridGUI/LiveDeployment/Service.java +++ b/java/src/IceGridGUI/LiveDeployment/Service.java @@ -27,247 +27,247 @@ class Service extends ListArrayTreeNode // public boolean[] getAvailableActions() { - boolean[] actions = new boolean[ACTION_COUNT]; + boolean[] actions = new boolean[ACTION_COUNT]; - if(((Server)_parent).getState() != null) - { - actions[RETRIEVE_LOG] = _serviceDescriptor.logs.length > 0; - } - return actions; + if(((Server)_parent).getState() != null) + { + actions[RETRIEVE_LOG] = _serviceDescriptor.logs.length > 0; + } + return actions; } public void retrieveLog() { - assert _serviceDescriptor.logs.length > 0; - - String path = null; - - if(_serviceDescriptor.logs.length == 1) - { - path = _resolver.substitute(_serviceDescriptor.logs[0]); - } - else - { - Object[] pathArray = new Object[_serviceDescriptor.logs.length]; - for(int i = 0; i < _serviceDescriptor.logs.length; ++i) - { - pathArray[i] = _resolver.substitute(_serviceDescriptor.logs[i]); - } - - path = (String)JOptionPane.showInputDialog( - getCoordinator().getMainFrame(), - "Which log file do you want to retrieve?", - "Retrieve Log File", - JOptionPane.QUESTION_MESSAGE, null, - pathArray, pathArray[0]); - } + assert _serviceDescriptor.logs.length > 0; + + String path = null; + + if(_serviceDescriptor.logs.length == 1) + { + path = _resolver.substitute(_serviceDescriptor.logs[0]); + } + else + { + Object[] pathArray = new Object[_serviceDescriptor.logs.length]; + for(int i = 0; i < _serviceDescriptor.logs.length; ++i) + { + pathArray[i] = _resolver.substitute(_serviceDescriptor.logs[i]); + } + + path = (String)JOptionPane.showInputDialog( + getCoordinator().getMainFrame(), + "Which log file do you want to retrieve?", + "Retrieve Log File", + JOptionPane.QUESTION_MESSAGE, null, + pathArray, pathArray[0]); + } - if(path != null) - { - final String fPath = path; - - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, - DeploymentException - { - AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); - return adminSession.openServerLog(_parent.getId(), fPath, count); - } - - public String getTitle() - { - return "Service " + _parent.getId() + "/" + _id + " " + new java.io.File(fPath).getName(); - } - - public String getDefaultFilename() - { - return new java.io.File(fPath).getName(); - } - }); - } + if(path != null) + { + final String fPath = path; + + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, ServerNotExistException, NodeUnreachableException, + DeploymentException + { + AdminSessionPrx adminSession = getRoot().getCoordinator().getSession(); + return adminSession.openServerLog(_parent.getId(), fPath, count); + } + + public String getTitle() + { + return "Service " + _parent.getId() + "/" + _id + " " + new java.io.File(fPath).getName(); + } + + public String getDefaultFilename() + { + return new java.io.File(fPath).getName(); + } + }); + } } public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + 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); + 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; + if(_editor == null) + { + _editor = new ServiceEditor(); + } + _editor.show(this); + return _editor; } public JPopupMenu getPopupMenu() { - LiveActions la = getCoordinator().getLiveActionsForPopup(); - - if(_popup == null) - { - _popup = new JPopupMenu(); - _popup.add(la.get(RETRIEVE_LOG)); - } - - la.setTarget(this); - return _popup; + LiveActions la = getCoordinator().getLiveActionsForPopup(); + + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(la.get(RETRIEVE_LOG)); + } + + la.setTarget(this); + return _popup; } Service(Server parent, String serviceName, Utils.Resolver resolver, - ServiceInstanceDescriptor descriptor, - ServiceDescriptor serviceDescriptor, - PropertySetDescriptor serverInstancePSDescriptor) + ServiceInstanceDescriptor descriptor, + ServiceDescriptor serviceDescriptor, + PropertySetDescriptor serverInstancePSDescriptor) { - super(parent, serviceName, 2); - _resolver = resolver; - - _instanceDescriptor = descriptor; - _serviceDescriptor = serviceDescriptor; - _serverInstancePSDescriptor = serverInstancePSDescriptor; - - _childrenArray[0] = _adapters; - _childrenArray[1] = _dbEnvs; - - createAdapters(); - createDbEnvs(); + super(parent, serviceName, 2); + _resolver = resolver; + + _instanceDescriptor = descriptor; + _serviceDescriptor = serviceDescriptor; + _serverInstancePSDescriptor = serverInstancePSDescriptor; + + _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; + 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; + 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); - } + java.util.Iterator p = _adapters.iterator(); + while(p.hasNext()) + { + Adapter adapter = (Adapter)p.next(); + adapter.update((AdapterDynamicInfo)null); + } } Utils.Resolver getResolver() { - return _resolver; + return _resolver; } ServiceDescriptor getServiceDescriptor() { - return _serviceDescriptor; + return _serviceDescriptor; } ServiceInstanceDescriptor getInstanceDescriptor() { - return _instanceDescriptor; + return _instanceDescriptor; } java.util.SortedMap getProperties() { - java.util.List psList = new java.util.LinkedList(); - Node node = (Node)_parent.getParent(); + java.util.List psList = new java.util.LinkedList(); + Node node = (Node)_parent.getParent(); - String applicationName = ((Server)_parent).getApplication().name; + String applicationName = ((Server)_parent).getApplication().name; - psList.add(node.expand(_serviceDescriptor.propertySet, - applicationName, _resolver)); + psList.add(node.expand(_serviceDescriptor.propertySet, + applicationName, _resolver)); - if(_instanceDescriptor != null) - { - psList.add(node.expand(_instanceDescriptor.propertySet, - applicationName, _resolver)); - } + if(_instanceDescriptor != null) + { + psList.add(node.expand(_instanceDescriptor.propertySet, + applicationName, _resolver)); + } - if(_serverInstancePSDescriptor != null) - { - psList.add(node.expand(_serverInstancePSDescriptor, - applicationName, _resolver)); + if(_serverInstancePSDescriptor != null) + { + psList.add(node.expand(_serverInstancePSDescriptor, + applicationName, _resolver)); - } + } - return Utils.propertySetsToMap(psList, _resolver); + return Utils.propertySetsToMap(psList, _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); - } + 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); - } + 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 final ServiceInstanceDescriptor _instanceDescriptor; diff --git a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java index 53e5e1c4e6e..e4768aa7c19 100755 --- a/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/ServiceEditor.java @@ -18,32 +18,32 @@ class ServiceEditor extends CommunicatorEditor { ServiceEditor() { - _entry.setEditable(false); + _entry.setEditable(false); } void show(Service service) { - ServiceDescriptor descriptor = service.getServiceDescriptor(); - Utils.Resolver resolver = service.getResolver(); + ServiceDescriptor descriptor = service.getServiceDescriptor(); + Utils.Resolver resolver = service.getResolver(); - show(descriptor, service.getProperties(), resolver); - _entry.setText(resolver.substitute(descriptor.entry)); + show(descriptor, service.getProperties(), resolver); + _entry.setText(resolver.substitute(descriptor.entry)); } protected void appendProperties(DefaultFormBuilder builder) { - super.appendProperties(builder); + super.appendProperties(builder); - builder.append("Entry Point"); - builder.append(_entry, 3); - builder.nextLine(); + builder.append("Entry Point"); + builder.append(_entry, 3); + builder.nextLine(); } protected void buildPropertiesPanel() { - super.buildPropertiesPanel(); - _propertiesPanel.setName("Service Properties"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Service Properties"); } private JTextField _entry = new JTextField(20); diff --git a/java/src/IceGridGUI/LiveDeployment/ShowLogDialog.java b/java/src/IceGridGUI/LiveDeployment/ShowLogDialog.java index c74f3508866..6454cbfeac8 100644 --- a/java/src/IceGridGUI/LiveDeployment/ShowLogDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ShowLogDialog.java @@ -48,697 +48,697 @@ class ShowLogDialog extends JDialog { static interface FileIteratorFactory { - FileIteratorPrx open(int count) - throws Ice.UserException; + FileIteratorPrx open(int count) + throws Ice.UserException; - String getTitle(); + String getTitle(); - String getDefaultFilename(); + String getDefaultFilename(); } private class FIFOTextArea extends JTextArea { - FIFOTextArea(int rows, int colums) - { - super(rows, colums); - setEditable(false); - setLineWrap(true); - } - - public void appendLines(final String[] lines, final int maxLines, final int maxSize) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - for(int i = 0; i < lines.length; ++i) - { - // - // The last line is always incomplete - // - if(i + 1 != lines.length) - { - append(lines[i] + "\n"); - } - else - { - append(lines[i]); - } - removeLines(maxLines, maxSize); - } - } - }); - } - - public void removeLines(int maxLines, int maxSize) - { - javax.swing.text.Document doc = getDocument(); - javax.swing.text.Element rootElt = doc.getDefaultRootElement(); - - // - // We keep at least one line, no matter its length - // - int lineCount = getLineCount(); - while(lineCount > 1 && (doc.getLength() > maxSize || (lineCount > maxLines))) - { - javax.swing.text.Element firstLine = rootElt.getElement(0); - try - { - doc.remove(0, firstLine.getEndOffset()); - } - catch(javax.swing.text.BadLocationException ble) - { - assert false; - } - lineCount--; - } - setCaretPosition(doc.getLength()); - } + FIFOTextArea(int rows, int colums) + { + super(rows, colums); + setEditable(false); + setLineWrap(true); + } + + public void appendLines(final String[] lines, final int maxLines, final int maxSize) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + for(int i = 0; i < lines.length; ++i) + { + // + // The last line is always incomplete + // + if(i + 1 != lines.length) + { + append(lines[i] + "\n"); + } + else + { + append(lines[i]); + } + removeLines(maxLines, maxSize); + } + } + }); + } + + public void removeLines(int maxLines, int maxSize) + { + javax.swing.text.Document doc = getDocument(); + javax.swing.text.Element rootElt = doc.getDefaultRootElement(); + + // + // We keep at least one line, no matter its length + // + int lineCount = getLineCount(); + while(lineCount > 1 && (doc.getLength() > maxSize || (lineCount > maxLines))) + { + javax.swing.text.Element firstLine = rootElt.getElement(0); + try + { + doc.remove(0, firstLine.getEndOffset()); + } + catch(javax.swing.text.BadLocationException ble) + { + assert false; + } + lineCount--; + } + setCaretPosition(doc.getLength()); + } } private class ReaderThread extends Thread { - ReaderThread() - { - _threadMaxLines = _maxLines; - _threadMaxSize = _maxSize; - _threadInitialLines = _initialLines; - _threadMaxReadSize = _maxReadSize; - _threadPeriod = _period; - - _playButton.setSelected(true); - _playItem.setSelected(true); - _pause.setEnabled(true); - } - - private void openError(final String message) - { - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - if(_textArea.getText() == null || _textArea.getText().length() == 0) - { - close(true); - } - else - { - stopReading(); - } - - JOptionPane.showMessageDialog( - ShowLogDialog.this, - message, - _factory.getTitle() + ": cannot open file", - JOptionPane.ERROR_MESSAGE); - } - }); - } - - - public void run() - { - // - // Open file - // - int initialLines; - - synchronized(this) - { - initialLines = _threadInitialLines; - } - - try - { - _p = _factory.open(initialLines); - } - catch(Ice.UserException e) - { - openError(e.toString()); - return; - } - catch(Ice.LocalException e) - { - openError(e.toString()); - return; - } - - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - if(isVisible()) - { - _textArea.setText(null); - } - else - { - setVisible(true); - } - } - }); - - boolean firstRun = true; - for(;;) - { - synchronized(this) - { - if(!_done) - { - if(_paused) - { - while(_paused && !_done) - { - try - { - wait(); - } - catch(InterruptedException e) - { - } - } - } - else if(!firstRun) - { - try - { - wait(_threadPeriod); - } - catch(InterruptedException e) - { - } - } - else - { - firstRun = false; - } - } - - if(_done) - { - cleanupIterator(); - return; - } - } - - boolean eofEncountered = false; - - while(!eofEncountered) - { - int maxLines; - int maxSize; - int maxReadSize; - - synchronized(this) - { - if(_done || _paused) - { - break; // while(!eofEncountered) - } - - maxLines = _threadMaxLines; - maxSize = _threadMaxSize; - maxReadSize = _threadMaxReadSize; - } - - Ice.StringSeqHolder linesHolder = new Ice.StringSeqHolder(); - - try - { - eofEncountered = _p.read(maxReadSize, linesHolder); - } - catch(IceGrid.FileNotAvailableException e) - { - _textArea.appendLines(new String[] - { - "---------------------------", - "IceGridAdmin caught: " + e.toString(), - "---------------------------" - }, maxLines, maxSize); - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - stopReading(); - } - }); - cleanupIterator(); - return; - } - catch(Ice.LocalException e) - { - _textArea.appendLines(new String[] - { - "---------------------------", - "IceGridAdmin caught: " + e.toString(), - "---------------------------" - }, maxLines, maxSize); - SwingUtilities.invokeLater( - new Runnable() - { - public void run() - { - stopReading(); - } - }); - return; - } - - _textArea.appendLines(linesHolder.value, maxLines, maxSize); - } - } - } - - private void cleanupIterator() - { - try - { - _p.destroy(); - } - catch(Ice.LocalException e) - { - // Ignored, maybe should log warning - } - } - - synchronized void pause() - { - if(!_paused) - { - _paused = true; - notify(); - } - } - - synchronized void terminate() - { - if(!_done) - { - _done = true; - notify(); - } - } - - synchronized void play() - { - if(_paused) - { - _paused = false; - notify(); - } - } - - synchronized void setPrefs() - { - _threadMaxLines = _maxLines; - _threadMaxSize = _maxSize; - _threadInitialLines = _initialLines; - _threadMaxReadSize = _maxReadSize; - _threadPeriod = _period; - } - - private FileIteratorPrx _p; - private boolean _done = false; - private boolean _paused = false; - - private int _threadMaxLines; - private int _threadMaxSize; - private int _threadInitialLines; - private int _threadMaxReadSize; - private int _threadPeriod; + ReaderThread() + { + _threadMaxLines = _maxLines; + _threadMaxSize = _maxSize; + _threadInitialLines = _initialLines; + _threadMaxReadSize = _maxReadSize; + _threadPeriod = _period; + + _playButton.setSelected(true); + _playItem.setSelected(true); + _pause.setEnabled(true); + } + + private void openError(final String message) + { + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + if(_textArea.getText() == null || _textArea.getText().length() == 0) + { + close(true); + } + else + { + stopReading(); + } + + JOptionPane.showMessageDialog( + ShowLogDialog.this, + message, + _factory.getTitle() + ": cannot open file", + JOptionPane.ERROR_MESSAGE); + } + }); + } + + + public void run() + { + // + // Open file + // + int initialLines; + + synchronized(this) + { + initialLines = _threadInitialLines; + } + + try + { + _p = _factory.open(initialLines); + } + catch(Ice.UserException e) + { + openError(e.toString()); + return; + } + catch(Ice.LocalException e) + { + openError(e.toString()); + return; + } + + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + if(isVisible()) + { + _textArea.setText(null); + } + else + { + setVisible(true); + } + } + }); + + boolean firstRun = true; + for(;;) + { + synchronized(this) + { + if(!_done) + { + if(_paused) + { + while(_paused && !_done) + { + try + { + wait(); + } + catch(InterruptedException e) + { + } + } + } + else if(!firstRun) + { + try + { + wait(_threadPeriod); + } + catch(InterruptedException e) + { + } + } + else + { + firstRun = false; + } + } + + if(_done) + { + cleanupIterator(); + return; + } + } + + boolean eofEncountered = false; + + while(!eofEncountered) + { + int maxLines; + int maxSize; + int maxReadSize; + + synchronized(this) + { + if(_done || _paused) + { + break; // while(!eofEncountered) + } + + maxLines = _threadMaxLines; + maxSize = _threadMaxSize; + maxReadSize = _threadMaxReadSize; + } + + Ice.StringSeqHolder linesHolder = new Ice.StringSeqHolder(); + + try + { + eofEncountered = _p.read(maxReadSize, linesHolder); + } + catch(IceGrid.FileNotAvailableException e) + { + _textArea.appendLines(new String[] + { + "---------------------------", + "IceGridAdmin caught: " + e.toString(), + "---------------------------" + }, maxLines, maxSize); + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + stopReading(); + } + }); + cleanupIterator(); + return; + } + catch(Ice.LocalException e) + { + _textArea.appendLines(new String[] + { + "---------------------------", + "IceGridAdmin caught: " + e.toString(), + "---------------------------" + }, maxLines, maxSize); + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + stopReading(); + } + }); + return; + } + + _textArea.appendLines(linesHolder.value, maxLines, maxSize); + } + } + } + + private void cleanupIterator() + { + try + { + _p.destroy(); + } + catch(Ice.LocalException e) + { + // Ignored, maybe should log warning + } + } + + synchronized void pause() + { + if(!_paused) + { + _paused = true; + notify(); + } + } + + synchronized void terminate() + { + if(!_done) + { + _done = true; + notify(); + } + } + + synchronized void play() + { + if(_paused) + { + _paused = false; + notify(); + } + } + + synchronized void setPrefs() + { + _threadMaxLines = _maxLines; + _threadMaxSize = _maxSize; + _threadInitialLines = _initialLines; + _threadMaxReadSize = _maxReadSize; + _threadPeriod = _period; + } + + private FileIteratorPrx _p; + private boolean _done = false; + private boolean _paused = false; + + private int _threadMaxLines; + private int _threadMaxSize; + private int _threadInitialLines; + private int _threadMaxReadSize; + private int _threadPeriod; } private class MenuBar extends JMenuBar { - private MenuBar() - { - putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); - putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); - - final int MENU_MASK = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - - // - // File menu - // - JMenu fileMenu = new JMenu("File"); - fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); - add(fileMenu); - - ButtonGroup bg = new ButtonGroup(); - - _pauseItem = new JRadioButtonMenuItem(_pause); - fileMenu.add(_pauseItem); - bg.add(_pauseItem); - _playItem = new JRadioButtonMenuItem(_play); - fileMenu.add(_playItem); - bg.add(_playItem); - _stopItem = new JRadioButtonMenuItem(_stop); - fileMenu.add(_stopItem); - bg.add(_stopItem); - fileMenu.addSeparator(); + private MenuBar() + { + putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); + putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); + + final int MENU_MASK = java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); + + // + // File menu + // + JMenu fileMenu = new JMenu("File"); + fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); + add(fileMenu); + + ButtonGroup bg = new ButtonGroup(); + + _pauseItem = new JRadioButtonMenuItem(_pause); + fileMenu.add(_pauseItem); + bg.add(_pauseItem); + _playItem = new JRadioButtonMenuItem(_play); + fileMenu.add(_playItem); + bg.add(_playItem); + _stopItem = new JRadioButtonMenuItem(_stop); + fileMenu.add(_stopItem); + bg.add(_stopItem); + fileMenu.addSeparator(); - Action save = new AbstractAction("Save As...") - { - public void actionPerformed(ActionEvent e) - { - JFileChooser fileChooser = _root.getCoordinator().getSaveLogChooser(); - - fileChooser.setSelectedFile(new java.io.File(fileChooser.getCurrentDirectory(), - _factory.getDefaultFilename())); - - java.io.File file = null; - - while(file == null) - { - int result = fileChooser.showSaveDialog(ShowLogDialog.this); - if(result == JFileChooser.APPROVE_OPTION) - { - file = fileChooser.getSelectedFile(); - - if(file != null) - { - if(!file.exists() && file.getName().indexOf('.') == -1) - { - file = new java.io.File(file.getAbsolutePath() + ".log"); - } - - java.io.OutputStreamWriter os = null; - - try - { - os = new java.io.OutputStreamWriter(new java.io.FileOutputStream(file)); - String txt = _textArea.getText(); - if(txt == null) - { - txt = ""; - } - os.write(txt, 0, txt.length()); - } - catch(java.io.IOException io) - { - JOptionPane.showMessageDialog( - ShowLogDialog.this, - io.toString(), - "Cannot write file", - JOptionPane.ERROR_MESSAGE); - } - finally - { - if(os != null) - { - try - { - os.close(); - } - catch(java.io.IOException io) - { - } - } - } - } - } - else - { - break; // while - } - } - } - }; - save.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK)); - save.putValue(Action.SHORT_DESCRIPTION, "Save As..."); - fileMenu.add(save); - fileMenu.addSeparator(); - - fileMenu.add(new AbstractAction("Close") - { - public void actionPerformed(ActionEvent e) - { - close(true); - } - }); - JMenu editMenu = new JMenu("Edit"); - editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E); - add(editMenu); - - Action copy = new AbstractAction("Copy") - { - public void actionPerformed(ActionEvent e) - { - _textArea.copy(); - } - - }; - copy.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK)); - copy.putValue(Action.SHORT_DESCRIPTION, "Copy"); - editMenu.add(copy); - - editMenu.addSeparator(); - Action selectAll = new AbstractAction("Select All") - { - public void actionPerformed(ActionEvent e) - { - _textArea.grabFocus(); - _textArea.selectAll(); - } - }; - selectAll.putValue(Action.ACCELERATOR_KEY, - KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK)); - selectAll.putValue(Action.SHORT_DESCRIPTION, "Select All"); - - editMenu.add(selectAll); - editMenu.addSeparator(); - editMenu.add(new AbstractAction("Preferences...") - { - public void actionPerformed(ActionEvent e) - { - new ShowLogPrefsDialog(ShowLogDialog.this); - } - }); - } + Action save = new AbstractAction("Save As...") + { + public void actionPerformed(ActionEvent e) + { + JFileChooser fileChooser = _root.getCoordinator().getSaveLogChooser(); + + fileChooser.setSelectedFile(new java.io.File(fileChooser.getCurrentDirectory(), + _factory.getDefaultFilename())); + + java.io.File file = null; + + while(file == null) + { + int result = fileChooser.showSaveDialog(ShowLogDialog.this); + if(result == JFileChooser.APPROVE_OPTION) + { + file = fileChooser.getSelectedFile(); + + if(file != null) + { + if(!file.exists() && file.getName().indexOf('.') == -1) + { + file = new java.io.File(file.getAbsolutePath() + ".log"); + } + + java.io.OutputStreamWriter os = null; + + try + { + os = new java.io.OutputStreamWriter(new java.io.FileOutputStream(file)); + String txt = _textArea.getText(); + if(txt == null) + { + txt = ""; + } + os.write(txt, 0, txt.length()); + } + catch(java.io.IOException io) + { + JOptionPane.showMessageDialog( + ShowLogDialog.this, + io.toString(), + "Cannot write file", + JOptionPane.ERROR_MESSAGE); + } + finally + { + if(os != null) + { + try + { + os.close(); + } + catch(java.io.IOException io) + { + } + } + } + } + } + else + { + break; // while + } + } + } + }; + save.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK)); + save.putValue(Action.SHORT_DESCRIPTION, "Save As..."); + fileMenu.add(save); + fileMenu.addSeparator(); + + fileMenu.add(new AbstractAction("Close") + { + public void actionPerformed(ActionEvent e) + { + close(true); + } + }); + JMenu editMenu = new JMenu("Edit"); + editMenu.setMnemonic(java.awt.event.KeyEvent.VK_E); + add(editMenu); + + Action copy = new AbstractAction("Copy") + { + public void actionPerformed(ActionEvent e) + { + _textArea.copy(); + } + + }; + copy.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK)); + copy.putValue(Action.SHORT_DESCRIPTION, "Copy"); + editMenu.add(copy); + + editMenu.addSeparator(); + Action selectAll = new AbstractAction("Select All") + { + public void actionPerformed(ActionEvent e) + { + _textArea.grabFocus(); + _textArea.selectAll(); + } + }; + selectAll.putValue(Action.ACCELERATOR_KEY, + KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK)); + selectAll.putValue(Action.SHORT_DESCRIPTION, "Select All"); + + editMenu.add(selectAll); + editMenu.addSeparator(); + editMenu.add(new AbstractAction("Preferences...") + { + public void actionPerformed(ActionEvent e) + { + new ShowLogPrefsDialog(ShowLogDialog.this); + } + }); + } } 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); - - _pauseButton = new JToggleButton(_pause); - _pauseButton.setText(null); - _pauseButton.setIcon(Utils.getIcon("/icons/16x16/pause.png")); - add(_pauseButton); - _playButton = new JToggleButton(_play); - _playButton.setText(null); - _playButton.setIcon(Utils.getIcon("/icons/16x16/start.png")); - add(_playButton); - _stopButton = new JToggleButton(_stop); - _stopButton.setText(null); - _stopButton.setIcon(Utils.getIcon("/icons/16x16/stop.png")); - add(_stopButton); - - ButtonGroup bg = new ButtonGroup(); - bg.add(_pauseButton); - bg.add(_playButton); - bg.add(_stopButton); - } + private ToolBar() + { + putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH); + putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR); + setFloatable(false); + putClientProperty("JToolBar.isRollover", Boolean.TRUE); + + _pauseButton = new JToggleButton(_pause); + _pauseButton.setText(null); + _pauseButton.setIcon(Utils.getIcon("/icons/16x16/pause.png")); + add(_pauseButton); + _playButton = new JToggleButton(_play); + _playButton.setText(null); + _playButton.setIcon(Utils.getIcon("/icons/16x16/start.png")); + add(_playButton); + _stopButton = new JToggleButton(_stop); + _stopButton.setText(null); + _stopButton.setIcon(Utils.getIcon("/icons/16x16/stop.png")); + add(_stopButton); + + ButtonGroup bg = new ButtonGroup(); + bg.add(_pauseButton); + bg.add(_playButton); + bg.add(_stopButton); + } } ShowLogDialog(Root root, FileIteratorFactory factory, - int maxLines, int maxSize, int initialLines, int maxReadSize, int period) + int maxLines, int maxSize, int initialLines, int maxReadSize, int period) { - super(root.getCoordinator().getMainFrame(), factory.getTitle() + " - IceGrid Admin", false); - - _maxLines = maxLines; - _maxSize = maxSize; - _initialLines = initialLines; - _maxReadSize = maxReadSize; - _period = period; - _factory = factory; - _root = root; - - setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - addWindowListener(new java.awt.event.WindowAdapter() - { - public void windowClosing(java.awt.event.WindowEvent e) - { - close(true); - } - }); - - _pause = new AbstractAction("Pause") - { - public void actionPerformed(ActionEvent e) - { - pause(); - } - }; - - _play = new AbstractAction("Play") - { - public void actionPerformed(ActionEvent e) - { - play(); - } - }; - - _stop = new AbstractAction("Stop") - { - public void actionPerformed(ActionEvent e) - { - stopReading(); - } - }; - - setJMenuBar(new MenuBar()); - getContentPane().add(new ToolBar(), - BorderLayout.PAGE_START); - - JScrollPane scrollPane = new JScrollPane(_textArea, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - - getContentPane().add(scrollPane); - - pack(); - setResizable(true); - - setLocationRelativeTo(root.getCoordinator().getMainFrame()); - play(); + super(root.getCoordinator().getMainFrame(), factory.getTitle() + " - IceGrid Admin", false); + + _maxLines = maxLines; + _maxSize = maxSize; + _initialLines = initialLines; + _maxReadSize = maxReadSize; + _period = period; + _factory = factory; + _root = root; + + setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + addWindowListener(new java.awt.event.WindowAdapter() + { + public void windowClosing(java.awt.event.WindowEvent e) + { + close(true); + } + }); + + _pause = new AbstractAction("Pause") + { + public void actionPerformed(ActionEvent e) + { + pause(); + } + }; + + _play = new AbstractAction("Play") + { + public void actionPerformed(ActionEvent e) + { + play(); + } + }; + + _stop = new AbstractAction("Stop") + { + public void actionPerformed(ActionEvent e) + { + stopReading(); + } + }; + + setJMenuBar(new MenuBar()); + getContentPane().add(new ToolBar(), + BorderLayout.PAGE_START); + + JScrollPane scrollPane = new JScrollPane(_textArea, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + + getContentPane().add(scrollPane); + + pack(); + setResizable(true); + + setLocationRelativeTo(root.getCoordinator().getMainFrame()); + play(); } void pause() { - _thread.pause(); - _pauseItem.setSelected(true); - _pauseButton.setSelected(true); + _thread.pause(); + _pauseItem.setSelected(true); + _pauseButton.setSelected(true); } void stopReading() { - if(_thread != null) - { - _thread.terminate(); - - try - { - _thread.join(); - } - catch(InterruptedException e) - { - } - - _thread = null; - _stopItem.setSelected(true); - _stopButton.setSelected(true); - _pause.setEnabled(false); - } + if(_thread != null) + { + _thread.terminate(); + + try + { + _thread.join(); + } + catch(InterruptedException e) + { + } + + _thread = null; + _stopItem.setSelected(true); + _stopButton.setSelected(true); + _pause.setEnabled(false); + } } void play() { - if(_thread != null) - { - _thread.play(); - _playItem.setSelected(true); - _playButton.setSelected(true); - _pause.setEnabled(true); - } - else - { - _thread = new ReaderThread(); - _thread.start(); - } + if(_thread != null) + { + _thread.play(); + _playItem.setSelected(true); + _playButton.setSelected(true); + _pause.setEnabled(true); + } + else + { + _thread = new ReaderThread(); + _thread.start(); + } } int getMaxLines() { - return _maxLines; + return _maxLines; } int getMaxSize() { - return _maxSize; + return _maxSize; } int getInitialLines() { - return _initialLines; + return _initialLines; } int getMaxReadSize() { - return _maxReadSize; + return _maxReadSize; } int getPeriod() { - return _period; + return _period; } void setPrefs(int maxLines, int maxSize, int initialLines, int maxReadSize, int period) { - if(maxLines < 50) - { - maxLines = 50; - } - _maxLines = maxLines; - - if(maxSize < 1000) - { - maxSize = 1000; - } - _maxSize = maxSize; - - _initialLines = initialLines; - - if(maxReadSize < 100) - { - maxReadSize = 100; - } - else if(maxReadSize + 512 > _root.getMessageSizeMax()) - { - maxReadSize = _root.getMessageSizeMax() - 512; - } - _maxReadSize = maxReadSize; - - if(period < 200) - { - period = 200; - } - else if(period > 5000) - { - period = 5000; - } - _period = period; - - if(_thread != null) - { - _thread.setPrefs(); - } - - _root.setLogPrefs(_maxLines, _maxSize, _initialLines, _maxReadSize, _period); + if(maxLines < 50) + { + maxLines = 50; + } + _maxLines = maxLines; + + if(maxSize < 1000) + { + maxSize = 1000; + } + _maxSize = maxSize; + + _initialLines = initialLines; + + if(maxReadSize < 100) + { + maxReadSize = 100; + } + else if(maxReadSize + 512 > _root.getMessageSizeMax()) + { + maxReadSize = _root.getMessageSizeMax() - 512; + } + _maxReadSize = maxReadSize; + + if(period < 200) + { + period = 200; + } + else if(period > 5000) + { + period = 5000; + } + _period = period; + + if(_thread != null) + { + _thread.setPrefs(); + } + + _root.setLogPrefs(_maxLines, _maxSize, _initialLines, _maxReadSize, _period); } void close(boolean notifyRoot) { - stopReading(); + stopReading(); - if(notifyRoot) - { - _root.removeShowLogDialog(_factory.getTitle()); - } - dispose(); + if(notifyRoot) + { + _root.removeShowLogDialog(_factory.getTitle()); + } + dispose(); } private final Root _root; diff --git a/java/src/IceGridGUI/LiveDeployment/ShowLogPrefsDialog.java b/java/src/IceGridGUI/LiveDeployment/ShowLogPrefsDialog.java index 25277c1baf6..11154d46c90 100644 --- a/java/src/IceGridGUI/LiveDeployment/ShowLogPrefsDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ShowLogPrefsDialog.java @@ -32,131 +32,131 @@ class ShowLogPrefsDialog extends JDialog { ShowLogPrefsDialog(final ShowLogDialog sld) { - super(sld, "Preferences - IceGrid Admin", true); - setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - - final JTextField maxLinesField = new JTextField(10); - maxLinesField.setText(Integer.toString(sld.getMaxLines())); - maxLinesField.setToolTipText("Maximum number of lines in this dialog's buffer"); - - final JTextField maxSizeField = new JTextField(10); - maxSizeField.setText(Integer.toString(sld.getMaxSize())); - maxSizeField.setToolTipText("Maximum number of characters in this dialog's buffer"); + super(sld, "Preferences - IceGrid Admin", true); + setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + + final JTextField maxLinesField = new JTextField(10); + maxLinesField.setText(Integer.toString(sld.getMaxLines())); + maxLinesField.setToolTipText("Maximum number of lines in this dialog's buffer"); + + final JTextField maxSizeField = new JTextField(10); + maxSizeField.setText(Integer.toString(sld.getMaxSize())); + maxSizeField.setToolTipText("Maximum number of characters in this dialog's buffer"); - final JTextField initialLinesField = new JTextField(10); - initialLinesField.setText(Integer.toString(sld.getInitialLines())); - initialLinesField.setToolTipText("Start by retrieving <num> lines from the server; -1 means retrieve all"); + final JTextField initialLinesField = new JTextField(10); + initialLinesField.setText(Integer.toString(sld.getInitialLines())); + initialLinesField.setToolTipText("Start by retrieving <num> lines from the server; -1 means retrieve all"); - final JTextField maxReadSizeField = new JTextField(10); - maxReadSizeField.setText(Integer.toString(sld.getMaxReadSize())); - maxReadSizeField.setToolTipText("Maximum number of bytes read by each request"); + final JTextField maxReadSizeField = new JTextField(10); + maxReadSizeField.setText(Integer.toString(sld.getMaxReadSize())); + maxReadSizeField.setToolTipText("Maximum number of bytes read by each request"); - final JTextField periodField = new JTextField(10); - periodField.setText(Float.toString((float)sld.getPeriod() / 1000)); - periodField.setToolTipText("After reaching EOF, check every <num> seconds for new output"); + final JTextField periodField = new JTextField(10); + periodField.setText(Float.toString((float)sld.getPeriod() / 1000)); + periodField.setToolTipText("After reaching EOF, check every <num> seconds for new output"); - JButton okButton = new JButton("OK"); - ActionListener okListener = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - try - { - int maxLines = parseInt(maxLinesField, "Max lines in buffer"); - int maxSize = parseInt(maxSizeField, "Max characters in buffer"); - int initialLines = parseInt(initialLinesField, "Initial tail (lines)"); - int maxReadSize = parseInt(maxReadSizeField, "Max bytes read per request"); - int period = (int)(parseFloat(periodField, "Poll period (seconds)") * 1000); - - sld.setPrefs(maxLines, maxSize, initialLines, maxReadSize, period); - dispose(); - } - catch(NumberFormatException ex) - { - return; - } - } - }; - okButton.addActionListener(okListener); - getRootPane().setDefaultButton(okButton); - - JButton cancelButton = new JButton("Cancel"); - ActionListener cancelListener = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dispose(); - } - }; - cancelButton.addActionListener(cancelListener); - - - FormLayout layout = new FormLayout("left:pref, 3dlu, fill:pref:grow", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.setRowGroupingEnabled(true); - builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); - - builder.append("Max lines in buffer", maxLinesField); - builder.nextLine(); - builder.append("Max characters in buffer", maxSizeField); - builder.nextLine(); - builder.append("Initial tail (lines)", initialLinesField); - builder.nextLine(); - builder.append("Max bytes read per request", maxReadSizeField); - builder.nextLine(); - builder.append("Poll period (seconds)", periodField); - builder.nextLine(); - - JComponent buttonBar = - ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); - buttonBar.setBorder(Borders.DIALOG_BORDER); - - java.awt.Container contentPane = getContentPane(); - contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); - contentPane.add(builder.getPanel()); - contentPane.add(buttonBar); - - pack(); - setResizable(false); - setLocationRelativeTo(sld); - setVisible(true); + JButton okButton = new JButton("OK"); + ActionListener okListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + try + { + int maxLines = parseInt(maxLinesField, "Max lines in buffer"); + int maxSize = parseInt(maxSizeField, "Max characters in buffer"); + int initialLines = parseInt(initialLinesField, "Initial tail (lines)"); + int maxReadSize = parseInt(maxReadSizeField, "Max bytes read per request"); + int period = (int)(parseFloat(periodField, "Poll period (seconds)") * 1000); + + sld.setPrefs(maxLines, maxSize, initialLines, maxReadSize, period); + dispose(); + } + catch(NumberFormatException ex) + { + return; + } + } + }; + okButton.addActionListener(okListener); + getRootPane().setDefaultButton(okButton); + + JButton cancelButton = new JButton("Cancel"); + ActionListener cancelListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + dispose(); + } + }; + cancelButton.addActionListener(cancelListener); + + + FormLayout layout = new FormLayout("left:pref, 3dlu, fill:pref:grow", ""); + DefaultFormBuilder builder = new DefaultFormBuilder(layout); + builder.setDefaultDialogBorder(); + builder.setRowGroupingEnabled(true); + builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); + + builder.append("Max lines in buffer", maxLinesField); + builder.nextLine(); + builder.append("Max characters in buffer", maxSizeField); + builder.nextLine(); + builder.append("Initial tail (lines)", initialLinesField); + builder.nextLine(); + builder.append("Max bytes read per request", maxReadSizeField); + builder.nextLine(); + builder.append("Poll period (seconds)", periodField); + builder.nextLine(); + + JComponent buttonBar = + ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); + buttonBar.setBorder(Borders.DIALOG_BORDER); + + java.awt.Container contentPane = getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(builder.getPanel()); + contentPane.add(buttonBar); + + pack(); + setResizable(false); + setLocationRelativeTo(sld); + setVisible(true); } private int parseInt(JTextField field, String label) throws NumberFormatException { - try - { - return Integer.parseInt(field.getText()); - } - catch(NumberFormatException e) - { - JOptionPane.showMessageDialog( - this, - label + " must be an integer", - "Invalid entry", - JOptionPane.ERROR_MESSAGE); - - throw e; - } + try + { + return Integer.parseInt(field.getText()); + } + catch(NumberFormatException e) + { + JOptionPane.showMessageDialog( + this, + label + " must be an integer", + "Invalid entry", + JOptionPane.ERROR_MESSAGE); + + throw e; + } } private float parseFloat(JTextField field, String label) throws NumberFormatException { - try - { - return Float.parseFloat(field.getText()); - } - catch(NumberFormatException e) - { - JOptionPane.showMessageDialog( - this, - label + " must be a decimal number", - "Invalid entry", - JOptionPane.ERROR_MESSAGE); - - throw e; - } + try + { + return Float.parseFloat(field.getText()); + } + catch(NumberFormatException e) + { + JOptionPane.showMessageDialog( + this, + label + " must be a decimal number", + "Invalid entry", + JOptionPane.ERROR_MESSAGE); + + throw e; + } } } diff --git a/java/src/IceGridGUI/LiveDeployment/Slave.java b/java/src/IceGridGUI/LiveDeployment/Slave.java index 83f6da5157f..63c450d5928 100644 --- a/java/src/IceGridGUI/LiveDeployment/Slave.java +++ b/java/src/IceGridGUI/LiveDeployment/Slave.java @@ -30,143 +30,143 @@ class Slave extends TreeNode public boolean[] getAvailableActions() { boolean[] actions = new boolean[ACTION_COUNT]; - actions[SHUTDOWN_REGISTRY] = true; - actions[RETRIEVE_STDOUT] = true; - actions[RETRIEVE_STDERR] = true; - return actions; + actions[SHUTDOWN_REGISTRY] = true; + actions[RETRIEVE_STDOUT] = true; + actions[RETRIEVE_STDERR] = true; + return actions; } public void shutdownRegistry() { - final String prefix = "Shutting down registry '" + _id + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - AMI_Admin_shutdownRegistry cb = new AMI_Admin_shutdownRegistry() - { - // - // 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().shutdownRegistry_async(cb, _id); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to shutdown " + _id, e.toString()); - } - finally - { - getCoordinator().getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + final String prefix = "Shutting down registry '" + _id + "'..."; + getCoordinator().getStatusBar().setText(prefix); + + AMI_Admin_shutdownRegistry cb = new AMI_Admin_shutdownRegistry() + { + // + // 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().shutdownRegistry_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 void retrieveOutput(final boolean stdout) { - getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() - { - public FileIteratorPrx open(int count) - throws FileNotAvailableException, RegistryNotExistException, RegistryUnreachableException - { - AdminSessionPrx session = getCoordinator().getSession(); - - if(stdout) - { - return session.openRegistryStdOut(_id, count); - } - else - { - return session.openRegistryStdErr(_id, count); - } - } - - public String getTitle() - { - return "Registry " + _title + " " + (stdout ? "stdout" : "stderr"); - } - - public String getDefaultFilename() - { - return _id + (stdout ? ".out" : ".err"); - } - }); + getRoot().openShowLogDialog(new ShowLogDialog.FileIteratorFactory() + { + public FileIteratorPrx open(int count) + throws FileNotAvailableException, RegistryNotExistException, RegistryUnreachableException + { + AdminSessionPrx session = getCoordinator().getSession(); + + if(stdout) + { + return session.openRegistryStdOut(_id, count); + } + else + { + return session.openRegistryStdErr(_id, count); + } + } + + public String getTitle() + { + return "Registry " + _title + " " + (stdout ? "stdout" : "stderr"); + } + + public String getDefaultFilename() + { + return _id + (stdout ? ".out" : ".err"); + } + }); } public JPopupMenu getPopupMenu() { - LiveActions la = getCoordinator().getLiveActionsForPopup(); + LiveActions la = getCoordinator().getLiveActionsForPopup(); if(_popup == null) - { - _popup = new JPopupMenu(); - _popup.add(la.get(RETRIEVE_STDOUT)); - _popup.add(la.get(RETRIEVE_STDERR)); - _popup.addSeparator(); - _popup.add(la.get(SHUTDOWN_REGISTRY)); - } - - la.setTarget(this); - return _popup; + { + _popup = new JPopupMenu(); + _popup.add(la.get(RETRIEVE_STDOUT)); + _popup.add(la.get(RETRIEVE_STDERR)); + _popup.addSeparator(); + _popup.add(la.get(SHUTDOWN_REGISTRY)); + } + + la.setTarget(this); + return _popup; } public Editor getEditor() { - if(_editor == null) - { - _editor = new SlaveEditor(); - } - _editor.show(_info); - return _editor; + if(_editor == null) + { + _editor = new SlaveEditor(); + } + _editor.show(_info); + return _editor; } public Component getTreeCellRendererComponent( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) + JTree tree, + Object value, + boolean sel, + boolean expanded, + boolean leaf, + int row, + boolean hasFocus) { - if(_cellRenderer == null) - { - // - // TODO: separate icon for master - // - - _cellRenderer = new DefaultTreeCellRenderer(); - _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/registry.png")); - } - - return _cellRenderer.getTreeCellRendererComponent( - tree, value, sel, expanded, leaf, row, hasFocus); + if(_cellRenderer == null) + { + // + // TODO: separate icon for master + // + + _cellRenderer = new DefaultTreeCellRenderer(); + _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/registry.png")); + } + + return _cellRenderer.getTreeCellRendererComponent( + tree, value, sel, expanded, leaf, row, hasFocus); } Slave(TreeNode parent, RegistryInfo info, String instanceName) { - super(parent, info.name); - _info = info; + super(parent, info.name); + _info = info; _title = instanceName + " (" + info.name + ")"; } diff --git a/java/src/IceGridGUI/LiveDeployment/SlaveEditor.java b/java/src/IceGridGUI/LiveDeployment/SlaveEditor.java index 4ce8d7ee4f0..a6c2348330a 100644 --- a/java/src/IceGridGUI/LiveDeployment/SlaveEditor.java +++ b/java/src/IceGridGUI/LiveDeployment/SlaveEditor.java @@ -19,25 +19,25 @@ class SlaveEditor extends Editor { SlaveEditor() { - _hostname.setEditable(false); + _hostname.setEditable(false); } void show(RegistryInfo info) { - _hostname.setText(info.hostname); + _hostname.setText(info.hostname); } protected void appendProperties(DefaultFormBuilder builder) { - builder.append("Hostname" ); - builder.append(_hostname, 3); - builder.nextLine(); + builder.append("Hostname" ); + builder.append(_hostname, 3); + builder.nextLine(); } protected void buildPropertiesPanel() { - super.buildPropertiesPanel(); - _propertiesPanel.setName("Slave Registry Properties"); + super.buildPropertiesPanel(); + _propertiesPanel.setName("Slave Registry Properties"); } private JTextField _hostname = new JTextField(20); diff --git a/java/src/IceGridGUI/LiveDeployment/TableField.java b/java/src/IceGridGUI/LiveDeployment/TableField.java index 767b0fc3486..610872ed7cb 100755 --- a/java/src/IceGridGUI/LiveDeployment/TableField.java +++ b/java/src/IceGridGUI/LiveDeployment/TableField.java @@ -32,161 +32,161 @@ import javax.swing.table.DefaultTableModel; public class TableField extends JTable { public TableField(String headKey, String headValue) - { - _columnNames = new java.util.Vector(2); - _columnNames.add(headKey); - _columnNames.add(headValue); - init(); + { + _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(); + { + _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()); + _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); + 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); + 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); + 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); + 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); + 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); + 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; diff --git a/java/src/IceGridGUI/LiveDeployment/TreeNode.java b/java/src/IceGridGUI/LiveDeployment/TreeNode.java index 9583c9232d3..b182730f70d 100755 --- a/java/src/IceGridGUI/LiveDeployment/TreeNode.java +++ b/java/src/IceGridGUI/LiveDeployment/TreeNode.java @@ -20,13 +20,13 @@ public abstract class TreeNode extends TreeNodeBase TreeNode(TreeNode parent, String id) { - super(parent, id); + super(parent, id); } Root getRoot() { - assert _parent != null; - return ((TreeNode)_parent).getRoot(); + assert _parent != null; + return ((TreeNode)_parent).getRoot(); } // @@ -62,57 +62,57 @@ public abstract class TreeNode extends TreeNodeBase public boolean[] getAvailableActions() { - return new boolean[ACTION_COUNT]; + return new boolean[ACTION_COUNT]; } public void start() { - assert false; + assert false; } public void stop() { - assert false; + assert false; } public void enable() { - assert false; + assert false; } public void disable() { - assert false; + assert false; } public void writeMessage() { - assert false; + assert false; } public void retrieveOutput(boolean stdout) { - assert false; + assert false; } public void retrieveLog() { - assert false; + assert false; } public void signal(String s) { - assert false; + assert false; } public void shutdownNode() { - assert false; + assert false; } public void shutdownRegistry() { - assert false; + assert false; } public void patchServer() { - assert false; + assert false; } public void addObject() { - assert false; + assert false; } // @@ -120,99 +120,99 @@ public abstract class TreeNode extends TreeNodeBase // protected void amiSuccess(final String prefix) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getCoordinator().getStatusBar().setText(prefix + "done."); - } - }); + 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()); - } + 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) + final String title, final String message) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - failure(prefix, title, 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!"); + getCoordinator().getStatusBar().setText(prefix + "failed!"); - JOptionPane.showMessageDialog( - getCoordinator().getMainFrame(), - message, - title, - JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog( + getCoordinator().getMainFrame(), + message, + title, + JOptionPane.ERROR_MESSAGE); } } diff --git a/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java index 104c5136945..7c6f1cba72c 100644 --- a/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java @@ -45,151 +45,151 @@ class WriteMessageDialog extends JDialog { WriteMessageDialog(final Root root) { - super(root.getCoordinator().getMainFrame(), - "Write Message - IceGrid Admin", true); - setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); - - _mainFrame = root.getCoordinator().getMainFrame(); - - _stdOut = new JRadioButton("Write to stdout"); - _stdOut.setSelected(true); - JRadioButton stdErr = new JRadioButton("Write to stderr"); - ButtonGroup bg = new ButtonGroup(); - bg.add(_stdOut); - bg.add(stdErr); - - JButton okButton = new JButton("OK"); - ActionListener okListener = new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - final Coordinator c = root.getCoordinator(); - final String target = _target; - final String prefix = "Writing message to server '" + target + "'..."; - - - AMI_Admin_writeMessage cb = new AMI_Admin_writeMessage() - { - public void ice_response() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - c.getStatusBar().setText(prefix + "done."); - } - }); - } - - public void ice_exception(final Ice.UserException e) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleFailure("IceGrid exception: " + e.toString()); - } - - }); - } - - public void ice_exception(final Ice.LocalException e) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleFailure("Communication exception: " + e.toString()); - } - }); - } - - private void handleFailure(String message) - { - c.getStatusBar().setText(prefix + "failed!"); - - JOptionPane.showMessageDialog( - _mainFrame, - message, - "Writing message to server '" + target + "' failed", - JOptionPane.ERROR_MESSAGE); - } - }; - - try - { - c.getStatusBar().setText(prefix); - _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - c.getAdmin().writeMessage_async( - cb, _target, _message.getText(), _stdOut.isSelected() ? 1 : 2); - } - catch(Ice.LocalException ex) - { - c.getStatusBar().setText(prefix + "failed."); - JOptionPane.showMessageDialog( - _mainFrame, - "Communication exception: " + ex.toString(), - "Writing message to server '" + target + "' failed", - JOptionPane.ERROR_MESSAGE); - - return; - } - finally - { - _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - 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("left:pref, 3dlu, fill:pref:grow", ""); - DefaultFormBuilder builder = new DefaultFormBuilder(layout); - builder.setDefaultDialogBorder(); - builder.setRowGroupingEnabled(true); - builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); - - _message.setLineWrap(true); - JScrollPane scrollPane = new JScrollPane(_message, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - builder.append(scrollPane, 3); - builder.nextLine(); - builder.append(_stdOut); - builder.append(stdErr); - 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); + super(root.getCoordinator().getMainFrame(), + "Write Message - IceGrid Admin", true); + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + + _mainFrame = root.getCoordinator().getMainFrame(); + + _stdOut = new JRadioButton("Write to stdout"); + _stdOut.setSelected(true); + JRadioButton stdErr = new JRadioButton("Write to stderr"); + ButtonGroup bg = new ButtonGroup(); + bg.add(_stdOut); + bg.add(stdErr); + + JButton okButton = new JButton("OK"); + ActionListener okListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + final Coordinator c = root.getCoordinator(); + final String target = _target; + final String prefix = "Writing message to server '" + target + "'..."; + + + AMI_Admin_writeMessage cb = new AMI_Admin_writeMessage() + { + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + c.getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure("IceGrid exception: " + e.toString()); + } + + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure("Communication exception: " + e.toString()); + } + }); + } + + private void handleFailure(String message) + { + c.getStatusBar().setText(prefix + "failed!"); + + JOptionPane.showMessageDialog( + _mainFrame, + message, + "Writing message to server '" + target + "' failed", + JOptionPane.ERROR_MESSAGE); + } + }; + + try + { + c.getStatusBar().setText(prefix); + _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + c.getAdmin().writeMessage_async( + cb, _target, _message.getText(), _stdOut.isSelected() ? 1 : 2); + } + catch(Ice.LocalException ex) + { + c.getStatusBar().setText(prefix + "failed."); + JOptionPane.showMessageDialog( + _mainFrame, + "Communication exception: " + ex.toString(), + "Writing message to server '" + target + "' failed", + JOptionPane.ERROR_MESSAGE); + + return; + } + finally + { + _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + 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("left:pref, 3dlu, fill:pref:grow", ""); + DefaultFormBuilder builder = new DefaultFormBuilder(layout); + builder.setDefaultDialogBorder(); + builder.setRowGroupingEnabled(true); + builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); + + _message.setLineWrap(true); + JScrollPane scrollPane = new JScrollPane(_message, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + builder.append(scrollPane, 3); + builder.nextLine(); + builder.append(_stdOut); + builder.append(stdErr); + 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(String serverId) { - _target = serverId; - _message.setText(""); - setLocationRelativeTo(_mainFrame); - setVisible(true); + _target = serverId; + _message.setText(""); + setLocationRelativeTo(_mainFrame); + setVisible(true); } private JRadioButton _stdOut; |