root / web_client / src / gr / grnet / pithos / web / client / FolderContextMenu.java @ f55cf326
History | View | Annotate | Download (5.6 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 | ab1eb3f8 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | ab1eb3f8 | Christos Stathis | |
37 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CopyCommand; |
38 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CutCommand; |
39 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.DeleteCommand; |
40 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.NewFolderCommand; |
41 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PasteCommand; |
42 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PropertiesCommand; |
43 | ab1eb3f8 | Christos Stathis | import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
44 | 287c3d8d | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
45 | ab1eb3f8 | Christos Stathis | |
46 | ab1eb3f8 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
47 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
48 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.MenuBar; |
49 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.MenuItem; |
50 | ab1eb3f8 | Christos Stathis | import com.google.gwt.user.client.ui.PopupPanel; |
51 | ab1eb3f8 | Christos Stathis | |
52 | ab1eb3f8 | Christos Stathis | /**
|
53 | ab1eb3f8 | Christos Stathis | * The 'Folder Context' menu implementation.
|
54 | ab1eb3f8 | Christos Stathis | */
|
55 | ab1eb3f8 | Christos Stathis | public class FolderContextMenu extends PopupPanel { |
56 | ab1eb3f8 | Christos Stathis | |
57 | ab1eb3f8 | Christos Stathis | /**
|
58 | ab1eb3f8 | Christos Stathis | * The widget's images.
|
59 | ab1eb3f8 | Christos Stathis | */
|
60 | ab1eb3f8 | Christos Stathis | private final Images images; |
61 | ab1eb3f8 | Christos Stathis | |
62 | ab1eb3f8 | Christos Stathis | /**
|
63 | ab1eb3f8 | Christos Stathis | * The image bundle for this widget's images that reuses images defined in
|
64 | ab1eb3f8 | Christos Stathis | * other menus.
|
65 | ab1eb3f8 | Christos Stathis | */
|
66 | ab1eb3f8 | Christos Stathis | public interface Images extends ClientBundle,FileMenu.Images, EditMenu.Images { |
67 | ab1eb3f8 | Christos Stathis | } |
68 | ab1eb3f8 | Christos Stathis | |
69 | ab1eb3f8 | Christos Stathis | private MenuItem pasteItem; |
70 | ab1eb3f8 | Christos Stathis | |
71 | ab1eb3f8 | Christos Stathis | /**
|
72 | ab1eb3f8 | Christos Stathis | * The widget's constructor.
|
73 | ab1eb3f8 | Christos Stathis | *
|
74 | ab1eb3f8 | Christos Stathis | * @param newImages the image bundle passed on by the parent object
|
75 | ab1eb3f8 | Christos Stathis | */
|
76 | 287c3d8d | Christos Stathis | public FolderContextMenu(final Images newImages, Folder folder) { |
77 | ab1eb3f8 | Christos Stathis | // The popup's constructor's argument is a boolean specifying that it
|
78 | ab1eb3f8 | Christos Stathis | // auto-close itself when the user clicks outside of it.
|
79 | ab1eb3f8 | Christos Stathis | super(true); |
80 | ab1eb3f8 | Christos Stathis | setAnimationEnabled(true);
|
81 | ab1eb3f8 | Christos Stathis | images = newImages; |
82 | 287c3d8d | Christos Stathis | MenuBar contextMenu = new MenuBar(true); |
83 | ab1eb3f8 | Christos Stathis | |
84 | 287c3d8d | Christos Stathis | MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, folder, images)); |
85 | 287c3d8d | Christos Stathis | contextMenu.addItem(newFolder); |
86 | ab1eb3f8 | Christos Stathis | |
87 | cf2dddff | Christos Stathis | if (!folder.isContainer()) {
|
88 | f55cf326 | Christos Stathis | MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(Pithos.get(), this, folder)); |
89 | cf2dddff | Christos Stathis | contextMenu.addItem(cut); |
90 | cf2dddff | Christos Stathis | } |
91 | ab1eb3f8 | Christos Stathis | |
92 | f55cf326 | Christos Stathis | MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(Pithos.get(), this, folder)); |
93 | 287c3d8d | Christos Stathis | contextMenu.addItem(copy); |
94 | ab1eb3f8 | Christos Stathis | |
95 | f55cf326 | Christos Stathis | if (!Pithos.get().getClipboard().isEmpty()) {
|
96 | f55cf326 | Christos Stathis | pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(Pithos.get(), this, folder)); |
97 | cf2dddff | Christos Stathis | contextMenu.addItem(pasteItem); |
98 | cf2dddff | Christos Stathis | } |
99 | 287c3d8d | Christos Stathis | |
100 | cf2dddff | Christos Stathis | if (!folder.isContainer()) {
|
101 | f55cf326 | Christos Stathis | MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(Pithos.get(), this, folder)); |
102 | cf2dddff | Christos Stathis | contextMenu.addItem(moveToTrash); |
103 | 287c3d8d | Christos Stathis | |
104 | cf2dddff | Christos Stathis | MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, folder, newImages)); |
105 | cf2dddff | Christos Stathis | contextMenu.addItem(delete); |
106 | cf2dddff | Christos Stathis | } |
107 | 287c3d8d | Christos Stathis | |
108 | cf2dddff | Christos Stathis | // MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
|
109 | cf2dddff | Christos Stathis | // contextMenu.addItem(refresh);
|
110 | 287c3d8d | Christos Stathis | |
111 | cf2dddff | Christos Stathis | // MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1));
|
112 | cf2dddff | Christos Stathis | // contextMenu.addItem(sharing);
|
113 | 287c3d8d | Christos Stathis | |
114 | f55cf326 | Christos Stathis | MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(Pithos.get(), this, folder, newImages, 0)); |
115 | 33b61be6 | Christos Stathis | contextMenu.addItem(properties); |
116 | ab1eb3f8 | Christos Stathis | |
117 | ab1eb3f8 | Christos Stathis | add(contextMenu); |
118 | ab1eb3f8 | Christos Stathis | } |
119 | ab1eb3f8 | Christos Stathis | } |