diff options
author | Jose <jose@zeroc.com> | 2012-11-01 00:16:56 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-11-01 00:16:56 +0100 |
commit | 92067a985f1c7cf25d7b5ce3db8ddf80e89682c9 (patch) | |
tree | 12bab0a8a8dbfbacd6348a619995b42becd41007 /java/src/IceGridGUI/LiveDeployment/MetricsView.java | |
parent | Fixed IceStorm metrics issues (diff) | |
download | ice-92067a985f1c7cf25d7b5ce3db8ddf80e89682c9.tar.bz2 ice-92067a985f1c7cf25d7b5ce3db8ddf80e89682c9.tar.xz ice-92067a985f1c7cf25d7b5ce3db8ddf80e89682c9.zip |
IceGridGUI metrics fixes:
* Update the GUI to also display disabled metrics
* Add enable/disable popup menu to metris views, correspoding to new
methods enableMetricsView/disableMetricsView in Metrics.ice
* Fixed ICE-4919 ConnectionRefusedException error dialog keeps popping up
* Fixed ICE-4917 bogus IceGrid GUI error message
Diffstat (limited to 'java/src/IceGridGUI/LiveDeployment/MetricsView.java')
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/MetricsView.java | 199 |
1 files changed, 191 insertions, 8 deletions
diff --git a/java/src/IceGridGUI/LiveDeployment/MetricsView.java b/java/src/IceGridGUI/LiveDeployment/MetricsView.java index 5aba867be20..6c7bd9afbe6 100644 --- a/java/src/IceGridGUI/LiveDeployment/MetricsView.java +++ b/java/src/IceGridGUI/LiveDeployment/MetricsView.java @@ -18,6 +18,7 @@ import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import javax.swing.SwingUtilities; import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; import java.util.Map; import java.util.Enumeration; @@ -32,6 +33,17 @@ class MetricsView extends TreeNode return _editor; } + // + // Actions + // + public boolean[] getAvailableActions() + { + boolean[] actions = new boolean[IceGridGUI.LiveDeployment.TreeNode.ACTION_COUNT]; + actions[ENABLE_METRICS_VIEW] = !_enabled; + actions[DISABLE_METRICS_VIEW] = _enabled; + return actions; + } + public Component getTreeCellRendererComponent( JTree tree, Object value, @@ -44,18 +56,171 @@ class MetricsView extends TreeNode if(_cellRenderer == null) { _cellRenderer = new DefaultTreeCellRenderer(); - _cellRenderer.setLeafIcon(Utils.getIcon("/icons/16x16/metrics.png")); + + _enabledIcon = Utils.getIcon("/icons/16x16/metrics.png"); + _disabledIcon = Utils.getIcon("/icons/16x16/metrics_disabled.png"); } - _cellRenderer.setToolTipText(_toolTip); + + Icon icon = _enabled ? _enabledIcon : _disabledIcon; + _cellRenderer.setLeafIcon(icon); return _cellRenderer.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); } - MetricsView(TreeNode parent, String name, IceMX.MetricsAdminPrx admin) + MetricsView(TreeNode parent, String name, IceMX.MetricsAdminPrx admin, boolean enabled) { super(parent, name); _name = name; _admin = admin; _editor = new MetricsViewEditor(getRoot()); + _enabled = enabled; + } + + public void enableMetricsView(boolean enabled) + { + IceMX.MetricsAdminPrx metricsAdmin = getMetricsAdmin(); + if(metricsAdmin != null) + { + if(enabled) + { + IceMX.Callback_MetricsAdmin_enableMetricsView cb = new IceMX.Callback_MetricsAdmin_enableMetricsView() + { + public void response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _enabled = true; + getRoot().getTreeModel().nodeChanged(MetricsView.this); + if(getRoot().getTree().getLastSelectedPathComponent() == MetricsView.this) + { + // + // If the metrics view is selected when enabled success, + // we must start the refresh thread to pull updates. + // + MetricsViewEditor.startRefreshThread(MetricsView.this); + } + } + }); + } + + public void exception(final Ice.LocalException e) + { + MetricsViewEditor.stopRefreshThread(); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(e instanceof Ice.ObjectNotExistException || + e instanceof Ice.ConnectionRefusedException) + { + // Server is down. + } + else if(e instanceof Ice.CommunicatorDestroyedException) + { + } + else + { + e.printStackTrace(); + JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), + "Error: " + e.toString(), "Error", + JOptionPane.ERROR_MESSAGE); + } + } + }); + } + + public void exception(final Ice.UserException e) + { + MetricsViewEditor.stopRefreshThread(); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + e.printStackTrace(); + JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), + "Error: " + e.toString(), "Error", + JOptionPane.ERROR_MESSAGE); + } + }); + } + }; + metricsAdmin.begin_enableMetricsView(_name, cb); + } + else + { + IceMX.Callback_MetricsAdmin_disableMetricsView cb = new IceMX.Callback_MetricsAdmin_disableMetricsView() + { + public void response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _enabled = false; + _editor.show(MetricsView.this, null, 0); + getRoot().getTreeModel().nodeChanged(MetricsView.this); + if(getRoot().getTree().getLastSelectedPathComponent() == MetricsView.this) + { + // + // If the metrics view is selected when disabled success, + // we stop the refresh. + // + MetricsViewEditor.stopRefreshThread(); + } + } + }); + } + + public void exception(final Ice.LocalException e) + { + MetricsViewEditor.stopRefreshThread(); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + if(e instanceof Ice.ObjectNotExistException || + e instanceof Ice.ConnectionRefusedException) + { + // Server is down. + } + else if(e instanceof Ice.CommunicatorDestroyedException) + { + } + else + { + e.printStackTrace(); + JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), + "Error: " + e.toString(), "Error", + JOptionPane.ERROR_MESSAGE); + } + } + }); + } + + public void exception(final Ice.UserException e) + { + MetricsViewEditor.stopRefreshThread(); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + e.printStackTrace(); + JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), + "Error: " + e.toString(), "Error", + JOptionPane.ERROR_MESSAGE); + } + }); + } + }; + metricsAdmin.begin_disableMetricsView(_name, cb); + } + } + } + + public boolean isEnabled() + { + return _enabled; } public String name() @@ -68,6 +233,21 @@ class MetricsView extends TreeNode return _admin; } + public JPopupMenu getPopupMenu() + { + LiveActions la = getCoordinator().getLiveActionsForPopup(); + + if(_popup == null) + { + _popup = new JPopupMenu(); + _popup.add(la.get(ENABLE_METRICS_VIEW)); + _popup.add(la.get(DISABLE_METRICS_VIEW)); + } + + la.setTarget(this); + return _popup; + } + public void fetchMetricsFailures(String map, String id, IceMX.Callback_MetricsAdmin_getMetricsFailures cb) { IceMX.MetricsAdminPrx metricsAdmin = getMetricsAdmin(); @@ -106,12 +286,13 @@ class MetricsView extends TreeNode public void exception(final Ice.LocalException e) { + MetricsViewEditor.stopRefreshThread(); SwingUtilities.invokeLater(new Runnable() { public void run() { - _editor.stopRefreshThread(); - if(e instanceof Ice.ObjectNotExistException) + if(e instanceof Ice.ObjectNotExistException || + e instanceof Ice.ConnectionRefusedException) { // Server is down. } @@ -124,7 +305,6 @@ class MetricsView extends TreeNode } else { - _editor.stopRefreshThread(); e.printStackTrace(); JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), "Error: " + e.toString(), "Error", @@ -136,11 +316,11 @@ class MetricsView extends TreeNode public void exception(final Ice.UserException e) { + MetricsViewEditor.stopRefreshThread(); SwingUtilities.invokeLater(new Runnable() { public void run() { - _editor.stopRefreshThread(); e.printStackTrace(); JOptionPane.showMessageDialog(getCoordinator().getMainFrame(), "Error: " + e.toString(), "Error", @@ -168,7 +348,10 @@ class MetricsView extends TreeNode private String _name; private IceMX.MetricsAdminPrx _admin; - private String _toolTip; private MetricsViewEditor _editor; + private boolean _enabled; + static private JPopupMenu _popup; static private DefaultTreeCellRenderer _cellRenderer; + static private Icon _enabledIcon; + static private Icon _disabledIcon; } |