modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
| 25 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotDriftDetailsView.java
| 82 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotView.java
| 136 ++++------
4 files changed, 147 insertions(+), 100 deletions(-)
New commits:
commit e3f2d0fb110f7bda3e4fbf4f14a6b829f1bcefbb
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Oct 28 12:59:00 2011 -0400
Change DriftSnapshotView to inline drift details via another level of
expanded rows. This removes a lot of complicated navigation in the UI
(deep anchors, back button issues, lack of context). It also ends up
taking advantage of all the snapshot context already on the page, and
keeping the user in one consolidated, robust snapshot view.
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 1985cd4..d3ef464 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
@@ -528,20 +528,6 @@ public class LinkManager {
return "#Resource/" + resourceId + "/Drift/Definitions/" +
driftDefId + "/Snapshot/" + version;
}
- public static String getDriftCarouselSnapshotDriftLink(int resourceId, int
driftDefId, int version, String driftId) {
- if (!driftId.startsWith(StringIDTableSection.ID_PREFIX)) {
- driftId = StringIDTableSection.ID_PREFIX + driftId;
- }
-
- // TODO: for now, just make this the same as the carousel drift link. The
downside is that the back button
- // will bring us back to the carousel and not the snapshot view. Eventually would
like another
- // master-detail relationship here, but it's hairy to get this working.
- //
- // return "#Resource/" + resourceId + "/Drift/Definitions/" +
driftDefId + "/Snapshot/" + version + "/" + driftId;
-
- return getDriftCarouselDriftLink(resourceId, driftDefId, driftId);
- }
-
public static String getDriftTemplateLink(int typeId, int templateId) {
String result =
getAdminTemplatesEditLink(DriftDefinitionTemplateTypeView.VIEW_ID.getName(), typeId);
@@ -553,15 +539,4 @@ public class LinkManager {
return result + "/Snapshot";
}
-
- public static String getDriftTemplateSnapshotDriftLink(int typeId, int templateId,
String driftId) {
- String result = getDriftTemplateSnapshotLink(typeId, templateId);
-
- if (!driftId.startsWith(StringIDTableSection.ID_PREFIX)) {
- driftId = StringIDTableSection.ID_PREFIX + driftId;
- }
-
- return result + "/" + driftId;
- }
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
index 8d7baf5..1dcf23b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftDetailsView.java
@@ -88,7 +88,7 @@ public class DriftDetailsView extends LocatableVLayout {
}
- private void show(DriftDetails driftDetails) {
+ protected void show(DriftDetails driftDetails) {
for (Canvas child : getMembers()) {
removeMember(child);
child.destroy();
@@ -223,7 +223,7 @@ public class DriftDetailsView extends LocatableVLayout {
return changeSetForm;
}
- private FormItem createViewFileLink(String hash, String path, int version,
DriftFileStatus status) {
+ protected FormItem createViewFileLink(String hash, String path, int version,
DriftFileStatus status) {
if (status == LOADED) {
return createViewFileLink(hash, path, version);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotDriftDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotDriftDetailsView.java
new file mode 100644
index 0000000..549d43c
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotDriftDetailsView.java
@@ -0,0 +1,82 @@
+/*
+ * RHQ Management Platform
+ * Copyright 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.
+ *
+ * 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.drift;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.drift.DriftDetails;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * Similar to {@link DriftDetailsView} but omits information already present from the
context of the
+ * snapshot view.
+ *
+ * @author Jay Shaughnessy
+ */
+public class DriftSnapshotDriftDetailsView extends DriftDetailsView {
+
+ public DriftSnapshotDriftDetailsView(String locatorId, String driftId) {
+ super(locatorId, driftId);
+ }
+
+ @Override
+ protected void show(DriftDetails driftDetails) {
+ for (Canvas child : getMembers()) {
+ removeMember(child);
+ child.destroy();
+ }
+
+ DynamicForm driftForm = new
LocatableDynamicForm(extendLocatorId("form"));
+ //driftForm.setIsGroup(true);
+ //driftForm.setGroupTitle(MSG.view_tabs_common_drift());
+ driftForm.setWrapItemTitles(false);
+ driftForm.setNumCols(4);
+
+ SpacerItem spacer = new SpacerItem();
+
+ //StaticTextItem id = new StaticTextItem("id", MSG.common_title_id());
+ //id.setValue(driftDetails.getDrift().getId());
+
+ StaticTextItem path = new StaticTextItem("path",
MSG.common_title_path());
+ path.setValue(driftDetails.getDrift().getPath());
+
+ StaticTextItem file = new StaticTextItem("File",
MSG.view_tabs_common_content());
+ FormItem fileLink = null;
+
+ if (driftDetails.isBinaryFile()) {
+ file.setValue(driftDetails.getDrift().getNewDriftFile().getHashId());
+ fileLink = spacer;
+ driftForm.setItems(path, spacer, file, fileLink);
+
+ } else {
+ file.setValue(driftDetails.getDrift().getNewDriftFile().getHashId());
+ fileLink =
createViewFileLink(driftDetails.getDrift().getNewDriftFile().getHashId(), driftDetails
+ .getDrift().getPath(), driftDetails.getChangeSet().getVersion(),
driftDetails.getNewFileStatus());
+ driftForm.setItems(path, spacer, file, fileLink);
+ }
+
+ addMember(driftForm);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotView.java
index e0996eb..e02f23e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftSnapshotView.java
@@ -29,16 +29,19 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.Autofit;
import com.smartgwt.client.types.ExpansionMode;
import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-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;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
+import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
+import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
import org.rhq.core.domain.criteria.DriftDefinitionCriteria;
import org.rhq.core.domain.criteria.DriftDefinitionTemplateCriteria;
@@ -53,7 +56,6 @@ 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.StringIDTableSection;
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;
@@ -63,7 +65,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A view that displays a nested table view of a snapshot. The outer table is a list of
directories in the snapshot
@@ -72,8 +73,6 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
*
* @author Jay Shaughnessy
*/
-// TODO: Make this extend an abstract table so we can set up true master-detail
-//public class DriftSnapshotView extends
StringIDTableSection<DriftSnapshotDataSource> {
public class DriftSnapshotView extends Table<DriftSnapshotDataSource> {
private static final String DEFAULT_TITLE = MSG.view_drift_table_snapshot();
@@ -84,7 +83,6 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
private boolean hasWriteAccess;
private String templateChangeSetId;
- private int templateResourceTypeId;
protected DriftSnapshotDataSource dataSource;
protected DriftSnapshotListGrid listGrid;
@@ -134,7 +132,7 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
@Override
protected void onDraw() {
- // Drift def snapshot view
+ // Drift def snapshot view or template pinned snapshot?
if (null != this.driftDefId) {
DriftDefinitionCriteria defCriteria = new DriftDefinitionCriteria();
defCriteria.addFilterId(driftDefId);
@@ -177,7 +175,7 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
String templateName = template.getName();
String title =
MSG.view_drift_table_title_templateSnapshot(templateName);
setTitleString(title);
- templateResourceTypeId = template.getResourceType().getId();
+
DriftSnapshotView.super.onDraw();
}
});
@@ -247,6 +245,9 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
setCanExpandRecords(true);
setCanExpandMultipleRecords(true);
setExpansionMode(ExpansionMode.RELATED);
+
+ //setDefaultHeight(10);
+ //setAutoFitData(Autofit.VERTICAL);
}
@Override
@@ -258,7 +259,8 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
}
}
- public class DirectoryView extends
StringIDTableSection<DirectoryView.DirectoryViewDataSource> {
+ //public class DirectoryView extends
StringIDTableSection<DirectoryView.DirectoryViewDataSource> {
+ public class DirectoryView extends Table<DirectoryView.DirectoryViewDataSource>
{
private String directory;
private DirectoryViewDataSource dataSource;
@@ -273,7 +275,8 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
setShowFooter(false);
setWidth100();
- setHeight(250);
+ setAutoHeight();
+ setOverflow(Overflow.VISIBLE);
setDataSource(getDataSource());
}
@@ -289,56 +292,65 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
}
@Override
+ protected LocatableListGrid createListGrid(String locatorId) {
+ return new DirectoryViewListGrid(locatorId);
+ }
+
+ @Override
protected void configureTable() {
ArrayList<ListGridField> dataSourceFields =
getDataSource().getListGridFields();
getListGrid().setFields(dataSourceFields.toArray(new
ListGridField[dataSourceFields.size()]));
super.configureTable();
+ }
- // TODO: when we have true detail support then we'll want to remove this.
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length == 1) {
- String driftId = getId(selectedRows[0]);
- String link = (null == templateId) ?
LinkManager.getDriftCarouselSnapshotDriftLink(resourceId,
- driftDefId, version, driftId) :
LinkManager.getDriftTemplateSnapshotDriftLink(
- templateResourceTypeId, templateId, driftId);
- CoreGUI.goToView(link);
+ private class DirectoryViewListGrid extends LocatableListGrid {
- }
- }
- });
- }
+ public DirectoryViewListGrid(String locatorId) {
+ super(locatorId);
- @Override
- protected String getDetailsLinkColumnName() {
- return DriftDataSource.ATTR_CTIME;
- }
+ setCanExpandRecords(true);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.RELATED);
- @Override
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- // TODO: provide a drift detail view for the template snapshot view
- if (null == templateId) {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int
i1) {
- String driftId = getId(record);
- String link = (null == templateId) ?
LinkManager.getDriftCarouselSnapshotDriftLink(resourceId,
- driftDefId, version, driftId) :
LinkManager.getDriftTemplateSnapshotDriftLink(
- templateResourceTypeId, templateId, driftId);
-
- String formattedValue = TimestampCellFormatter.format(value);
- return SeleniumUtility.getLocatableHref(link, formattedValue,
null);
+ setDefaultHeight(10);
+ setAutoFitData(Autofit.VERTICAL);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+
+ @Override
+ public void onRecordExpand(RecordExpandEvent event) {
+ event.getRecord().setAttribute("Expanded", true);
}
- };
- } else {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int
i1) {
- return TimestampCellFormatter.format(value);
+ });
+
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent event) {
+ event.getRecord().setAttribute("Expanded", false);
}
- };
+ });
+
+ }
+
+ @Override
+ protected String getCellCSSText(ListGridRecord record, int rowNum, int
colNum) {
+
+ if
(Boolean.TRUE.equals(record.getAttributeAsBoolean("Expanded"))) {
+ return "background-color:#ffffcc;";
+ }
+
+ return super.getCellCSSText(record, rowNum, colNum);
+
+ }
+
+ @Override
+ protected Canvas getExpansionComponent(ListGridRecord record) {
+
+ String driftId = record.getAttribute(DriftDataSource.ATTR_ID);
+
+ return new DriftSnapshotDriftDetailsView(extendLocatorId(driftId),
driftId);
}
}
@@ -491,11 +503,6 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
return record;
}
}
-
- @Override
- public Canvas getDetailsView(String driftId) {
- return new DriftDetailsView(extendLocatorId("Details"), driftId);
- }
}
/**
@@ -513,21 +520,4 @@ public class DriftSnapshotView extends
Table<DriftSnapshotDataSource> {
return (i < 0) ? path.trim() : path.substring(++i).trim();
}
-
- // TODO: Make this extend an abstract table so we can set up true master-detail
-
- /*
- @Override
- public void renderView(ViewPath viewPath) {
- viewPath.next();
- super.renderView(viewPath);
- }
-
-
- @Override
- public Canvas getDetailsView(String driftId) {
- return new DriftDetailsView(extendLocatorId("Details"), driftId);
- }
- */
-
}