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 bfee8e13e4dd30b6f043fbbffae71240fcc332b7..508652335af61ce0b8885875b7a080c25d3ba2a5 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 @@ -330,6 +330,8 @@ public abstract class Dict public static final String SHOW_ALL_VERSIONS = "show_all_versions"; + public static final String BUTTON_DOWNLOAD = "button_download"; + public static final String BUTTON_SHOW_ALL_VERSIONS = "button_show_all_versions"; public static final String NO_ATTACHMENTS_FOUND = "no_attachments_found"; @@ -579,7 +581,7 @@ public abstract class Dict public static final String TITLE_CHOOSE_EXPERIMENT = "TITLE_CHOOSE_EXPERIMENT"; public static final String INCORRECT_EXPERIMENT_SYNTAX = "incorrect_experiment_syntax"; - + public static final String TITLE_CHOOSE_SAMPLE = "title_choose_sample"; // diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentBrowser.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentBrowser.java index 7465668c3c97e7a2720870fea16802a792f415b8..b030e5b598d00d63ed638e737aa7c9616beabbd3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentBrowser.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentBrowser.java @@ -90,7 +90,9 @@ public class AttachmentBrowser extends AbstractSimpleBrowserGrid<AttachmentVersi private static final String ID_PREFIX = GenericConstants.ID_PREFIX + PREFIX; - private IDelegatedAction postRegistrationCallback; + public static final String DOWNLOAD_BUTTON_ID_SUFFIX = "_download-button"; + + private final IDelegatedAction postRegistrationCallback; public static IDisposableComponent create( final IViewContext<ICommonClientServiceAsync> viewContext, @@ -169,6 +171,12 @@ public class AttachmentBrowser extends AbstractSimpleBrowserGrid<AttachmentVersi { addEntityOperationsLabel(); + String downloadTitle = viewContext.getMessage(Dict.BUTTON_DOWNLOAD); + Button downloadButton = + createSelectedItemButton(downloadTitle, asDownloadAttachmentInvoker()); + downloadButton.setId(createBrowserId(attachmentHolder) + DOWNLOAD_BUTTON_ID_SUFFIX); + addButton(downloadButton); + String showAllVersionsTitle = viewContext.getMessage(Dict.BUTTON_SHOW_ALL_VERSIONS); Button showAllVersionsButton = createSelectedItemButton(showAllVersionsTitle, asShowEntityInvoker(false)); @@ -202,6 +210,20 @@ public class AttachmentBrowser extends AbstractSimpleBrowserGrid<AttachmentVersi addEntityOperationsSeparator(); } + protected final ISelectedEntityInvoker<BaseEntityModel<AttachmentVersions>> asDownloadAttachmentInvoker() + { + return new ISelectedEntityInvoker<BaseEntityModel<AttachmentVersions>>() + { + public void invoke(BaseEntityModel<AttachmentVersions> selectedItem) + { + AttachmentVersions versions = selectedItem.getBaseObject(); + final String fileName = versions.getCurrent().getFileName(); + final int version = versions.getCurrent().getVersion(); + downloadAttachment(fileName, version, attachmentHolder); + } + }; + } + private Window createEditAttachmentDialog(final AttachmentVersions versions) { final Attachment current = versions.getCurrent(); 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 6a9c012f22cc3a6d9b9e1b8e25e4564f00f025a2..10ed80df450ed1bb1dfed1e0a75a5cae467c01e2 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 @@ -410,6 +410,7 @@ incorrect_experiment_syntax: "Incorrect experiment specification. Please provide version: "Version", show_all_versions: "show all versions", button_show_all_versions: "Show All Versions", + button_download: "Download", // // Grid Column Chooser diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java index 92aa4b79fd4f9445a314e9fa9ad746f616ac85b7..f1a528a3054cb4a06a336e5cfee5e5cb93637692 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/SystemTestSuite.java @@ -37,6 +37,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.SampleBrow import ch.systemsx.cisd.openbis.generic.client.web.client.application.SearchTest; import ch.systemsx.cisd.openbis.generic.client.web.client.application.VocabularyBrowserTest; import ch.systemsx.cisd.openbis.generic.client.web.client.application.VocabularyRegistrationTest; +import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.experiment.GenericExperimentAttachmentDownloadTest; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.experiment.GenericExperimentEditorTest; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.experiment.GenericExperimentViewerTest; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.sample.GenericSampleRegistrationTest; @@ -71,8 +72,7 @@ public class SystemTestSuite extends GWTTestSuite testSuite.addTestSuite(EntityTypePropertyTypeAssignmentTest.class); testSuite.addTestSuite(VocabularyRegistrationTest.class); testSuite.addTestSuite(PropertyTypeRegistrationTest.class); - // TODO 2009-06-24, Piotr Buczek: fix clicking on cell with anchor or add a download button - // testSuite.addTestSuite(GenericExperimentAttachmentDownloadTest.class); + testSuite.addTestSuite(GenericExperimentAttachmentDownloadTest.class); testSuite.addTestSuite(ProjectRegistrationTest.class); testSuite.addTestSuite(EntityTypeBrowserTest.class); return testSuite; diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/ClickDownloadAttachmentCmdTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/DownloadAttachment.java similarity index 80% rename from openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/ClickDownloadAttachmentCmdTest.java rename to openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/DownloadAttachment.java index 29b3de6b02676fc11207d5a3ac1728dff2b5c2b7..171ed8b037452a377521ae0a92e02dfa69d28c45 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/ClickDownloadAttachmentCmdTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/DownloadAttachment.java @@ -30,17 +30,17 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.testframework.GWTTestU import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; /** - * Simulates clicking on the specified attachment in the experiment info window. + * Simulates downloading of the specified attachment in the experiment detail view. * * @author Tomasz Pylak */ -public class ClickDownloadAttachmentCmdTest extends AbstractDefaultTestCommand +public class DownloadAttachment extends AbstractDefaultTestCommand { private final String fileName; private final TechId experimentId; - public ClickDownloadAttachmentCmdTest(final String fileName, final TechId experimentId) + public DownloadAttachment(final String fileName, final TechId experimentId) { this.fileName = fileName; this.experimentId = experimentId; @@ -56,6 +56,10 @@ public class ClickDownloadAttachmentCmdTest extends AbstractDefaultTestCommand final Widget widget = GWTTestUtil.getWidgetWithID(attachmentGridId); final Grid<BaseEntityModel<AttachmentVersions>> table = (Grid<BaseEntityModel<AttachmentVersions>>) widget; - GridTestUtils.fireSingleClick(table, AttachmentColDefKind.FILE_NAME.id(), fileName); + GridTestUtils.fireSelectRow(table, AttachmentColDefKind.FILE_NAME.id(), fileName); + String downloadButtonId = + AttachmentBrowser.createBrowserId(experimentId, AttachmentHolderKind.EXPERIMENT) + + AttachmentBrowser.DOWNLOAD_BUTTON_ID_SUFFIX; + GWTTestUtil.clickButtonWithID(downloadButtonId); } } \ No newline at end of file diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentAttachmentDownloadTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentAttachmentDownloadTest.java index 9c03d02edada93b469f1634e379e1c1301a4b319..c4564f54b269bc9d7c9cf9f8eedf2afa5828d0a2 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentAttachmentDownloadTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/experiment/GenericExperimentAttachmentDownloadTest.java @@ -59,7 +59,7 @@ public class GenericExperimentAttachmentDownloadTest extends AbstractGWTTestCase // // Assumption: technicalId(CISD:/CISD/DEFAULT/EXP_REUSE) = 8 // - remoteConsole.prepare(new ClickDownloadAttachmentCmdTest("cellPlates.txt", new TechId(8L))); + remoteConsole.prepare(new DownloadAttachment("cellPlates.txt", new TechId(8L))); // this callback will be used when the attempt to open an URL will occur OpenedUrlCallback openedUrlCallback = new OpenedUrlCallback(client.tryToGetViewContext());