root / src / gr / ebs / gss / client / FolderContextMenu.java @ fc0fa492
History | View | Annotate | Download (8.9 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 14ad7326 | pastith | * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 | 14ad7326 | pastith | *
|
4 | 14ad7326 | pastith | * This file is part of GSS.
|
5 | 14ad7326 | pastith | *
|
6 | 14ad7326 | pastith | * GSS is free software: you can redistribute it and/or modify
|
7 | 14ad7326 | pastith | * it under the terms of the GNU General Public License as published by
|
8 | 14ad7326 | pastith | * the Free Software Foundation, either version 3 of the License, or
|
9 | 14ad7326 | pastith | * (at your option) any later version.
|
10 | 14ad7326 | pastith | *
|
11 | 14ad7326 | pastith | * GSS is distributed in the hope that it will be useful,
|
12 | 14ad7326 | pastith | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 14ad7326 | pastith | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 14ad7326 | pastith | * GNU General Public License for more details.
|
15 | 14ad7326 | pastith | *
|
16 | 14ad7326 | pastith | * You should have received a copy of the GNU General Public License
|
17 | 14ad7326 | pastith | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 14ad7326 | pastith | */
|
19 | 14ad7326 | pastith | package gr.ebs.gss.client; |
20 | 14ad7326 | pastith | |
21 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.CopyCommand; |
22 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.CutCommand; |
23 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.DeleteCommand; |
24 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.EmptyTrashCommand; |
25 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.NewFolderCommand; |
26 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.PasteCommand; |
27 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.PropertiesCommand; |
28 | ad8b38cb | koutsoub | import gr.ebs.gss.client.commands.RefreshCommand; |
29 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.RestoreTrashCommand; |
30 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.ToTrashCommand; |
31 | 14ad7326 | pastith | import gr.ebs.gss.client.commands.UploadFileCommand; |
32 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.OtherUserResource; |
33 | 14ad7326 | pastith | |
34 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.resources.client.ClientBundle; |
35 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
36 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuBar; |
37 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuItem; |
38 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.PopupPanel; |
39 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TreeItem; |
40 | 14ad7326 | pastith | |
41 | 14ad7326 | pastith | /**
|
42 | 14ad7326 | pastith | * The 'Folder Context' menu implementation.
|
43 | 14ad7326 | pastith | */
|
44 | 14ad7326 | pastith | public class FolderContextMenu extends PopupPanel { |
45 | 14ad7326 | pastith | |
46 | 14ad7326 | pastith | /**
|
47 | 14ad7326 | pastith | * The widget's images.
|
48 | 14ad7326 | pastith | */
|
49 | 14ad7326 | pastith | private final Images images; |
50 | 14ad7326 | pastith | |
51 | 14ad7326 | pastith | /**
|
52 | 14ad7326 | pastith | * The image bundle for this widget's images that reuses images defined in
|
53 | 14ad7326 | pastith | * other menus.
|
54 | 14ad7326 | pastith | */
|
55 | afd3a0ef | Giannis Koutsoubos | public interface Images extends ClientBundle,FileMenu.Images, EditMenu.Images { |
56 | 14ad7326 | pastith | } |
57 | a93eb00b | pastith | |
58 | a93eb00b | pastith | private MenuItem pasteItem; |
59 | a93eb00b | pastith | |
60 | 14ad7326 | pastith | /**
|
61 | 14ad7326 | pastith | * The widget's constructor.
|
62 | 14ad7326 | pastith | *
|
63 | 14ad7326 | pastith | * @param newImages the image bundle passed on by the parent object
|
64 | 14ad7326 | pastith | */
|
65 | 14ad7326 | pastith | public FolderContextMenu(final Images newImages) { |
66 | 14ad7326 | pastith | // The popup's constructor's argument is a boolean specifying that it
|
67 | 14ad7326 | pastith | // auto-close itself when the user clicks outside of it.
|
68 | 14ad7326 | pastith | super(true); |
69 | 14ad7326 | pastith | setAnimationEnabled(true);
|
70 | 14ad7326 | pastith | images = newImages; |
71 | 14ad7326 | pastith | |
72 | afd3a0ef | Giannis Koutsoubos | pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(this)); |
73 | a93eb00b | pastith | MenuBar contextMenu = new MenuBar(true); |
74 | a93eb00b | pastith | Folders folders = GSS.get().getFolders(); |
75 | a93eb00b | pastith | TreeItem selectedItem = folders.getCurrent(); |
76 | 14ad7326 | pastith | |
77 | 14ad7326 | pastith | |
78 | 14ad7326 | pastith | if(selectedItem != null) |
79 | 14ad7326 | pastith | if(folders.isTrashItem(selectedItem)){
|
80 | ad8b38cb | koutsoub | if (folders.isTrash(selectedItem)){
|
81 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this)); |
82 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
83 | ad8b38cb | koutsoub | } |
84 | a93eb00b | pastith | else {
|
85 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Restore folder and contents</span>", true, new RestoreTrashCommand(this)); |
86 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
87 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
88 | a93eb00b | pastith | } |
89 | 14ad7326 | pastith | } |
90 | 14ad7326 | pastith | else if(folders.isFileItem(selectedItem)){ |
91 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
92 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
93 | a93eb00b | pastith | boolean notRootFolder = !folders.getRootItem().equals(selectedItem);
|
94 | a93eb00b | pastith | if (notRootFolder) {
|
95 | a93eb00b | pastith | // do not show the copy & cut option for the user's root folder
|
96 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
97 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
98 | a93eb00b | pastith | } |
99 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
100 | a93eb00b | pastith | if (notRootFolder) {
|
101 | a93eb00b | pastith | // do not show delete options for the user's root folder
|
102 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
103 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
104 | a93eb00b | pastith | } |
105 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
106 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
107 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
108 | 14ad7326 | pastith | } |
109 | 14ad7326 | pastith | else if(!folders.isMyShares(selectedItem) && folders.isMySharedItem(selectedItem)){ |
110 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
111 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
112 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
113 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
114 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
115 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
116 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
117 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
118 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
119 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
120 | 14ad7326 | pastith | } |
121 | a52ea5e4 | pastith | else if(!folders.isOthersShared(selectedItem) && folders.isOthersSharedItem(selectedItem) && !(GSS.get().getCurrentSelection() instanceof OtherUserResource)){ |
122 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
123 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
124 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
125 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
126 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
127 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
128 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
129 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
130 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
131 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
132 | ad8b38cb | koutsoub | } else if(!selectedItem.equals(folders.getSharesItem())) |
133 | afd3a0ef | Giannis Koutsoubos | contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
134 | 14ad7326 | pastith | add(contextMenu); |
135 | 14ad7326 | pastith | if (GSS.get().getClipboard().hasFolderOrFileItem())
|
136 | 14ad7326 | pastith | pasteItem.setVisible(true);
|
137 | 14ad7326 | pastith | else
|
138 | 14ad7326 | pastith | pasteItem.setVisible(false);
|
139 | 14ad7326 | pastith | } |
140 | 14ad7326 | pastith | |
141 | 14ad7326 | pastith | } |