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