001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.gwt.client.ui.contextmenu; 029 030import org.opencms.gwt.client.CmsCoreProvider; 031import org.opencms.gwt.client.Messages; 032import org.opencms.gwt.client.rpc.CmsRpcAction; 033import org.opencms.gwt.client.ui.CmsResourceInfoConfirmDialog; 034import org.opencms.gwt.shared.CmsContextMenuEntryBean; 035import org.opencms.gwt.shared.CmsResourceStatusBean; 036import org.opencms.util.CmsUUID; 037 038/** 039 * ADE context menu option for undeleting a file.<p> 040 */ 041public class CmsUndelete implements I_CmsHasContextMenuCommand, I_CmsContextMenuCommand { 042 043 /** 044 * Creates a new context menu command.<p> 045 * 046 * @return the context menu command 047 */ 048 public static I_CmsContextMenuCommand getContextMenuCommand() { 049 050 return new CmsUndelete(); 051 } 052 053 /** 054 * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#execute(org.opencms.util.CmsUUID, org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler, org.opencms.gwt.shared.CmsContextMenuEntryBean) 055 */ 056 public void execute( 057 final CmsUUID structureId, 058 final I_CmsContextMenuHandler handler, 059 CmsContextMenuEntryBean bean) { 060 061 CmsCoreProvider.get(); 062 063 CmsRpcAction<CmsResourceStatusBean> loadStatusAction = new CmsRpcAction<CmsResourceStatusBean>() { 064 065 @Override 066 public void execute() { 067 068 start(0, true); 069 CmsCoreProvider.getVfsService().getResourceStatus( 070 structureId, 071 CmsCoreProvider.get().getLocale(), 072 false, 073 null, 074 null, 075 this); 076 077 } 078 079 @Override 080 protected void onResponse(CmsResourceStatusBean result) { 081 082 stop(false); 083 CmsResourceInfoConfirmDialog dialog = new CmsResourceInfoConfirmDialog(result) { 084 085 @Override 086 public String getCancelText() { 087 088 return Messages.get().key(Messages.GUI_CANCEL_0); 089 } 090 091 @Override 092 public String getCaption() { 093 094 return Messages.get().key(Messages.GUI_UNDELETE_CAPTION_0); 095 } 096 097 @Override 098 public String getOkText() { 099 100 return Messages.get().key(Messages.GUI_OK_0); 101 } 102 103 @Override 104 public String getText() { 105 106 return Messages.get().key(Messages.GUI_UNDELETE_TEXT_0); 107 } 108 109 @Override 110 public void onConfirm() { 111 112 CmsRpcAction<Void> undeleteAction = new CmsRpcAction<Void>() { 113 114 @Override 115 public void execute() { 116 117 start(0, true); 118 CmsCoreProvider.getVfsService().undelete(structureId, this); 119 } 120 121 @Override 122 protected void onResponse(Void voidResult) { 123 124 stop(false); 125 handler.refreshResource(structureId); 126 } 127 128 }; 129 undeleteAction.execute(); 130 131 } 132 }; 133 dialog.display(); 134 } 135 }; 136 loadStatusAction.execute(); 137 138 } 139 140 /** 141 * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#getItemWidget(org.opencms.util.CmsUUID, org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler, org.opencms.gwt.shared.CmsContextMenuEntryBean) 142 */ 143 public A_CmsContextMenuItem getItemWidget( 144 CmsUUID structureId, 145 I_CmsContextMenuHandler handler, 146 CmsContextMenuEntryBean bean) { 147 148 return null; 149 } 150 151 /** 152 * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#hasItemWidget() 153 */ 154 public boolean hasItemWidget() { 155 156 return false; 157 } 158 159}