modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
| 136 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
| 18 -
3 files changed, 81 insertions(+), 75 deletions(-)
New commits:
commit 3c5a00e40f93589f3fd333502d3b0d4ffde0c743
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 22:19:06 2010 -0400
cosmetic - reformatting
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 242aa4b..8da5ef0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -82,6 +82,7 @@ public class MessageBar extends LocatableHLayout implements
MessageCenter.Messag
clearMessage();
this.label = createLabel(message);
+
addMember(this.label);
markForRedraw();
commit 4288e5e7ec99e01767be54eb91a2698b2e515036
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 22:18:48 2010 -0400
tweak display of top/center message
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index 02d3e33..242aa4b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -40,8 +40,7 @@ public class MessageBar extends LocatableHLayout implements
MessageCenter.Messag
private static final String LOCATOR_ID = "MessageBar";
private static final int AUTO_HIDE_DELAY_MILLIS = 30000; // 30 seconds
- private static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP
=
- new HashMap<Message.Severity, String>();
+ private static final Map<Message.Severity, String> SEVERITY_TO_STYLE_NAME_MAP =
new HashMap<Message.Severity, String>();
static {
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Info, "InfoBlock");
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Warning, "WarnBlock");
@@ -49,8 +48,7 @@ public class MessageBar extends LocatableHLayout implements
MessageCenter.Messag
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Fatal, "FatalBlock");
}
- private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP =
- new HashMap<Message.Severity, String>();
+ private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP = new
HashMap<Message.Severity, String>();
static {
SEVERITY_TO_ICON_MAP.put(Message.Severity.Info,
"info/icn_info_blue.png");
SEVERITY_TO_ICON_MAP.put(Message.Severity.Warning,
"info/icn_info_orange.png");
@@ -70,7 +68,6 @@ public class MessageBar extends LocatableHLayout implements
MessageCenter.Messag
super.onDraw();
setWidth100();
- setAutoHeight();
setHeight(35);
setAlign(Alignment.CENTER);
@@ -112,17 +109,15 @@ public class MessageBar extends LocatableHLayout implements
MessageCenter.Messag
private Label createLabel(Message message) {
Label label = new Label();
- String contents = (message.getConciseMessage() != null) ?
- message.getConciseMessage() : message.getDetailedMessage();
+ String contents = (message.getConciseMessage() != null) ?
message.getConciseMessage() : message
+ .getDetailedMessage();
label.setContents(contents);
+ label.setAlign(Alignment.CENTER);
String styleName = (contents != null) ?
SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity()) : null;
label.setStyleName(styleName);
- label.setAutoHeight();
- label.setHeight(30);
- label.setAutoWidth();
- label.setWidth("75%");
+ label.setWidth(400);
String icon = (contents != null) ?
SEVERITY_TO_ICON_MAP.get(message.getSeverity()) : null;
label.setIcon(icon);
commit be9e31c733dcb1e75299025ed32caa3af28584a1
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 19:14:57 2010 -0400
minor fixes to SearchBarPanel for maintainability
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
index 0d920ef..657c4d3 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/menu/SearchBarPane.java
@@ -29,7 +29,6 @@ import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.grid.ListGridField;
@@ -44,6 +43,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
/**
* @author Greg Hinkle
+ * @author Joseph Marques
*/
public class SearchBarPane extends LocatableHLayout {
@@ -54,6 +54,31 @@ public class SearchBarPane extends LocatableHLayout {
setHeight(28);
}
+ public enum SearchType {
+ RESOURCE("Resources"), //
+ GROUP("Resource Groups");
+
+ private String displayName;
+
+ private SearchType(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public static String[] getValueMap() {
+ SearchType[] searchTypes = SearchType.values();
+ String[] results = new String[searchTypes.length];
+ int i = 0;
+ for (SearchType nextType : searchTypes) {
+ results[i++] = nextType.getDisplayName();
+ }
+ return results;
+ }
+ }
+
@Override
protected void onDraw() {
super.onDraw();
@@ -63,9 +88,10 @@ public class SearchBarPane extends LocatableHLayout {
form.setColWidths("120", "140", "400");
final SelectItem searchType = new SelectItem("searchType",
"Search");
+ String[] valueMap = SearchType.getValueMap();
+ searchType.setValueMap(valueMap);
+ searchType.setValue(valueMap[0]);
searchType.setWidth(120);
- searchType.setValueMap("Resources", "Resource Groups"/*,
"Bundles", "Packages", "Users", "Roles"*/);
- searchType.setValue("Resources");
searchType.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
@@ -74,21 +100,7 @@ public class SearchBarPane extends LocatableHLayout {
});
ComboBoxItem resourceSearch = getResourceComboBox();
- resourceSearch.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm)
{
- return
form.getValueAsString("searchType").equals("Resources");
- }
- });
-
ComboBoxItem groupSearch = getGroupComboBox();
- groupSearch.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm)
{
- return
form.getValueAsString("searchType").equals("Resource Groups");
- }
- });
-
- TextItem query = new TextItem("query");
- query.setShowTitle(false);
ButtonItem search = new ButtonItem("Search", "Search");
search.setStartRow(false);
@@ -102,14 +114,7 @@ public class SearchBarPane extends LocatableHLayout {
}
private ComboBoxItem getResourceComboBox() {
-
- final ComboBoxItem comboBox = new ComboBoxItem("query",
"Query");
- comboBox.setWidth(400);
- comboBox.setShowTitle(false);
- comboBox.setHint("resource search");
- comboBox.setShowHintInField(true);
-
- comboBox.setOptionDataSource(new ResourceDatasource());
+ final ComboBoxItem comboBox = getBaseComboBox(SearchType.RESOURCE);
ListGridField nameField = ResourceDataSourceField.NAME.getListGridField(250);
ListGridField descriptionField =
ResourceDataSourceField.DESCRIPTION.getListGridField();
@@ -124,38 +129,13 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setValueField("id");
comboBox.setDisplayField(ResourceDataSourceField.NAME.propertyName());
- comboBox.setPickListWidth(800);
- comboBox.setTextMatchStyle(TextMatchStyle.SUBSTRING);
- comboBox.setCompleteOnTab(true);
-
- comboBox.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- try {
- Integer resourceId = (Integer) changedEvent.getValue();
- comboBox.setValue("");
-
- String link = LinkManager.getResourceLink(resourceId);
- if (!link.contains("#")) {
- com.google.gwt.user.client.Window.Location.assign(link);
- } else {
- History.newItem(link.substring(1));
- }
- } catch (Exception e) {
- }
- }
- });
+ comboBox.setOptionDataSource(new ResourceDatasource());
return comboBox;
}
private ComboBoxItem getGroupComboBox() {
- final ComboBoxItem comboBox = new ComboBoxItem("query",
"Query");
- comboBox.setWidth(400);
- comboBox.setShowTitle(false);
- comboBox.setHint("group search");
- comboBox.setShowHintInField(true);
-
- comboBox.setOptionDataSource(new ResourceGroupsDataSource());
+ final ComboBoxItem comboBox = getBaseComboBox(SearchType.GROUP);
ListGridField nameField =
ResourceGroupDataSourceField.NAME.getListGridField(250);
ListGridField descriptionField =
ResourceGroupDataSourceField.DESCRIPTION.getListGridField();
@@ -167,27 +147,57 @@ public class SearchBarPane extends LocatableHLayout {
comboBox.setValueField("id");
comboBox.setDisplayField(ResourceGroupDataSourceField.NAME.propertyName());
+ comboBox.setOptionDataSource(new ResourceGroupsDataSource());
+
+ return comboBox;
+ }
+
+ private ComboBoxItem getBaseComboBox(final SearchType searchType) {
+ final ComboBoxItem comboBox = new ComboBoxItem("query",
"Query");
+ comboBox.setWidth(400);
+ comboBox.setShowTitle(false);
+ comboBox.setHint("search");
+ comboBox.setShowHintInField(true);
+
comboBox.setPickListWidth(800);
comboBox.setTextMatchStyle(TextMatchStyle.SUBSTRING);
comboBox.setCompleteOnTab(true);
comboBox.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
- try {
- Integer groupId = (Integer) changedEvent.getValue();
- comboBox.setValue("");
-
- String link = LinkManager.getResourceGroupLink(groupId);
- if (!link.contains("#")) {
- com.google.gwt.user.client.Window.Location.assign(link);
- } else {
- History.newItem(link.substring(1));
- }
- } catch (Exception e) {
+ //System.out.println("ChangedEvent: " +
changedEvent.getValue());
+
+ Object intermediate = changedEvent.getValue();
+ if (!(intermediate instanceof Integer)) {
+ return;
+ }
+
+ Integer id = (Integer) changedEvent.getValue();
+ comboBox.setValue("");
+
+ String link = null;
+ if (searchType == SearchType.RESOURCE) {
+ link = LinkManager.getResourceLink(id);
+ } else if (searchType == SearchType.GROUP) {
+ link = LinkManager.getResourceGroupLink(id);
+ } else {
+ throw new IllegalArgumentException("There is no global search
type for " + searchType);
+ }
+
+ if (!link.contains("#")) {
+ com.google.gwt.user.client.Window.Location.assign(link);
+ } else {
+ History.newItem(link.substring(1));
}
}
});
+ comboBox.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm)
{
+ return
dynamicForm.getValueAsString("searchType").equals(searchType.getDisplayName());
+ }
+ });
+
return comboBox;
}
commit acf0d09358c36e094bb041ebf5106a921009a51a
Author: Joseph Marques <joseph(a)redhat.com>
Date: Thu Sep 30 17:30:43 2010 -0400
prevent exceptions when using integer-based filters that might pass empty string
instead of null
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 1184697..a717108 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -286,7 +286,7 @@ public abstract class RPCDataSource<T> extends DataSource {
S result = null;
Object value = criteriaMap.get(paramName);
- if (value == null) {
+ if (value == null || value.toString().equals("")) {
// nothing to do, result is already null
} else {
String strValue = value.toString();