modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java | 7 modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 239 --- modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java | 99 + modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/History.java | 147 ++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java | 10 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java | 20 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 130 +- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 45 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 55 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 168 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 5 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 5 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 16 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 371 +++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java | 76 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 9 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java | 14 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java | 352 ----- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java | 378 ------ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java | 376 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java | 96 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 626 ---------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java | 151 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java | 28 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 12 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java | 27 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 6 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 2 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TagCloudView.java | 125 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java | 73 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 5 modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 29 modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js | 119 - 51 files changed, 1508 insertions(+), 2393 deletions(-)
New commits: commit a3fdac16d1b0301ca4771c61ba7f7517d2880117 Merge: 7122b59 080e1d7 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Mar 31 12:56:44 2011 +0200
Merge branch 'master' into as7plugin
commit 080e1d77247f9fe6a730a3db01152554072fb7b3 Merge: 22cb9ff 8573843 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Mar 31 12:56:13 2011 +0200
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 22cb9ff2d4a08c96591f5e6a4670e38505cd6162 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Mar 31 12:53:14 2011 +0200
Be more relaxed when parsing the input.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index 25130ec..fe4ee1c 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -199,6 +199,9 @@ public class StandaloneContainer { if (tokens[0].startsWith("#")) return false;
+ if (tokens[0].isEmpty()) + return false; + Command com = Command.get(tokens[0]); if (com == null) { System.err.println("Command " + tokens[0] + " is unknown"); @@ -486,7 +489,7 @@ public class StandaloneContainer { String pattern = tokens[2]; pattern = pattern.replaceAll("\*", "\.\*");
- if (tokens[1].equals("r")) { + if (tokens[1].equals("r") || tokens[1].startsWith("res")) { Set<Resource> resources = getResources(); for (Resource res : resources) { if (res.getName().matches(pattern)) {
commit 3630e07e77391007034d71692a401a1fe8cd2e3c Author: Heiko W. Rupp hwr@redhat.com Date: Thu Mar 31 12:45:42 2011 +0200
Factor out Command enum and History handling. Print command when input was a script.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index 74ccf48..25130ec 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright (C) 2005-2009 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 @@ -22,10 +22,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; import java.io.InputStreamReader; -import java.io.Writer; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; @@ -56,6 +53,8 @@ import org.rhq.core.pc.inventory.ResourceContainer; import org.rhq.core.pc.measurement.MeasurementManager; import org.rhq.core.pc.operation.OperationContextImpl; import org.rhq.core.pc.plugin.FileSystemPluginFinder; +import org.rhq.core.pc.standaloneContainer.Command; +import org.rhq.core.pc.standaloneContainer.History; import org.rhq.core.pluginapi.operation.OperationContext; import org.rhq.core.pluginapi.operation.OperationServices; import org.rhq.core.pluginapi.operation.OperationServicesResult; @@ -80,29 +79,25 @@ public class StandaloneContainer { InventoryManager inventoryManager; /** Global operation counter */ Integer opId = 0; - /** Holder for the command history */ - List<String> history = new ArrayList<String>(10); /** Map of resource plugin configurations */ Map<Integer, Configuration> resConfigMap = new HashMap<Integer, Configuration>(); /** variable set by find() and which can be used in set() */ int dollarR = 0; - - private static final String HISTORY_HELP = "!! : repeat the last action\n" + // - "!? : show the history of commands issued\n" + // - "!h : show this help\n" + // - "!nn : repeat history item with number nn\n" + // - "!w fileName : write history to file with name fileName\n" + // - "!dnn : delete history item with number nn"; + /** Do we read from stdin ? */ + static boolean isStdin;
public static void main(String[] argv) { StandaloneContainer sc = new StandaloneContainer(); BufferedReader br = null;
- if (argv.length == 0) + if (argv.length == 0) { br = new BufferedReader(new InputStreamReader(System.in)); + isStdin = true; + } else { try { br = new BufferedReader(new InputStreamReader(new FileInputStream(argv[0]))); + isStdin=false; } catch (FileNotFoundException fnfe) { System.err.println("File " + argv[0] + " not found"); System.exit(1); @@ -150,6 +145,8 @@ public class StandaloneContainer {
System.out.println("\nReady.");
+ History history = new History(); + // Run the main loop while (!shouldQuit) { try { @@ -158,13 +155,16 @@ public class StandaloneContainer { if (answer == null) { break; } + if (!isStdin) + System.out.println(answer);
if (answer.equalsIgnoreCase(Command.STDIN.toString())) { br = new BufferedReader(new InputStreamReader(System.in)); + isStdin=true; }
// Check for history commands - answer = handleHistory(answer); + answer = history.handleHistory(answer);
// If we have a 'real' command, dispatch it if (!answer.startsWith("!")) { @@ -184,104 +184,6 @@ public class StandaloneContainer {
}
- /** - * Handle processing of the command history. This gives some csh like commands - * and records the commands given. Nice side effect is the possibility to write the - * history to disk and to use this later as input so that testing can be scripted. - * Commands are: - * <ul> - * <li>!! : repeat the last action</li> - * <li>!? : show the history</li> - * <li>!h : show history help</li> - * <li>!<i>nnn</i> : repeat history item with number <i>nnn</i></li> - * <li>!w <i>file</i> : write the history to the file <i>file</i></li> - * <li>!d<i>nnn</i> : delete the history item with number <i>nnn</i> - * </ul> - * @param answer the input given on the command line - * @return a command or '!' if no command substitution from the history was possible. - */ - private String handleHistory(String answer) { - - // Normal command - just return it - if (!answer.startsWith("!")) { - history.add(answer); - return answer; - } - - // History commands - if (answer.startsWith("!?")) { - for (int i = 0; i < history.size(); i++) - System.out.println("[" + i + "]: " + history.get(i)); - } else if (answer.startsWith("!h")) { - System.out.println(HISTORY_HELP); - return "!"; - } else if (answer.startsWith("!!")) { - String text = history.get(history.size() - 1); - System.out.println(text); - history.add(text); - return text; - } else if (answer.matches("![0-9]+")) { - String id = answer.substring(1); - Integer i; - try { - i = Integer.valueOf(id); - } catch (NumberFormatException nfe) { - System.err.println(id + " is no valid history position"); - return "!"; - } - if (i > history.size()) { - System.err.println(i + " is no valid history position"); - return "!"; - } else { - String text = history.get(i); - System.out.println(text); - history.add(text); - return text; - } - } else if (answer.startsWith("!w")) { - String[] tokens = answer.split(" "); - if (tokens.length < 2) { - System.err.println("Not enough parameters. You need to give a file name"); - } - File file = new File(tokens[1]); - try { - file.createNewFile(); - if (file.canWrite()) { - Writer writer = new FileWriter(file); - for (String item : history) { - writer.write(item); - writer.write("\n"); - } - writer.flush(); - writer.close(); - } else { - System.err.println("Can not write to file " + file); - } - } catch (IOException ioe) { - System.err.println("Saving the history to file " + file + " failed: " + ioe.getMessage()); - } - return "!"; - } else if (answer.matches("!d[0-9]+")) { - String id = answer.substring(2); - Integer i; - try { - i = Integer.valueOf(id); - } catch (NumberFormatException nfe) { - System.err.println(id + " is no valid history position"); - return "!"; - } - if (i > history.size()) { - System.err.println(i + " is no valid history position"); - return "!"; - } - history.remove(i.intValue()); - return "!"; - } else { - System.err.println(answer + " is no valid history command"); - return "!"; - } - return "!"; - }
/** * Dispatches the input to various commands that do the actual work. @@ -809,78 +711,4 @@ public class StandaloneContainer { System.out.println(config.getProperties()); }
- /** - * List of possible commands - */ - private enum Command { - ASCAN("as", "", 0, "Triggers an availability scan"), // - AVAIL("a", " ( id )", 0, - "Shows an availability report. If id is given, only shows availability for resource with id id"), // - CHILDREN("chi", "[id]", 0, "Shows the direct children of the resource with the passed id, or if no id passed of the current resource"), // - DISCOVER("disc", " s | i | all", 1, "Triggers a discovery scan for (s)erver, serv(i)ce or all resources"), // - // EVENT("e", "", 0, "Pull events"), // TODO needs to be defined - FIND("find", "r | t | rt <name>", 2, - "Searches a (r)esource, resource (t)ype or resources of (rt)ype. Use * as wildcard.\n" - + " Will set $r for the last resource shown."), HELP("h", "", 0, "Shows this help"), // - INVOKE("i", "operation [params]", 1, "Triggers running an operation. If operation is '-list' it shows available operations"), // - MEASURE("m", "datatype property+", 1, "Triggers getting metric values. All need to be of the same data type. If datatype is '-list' it shows the defined metrics"), // - NATIVE("n", "e | d | s", 1, "Enables/disables native system or shows native status"), // - QUIT("quit", "", 0, "Terminates the application"), // - RESOURCES("res", "", 0, "Shows the discovered resources"), // - SET("set", "'resource' N", 2, - "Sets the resource id to work with. N can be a number or '$r' as result of last find resource call. 'id' is an alias for 'res'"), // - STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), // - WAIT("w", "milliseconds", 1, "Waits the given amount of time"), - P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."), - R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."), - SR_CONFIG("rcs", "", 0, "[parameters] set resource config "), - SP_CONFIG("pcs", "", 0, "[parameters] set plugin config ") - ; - - private String abbrev; - private String args; - private String help; - private int minArgs; // minimum number of args needed - - public String getArgs() { - return args; - } - - public String getHelp() { - return help; - } - - public int getMinArgs() { - return minArgs; - } - - /** - * Construct a new Command - * @param abbrev Abbreviation for this command - * @param args Description of expected arguments - * @param minArgs Minumum number of arguments that need to be present - * @param help A short description of the command - */ - private Command(String abbrev, String args, int minArgs, String help) { - this.abbrev = abbrev; - this.args = args; - this.minArgs = minArgs; - this.help = help; - } - - public String getAbbrev() { - return abbrev; - } - - public static Command get(String s) { - - String upper = s.toUpperCase(); - - for (Command c : EnumSet.allOf(Command.class)) { - if (c.name().equals(upper) || c.getAbbrev().equals(s.toLowerCase())) - return c; - } - return null; - } - } } diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java new file mode 100644 index 0000000..aa91e22 --- /dev/null +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java @@ -0,0 +1,99 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.pc.standaloneContainer; + +import java.util.EnumSet; + +import org.rhq.core.pc.StandaloneContainer; + +/** + * List of possible commands of the standalone container + * @author Heiko W. Rupp + */ +public enum Command { + ASCAN("as", "", 0, "Triggers an availability scan"), // + AVAIL("a", " ( id )", 0, + "Shows an availability report. If id is given, only shows availability for resource with id id"), // + CHILDREN("chi", "[id]", 0, "Shows the direct children of the resource with the passed id, or if no id passed of the current resource"), // + DISCOVER("disc", " s | i | all", 1, "Triggers a discovery scan for (s)erver, serv(i)ce or all resources"), // + // EVENT("e", "", 0, "Pull events"), // TODO needs to be defined + FIND("find", "r | t | rt <name>", 2, + "Searches a (r)esource, resource (t)ype or resources of (rt)ype. Use * as wildcard.\n" + + " Will set $r for the last resource shown."), HELP("h", "", 0, "Shows this help"), // + INVOKE("i", "operation [params]", 1, "Triggers running an operation. If operation is '-list' it shows available operations"), // + MEASURE("m", "datatype property+", 1, "Triggers getting metric values. All need to be of the same data type. If datatype is '-list' it shows the defined metrics"), // + NATIVE("n", "e | d | s", 1, "Enables/disables native system or shows native status"), // + QUIT("quit", "", 0, "Terminates the application"), // + RESOURCES("res", "", 0, "Shows the discovered resources"), // + SET("set", "'resource' N", 2, + "Sets the resource id to work with. N can be a number or '$r' as result of last find resource call. 'id' is an alias for 'res'"), // + STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), // + WAIT("w", "milliseconds", 1, "Waits the given amount of time"), + P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."), + R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."), + SR_CONFIG("rcs", "", 0, "[parameters] set resource config "), + SP_CONFIG("pcs", "", 0, "[parameters] set plugin config ") + ; + + private String abbrev; + private String args; + private String help; + private int minArgs; // minimum number of args needed + + public String getArgs() { + return args; + } + + public String getHelp() { + return help; + } + + public int getMinArgs() { + return minArgs; + } + + /** + * Construct a new Command + * @param abbrev Abbreviation for this command + * @param args Description of expected arguments + * @param minArgs Minumum number of arguments that need to be present + * @param help A short description of the command + */ + private Command(String abbrev, String args, int minArgs, String help) { + this.abbrev = abbrev; + this.args = args; + this.minArgs = minArgs; + this.help = help; + } + + public String getAbbrev() { + return abbrev; + } + + public static Command get(String s) { + + String upper = s.toUpperCase(); + + for (Command c : EnumSet.allOf(Command.class)) { + if (c.name().equals(upper) || c.getAbbrev().equals(s.toLowerCase())) + return c; + } + return null; + } +} diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/History.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/History.java new file mode 100644 index 0000000..37b5bf1 --- /dev/null +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/History.java @@ -0,0 +1,147 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2011 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.core.pc.standaloneContainer; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +/** + * Handle command line history + * @author Heiko W. Rupp + */ +public class History { + + private static final String HISTORY_HELP = "!! : repeat the last action\n" + // + "!? : show the history of commands issued\n" + // + "!h : show this help\n" + // + "!nn : repeat history item with number nn\n" + // + "!w fileName : write history to file with name fileName\n" + // + "!dnn : delete history item with number nn"; + /** Holder for the command history */ + List<String> history = new ArrayList<String>(10); + + + /** + * Handle processing of the command history. This gives some csh like commands + * and records the commands given. Nice side effect is the possibility to write the + * history to disk and to use this later as input so that testing can be scripted. + * Commands are: + * <ul> + * <li>!! : repeat the last action</li> + * <li>!? : show the history</li> + * <li>!h : show history help</li> + * <li>!<i>nnn</i> : repeat history item with number <i>nnn</i></li> + * <li>!w <i>file</i> : write the history to the file <i>file</i></li> + * <li>!d<i>nnn</i> : delete the history item with number <i>nnn</i> + * </ul> + * @param answer the input given on the command line + * @return a command or '!' if no command substitution from the history was possible. + */ + public String handleHistory(String answer) { + + // Normal command - just return it + if (!answer.startsWith("!")) { + history.add(answer); + return answer; + } + + // History commands + if (answer.startsWith("!?")) { + for (int i = 0; i < history.size(); i++) + System.out.println("[" + i + "]: " + history.get(i)); + } else if (answer.startsWith("!h")) { + System.out.println(HISTORY_HELP); + return "!"; + } else if (answer.startsWith("!!")) { + String text = history.get(history.size() - 1); + System.out.println(text); + history.add(text); + return text; + } else if (answer.matches("![0-9]+")) { + String id = answer.substring(1); + Integer i; + try { + i = Integer.valueOf(id); + } catch (NumberFormatException nfe) { + System.err.println(id + " is no valid history position"); + return "!"; + } + if (i > history.size()) { + System.err.println(i + " is no valid history position"); + return "!"; + } else { + String text = history.get(i); + System.out.println(text); + history.add(text); + return text; + } + } else if (answer.startsWith("!w")) { + String[] tokens = answer.split(" "); + if (tokens.length < 2) { + System.err.println("Not enough parameters. You need to give a file name"); + } + File file = new File(tokens[1]); + try { + file.createNewFile(); + if (file.canWrite()) { + Writer writer = new FileWriter(file); + for (String item : history) { + writer.write(item); + writer.write("\n"); + } + writer.flush(); + writer.close(); + } else { + System.err.println("Can not write to file " + file); + } + } catch (IOException ioe) { + System.err.println("Saving the history to file " + file + " failed: " + ioe.getMessage()); + } + return "!"; + } else if (answer.matches("!d[0-9]+")) { + String id = answer.substring(2); + Integer i; + try { + i = Integer.valueOf(id); + } catch (NumberFormatException nfe) { + System.err.println(id + " is no valid history position"); + return "!"; + } + if (i > history.size()) { + System.err.println(i + " is no valid history position"); + return "!"; + } + history.remove(i.intValue()); + return "!"; + } else { + System.err.println(answer + " is no valid history command"); + return "!"; + } + return "!"; + } + + public int size() { + return history.size(); + } + +}
commit 8573843d27eac077950e9a54246e651897637f0c Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 21:13:34 2011 -0400
format col
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java index c839109..dad4578 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java @@ -43,6 +43,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple; import org.rhq.core.domain.configuration.definition.PropertySimpleType; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.LinkManager; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; @@ -186,6 +187,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField timeRecent = new ListGridField(RecentOperationsDataSource.Field.TIME.propertyName(), RecentOperationsDataSource.Field.TIME.title(), WIDTH_RECENT_TIME); + TimestampCellFormatter.prepareDateField(timeRecent);
ListGridField statusRecent = new ListGridField(RecentOperationsDataSource.Field.STATUS.propertyName(), RecentOperationsDataSource.Field.STATUS.title(), WIDTH_RECENT_STATUS); @@ -215,6 +217,7 @@ public class OperationsPortlet extends LocatableVLayout implements CustomSetting
ListGridField timeNext = new ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(), ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME); + TimestampCellFormatter.prepareDateField(timeNext);
scheduledOperationsGrid.setFields(resourceNext, ancestryNext, operationNext, timeNext); }
commit eac8b15a961194621d8c2ce8e09f338feb895760 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 20:56:02 2011 -0400
format cols
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java index 40a826d..27b1040 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryDetailsView.java @@ -18,6 +18,10 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+import java.util.ArrayList; +import java.util.Date; +import java.util.List; + import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; @@ -30,7 +34,7 @@ import com.smartgwt.client.widgets.form.fields.LinkItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; -import com.smartgwt.client.widgets.layout.VLayout; + import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.operation.OperationDefinition; import org.rhq.core.domain.operation.OperationHistory; @@ -39,20 +43,17 @@ import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVStack; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author Greg Hinkle */ -public abstract class AbstractOperationHistoryDetailsView<T extends OperationHistory> extends LocatableVStack - implements BookmarkableView { +public abstract class AbstractOperationHistoryDetailsView<T extends OperationHistory> extends LocatableVStack implements + BookmarkableView {
private T operationHistory;
@@ -110,11 +111,11 @@ public abstract class AbstractOperationHistoryDetailsView<T extends OperationHis
OperationDefinition operationDefinition = operationHistory.getOperationDefinition(); ConfigurationDefinition parametersConfigurationDefinition = operationDefinition - .getParametersConfigurationDefinition(); - if (parametersConfigurationDefinition != null && - !parametersConfigurationDefinition.getPropertyDefinitions().isEmpty()) { + .getParametersConfigurationDefinition(); + if (parametersConfigurationDefinition != null + && !parametersConfigurationDefinition.getPropertyDefinitions().isEmpty()) { ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("params"), - parametersConfigurationDefinition, operationHistory.getParameters()); + parametersConfigurationDefinition, operationHistory.getParameters()); editor.setReadOnly(true); parametersSection.addMember(editor); } else { @@ -150,7 +151,7 @@ public abstract class AbstractOperationHistoryDetailsView<T extends OperationHis
StaticTextItem submittedItem = new StaticTextItem(AbstractOperationHistoryDataSource.Field.STARTED_TIME, MSG .view_operationHistoryDetails_dateSubmitted()); - submittedItem.setValue(new Date(operationHistory.getStartedTime())); + submittedItem.setValue(TimestampCellFormatter.format(operationHistory.getStartedTime())); items.add(submittedItem);
StaticTextItem completedItem = new StaticTextItem("completed", MSG.view_operationHistoryDetails_dateCompleted()); @@ -159,7 +160,8 @@ public abstract class AbstractOperationHistoryDetailsView<T extends OperationHis } else if (status == OperationRequestStatus.CANCELED) { completedItem.setValue(MSG.common_val_never()); } else { - completedItem.setValue(new Date(operationHistory.getStartedTime() + operationHistory.getDuration())); + completedItem.setValue(TimestampCellFormatter.format(new Date(operationHistory.getStartedTime() + + operationHistory.getDuration()))); } items.add(completedItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java index e058004..5433940 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java @@ -19,10 +19,8 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
import java.util.ArrayList; -import java.util.Date; import java.util.List;
-import com.google.gwt.i18n.client.DateTimeFormat; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.Record; @@ -46,6 +44,7 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow; @@ -143,16 +142,19 @@ public abstract class AbstractOperationHistoryListView<T extends AbstractOperati ListGridField startedTimeField = new ListGridField(AbstractOperationHistoryDataSource.Field.STARTED_TIME); startedTimeField.setAlign(Alignment.LEFT); startedTimeField.setCellAlign(Alignment.LEFT); - startedTimeField.setCellFormatter(new CellFormatter() { + startedTimeField.setCellFormatter(new TimestampCellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { - Date date = (Date) value; - return DateTimeFormat.getMediumDateTimeFormat().format(date); + return super.format(value, record, rowNum, colNum); } else { return "<i>" + MSG.view_operationHistoryList_notYetStarted() + "</i>"; } } }); + startedTimeField.setShowHover(true); + startedTimeField.setHoverCustomizer(TimestampCellFormatter + .getHoverCustomizer(AbstractOperationHistoryDataSource.Field.STARTED_TIME)); + return startedTimeField; }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java index b2c80ba..60f9efc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleListView.java @@ -25,6 +25,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; import org.rhq.enterprise.gui.coregui.client.components.table.SubjectRecordCellFormatter; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/** * @author Ian Springer @@ -51,7 +52,8 @@ public abstract class AbstractOperationScheduleListView extends TableSection<Abs subjectField.setCellFormatter(new SubjectRecordCellFormatter());
ListGridField nextFireTimeField = new ListGridField(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME, - 190); + 190); + TimestampCellFormatter.prepareDateField(nextFireTimeField);
ListGridField descriptionField = new ListGridField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
commit f48ccec96ccbafafb3d002dc9e7fa462b2ee75cb Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 20:14:31 2011 -0400
fix col format
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java index 3d41d42..75c4bc4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java @@ -26,7 +26,6 @@ import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.CellFormatter; @@ -43,6 +42,7 @@ import org.rhq.core.domain.criteria.AbstractResourceConfigurationUpdateCriteria; import org.rhq.core.domain.resource.Resource; import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow; import org.rhq.enterprise.gui.coregui.client.LinkManager; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; @@ -155,13 +155,13 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR ListGridField submittedTimeField = new ListGridField(Field.CREATED_TIME, MSG .dataSource_configurationHistory_dateSubmitted()); submittedTimeField.setType(ListGridFieldType.DATE); - submittedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + TimestampCellFormatter.prepareDateField(submittedTimeField); fields.add(submittedTimeField);
ListGridField completedTimeField = new ListGridField(Field.MODIFIED_TIME, MSG .dataSource_configurationHistory_dateCompleted()); completedTimeField.setType(ListGridFieldType.DATE); - completedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + TimestampCellFormatter.prepareDateField(completedTimeField); fields.add(completedTimeField);
ListGridField statusField = new ListGridField(Field.STATUS, MSG.common_title_status());
commit 9da6973e664b288b3ad21a2521685594e1691e36 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 20:02:51 2011 -0400
fix col format and hover
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java index ae28218..31520bd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationMembers.java @@ -52,6 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; @@ -121,8 +122,10 @@ public class HistoryGroupResourceConfigurationMembers extends LocatableVLayout { ListGridField fieldAncestry = AncestryUtil.setupAncestryListGridField(); ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG .common_title_dateCreated()); + TimestampCellFormatter.prepareDateField(fieldDateCreated); ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG .common_title_lastUpdated()); + TimestampCellFormatter.prepareDateField(fieldLastUpdated); ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status()); ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java index d6da7d0..35be43c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/configuration/HistoryGroupResourceConfigurationTable.java @@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -80,6 +81,9 @@ public class HistoryGroupResourceConfigurationTable extends Table<HistoryGroupRe ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status()); ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
+ TimestampCellFormatter.prepareDateField(fieldDateCreated); + TimestampCellFormatter.prepareDateField(fieldLastUpdated); + fieldId.setWidth("10%"); fieldDateCreated.setWidth("35%"); fieldLastUpdated.setWidth("35%"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java index b2f923c..2699dff 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationMembers.java @@ -52,6 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; @@ -120,8 +121,10 @@ public class HistoryGroupPluginConfigurationMembers extends LocatableVLayout { ListGridField fieldAncestry = AncestryUtil.setupAncestryListGridField(); ListGridField fieldDateCreated = new ListGridField(DataSource.Field.DATECREATED, MSG .common_title_dateCreated()); + TimestampCellFormatter.prepareDateField(fieldDateCreated); ListGridField fieldLastUpdated = new ListGridField(DataSource.Field.LASTUPDATED, MSG .common_title_lastUpdated()); + TimestampCellFormatter.prepareDateField(fieldLastUpdated); ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status()); ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java index 1c36f7c..9dcd1c5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/inventory/HistoryGroupPluginConfigurationTable.java @@ -50,6 +50,7 @@ import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; @@ -80,6 +81,9 @@ public class HistoryGroupPluginConfigurationTable extends Table<HistoryGroupPlug ListGridField fieldStatus = new ListGridField(DataSource.Field.STATUS, MSG.common_title_status()); ListGridField fieldUser = new ListGridField(DataSource.Field.USER, MSG.common_title_user());
+ TimestampCellFormatter.prepareDateField(fieldDateCreated); + TimestampCellFormatter.prepareDateField(fieldLastUpdated); + fieldId.setWidth("10%"); fieldDateCreated.setWidth("35%"); fieldLastUpdated.setWidth("35%");
commit 6bb2125a164e9dfbdddce5a32cfbf4dc93c6a7d4 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 19:49:13 2011 -0400
unsure if this does anything- but I still can't get the hover to work - no idea why
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java index 17dbb52..1d64d92 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java @@ -29,6 +29,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.core.DataClass; import com.smartgwt.client.data.Record; import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; @@ -209,6 +210,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi ListGridField status = new ListGridField("status", MSG.view_alert_common_tab_notifications_status()); status.setWidth("50"); status.setAlign(Alignment.CENTER); + status.setType(ListGridFieldType.IMAGE); status.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { String statusStr = record.getAttribute("status");
commit d9c77b890c647450837fb876c74e2d66c01ff789 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 19:48:33 2011 -0400
fix notificaton log tab
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java index f30c23b..58346f0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/ImageManager.java @@ -1,6 +1,7 @@ package org.rhq.enterprise.gui.coregui.client;
import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.alert.notification.ResultState; import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; import org.rhq.core.domain.event.EventSeverity; import org.rhq.core.domain.measurement.AvailabilityType; @@ -405,6 +406,25 @@ public class ImageManager { return "subsystems/event/Events" + icon + "_16.png"; }
+ public static String getAlertNotificationResultIcon(ResultState status) { + if (status == null) { + status = ResultState.UNKNOWN; + } + switch (status) { + case SUCCESS: + return ImageManager.getAvailabilityIcon(Boolean.TRUE); + case FAILURE: + return ImageManager.getAvailabilityIcon(Boolean.FALSE); + case PARTIAL: + return ImageManager.getAvailabilityYellowIcon(); + case DEFERRED: + return "[skin]/actions/redo.png"; // for lack of a better icon + case UNKNOWN: + default: + return ImageManager.getAvailabilityIcon(null); + } + } + /** * This returns an icon of the badge (e.g. the red X or the blue I) without the * event icon. This is used if you have a table of events and the user knows they are diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 71a698a..262f7d0 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -398,7 +398,7 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { for (AlertNotificationLog log : from.getAlertNotificationLogs()) { DataClass dc = new DataClass(); dc.setAttribute("sender", log.getSender()); - dc.setAttribute("status", log.getResultState()); + dc.setAttribute("status", log.getResultState().name()); dc.setAttribute("message", log.getMessage());
notifications[i++] = dc; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java index 14cfc8a..17dbb52 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java @@ -32,6 +32,8 @@ import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.HoverCustomizer; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -39,10 +41,12 @@ import com.smartgwt.client.widgets.tab.Tab; import com.smartgwt.client.widgets.tab.TabSet;
import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.notification.ResultState; import org.rhq.core.domain.criteria.AlertCriteria; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTab; import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTabSet; @@ -198,12 +202,43 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi DataClass[] input = record.getAttributeAsRecordArray("notificationLogs"); ListGrid grid = getListGrid(); grid.setData((Record[]) input); + ListGridField sender = new ListGridField("sender", MSG.view_alert_common_tab_notifications_sender()); sender.setWidth("33%"); + ListGridField status = new ListGridField("status", MSG.view_alert_common_tab_notifications_status()); - status.setWidth("33%"); + status.setWidth("50"); + status.setAlign(Alignment.CENTER); + status.setCellFormatter(new CellFormatter() { + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + String statusStr = record.getAttribute("status"); + ResultState statusEnum = (statusStr == null) ? ResultState.UNKNOWN : ResultState.valueOf(statusStr); + return imgHTML(ImageManager.getAlertNotificationResultIcon(statusEnum)); + } + }); + status.setShowHover(true); + status.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { + String statusStr = record.getAttribute("status"); + ResultState statusEnum = (statusStr == null) ? ResultState.UNKNOWN : ResultState.valueOf(statusStr); + switch (statusEnum) { + case SUCCESS: + return MSG.common_status_success(); + case FAILURE: + return MSG.common_status_failed(); + case PARTIAL: + return MSG.common_status_partial(); + case DEFERRED: + return MSG.common_status_deferred(); + case UNKNOWN: + default: + return MSG.common_status_unknown(); + } + } + }); + ListGridField message = new ListGridField("message", MSG.view_alert_common_tab_notifications_message()); - message.setWidth("34%"); + message.setWidth("*");
grid.setFields(sender, status, message); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java index 1838e14..c00a454 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java @@ -23,14 +23,12 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.AnimationEffect; import com.smartgwt.client.types.AutoFitWidthApproach; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.util.BooleanCallback; import com.smartgwt.client.util.SC; @@ -74,6 +72,7 @@ import org.rhq.enterprise.gui.coregui.client.bundle.revert.BundleRevertWizard; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; import org.rhq.enterprise.gui.coregui.client.components.buttons.BackButton; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView; import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback; import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync; @@ -164,8 +163,8 @@ public class BundleDeploymentView extends LocatableVLayout implements Bookmarkab bundleVersionName.setTarget("_self");
StaticTextItem deployed = new StaticTextItem("deployed", MSG.view_bundle_deployed()); - deployed.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); - deployed.setValue(new Date(deployment.getCtime())); + deployed.setValue(TimestampCellFormatter.format(deployment.getCtime(), + TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
StaticTextItem deployedBy = new StaticTextItem("deployedBy", MSG.view_bundle_deploy_deployedBy()); deployedBy.setValue(deployment.getSubjectName()); 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 c5f4d20..1867bf7 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 @@ -235,6 +235,8 @@ common_status_failed = Failed common_status_inprogress = In Progress common_status_canceled = Canceled common_status_unknown = Unknown +common_status_deferred = Deferred +common_status_partial = Partial
# 1st, 2nd, 3rd, 4th, etc. common_val_n1st = {0}st
commit caf6832295d8c0a44cfd77a251a530e28b53c0be Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 17:18:11 2011 -0400
fix fields
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java index afcb435..c221bd4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java @@ -30,7 +30,6 @@ import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceImageField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.Alignment; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.grid.HoverCustomizer; @@ -42,6 +41,7 @@ import org.rhq.core.domain.criteria.AlertDefinitionCriteria; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; +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.util.RPCDataSource;
@@ -87,13 +87,13 @@ public abstract class AbstractAlertDefinitionsDataSource extends
ListGridField ctimeField = new ListGridField(FIELD_CTIME, MSG.view_alerts_field_created_time()); ctimeField.setType(ListGridFieldType.DATE); - ctimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + TimestampCellFormatter.prepareDateField(ctimeField); ctimeField.setWidth("15%"); fields.add(ctimeField);
ListGridField mtimeField = new ListGridField(FIELD_MTIME, MSG.view_alerts_field_modified_time()); mtimeField.setType(ListGridFieldType.DATE); - mtimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + TimestampCellFormatter.prepareDateField(mtimeField); mtimeField.setWidth("15%"); fields.add(mtimeField);
commit e3ca14ca6588adbc11c58c1fffca0c93841fa88d Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 30 17:46:34 2011 -0400
Fix an issue when performing direct navigation to bookmarkable subtab views.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java index 04d6410..cac30b2 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/AbstractTwoLevelTabSetView.java @@ -247,12 +247,19 @@ public abstract class AbstractTwoLevelTabSetView<T, U extends Layout> extends Lo // select the subTab (this does not fire an event, just sets the subtab) tab.getLayout().selectSubTab(subtab);
- // now that the tab/subtab is determined, if currently selected tab is not the desired tab, then - // select it now (firing a new event). + // the target tab/subtab is now determined. if the currently selected tab is not the target tab then + // select it now. if (!tab.equals(this.tabSet.getSelectedTab())) { - this.tabSet.setIgnoreSelectEvents(false); + + // Fire a tab selection event only if we're at the end of the path. If not then it is assumed that + // the subtab view is a BookmarkableView and the navigation will continue in that way, below. + if (viewPath.isEnd()) { + this.tabSet.setIgnoreSelectEvents(false); + this.tabSet.selectTab(tab); + return; + } + this.tabSet.selectTab(tab); - return; }
// if the desired tab/subtab are already selected, now we can render the subtab canvas
commit 7e2125b7c5e89bb921be4b0aa2ccb203401ec62e Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 30 17:45:27 2011 -0400
Fix a null protection issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java index e321819..2746c41 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.LinkedHashMap;
import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.ResultSet; import com.smartgwt.client.data.SortSpecifier; import com.smartgwt.client.types.MultipleAppearance; import com.smartgwt.client.types.SortDirection; @@ -169,7 +170,8 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { new TableAction() { public boolean isEnabled(ListGridRecord[] selection) { ListGrid grid = getListGrid(); - return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty()); + ResultSet resultSet = (null != grid) ? grid.getResultSet() : null; + return (hasWriteAccess && grid != null && resultSet != null && !resultSet.isEmpty()); }
public void executeAction(ListGridRecord[] selection, Object actionValue) { @@ -180,7 +182,8 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { new TableAction() { public boolean isEnabled(ListGridRecord[] selection) { ListGrid grid = getListGrid(); - return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty()); + ResultSet resultSet = (null != grid) ? grid.getResultSet() : null; + return (hasWriteAccess && grid != null && resultSet != null && !resultSet.isEmpty()); }
public void executeAction(ListGridRecord[] selection, Object actionValue) {
commit ed227f84f309a55d2e7fe06169cdb1b4cb2ab97d Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 16:59:02 2011 -0400
group def interval spinner should step every 1m label it as (ms) so people know the units fix some columns
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java index 53a0209..260ed01 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java @@ -23,7 +23,7 @@ public class TimestampCellFormatter implements CellFormatter { private DateTimeFormat dateTimeFormat;
/** - * Uses SHORT format. + * Uses MEDIUM format. */ public TimestampCellFormatter() { this(DATE_TIME_FORMAT_MEDIUM); @@ -40,7 +40,7 @@ public class TimestampCellFormatter implements CellFormatter {
/** * @param value - * @return SHORT format for value + * @return MEDIUM format for value */ public static String format(Object value) { return format(value, DATE_TIME_FORMAT_MEDIUM); @@ -94,15 +94,27 @@ public class TimestampCellFormatter implements CellFormatter { return new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { Date attribValue = record.getAttributeAsDate(dateTimeAttributeName); - if (attribValue != null) { - StringBuilder sb = new StringBuilder("<p style='width:300px'>"); - sb.append(format(attribValue, DATE_TIME_FORMAT_FULL)); - sb.append("</p>"); - return sb.toString(); - } else { - return null; - } + return getHoverDateString(attribValue); } }; } + + /** + * Returns an HTML string that can be used in as hover for a date field. + * It formats the date in the FULL format. + * + * @param date + * @return HTML string that shows the date in FULL format, + * or <code>null</code> if <code>date</code> is <code>null</code> + */ + public static String getHoverDateString(Date date) { + if (date != null) { + StringBuilder sb = new StringBuilder("<p style='width:300px'>"); + sb.append(format(date, DATE_TIME_FORMAT_FULL)); + sb.append("</p>"); + return sb.toString(); + } else { + return null; + } + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java index cef860a..0207062 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionDataSource.java @@ -86,7 +86,7 @@ public class GroupDefinitionDataSource extends RPCDataSource<GroupDefinition, Re
// it is a Long, but there is no DataSourceLongField and I've seen problems trying to use anything other than text field DataSourceTextField lastCalculationTimeIntervalField = new DataSourceTextField("lastCalculationTime", MSG - .view_dynagroup_recalculationInterval()); + .view_dynagroup_lastCalculationTime()); fields.add(lastCalculationTimeIntervalField);
// it is a Long, but there is no DataSourceLongField and I've seen problems trying to use anything other than text field diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java index 4a9106b..9106e60 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/GroupDefinitionListView.java @@ -18,6 +18,7 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.groups.definitions;
+import java.util.Date; import java.util.Set;
import com.google.gwt.user.client.History; @@ -25,6 +26,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.HoverCustomizer; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -47,7 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; * @author Greg Hinkle * @author Joseph Marques */ -public class GroupDefinitionListView extends TableSection { +public class GroupDefinitionListView extends TableSection<GroupDefinitionDataSource> { private static final String TITLE = MSG.view_dynagroup_definitions();
public GroupDefinitionListView(String locatorId, String headerIcon) { @@ -84,6 +86,17 @@ public class GroupDefinitionListView extends TableSection { return super.format(value, record, rowNum, colNum); } }); + lastCalculationTimeField.setShowHover(true); + lastCalculationTimeField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { + String attribValue = record.getAttribute("lastCalculationTime"); + if (attribValue != null) { + return TimestampCellFormatter.getHoverDateString(new Date(Long.valueOf(attribValue).longValue())); + } else { + return null; + } + } + });
ListGridField nextCalculationTimeField = new ListGridField("nextCalculationTime", MSG .view_dynagroup_nextCalculationTime(), 175); @@ -95,6 +108,18 @@ public class GroupDefinitionListView extends TableSection { return super.format(value, record, rowNum, colNum); } }); + nextCalculationTimeField.setShowHover(true); + nextCalculationTimeField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { + String attribValue = record.getAttribute("nextCalculationTime"); + if (attribValue != null && !("0".equals(attribValue.toString()))) { + return TimestampCellFormatter.getHoverDateString(new Date(Long.valueOf(attribValue).longValue())); + } else { + return null; + } + } + }); + setListGridFields(idField, nameField, descriptionField, expressionField, lastCalculationTimeField, nextCalculationTimeField);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java index 865e03b..a302455 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java @@ -397,6 +397,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm //recalculationInterval.setWrapTitle(false); // do not set this - it causes the form to grow abnormally width-wise for some reason recalculationInterval.setMin(0); recalculationInterval.setDefaultValue(0); + recalculationInterval.setStep(60000); // the recalc interval is in milliseconds, step up one minute at a time }
public static LinkedHashMap<String, String> getTemplates() { 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 ae8ccbd..c5f4d20 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 @@ -1707,7 +1707,7 @@ view_titleBar_group_failInfo = Failed to get general info on group [{0}] with ID view_titleBar_group_summary_collapsedTooltip = Click to show more details for this group view_titleBar_group_summary_expandedTooltip = Click to hide details for this group view_dynagroup_expressionSet = Expression Set -view_dynagroup_recalculationInterval = Recalculation Interval +view_dynagroup_recalculationInterval = Recalculation Interval (ms) view_dynagroup_lastCalculationTime = Last Calculation Time view_dynagroup_nextCalculationTime = Next Calculation Time view_dynagroup_definitionCreated = You have successfully created a group definition named [{0}]
commit 9eaaf6b98d89a8756f12f5d8664e495ba11b91d3 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 16:24:44 2011 -0400
protect against null attribute value
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java index f17c62f..53a0209 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java @@ -92,12 +92,16 @@ public class TimestampCellFormatter implements CellFormatter {
public static HoverCustomizer getHoverCustomizer(final String dateTimeAttributeName) { return new HoverCustomizer() { - public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { - StringBuilder sb = new StringBuilder("<p style='width:300px'>"); - sb.append(format(record.getAttributeAsDate(dateTimeAttributeName), DATE_TIME_FORMAT_FULL)); - sb.append("</p>"); - return sb.toString(); + Date attribValue = record.getAttributeAsDate(dateTimeAttributeName); + if (attribValue != null) { + StringBuilder sb = new StringBuilder("<p style='width:300px'>"); + sb.append(format(attribValue, DATE_TIME_FORMAT_FULL)); + sb.append("</p>"); + return sb.toString(); + } else { + return null; + } } }; }
commit 4ca57bc786e2ce8772dce7fd0981f9e618d6b67e Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 16:09:31 2011 -0400
format more cols
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java index cde6b9e..a9c1dc7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java @@ -28,7 +28,6 @@ import java.util.Date; import java.util.List;
import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; @@ -185,7 +184,7 @@ public class RecentlyAddedResourceDS extends DataSource { setAttribute("id", id); setAttribute("parentId", parentId); setAttribute("name", recentlyAdded.getName()); - setAttribute("timestamp", DateTimeFormat.getMediumDateTimeFormat().format(dateAdded)); + setAttribute("timestamp", dateAdded); setIsFolder(recentlyAdded.getParentId() == 0); } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java index e570a04..c4685da 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java @@ -38,6 +38,7 @@ import com.smartgwt.client.widgets.tree.TreeGrid; import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.dashboard.DashboardPortlet; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; @@ -95,7 +96,7 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C });
ListGridField timestampField = new ListGridField("timestamp", MSG.common_title_timestamp()); - + TimestampCellFormatter.prepareDateField(timestampField); treeGrid.setFields(resourceNameField, timestampField);
if (!simple) {
commit 13609683074b17265180c9b704479989b2095d16 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 14:52:32 2011 -0400
quick fix some more columns and hovers
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java index b99ab75..42711b6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java @@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deployment; import java.util.HashMap;
import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.events.DoubleClickEvent; import com.smartgwt.client.widgets.events.DoubleClickHandler; @@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/** * @author Greg Hinkle @@ -70,9 +70,8 @@ public class BundleDeploymentListView extends Table<BundleDeploymentDataSource> .common_title_status()); ListGridField deployTimeField = new ListGridField(BundleDeploymentDataSource.FIELD_DEPLOY_TIME, MSG .view_bundle_deploy_time()); - + TimestampCellFormatter.prepareDateField(deployTimeField); deployTimeField.setType(ListGridFieldType.DATE); - deployTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
// only users that are authorized can see deployments if (canManageBundles) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java index f9dbe30..d1e5a74 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java @@ -50,6 +50,7 @@ import org.rhq.core.domain.bundle.BundleDeploymentStatus; import org.rhq.core.domain.bundle.BundleResourceDeployment; import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory; import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; @@ -103,6 +104,7 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout { user.setHidden(true);
ListGridField timestamp = new ListGridField("timestamp", MSG.common_title_timestamp()); + TimestampCellFormatter.prepareDateField(timestamp); timestamp.setWidth("40%");
ListGridField status = new ListGridField("status", MSG.common_title_status()); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java index e95626c..d3ca12c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java @@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.bundle.destination; import java.util.HashMap;
import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.events.DoubleClickEvent; import com.smartgwt.client.widgets.events.DoubleClickHandler; @@ -38,6 +37,7 @@ import org.rhq.core.domain.bundle.BundleDeploymentStatus; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/** * @author Greg Hinkle @@ -74,7 +74,7 @@ public class BundleDestinationListView extends Table<BundleDestinationDataSource BundleDestinationDataSource.FIELD_LATEST_DEPLOY_STATUS, MSG.view_bundle_dest_lastDeploymentStatus());
latestDeploymentDateField.setType(ListGridFieldType.DATE); - latestDeploymentDateField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + TimestampCellFormatter.prepareDateField(latestDeploymentDateField);
nameField.setCellFormatter(new CellFormatter() { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { @@ -107,6 +107,7 @@ public class BundleDestinationListView extends Table<BundleDestinationDataSource latestDeploymentStatusField.setValueIcons(statusIcons); latestDeploymentStatusField.setValueIconHeight(11); latestDeploymentStatusField.setValueIconWidth(11); + latestDeploymentStatusField.setShowValueIconOnly(true);
idField.setWidth(50); nameField.setWidth("20%"); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java index dd7d3f3..ba62aa4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java @@ -19,7 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList; -import java.util.Date; import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback; @@ -40,6 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem; import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm; import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator; import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler; +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.ResourceGroupGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.message.Message; @@ -199,11 +199,11 @@ public class GeneralProperties extends LocatableVLayout { formItems.add(recursiveItem);
StaticTextItem createdItem = new StaticTextItem("created", MSG.common_title_dateCreated()); - createdItem.setValue(new Date(group.getCtime())); + createdItem.setValue(TimestampCellFormatter.format(group.getCtime())); formItems.add(createdItem);
StaticTextItem lastModifiedItem = new StaticTextItem("lastModified", MSG.common_title_lastUpdated()); - lastModifiedItem.setValue(new Date(group.getMtime())); + lastModifiedItem.setValue(TimestampCellFormatter.format(group.getMtime())); formItems.add(lastModifiedItem);
StaticTextItem lastModifiedByItem = new StaticTextItem("lastModifiedBy", MSG.common_title_lastUpdatedBy());
commit b73e1a2fdeca8cf1d1e5739e79807fe1ba8afcf7 Author: Ian Springer ian.springer@redhat.com Date: Wed Mar 30 15:53:27 2011 -0400
remove unused http://www.dyn-web.com/ javascript code (https://bugzilla.redhat.com/show_bug.cgi?id=536549)
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js index ca82a55..c9e6b2e 100644 --- a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js +++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js @@ -123,122 +123,3 @@ var overlay = { WindowResizeTracker.addListener(function() { overlay.refresh(); }); - -/************************************************************************* - This code is from Dynamic Web Coding at http://www.dyn-web.com/ - Copyright 2003 by Sharon Paine - See Terms of Use at http://www.dyn-web.com/bus/terms.html - regarding conditions under which you may use this code. - This notice must be retained in the code as is! -*************************************************************************/ - -var viewport = { - getWinWidth: function () { - this.width = 0; - if (window.innerWidth) this.width = window.innerWidth - 18; - else if (document.documentElement && document.documentElement.clientWidth) - this.width = document.documentElement.clientWidth; - else if (document.body && document.body.clientWidth) - this.width = document.body.clientWidth; - }, - - getWinHeight: function () { - this.height = 0; - if (window.innerHeight) this.height = window.innerHeight - 18; - else if (document.documentElement && document.documentElement.clientHeight) - this.height = document.documentElement.clientHeight; - else if (document.body && document.body.clientHeight) - this.height = document.body.clientHeight; - }, - - getScrollX: function () { - this.scrollX = 0; - if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset -; - else if (document.documentElement && document.documentElement.scrollLeft) - this.scrollX = document.documentElement.scrollLeft; - else if (document.body && document.body.scrollLeft) - this.scrollX = document.body.scrollLeft; - else if (window.scrollX) this.scrollX = window.scrollX; - }, - - getScrollY: function () { - this.scrollY = 0; - if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset -; - else if (document.documentElement && document.documentElement.scrollTop) - this.scrollY = document.documentElement.scrollTop; - else if (document.body && document.body.scrollTop) - this.scrollY = document.body.scrollTop; - else if (window.scrollY) this.scrollY = window.scrollY; - }, - - getAll: function () { - this.getWinWidth(); this.getWinHeight(); - this.getScrollX(); this.getScrollY(); - } - -} - -var menuLayers = { - timer: null, - activeMenuID: null, - offX: 3, // horizontal offset - offY: 5, // vertical offset - - show: function(id, e) { - var mnu = $? $(id): null; - if (!mnu) return; - this.activeMenuID = id; - if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck; - if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer; - viewport.getAll(); - this.position(mnu, e); - }, - - hide: function() { - this.clearTimer(); - if (this.activeMenuID && $) - this.timer = setTimeout("$('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200); - }, - - position: function(mnu, e) { - var x = e.pageX? e.pageX: e.clientX + viewport.scrollX; - var y = e.pageY? e.pageY: e.clientY + viewport.scrollY; - - if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX ) - x = x - mnu.offsetWidth - this.offX; - else x = x + this.offX; - - if ( y + mnu.offsetHeight + this.offY > - viewport.height + viewport.scrollY ) - y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )? - y - mnu.offsetHeight - this.offY : - viewport.height + viewport.scrollY - mnu.offsetHeight; - else y = y + this.offY; - - this.timer = setTimeout("$('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200); - mnu.style.left = x + "px"; mnu.style.top = y + "px"; - }, - - mouseoutCheck: function(e) { - e = e? e: window.event; - // is element moused into contained by menu? or is it menu (ul or li or a to menu div)? - var mnu = $(menuLayers.activeMenuID); - var toEl = e.relatedTarget? e.relatedTarget: e.toElement; - if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide(); - }, - - // returns true of oNode is contained by oCont (container) - contained: function(oNode, oCont) { - if (!oNode) return; // in case alt-tab away while hovering (prevent error) - while ( oNode = oNode.parentNode ) - if ( oNode == oCont ) return true; - return false; - }, - - clearTimer: function() { - if (menuLayers.timer) clearTimeout(menuLayers.timer); - } -} -
commit f38951d435424a8e601ffbf7060ed01afb7b4fde Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 14:24:07 2011 -0400
normally don't need to pass in the attrib name explicitly since the name of the field is normally the same as the attrib name
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java index 3cf8695..f17c62f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java @@ -80,6 +80,10 @@ public class TimestampCellFormatter implements CellFormatter { return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date); }
+ public static void prepareDateField(final ListGridField field) { + prepareDateField(field, field.getName()); + } + public static void prepareDateField(final ListGridField field, final String dateTimeAttributeName) { field.setCellFormatter(new TimestampCellFormatter()); field.setShowHover(true); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java index 3980125..e4e62e8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java @@ -75,11 +75,9 @@ public class ResourceErrorsView extends Table<ResourceErrorsDataSource> { ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG .dataSource_resourceErrors_field_timeOccured()); timeField.setType(ListGridFieldType.DATE); - timeField.setCellFormatter(new TimestampCellFormatter()); timeField.setAlign(Alignment.CENTER); timeField.setWidth("20%"); - timeField.setShowHover(true); - timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.TIME_OCCURED)); + TimestampCellFormatter.prepareDateField(timeField);
ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary()); summaryField.setAlign(Alignment.CENTER); 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 6955700..31732c1 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 @@ -131,7 +131,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { description = new TreeGridField("description"); status = new TreeGridField("statusLabel"); ctime = new TreeGridField("ctime"); - TimestampCellFormatter.prepareDateField(ctime, "ctime"); + TimestampCellFormatter.prepareDateField(ctime);
if (!simple) { treeGrid.setFields(name, key, type, description, status, ctime);
commit e515acc7a0c083dd3969305d095f3a5274b6c8bd Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 30 14:17:21 2011 -0400
Protect against NPE and improve hover text.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 9fde105..71a698a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -165,11 +165,17 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { statusField.setHoverCustomizer(new HoverCustomizer() { public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { String ackSubject = record.getAttribute("acknowledgingSubject"); - Date ackTime = record.getAttributeAsDate("acknowledgeTime"); - String ackTimeString = TimestampCellFormatter.format(ackTime, - TimestampCellFormatter.DATE_TIME_FORMAT_FULL); - StringBuilder sb = new StringBuilder("<p style='width:500px'>"); - sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString)); + StringBuilder sb = new StringBuilder("<p"); + if (ackSubject == null) { + sb.append(" style='width:150px'>"); + sb.append(MSG.view_alerts_field_ack_status_noAckHover()); + } else { + sb.append(" style='width:500px'>"); + Date ackTime = record.getAttributeAsDate("acknowledgeTime"); + String ackTimeString = TimestampCellFormatter.format(ackTime, + TimestampCellFormatter.DATE_TIME_FORMAT_FULL); + sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString)); + } sb.append("</p>"); return sb.toString(); } 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 7bc3ea4..ae8ccbd 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 @@ -881,6 +881,7 @@ view_alerts_field_ack_time = Acknowledge Time view_alerts_field_ack_subject = Acknowledge Subject view_alerts_field_ack_status = Status view_alerts_field_ack_status_noAck = No Ack +view_alerts_field_ack_status_noAckHover = Not yet Acknowledged view_alerts_field_ack_status_ack = Ack ({0}) view_alerts_field_ack_status_ackHover = Acknowledged by {0} at {1} view_alerts_field_name = Name
commit 4871543e3fd99c94efcb5b27f9039e25642244c3 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 14:17:01 2011 -0400
quick fix to ctime field
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java index 1c75bcc..3980125 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java @@ -22,7 +22,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.AutoFitWidthApproach; -import com.smartgwt.client.types.DateDisplayFormat; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.SelectionStyle; @@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; +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.inventory.resource.detail.summary.ResourceErrorsDataSource.Field; import org.rhq.enterprise.gui.coregui.client.util.message.Message; @@ -75,9 +75,11 @@ public class ResourceErrorsView extends Table<ResourceErrorsDataSource> { ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG .dataSource_resourceErrors_field_timeOccured()); timeField.setType(ListGridFieldType.DATE); - timeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING); + timeField.setCellFormatter(new TimestampCellFormatter()); timeField.setAlign(Alignment.CENTER); timeField.setWidth("20%"); + timeField.setShowHover(true); + timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.TIME_OCCURED));
ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary()); summaryField.setAlign(Alignment.CENTER); 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 c2b3748..6955700 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 @@ -50,6 +50,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.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.util.TableUtility; @@ -130,6 +131,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout { description = new TreeGridField("description"); status = new TreeGridField("statusLabel"); ctime = new TreeGridField("ctime"); + TimestampCellFormatter.prepareDateField(ctime, "ctime");
if (!simple) { treeGrid.setFields(name, key, type, description, status, ctime);
commit e7ec5cfe2a6da8ea2a0487e256e284cb9d03b8a8 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 14:13:20 2011 -0400
add a convienence method that prepares a list grid field as a data field, complete wiht a hover and a standard time format
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java index d8a86c7..3cf8695 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java @@ -5,6 +5,7 @@ import java.util.Date; import com.google.gwt.i18n.client.DateTimeFormat; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.HoverCustomizer; +import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord;
/** @@ -79,6 +80,12 @@ public class TimestampCellFormatter implements CellFormatter { return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date); }
+ public static void prepareDateField(final ListGridField field, final String dateTimeAttributeName) { + field.setCellFormatter(new TimestampCellFormatter()); + field.setShowHover(true); + field.setHoverCustomizer(getHoverCustomizer(dateTimeAttributeName)); + } + public static HoverCustomizer getHoverCustomizer(final String dateTimeAttributeName) { return new HoverCustomizer() {
commit 874fd083a82b0b42a39f3d1b001fed2c55312ace Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 13:50:45 2011 -0400
fix message center time
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java index b5907fd..f692f44 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java @@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow; @@ -182,6 +183,8 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis timeField.setType(ListGridFieldType.TIME); timeField.setAttribute("displayFormat", TimeFormatter.TOPADDEDTIME); timeField.setAlign(Alignment.LEFT); + timeField.setShowHover(true); + timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(FIELD_TIME));
ListGridField messageField = new ListGridField(FIELD_CONCISEMESSAGE, MSG.common_title_message());
@@ -339,7 +342,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis severity.setValue(message.severity.name());
StaticTextItem date = new StaticTextItem("time", MSG.view_messageCenter_messageTime()); - date.setValue(message.fired); + date.setValue(TimestampCellFormatter.format(message.fired, TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
StaticTextItem detail = new StaticTextItem("detail", MSG.view_messageCenter_messageDetail()); detail.setTitleVAlign(VerticalAlignment.TOP);
commit e558e9be8dd60a5e4478dc183a8fa1ba2937a8b8 Author: Ian Springer ian.springer@redhat.com Date: Wed Mar 30 13:54:12 2011 -0400
fix a bunch of group config editor bugs including https://bugzilla.redhat.com/show_bug.cgi?id=680229
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java index d991515..ac2d132 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java @@ -65,6 +65,8 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; import com.smartgwt.client.widgets.form.fields.TextAreaItem; import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.fields.events.BlurEvent; +import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; @@ -713,7 +715,6 @@ public class ConfigurationEditor extends LocatableVLayout { }
protected void firePropertyChangedEvent(Property property, PropertyDefinition propertyDefinition, boolean isValid) { - boolean wasValidBefore = this.invalidPropertyNameToDisplayNameMap.isEmpty(); PropertyDefinition topLevelPropertyDefinition = getTopLevelPropertyDefinition(propertyDefinition); boolean invalidPropertySetChanged; if (isValid) { @@ -1404,14 +1405,13 @@ public class ConfigurationEditor extends LocatableVLayout { final PropertySimple propertySimple, final FormItem valueItem) { FormItem item; if (!propertyDefinitionSimple.isRequired()) { - final CheckboxItem unsetItem = new CheckboxItem(); + final CheckboxItem unsetItem = new CheckboxItem("unset-" + valueItem.getName()); boolean unset = isUnset(propertyDefinitionSimple, propertySimple); unsetItem.setValue(unset); unsetItem.setDisabled(isReadOnly(propertyDefinitionSimple, propertySimple)); unsetItem.setShowLabel(false); unsetItem.setShowTitle(false); unsetItem.setLabelAsTitle(false); - unsetItem.setColSpan(1);
unsetItem.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent changeEvent) { @@ -1429,6 +1429,14 @@ public class ConfigurationEditor extends LocatableVLayout { } });
+ valueItem.addBlurHandler(new BlurHandler() { + public void onBlur(BlurEvent event) { + boolean isUnset = (event.getItem().getValue() == null); + unsetItem.setValue(isUnset); + valueItem.disable(); + } + }); + item = unsetItem; } else { item = new SpacerItem(); @@ -1441,7 +1449,7 @@ public class ConfigurationEditor extends LocatableVLayout { return (!propertyDefinition.isRequired() && (propertySimple == null || propertySimple.getStringValue() == null)); }
- private boolean isReadOnly(PropertyDefinition propertyDefinition, Property property) { + protected boolean isReadOnly(PropertyDefinition propertyDefinition, Property property) { if (this.readOnly) { return true; } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java index eafbd15..c7b087c 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java @@ -1,6 +1,6 @@ /* * RHQ Management Platform - * Copyright 2010, Red Hat Middleware LLC, and individual contributors + * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * @@ -65,9 +65,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; * @author Ian Springer */ public class GroupConfigurationEditor extends ConfigurationEditor { + + private static final String RHQ_STATIC_ITEM_NAME_ATTRIBUTE = "rhq:staticItemName"; + private static final String RHQ_UNSET_ITEM_NAME_ATTRIBUTE = "rhq:unsetItemName"; + private List<GroupMemberConfiguration> memberConfigurations; - private Map<String, FormItem> valueItemNameToStaticItemMap = new HashMap<String, FormItem>(); - private Map<String, FormItem> valueItemNameToUnsetItemMap = new HashMap<String, FormItem>();
public GroupConfigurationEditor(String locatorId, ConfigurationDefinition configurationDefinition, List<GroupMemberConfiguration> memberConfigurations) { @@ -94,7 +96,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
if (isAggregateProperty(propertySimple)) { // Create the "MEMBER VALUES DIFFER" label that is displayed when member values are heterogeneous. - final StaticTextItem staticItem = new StaticTextItem(); + final StaticTextItem staticItem = new StaticTextItem("static-" + propertySimple.getName()); staticItem.setValue(MSG.view_groupConfigEdit_valsDiff()); staticItem.setTextBoxStyle("InlineNote"); staticItem.setShowTitle(false); @@ -106,7 +108,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { FormItemIcon icon = buildEditMemberValuesIcon(propertyDefinitionSimple, propertySimple, valueItem); staticItem.setIcons(icon);
- this.valueItemNameToStaticItemMap.put(valueItem.getName(), staticItem); + valueItem.setAttribute(RHQ_STATIC_ITEM_NAME_ATTRIBUTE, staticItem.getName()); fields.add(3, staticItem); }
@@ -147,7 +149,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { item.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent changedEvent) { Object value = changedEvent.getValue(); - updateMemberProperties(propertyDefinitionSimple, propertySimple, value); + updateMemberProperties(propertySimple, value); } });
@@ -159,7 +161,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { }
private FormItemIcon buildEditMemberValuesIcon(final PropertyDefinitionSimple propertyDefinitionSimple, - final PropertySimple propertySimple, final FormItem dynamicItem) { + final PropertySimple propertySimple, final FormItem dynamicItem) { FormItemIcon icon = new FormItemIcon();
icon.setSrc(ImageManager.getEditIcon()); @@ -178,8 +180,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor { return icon; }
- private void updateMemberProperties(PropertyDefinitionSimple propertyDefinitionSimple, - PropertySimple propertySimple, Object value) { + private void updateMemberProperties(PropertySimple propertySimple, Object value) { for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) { Configuration configuration = memberConfiguration.getConfiguration(); PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null); @@ -196,12 +197,13 @@ public class GroupConfigurationEditor extends ConfigurationEditor { unsetItem.setValue(false); unsetItem.setDisabled(true); } - this.valueItemNameToUnsetItemMap.put(valueItem.getName(), unsetItem); + valueItem.setAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE, unsetItem.getName()); return unsetItem; }
private void displayMemberValuesEditor(String locatorId, final PropertyDefinitionSimple propertyDefinitionSimple, - final PropertySimple aggregatePropertySimple, Integer index, final FormItem aggregateValueItem) { + final PropertySimple aggregatePropertySimple, Integer index, + final FormItem aggregateValueItem) { final Window popup = new Window(); popup.setTitle(MSG.view_groupConfigEdit_valsDiffForProp(propertyDefinitionSimple.getName())); popup.setWidth(800); @@ -215,101 +217,11 @@ public class GroupConfigurationEditor extends ConfigurationEditor { layout.setHeight100(); layout.setMargin(11);
- final DynamicForm setAllForm = new DynamicForm(); - setAllForm.setNumCols(4); - setAllForm.setColWidths(175, 25, 200, 100); - setAllForm.setCellPadding(5); - - List<FormItem> setAllItems = new ArrayList<FormItem>(); - - // Header Row - SpacerItem spacerItem = new SpacerItem(); - setAllItems.add(spacerItem); - - StaticTextItem unsetAllHeader = new StaticTextItem(); - unsetAllHeader.setShowTitle(false); - if (!propertyDefinitionSimple.isRequired()) { - unsetAllHeader.setDefaultValue("<h4>" + MSG.view_groupConfigEdit_unset() + "</h4>"); - } - setAllItems.add(unsetAllHeader); - - StaticTextItem valueAllHeader = new StaticTextItem(); - valueAllHeader.setShowTitle(false); - valueAllHeader.setDefaultValue("<h4>" + MSG.common_title_value() + "</h4>"); - - setAllItems.add(valueAllHeader); - - spacerItem = new SpacerItem(); - //spacerItem.setEndRow(true); - setAllItems.add(spacerItem); - - // Input Row - StaticTextItem setAllValuesToItem = new StaticTextItem(); - setAllValuesToItem.setShowTitle(false); - setAllValuesToItem.setDefaultValue("<b>" + MSG.view_groupConfigEdit_setAll() + "</b>"); - setAllValuesToItem.setAlign(Alignment.RIGHT); - setAllItems.add(setAllValuesToItem); - - PropertySimple masterPropertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null); - final FormItem masterValueItem = super.buildSimpleField(propertyDefinitionSimple, masterPropertySimple); - masterValueItem.setDisabled(false); - - FormItem masterUnsetItem = buildUnsetItem(propertyDefinitionSimple, masterPropertySimple, masterValueItem); - if (masterUnsetItem instanceof CheckboxItem) { - masterUnsetItem.setValue(false); - } - - setAllItems.add(masterUnsetItem); - setAllItems.add(masterValueItem); - - //ButtonItem applyButtonItem = new ButtonItem(); - //applyButtonItem.setTitle("Apply"); - //applyButtonItem.setEndRow(true); - //setAllItems.add(applyButtonItem); - - // NOTE (ips, 10/27/10): Using a ButtonItem didn't work out, because SmartGWT would always display it in a new - // table row, rather than in the next column in the current row (most likely a bug). So - // we use an IButton wrapped in a CanvasItem instead. - CanvasItem canvasItem = new CanvasItem(); - canvasItem.setShowTitle(false); - HLayout buttonCanvas = new HLayout(); - buttonCanvas.setWidth(90); - buttonCanvas.setHeight100(); - buttonCanvas.setAlign(Alignment.LEFT); - final IButton applyButton = new LocatableIButton(layout.extendLocatorId("Apply"), MSG.common_button_apply()); - applyButton.setDisabled(true); - buttonCanvas.addMember(applyButton); - canvasItem.setCanvas(buttonCanvas); - canvasItem.setEndRow(true); - setAllItems.add(canvasItem); - - masterValueItem.addChangedHandler(new ChangedHandler() { - public void onChanged(ChangedEvent changedEvent) { - applyButton.enable(); - //applyButton.focus(); - } - }); - - masterUnsetItem.addChangedHandler(new ChangedHandler() { - public void onChanged(ChangedEvent changedEvent) { - applyButton.enable(); - applyButton.focus(); - } - }); - - setAllForm.setFields(setAllItems.toArray(new FormItem[setAllItems.size()])); - layout.addMember(setAllForm); - - VLayout spacerLayout = new VLayout(); - spacerLayout.setHeight(20); - layout.addMember(spacerLayout); - final DynamicForm membersForm = new DynamicForm(); membersForm.setHeight100(); membersForm.setNumCols(3); membersForm.setColWidths("52%", "8%", "40%"); membersForm.setHiliteRequiredFields(true); - layout.addMember(membersForm);
// Add header row. List<FormItem> items = new ArrayList<FormItem>(); @@ -362,57 +274,72 @@ public class GroupConfigurationEditor extends ConfigurationEditor { valueItem.setDisabled(false); }
+ // TODO: Anchor the button bar at the bottom of the modal window, so it's always visible. + HLayout buttonBar = new HLayout(); + buttonBar.setAlign(Alignment.CENTER); + buttonBar.setMembersMargin(7); + final IButton okButton = new LocatableIButton(layout.extendLocatorId("OK"), MSG.common_button_ok()); - okButton.disable(); + final boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, aggregatePropertySimple); + if (!propertyIsReadOnly) { + okButton.disable(); + } okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { public void onClick(ClickEvent clickEvent) { - boolean valuesHomogeneous = true; - boolean isValid = true; - - Object firstValue = valueItems.get(0).getValue(); - for (FormItem valueItem : valueItems) { - Object value = valueItem.getValue(); - if ((value != null && !value.equals(firstValue)) || (value == null && firstValue != null)) { - valuesHomogeneous = false; + if (!propertyIsReadOnly) { + boolean valuesHomogeneous = true; + boolean isValid = true; + + Object firstValue = valueItems.get(0).getValue(); + for (FormItem valueItem : valueItems) { + Object value = valueItem.getValue(); + if ((value != null && !value.equals(firstValue)) || (value == null && firstValue != null)) { + valuesHomogeneous = false; + } + isValid = isValid && valueItem.validate(); + PropertySimple memberPropertySimple = valueItemNameToPropertySimpleMap.get(valueItem.getName()); + memberPropertySimple.setValue(value); + memberPropertySimple.setErrorMessage(null); } - isValid = isValid && valueItem.validate(); - PropertySimple memberPropertySimple = valueItemNameToPropertySimpleMap.get(valueItem.getName()); - memberPropertySimple.setValue(value); - memberPropertySimple.setErrorMessage(null); - }
- FormItem aggregateStaticItem = valueItemNameToStaticItemMap.get(aggregateValueItem.getName()); + String aggregateStaticItemName = aggregateValueItem.getAttribute(RHQ_STATIC_ITEM_NAME_ATTRIBUTE); + FormItem aggregateStaticItem = aggregateValueItem.getForm().getField(aggregateStaticItemName);
- FormItem aggregateUnsetItem = valueItemNameToUnsetItemMap.get(aggregateValueItem.getName()); - aggregateUnsetItem.setDisabled(!valuesHomogeneous); + String aggregateUnsetItemName = aggregateValueItem.getAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE); + FormItem aggregateUnsetItem = aggregateValueItem.getForm().getField(aggregateUnsetItemName); + aggregateUnsetItem.setDisabled(!valuesHomogeneous);
- if (valuesHomogeneous) { - // Update the value of the aggregate property and set its override flag to true. - aggregatePropertySimple.setValue(firstValue); - aggregatePropertySimple.setOverride(true); + if (valuesHomogeneous) { + // Update the value of the aggregate property and set its override flag to true. + aggregatePropertySimple.setValue(firstValue); + aggregatePropertySimple.setOverride(true);
- aggregateUnsetItem.setValue(firstValue == null); + boolean isUnset = (firstValue == null); + aggregateUnsetItem.setValue(isUnset);
- // Set the aggregate value item's value to the homogeneous value, unhide it, and enable it. - setValue(aggregateValueItem, firstValue); - aggregateValueItem.show(); - aggregateValueItem.setDisabled(false); + // Set the aggregate value item's value to the homogeneous value, unhide it, and enable it + // unless it's unset. + setValue(aggregateValueItem, firstValue); + aggregateValueItem.show(); + aggregateValueItem.setDisabled(isUnset);
- aggregateStaticItem.hide(); - } else { - aggregatePropertySimple.setValue(null); - aggregatePropertySimple.setOverride(false); + aggregateStaticItem.hide(); + } else { + aggregatePropertySimple.setValue(null); + aggregatePropertySimple.setOverride(false);
- aggregateValueItem.hide(); + aggregateValueItem.hide();
- aggregateStaticItem.show(); - } + aggregateStaticItem.show(); + }
- firePropertyChangedEvent(aggregatePropertySimple, propertyDefinitionSimple, isValid); + firePropertyChangedEvent(aggregatePropertySimple, propertyDefinitionSimple, isValid); + }
popup.destroy(); } }); + buttonBar.addMember(okButton);
// Only enable the OK button if all properties are valid. membersForm.addItemChangedHandler(new ItemChangedHandler() { @@ -421,42 +348,130 @@ public class GroupConfigurationEditor extends ConfigurationEditor { } });
- applyButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - @Override - public void onClick(ClickEvent clickEvent) { - Object value = masterValueItem.getValue(); - // Update the aggregate property. - aggregatePropertySimple.setValue(value); - - // Update the member properties. - for (FormItem valueItem : valueItems) { - setValue(valueItem, value); - - FormItem unsetItem = valueItemNameToUnsetItemMap.get(valueItem.getName()); - if (unsetItem instanceof CheckboxItem) { - unsetItem.setValue((value == null)); - valueItem.setDisabled((value == null)); - } + if (!propertyIsReadOnly) { + final DynamicForm setAllForm = new DynamicForm(); + setAllForm.setNumCols(4); + setAllForm.setColWidths(175, 25, 200, 100); + setAllForm.setCellPadding(5);
- okButton.setDisabled(!membersForm.validate()); - } + List<FormItem> setAllItems = new ArrayList<FormItem>(); + + // Header Row + SpacerItem spacerItem = new SpacerItem(); + setAllItems.add(spacerItem); + + StaticTextItem unsetAllHeader = new StaticTextItem(); + unsetAllHeader.setShowTitle(false); + if (!propertyDefinitionSimple.isRequired()) { + unsetAllHeader.setDefaultValue("<h4>" + MSG.view_groupConfigEdit_unset() + "</h4>"); } - }); + setAllItems.add(unsetAllHeader);
- final IButton cancelButton = new LocatableIButton(layout.extendLocatorId("Cancel"), MSG.common_button_cancel()); - cancelButton.focus(); - cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { - public void onClick(ClickEvent clickEvent) { - popup.destroy(); + StaticTextItem valueAllHeader = new StaticTextItem(); + valueAllHeader.setShowTitle(false); + valueAllHeader.setDefaultValue("<h4>" + MSG.common_title_value() + "</h4>"); + + setAllItems.add(valueAllHeader); + + spacerItem = new SpacerItem(); + //spacerItem.setEndRow(true); + setAllItems.add(spacerItem); + + // Input Row + StaticTextItem setAllValuesToItem = new StaticTextItem(); + setAllValuesToItem.setShowTitle(false); + setAllValuesToItem.setDefaultValue("<b>" + MSG.view_groupConfigEdit_setAll() + "</b>"); + setAllValuesToItem.setAlign(Alignment.RIGHT); + setAllItems.add(setAllValuesToItem); + + PropertySimple masterPropertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null); + final FormItem masterValueItem = super.buildSimpleField(propertyDefinitionSimple, masterPropertySimple); + masterValueItem.setName("master-" + masterValueItem.getName()); + masterValueItem.setDisabled(false); + + FormItem masterUnsetItem = buildUnsetItem(propertyDefinitionSimple, masterPropertySimple, masterValueItem); + if (masterUnsetItem instanceof CheckboxItem) { + masterUnsetItem.setValue(false); } - });
- // TODO: Anchor the button bar at the bottom of the modal window, so it's always visible. - HLayout buttons = new HLayout(); - buttons.setAlign(Alignment.CENTER); - buttons.setMembersMargin(7); - buttons.setMembers(okButton, cancelButton); - layout.addMember(buttons); + setAllItems.add(masterUnsetItem); + setAllItems.add(masterValueItem); + + //ButtonItem applyButtonItem = new ButtonItem(); + //applyButtonItem.setTitle("Apply"); + //applyButtonItem.setEndRow(true); + //setAllItems.add(applyButtonItem); + + // NOTE (ips, 10/27/10): Using a ButtonItem didn't work out, because SmartGWT would always display it in a new + // table row, rather than in the next column in the current row (most likely a bug). So + // we use an IButton wrapped in a CanvasItem instead. + CanvasItem canvasItem = new CanvasItem(); + canvasItem.setShowTitle(false); + HLayout buttonCanvas = new HLayout(); + buttonCanvas.setWidth(90); + buttonCanvas.setHeight100(); + buttonCanvas.setAlign(Alignment.LEFT); + final IButton applyButton = new LocatableIButton(layout.extendLocatorId("Apply"), MSG.common_button_apply()); + applyButton.setDisabled(true); + + applyButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + @Override + public void onClick(ClickEvent clickEvent) { + Object value = masterValueItem.getValue(); + + // Update the member property value items. + for (FormItem valueItem : valueItems) { + setValue(valueItem, value); + + String unsetItemName = valueItem.getAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE); + FormItem unsetItem = valueItem.getForm().getField(unsetItemName); + if (unsetItem instanceof CheckboxItem) { + unsetItem.setValue((value == null)); + valueItem.setDisabled((value == null)); + } + + okButton.setDisabled(!membersForm.validate()); + } + } + }); + + buttonCanvas.addMember(applyButton); + canvasItem.setCanvas(buttonCanvas); + canvasItem.setEndRow(true); + setAllItems.add(canvasItem); + + masterValueItem.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent changedEvent) { + applyButton.enable(); + } + }); + + masterUnsetItem.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent changedEvent) { + applyButton.enable(); + applyButton.focus(); + } + }); + + setAllForm.setFields(setAllItems.toArray(new FormItem[setAllItems.size()])); + layout.addMember(setAllForm); + + VLayout spacerLayout = new VLayout(); + spacerLayout.setHeight(20); + layout.addMember(spacerLayout); + + final IButton cancelButton = new LocatableIButton(layout.extendLocatorId("Cancel"), MSG.common_button_cancel()); + cancelButton.focus(); + cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() { + public void onClick(ClickEvent clickEvent) { + popup.destroy(); + } + }); + buttonBar.addMember(cancelButton); + } + + layout.addMember(membersForm); + layout.addMember(buttonBar);
popup.addItem(layout); popup.show(); @@ -472,16 +487,19 @@ public class GroupConfigurationEditor extends ConfigurationEditor { @Override protected void updatePropertySimpleValue(Object value, PropertySimple propertySimple, PropertyDefinitionSimple propertyDefinitionSimple) { - // Update the aggregate property - super.updatePropertySimpleValue(value, propertySimple, propertyDefinitionSimple); - propertySimple.setOverride(true); - - // Update all the member properties. - for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) { - Configuration configuration = memberConfiguration.getConfiguration(); - PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null); - memberPropertySimple.setErrorMessage(null); - memberPropertySimple.setValue(value); + if ((propertySimple.getConfiguration() != null) || (propertySimple.getParentMap() != null) || + (propertySimple.getParentList() != null)) { + // Update the aggregate property. + super.updatePropertySimpleValue(value, propertySimple, propertyDefinitionSimple); + propertySimple.setOverride(true); + + // Update all the member properties. + for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) { + Configuration configuration = memberConfiguration.getConfiguration(); + PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null); + memberPropertySimple.setErrorMessage(null); + memberPropertySimple.setValue(value); + } } }
@@ -564,4 +582,5 @@ public class GroupConfigurationEditor extends ConfigurationEditor { Property topLevelProperty = getTopLevelProperty(property); return topLevelProperty.getConfiguration(); } + }
commit eca868ae89eed3a67cc0ea5fee4a7d0974a233a3 Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 30 12:45:20 2011 -0400
AlertHistoryView fixes - fix bad link for create time field to alert detail - consolidate timestamp formats for the createTime and status columns, shortening value but adding verbose hover. - replace "Ack" with "Acknowledge" where width is not an issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index d9d1eda..9fde105 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -111,6 +111,8 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { ListGridField ctimeField = new ListGridField(AlertCriteria.SORT_FIELD_CTIME, MSG .view_alerts_field_created_time()); ctimeField.setCellFormatter(new TimestampCellFormatter()); + ctimeField.setShowHover(true); + ctimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(AlertCriteria.SORT_FIELD_CTIME)); fields.add(ctimeField);
ListGridField nameField = new ListGridField("name", MSG.view_alerts_field_name()); @@ -153,14 +155,25 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { public String format(Object o, ListGridRecord listGridRecord, int i, int i1) { String ackSubject = listGridRecord.getAttribute("acknowledgingSubject"); if (ackSubject == null) { - return MSG.view_alerts_field_ack_status_empty(); + return MSG.view_alerts_field_ack_status_noAck(); } else { - Date ackTime = listGridRecord.getAttributeAsDate("acknowledgeTime"); - String formattedTime = TimestampCellFormatter.format(ackTime); - return MSG.view_alerts_field_ack_status_filled(ackSubject, formattedTime); + return MSG.view_alerts_field_ack_status_ack(ackSubject); } } }); + statusField.setShowHover(true); + statusField.setHoverCustomizer(new HoverCustomizer() { + public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { + String ackSubject = record.getAttribute("acknowledgingSubject"); + Date ackTime = record.getAttributeAsDate("acknowledgeTime"); + String ackTimeString = TimestampCellFormatter.format(ackTime, + TimestampCellFormatter.DATE_TIME_FORMAT_FULL); + StringBuilder sb = new StringBuilder("<p style='width:500px'>"); + sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString)); + sb.append("</p>"); + return sb.toString(); + } + }); fields.add(statusField);
if (this.entityContext.type != EntityContext.Type.Resource) { @@ -184,17 +197,17 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { ListGridField ancestryField = AncestryUtil.setupAncestryListGridField(); fields.add(ancestryField);
- ctimeField.setWidth(125); - nameField.setWidth("20%"); - conditionField.setWidth("30%"); + ctimeField.setWidth(100); + nameField.setWidth("15%"); + conditionField.setWidth("35%"); priorityField.setWidth(50); - statusField.setWidth("80"); + statusField.setWidth(100); resourceNameField.setWidth("25%"); ancestryField.setWidth("25%"); } else { - ctimeField.setWidth(125); - nameField.setWidth("35%"); - conditionField.setWidth("40%"); + ctimeField.setWidth(200); + nameField.setWidth("15%"); + conditionField.setWidth("60%"); priorityField.setWidth(50); statusField.setWidth("25%"); } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java index 49b2484..14cfc8a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java @@ -161,7 +161,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi if (record.getAttribute("acknowledgingSubject") != null) { ackByItem.setValue(record.getAttribute("acknowledgingSubject")); } else { - ackByItem.setValue(MSG.view_alerts_field_ack_status_empty()); + ackByItem.setValue(MSG.view_alerts_field_ack_status_noAck()); } items.add(ackByItem);
@@ -170,7 +170,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi if (ack_time != null) { ackTimeItem.setValue(TimestampCellFormatter.format(ack_time)); } else { - ackTimeItem.setValue(MSG.view_alerts_field_ack_status_empty()); + ackTimeItem.setValue(MSG.view_alerts_field_ack_status_noAck()); } items.add(ackTimeItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java index f5fd917..e321819 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java @@ -29,6 +29,7 @@ import com.smartgwt.client.types.MultipleAppearance; import com.smartgwt.client.types.SortDirection; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -38,13 +39,17 @@ import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.criteria.AlertCriteria; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement; import org.rhq.enterprise.gui.coregui.client.components.table.TableSection; +import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter; import org.rhq.enterprise.gui.coregui.client.components.view.ViewName; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert alert}s, along with the @@ -131,6 +136,19 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { return AlertCriteria.SORT_FIELD_CTIME; }
+ @Override + protected CellFormatter getDetailsLinkColumnCellFormatter() { + return new CellFormatter() { + public String format(Object value, ListGridRecord record, int i, int i1) { + Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID); + Integer alertHistoryId = getId(record); + String url = LinkManager.getSubsystemAlertHistoryLink(resourceId, alertHistoryId); + String formattedValue = TimestampCellFormatter.format(value); + return SeleniumUtility.getLocatableHref(url, formattedValue, null); + } + }; + } + protected void setupTableInteractions(final boolean hasWriteAccess) { TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY : TableActionEnablement.NEVER; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java index b08c0ee..d8a86c7 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java @@ -4,6 +4,7 @@ import java.util.Date;
import com.google.gwt.i18n.client.DateTimeFormat; import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.HoverCustomizer; import com.smartgwt.client.widgets.grid.ListGridRecord;
/** @@ -12,10 +13,36 @@ import com.smartgwt.client.widgets.grid.ListGridRecord; * @author Ian Springer */ public class TimestampCellFormatter implements CellFormatter { - public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getMediumDateTimeFormat(); + + public static final DateTimeFormat DATE_TIME_FORMAT_FULL = DateTimeFormat.getFullDateTimeFormat(); + public static final DateTimeFormat DATE_TIME_FORMAT_LONG = DateTimeFormat.getLongDateTimeFormat(); + public static final DateTimeFormat DATE_TIME_FORMAT_MEDIUM = DateTimeFormat.getMediumDateTimeFormat(); + public static final DateTimeFormat DATE_TIME_FORMAT_SHORT = DateTimeFormat.getShortDateTimeFormat(); + + private DateTimeFormat dateTimeFormat; + + /** + * Uses SHORT format. + */ + public TimestampCellFormatter() { + this(DATE_TIME_FORMAT_MEDIUM); + } + + public TimestampCellFormatter(DateTimeFormat dateTimeFormat) { + super(); + this.dateTimeFormat = dateTimeFormat; + }
public String format(Object value, ListGridRecord record, int rowNum, int colNum) { - return format(value); + return format(value, dateTimeFormat); + } + + /** + * @param value + * @return SHORT format for value + */ + public static String format(Object value) { + return format(value, DATE_TIME_FORMAT_MEDIUM); }
/** @@ -24,10 +51,11 @@ public class TimestampCellFormatter implements CellFormatter { * consistent across the app, whether the data is in a cell or not. * * @param value the date to format as a Date, Long, Integer or a String + * @param dateTimeFormat the format to use. If null defaults to SHORT format * * @return the formatted date string */ - public static String format(Object value) { + public static String format(Object value, DateTimeFormat dateTimeFormat) { if (value == null) { return ""; } @@ -47,6 +75,19 @@ public class TimestampCellFormatter implements CellFormatter { } date = new Date(longValue); } - return DATE_TIME_FORMAT.format(date); + + return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date); + } + + public static HoverCustomizer getHoverCustomizer(final String dateTimeAttributeName) { + return new HoverCustomizer() { + + public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) { + StringBuilder sb = new StringBuilder("<p style='width:300px'>"); + sb.append(format(record.getAttributeAsDate(dateTimeAttributeName), DATE_TIME_FORMAT_FULL)); + sb.append("</p>"); + return sb.toString(); + } + }; } } 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 a965934..7bc3ea4 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 @@ -13,8 +13,8 @@ common_buildInfo_gwtVersion = ${gwt.version}
# Button Labels #-------------- -common_button_ack = Ack -common_button_ack_all = Ack All +common_button_ack = Acknowlege +common_button_ack_all = Acknowledge All common_button_add = Add common_button_advanced = Advanced... common_button_apply = Apply @@ -877,11 +877,12 @@ view_alerts_table_filter_priority = Priority Filter view_alerts_field_created_time = Creation Time view_alerts_field_modified_time = Modified Time view_alerts_field_enabled = Enabled -view_alerts_field_ack_time = Ack Time -view_alerts_field_ack_subject = Ack Subject +view_alerts_field_ack_time = Acknowledge Time +view_alerts_field_ack_subject = Acknowledge Subject view_alerts_field_ack_status = Status -view_alerts_field_ack_status_empty = Not Acknowledged -view_alerts_field_ack_status_filled = {0} acknowledged on {1} +view_alerts_field_ack_status_noAck = No Ack +view_alerts_field_ack_status_ack = Ack ({0}) +view_alerts_field_ack_status_ackHover = Acknowledged by {0} at {1} view_alerts_field_name = Name view_alerts_field_condition_text = Condition Text view_alerts_field_condition_text_none = No Conditions @@ -897,8 +898,8 @@ view_alerts_delete_confirm_all = Delete all alerts from this source? view_alerts_delete_success = Successfully deleted {0} alerts view_alerts_delete_failure = Failed to delete alerts with id''s: {0} view_alerts_delete_failure_all = Failed to delete all alerts from this source -view_alerts_ack_confirm = Ack the selected alert(s)? -view_alerts_ack_confirm_all = Ack all alerts from this source? +view_alerts_ack_confirm = Acknowledge the selected alert(s)? +view_alerts_ack_confirm_all = Acknowledge all alerts from this source? view_alerts_ack_success = Successfully acknowledged {0} alerts view_alerts_ack_failure = Failed to acknowledge alerts with id''s: {0} view_alerts_ack_failure_all = Failed to acknowledge all alerts from this source
commit fe0030c1b3965b1a45e6374e40de3e243ea9af74 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 09:55:29 2011 -0400
fix selenium locator conflicts
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java index 36e2ff8..c84223e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java @@ -113,14 +113,15 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView {
Tab tab;
- BundlesListView bundlesView = new BundlesListView(getLocatorId(), criteria, null); + BundlesListView bundlesView = new BundlesListView(extendLocatorId("bundleListView"), criteria, null); viewsWithTags.add(bundlesView); tab = new LocatableTab(extendLocatorId("bundleList"), MSG.view_bundle_bundles()); tab.setIcon(ImageManager.getBundleIcon()); tab.setPane(bundlesView); container.addTab(tab);
- BundleVersionListView bundleVersionListView = new BundleVersionListView(getLocatorId(), criteria); + BundleVersionListView bundleVersionListView = new BundleVersionListView( + extendLocatorId("bundleVersionListView"), criteria); viewsWithTags.add(bundleVersionListView); tab = new LocatableTab(extendLocatorId("bundleVersionList"), MSG.view_bundle_bundleVersions()); tab.setIcon("subsystems/bundle/BundleVersion_16.png"); @@ -128,23 +129,23 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { container.addTab(tab);
// TODO: get manage_bundle perm, if user has it pass true - BundleDeploymentListView bundleDeploymentListView = new BundleDeploymentListView(getLocatorId(), criteria, - false); + BundleDeploymentListView bundleDeploymentListView = new BundleDeploymentListView( + extendLocatorId("bundleDeploymentListView"), criteria, false); viewsWithTags.add(bundleDeploymentListView); tab = new LocatableTab(extendLocatorId("bundleDeploymentsList"), MSG.view_bundle_bundleDeployments()); tab.setIcon("subsystems/bundle/BundleDeployment_16.png"); tab.setPane(bundleDeploymentListView); container.addTab(tab);
- BundleDestinationListView bundleDestinationListView = new BundleDestinationListView(getLocatorId(), - criteria); + BundleDestinationListView bundleDestinationListView = new BundleDestinationListView( + extendLocatorId("bundleDestinationListView"), criteria); viewsWithTags.add(bundleDestinationListView); tab = new LocatableTab(extendLocatorId("bundleDestinationsList"), MSG.view_bundle_bundleDestinations()); tab.setIcon("subsystems/bundle/BundleDestination_16.png"); tab.setPane(bundleDestinationListView); container.addTab(tab);
- ResourceSearchView resourceView = new ResourceSearchView(getLocatorId(), criteria, MSG + ResourceSearchView resourceView = new ResourceSearchView(extendLocatorId("resourceView"), criteria, MSG .view_taggedResources_title()); viewsWithTags.add(resourceView); tab = new LocatableTab(extendLocatorId("resourceList"), MSG.view_taggedResources_title());
commit ccbc787a51ecd53ab364e43046b8b4f49147c81d Author: Jay Shaughnessy jshaughn@redhat.com Date: Wed Mar 30 09:27:30 2011 -0400
Fix several issues in Alerts Portlets - refactor to share a common abstract base class to simplify the concrete classes and conslidate fixes. - Fixed issue causing retrieval of all alerts - Fixed issue with ordering of alerts - Fixed issues with button enablement (affected resource alert history view as well) - Removed some obsolete classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java index 3e51b24..d9d1eda 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java @@ -225,56 +225,61 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> { long fetchTime = System.currentTimeMillis() - start; Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- if (entityContext.type != EntityContext.Type.Resource) { - dataRetrieved(result, response, request); - } else { - response.setData(buildRecords(result)); - response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set - processResponse(request.getRequestId(), response); - } + dataRetrieved(result, response, request); + processResponse(request.getRequestId(), response); } }); }
/** - * Additional processing to support a cross-resource view) - * @param result - * @param response - * @param request + * Additional processing to support entity-specific or cross-resource views, and something that can be overidden. */ protected void dataRetrieved(final PageList<Alert> result, final DSResponse response, final DSRequest request) { - HashSet<Integer> typesSet = new HashSet<Integer>(); - HashSet<String> ancestries = new HashSet<String>(); - for (Alert alert : result) { - Resource resource = alert.getAlertDefinition().getResource(); - typesSet.add(resource.getResourceType().getId()); - ancestries.add(resource.getAncestry()); - } - - // In addition to the types of the result resources, get the types of their ancestry - typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); + switch (entityContext.type) { + + // no need to disambiguate, the alerts are for a singe resource + case Resource: + response.setData(buildRecords(result)); + // for paging to work we have to specify size of full result set + response.setTotalRows(result.getTotalSize()); + break; + + // disambiguate as the results could be cross-resource + default: + HashSet<Integer> typesSet = new HashSet<Integer>(); + HashSet<String> ancestries = new HashSet<String>(); + for (Alert alert : result) { + Resource resource = alert.getAlertDefinition().getResource(); + typesSet.add(resource.getResourceType().getId()); + ancestries.add(resource.getAncestry()); + }
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance(); - typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { - @Override - public void onTypesLoaded(Map<Integer, ResourceType> types) { - // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. - AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types); - - Record[] records = buildRecords(result); - for (Record record : records) { - // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. - // Store the types map off the records so we can build a detailed hover string as needed. - record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); - - // Build the decoded ancestry Strings now for display - record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); + // In addition to the types of the result resources, get the types of their ancestry + typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); + + ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance(); + typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() { + @Override + public void onTypesLoaded(Map<Integer, ResourceType> types) { + // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo. + AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types); + + Record[] records = buildRecords(result); + for (Record record : records) { + // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text. + // Store the types map off the records so we can build a detailed hover string as needed. + record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper); + + // Build the decoded ancestry Strings now for display + record + .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record)); + } + response.setData(records); + // for paging to work we have to specify size of full result set + response.setTotalRows(result.getTotalSize()); } - response.setData(records); - response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set - processResponse(request.getRequestId(), response); - } - }); + }); + } }
@Override diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java index 98e4b34..f5fd917 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java @@ -67,18 +67,31 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { SortDirection.DESCENDING); EntityContext context; boolean hasWriteAccess; + AlertDataSource dataSource;
// for subsystem views public AlertHistoryView(String locatorId) { this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(), false); }
+ public AlertHistoryView(String locatorId, EntityContext entityContext) { + this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false); + } + protected AlertHistoryView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) { super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER }); this.context = context; this.hasWriteAccess = hasWriteAccess;
- setDataSource(new AlertDataSource(context)); + setDataSource(getDataSource()); + } + + @Override + public AlertDataSource getDataSource() { + if (null == this.dataSource) { + this.dataSource = new AlertDataSource(context); + } + return this.dataSource; }
@Override @@ -128,28 +141,28 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { delete(selection); } }); + addTableAction("AcknowledgeAlert", MSG.common_button_ack(), MSG.view_alerts_ack_confirm(), + new AbstractTableAction(singleTargetEnablement) { + public void executeAction(ListGridRecord[] selection, Object actionValue) { + acknowledge(selection); + } + }); addTableAction("DeleteAll", MSG.common_button_delete_all(), MSG.view_alerts_delete_confirm_all(), new TableAction() { public boolean isEnabled(ListGridRecord[] selection) { ListGrid grid = getListGrid(); - return (hasWriteAccess && grid != null && (getListGrid().getRecords().length >= 1)); + return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty()); }
public void executeAction(ListGridRecord[] selection, Object actionValue) { deleteAll(); } }); - addTableAction("AcknowledgeAlert", MSG.common_button_ack(), MSG.view_alerts_ack_confirm(), - new AbstractTableAction(singleTargetEnablement) { - public void executeAction(ListGridRecord[] selection, Object actionValue) { - acknowledge(selection); - } - }); addTableAction("AcknowledgeAll", MSG.common_button_ack_all(), MSG.view_alerts_ack_confirm_all(), new TableAction() { public boolean isEnabled(ListGridRecord[] selection) { ListGrid grid = getListGrid(); - return (hasWriteAccess && grid != null && (grid.getRecords().length >= 1)); + return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty()); }
public void executeAction(ListGridRecord[] selection, Object actionValue) { @@ -234,4 +247,7 @@ public class AlertHistoryView extends TableSection<AlertDataSource> { return AlertDetailsView.getInstance(); }
+ public EntityContext getContext() { + return context; + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java index 2cb7f74..db1e4ef 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java @@ -41,7 +41,6 @@ import org.rhq.core.domain.util.PageOrdering; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet; import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** Customize the AlertDataSource to pull fetch criteria information from @@ -221,8 +220,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource { }
public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) { - PropertyList propertyList = storedPortlet.getConfiguration().getList( - RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS); + PropertyList propertyList = storedPortlet.getConfiguration().getList("alert-range-resource-ids"); if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty()) && (propertyList.getList().get(0) != null)) { Property container = propertyList.getList().get(0); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java deleted file mode 100644 index a2d0aba..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.rhq.enterprise.gui.coregui.client.alert; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DSResponse; -import com.smartgwt.client.rpc.RPCResponse; - -import org.rhq.core.domain.alert.Alert; -import org.rhq.core.domain.alert.AlertPriority; -import org.rhq.core.domain.configuration.Property; -import org.rhq.core.domain.configuration.PropertyList; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.criteria.AlertCriteria; -import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.core.domain.util.PageControl; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet; - -public class AlertPortletDataSource extends AlertDataSource { - //configuration attributes - private int alertRangeCompleted = -1; - private int alertPriorityIndex = -1; - private long alertTimeRange = -1; - private String alertResourcesToUse = "all"; - private Integer[] alertFilterResourceIds = {}; - private DashboardPortlet portlet = null; - - public AlertPortletDataSource() { - super(); - } - - public AlertPortletDataSource(DashboardPortlet recentAlertsPortlet) { - super(); - this.portlet = recentAlertsPortlet; - } - - @Override - protected AlertCriteria getFetchCriteria(DSRequest request) { - //retrieve previous settings from portlet config - if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) { - //must check for whether portlet config - PropertySimple property = portlet.getConfiguration().getSimple( - RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE); - if ((property != null) && (property.getStringValue() != null)) { - //retrieve and translate to int - String retrieved = property.getStringValue(); - if (retrieved.trim().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) { - setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_SELECTED); - } else { - setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL); - } - //if 'selected' then check for previously set resource ids to filter on - if (getAlertResourcesToUse().equals(RecentAlertsPortlet.RESOURCES_SELECTED)) { - Integer[] alertResourceFilterIds = null; - alertResourceFilterIds = extractFilterResourceIds(portlet, alertResourceFilterIds); - if (alertFilterResourceIds != null) { - setAlertFilterResourceId(alertFilterResourceIds); - } - } - } else {//create setting - portlet.getConfiguration().put( - new PropertySimple(RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE, - RecentAlertsPortlet.defaultResourceValue)); - setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL); - } - } - - AlertCriteria criteria = new AlertCriteria(); - criteria.fetchAlertDefinition(true); - criteria.fetchRecoveryAlertDefinition(true); - // TODO: Uncomment the below once the bad performance of it has been fixed. - //criteria.fetchConditionLogs(true); - PageControl pc = new PageControl(0, getAlertRangeCompleted()); - criteria.setPageControl(pc);//display per page - criteria.addFilterStartTime(getAlertTimeRange());//alert age - if ((getAlertResourcesToUse().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) - && (getAlertFilterResourceIds().length > 0)) { - //add resource ids to filter on - criteria.addFilterResourceIds(getAlertFilterResourceIds()); - } - if (getAlertPriorityIndex() > 0) {//add priority selection - criteria.addFilterPriorities(AlertPriority.getByLegacyIndex(getAlertPriorityIndex())); - } - - return criteria; - } - - /** Override the executeFetch for AlertPortlet to allow specifying smaller than total - * result displays. - */ - @Override - protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) { - getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { - - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_alerts_loadFailed(), caught); - response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(request.getRequestId(), response); - } - - public void onSuccess(PageList<Alert> result) { - dataRetrieved(result, response, request); - } - }); - } - - public int getAlertRangeCompleted() { - return alertRangeCompleted; - } - - public void setAlertRangeCompleted(int alertRangeCompleted) { - this.alertRangeCompleted = alertRangeCompleted; - } - - public int getAlertPriorityIndex() { - return alertPriorityIndex; - } - - public void setAlertPriorityIndex(int alertPriorityIndex) { - this.alertPriorityIndex = alertPriorityIndex; - } - - public long getAlertTimeRange() { - return alertTimeRange; - } - - public void setAlertTimeRange(long alertTimeRange) { - this.alertTimeRange = alertTimeRange; - } - - public String getAlertResourcesToUse() { - return alertResourcesToUse; - } - - public void setAlertResourcesToUse(String resourcesToUse) { - this.alertResourcesToUse = resourcesToUse; - } - - public Integer[] getAlertFilterResourceIds() { - return alertFilterResourceIds; - } - - public void setAlertFilterResourceId(Integer[] alertFilterResourceId) { - this.alertFilterResourceIds = alertFilterResourceId; - } - - public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) { - PropertyList propertyList = storedPortlet.getConfiguration().getList( - RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS); - if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty()) - && (propertyList.getList().get(0) != null)) { - Property container = propertyList.getList().get(0); - if (container instanceof PropertyList) { - PropertyList anotherList = (PropertyList) container; - if (anotherList.getList() != null) { - filterResourceIds = new Integer[anotherList.getList().size()]; - int index = 0; - for (Property p : anotherList.getList()) { - filterResourceIds[index++] = ((PropertySimple) p).getIntegerValue(); - } - } - } - } - return filterResourceIds; - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java index 4c19ac1..ba91415 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java @@ -889,4 +889,13 @@ public class DashboardView extends LocatableVLayout { public Dashboard getStoredDashboard() { return storedDashboard; } + + public ResourceGroupComposite getGroupComposite() { + return groupComposite; + } + + public ResourceComposite getResourceComposite() { + return resourceComposite; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java index 75710a8..e8d51d1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java @@ -41,6 +41,7 @@ import com.smartgwt.client.widgets.events.MouseOverHandler;
import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.resource.composite.ResourcePermission; import org.rhq.enterprise.gui.coregui.client.components.table.Table; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHeaderControl; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow; @@ -246,4 +247,17 @@ public class PortletWindow extends LocatableWindow { return dashboardView.getGlobalPermissions(); }
+ public ResourcePermission getResourcePermissions() { + + ResourcePermission result = null; + + if (null != dashboardView.getResourceComposite()) { + result = dashboardView.getResourceComposite().getResourcePermission(); + } else if (null != dashboardView.getGroupComposite()) { + result = dashboardView.getGroupComposite().getResourcePermission(); + } + + return result; + } + } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java index 6ac9afe..337989b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java @@ -18,363 +18,63 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
-import java.util.HashMap; -import java.util.Set; - import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Timer; -import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.HTMLFlow; -import com.smartgwt.client.widgets.events.DoubleClickEvent; -import com.smartgwt.client.widgets.events.DoubleClickHandler; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; -import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; -import com.smartgwt.client.widgets.form.fields.SelectItem; -import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView; -import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource; -import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; -import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; +import org.rhq.core.domain.common.EntityContext; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; -import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector; -import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.AbstractRecentAlertsPortlet;
/** + * @author Jay Shaughnessy * @author Simeon Pinder */ -public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet { +public class GroupAlertsPortlet extends AbstractRecentAlertsPortlet {
// A non-displayed, persisted identifier for the portlet public static final String KEY = "GroupAlerts"; // A default displayed, persisted name for the portlet public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
- public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value"; - public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids"; - public static final String RESOURCES_ALL = MSG.common_label_all_resources(); - public static final String RESOURCES_SELECTED = MSG.common_label_selected_resources(); - public static final String defaultResourceValue = RESOURCES_ALL; - public static final String ID = "id"; - private boolean currentlyRefreshing = false; - - // set on initial configuration, the window for this portlet view. - protected PortletWindow portletWindow; - - //shared private UI elements - protected AlertResourceSelectorRegion resourceSelector; - - protected AlertPortletConfigurationDataSource dataSource; - //instance ui widgets - protected Canvas containerCanvas; - - protected Timer refreshTimer; - protected DashboardPortlet storedPortlet; - protected Configuration portletConfig; private int groupId; - protected boolean portletConfigInitialized = false;
- protected static HashMap<String, String> updatedMapping = new HashMap<String, String>(); - static { - updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION); - //Key, default - updatedMapping.put(ALERT_RANGE_RESOURCES_VALUE, RESOURCES_ALL); - updatedMapping.put(ALERT_RANGE_RESOURCE_IDS, RESOURCES_ALL); - } + public GroupAlertsPortlet(String locatorId, int groupId) {
- public GroupAlertsPortlet(String locatorId) { - super(locatorId); + // Since the group id is only used for filtering I don't think it matters whether this is a + // standard group, autogroup, or autocluster, but if so, we'll have to provide more specific + // contexts and more specific context handling. + super(locatorId, EntityContext.forGroup(groupId));
- //override the shared datasource - //figure out which page we're loading - String currentPage = History.getToken(); - //get groupId - int groupId = AbstractActivityView.groupIdLookup(currentPage); this.groupId = groupId; - - setShowFilterForm(false); //disable filter form for portlet - setOverflow(Overflow.VISIBLE); - } - - /**Defines layout for the portlet page. - */ - protected void initializeUi() { - //initalize the datasource - this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null); - setDataSource(this.dataSource); - - setShowHeader(false); - setShowFooter(true); - setShowFooterRefresh(false); //disable footer refresh - - getListGrid().setEmptyMessage(MSG.view_portlet_results_empty()); - } - - /** Responsible for initialization and lazy configuration of the portlet values - */ - public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - //populate portlet configuration details - if (null == this.portletWindow && null != portletWindow) { - this.portletWindow = portletWindow; - } - - if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { - return; - } - this.storedPortlet = storedPortlet; - portletConfig = storedPortlet.getConfiguration(); - - if (!portletConfigInitialized) { - this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, this.groupId, null); - setDataSource(this.dataSource); - portletConfigInitialized = true; - } - - //lazy init any elements not yet configured. - for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { - if (portletConfig.getSimple(key) == null) { - portletConfig.put(new PropertySimple(key, - PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key))); - } - } - - //resource ids to be conditionally included in the query - Integer[] filterResourceIds = null; - filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds); - //no defaults - - if (filterResourceIds != null) { - getDataSource().setAlertFilterResourceId(filterResourceIds); - } - - //conditionally display the selected resources ui - if (containerCanvas != null) { - //empty out earlier canvas - for (Canvas c : containerCanvas.getChildren()) { - c.destroy(); - } - if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) { - containerCanvas.addChild(resourceSelector.getCanvas()); - } else { - containerCanvas.addChild(new Canvas()); - } - } - - } - - public Canvas getHelpCanvas() { - return new HTMLFlow(MSG.view_portlet_help_recentAlerts()); - } - - @Override - public DynamicForm getCustomSettingsForm() { - LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings")); - LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page")); - //build editor form container - final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter")); - form.setMargin(5); - - //add label about what configuration affects - - //add alert priority selector - final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent - .getAlertPriorityEditor(portletConfig); - //add sort priority selector - // final SelectItem resultSortSelector = PortletConfigurationEditorComponent - // .getResulSortOrderEditor(portletConfig); - //add result count selector - final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig); - - //add range selector - final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent - .getMeasurementRangeEditor(portletConfig); - - form.setItems(alertPrioritySelector, resultCountSelector); - - //submit handler - customSettings.addSubmitValuesHandler(new SubmitValuesHandler() { - - @Override - public void onSubmitValues(SubmitValuesEvent event) { - //alert severity - portletConfig = AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig); - - // //result sort order - // selectedValue = resultSortSelector.getValue().toString(); - // if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc - // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC)); - // } else { - // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC)); - // } - //result count - portletConfig = AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig); - - //time range settings - portletConfig = AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor, - portletConfig); - - //persist and reload portlet - storedPortlet.setConfiguration(portletConfig); - configure(portletWindow, storedPortlet); - refresh(); - } - }); - form.markForRedraw(); - page.addMember(measurementRangeEditor); - page.addMember(form); - customSettings.addChild(page); - return customSettings; }
- public AlertPortletConfigurationDataSource getDataSource() { - return dataSource; + public int getResourceId() { + return groupId; }
public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc) + * TODO: This factory ASSUMES the user is currently navigated to a group detail view, and generates a portlet + * for that group. It will fail in other scenarios. This mechanism should be improved such that the + * factory method can take an EntityContext explicitly indicating, in this case, the group. + * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String) + */ public final Portlet getInstance(String locatorId) {
- return new GroupAlertsPortlet(locatorId); - } - } - - public void startRefreshCycle() { - refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); - } - - @Override - protected void onDestroy() { - AutoRefreshPortletUtil.onDestroy(this, refreshTimer); - - super.onDestroy(); - } - - public boolean isRefreshing() { - return this.currentlyRefreshing; - } - - @Override - protected void setupTableInteractions(boolean hasWriteAccess) { - // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for - // the user. This means the user can have varying permissions on the underlying groups and/or resources, - // which makes button enablement tricky. So, for the portlet don't even show the buttons unless the user - // is inventory manager. Other users will just have to navigate to the alert in question in order to - // manipulate it. - - //determine if the user is inventory manager and if so render the buttons - Set<Permission> permissions = this.portletWindow.getGlobalPermissions(); - if ((null != permissions) && permissions.contains(Permission.MANAGE_INVENTORY)) { - super.setupTableInteractions(true); - } - } - - protected CellFormatter getDetailsLinkColumnCellFormatter() { - return new CellFormatter() { - public String format(Object value, ListGridRecord record, int i, int i1) { - Integer recordId = getId(record); - Integer resourceId = record.getAttributeAsInt("resourceId"); - String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId); - return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null); - } - }; - } - - @Override - protected void configureTable() { - super.configureTable(); - - setListGridDoubleClickHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - ListGrid listGrid = (ListGrid) event.getSource(); - ListGridRecord[] selectedRows = listGrid.getSelection(); - if (selectedRows != null && selectedRows.length == 1) { - Integer recordId = getId(selectedRows[0]); - Integer resourceId = selectedRows[0].getAttributeAsInt("resourceId"); - CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId)); - } + String currentPage = History.getToken(); + int groupId = -1; + String[] elements = currentPage.split("/"); + // process for groups and auto groups Ex. ResourceGroup/10111 or ResourceGroup/AutoCluster/10321 + try { + groupId = Integer.valueOf(elements[1]); + } catch (NumberFormatException nfe) { + groupId = Integer.valueOf(elements[2]); } - }); - } - - @Override - protected void onInit() { - super.onInit(); - initializeUi(); - } - - @Override - protected void refreshTableInfo() { - super.refreshTableInfo(); - if (getTableInfo() != null) { - int count = getListGrid().getSelection().length; - getTableInfo().setContents( - MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()), String.valueOf(count))); - } - } - - @Override - public void redraw() { - super.redraw(); - refresh();//is table so need to call this to reload - } -} - -/** Bundles a ResourceSelector instance with labeling in Canvas for display. - * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly. - */ -//class AlertResourceSelectorRegion extends LocatableVLayout { -final class AlertResourceSelectorRegion extends LocatableVLayout { - public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) { - super(locatorId); - this.currentlyAssignedIds = assigned; - } - - private PortletAlertSelector selector = null; - - private Integer[] currentlyAssignedIds; - - public Integer[] getCurrentlyAssignedIds() { - return currentlyAssignedIds; - }
- public Integer[] getListGridValues() { - Integer[] listGridValues = new Integer[0]; - if (null != selector) { - listGridValues = selector.getAssignedListGridValues(); + return new GroupAlertsPortlet(locatorId, groupId); } - return listGridValues; }
- public Canvas getCanvas() { - if (selector == null) { - selector = new PortletAlertSelector(extendLocatorId("AlertSelector"), this.currentlyAssignedIds, - ResourceType.ANY_PLATFORM_TYPE, false); - } - return selector; - } - - public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { - this.currentlyAssignedIds = currentlyAssignedIds; - } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java deleted file mode 100644 index 2a2b3ac..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups; - -import java.util.List; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.HTMLFlow; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; -import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; -import com.smartgwt.client.widgets.form.fields.CheckboxItem; -import com.smartgwt.client.widgets.form.fields.FormItem; -import com.smartgwt.client.widgets.form.fields.LinkItem; -import com.smartgwt.client.widgets.form.fields.SelectItem; -import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.layout.VLayout; - -import org.rhq.core.domain.alert.Alert; -import org.rhq.core.domain.alert.AlertPriority; -import org.rhq.core.domain.configuration.Configuration; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.criteria.AlertCriteria; -import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.core.domain.util.PageControl; -import org.rhq.core.domain.util.PageList; -import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.ImageManager; -import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; -import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; -import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; -import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView; -import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator; -import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; - -/**This portlet allows the end user to customize the: - * i)range - * ii)priority - * iii)etc. - * of alerts to display for the given group - * - * @author Simeon Pinder - */ -public class GroupAlertsPortlet3 extends LocatableVLayout implements CustomSettingsPortlet, AutoRefreshPortlet { - private int groupId = -1; - protected LocatableCanvas recentAlertsContent = new LocatableCanvas(extendLocatorId("RecentAlerts")); - private static AlertGWTServiceAsync alertService = GWTServiceLookup.getAlertService(); - private boolean currentlyLoading = false; - private Configuration portletConfig = null; - private DashboardPortlet storedPortlet; - - public GroupAlertsPortlet3(String locatorId) { - super(locatorId); - //figure out which page we're loading - String currentPage = History.getToken(); - String[] elements = currentPage.split("/"); - int currentGroupIdentifier = Integer.valueOf(elements[1]); - this.groupId = currentGroupIdentifier; - initializeUi(); - } - - @Override - protected void onInit() { - super.onInit(); - loadData(); - } - - /**Defines layout for the Activity page. - */ - protected void initializeUi() { - setPadding(5); - setMembersMargin(5); - addMember(recentAlertsContent); - } - - // A non-displayed, persisted identifier for the portlet - public static final String KEY = "GroupAlerts"; - // A default displayed, persisted name for the portlet - public static final String NAME = "Group: Alerts"; - public static final String ID = "id"; - - // set on initial configuration, the window for this portlet view. - private PortletWindow portletWindow; - //instance ui widgets - - private Timer refreshTimer; - - /** Responsible for initialization and lazy configuration of the portlet values - */ - public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - //populate portlet configuration details - if (null == this.portletWindow && null != portletWindow) { - this.portletWindow = portletWindow; - } - - if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { - return; - } - this.storedPortlet = storedPortlet; - portletConfig = storedPortlet.getConfiguration(); - - //lazy init any elements not yet configured. - for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { - if (portletConfig.getSimple(key) == null) { - portletConfig.put(new PropertySimple(key, - PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key))); - } - } - } - - public Canvas getHelpCanvas() { - return new HTMLFlow(MSG.view_portlet_help_recentAlerts()); - } - - public static final class Factory implements PortletViewFactory { - public static PortletViewFactory INSTANCE = new Factory(); - - public final Portlet getInstance(String locatorId) { - return new GroupAlertsPortlet3(locatorId); - } - } - - /** Fetches alerts and updates the DynamicForm instance with the latest - * alert information. - */ - private void getRecentAlerts() { - final int groupId = this.groupId; - currentlyLoading = false; - //fetches last five alerts for this resource - AlertCriteria criteria = new AlertCriteria(); - //filter priority - PropertySimple property = portletConfig.getSimple(Constant.ALERT_PRIORITY); - if (property != null) { - String currentSetting = property.getStringValue(); - String[] parsedValues = currentSetting.trim().split(","); - if (currentSetting.trim().isEmpty() || parsedValues.length == 3) { - //all alert priorities assumed - } else { - AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length]; - int indx = 0; - for (String priority : parsedValues) { - AlertPriority p = AlertPriority.valueOf(priority); - filterPriorities[indx++] = p; - } - criteria.addFilterPriorities(filterPriorities); - } - } - PageControl pc = new PageControl(); - //result sort order - property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER); - if (property != null) { - String currentSetting = property.getStringValue(); - if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) { - criteria.addSortCtime(PageOrdering.DESC); - pc.setPrimarySortOrder(PageOrdering.DESC); - } else { - criteria.addSortCtime(PageOrdering.ASC); - pc.setPrimarySortOrder(PageOrdering.ASC); - } - } - //result timeframe if enabled - property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE); - if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting - property = portletConfig.getSimple(Constant.METRIC_RANGE); - if (property != null) { - String currentSetting = property.getStringValue(); - String[] range = currentSetting.split(","); - criteria.addFilterStartTime(Long.valueOf(range[0])); - criteria.addFilterEndTime(Long.valueOf(range[1])); - } - } - - //result count - property = portletConfig.getSimple(Constant.RESULT_COUNT); - if (property != null) { - String currentSetting = property.getStringValue(); - if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase("5")) { - //PageControl pageControl = new PageControl(0, 5); - pc.setPageSize(5); - } else { - //PageControl pageControl = new PageControl(0, Integer.valueOf(currentSetting)); - pc.setPageSize(Integer.valueOf(currentSetting)); - } - } - criteria.setPageControl(pc); - criteria.addFilterResourceGroupIds(groupId); - alertService.findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() { - @Override - public void onSuccess(PageList<Alert> result) { - VLayout column = new VLayout(); - column.setHeight(10); - if (!result.isEmpty()) { - int rowNum = 0; - for (Alert alert : result) { - // alert history records do not have a usable locatorId, we'll use rownum, which is unique and - // may be repeatable. - LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String - .valueOf(rowNum++))); - row.setNumCols(3); - - StaticTextItem iconItem = AbstractActivityView.newTextItemIcon(ImageManager.getAlertIcon(alert - .getAlertDefinition().getPriority()), alert.getAlertDefinition().getPriority() - .getDisplayName()); - LinkItem link = AbstractActivityView.newLinkItem(alert.getAlertDefinition().getName() + ": ", - ReportDecorator.GWT_GROUP_URL + groupId + "/Alerts/History/" + alert.getId()); - StaticTextItem time = AbstractActivityView.newTextItem(GwtRelativeDurationConverter - .format(alert.getCtime())); - row.setItems(iconItem, link, time); - - column.addMember(row); - } - //link to more details - LocatableDynamicForm row = new LocatableDynamicForm(recentAlertsContent.extendLocatorId(String - .valueOf(rowNum++))); - AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId - + "/Alerts/History/", column); - } else { - LocatableDynamicForm row = AbstractActivityView.createEmptyDisplayRow(recentAlertsContent - // .extendLocatorId("None"), AbstractActivityView.RECENT_ALERTS_NONE); - .extendLocatorId("None"), "No results found using criteria specified."); - column.addMember(row); - } - for (Canvas child : recentAlertsContent.getChildren()) { - child.destroy(); - } - recentAlertsContent.addChild(column); - recentAlertsContent.markForRedraw(); - } - - @Override - public void onFailure(Throwable caught) { - Log.debug("Error retrieving recent alerts for group [" + groupId + "]:" + caught.getMessage()); - } - }); - } - - protected void loadData() { - currentlyLoading = true; - getRecentAlerts(); - } - - @Override - public DynamicForm getCustomSettingsForm() { - LocatableDynamicForm customSettings = new LocatableDynamicForm(extendLocatorId("customSettings")); - LocatableVLayout page = new LocatableVLayout(customSettings.extendLocatorId("page")); - //build editor form container - final LocatableDynamicForm form = new LocatableDynamicForm(page.extendLocatorId("alert-filter")); - form.setMargin(5); - - //add label about what configuration affects - - //add alert priority selector - final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent - .getAlertPriorityEditor(portletConfig); - //add sort priority selector - // final SelectItem resultSortSelector = PortletConfigurationEditorComponent - // .getResulSortOrderEditor(portletConfig); - //add result count selector - final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig); - //add range selector - final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent - .getMeasurementRangeEditor(portletConfig); - //TODO: spinder 3/10/11 renable sort selector once it's working in criteria - // form.setItems(alertPrioritySelector, resultSortSelector, resultCountSelector); - form.setItems(alertPrioritySelector, resultCountSelector); - - //submit handler - customSettings.addSubmitValuesHandler(new SubmitValuesHandler() { - - @Override - public void onSubmitValues(SubmitValuesEvent event) { - //alert severity - String selectedValue = alertPrioritySelector.getValue().toString(); - if ((selectedValue.trim().isEmpty()) || (selectedValue.split(",").length == 3)) {//then no alertPriority specified - portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, "")); - } else {//some subset of available alertPriorities will be used - portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, selectedValue)); - } - // //result sort order - // selectedValue = resultSortSelector.getValue().toString(); - // if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc - // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC)); - // } else { - // portletConfig.put(new PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC)); - // } - //result count - selectedValue = resultCountSelector.getValue().toString(); - if ((selectedValue.trim().isEmpty()) || (selectedValue.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT))) {//then 5 - portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, Constant.RESULT_COUNT_DEFAULT)); - } else { - portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue)); - } - - //alert time range filter. Check for enabled and then persist property. Dealing with compound widget. - FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM); - CheckboxItem itemC = (CheckboxItem) item; - selectedValue = String.valueOf(itemC.getValueAsBoolean()); - if (!selectedValue.trim().isEmpty()) {//then call - portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue)); - } - - //alert time advanced time filter enabled. - selectedValue = String.valueOf(measurementRangeEditor.isAdvanced()); - if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) { - portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue)); - } - - //alert time frame - List<Long> begEnd = measurementRangeEditor.getBeginEndTimes(); - if (begEnd.get(0) != 0) {//advanced settings - portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1)))); - } - - //persist - storedPortlet.setConfiguration(portletConfig); - configure(portletWindow, storedPortlet); - loadData(); - } - }); - form.markForRedraw(); - page.addMember(measurementRangeEditor); - page.addMember(form); - customSettings.addChild(page); - return customSettings; - } - - public void startRefreshCycle() { - refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); - } - - @Override - protected void onDestroy() { - AutoRefreshPortletUtil.onDestroy(this, refreshTimer); - - super.onDestroy(); - } - - public boolean isRefreshing() { - return this.currentlyLoading; - } - - @Override - public void redraw() { - super.redraw(); - loadData(); - } -} \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java new file mode 100644 index 0000000..013e5be --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java @@ -0,0 +1,376 @@ +package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import com.google.gwt.user.client.Timer; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; +import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; +import com.smartgwt.client.widgets.form.fields.CheckboxItem; +import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; + +import org.rhq.core.domain.alert.Alert; +import org.rhq.core.domain.alert.AlertPriority; +import org.rhq.core.domain.authz.Permission; +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.configuration.Configuration; +import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.criteria.AlertCriteria; +import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.resource.composite.ResourcePermission; +import org.rhq.core.domain.util.OrderingField; +import org.rhq.core.domain.util.PageControl; +import org.rhq.core.domain.util.PageList; +import org.rhq.core.domain.util.PageOrdering; +import org.rhq.enterprise.gui.coregui.client.alert.AlertDataSource; +import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView; +import org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; +import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; +import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant; +import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; + +/** + * A base class for deriving recent alerts portlets for different entity contexts. In this way the + * basic plumbing is shared, giving a consistent behavior and configuration for the concrete portlets. + * + * @author Jay Shaughnessy + * @author Simeon Pinder + */ +public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, + AutoRefreshPortlet { + + // set on initial configuration, the window for this portlet view. + private PortletWindow portletWindow; + + private AlertsPortletDataSource dataSource; + + // autorefresh timer + private Timer refreshTimer; + + public AbstractRecentAlertsPortlet(String locatorId, EntityContext entityContext) { + super(locatorId, entityContext); + + setShowFilterForm(false); //disable filter form for portlet + setOverflow(Overflow.VISIBLE); + } + + public Timer getRefreshTimer() { + return refreshTimer; + } + + public void setRefreshTimer(Timer refreshTimer) { + this.refreshTimer = refreshTimer; + } + + public PortletWindow getPortletWindow() { + return portletWindow; + } + + @Override + public AlertsPortletDataSource getDataSource() { + if (null == this.dataSource) { + this.dataSource = new AlertsPortletDataSource(getContext()); + } + return this.dataSource; + } + + @Override + public Canvas getHelpCanvas() { + return new HTMLFlow(MSG.view_portlet_help_recentAlerts()); + } + + @Override + public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { + + // the portletWindow does not change, so we can hold onto it locally + if (null == this.portletWindow && null != portletWindow) { + this.portletWindow = portletWindow; + } + + // if there is no configuration there is nothing to set + if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { + return; + } + + Configuration config = storedPortlet.getConfiguration(); + + // not sure I love the fact that this common portlet config assigns some irrelevant/unused config props, + // may be better to prune the common set and add the specific properties locally in this method + for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { + if (config.getSimple(key) == null) { + config.put(new PropertySimple(key, PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION + .get(key))); + } + } + + getDataSource().setConfiguration(config); + } + + @Override + public DynamicForm getCustomSettingsForm() { + + LocatableDynamicForm customSettingsForm = new LocatableDynamicForm(extendLocatorId("CustomSettings")); + LocatableVLayout page = new LocatableVLayout(customSettingsForm.extendLocatorId("Page")); + LocatableDynamicForm filterForm = new LocatableDynamicForm(page.extendLocatorId("Filter")); + filterForm.setMargin(5); + + final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet(); + final Configuration portletConfig = storedPortlet.getConfiguration(); + + // alert priority selector + final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent + .getAlertPriorityEditor(portletConfig); + + // result count selector + final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig); + + // range selector + final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent + .getMeasurementRangeEditor(portletConfig); + + filterForm.setItems(alertPrioritySelector, resultCountSelector); + + //submit handler + customSettingsForm.addSubmitValuesHandler(new SubmitValuesHandler() { + + @Override + public void onSubmitValues(SubmitValuesEvent event) { + // alert severity + String selectedValue = alertPrioritySelector.getValue().toString(); + if ((selectedValue.trim().isEmpty()) + || (selectedValue.split(",").length == AlertPriority.values().length)) { + // no severity filter + selectedValue = Constant.ALERT_PRIORITY_DEFAULT; + } + portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, selectedValue)); + + // result count + selectedValue = resultCountSelector.getValue().toString(); + if (selectedValue.trim().isEmpty()) { + selectedValue = Constant.RESULT_COUNT_DEFAULT; + } + portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue)); + + // time range settings + saveMeasurementRangeEditorSettings(measurementRangeEditor, portletConfig); + + // persist and reload portlet + storedPortlet.setConfiguration(portletConfig); + configure(portletWindow, storedPortlet); + } + }); + + page.addMember(measurementRangeEditor); + page.addMember(filterForm); + customSettingsForm.addChild(page); + + return customSettingsForm; + } + + /** + * Takes the current value of the widget and persists it into the configuration object passed in. + * + * @param measurementRangeEditor + * @param portletConfig + * returns populated configuration object. + */ + private void saveMeasurementRangeEditorSettings(final CustomConfigMeasurementRangeEditor measurementRangeEditor, + Configuration portletConfig) { + String selectedValue = null; + if ((measurementRangeEditor != null) && (portletConfig != null)) { + //time range filter. Check for enabled and then persist property. Dealing with compound widget. + FormItem item = measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM); + CheckboxItem itemC = (CheckboxItem) item; + boolean persistTimeRangeSettings = itemC.getValueAsBoolean(); + if (persistTimeRangeSettings) {//retrieve values and persist + selectedValue = String.valueOf(itemC.getValueAsBoolean()); + if (!selectedValue.trim().isEmpty()) {//then call + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, selectedValue)); + } + + //time advanced time filter enabled. + boolean isAdvanceTimeSetting = false; + selectedValue = String.valueOf(measurementRangeEditor.isAdvanced()); + if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) { + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue)); + isAdvanceTimeSetting = Boolean.valueOf(selectedValue); + } + + //time frame + List<Long> begEnd = measurementRangeEditor.getBeginEndTimes(); + if (isAdvanceTimeSetting) {//advanced settings + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, (begEnd.get(0) + "," + begEnd.get(1)))); + } else { + //save not advanced time range + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN, measurementRangeEditor + .getMetricRangePreferences().lastN)); + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT, measurementRangeEditor + .getMetricRangePreferences().unit)); + } + } else {//if disabled, reset time defaults + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE, false)); + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, false)); + List<Long> rangeArray = MeasurementUtility.calculateTimeFrame(Integer + .valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT), Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT)); + // String[] range = {String.valueOf(rangeArray.get(0)),String.valueOf(rangeArray.get(1))}; + portletConfig.put(new PropertySimple(Constant.METRIC_RANGE, + (String.valueOf(rangeArray.get(0)) + "," + String.valueOf(rangeArray.get(1))))); + } + } + } + + @Override + protected void setupTableInteractions(boolean hasWriteAccess) { + if (!hasWriteAccess) { + Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions(); + ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions(); + hasWriteAccess = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm.isAlert())); + } + super.setupTableInteractions(hasWriteAccess); + } + + public void startRefreshCycle() { + refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); + } + + public boolean isRefreshing() { + // TODO: actually keep track of when the portlet is refreshing data + return false; + } + + @Override + protected void onDestroy() { + AutoRefreshPortletUtil.onDestroy(this, refreshTimer); + + super.onDestroy(); + } + + static public class AlertsPortletDataSource extends AlertDataSource { + private Configuration configuration; + + public AlertsPortletDataSource(EntityContext entityContext) { + this(entityContext, null); + } + + public AlertsPortletDataSource(EntityContext entityContext, Configuration configuration) { + super(entityContext); + this.configuration = configuration; + } + + public Configuration getConfiguration() { + return configuration; + } + + public void setConfiguration(Configuration configuration) { + this.configuration = configuration; + } + + /* (non-Javadoc) + * This override allows us to set the total rows to the number of recent alerts configured for + * the portlet. This sets the counter appropriately and stops further queries to the server. + * + * @see org.rhq.enterprise.gui.coregui.client.alert.AlertDataSource#dataRetrieved(org.rhq.core.domain.util.PageList, com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest) + */ + @Override + protected void dataRetrieved(PageList<Alert> result, DSResponse response, DSRequest request) { + super.dataRetrieved(result, response, request); + + response.setTotalRows(result.size()); + } + + @Override + protected AlertCriteria getFetchCriteria(DSRequest request) { + AlertCriteria criteria = new AlertCriteria(); + + // result count + String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT, + Constant.RESULT_COUNT_DEFAULT); + + // We have to set a PageControl override here, or RPCDataSource will apply default paging based on the + // request. But, once setting a paging override the CriteriaQueryGenerator will use it for + // paging *and* sorting, so we need to also ensure our desired sorting is included in the override. So, + // to get the most recent alerts, apply a descending ordering on create time. + int pageNumber = 0; + int pageSize = Integer.valueOf(currentSetting); + OrderingField orderingField = new OrderingField("ctime", PageOrdering.DESC); + criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField)); + + // filter priority + currentSetting = this.configuration + .getSimpleValue(Constant.ALERT_PRIORITY, Constant.ALERT_PRIORITY_DEFAULT); + String[] parsedValues = currentSetting.trim().split(","); + if (!(currentSetting.trim().isEmpty() || parsedValues.length == 3)) { + AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length]; + int indx = 0; + for (String priority : parsedValues) { + AlertPriority p = AlertPriority.valueOf(priority); + filterPriorities[indx++] = p; + } + criteria.addFilterPriorities(filterPriorities); + } + + //result timeframe if enabled + currentSetting = this.configuration.getSimpleValue(Constant.METRIC_RANGE_ENABLE, null); + if (Boolean.valueOf(currentSetting)) {//then proceed setting + + boolean isAdvanced = false; + //detect type of widget[Simple|Advanced] + PropertySimple property = this.configuration.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG); + if (property != null) { + isAdvanced = property.getBooleanValue(); + } + if (isAdvanced) { + //Advanced time settings + property = this.configuration.getSimple(Constant.METRIC_RANGE); + if (property != null) { + currentSetting = property.getStringValue(); + String[] range = currentSetting.split(","); + criteria.addFilterStartTime(Long.valueOf(range[0])); + criteria.addFilterEndTime(Long.valueOf(range[1])); + } + } else { + //Simple time settings + property = this.configuration.getSimple(Constant.METRIC_RANGE_LASTN); + if (property != null) { + int lastN = property.getIntegerValue(); + property = this.configuration.getSimple(Constant.METRIC_RANGE_UNIT); + int lastUnits = property.getIntegerValue(); + ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, Integer + .valueOf(lastUnits)); + criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0))); + criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1))); + } + } + } + + // add any context related filters + switch (getEntityContext().type) { + case Resource: + criteria.addFilterResourceIds(getEntityContext().getResourceId()); + break; + + case ResourceGroup: + criteria.addFilterResourceGroupIds(getEntityContext().getGroupId()); + } + + criteria.fetchAlertDefinition(true); + criteria.fetchRecoveryAlertDefinition(true); + + return criteria; + } + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java deleted file mode 100644 index dae36c2..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation, and/or the GNU Lesser - * General Public License, version 2.1, also as published by the Free - * Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License and the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * and the GNU Lesser General Public License along with this program; - * if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.RecordList; -import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.widgets.grid.ListGridField; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.criteria.ResourceCriteria; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; - -/** - * @author Simeon Pinder - */ -public class PortletAlertSelector extends ResourceSelector { - - public PortletAlertSelector(String locatorId, Integer[] currentlyAssignedIds, ResourceType resourceTypeFilter, - boolean forceResourceTypeFilter) { - super(locatorId, resourceTypeFilter, forceResourceTypeFilter); - - //populate fields for grid. - ListGridField nameField = new ListGridField("name", MSG.common_title_name()); - ListGridField iconField = new ListGridField("icon", MSG.common_title_icon(), 50); - iconField.setType(ListGridFieldType.ICON); - assignedGrid.setFields(iconField, nameField); - - setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH); - - //retrieve the previously assigned resource ids - if ((currentlyAssignedIds != null) && currentlyAssignedIds.length > 0) { - //build listgrid records - ResourceCriteria criteria = new ResourceCriteria(); - criteria.addFilterIds(currentlyAssignedIds); - - GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria, - new AsyncCallback<PageList<Resource>>() { - @Override - public void onSuccess(PageList<Resource> result) { - if (result.size() > 0) { - ListGridRecord[] data = (new ResourceDatasource()).buildRecords(result); - assignedGrid.setData(data); - } - } - - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_portlet_recentAlerts_fail_msg(), caught); - } - }); - } - } - - public Integer[] getAssignedListGridValues() { - Integer[] listGridValues = new Integer[0]; - if ((null != assignedGrid)) { - RecordList allRecords = assignedGrid.getDataAsRecordList(); - if (allRecords.getLength() > 0) { - listGridValues = new Integer[allRecords.getLength()]; - for (int i = 0; i < allRecords.getLength(); i++) { - Record record = allRecords.get(i); - listGridValues[i] = record.getAttributeAsInt(RecentAlertsPortlet.ID); - } - } - } - return listGridValues; - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java index fed9070..51e12b6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java @@ -18,542 +18,22 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-import java.util.Set; - -import com.google.gwt.user.client.Timer; -import com.smartgwt.client.types.Overflow; -import com.smartgwt.client.widgets.Canvas; -import com.smartgwt.client.widgets.HTMLFlow; -import com.smartgwt.client.widgets.events.DoubleClickEvent; -import com.smartgwt.client.widgets.events.DoubleClickHandler; -import com.smartgwt.client.widgets.form.DynamicForm; -import com.smartgwt.client.widgets.form.events.SubmitValuesEvent; -import com.smartgwt.client.widgets.form.events.SubmitValuesHandler; -import com.smartgwt.client.widgets.form.fields.SelectItem; -import com.smartgwt.client.widgets.form.fields.SpacerItem; -import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; -import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; -import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.layout.VLayout; - -import org.rhq.core.domain.alert.AlertPriority; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.configuration.PropertyList; -import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.LinkManager; -import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView; -import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil; -import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; +import org.rhq.core.domain.common.EntityContext; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; -import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; -import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** - * @author Simeon Pinder - * @author Greg Hinkle + * @author Jay Shaughnessy */ -public class RecentAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet { +public class RecentAlertsPortlet extends AbstractRecentAlertsPortlet {
// A non-displayed, persisted identifier for the portlet public static final String KEY = "RecentAlerts"; // A default displayed, persisted name for the portlet public static final String NAME = MSG.view_portlet_defaultName_recentAlerts();
- //widget keys also used in form population - public static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE = "alert-range-display-amount-value"; - public static final String ALERT_RANGE_PRIORITY_VALUE = "alert-range-priority-value"; - public static final String ALERT_RANGE_TIME_VALUE = "alert-range-time-value"; - public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value"; - public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids"; - //configuration default information - private static final String defaultAlertCountValue = "5"; - private static final String PRIORITY_ALL = MSG.common_label_all(); - private static final String PRIORITY_HIGH = AlertPriority.HIGH.getDisplayName(); - private static final String PRIORITY_MEDIUM = AlertPriority.MEDIUM.getDisplayName(); - private static final String PRIORITY_LOW = AlertPriority.LOW.getDisplayName(); - private static final String defaultPriorityValue = PRIORITY_ALL; - private static final String TIME_30_MINS = "30 " + MSG.common_label_minutes(); - private static final String TIME_HOUR = MSG.common_label_hour(); - private static final String TIME_12_HRS = "12 " + MSG.common_label_hours(); - private static final String TIME_DAY = MSG.common_label_day(); - private static final String TIME_WEEK = MSG.common_label_week(); - private static final String TIME_MONTH = MSG.common_label_month(); - private static final String defaultTimeValue = TIME_DAY; - public static final String RESOURCES_ALL = MSG.common_label_all_resources(); - public static final String RESOURCES_SELECTED = MSG.common_label_selected_resources(); - public static final String defaultResourceValue = RESOURCES_ALL; - private static final String unlimited = MSG.common_label_unlimited(); - //alert resource labels - public static final String ALERT_LABEL_SELECTED_RESOURCES = MSG.common_title_selected_resources(); - public static final String ALERT_LABEL_AVAILABLE_RESOURCES = MSG.common_title_available_resources(); - public static final String ALERT_LABEL_RESOURCE_INVENTORY = MSG.common_title_resource_inventory(); - public static final int ALERT_RESOURCE_SELECTION_WIDTH = 800; - public static final String ID = "id"; - - // set on initial configuration, the window for this portlet view. - private PortletWindow portletWindow; - - //shared private UI elements - private AlertResourceSelectorRegion resourceSelector; - - private AlertPortletDataSource dataSource; - //instance ui widgets - private Canvas containerCanvas; - - private Timer refreshTimer; - public RecentAlertsPortlet(String locatorId) { - super(locatorId); - - //override the shared datasource - this.dataSource = new AlertPortletDataSource(); - setDataSource(this.dataSource); - - setShowHeader(false); - setShowFooter(true); - setShowFooterRefresh(false); //disable footer refresh - setShowFilterForm(false); //disable filter form for portlet - - setOverflow(Overflow.VISIBLE); - } - - public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - - if (null == this.portletWindow && null != portletWindow) { - this.portletWindow = portletWindow; - } - - if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { - return; - } - - //Operation range property - retrieve existing value - PropertySimple property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE); - if ((property != null) && (property.getStringValue() != null)) { - //retrieve and translate to int - String retrieved = property.getStringValue(); - int translatedAlertRangeSelection = translatedAlertRangeSelection(retrieved); - getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection); - } else {//create setting - storedPortlet.getConfiguration().put( - new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue)); - getDataSource().setAlertRangeCompleted(Integer.parseInt(defaultAlertCountValue)); - } - //Operation priority property setting - property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE); - if ((property != null) && (property.getStringValue() != null)) { - //retrieve and translate to int - String retrieved = property.getStringValue(); - int translatedPriorityIndex = translatedPriorityToValidIndex(retrieved); - getDataSource().setAlertPriorityIndex(translatedPriorityIndex); - } else {//create setting - storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue)); - getDataSource().setAlertPriorityIndex(translatedPriorityToValidIndex(PRIORITY_ALL)); - } - - //Range to time that alerts will be shown for - property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE); - if ((property != null) && (property.getStringValue() != null)) { - //retrieve and translate to int - String retrieved = property.getStringValue(); - long translatedRange = translateTimeToValidRange(retrieved); - getDataSource().setAlertTimeRange(translatedRange); - } else {//create setting - storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue)); - getDataSource().setAlertTimeRange(translateTimeToValidRange(defaultTimeValue)); - } - - //Range of resources to be included in the query - property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE); - if ((property != null) && (property.getStringValue() != null)) { - //retrieve and translate to int - String retrieved = property.getStringValue(); - if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) { - getDataSource().setAlertResourcesToUse(RESOURCES_SELECTED); - } else { - getDataSource().setAlertResourcesToUse(RESOURCES_ALL); - } - } else {//create setting - storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue)); - getDataSource().setAlertResourcesToUse(RESOURCES_ALL); - } - - //resource ids to be conditionally included in the query - Integer[] filterResourceIds = null; - filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds); - //no defaults - - if (filterResourceIds != null) { - getDataSource().setAlertFilterResourceId(filterResourceIds); - } - - //conditionally display the selected resources ui - if (containerCanvas != null) { - //empty out earlier canvas - for (Canvas c : containerCanvas.getChildren()) { - c.destroy(); - } - if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) { - containerCanvas.addChild(resourceSelector.getCanvas()); - } else { - containerCanvas.addChild(new Canvas()); - } - } - } - - private int translatedAlertRangeSelection(String retrieved) { - int translated = -1; - if ((retrieved != null) && (!retrieved.trim().isEmpty())) { - if (retrieved.equalsIgnoreCase(unlimited)) { - translated = -1; - } else { - translated = Integer.parseInt(retrieved);//default to all - } - } else {//default to defaultValue - if (defaultAlertCountValue.equalsIgnoreCase(unlimited)) { - translated = -1; - } else { - translated = Integer.parseInt(defaultAlertCountValue); - } - } - return translated; - } - - private int translatedPriorityToValidIndex(String retrieved) { - int translatedPriority = 0;//default to all - if ((retrieved != null) && (!retrieved.trim().isEmpty())) { - if (retrieved.equalsIgnoreCase(PRIORITY_HIGH)) { - translatedPriority = 3; - } else if (retrieved.equalsIgnoreCase(PRIORITY_MEDIUM)) { - translatedPriority = 2; - } else if (retrieved.equalsIgnoreCase(PRIORITY_LOW)) { - translatedPriority = 1; - } else { - translatedPriority = 0;//default to all - } - } - return translatedPriority; - } - - /**Translates the UI selection options into time values for alert query. - * - * @param retrieved - * @return long value mapping to string passed in. - */ - private long translateTimeToValidRange(String retrieved) { - long translated = 0;//default to ALL - if ((retrieved != null) && (!retrieved.trim().isEmpty())) { - if (retrieved.equalsIgnoreCase(TIME_30_MINS)) { - translated = MeasurementUtility.MINUTES * 30; - } else if (retrieved.equalsIgnoreCase(TIME_HOUR)) { - translated = MeasurementUtility.HOURS; - } else if (retrieved.equalsIgnoreCase(TIME_12_HRS)) { - translated = MeasurementUtility.HOURS * 12; - } else if (retrieved.equalsIgnoreCase(TIME_DAY)) { - translated = MeasurementUtility.DAYS; - } else if (retrieved.equalsIgnoreCase(TIME_WEEK)) { - translated = MeasurementUtility.WEEKS; - } else if (retrieved.equalsIgnoreCase(TIME_MONTH)) { - translated = MeasurementUtility.DAYS * 28;//replicated from old struts def. - } else { - translated = MeasurementUtility.DAYS;//default to day otherwise. - } - } - return translated; - } - - public Canvas getHelpCanvas() { - return new HTMLFlow(MSG.view_portlet_help_recentAlerts()); - } - - public DynamicForm getCustomSettingsForm() { - //root dynamic form instance - final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("custom-settings")); - form.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH + 40);//largest widget display + 40 for buttons - form.setHeight(400); - form.setMargin(5); - - final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet(); - - //vertical container - VLayout column = new VLayout(); - - //label - LocatableLabel alertRangeLabel = new LocatableLabel(extendLocatorId("DynamicForm_Label_Alert_Range"), "<b>" - + MSG.common_title_alert_range() + "</b>"); - - //horizontal layout - LocatableHLayout row = new LocatableHLayout(extendLocatorId("alert-range-settings-row-1")); - row.setMembersMargin(10); - - //-------------combobox for number of completed scheduled ops to display on the dashboard - final SelectItem alertRangeLastComboBox = new SelectItem(ALERT_RANGE_DISPLAY_AMOUNT_VALUE); - alertRangeLastComboBox.setTitle(MSG.view_measureRange_last()); - alertRangeLastComboBox.setType("selection"); - alertRangeLastComboBox.setWrapTitle(false); - //define acceptable values for display amount - String[] acceptableDisplayValues = { "5", "10", MSG.common_label_unlimited() }; - alertRangeLastComboBox.setValueMap(acceptableDisplayValues); - //set width of dropdown display region - alertRangeLastComboBox.setWidth(100); - alertRangeLastComboBox.addChangeHandler(new ChangeHandler() { - public void onChange(ChangeEvent event) { - String selectedItem = "" + event.getValue(); - //stuff into the master form for retrieval - form.setValue(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, selectedItem); - } - }); - - //default selected value to 'unlimited'(live lists) and check both combobox settings here. - String selectedValue = defaultAlertCountValue; - if (storedPortlet != null) { - //if property exists retrieve it - if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) != null) { - selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) - .getStringValue(); - } else {//insert default value - storedPortlet.getConfiguration().put( - new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue)); - } - } - //prepopulate the combobox with the previously stored selection - alertRangeLastComboBox.setDefaultValue(selectedValue); - - //-------------combobox for number of completed scheduled ops to display on the dashboard - final SelectItem alertRangePriorityComboBox = new SelectItem(ALERT_RANGE_PRIORITY_VALUE); - alertRangePriorityComboBox.setTitle(""); - alertRangePriorityComboBox.setHint("<nobr> <b> " + MSG.view_portlet_recentAlerts_config_priority_label() - + "</b></nobr>"); - alertRangePriorityComboBox.setType("selection"); - //define acceptable values for display amount - String[] acceptablePriorityDisplayValues = { PRIORITY_ALL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW }; - alertRangePriorityComboBox.setValueMap(acceptablePriorityDisplayValues); - //set width of dropdown display region - alertRangePriorityComboBox.setWidth(100); - alertRangePriorityComboBox.addChangeHandler(new ChangeHandler() { - public void onChange(ChangeEvent event) { - String selectedItem = "" + event.getValue(); - //stuff into the master form for retrieval - form.setValue(ALERT_RANGE_PRIORITY_VALUE, selectedItem); - } - }); - - //default selected value to 'unlimited'(live lists) and check both combobox settings here. - selectedValue = defaultPriorityValue; - if (storedPortlet != null) { - //if property exists retrieve it - if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE) != null) { - selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE).getStringValue(); - } else {//insert default value - storedPortlet.getConfiguration().put( - new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue)); - } - } - //prepopulate the combobox with the previously stored selection - alertRangePriorityComboBox.setDefaultValue(selectedValue); - row.addMember(alertRangeLabel); - DynamicForm wrappedRange = new DynamicForm(); - wrappedRange.setFields(alertRangeLastComboBox); - row.addMember(wrappedRange); - - DynamicForm wrappedPriority = new DynamicForm(); - wrappedPriority.setFields(alertRangePriorityComboBox); - row.addMember(wrappedPriority); - - //horizontal layout - LocatableHLayout row2 = new LocatableHLayout(extendLocatorId("alert-range-settings-row-2")); - - LocatableLabel alertRangeSpanLabel = new LocatableLabel(extendLocatorId("range-span-label"), "<b>" - + MSG.view_portlet_recentAlerts_config_when() + "<b>"); - //------------- Build second combobox for timeframe for problem resources search. - final SelectItem alertRangeTimeComboBox = new SelectItem(ALERT_RANGE_TIME_VALUE); - alertRangeTimeComboBox.setTitle(""); - alertRangeTimeComboBox.setHint(""); - alertRangeTimeComboBox.setType("selection"); - String[] acceptableTimeDisplayValues = { TIME_30_MINS, TIME_HOUR, TIME_12_HRS, TIME_DAY, TIME_WEEK, TIME_MONTH }; - alertRangeTimeComboBox.setValueMap(acceptableTimeDisplayValues); - alertRangeTimeComboBox.setWidth(100); - alertRangeTimeComboBox.addChangeHandler(new ChangeHandler() { - public void onChange(ChangeEvent event) { - String selectedItem = "" + event.getValue(); - //stuff into the master form for retrieval - form.setValue(ALERT_RANGE_TIME_VALUE, selectedItem); - } - }); - - //set to default - selectedValue = defaultTimeValue; - if (storedPortlet != null) { - //if property exists retrieve it - if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE) != null) { - selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE).getStringValue(); - } else {//insert default value - storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue)); - } - } - //prepopulate the combobox with the previously stored selection - alertRangeTimeComboBox.setDefaultValue(selectedValue); - DynamicForm timeSelectionWrapper = new DynamicForm(); - timeSelectionWrapper.setFields(alertRangeTimeComboBox); - - // build resource selection drop down - //------------- Build second combobox for timeframe for problem resources search. - final SelectItem alertResourcesComboBox = new SelectItem(ALERT_RANGE_RESOURCES_VALUE); - alertResourcesComboBox.setTitle(MSG.common_val_for()); - alertResourcesComboBox.setHint(""); - alertResourcesComboBox.setType("selection"); - String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED }; - alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues); - alertResourcesComboBox.setWidth(150); - alertResourcesComboBox.addChangeHandler(new ChangeHandler() { - public void onChange(ChangeEvent event) { - String selectedItem = "" + event.getValue(); - //stuff into the master form for retrieval - form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem); - //empty out earlier canvas - for (Canvas c : containerCanvas.getChildren()) { - c.destroy(); - } - if (selectedItem.equals(RESOURCES_SELECTED)) { - containerCanvas.addChild(resourceSelector.getCanvas()); - } else { - containerCanvas.addChild(new Canvas()); - } - } - }); - - //set to default - selectedValue = defaultResourceValue; - if (storedPortlet != null) { - //if property exists retrieve it - if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) != null) { - selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) - .getStringValue(); - } else {//insert default value - storedPortlet.getConfiguration().put( - new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue)); - } - } - //prepopulate the combobox with the previously stored selection - alertResourcesComboBox.setDefaultValue(selectedValue); - DynamicForm resourceSelectionWrapper = new DynamicForm(); - resourceSelectionWrapper.setFields(alertResourcesComboBox); - - alertRangeSpanLabel.setWrap(false); - alertRangeSpanLabel.setWidth(150); - row2.addMember(alertRangeSpanLabel); - row2.addMember(timeSelectionWrapper); - row2.addMember(resourceSelectionWrapper); - - //if portlet config setting exist, then retrieve - Integer[] alertFilterResourceIds = null; - alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, alertFilterResourceIds); - - LocatableHLayout resourceSelectionRegion = new LocatableHLayout(extendLocatorId("selection-canvas")); - resourceSelector = new AlertResourceSelectorRegion(extendLocatorId("ResourcesWithAlerts"), - alertFilterResourceIds); - resourceSelectionRegion.setWidth100(); - - if (alertFilterResourceIds != null) { - getDataSource().setAlertFilterResourceId(alertFilterResourceIds); - resourceSelector.setCurrentlyAssignedIds(alertFilterResourceIds); - } - - //instantiate canvas area to display empty or rich resource selection based on dropdown selection - containerCanvas = new Canvas(); - String previousAlertFilterChoice = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) - .getStringValue(); - - //reload the ResourceSelectionRegion if user has chosen to focus on specific resources with alerts - if (previousAlertFilterChoice.equals(RESOURCES_SELECTED)) { - containerCanvas.addChild(resourceSelector.getCanvas()); - } else {// define empty canvas - containerCanvas.addChild(new Canvas()); - } - - //add contain resource selection region. - resourceSelectionRegion.addMember(containerCanvas); - - //finish construction of the layout - column.addMember(row); - column.addMember(row2); - SpacerItem verticalSpace = new SpacerItem(); - verticalSpace.setHeight(20); - DynamicForm spacerWrapper = new DynamicForm(); - spacerWrapper.setItems(verticalSpace); - column.addMember(spacerWrapper); - column.addMember(resourceSelectionRegion); - form.addChild(column); - - //submit handler - form.addSubmitValuesHandler(new SubmitValuesHandler() { - @Override - public void onSubmitValues(SubmitValuesEvent event) { - //no need to insert validation here as user not allowed to enter values - parseFormAndPopulateConfiguration(form, storedPortlet, ALERT_RANGE_DISPLAY_AMOUNT_VALUE, - ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE, ALERT_RANGE_TIME_VALUE); - - //retrieve alert-resource-selection property - PropertySimple prop = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE); - - //check to see if "Selected Resources" or "All Resources" - if (prop != null && RESOURCES_SELECTED.equals(prop.getStringValue())) { - //retrieve currentlyAssignedIds - Integer[] valuesToPersist = resourceSelector.getListGridValues(); - resourceSelector.setCurrentlyAssignedIds(valuesToPersist); - - //build property list of ids to persist - PropertyList list = new PropertyList(ALERT_RANGE_RESOURCE_IDS); - for (int rid : resourceSelector.getCurrentlyAssignedIds()) { - list.add(new PropertySimple(ALERT_RANGE_RESOURCE_IDS, rid)); - } - storedPortlet.getConfiguration().put(new PropertyList(ALERT_RANGE_RESOURCE_IDS, list)); - getDataSource().setAlertFilterResourceId(resourceSelector.getCurrentlyAssignedIds()); - } - - configure(portletWindow, storedPortlet); - - refresh();//reload form with new data selections - markForRedraw(); - } - }); - - return form; - } - - /**Iterates over DynamicForm instance to check for properties passed in and if they have been set - * to put that property into the DashboardPortlet configuration. - * - * @param form Dynamic form storing user selections - * @param portlet Container for configuration changes - * @param properties Variable list of keys used to verify or populate properties. - */ - private void parseFormAndPopulateConfiguration(final DynamicForm form, DashboardPortlet storedPortlet, - String... properties) { - if ((form != null) && (storedPortlet != null)) { - for (String property : properties) { - if (form.getValue(property) != null) {//if new value supplied - storedPortlet.getConfiguration().put(new PropertySimple(property, form.getValue(property))); - } - } - } - } - - public AlertPortletDataSource getDataSource() { - return dataSource; + super(locatorId, EntityContext.forSubsystemView()); }
public static final class Factory implements PortletViewFactory { @@ -565,102 +45,4 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti } }
- public void startRefreshCycle() { - refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer); - } - - @Override - protected void onDestroy() { - AutoRefreshPortletUtil.onDestroy(this, refreshTimer); - - super.onDestroy(); - } - - public boolean isRefreshing() { - return false; - } - - @Override - protected void setupTableInteractions(boolean hasWriteAccess) { - // The portlet is a "subsystem" view. Meaning the alerts displayed can be from any accessible group for - // the user. This means the user can have varying permissions on the underlying groups and/or resources, - // which makes button enablement tricky. So, for the portlet don't even show the buttons unless the user - // is inventory manager. Other users will just have to navigate to the alert in question in order to - // manipulate it. - - //determine if the user is inventory manager and if so render the buttons - Set<Permission> permissions = this.portletWindow.getGlobalPermissions(); - if ((null != permissions) && permissions.contains(Permission.MANAGE_INVENTORY)) { - super.setupTableInteractions(true); - } - } - - protected CellFormatter getDetailsLinkColumnCellFormatter() { - return new CellFormatter() { - public String format(Object value, ListGridRecord record, int i, int i1) { - Integer recordId = getId(record); - Integer resourceId = record.getAttributeAsInt("resourceId"); - String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId); - return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(), null); - } - }; - } - - @Override - protected void configureTable() { - // TODO Auto-generated method stub - super.configureTable(); - - setListGridDoubleClickHandler(new DoubleClickHandler() { - @Override - public void onDoubleClick(DoubleClickEvent event) { - ListGrid listGrid = (ListGrid) event.getSource(); - ListGridRecord[] selectedRows = listGrid.getSelection(); - if (selectedRows != null && selectedRows.length == 1) { - Integer recordId = getId(selectedRows[0]); - Integer resourceId = selectedRows[0].getAttributeAsInt("resourceId"); - CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId, recordId)); - } - } - }); - } - -} - -/** Bundles a ResourceSelector instance with labelling in Canvas for display. - * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly. - */ -class AlertResourceSelectorRegion extends LocatableVLayout { - public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) { - super(locatorId); - this.currentlyAssignedIds = assigned; - } - - private PortletAlertSelector selector = null; - - private Integer[] currentlyAssignedIds; - - public Integer[] getCurrentlyAssignedIds() { - return currentlyAssignedIds; - } - - public Integer[] getListGridValues() { - Integer[] listGridValues = new Integer[0]; - if (null != selector) { - listGridValues = selector.getAssignedListGridValues(); - } - return listGridValues; - } - - public Canvas getCanvas() { - if (selector == null) { - selector = new PortletAlertSelector(extendLocatorId("AlertSelector"), this.currentlyAssignedIds, - ResourceType.ANY_PLATFORM_TYPE, false); - } - return selector; - } - - public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { - this.currentlyAssignedIds = currentlyAssignedIds; - } } \ No newline at end of file diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java index ff3a9939..c43068f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java @@ -19,26 +19,17 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
import com.google.gwt.user.client.History; -import com.smartgwt.client.widgets.Canvas;
-import org.rhq.core.domain.configuration.PropertySimple; -import org.rhq.core.domain.dashboard.DashboardPortlet; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.Messages; -import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource; +import org.rhq.core.domain.common.EntityContext; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; -import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet; -import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector; -import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.AbstractRecentAlertsPortlet;
/** + * @author Jay Shaughnessy * @author Simeon Pinder */ -public class ResourceAlertsPortlet extends GroupAlertsPortlet { +public class ResourceAlertsPortlet extends AbstractRecentAlertsPortlet {
// A non-displayed, persisted identifier for the portlet public static final String KEY = "ResourceAlerts"; @@ -47,138 +38,34 @@ public class ResourceAlertsPortlet extends GroupAlertsPortlet {
private int resourceId;
- public ResourceAlertsPortlet(String locatorId) { - super(locatorId); + public ResourceAlertsPortlet(String locatorId, int resourceId) {
- //override the shared datasource - //figure out which page we're loading - String currentPage = History.getToken(); - String[] elements = currentPage.split("/"); - this.resourceId = Integer.valueOf(elements[1]); - } - - /**Defines layout for the portlet page. - */ - protected void initializeUi() { - //initalize the datasource - Integer[] resourceIds = new Integer[1]; - resourceIds[0] = this.resourceId; - this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds); - setDataSource(this.dataSource); - - setShowHeader(false); - setShowFooter(true); - setShowFooterRefresh(false); //disable footer refresh - setShowFilterForm(false); //disable filter form for portlet - - getListGrid().setEmptyMessage(MSG.view_portlet_results_empty()); - } + super(locatorId, EntityContext.forResource(resourceId));
- @Override - protected void onInit() { - super.onInit(); - initializeUi(); + this.resourceId = resourceId; }
- /** Responsible for initialization and lazy configuration of the portlet values - */ - public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { - //populate portlet configuration details - if (null == this.portletWindow && null != portletWindow) { - this.portletWindow = portletWindow; - } - - if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) { - return; - } - this.storedPortlet = storedPortlet; - portletConfig = storedPortlet.getConfiguration(); - - if (!portletConfigInitialized) { - Integer[] resourceIds = new Integer[1]; - resourceIds[0] = this.resourceId; - this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds); - setDataSource(this.dataSource); - portletConfigInitialized = true; - } - - //lazy init any elements not yet configured. - for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) { - if (portletConfig.getSimple(key) == null) { - portletConfig.put(new PropertySimple(key, - PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key))); - } - } - - //resource ids to be conditionally included in the query - Integer[] filterResourceIds = null; - filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, filterResourceIds); - //no defaults - - if (filterResourceIds != null) { - getDataSource().setAlertFilterResourceId(filterResourceIds); - } - - // //conditionally display the selected resources ui - // if (containerCanvas != null) { - // //empty out earlier canvas - // for (Canvas c : containerCanvas.getChildren()) { - // c.destroy(); - // } - // if ((resourceSelector != null) && getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) { - // containerCanvas.addChild(resourceSelector.getCanvas()); - // } else { - // containerCanvas.addChild(new Canvas()); - // } - // } - + public int getResourceId() { + return resourceId; }
public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc) + * TODO: This factory ASSUMES the user is currently navigated to a resource detail view, and generates a portlet + * for that resource. It will fail in other scenarios. This mechanism should be improved such that the + * factory method can take an EntityContext explicitly indicating, in this case, the resource. + * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String) + */ public final Portlet getInstance(String locatorId) {
- return new ResourceAlertsPortlet(locatorId); - } - } -} - -/** Bundles a ResourceSelector instance with labeling in Canvas for display. - * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly. - */ -class AlertResourceSelectorRegion extends LocatableVLayout { - public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) { - super(locatorId); - this.currentlyAssignedIds = assigned; - } - - private static final Messages MSG = CoreGUI.getMessages(); - private PortletAlertSelector selector = null; + String currentPage = History.getToken(); + String[] elements = currentPage.split("/"); + int resourceId = Integer.valueOf(elements[1]);
- private Integer[] currentlyAssignedIds; - - public Integer[] getCurrentlyAssignedIds() { - return currentlyAssignedIds; - } - - public Integer[] getListGridValues() { - Integer[] listGridValues = new Integer[0]; - if (null != selector) { - listGridValues = selector.getAssignedListGridValues(); + return new ResourceAlertsPortlet(locatorId, resourceId); } - return listGridValues; }
- public Canvas getCanvas() { - if (selector == null) { - selector = new PortletAlertSelector(extendLocatorId("AlertSelector"), this.currentlyAssignedIds, - ResourceType.ANY_PLATFORM_TYPE, false); - } - return selector; - } - - public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { - this.currentlyAssignedIds = currentlyAssignedIds; - } } \ No newline at end of file
commit ba0c90686a14b3dd6058bcf707de2d66360fc285 Author: Heiko W. Rupp hwr@redhat.com Date: Wed Mar 30 13:00:39 2011 +0200
Fix an exception, add an alias for 'set res', rename 'src' to 'rcs', implement 'pcs'.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java index 4e4e103..74ccf48 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java @@ -42,7 +42,6 @@ import org.rhq.core.domain.configuration.PropertySimple; import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; import org.rhq.core.domain.configuration.definition.PropertyDefinition; import org.rhq.core.domain.discovery.AvailabilityReport; -import org.rhq.core.clientapi.server.discovery.InventoryReport; import org.rhq.core.domain.measurement.Availability; import org.rhq.core.domain.measurement.DataType; import org.rhq.core.domain.measurement.MeasurementData; @@ -56,8 +55,6 @@ import org.rhq.core.pc.inventory.InventoryManager; import org.rhq.core.pc.inventory.ResourceContainer; import org.rhq.core.pc.measurement.MeasurementManager; import org.rhq.core.pc.operation.OperationContextImpl; -import org.rhq.core.pc.operation.OperationManager; -import org.rhq.core.pc.operation.OperationServicesAdapter; import org.rhq.core.pc.plugin.FileSystemPluginFinder; import org.rhq.core.pluginapi.operation.OperationContext; import org.rhq.core.pluginapi.operation.OperationServices; @@ -369,7 +366,10 @@ public class StandaloneContainer { showResourceConfig(); break; case SR_CONFIG: - setResourceConfig(tokens); + setResourcePluginConfig(tokens, false); + break; + case SP_CONFIG: + setResourcePluginConfig(tokens,true); break; }
@@ -431,7 +431,7 @@ public class StandaloneContainer {
}
- private void setResourceConfig(String[] tokens) { + private void setResourcePluginConfig(String[] tokens,boolean pluginConfig) { if (resourceId == 0) { System.err.println("No resource set"); return; @@ -450,7 +450,10 @@ public class StandaloneContainer {
ConfigurationManager cm = pc.getConfigurationManager();
- cm.updateResourceConfiguration(request); + if (pluginConfig) { + pc.getInventoryManager().getResourceContainer(resourceId).getResource().setPluginConfiguration(config); + } else + cm.updateResourceConfiguration(request);
@@ -534,7 +537,12 @@ public class StandaloneContainer { * @param tokens tokenized command line tokens[0] is the command itself */ private void children(String[] tokens) { - int id = Integer.valueOf(tokens[1]); + + int id; + if (tokens.length>1) + id = Integer.valueOf(tokens[1]); + else + id = resourceId; ResourceContainer resourceContainer = inventoryManager.getResourceContainer(id); if (resourceContainer != null) { Resource r = resourceContainer.getResource(); @@ -623,7 +631,7 @@ public class StandaloneContainer {
if (comm.startsWith("plu")) { //pluginName = arg; - } else if (comm.startsWith("r")) { + } else if (comm.startsWith("r") || comm.equals("id")) { try { if (arg.equals("$r")) { resourceId = dollarR; @@ -654,7 +662,6 @@ public class StandaloneContainer { private void discover(String[] tokens) {
Set<Resource> existing = getResources(); - InventoryReport report; String what = tokens[1]; long t1 = System.currentTimeMillis(); if (what.startsWith("s")) @@ -755,10 +762,10 @@ public class StandaloneContainer {
/** * Creates a configuration object from the passed String. The string must consist - * of individual key-value pairs, that are spearated by || keys and values are separated by + * of individual key-value pairs, that are separated by || keys and values are separated by * =. Only simple properties are supported for the configuration. * @param input The input string, may be null - * @return a Configuration object or null if input was null + * @return a Configuration object or null if input was null or if one of the pairs was invalid. */ private Configuration createConfigurationFromString(String input) { if (input == null) @@ -768,6 +775,10 @@ public class StandaloneContainer { String[] pairs = input.split("\|\|"); for (String pair : pairs) { String[] kv = pair.split("="); + if (kv.length %2 ==1 ) { + System.err.println("Token " + pair + " is invalid as it contains no '='"); + return null; + } PropertySimple ps = new PropertySimple(kv[0], kv[1]); config.put(ps); } @@ -805,7 +816,7 @@ public class StandaloneContainer { ASCAN("as", "", 0, "Triggers an availability scan"), // AVAIL("a", " ( id )", 0, "Shows an availability report. If id is given, only shows availability for resource with id id"), // - CHILDREN("chi", "id", 1, "Shows the direct children of the resource with the passed id"), // + CHILDREN("chi", "[id]", 0, "Shows the direct children of the resource with the passed id, or if no id passed of the current resource"), // DISCOVER("disc", " s | i | all", 1, "Triggers a discovery scan for (s)erver, serv(i)ce or all resources"), // // EVENT("e", "", 0, "Pull events"), // TODO needs to be defined FIND("find", "r | t | rt <name>", 2, @@ -817,12 +828,13 @@ public class StandaloneContainer { QUIT("quit", "", 0, "Terminates the application"), // RESOURCES("res", "", 0, "Shows the discovered resources"), // SET("set", "'resource' N", 2, - "Sets the resource id to work with. N can be a number or '$r' as result of last find resource call"), // + "Sets the resource id to work with. N can be a number or '$r' as result of last find resource call. 'id' is an alias for 'res'"), // STDIN("stdin","",0, "Stop reading the batch file and wait for commands on stdin"), // WAIT("w", "milliseconds", 1, "Waits the given amount of time"), P_CONFIG("pc", "", 0, "Shows the plugin configuration of the current resource."), R_CONFIG("rc", "", 0, "Shows the resource configuration of the current resource."), - SR_CONFIG("src", "", 0, "[parameters] set resource config ") + SR_CONFIG("rcs", "", 0, "[parameters] set resource config "), + SP_CONFIG("pcs", "", 0, "[parameters] set plugin config ") ;
private String abbrev;
commit 8337b34c8a757821de0c22f4c30f9f32b55265f2 Author: John Mazzitelli mazz@redhat.com Date: Wed Mar 30 00:57:02 2011 -0400
BZ 691978 - fix tag cloud view - you can now delete tags. prettied up the UI as well
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java index 57084e2..d5bcceb 100644 --- a/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java +++ b/modules/core/domain/src/main/java/org/rhq/core/domain/tagging/compsite/TagReportComposite.java @@ -31,7 +31,6 @@ public class TagReportComposite extends Tag {
private static final long serialVersionUID = 1L;
- private Tag tag; private long total; private long resourceCount; private long resourceGroupCount; @@ -46,8 +45,8 @@ public class TagReportComposite extends Tag { public TagReportComposite(int id, String namespace, String semantic, String name, long total, long resourceCount, long resourceGroupCount, long bundleCount, long bundleVersionCount, long bundleDeploymentCount, long bundleDestinationCount) { - this.tag = new Tag(namespace, semantic, name); - this.tag.setId(id); + super(namespace, semantic, name); + setId(id); this.total = total; this.resourceCount = resourceCount; this.resourceGroupCount = resourceGroupCount; @@ -58,7 +57,7 @@ public class TagReportComposite extends Tag { }
public Tag getTag() { - return tag; + return this; }
public long getTotal() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java index 61bfede..2a6beeb 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java @@ -383,7 +383,11 @@ public class LinkManager { }
public static String getTagLink(String tag) { - return "#Reports/Subsystems/Tags/" + tag; + if (tag == null) { + return "#Reports/Subsystems/Tags"; + } else { + return "#Reports/Subsystems/Tags/" + tag; + } }
public static String getBundleLink(int bundleId) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TagCloudView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TagCloudView.java index 61164f3..b2ce6bc 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TagCloudView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TagCloudView.java @@ -24,26 +24,42 @@ package org.rhq.enterprise.gui.coregui.client.report.tag;
import java.util.Collections; import java.util.Comparator; +import java.util.HashSet;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.events.ClickEvent; +import com.smartgwt.client.widgets.events.ClickHandler;
import org.rhq.core.domain.criteria.TagCriteria; +import org.rhq.core.domain.tagging.Tag; import org.rhq.core.domain.tagging.compsite.TagReportComposite; +import org.rhq.core.domain.util.PageControl; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; +import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** + * Shows the tags in a large HTML block, where the most used tags are shown in bigger fonts. + * * @author Greg Hinkle + * @author John Mazzitelli */ public class TagCloudView extends LocatableVLayout {
- private PageList<TagReportComposite> tags; + private static final String REMOVE_ICON = "[skin]/images/actions/remove.png"; + private static final int MIN_FONTSIZE = 8; + private static final int MAX_FONTSIZE = 22;
+ private PageList<TagReportComposite> tags; private String selectedTag; + private IButton deleteButton;
public TagCloudView(String locatorId) { super(locatorId); @@ -52,10 +68,16 @@ public class TagCloudView extends LocatableVLayout { @Override protected void onDraw() { super.onDraw(); + refresh(); + }
+ private void refresh() { removeMembers(getMembers());
- GWTServiceLookup.getTagService().findTagReportCompositesByCriteria(new TagCriteria(), + TagCriteria tagCriteria = new TagCriteria(); + tagCriteria.setPageControl(PageControl.getUnlimitedInstance()); + + GWTServiceLookup.getTagService().findTagReportCompositesByCriteria(tagCriteria, new AsyncCallback<PageList<TagReportComposite>>() { public void onFailure(Throwable caught) { CoreGUI.getErrorHandler().handleError(MSG.view_tagCloud_error_fetchFailure(), caught); @@ -68,36 +90,34 @@ public class TagCloudView extends LocatableVLayout { }
private void drawTags(PageList<TagReportComposite> tags) { - if (tags == null) { - return; // Tags still loading + return; // tags are still loading }
this.tags = tags;
+ // determine the maximum number of times any single tag is used long max = 0; - long total = 0; for (TagReportComposite tag : tags) { if (tag.getTotal() > max) { max = tag.getTotal(); } - total += tag.getTotal(); }
+ // sort the tags so they appear alphabetically Collections.sort(tags, new Comparator<TagReportComposite>() { public int compare(TagReportComposite o1, TagReportComposite o2) { return o1.getTag().toString().compareTo(o2.getTag().toString()); } });
+ // build the HTML block that contains all the tags with variable font sizes + // where the font size represents the relative number of times the tag is used StringBuilder buf = new StringBuilder(); - - int minFont = 8; - int maxFont = 22; - for (TagReportComposite tag : tags) {
- int font = (int) ((((double) tag.getTotal()) / (double) max) * (maxFont - minFont)) + minFont; + int font = (int) ((((double) tag.getTotal()) / (double) max) * (MAX_FONTSIZE - MIN_FONTSIZE)) + + MIN_FONTSIZE;
buf.append("<a href="").append(LinkManager.getTagLink(tag.getTag().toString())).append( "" style="font-size: ").append(font).append("pt; margin: 8px;""); @@ -111,16 +131,93 @@ public class TagCloudView extends LocatableVLayout {
buf.append(">").append(tag.getTag()).append("</a> "); } - HTMLFlow flow = new HTMLFlow(buf.toString()); - addMember(flow); }
+ public String getSelectedTag() { + return this.selectedTag; + } + + /** + * Determines which, if any, tag is currently selected. + * + * @param selectedTag the full tag name, or <code>null</code> if nothing is selected + */ public void setSelectedTag(String selectedTag) { this.selectedTag = selectedTag; + TagReportComposite selected = getSelectedTagReportComposite(); + getDeleteButton().setDisabled(selected == null || selected.getTotal() > 0); // don't be able to delete non-existent tag or tag that is used removeMembers(getMembers()); - drawTags(tags); + drawTags(this.tags); }
+ /** + * This view can provide a delete button that, when clicked, will delete the currently + * selected tag. This view doesn't put this delete button anywhere, the caller can place + * this button where ever it deems appropriate. + * + * @return a delete button component that can be placed as a member of a canvas + */ + public IButton getDeleteButton() { + if (this.deleteButton == null) { + final IButton button = new DeleteButton(extendLocatorId("deleteButton")); + button.setIcon(REMOVE_ICON); + button.setIconWidth(16); + button.setIconHeight(16); + button.setTitle(MSG.view_tagCloud_deleteTag()); + button.setAutoFit(true); + button.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + final TagReportComposite selected = getSelectedTagReportComposite(); + if (selected != null) { + HashSet<Tag> doomedTag = new HashSet<Tag>(1); + doomedTag.add(selected.getTag()); + GWTServiceLookup.getTagService().removeTags(doomedTag, new AsyncCallback<Void>() { + @Override + public void onSuccess(Void result) { + tags.remove(selected); + CoreGUI.goToView(LinkManager.getTagLink(null)); + CoreGUI.getMessageCenter().notify( + new Message(MSG.view_tagCloud_deleteTagSuccess(selected.getTag().toString()), + Severity.Info)); + } + + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + MSG.view_tagCloud_deleteTagFailure(selected.getTag().toString()), caught); + } + }); + } + } + }); + this.deleteButton = button; + } + return this.deleteButton; + } + + private TagReportComposite getSelectedTagReportComposite() { + if (selectedTag != null && tags != null) { + for (TagReportComposite tag : tags) { + if (tag.getTag().toString().equals(selectedTag)) { + return tag; + } + } + } + return null; + } + + class DeleteButton extends LocatableIButton { + public DeleteButton(String locatorId) { + super(locatorId); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + deleteButton = null; + } + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java index 465b37c..36e2ff8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java @@ -26,9 +26,13 @@ import java.util.ArrayList;
import com.smartgwt.client.data.Criteria; import com.smartgwt.client.widgets.tab.Tab; +import com.smartgwt.client.widgets.tab.events.TabSelectedEvent; +import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
+import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.tagging.Tag; import org.rhq.enterprise.gui.coregui.client.BookmarkableView; +import org.rhq.enterprise.gui.coregui.client.ImageManager; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.bundle.deployment.BundleDeploymentListView; import org.rhq.enterprise.gui.coregui.client.bundle.destination.BundleDestinationListView; @@ -43,7 +47,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableTabSet; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/** + * The main tag cloud view which will show the actual tag cloud with a tabbed view + * underneath containing all the tables of data for the selected tag. + * * @author Greg Hinkle + * @author John Mazzitelli */ public class TaggedView extends LocatableVLayout implements BookmarkableView {
@@ -52,6 +60,7 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { private TagCloudView tagCloudView; private LocatableTabSet container; private ArrayList<Table> viewsWithTags = new ArrayList<Table>(); + private int selectedTabNum = 0;
public TaggedView(String locatorId) { super(locatorId); @@ -73,40 +82,48 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { addMember(tagCloudView); }
- @Override - protected void onDraw() { - super.onDraw(); - } - private void viewTag(String tagString) {
+ // if we are switching tags, remove all our tables - we need to recreate them with new criteria + if (tagString != null && !tagString.equals(tagCloudView.getSelectedTag())) { + destroyTagTables(); + } + tagCloudView.setSelectedTag(tagString);
- Tag tag = new Tag(tagString); + if (container == null) {
- Criteria criteria = new Criteria(); - criteria.addCriteria("tagNamespace", tag.getNamespace()); - criteria.addCriteria("tagSemantic", tag.getSemantic()); - criteria.addCriteria("tagName", tag.getName()); + Tag tag = new Tag(tagString);
- if (container == null) { + Criteria criteria = new Criteria(); + criteria.addCriteria("tagNamespace", tag.getNamespace()); + criteria.addCriteria("tagSemantic", tag.getSemantic()); + criteria.addCriteria("tagName", tag.getName());
container = new LocatableTabSet(extendLocatorId("tags")); container.setWidth100(); container.setHeight100(); - addMember(container); + container.setTabBarControls(tagCloudView.getDeleteButton()); + container.addTabSelectedHandler(new TabSelectedHandler() { + public void onTabSelected(TabSelectedEvent event) { + selectedTabNum = event.getTabNum(); + } + }); + container.setSelectedTab(selectedTabNum); // this is so we keep the same tab the user selected between tag selections
Tab tab;
BundlesListView bundlesView = new BundlesListView(getLocatorId(), criteria, null); viewsWithTags.add(bundlesView); tab = new LocatableTab(extendLocatorId("bundleList"), MSG.view_bundle_bundles()); + tab.setIcon(ImageManager.getBundleIcon()); tab.setPane(bundlesView); container.addTab(tab);
BundleVersionListView bundleVersionListView = new BundleVersionListView(getLocatorId(), criteria); viewsWithTags.add(bundleVersionListView); tab = new LocatableTab(extendLocatorId("bundleVersionList"), MSG.view_bundle_bundleVersions()); + tab.setIcon("subsystems/bundle/BundleVersion_16.png"); tab.setPane(bundleVersionListView); container.addTab(tab);
@@ -115,6 +132,7 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { false); viewsWithTags.add(bundleDeploymentListView); tab = new LocatableTab(extendLocatorId("bundleDeploymentsList"), MSG.view_bundle_bundleDeployments()); + tab.setIcon("subsystems/bundle/BundleDeployment_16.png"); tab.setPane(bundleDeploymentListView); container.addTab(tab);
@@ -122,6 +140,7 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { criteria); viewsWithTags.add(bundleDestinationListView); tab = new LocatableTab(extendLocatorId("bundleDestinationsList"), MSG.view_bundle_bundleDestinations()); + tab.setIcon("subsystems/bundle/BundleDestination_16.png"); tab.setPane(bundleDestinationListView); container.addTab(tab);
@@ -129,12 +148,15 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { .view_taggedResources_title()); viewsWithTags.add(resourceView); tab = new LocatableTab(extendLocatorId("resourceList"), MSG.view_taggedResources_title()); + tab.setIcon(ImageManager.getResourceIcon(ResourceCategory.SERVICE)); tab.setPane(resourceView); container.addTab(tab);
for (Table t : viewsWithTags) { t.setShowFooter(false); } + + addMember(container); }
for (Table t : viewsWithTags) { @@ -142,10 +164,22 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView { } }
+ private void destroyTagTables() { + if (this.container != null) { + this.viewsWithTags.clear(); + removeMember(this.container); + this.container.destroy(); + this.container = null; + } + } + public void renderView(ViewPath viewPath) { if (!viewPath.isEnd()) { String tagString = viewPath.getCurrent().getPath(); viewTag(tagString); + } else { + destroyTagTables(); + tagCloudView.setSelectedTag(null); } } } 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 fd6ac7e..a965934 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 @@ -2021,10 +2021,13 @@ view_measurementOob_title = Suspect Metrics view_tagCloud_title = Tag Cloud view_tagCloud_error_fetchFailure = Failed to load tags. view_tagCloud_error_tagUsedCount = Tag used {0} times. +view_tagCloud_deleteTag = Delete Tag +view_tagCloud_deleteTagFailure = Failed to delete the tag [{0}] +view_tagCloud_deleteTagSuccess = You successfully deleted the tag [{0}]
view_reports_inventorySummary_failFetch = Failed to get inventory summary
-view_taggedResources_title = Tagged Resources +view_taggedResources_title = Resources
view_reports_alertDefinitions_parentHover = Click to go to the parent alert definition view_reports_alertDefinitions_resTypeLoadError = Cannot get the template resource type - unable to view the alert template.
commit 1385a03d7363cda58358d929349f67e3cf24dd7c Author: John Mazzitelli mazz@redhat.com Date: Tue Mar 29 15:43:05 2011 -0400
- remove refresh button - add the recent alert count number next to the alert flag
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java index 5a9d3fc..88e7a9b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/Footer.java @@ -87,7 +87,9 @@ public class Footer extends LocatableHLayout {
addMember(getMessageCenterButton());
- addMember(getRefreshButton()); + // people don't like the refresh and CoreGUI.refresh() isn't refreshing everything I want + // if we ever want to reintroduce the refresh button to manually call CoreGUI.refresh(), just uncomment this line + // addMember(getRefreshButton());
addMember(createHSpacer(0));
@@ -195,13 +197,15 @@ public class Footer extends LocatableHLayout { private void changeIcon(int alertCount) { if (alertCount == 0) { setPrompt(MSG.view_core_noRecentAlerts()); - setContents(imgHTML("subsystems/alert/Alerts_16.png", 16, 16)); + setContents(imgHTML("subsystems/alert/Alerts_16.png", 16, 16) + + "<span style="display:inline-block; vertical-align:middle">0</span>"); } else { setPrompt(MSG.view_core_recentAlerts(String.valueOf(alertCount))); String link = '#' + ReportTopView.VIEW_ID.getName() + "/" + ReportTopView.SECTION_SUBSYSTEMS_VIEW_ID + "/" + AlertHistoryView.SUBSYSTEM_VIEW_ID; setContents("<a href="" + link + "">" + imgHTML(ImageManager.getAlertIcon(AlertPriority.HIGH)) - + "</a>"); + + "<span style="display:inline-block; vertical-align:middle">" + String.valueOf(alertCount) + + "</span></a>"); } }
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 695bd9d..fd6ac7e 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 @@ -2057,7 +2057,7 @@ view_aboutBox_version = Version: view_core_error_1 = New Alerts lookup failed #view_core_loggedInAs = Logged in as {0} view_core_loggedOut = Logged out -view_core_recentAlerts = There are [{0}] recent alerts - click the icon to go to the recent alerts report +view_core_recentAlerts = There are [{0}] recent alerts - click to go to the recent alerts report view_core_noRecentAlerts = There are no recent alerts to report view_core_uncaught = Globally uncaught exception
rhq-commits@lists.fedorahosted.org