From b85dd837fee72d49f629f483d8a55ace1ec92cf9 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 14 Jul 2011 09:12:55 +0000 Subject: [PATCH] [LMS-2366] temporary solution - allow only to completely empty the trash SVN: 22138 --- .../web/client/ICommonClientService.java | 5 ++ .../web/client/ICommonClientServiceAsync.java | 6 ++ .../client/web/client/application/Dict.java | 6 ++ .../application/ui/deletion/DeletionGrid.java | 19 ++++- .../EmptyTrashConfirmationDialog.java | 69 +++++++++++++++++++ .../web/server/CommonClientService.java | 8 +++ .../cisd/openbis/public/common-dictionary.js | 5 +- 7 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/EmptyTrashConfirmationDialog.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java index afbab8efcab..8d45e8aab4e 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientService.java @@ -1099,4 +1099,9 @@ public interface ICommonClientService extends IClientService */ public void deletePermanently(List<TechId> deletionIds) throws UserFailureException; + /** + * Permanently deletes all entities moved to trash. + */ + public void emptyTrash() throws UserFailureException; + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java index d8c54c32653..baafd567502 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/ICommonClientServiceAsync.java @@ -21,6 +21,7 @@ import java.util.List; import com.google.gwt.user.client.rpc.AsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ArchivingResult; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUploadParameters; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; @@ -993,4 +994,9 @@ public interface ICommonClientServiceAsync extends IClientServiceAsync * @see ICommonClientService#deletePermanently(List) */ public void deletePermanently(List<TechId> deletionIds, AsyncCallback<Void> callback); + + /** + * @see ICommonClientService#emptyTrash() + */ + public void emptyTrash(AbstractAsyncCallback<Void> callback); } 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 9fe8f0085b9..b5be32ee273 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 @@ -520,6 +520,8 @@ public abstract class Dict public static final String BUTTON_REVERT_DELETION = "button_revert_deletion"; + public static final String BUTTON_EMPTY_TRASH = "button_empty_trash"; + public static final String BUTTON_DELETE_PERMANENTLY = "button_delete_permanently"; public static final String REVERT_DELETIONS_CONFIRMATION_TITLE = @@ -534,6 +536,10 @@ public abstract class Dict public static final String PERMANENT_DELETIONS_CONFIRMATION_MSG = "permanent_deletions_confirmation_msg"; + public static final String EMPTY_TRASH_CONFIRMATION_TITLE = "empty_trash_confirmation_title"; + + public static final String EMPTY_TRASH_CONFIRMATION_MSG = "empty_trash_confirmation_msg"; + // // Sample Viewer // diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/DeletionGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/DeletionGrid.java index 38c8684d9b8..a9b052225e3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/DeletionGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/DeletionGrid.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.extjs.gxt.ui.client.event.ButtonEvent; +import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.button.Button; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -93,6 +95,20 @@ public class DeletionGrid extends TypedTableGrid<Deletion> }); addButton(revertButton); + Button emptyTrashButton = + new Button(viewContext.getMessage(Dict.BUTTON_EMPTY_TRASH), + new SelectionListener<ButtonEvent>() + { + @Override + public void componentSelected(ButtonEvent ce) + { + new EmptyTrashConfirmationDialog(viewContext, + createRefreshCallback(asActionInvoker())).show(); + } + }); + addButton(emptyTrashButton); + + @SuppressWarnings("unused") Button deletePermanentlyButton = createSelectedItemsButton(viewContext.getMessage(Dict.BUTTON_DELETE_PERMANENTLY), new AbstractCreateDialogListener() @@ -111,7 +127,8 @@ public class DeletionGrid extends TypedTableGrid<Deletion> deletions, createRefreshCallback(invoker)); } }); - addButton(deletePermanentlyButton); + // TODO uncomment when permanent deletion of selected deletions is reliably implemented + // addButton(deletePermanentlyButton); allowMultipleSelection(); // we allow deletion/revert of multiple deletions addEntityOperationsSeparator(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/EmptyTrashConfirmationDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/EmptyTrashConfirmationDialog.java new file mode 100644 index 00000000000..b9b4535b7cb --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/deletion/EmptyTrashConfirmationDialog.java @@ -0,0 +1,69 @@ +/* + * 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.client.web.client.application.ui.deletion; + +import java.util.Collections; +import java.util.List; + +import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.AbstractDataConfirmationDialog; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Deletion; + +public final class EmptyTrashConfirmationDialog extends + AbstractDataConfirmationDialog<List<Deletion>> +{ + private static final int LABEL_WIDTH = 60; + + private static final int FIELD_WIDTH = 180; + + private final IViewContext<ICommonClientServiceAsync> viewContext; + + private final AbstractAsyncCallback<Void> callback; + + public EmptyTrashConfirmationDialog( + IViewContext<ICommonClientServiceAsync> viewContext, + AbstractAsyncCallback<Void> callback) + { + super(viewContext, Collections.<Deletion> emptyList(), viewContext + .getMessage(Dict.PERMANENT_DELETIONS_CONFIRMATION_TITLE)); + this.viewContext = viewContext; + this.callback = callback; + } + + @Override + protected void executeConfirmedAction() + { + viewContext.getCommonService().emptyTrash(callback); + } + + @Override + protected String createMessage() + { + return viewContext.getMessage(Dict.PERMANENT_DELETIONS_CONFIRMATION_MSG, data.size()); + } + + @Override + protected void extendForm() + { + formPanel.setLabelWidth(LABEL_WIDTH); + formPanel.setFieldWidth(FIELD_WIDTH); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java index 5a4d82c164b..c0eabd56c18 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/CommonClientService.java @@ -2226,4 +2226,12 @@ public final class CommonClientService extends AbstractClientService implements { commonServer.deletePermanently(getSessionToken(), deletionIds); } + + public void emptyTrash() + throws ch.systemsx.cisd.openbis.generic.client.web.client.exception.UserFailureException + { + String sessionToken = getSessionToken(); + List<Deletion> deletions = commonServer.listDeletions(sessionToken); + commonServer.deletePermanently(sessionToken, TechId.createList(deletions)); + } } 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 f34ed83c3a1..8d6e48c61ad 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 @@ -76,11 +76,14 @@ var common = { cannot_modify_deleted_entity_msg: "{0} '{1}' has been moved to trash and therefore can't be modified.", deletion_browser: "Trash", button_revert_deletion: "Revert", + button_empty_trash: "Empty Trash", button_delete_permanently: "Delete Permanently", revert_deletions_confirmation_title: "Confirm Revert", revert_deletions_confirmation_msg: "Are you sure you want to revert {0} selected deletion(s)?", permanent_deletions_confirmation_title: "Confirm Permanent Deletion", - permanent_deletions_confirmation_msg: "Are you sure you want to <b>permanently</b> delete all entities that were moved to trash in selected {0} deletion(s)?", + permanent_deletions_confirmation_msg: "Are you sure you want to <b>permanently</b> delete all entities that were moved to trash in selected {0} deletion(s)?</br></br>You can't undo this action.", + empty_trash_confirmation_title: "Confirm Empty Trash", + empty_trash_confirmation_msg: "Are you sure you want to <b>permanently</b> delete all entities that were moved to trash?</br></br>You can't undo this action.", // // Table Modifications -- GitLab