From ffddda8ab22eb6062b28213d12d4b1325debcf76 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Mon, 17 Jan 2011 20:29:46 +0000 Subject: [PATCH] [LMS-1949] partly implemented refreshing of managed properties SVN: 19451 --- .../application/DisposableTabContent.java | 12 +++- .../application/ManagedPropertySection.java | 34 +++++++--- .../ui/grid/AbstractBrowserGrid.java | 2 +- .../managed_property/ManagedPropertyGrid.java | 65 +++++++++++++++++-- .../ManagedPropertyGridGeneratedCallback.java | 22 +++++-- .../application/ui/report/ReportGrid.java | 2 +- 6 files changed, 111 insertions(+), 26 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableTabContent.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableTabContent.java index 96e2feeb12b..2807370200c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableTabContent.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/DisposableTabContent.java @@ -66,7 +66,7 @@ abstract public class DisposableTabContent extends TabContent } } - protected void updateContent(IDisposableComponent content, boolean syncNeeded) + private void updateContent(IDisposableComponent content, boolean syncNeeded) { if (content != null) { @@ -77,4 +77,14 @@ abstract public class DisposableTabContent extends TabContent } } } + + protected void replaceContent(IDisposableComponent content) + { + if (content != null) + { + removeAll(); + disposeComponents(); + updateContent(content, true); + } + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java index 383e48918c6..b540403c6c0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ManagedPropertySection.java @@ -29,6 +29,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework. import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.managed_property.ManagedPropertyGridGeneratedCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.managed_property.ManagedPropertyGridGeneratedCallback.IOnGridComponentGeneratedAction; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableModelReference; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IManagedPropertyGridInformationProvider; @@ -99,14 +100,14 @@ public class ManagedPropertySection extends DisposableTabContent { Info.display(getHeading() + " show content", uiDescription.toString()); - ManagedTableWidgetDescription tableDescriptionOrNull = tryGetTableDescription(); + final ManagedTableWidgetDescription tableDescriptionOrNull = tryGetTableDescription(); if (tableDescriptionOrNull == null) { MessageBox.alert("Error", "Failed to create content", null); return DUMMY_CONTENT; } else { - IManagedPropertyGridInformationProvider gridInfo = + final IManagedPropertyGridInformationProvider gridInfo = new IManagedPropertyGridInformationProvider() { public String getKey() @@ -114,22 +115,34 @@ public class ManagedPropertySection extends DisposableTabContent return gridIdSuffix; } }; - IOnGridComponentGeneratedAction gridGeneratedAction = + // refresh reloads the table and replaces tab component + final IOnGridComponentGeneratedAction gridGeneratedAction = new IOnGridComponentGeneratedAction() { public void execute(IDisposableComponent gridComponent) { - Info.display("grid generated", gridComponent.getComponent().getId()); - updateContent(gridComponent, true); + Info.display("grid generated", ""); // TODO remove + replaceContent(gridComponent); } }; - AsyncCallback<TableModelReference> callback = - ManagedPropertyGridGeneratedCallback.create(viewContext.getCommonViewContext(), - gridInfo, gridGeneratedAction); - viewContext.getCommonService().createReportForManagedProperty(tableDescriptionOrNull, - callback); + + IDelegatedAction loadGrid = new IDelegatedAction() + { + + public void execute() + { + AsyncCallback<TableModelReference> callback = + ManagedPropertyGridGeneratedCallback.create( + viewContext.getCommonViewContext(), gridInfo, + gridGeneratedAction, this); + viewContext.getCommonService().createReportForManagedProperty( + tableDescriptionOrNull, callback); + } + + }; + loadGrid.execute(); return null; } @@ -147,4 +160,5 @@ public class ManagedPropertySection extends DisposableTabContent return null; } } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java index 340a9dd9eaf..cf40b58fe6f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java @@ -820,7 +820,7 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod // wraps this browser into the interface appropriate for the toolbar. If this class would just // implement the interface it could be very confusing for the code reader. - protected final IBrowserGridActionInvoker asActionInvoker() + protected IBrowserGridActionInvoker asActionInvoker() { final AbstractBrowserGrid<T, M> delegate = this; return new IBrowserGridActionInvoker() diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java index 235b80dd811..4e25891aa8e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGrid.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.manage import java.util.Set; +import com.extjs.gxt.ui.client.widget.Info; import com.google.gwt.user.client.rpc.AsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; @@ -26,7 +27,9 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericCon import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplayTypeIDGenerator; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.TypedTableGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IBrowserGridActionInvoker; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSetFetchConfig; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; @@ -34,6 +37,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableModelReferenc import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TypedTableResultSet; import ch.systemsx.cisd.openbis.generic.shared.basic.IManagedPropertyGridInformationProvider; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Null; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; @@ -43,15 +47,17 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject public class ManagedPropertyGrid extends TypedTableGrid<Null> { // browser consists of the grid and the paging toolbar - public static final String BROWSER_ID = GenericConstants.ID_PREFIX + "DataSetReporterGrid"; + public static final String BROWSER_ID = GenericConstants.ID_PREFIX + "ManagedPropertyGrid"; public static IDisposableComponent create( final IViewContext<ICommonClientServiceAsync> viewContext, TableModelReference tableModelReference, - IManagedPropertyGridInformationProvider gridInformation) + IManagedPropertyGridInformationProvider gridInformation, + IDelegatedAction onRefreshAction) { final ManagedPropertyGrid grid = - new ManagedPropertyGrid(viewContext, tableModelReference, gridInformation); + new ManagedPropertyGrid(viewContext, tableModelReference, gridInformation, + onRefreshAction); return grid.asDisposableWithoutToolbar(); } @@ -64,11 +70,15 @@ public class ManagedPropertyGrid extends TypedTableGrid<Null> private final String gridKind; + private final IDelegatedAction onRefreshAction; + private ManagedPropertyGrid(IViewContext<ICommonClientServiceAsync> viewContext, TableModelReference tableModelReference, - IManagedPropertyGridInformationProvider gridInformation) + IManagedPropertyGridInformationProvider gridInformation, + IDelegatedAction onRefreshAction) { super(viewContext, BROWSER_ID, true, DisplayTypeIDGenerator.DATA_SET_REPORTING_GRID); + this.onRefreshAction = onRefreshAction; setId(BROWSER_ID); this.resultSetKey = tableModelReference.getResultSetKey(); this.gridKind = gridInformation.getKey(); @@ -87,7 +97,7 @@ public class ManagedPropertyGrid extends TypedTableGrid<Null> AsyncCallback<TypedTableResultSet<Null>> callback) { // In all cases the data should be taken from the cache, and we know the key already. - // The custom columns should be recomputed. - TODO 2011-01-13, Piotr Buczek: WHY?? + // The custom columns should be recomputed. resultSetConfig.setCacheConfig(ResultSetFetchConfig .createFetchFromCacheAndRecompute(resultSetKey)); viewContext.getService().listReport(resultSetConfig, callback); @@ -101,10 +111,53 @@ public class ManagedPropertyGrid extends TypedTableGrid<Null> viewContext.getService().prepareExportReport(exportCriteria, callback); } + @Override + public DatabaseModificationKind[] getRelevantModifications() + { + Info.display("getRelevantModifications", ""); + return new DatabaseModificationKind[] + { + // script changes can cause all sorts of changes to the grid + DatabaseModificationKind.edit(ObjectKind.SCRIPT), + // different script can be assigned + DatabaseModificationKind.edit(ObjectKind.PROPERTY_TYPE_ASSIGNMENT) + + }; + } + @Override public void update(Set<DatabaseModificationKind> observedModifications) { - // do nothing + Info.display("update", ""); + super.update(observedModifications); } + @Override + protected IBrowserGridActionInvoker asActionInvoker() + { + final IBrowserGridActionInvoker delegate = super.asActionInvoker(); + return new IBrowserGridActionInvoker() + { + + public void toggleFilters(boolean show) + { + delegate.toggleFilters(show); + } + + public void refresh() + { + onRefreshAction.execute(); + } + + public void export(boolean allColumns) + { + delegate.export(allColumns); + } + + public void configure() + { + delegate.configure(); + } + }; + } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridGeneratedCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridGeneratedCallback.java index 65823b0aa89..7c7603e236d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridGeneratedCallback.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/managed_property/ManagedPropertyGridGeneratedCallback.java @@ -25,6 +25,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAs import ch.systemsx.cisd.openbis.generic.client.web.client.application.AsyncCallbackWithProgressBar; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableModelReference; import ch.systemsx.cisd.openbis.generic.shared.basic.IManagedPropertyGridInformationProvider; @@ -41,34 +42,41 @@ public class ManagedPropertyGridGeneratedCallback extends private final IViewContext<ICommonClientServiceAsync> viewContext; - private final IOnGridComponentGeneratedAction action; + private final IOnGridComponentGeneratedAction onGridGeneratedAction; private final IManagedPropertyGridInformationProvider gridInfo; + private final IDelegatedAction onRefreshAction; + public static AsyncCallback<TableModelReference> create( IViewContext<ICommonClientServiceAsync> viewContext, - IManagedPropertyGridInformationProvider gridInfo, IOnGridComponentGeneratedAction action) + IManagedPropertyGridInformationProvider gridInfo, + IOnGridComponentGeneratedAction onGridGeneratedAction, IDelegatedAction onRefreshAction) { return AsyncCallbackWithProgressBar.decorate(new ManagedPropertyGridGeneratedCallback( - viewContext, gridInfo, action), "Generating the table..."); + viewContext, gridInfo, onGridGeneratedAction, onRefreshAction), + "Generating the table..."); } private ManagedPropertyGridGeneratedCallback( IViewContext<ICommonClientServiceAsync> viewContext, - IManagedPropertyGridInformationProvider gridInfo, IOnGridComponentGeneratedAction action) + IManagedPropertyGridInformationProvider gridInfo, + IOnGridComponentGeneratedAction onGridGeneratedAction, IDelegatedAction onRefreshAction) { super(viewContext); this.viewContext = viewContext; this.gridInfo = gridInfo; - this.action = action; + this.onGridGeneratedAction = onGridGeneratedAction; + this.onRefreshAction = onRefreshAction; } @Override protected void process(final TableModelReference tableModelReference) { final IDisposableComponent reportComponent = - ManagedPropertyGrid.create(viewContext, tableModelReference, gridInfo); - action.execute(reportComponent); + ManagedPropertyGrid.create(viewContext, tableModelReference, gridInfo, + onRefreshAction); + onGridGeneratedAction.execute(reportComponent); if (StringUtils.isBlank(tableModelReference.tryGetMessage()) == false) { MessageBox.info(null, tableModelReference.tryGetMessage(), null); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/report/ReportGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/report/ReportGrid.java index ced5f74d5aa..4870bb710db 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/report/ReportGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/report/ReportGrid.java @@ -87,7 +87,7 @@ public class ReportGrid extends TypedTableGrid<Null> AsyncCallback<TypedTableResultSet<Null>> callback) { // In all cases the data should be taken from the cache, and we know the key already. - // The custom columns should be recomputed. - TODO 2011-01-13, Piotr Buczek: WHY?? + // The custom columns should be recomputed. resultSetConfig.setCacheConfig(ResultSetFetchConfig .createFetchFromCacheAndRecompute(resultSetKey)); viewContext.getService().listReport(resultSetConfig, callback); -- GitLab