Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / commands / CopyCommand.java @ 31840568

History | View | Annotate | Download (2.3 kB)

1
/*
2
 * Copyright 2008, 2009 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package gr.ebs.gss.client.commands;
20

    
21
import gr.ebs.gss.client.GSS;
22
import gr.ebs.gss.client.clipboard.ClipboardItem;
23
import gr.ebs.gss.client.rest.resource.FileResource;
24
import gr.ebs.gss.client.rest.resource.FolderResource;
25
import gr.ebs.gss.client.rest.resource.GroupUserResource;
26
import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
27

    
28
import java.util.List;
29

    
30
import com.google.gwt.user.client.Command;
31
import com.google.gwt.user.client.ui.PopupPanel;
32
/**
33
 *
34
 * Command for copying a file, folder or user to GSS Clipboard
35
 * @author kman
36
 *
37
 */
38
public class CopyCommand implements Command{
39
        private PopupPanel containerPanel;
40

    
41
        public CopyCommand(PopupPanel _containerPanel){
42
                containerPanel = _containerPanel;
43
        }
44

    
45
        @Override
46
        public void execute() {
47
                containerPanel.hide();
48
                Object selection = GSS.get().getCurrentSelection();
49
                if (selection == null)
50
                        return;
51

    
52
                if (selection instanceof RestResourceWrapper) {
53
                        ClipboardItem clipboardItem = new ClipboardItem((RestResourceWrapper) selection);
54
                        GSS.get().getClipboard().setItem(clipboardItem);
55
                } else if (selection instanceof FileResource) {
56
                        ClipboardItem clipboardItem = new ClipboardItem((FileResource) selection);
57
                        GSS.get().getClipboard().setItem(clipboardItem);
58
                } else if (selection instanceof GroupUserResource) {
59
                        ClipboardItem clipboardItem = new ClipboardItem((GroupUserResource) selection);
60
                        GSS.get().getClipboard().setItem(clipboardItem);
61
                }
62
                 else if (selection instanceof List){
63
                         ClipboardItem clipboardItem = new ClipboardItem((List<FileResource>) selection);
64
                         GSS.get().getClipboard().setItem(clipboardItem);
65
                 }
66

    
67
        }
68

    
69
}