summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2009-12-11 18:14:22 +0100
committerBenoit Foucher <benoit@zeroc.com>2009-12-11 18:14:22 +0100
commitd123cca9cdeb145735047dfbc7c09e2e4d7de704 (patch)
tree45afeed01ac22a04bb71c50d60e98c91eca8c69e /java/src
parenthttp://bugzilla/bugzilla/show_bug.cgi?id=4461 - SL 32 & 64 bit optional builds. (diff)
downloadice-d123cca9cdeb145735047dfbc7c09e2e4d7de704.tar.bz2
ice-d123cca9cdeb145735047dfbc7c09e2e4d7de704.tar.xz
ice-d123cca9cdeb145735047dfbc7c09e2e4d7de704.zip
Fixed bug 3470 - IceGridGUI application filtering
Diffstat (limited to 'java/src')
-rw-r--r--java/src/IceGridGUI/ApplicationPane.java1
-rw-r--r--java/src/IceGridGUI/Coordinator.java59
-rw-r--r--java/src/IceGridGUI/LiveDeployment/Node.java5
-rw-r--r--java/src/IceGridGUI/LiveDeployment/Root.java131
-rw-r--r--java/src/IceGridGUI/LiveDeployment/Server.java3
5 files changed, 194 insertions, 5 deletions
diff --git a/java/src/IceGridGUI/ApplicationPane.java b/java/src/IceGridGUI/ApplicationPane.java
index f2d987d7349..8af19edd927 100644
--- a/java/src/IceGridGUI/ApplicationPane.java
+++ b/java/src/IceGridGUI/ApplicationPane.java
@@ -49,6 +49,7 @@ public class ApplicationPane extends JSplitPane implements Tab
{
Coordinator c = _root.getCoordinator();
+ c.getShowLiveDeploymentFiltersAction().setEnabled(false);
c.getCloseApplicationAction().setEnabled(true);
c.getSaveAction().setEnabled(_root.needsSaving() && (_root.isLive() && c.connectedToMaster() ||
diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java
index c38c134b8e7..131d039bd63 100644
--- a/java/src/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/Coordinator.java
@@ -523,6 +523,13 @@ public class Coordinator
addSeparator();
+ button = new JButton(_showLiveDeploymentFilters);
+ button.setText(null);
+ button.setIcon(Utils.getIcon("/icons/24x24/view_filter.png"));
+ add(button);
+
+ addSeparator();
+
button = new JButton(_openApplicationFromRegistry);
button.setText(null);
button.setIcon(Utils.getIcon("/icons/24x24/open_from_registry.png"));
@@ -642,6 +649,11 @@ public class Coordinator
return _closeApplication;
}
+ public Action getShowLiveDeploymentFiltersAction()
+ {
+ return _showLiveDeploymentFilters;
+ }
+
public Action getSaveAction()
{
return _save;
@@ -1185,6 +1197,7 @@ public class Coordinator
_liveApplications.clear();
_logout.setEnabled(false);
+ _showLiveDeploymentFilters.setEnabled(false);
_openApplicationFromRegistry.setEnabled(false);
_patchApplication.setEnabled(false);
_showApplicationDetails.setEnabled(false);
@@ -1484,6 +1497,7 @@ public class Coordinator
}
_logout.setEnabled(true);
+ _showLiveDeploymentFilters.setEnabled(true);
_openApplicationFromRegistry.setEnabled(true);
_patchApplication.setEnabled(true);
_showApplicationDetails.setEnabled(true);
@@ -1491,7 +1505,6 @@ public class Coordinator
_appMenu.setEnabled(true);
_newApplicationWithDefaultTemplates.setEnabled(true);
_acquireExclusiveWriteAccess.setEnabled(true);
-
_mainPane.setSelectedComponent(_liveDeploymentPane);
return session;
@@ -1983,6 +1996,49 @@ public class Coordinator
"Release exclusive write access on the registry");
_releaseExclusiveWriteAccess.setEnabled(false);
+ _showLiveDeploymentFilters = new AbstractAction("Filter live deployment")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+
+ Object[] applicationNames = _liveDeploymentRoot.getApplicationNames();
+
+ if(applicationNames.length == 0)
+ {
+ JOptionPane.showMessageDialog(
+ _mainFrame,
+ "The registry does not contain any application",
+ "Empty registry",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+ else
+ {
+ java.util.List<Object> names = new java.util.ArrayList<Object>();
+ names.add("<All>");
+ names.addAll(java.util.Arrays.asList(applicationNames));
+ String appName = (String)JOptionPane.showInputDialog(
+ _mainFrame, "Which Application do you want to see in the live deployment?",
+ "Filter live deployment",
+ JOptionPane.QUESTION_MESSAGE, null,
+ names.toArray(), names.get(0));
+
+ if(appName != null)
+ {
+ if(appName.equals("<All>"))
+ {
+ _liveDeploymentRoot.setApplicationNameFilter(null);
+ }
+ else
+ {
+ _liveDeploymentRoot.setApplicationNameFilter(appName);
+ }
+ }
+ }
+ }
+ };
+ _showLiveDeploymentFilters.putValue(Action.SHORT_DESCRIPTION, "Filter live deployment");
+ _showLiveDeploymentFilters.setEnabled(false);
+
_openApplicationFromFile = new AbstractAction("Application from File")
{
public void actionPerformed(ActionEvent e)
@@ -2711,6 +2767,7 @@ public class Coordinator
private Action _acquireExclusiveWriteAccess;
private Action _releaseExclusiveWriteAccess;
+ private Action _showLiveDeploymentFilters;
private Action _openApplicationFromFile;
private Action _openApplicationFromRegistry;
private Action _closeApplication;
diff --git a/java/src/IceGridGUI/LiveDeployment/Node.java b/java/src/IceGridGUI/LiveDeployment/Node.java
index 5decca4c8f6..88939d3a878 100644
--- a/java/src/IceGridGUI/LiveDeployment/Node.java
+++ b/java/src/IceGridGUI/LiveDeployment/Node.java
@@ -253,6 +253,11 @@ class Node extends ListTreeNode
return getRoot().findNamedPropertySet(name, applicationName);
}
+ boolean hasServersFromApplication(String name)
+ {
+ return _map.containsKey(name);
+ }
+
void add(ApplicationDescriptor appDesc, NodeDescriptor nodeDesc)
{
ApplicationData data = new ApplicationData();
diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java
index 99f8da96e88..2bca765471d 100644
--- a/java/src/IceGridGUI/LiveDeployment/Root.java
+++ b/java/src/IceGridGUI/LiveDeployment/Root.java
@@ -32,6 +32,122 @@ import IceGridGUI.*;
//
public class Root extends ListArrayTreeNode
{
+
+ //
+ // A custom tree model to filter tree views.
+ //
+ class FilteredTreeModel extends DefaultTreeModel
+ {
+ public FilteredTreeModel(TreeNode root)
+ {
+ super(root, true);
+ }
+
+ public void resetFilters()
+ {
+ Object[] path = { root };
+ int[] childIndices = new int[root.getChildCount()];
+ Object[] children = new Object[root.getChildCount()];
+ for(int i = 0; i < root.getChildCount(); i++)
+ {
+ childIndices[i] = i;
+ children[i] = root.getChildAt(i);
+ }
+ fireTreeStructureChanged(this, path, childIndices, children);
+ }
+
+ public int
+ getChildCount(Object parent)
+ {
+ if(!filterEnabled())
+ {
+ return super.getChildCount(parent);
+ }
+ int p = super.getChildCount(parent);
+ int q = 0;
+ for (int j = 0; j < p; j++)
+ {
+ TreeNode node = (TreeNode)super.getChild(parent, j);
+ if(matchFilter(node))
+ {
+ q++;
+ }
+ }
+ return q;
+ }
+
+ public Object getChild(Object parent, int index)
+ {
+ if(!filterEnabled())
+ {
+ return super.getChild(parent, index);
+ }
+ Object child = null;
+ int p = 0;
+ int q = super.getChildCount(parent);
+ for (int j = 0; j < q ; ++j)
+ {
+ TreeNode node = (TreeNode)super.getChild(parent, j);
+ if(!matchFilter(node))
+ {
+ continue;
+ }
+
+ if(p == index)
+ {
+ child = node;
+ break;
+ }
+ p++;
+ if(p > index)
+ {
+ break;
+ }
+ }
+ return child;
+ }
+
+ private boolean _filtered;
+ }
+
+ private boolean matchFilter(TreeNode n)
+ {
+ if(_applicationNameFilter == null)
+ {
+ return true;
+ }
+
+ if(n instanceof Server)
+ {
+ Server server = (Server)n;
+ if(!_applicationNameFilter.equals(server.getApplication().name))
+ {
+ return false;
+ }
+ }
+ else if(n instanceof Node)
+ {
+ return ((Node)n).hasServersFromApplication(_applicationNameFilter);
+ }
+ return true;
+ }
+
+ private boolean filterEnabled()
+ {
+ return _applicationNameFilter != null;
+ }
+
+ public void setApplicationNameFilter(String name)
+ {
+ _applicationNameFilter = name;
+ _label = _instanceName + " (" + _replicaName + ")";
+ if(_applicationNameFilter != null)
+ {
+ _label += " - " + _applicationNameFilter;
+ }
+ _treeModel.resetFilters();
+ }
+
public Root(Coordinator coordinator)
{
super(null, "Root", 2);
@@ -40,8 +156,9 @@ public class Root extends ListArrayTreeNode
_childrenArray[1] = _nodes;
_messageSizeMax = computeMessageSizeMax(_coordinator.getProperties().getPropertyAsInt("Ice.MessageSizeMax"));
- _tree = new JTree(this, true);
- _treeModel = (DefaultTreeModel)_tree.getModel();
+ _treeModel = new FilteredTreeModel(this);
+ _tree = new JTree();
+ _tree.setModel(_treeModel);
_addObjectDialog = new ObjectDialog(this, false);
_showObjectDialog = new ObjectDialog(this, true);
@@ -210,6 +327,7 @@ public class Root extends ListArrayTreeNode
{
applicationAdded(p);
}
+ _treeModel.resetFilters();
}
//
@@ -220,6 +338,7 @@ public class Root extends ListArrayTreeNode
_adapters.clear();
_objects.clear();
_replicaName = null;
+ _applicationNameFilter = null;
_infoMap.clear();
_nodes.clear();
@@ -1064,7 +1183,7 @@ public class Root extends ListArrayTreeNode
// 'this' is the root of the tree
//
private final JTree _tree;
- private final DefaultTreeModel _treeModel;
+ private final FilteredTreeModel _treeModel;
private RegistryInfo _info;
@@ -1091,4 +1210,10 @@ public class Root extends ListArrayTreeNode
static private RegistryEditor _editor;
static private JPopupMenu _popup;
static private DefaultTreeCellRenderer _cellRenderer;
+
+
+ //
+ // Application name to filter, if empty all applications are displayed.
+ //
+ private String _applicationNameFilter = null;
}
diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java
index 516680c8725..b2be22b0401 100644
--- a/java/src/IceGridGUI/LiveDeployment/Server.java
+++ b/java/src/IceGridGUI/LiveDeployment/Server.java
@@ -555,7 +555,8 @@ class Server extends ListArrayTreeNode
// IceBox servers
//
_icons[0][1][0] = Utils.getIcon("/icons/16x16/icebox_server_unknown.png");
- _icons[ServerState.Inactive.ordinal() + 1][1][0] = Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
+ _icons[ServerState.Inactive.ordinal() + 1][1][0] =
+ Utils.getIcon("/icons/16x16/icebox_server_inactive.png");
_icons[ServerState.Activating.ordinal() + 1][1][0] =
Utils.getIcon("/icons/16x16/icebox_server_activating.png");
_icons[ServerState.ActivationTimedOut.ordinal() + 1][1][0] =