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 afbab8efcabdd745bbf3ce9a5243ae0cd5a143d3..8d45e8aab4e68e54ee3ea57a4b2abeb097cf33e6 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 d8c54c326535133da7ebd60ecad6cfcb4fa33863..baafd567502f02ddb0c968c892223526df331b93 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 9fe8f0085b9372d3de4a38e368101b22a056874b..b5be32ee27324b61ebf442e2833e0baac5507c22 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 38c8684d9b878c280ddc85971b71f55b7abcde4d..a9b052225e3c98da8e7455632766126fbeb9fde8 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 0000000000000000000000000000000000000000..b9b4535b7cbb56cd74a7663e7fda3da1efbc7eeb --- /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 5a4d82c164b90a71b37ae121958a88e5652cfcd3..c0eabd56c185ac7d21f4a850477306561d913512 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 f34ed83c3a1051d40f20e3f6acb939df79d76e8a..8d6e48c61adf130918301eb581e7d7e2a505a41f 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