001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.webapp.clipboard;
021
022import java.util.List;
023
024import org.nuxeo.ecm.core.api.DocumentModel;
025import org.nuxeo.ecm.core.api.DocumentRef;
026import org.nuxeo.ecm.platform.actions.Action;
027import org.nuxeo.ecm.webapp.documentsLists.DocumentsListDescriptor;
028
029/**
030 * Interface for clipboard template page action listener. Exposes methods for handling user actions related to the
031 * copy/paste buttons from clipboard.xhtml template.
032 *
033 * @author <a href="mailto:rcaraghin@nuxeo.com">Razvan Caraghin</a>
034 */
035public interface ClipboardActions {
036
037    /**
038     * Called when the drag and drop is launched in the clipboard fragment. Copies the documents passed to the
039     * clipboard.
040     * <p>
041     * The selection is added to the clipboard and to the WorkingList.
042     *
043     * @param docCopied the list of documents we want to copy
044     */
045    void copySelection(List<DocumentModel> docCopied);
046
047    /**
048     * Called when the delete button is clicked on the clipboard.
049     */
050    String removeWorkListItem(DocumentRef ref);
051
052    /**
053     * Called when the "delete all" button is clicked on the clipboard.
054     */
055    String clearWorkingList();
056
057    /**
058     * Called when the "paste all" button is clicked on the clipboard.
059     */
060    String pasteWorkingList();
061
062    /**
063     * Called when the "move all" button is clicked on the clipboard/selection
064     */
065    String moveWorkingList();
066
067    /**
068     * Called when the drag and drop is launched in the body fragment. Pastes the documents passed to the clipboard.
069     *
070     * @param docPaste the list of doc we want to paste
071     */
072    String pasteDocumentList(List<DocumentModel> docPaste);
073
074    String pasteDocumentListInside(List<DocumentModel> docPaste, String docId);
075
076    /**
077     * Pastes the content of the list listName into the current context document.
078     */
079    String pasteDocumentList(String listName);
080
081    String pasteDocumentListInside(String listName, String docId);
082
083    String pasteClipboard();
084
085    String pasteClipboardInside(String docId);
086
087    String moveClipboardInside(String docId);
088
089    String exportWorklistAsZip();
090
091    String exportAllBlobsFromWorkingListAsZip();
092
093    String exportMainBlobFromWorkingListAsZip();
094
095    String exportWorklistAsZip(List<DocumentModel> documents);
096
097    String exportWorklistAsZip(List<DocumentModel> documents, boolean exportAllBlobs);
098
099    void releaseClipboardableDocuments();
100
101    boolean isInitialized();
102
103    /**
104     * Checks if the currently selected WorkList is empty.
105     */
106    boolean isWorkListEmpty();
107
108    /**
109     * Shortcut for getCanPaste on the currently selected workList.
110     */
111    boolean getCanPasteWorkList();
112
113    /**
114     * Shortcut for getCanPaste on the clipboard.
115     */
116    boolean getCanPasteFromClipboard();
117
118    boolean getCanPasteFromClipboardInside(DocumentModel document);
119
120    /**
121     * Checks if the documents from the clipboard can be moved into the given document
122     */
123    boolean getCanMoveFromClipboardInside(DocumentModel document);
124
125    /**
126     * Checks if the content of a given workList can be pasted.
127     * <p>
128     * - checks if the list is empty<br>
129     * - checks if the user has the needed rights in the current context
130     */
131    boolean getCanPaste(String listName);
132
133    boolean getCanPasteInside(String listName, DocumentModel document);
134
135    /**
136     * Checks if there are selected items that can be copied into the current worklist.
137     */
138    boolean getCanCopy();
139
140    /**
141     * Checks if there are documents in current worklist can be moved into the current folder.
142     */
143    boolean getCanMoveWorkingList();
144
145    /**
146     * Checks if the documents in a given worklist can be moved into the given document
147     */
148    boolean getCanMoveInside(String listName, DocumentModel document);
149
150    /**
151     * Copies docsList into the current WorkList.
152     */
153    void putSelectionInWorkList(List<DocumentModel> docsList);
154
155    void putSelectionInWorkList(List<DocumentModel> docsList, Boolean forceAppend);
156
157    /**
158     * Copies the lists of selected documents into the current WorkList.
159     */
160    void putSelectionInWorkList();
161
162    void putSelectionInWorkList(Boolean forceAppend);
163
164    void putSelectionInClipboard();
165
166    void putSelectionInDefaultWorkList();
167
168    void putInClipboard(String docId);
169
170    /**
171     * Retries contents of current WorkList.
172     */
173    List<DocumentModel> getCurrentSelectedList();
174
175    /*
176     * List<DocumentModel> getWorkingList();
177     */
178
179    /**
180     * Returns the name of the current selected WorkList.
181     */
182    String getCurrentSelectedListName();
183
184    String getCurrentSelectedListTitle();
185
186    /**
187     * Sets the current selected WorkList.
188     */
189    void setCurrentSelectedList(String listId);
190
191    /**
192     * Returns the list of available lists (ie: the lists from the CLIPBOARD Category).
193     */
194    List<String> getAvailableLists();
195
196    /**
197     * Returns the list of Descriptors for available lists.
198     */
199    List<DocumentsListDescriptor> getDescriptorsForAvailableLists();
200
201    /**
202     * Returns the list of available web actions for the currently selected DocumentList.
203     *
204     * @return the WebAction list
205     */
206    List<Action> getActionsForCurrentList();
207
208    /**
209     * Returns the list of available web actions for the currently selected Documents.
210     *
211     * @return the WebAction list
212     */
213    List<Action> getActionsForSelection();
214
215    void selectList();
216
217    /**
218     * Checks for documents bulk editing action.
219     *
220     * @return <code>true</code> if the current selected docs (from clipboard) are editable by the current user
221     */
222    boolean getCanEditSelectedDocs();
223
224    /**
225     * Checks if documents in the specified list are editable so the bulk editing action can be invoked later.
226     *
227     * @return <code>true</code> if the docs from the specified working list are editable by the current user
228     */
229    boolean getCanEditListDocs(String listName);
230
231    boolean factoryForIsCurrentWorkListEmpty();
232
233    boolean isCacheEnabled();
234
235    String getCacheKey();
236
237    boolean isCacheEnabledForSelection();
238
239}