From 3f1edb1bc88ead832f10d11aec79ad512090b24a Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Wed, 8 Dec 2010 14:46:59 +0000 Subject: [PATCH] [LMS-1924] client side SVN: 19056 --- .../client/web/client/application/Dict.java | 4 +- .../data/CommonExternalDataColDefKind.java | 9 +++ .../ui/data/AbstractExternalDataGrid.java | 32 ++++++++++ .../basic/DatasetImageOverviewUtilities.java | 64 +++++++++++++++++++ .../shared/basic/dto/ImageResolutionKind.java | 25 ++++++++ .../cisd/openbis/public/common-dictionary.js | 1 + 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/DatasetImageOverviewUtilities.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ImageResolutionKind.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java index 8a43637892c..62fd1f6f0ba 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java @@ -615,7 +615,7 @@ public abstract class Dict public static final String SAMPLES_LIST = "samples_list"; public static final String EXPERIMENT_IMPORT = "experiment_import"; - + public static final String EXPERIMENT_BATCH_UPDATE = "experiment_batch_update"; // @@ -885,6 +885,8 @@ public abstract class Dict public static final String SHOW_DETAILS_LINK_TEXT_VALUE = "show_details_link_text_value"; + public static final String OVERVIEW = "overview_column_name"; + public static final String FILE_TEMPLATE_LABEL = "file_template_label"; public static final String URL = "url"; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java index ca8cd3f9adc..945a05c839c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/columns/specific/data/CommonExternalDataColDefKind.java @@ -280,6 +280,15 @@ public enum CommonExternalDataColDefKind implements IColumnDefinitionKind<Extern { return entity.getPermlink(); } + }), + + OVERVIEW(new AbstractColumnDefinitionKind<ExternalData>(Dict.OVERVIEW, true) + { + @Override + public String tryGetValue(ExternalData entity) + { + return ""; // link doesn't make sense here as session id is needed + } }); private final AbstractColumnDefinitionKind<ExternalData> columnDefinitionKind; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java index 3bb3a9fc400..69dfc0b780a 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/AbstractExternalDataGrid.java @@ -21,8 +21,11 @@ import static ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModifica import java.util.List; import java.util.Set; +import com.extjs.gxt.ui.client.store.ListStore; import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.button.Button; +import com.extjs.gxt.ui.client.widget.grid.ColumnData; +import com.extjs.gxt.ui.client.widget.grid.Grid; import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; import ch.systemsx.cisd.common.shared.basic.utils.StringUtils; @@ -50,6 +53,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DisplayedOrSelecte import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSetWithEntityTypes; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; +import ch.systemsx.cisd.openbis.generic.shared.basic.DatasetImageOverviewUtilities; import ch.systemsx.cisd.openbis.generic.shared.basic.GridRowModel; import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition; import ch.systemsx.cisd.openbis.generic.shared.basic.IEntityInformationHolderWithPermId; @@ -330,9 +334,37 @@ public abstract class AbstractExternalDataGrid schema.setGridCellRendererFor(CommonExternalDataColDefKind.PROJECT.id(), linkRenderer); schema.setGridCellRendererFor(CommonExternalDataColDefKind.SHOW_DETAILS_LINK.id(), createShowDetailsLinkCellRenderer()); + schema.setGridCellRendererFor(CommonExternalDataColDefKind.OVERVIEW.id(), + createOverviewCellRenderer()); return schema; } + private GridCellRenderer<BaseEntityModel<?>> createOverviewCellRenderer() + { + final String sessionID = viewContext.getModel().getSessionContext().getSessionID(); + return new GridCellRenderer<BaseEntityModel<?>>() + { + + public Object render(BaseEntityModel<?> model, String property, ColumnData config, + int rowIndex, int colIndex, ListStore<BaseEntityModel<?>> store, + Grid<BaseEntityModel<?>> grid) + { + ExternalData dataset = (ExternalData) model.getBaseObject(); + return createOverviewLink(dataset); + } + + private String createOverviewLink(ExternalData dataset) + { + final String permId = dataset.getPermId(); + final String dssBaseURL = dataset.getDataStore().getHostUrl(); + final String typeCode = dataset.getDataSetType().getCode(); + return DatasetImageOverviewUtilities.createEmbededImageHtml(dssBaseURL, permId, + typeCode, sessionID); + } + }; + + } + private EntityGridModelFactory<ExternalData> getColumnsFactory() { return new EntityGridModelFactory<ExternalData>(viewContext, getStaticColumnsDefinition()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/DatasetImageOverviewUtilities.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/DatasetImageOverviewUtilities.java new file mode 100644 index 00000000000..1dd228f374a --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/DatasetImageOverviewUtilities.java @@ -0,0 +1,64 @@ +/* + * Copyright 2009 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ImageResolutionKind; + +/** + * @author Piotr Buczek + */ +public class DatasetImageOverviewUtilities +{ + public static final String SERVLET_NAME = "image-overview"; + + /** The HTTP URL parameter used to specify the data set identifier. */ + public static final String PERM_ID_PARAMETER_KEY = "permId"; + + /** The HTTP URL parameter used to specify the data set type code. */ + public static final String TYPE_PARAMETER_KEY = "type"; + + /** The HTTP URL parameter used to specify the resolution of image. */ + public static final String RESOLUTION_PARAMETER_KEY = "resolution"; + + /** The HTTP URL parameter used to specify the DSS session id. */ + public static final String SESSION_ID_PARAM = "session_id"; + + public final static String createLink(final String dssBaseURL, final String permId, + final String typeCode, final ImageResolutionKind resolution, final String sessionId) + { + URLMethodWithParameters ulrWithParameters = + new URLMethodWithParameters(dssBaseURL + "/" + SERVLET_NAME); + ulrWithParameters.addParameter(PERM_ID_PARAMETER_KEY, permId); + ulrWithParameters.addParameter(TYPE_PARAMETER_KEY, typeCode); + ulrWithParameters.addParameter(RESOLUTION_PARAMETER_KEY, resolution); + ulrWithParameters.addParameter(SESSION_ID_PARAM, sessionId); + return ulrWithParameters.toString(); + } + + /** generates URL of an image on Data Store server */ + public static String createEmbededImageHtml(final String dssBaseURL, final String permId, + final String typeCode, final String sessionId) + { + final String imageURL = + createLink(dssBaseURL, permId, typeCode, ImageResolutionKind.SMALL, sessionId); + final String linkURL = + createLink(dssBaseURL, permId, typeCode, ImageResolutionKind.NORMAL, sessionId); + + return URLMethodWithParameters.createEmbededImageHtml(imageURL, linkURL, -1, -1); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ImageResolutionKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ImageResolutionKind.java new file mode 100644 index 00000000000..0044255e17a --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/ImageResolutionKind.java @@ -0,0 +1,25 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.shared.basic.dto; + +/** + * @author Piotr Buczek + */ +public enum ImageResolutionKind +{ + SMALL, NORMAL +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js index 33cd43f5dd8..7290158bc4d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js @@ -32,6 +32,7 @@ var common = { tab_link: "Link", tab_link_message: "Copy this {0} and use it to access openBIS with current tab opened.", permlink_column_name: "Permlink", + show_details_link_column_name: "Overview", show_details_link_column_name: "Show Details Link", show_details_link_text_value: "Permlink", table_operations: "Table:", -- GitLab