root / src / gr / ebs / gss / client / FolderContextMenu.java @ 66cbe681
History | View | Annotate | Download (7.5 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 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuBar; |
35 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.MenuItem; |
36 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.PopupPanel; |
37 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TreeItem; |
38 | 14ad7326 | pastith | |
39 | 14ad7326 | pastith | /**
|
40 | 14ad7326 | pastith | * The 'Folder Context' menu implementation.
|
41 | 14ad7326 | pastith | */
|
42 | 14ad7326 | pastith | public class FolderContextMenu extends PopupPanel { |
43 | 14ad7326 | pastith | |
44 | 14ad7326 | pastith | /**
|
45 | 14ad7326 | pastith | * The widget's images.
|
46 | 14ad7326 | pastith | */
|
47 | 14ad7326 | pastith | private final Images images; |
48 | 14ad7326 | pastith | |
49 | 14ad7326 | pastith | /**
|
50 | 14ad7326 | pastith | * The image bundle for this widget's images that reuses images defined in
|
51 | 14ad7326 | pastith | * other menus.
|
52 | 14ad7326 | pastith | */
|
53 | 14ad7326 | pastith | public interface Images extends FileMenu.Images, EditMenu.Images { |
54 | 14ad7326 | pastith | } |
55 | a93eb00b | pastith | |
56 | a93eb00b | pastith | private MenuItem pasteItem; |
57 | a93eb00b | pastith | |
58 | 14ad7326 | pastith | /**
|
59 | 14ad7326 | pastith | * The widget's constructor.
|
60 | 14ad7326 | pastith | *
|
61 | 14ad7326 | pastith | * @param newImages the image bundle passed on by the parent object
|
62 | 14ad7326 | pastith | */
|
63 | 14ad7326 | pastith | public FolderContextMenu(final Images newImages) { |
64 | 14ad7326 | pastith | // The popup's constructor's argument is a boolean specifying that it
|
65 | 14ad7326 | pastith | // auto-close itself when the user clicks outside of it.
|
66 | 14ad7326 | pastith | super(true); |
67 | 14ad7326 | pastith | setAnimationEnabled(true);
|
68 | 14ad7326 | pastith | images = newImages; |
69 | 14ad7326 | pastith | |
70 | 14ad7326 | pastith | pasteItem = new MenuItem("<span>" + newImages.paste().getHTML() + " Paste</span>", true, new PasteCommand(this)); |
71 | a93eb00b | pastith | MenuBar contextMenu = new MenuBar(true); |
72 | a93eb00b | pastith | Folders folders = GSS.get().getFolders(); |
73 | a93eb00b | pastith | TreeItem selectedItem = folders.getCurrent(); |
74 | 14ad7326 | pastith | |
75 | 14ad7326 | pastith | |
76 | 14ad7326 | pastith | if(selectedItem != null) |
77 | 14ad7326 | pastith | if(folders.isTrashItem(selectedItem)){
|
78 | ad8b38cb | koutsoub | if (folders.isTrash(selectedItem)){
|
79 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.delete().getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this)); |
80 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
81 | ad8b38cb | koutsoub | } |
82 | a93eb00b | pastith | else {
|
83 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.viewText().getHTML() + " Restore folder and contents</span>", true, new RestoreTrashCommand(this)); |
84 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
85 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
86 | a93eb00b | pastith | } |
87 | 14ad7326 | pastith | } |
88 | 14ad7326 | pastith | else if(folders.isFileItem(selectedItem)){ |
89 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.folderNew().getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
90 | 5c6b4b2c | Panagiotis Astithas | contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
91 | a93eb00b | pastith | boolean notRootFolder = !folders.getRootItem().equals(selectedItem);
|
92 | a93eb00b | pastith | if (notRootFolder) {
|
93 | a93eb00b | pastith | // do not show the copy & cut option for the user's root folder
|
94 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.cut().getHTML() + " Cut</span>", true, new CutCommand(this)); |
95 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.copy().getHTML() + " Copy</span>", true, new CopyCommand(this)); |
96 | a93eb00b | pastith | } |
97 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
98 | a93eb00b | pastith | if (notRootFolder) {
|
99 | a93eb00b | pastith | // do not show delete options for the user's root folder
|
100 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.emptyTrash().getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
101 | a93eb00b | pastith | contextMenu.addItem("<span>" + newImages.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
102 | a93eb00b | pastith | } |
103 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
104 | 892a2836 | fstamatelopoulos | contextMenu.addItem("<span>" + newImages.sharing().getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
105 | 892a2836 | fstamatelopoulos | contextMenu.addItem("<span>" + newImages.viewText().getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
106 | 14ad7326 | pastith | } |
107 | 14ad7326 | pastith | else if(!folders.isMyShares(selectedItem) && folders.isMySharedItem(selectedItem)){ |
108 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.folderNew().getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
109 | 5c6b4b2c | Panagiotis Astithas | contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
110 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.cut().getHTML() + " Cut</span>", true, new CutCommand(this)); |
111 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.copy().getHTML() + " Copy</span>", true, new CopyCommand(this)); |
112 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
113 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.emptyTrash().getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
114 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
115 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
116 | 892a2836 | fstamatelopoulos | contextMenu.addItem("<span>" + newImages.viewText().getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
117 | 14ad7326 | pastith | } |
118 | a52ea5e4 | pastith | else if(!folders.isOthersShared(selectedItem) && folders.isOthersSharedItem(selectedItem) && !(GSS.get().getCurrentSelection() instanceof OtherUserResource)){ |
119 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.folderNew().getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
120 | 5c6b4b2c | Panagiotis Astithas | contextMenu.addItem("<span>" + newImages.fileUpdate().getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
121 | 66cbe681 | Dimitris Routsis | contextMenu.addItem("<span>" + newImages.cut().getHTML() + " Cut</span>", true, new CutCommand(this)); |
122 | 14ad7326 | pastith | contextMenu.addItem("<span>" + newImages.copy().getHTML() + " Copy</span>", true, new CopyCommand(this)); |
123 | 14ad7326 | pastith | contextMenu.addItem(pasteItem); |
124 | 66cbe681 | Dimitris Routsis | contextMenu.addItem("<span>" + newImages.emptyTrash().getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
125 | 66cbe681 | Dimitris Routsis | contextMenu.addItem("<span>" + newImages.delete().getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
126 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
127 | 892a2836 | fstamatelopoulos | contextMenu.addItem("<span>" + newImages.viewText().getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
128 | ad8b38cb | koutsoub | } else if(!selectedItem.equals(folders.getSharesItem())) |
129 | ad8b38cb | koutsoub | contextMenu.addItem("<span>" + images.refresh().getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
130 | 14ad7326 | pastith | add(contextMenu); |
131 | 14ad7326 | pastith | if (GSS.get().getClipboard().hasFolderOrFileItem())
|
132 | 14ad7326 | pastith | pasteItem.setVisible(true);
|
133 | 14ad7326 | pastith | else
|
134 | 14ad7326 | pastith | pasteItem.setVisible(false);
|
135 | 14ad7326 | pastith | } |
136 | 14ad7326 | pastith | |
137 | 14ad7326 | pastith | } |