001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 */
011
012package org.nuxeo.ecm.automation.jsf.operations;
013
014import java.util.List;
015
016import org.nuxeo.ecm.automation.OperationContext;
017import org.nuxeo.ecm.automation.core.Constants;
018import org.nuxeo.ecm.automation.core.annotations.Context;
019import org.nuxeo.ecm.automation.core.annotations.Operation;
020import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
021import org.nuxeo.ecm.automation.jsf.OperationHelper;
022import org.nuxeo.ecm.core.api.DocumentModel;
023import org.nuxeo.ecm.core.api.DocumentModelList;
024import org.nuxeo.ecm.core.api.impl.DocumentModelListImpl;
025import org.nuxeo.ecm.webapp.documentsLists.DocumentsListsManager;
026
027/**
028 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a>
029 */
030@Operation(id = GetSelectedDocuments.ID, category = Constants.CAT_FETCH, requires = Constants.SEAM_CONTEXT, label = "UI Selected documents", description = "Fetch the documents selected in the current folder listing")
031public class GetSelectedDocuments {
032
033    public static final String ID = "Seam.GetSelectedDocuments";
034
035    @Context
036    protected OperationContext ctx;
037
038    @OperationMethod
039    public DocumentModelList run() {
040        List<DocumentModel> res = OperationHelper.getDocumentListManager().getWorkingList(
041                DocumentsListsManager.CURRENT_DOCUMENT_SELECTION);
042        return new DocumentModelListImpl(res);
043    }
044
045}