modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java | 1 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java | 7 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java | 125 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java | 75 ++++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 75 +++--- 5 files changed, 237 insertions(+), 46 deletions(-)
New commits: commit a13969c550099c19bbeb3cbad76df38ec4391cb5 Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 26 15:32:17 2010 -0400
show bundle versions at the bottom right of the bundle view
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java new file mode 100644 index 0000000..9a576a6 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleVersionDataSource.java @@ -0,0 +1,125 @@ +/* + * 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.bundle.list; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.fields.DataSourceIntegerField; +import com.smartgwt.client.data.fields.DataSourceTextField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.bundle.BundleVersion; +import org.rhq.core.domain.criteria.BundleVersionCriteria; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.gwt.BundleGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; + +/** + * @author John Mazzitelli + */ +public class BundleVersionDataSource extends RPCDataSource<BundleVersion> { + + private BundleGWTServiceAsync bundleService = GWTServiceLookup.getBundleService(); + private int bundleId; + + public BundleVersionDataSource() { + DataSourceIntegerField idField = new DataSourceIntegerField("id", "ID"); + idField.setPrimaryKey(true); + addField(idField); + + DataSourceTextField nameField = new DataSourceTextField("name", "Name"); + addField(nameField); + + DataSourceTextField descriptionField = new DataSourceTextField("description", "Description"); + addField(descriptionField); + + DataSourceTextField latestVersionField = new DataSourceTextField("version", "Version"); + addField(latestVersionField); + + DataSourceIntegerField deploymentCountField = new DataSourceIntegerField("fileCount", "File Count"); + addField(deploymentCountField); + } + + public int getBundleId() { + return bundleId; + } + + public void setBundleId(int bundleId) { + this.bundleId = bundleId; + } + + @Override + protected void executeFetch(final DSRequest request, final DSResponse response) { + + BundleVersionCriteria criteria = new BundleVersionCriteria(); + criteria.addFilterBundleId(this.bundleId); + criteria.fetchBundleFiles(true); + criteria.setPageControl(getPageControl(request)); + + bundleService.findBundleVersionsByCriteria(criteria, new AsyncCallback<PageList<BundleVersion>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError("Failed to load bundle version data", caught); + response.setStatus(DSResponse.STATUS_FAILURE); + processResponse(request.getRequestId(), response); + } + + public void onSuccess(PageList<BundleVersion> result) { + response.setData(buildRecords(result)); + response.setTotalRows(result.getTotalSize()); + processResponse(request.getRequestId(), response); + } + }); + + } + + @Override + public BundleVersion copyValues(ListGridRecord from) { + // can't I just get the "object" attribute and return it??? + Integer idAttrib = from.getAttributeAsInt("id"); + String nameAttrib = from.getAttribute("name"); + String descriptionAttrib = from.getAttribute("description"); + String versionAttrib = from.getAttribute("version"); + + BundleVersion bv = new BundleVersion(); + bv.setId(idAttrib.intValue()); + bv.setName(nameAttrib); + bv.setDescription(descriptionAttrib); + bv.setVersion(versionAttrib); + return bv; + } + + @Override + public ListGridRecord copyValues(BundleVersion from) { + ListGridRecord record = new ListGridRecord(); + + record.setAttribute("id", from.getId()); + record.setAttribute("name", from.getName()); + record.setAttribute("description", from.getDescription()); + record.setAttribute("version", from.getVersion()); + record.setAttribute("fileCount", Integer.valueOf(from.getBundleFiles().size())); + + record.setAttribute("object", from); + + return record; + + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java index 4d7575e..be0e415 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/list/BundleView.java @@ -21,6 +21,8 @@ package org.rhq.enterprise.gui.coregui.client.bundle.list; import com.smartgwt.client.data.Record; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.Overflow; +import com.smartgwt.client.types.SelectionAppearance; +import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.DynamicForm; @@ -32,6 +34,7 @@ import com.smartgwt.client.widgets.tab.TabSet; import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel; +import org.rhq.enterprise.gui.coregui.client.components.table.Table;
public class BundleView extends VLayout {
@@ -41,6 +44,7 @@ public class BundleView extends VLayout { private HeaderLabel headerLabel; private StaticTextItem descriptionItem; private StaticTextItem latestVersionItem; + private Table bundleVersionsTable;
public BundleView() { super(); @@ -77,11 +81,30 @@ public class BundleView extends VLayout { }
private Tab createDeploymentsTab() { - return new Tab("Deployments"); + Tab deploymentsTab = new Tab("Deployments"); + return deploymentsTab; }
private Tab createVersionsTab() { - return new Tab("Versions"); + Tab versionsTab = new Tab("Versions"); + + bundleVersionsTable = new Table(); + bundleVersionsTable.setHeight100(); + + BundleVersionDataSource bundleVersionsDataSource = new BundleVersionDataSource(); + bundleVersionsTable.setDataSource(bundleVersionsDataSource); + + bundleVersionsTable.getListGrid().getField("id").setWidth("60"); + bundleVersionsTable.getListGrid().getField("name").setWidth("25%"); + bundleVersionsTable.getListGrid().getField("version").setWidth("10%"); + bundleVersionsTable.getListGrid().getField("fileCount").setWidth("10%"); + bundleVersionsTable.getListGrid().getField("description").setWidth("*"); + + bundleVersionsTable.getListGrid().setSelectionType(SelectionStyle.NONE); + bundleVersionsTable.getListGrid().setSelectionAppearance(SelectionAppearance.ROW_STYLE); + + versionsTab.setPane(bundleVersionsTable); + return versionsTab; }
private Tab createSummaryTab() { @@ -109,21 +132,39 @@ public class BundleView extends VLayout { }
public void viewRecord(Record record) { - final BundleWithLatestVersionComposite object; - object = (BundleWithLatestVersionComposite) record.getAttributeAsObject("object"); - - if (bundleBeingViewed != object.getBundleId()) { - headerLabel.setContents(object.getBundleName()); - latestVersionItem.setValue(object.getLatestVersion()); - descriptionItem.setValue(object.getBundleDescription()); - } - - try { - message.hide(); - canvas.show(); - markForRedraw(); - } catch (Throwable t) { - CoreGUI.getErrorHandler().handleError("Cannot view bundle record", t); + if (record == null) { + viewNone(); + } else { + final BundleWithLatestVersionComposite object; + object = (BundleWithLatestVersionComposite) record.getAttributeAsObject("object"); + + if (object == null) { + viewNone(); + } else { + if (bundleBeingViewed != object.getBundleId()) { + bundleBeingViewed = object.getBundleId(); + + // summary tab + headerLabel.setContents(object.getBundleName()); + latestVersionItem.setValue(object.getLatestVersion()); + descriptionItem.setValue(object.getBundleDescription()); + + // versions tab + BundleVersionDataSource bvDataSource; + bvDataSource = (BundleVersionDataSource) bundleVersionsTable.getDataSource(); + bvDataSource.setBundleId(bundleBeingViewed); + bvDataSource.fetchData(); + bundleVersionsTable.getListGrid().invalidateCache(); // TODO: is there a better way to refresh? + } + + try { + message.hide(); + canvas.show(); + markForRedraw(); + } catch (Throwable t) { + CoreGUI.getErrorHandler().handleError("Cannot view bundle record", t); + } + } } }
commit 8bfd48b11e356dab8b7621d615fa83916782257f Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 26 15:31:55 2010 -0400
be able to go to next step when no files need to be uploaded
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java index e241771..7baec2f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleUploadDataStep.java @@ -47,6 +47,7 @@ public class BundleUploadDataStep implements WizardStep { private final AbstractBundleCreateWizard wizard; private final BundleGWTServiceAsync bundleServer = GWTServiceLookup.getBundleService(); private ArrayList<BundleFileUploadForm> uploadForms; + private Boolean noFilesNeedToBeUploaded = null; // will be non-null when we know the answer
public BundleUploadDataStep(AbstractBundleCreateWizard bundleCreationWizard) { this.wizard = bundleCreationWizard; @@ -84,6 +85,10 @@ public class BundleUploadDataStep implements WizardStep { }
private boolean isFinished() { + if (noFilesNeedToBeUploaded != null && noFilesNeedToBeUploaded.booleanValue()) { + return true; + } + if (wizard.getAllBundleFilesStatus() == null) { return false; } @@ -114,9 +119,11 @@ public class BundleUploadDataStep implements WizardStep { label.setWidth100(); mainLayout.addMember(label); uploadForms = null; + noFilesNeedToBeUploaded = Boolean.TRUE; return; }
+ noFilesNeedToBeUploaded = Boolean.FALSE; uploadForms = new ArrayList<BundleFileUploadForm>();
for (Map.Entry<String, Boolean> entry : allFilesStatus.entrySet()) {
commit 1ad47adb952bab44b66c973f535f638c447ac492 Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 26 15:19:44 2010 -0400
allow for a non-titled table
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index 1c7c68c..e56c48f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -83,6 +83,10 @@ public class Table extends VLayout {
private ArrayList<TableActionInfo> tableActions = new ArrayList<TableActionInfo>();
+ public Table() { + this(null, null, null, null, true); + } + public Table(String tableTitle) { this(tableTitle, null, null, null, true); } @@ -100,10 +104,11 @@ public class Table extends VLayout { }
public Table(String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers, String[] excludedFieldNames) { - this(tableTitle,criteria,sortSpecifiers,excludedFieldNames,true); + this(tableTitle, criteria, sortSpecifiers, excludedFieldNames, true); } + public Table(String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers, String[] excludedFieldNames, - boolean autoFetchData) { + boolean autoFetchData) { super();
setWidth100(); @@ -111,11 +116,7 @@ public class Table extends VLayout {
// Title title = new HTMLFlow(); - title.setWidth100(); - title.setHeight(35); - title.setContents(tableTitle); - title.setPadding(4); - title.setStyleName("HeaderLabel"); + setTableTitle(tableTitle);
// Grid listGrid = new ListGrid(); @@ -169,7 +170,8 @@ public class Table extends VLayout { public void onClick(ClickEvent clickEvent) { if (tableAction.confirmMessage != null) {
- String message = tableAction.confirmMessage.replaceAll("\#", String.valueOf(listGrid.getSelection().length)); + String message = tableAction.confirmMessage.replaceAll("\#", String.valueOf(listGrid + .getSelection().length));
SC.ask(message, new BooleanCallback() { public void execute(Boolean confirmed) { @@ -213,9 +215,8 @@ public class Table extends VLayout { } });
- // TODO GH: This doesn't yet work as desired to force the fields to fit to the table when you resize one of them. - if (false) { // If Force Fit + if (false) { // If Force Fit listGrid.addDataArrivedHandler(new DataArrivedHandler() { public void onDataArrived(DataArrivedEvent dataArrivedEvent) { for (ListGridField f : listGrid.getFields()) { @@ -273,14 +274,30 @@ public class Table extends VLayout { private ArrayList<Integer> fieldSizes = new ArrayList<Integer>(); private boolean autoSizing = false;
- public void refresh(Criteria criteria) { this.listGrid.setCriteria(criteria); this.listGrid.markForRedraw(); }
- public void setTableTitle(String title) { - this.title.setContents(title); + public void setTableTitle(String titleString) { + if (titleString == null) { + titleString = ""; + } + if (titleString.length() > 0) { + title.setWidth100(); + title.setHeight(35); + title.setContents(titleString); + title.setPadding(4); + title.setStyleName("HeaderLabel"); + } else { + title.setWidth100(); + title.setHeight(0); + title.setContents(null); + title.setPadding(0); + title.setStyleName("normal"); + } + + title.markForRedraw(); }
public void setDataSource(RPCDataSource dataSource) { @@ -299,7 +316,8 @@ public class Table extends VLayout { this.addTableAction(title, null, null, tableAction); }
- public void addTableAction(String title, SelectionEnablement enablement, String confirmation, TableAction tableAction) { + public void addTableAction(String title, SelectionEnablement enablement, String confirmation, + TableAction tableAction) { if (enablement == null) { enablement = DEFAULT_SELECTION_ENABLEMENT; } @@ -313,27 +331,26 @@ public class Table extends VLayout { for (TableActionInfo tableAction : tableActions) { boolean enabled; switch (tableAction.enablement) { - case ALWAYS: - enabled = true; - break; - case ANY: - enabled = (count >= 1); - break; - case SINGLE: - enabled = (count == 1); - break; - case MULTIPLE: - enabled = (count > 1); - break; - default: - throw new IllegalStateException("Unhandled SelectionEnablement: " + tableAction.enablement.name()); + case ALWAYS: + enabled = true; + break; + case ANY: + enabled = (count >= 1); + break; + case SINGLE: + enabled = (count == 1); + break; + case MULTIPLE: + enabled = (count > 1); + break; + default: + throw new IllegalStateException("Unhandled SelectionEnablement: " + tableAction.enablement.name()); } tableAction.actionButton.setDisabled(!enabled); } this.tableInfo.setContents("Total: " + listGrid.getTotalRows() + " (" + count + " selected)"); }
- // -------------- Inner utility class -------------
private static class TableActionInfo {
commit cf3888c51458c009411d1ccee4e4b3becfe336c3 Author: John Mazzitelli mazz@redhat.com Date: Fri Mar 26 15:18:53 2010 -0400
put the summary data in the same location as the other steps (via margin)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java index ffa143a..c010952 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/create/BundleSummaryStep.java @@ -41,6 +41,7 @@ public class BundleSummaryStep implements WizardStep {
DynamicForm form = new DynamicForm(); form.setNumCols(2); + form.setMargin(20);
StaticTextItem bundleTypeLabel = new StaticTextItem("bundleType", "Type"); bundleTypeLabel.setTitleAlign(Alignment.LEFT);
rhq-commits@lists.fedorahosted.org