modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 156 ++++++---- modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 18 - 2 files changed, 113 insertions(+), 61 deletions(-)
New commits: commit 2ffae275d74d321668ad36009bdad223cea78cb5 Author: Ian Springer ian.springer@redhat.com Date: Wed Jul 6 13:20:56 2011 -0400
[BZ 718335] add Select All and Deselect All buttons to autodiscovery view (https://bugzilla.redhat.com/show_bug.cgi?id=718335); right-align inventory status filter in footer, along with Select All, Deselect All, and Refresh buttons
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java index da3768c..e504f2a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. + * Copyright (C) 2005-2011 Red Hat, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -51,6 +51,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.resource.InventoryStatus; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.RefreshableView; import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; @@ -64,7 +65,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; /** * @author Greg Hinkle */ -public class ResourceAutodiscoveryView extends LocatableVLayout { +public class ResourceAutodiscoveryView extends LocatableVLayout implements RefreshableView {
private static final String TITLE = MSG.view_autoDiscoveryQ_title(); private static final String HEADER_ICON = "global/AutoDiscovery_24.png"; @@ -73,6 +74,8 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { private TreeGrid treeGrid; private ToolStrip footer; private DataSource dataSource; + // This allows the selection handler to ignore selection changes initiated by us, as opposed to by the user. + private boolean selectionChangedHandlerDisabled;
private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(1000000);
@@ -167,6 +170,10 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
disableButtons(importButton, ignoreButton, unignoreButton);
+ footer.addMember(new LayoutSpacer()); + + // The remaining footer items (status filter, (de)select all buttons, and refresh button) will be right-aligned. + DynamicForm form = new LocatableDynamicForm(this.extendLocatorId("Status")); final SelectItem statusSelectItem = new SelectItem("status", MSG.view_autoDiscoveryQ_showStatus()); statusSelectItem.setValueMap(AutodiscoveryQueueDataSource.NEW, AutodiscoveryQueueDataSource.IGNORED, @@ -182,7 +189,13 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { }); footer.addMember(form);
- footer.addMember(new LayoutSpacer()); + final IButton selectAllButton = new LocatableIButton(this.extendLocatorId("SelectAll"), + MSG.view_autoDiscoveryQ_selectAll()); + footer.addMember(selectAllButton); + final IButton deselectAllButton = new LocatableIButton(this.extendLocatorId("DeselectAll"), + MSG.view_autoDiscoveryQ_deselectAll()); + deselectAllButton.setDisabled(true); + footer.addMember(deselectAllButton);
IButton refreshButton = new LocatableIButton(extendLocatorId("Refresh"), MSG.common_button_refresh()); refreshButton.addClickHandler(new ClickHandler() { @@ -193,9 +206,6 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { footer.addMember(refreshButton);
treeGrid.addSelectionChangedHandler(new SelectionChangedHandler() { - // use this to ignore selection changes we initiate from within this handler - private boolean selectionChangedHandlerDisabled = false; - public void onSelectionChanged(SelectionEvent selectionEvent) { if (selectionChangedHandlerDisabled || selectionEvent.isRightButtonDown()) { return; @@ -218,7 +228,8 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { } } } - updateButtonEnablement(importButton, ignoreButton, unignoreButton); + updateButtonEnablement(selectAllButton, deselectAllButton, importButton, ignoreButton, + unignoreButton); selectionChangedHandlerDisabled = false; } }); @@ -228,10 +239,11 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { treeGrid.deselectRecord(child); } } - // the immediate redraw below should not be necessary but without it the deselected + // the immediate redraw below should not be necessary, but without it the deselected // platform checkbox remained checked. treeGrid.redraw(); - updateButtonEnablement(importButton, ignoreButton, unignoreButton); + updateButtonEnablement(selectAllButton, deselectAllButton, importButton, ignoreButton, + unignoreButton); selectionChangedHandlerDisabled = false; } } else { @@ -240,52 +252,51 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { treeGrid.selectRecord(parentNode); } } - updateButtonEnablement(importButton, ignoreButton, unignoreButton); + updateButtonEnablement(selectAllButton, deselectAllButton, importButton, ignoreButton, + unignoreButton); selectionChangedHandlerDisabled = false; } }
- private void updateButtonEnablement(IButton importButton, IButton ignoreButton, IButton unignoreButton) { - if (treeGrid.getSelection().length == 0) { - importButton.setDisabled(true); - ignoreButton.setDisabled(true); - unignoreButton.setDisabled(true); - return; - } - - boolean importOk = false; - boolean ignoreOk = false; - boolean unignoreOk = false; - - for (ListGridRecord listGridRecord : treeGrid.getSelection()) { - TreeNode node = (TreeNode) listGridRecord; - String status = node.getAttributeAsString("status"); - TreeNode parentNode = treeGrid.getTree().getParent(node); - boolean isPlatform = treeGrid.getTree().isRoot(parentNode); - - importOk |= InventoryStatus.NEW.name().equals(status); - unignoreOk |= InventoryStatus.IGNORED.name().equals(status); + });
- if (!isPlatform) { - String parentStatus = parentNode.getAttributeAsString("status"); - if (InventoryStatus.COMMITTED.name().equals(parentStatus)) { - ignoreOk |= InventoryStatus.NEW.name().equals(status); + selectAllButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + SC.ask(MSG.view_autoDiscoveryQ_confirmSelectAll(), new BooleanCallback() { + public void execute(Boolean selectChildServers) { + selectionChangedHandlerDisabled = true; + if (selectChildServers) { + treeGrid.selectAllRecords(); + } else { + // Select only the platforms. + TreeNode rootNode = treeGrid.getTree().getRoot(); + TreeNode[] platformNodes = treeGrid.getTree().getChildren(rootNode); + for (TreeNode platformNode : platformNodes) { + treeGrid.selectRecord(platformNode); + } } + selectionChangedHandlerDisabled = false; + updateButtonEnablement(selectAllButton, deselectAllButton, importButton, ignoreButton, + unignoreButton); } - } + }); + } + });
- importButton.setDisabled(!importOk || unignoreOk); - ignoreButton.setDisabled(!ignoreOk || unignoreOk); - unignoreButton.setDisabled(!unignoreOk || importOk || ignoreOk); - markForRedraw(); + deselectAllButton.addClickHandler(new ClickHandler() { + public void onClick(ClickEvent clickEvent) { + selectionChangedHandlerDisabled = true; + treeGrid.deselectAllRecords(); + selectionChangedHandlerDisabled = false; + updateButtonEnablement(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton); } });
importButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { - disableButtons(importButton, ignoreButton, unignoreButton); + disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton); CoreGUI.getMessageCenter().notify( - new Message("Importing the selected Resources...", Message.Severity.Info, EnumSet + new Message(MSG.view_autoDiscoveryQ_importInProgress(), Message.Severity.Info, EnumSet .of(Message.Option.Transient)));
resourceService.importResources(getSelectedIds(), new AsyncCallback<Void>() { @@ -304,9 +315,9 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
ignoreButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { - disableButtons(importButton, ignoreButton, unignoreButton); + disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton); CoreGUI.getMessageCenter().notify( - new Message("Ignoring the selected Resources...", Message.Severity.Info, EnumSet + new Message(MSG.view_autoDiscoveryQ_ignoreInProgress(), Message.Severity.Info, EnumSet .of(Message.Option.Transient)));
resourceService.ignoreResources(getSelectedIds(), new AsyncCallback<Void>() { @@ -325,9 +336,9 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
unignoreButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent clickEvent) { - disableButtons(importButton, ignoreButton, unignoreButton); + disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton); CoreGUI.getMessageCenter().notify( - new Message("Unignoring the selected Resources...", Message.Severity.Info, EnumSet + new Message(MSG.view_autoDiscoveryQ_unignoreInProgress(), Message.Severity.Info, EnumSet .of(Message.Option.Transient)));
resourceService.unignoreResources(getSelectedIds(), new AsyncCallback<Void>() { @@ -346,6 +357,48 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
}
+ private void updateButtonEnablement(IButton selectAllButton, IButton deselectAllButton, + IButton importButton, IButton ignoreButton, IButton unignoreButton) { + if (treeGrid.getSelection().length == 0) { + selectAllButton.setDisabled(false); + deselectAllButton.setDisabled(true); + importButton.setDisabled(true); + ignoreButton.setDisabled(true); + unignoreButton.setDisabled(true); + return; + } + + boolean allSelected = (treeGrid.getSelection().length == treeGrid.getRecords().length); + selectAllButton.setDisabled(allSelected); + deselectAllButton.setDisabled(false); + + boolean importOk = false; + boolean ignoreOk = false; + boolean unignoreOk = false; + + for (ListGridRecord listGridRecord : treeGrid.getSelection()) { + TreeNode node = (TreeNode) listGridRecord; + String status = node.getAttributeAsString("status"); + TreeNode parentNode = treeGrid.getTree().getParent(node); + boolean isPlatform = treeGrid.getTree().isRoot(parentNode); + + importOk |= InventoryStatus.NEW.name().equals(status); + unignoreOk |= InventoryStatus.IGNORED.name().equals(status); + + if (!isPlatform) { + String parentStatus = parentNode.getAttributeAsString("status"); + if (InventoryStatus.COMMITTED.name().equals(parentStatus)) { + ignoreOk |= InventoryStatus.NEW.name().equals(status); + } + } + } + + importButton.setDisabled(!importOk || unignoreOk); + ignoreButton.setDisabled(!ignoreOk || unignoreOk); + unignoreButton.setDisabled(!unignoreOk || importOk || ignoreOk); + markForRedraw(); + } + private void disableButtons(IButton... buttons) { for (IButton button : buttons) { button.setDisabled(true); @@ -363,17 +416,10 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { return TableUtility.getIds(selected); }
- /** Custom refresh operation as we cannot directly extend Table because it - * contains a TreeGrid, not a ListGrid. + /** + * Custom refresh operation, as we cannot extend Table because we use a TreeGrid, not a ListGrid. */ - @Override - public void redraw() { - super.redraw(); - // Now reload the table data. - refresh(); - } - - private void refresh() { + public void refresh() { this.treeGrid.invalidateCache(); this.treeGrid.markForRedraw(); } diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties index ddd0d3e..f7f6f75 100644 --- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties +++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties @@ -831,29 +831,35 @@ view_alerts_table_title_group = Group Alert History view_alerts_table_title_resource = Resource Alert History view_autoDiscoveryQ_committed = Committed view_autoDiscoveryQ_confirmSelect = Also select the platform children? +view_autoDiscoveryQ_confirmSelectAll = Also select the children of each platform? view_autoDiscoveryQ_deleted = Deleted +view_autoDiscoveryQ_deselectAll = Deselect All view_autoDiscoveryQ_field_discoveryTime = Discovery Time view_autoDiscoveryQ_field_inventoryStatus = Inventory Status view_autoDiscoveryQ_field_key = Resource Key view_autoDiscoveryQ_field_name = Resource Name view_autoDiscoveryQ_field_parentId = Parent ID view_autoDiscoveryQ_ignore = Ignore -view_autoDiscoveryQ_ignoreFailure = Failed to ignore resources -view_autoDiscoveryQ_ignoreSuccessful = You have successfully ignored the selected resources. +view_autoDiscoveryQ_ignoreFailure = Failed to ignore Resources +view_autoDiscoveryQ_ignoreInProgress = Ignoring the selected Resources... +view_autoDiscoveryQ_ignoreSuccessful = You have successfully ignored the selected Resources. view_autoDiscoveryQ_ignored = Ignored view_autoDiscoveryQ_import = Import -view_autoDiscoveryQ_importFailure = Failed to import resources -view_autoDiscoveryQ_importSuccessful = You have successfully imported the selected resources. +view_autoDiscoveryQ_importFailure = Failed to import Resources +view_autoDiscoveryQ_importInProgress = Importing the selected Resources... +view_autoDiscoveryQ_importSuccessful = You have successfully imported the selected Resources. view_autoDiscoveryQ_loadFailure = Failed to load the inventory discovery queue view_autoDiscoveryQ_new = New view_autoDiscoveryQ_newAndIgnored = New and Ignored view_autoDiscoveryQ_noItems = No items to show view_autoDiscoveryQ_noperm = (You are not authorized to view the auto-discovery queue) +view_autoDiscoveryQ_selectAll = Select All view_autoDiscoveryQ_showStatus = Show view_autoDiscoveryQ_title = Autodiscovery Queue view_autoDiscoveryQ_unignore = Unignore -view_autoDiscoveryQ_unignoreFailure = Failed to unignore resources -view_autoDiscoveryQ_unignoreSuccessful = You have successfully unignored the selected resources. +view_autoDiscoveryQ_unignoreFailure = Failed to unignore Resources +view_autoDiscoveryQ_unignoreInProgress = Unignoring the selected Resources... +view_autoDiscoveryQ_unignoreSuccessful = You have successfully unignored the selected Resources. view_autoDiscoveryQ_uninventoried = Uninventoried view_bundleVersion_loadFailure = Failed to load bundle version data view_bundle_bundle = Bundle
rhq-commits@lists.fedorahosted.org