Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / Clipboard.java @ 2e3e007c

History | View | Annotate | Download (2.7 kB)

1 ab1eb3f8 Christos Stathis
/*
2 58777026 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 58777026 Christos Stathis
 *
4 58777026 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 58777026 Christos Stathis
 * without modification, are permitted provided that the following
6 58777026 Christos Stathis
 * conditions are met:
7 58777026 Christos Stathis
 *
8 58777026 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 58777026 Christos Stathis
 *      disclaimer.
11 58777026 Christos Stathis
 *
12 58777026 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 58777026 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 58777026 Christos Stathis
 *      provided with the distribution.
16 58777026 Christos Stathis
 *
17 58777026 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 58777026 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 58777026 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 58777026 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 58777026 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 58777026 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 58777026 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 58777026 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 58777026 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 58777026 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 58777026 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 58777026 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 58777026 Christos Stathis
 *
30 58777026 Christos Stathis
 * The views and conclusions contained in the software and
31 58777026 Christos Stathis
 * documentation are those of the authors and should not be
32 58777026 Christos Stathis
 * interpreted as representing official policies, either expressed
33 58777026 Christos Stathis
 * or implied, of GRNET S.A.
34 ab1eb3f8 Christos Stathis
 */
35 6b4a2499 Christos Stathis
package gr.grnet.pithos.web.client;
36 ab1eb3f8 Christos Stathis
37 6b4a2499 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
38 6b4a2499 Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
39 6b4a2499 Christos Stathis
import java.util.List;
40 ab1eb3f8 Christos Stathis
41 ab1eb3f8 Christos Stathis
public class Clipboard {
42 ab1eb3f8 Christos Stathis
        public final static int CUT=1;
43 ab1eb3f8 Christos Stathis
        public final static int COPY=2;
44 6b4a2499 Christos Stathis
45 6b4a2499 Christos Stathis
    private int operation;
46 6b4a2499 Christos Stathis
47 6b4a2499 Christos Stathis
    private List<File> files;
48 6b4a2499 Christos Stathis
49 6b4a2499 Christos Stathis
    private Folder folder;
50 ab1eb3f8 Christos Stathis
51 ab1eb3f8 Christos Stathis
        /**
52 ab1eb3f8 Christos Stathis
         * Retrieve the item.
53 ab1eb3f8 Christos Stathis
         *
54 ab1eb3f8 Christos Stathis
         * @return the item
55 ab1eb3f8 Christos Stathis
         */
56 6b4a2499 Christos Stathis
        public Object getItem() {
57 6b4a2499 Christos Stathis
        if (folder != null)
58 6b4a2499 Christos Stathis
            return folder;
59 6b4a2499 Christos Stathis
        if (files != null)
60 6b4a2499 Christos Stathis
            return files;
61 6b4a2499 Christos Stathis
        return null;
62 ab1eb3f8 Christos Stathis
        }
63 ab1eb3f8 Christos Stathis
64 6b4a2499 Christos Stathis
        public void setItem(int _operation, Folder _folder) {
65 6b4a2499 Christos Stathis
        operation = _operation;
66 6b4a2499 Christos Stathis
                folder = _folder;
67 6b4a2499 Christos Stathis
        files = null;
68 ab1eb3f8 Christos Stathis
        }
69 ab1eb3f8 Christos Stathis
70 6b4a2499 Christos Stathis
    public void setItem(int _operation, List<File> _files) {
71 6b4a2499 Christos Stathis
        operation = _operation;
72 6b4a2499 Christos Stathis
        files = _files;
73 6b4a2499 Christos Stathis
        folder = null;
74 6b4a2499 Christos Stathis
    }
75 ab1eb3f8 Christos Stathis
76 6b4a2499 Christos Stathis
    public int getOperation() {
77 6b4a2499 Christos Stathis
        return operation;
78 6b4a2499 Christos Stathis
    }
79 ab1eb3f8 Christos Stathis
80 6b4a2499 Christos Stathis
    public void clear() {
81 6b4a2499 Christos Stathis
        folder = null;
82 6b4a2499 Christos Stathis
        files = null;
83 6b4a2499 Christos Stathis
    }
84 cf2dddff Christos Stathis
85 cf2dddff Christos Stathis
    public boolean isEmpty() {
86 cf2dddff Christos Stathis
        return (files == null || files.isEmpty()) && folder == null;
87 cf2dddff Christos Stathis
    }
88 cf2dddff Christos Stathis
89 cf2dddff Christos Stathis
    public boolean hasFiles() {
90 cf2dddff Christos Stathis
        return files != null && !files.isEmpty();
91 cf2dddff Christos Stathis
    }
92 ab1eb3f8 Christos Stathis
}