root / src / gr / grnet / pithos / web / client / FolderContextMenu.java @ a33428e4
History | View | Annotate | Download (5.6 kB)
1 | a57faaf0 | Christos Stathis | /*
|
---|---|---|---|
2 | 63366925 | Christos Stathis | * Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | a57faaf0 | Christos Stathis | */
|
35 | a57faaf0 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | a57faaf0 | Christos Stathis | |
37 | f6445935 | Christos Stathis | import gr.grnet.pithos.web.client.FileContextMenu.Images; |
38 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CopyCommand; |
39 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.CutCommand; |
40 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.DeleteCommand; |
41 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.NewFolderCommand; |
42 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PasteCommand; |
43 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.PropertiesCommand; |
44 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
45 | 447407c8 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
46 | a57faaf0 | Christos Stathis | |
47 | a57faaf0 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
48 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
49 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.MenuBar; |
50 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.MenuItem; |
51 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.PopupPanel; |
52 | a57faaf0 | Christos Stathis | |
53 | a57faaf0 | Christos Stathis | /**
|
54 | a57faaf0 | Christos Stathis | * The 'Folder Context' menu implementation.
|
55 | a57faaf0 | Christos Stathis | */
|
56 | a57faaf0 | Christos Stathis | public class FolderContextMenu extends PopupPanel { |
57 | a57faaf0 | Christos Stathis | |
58 | a57faaf0 | Christos Stathis | /**
|
59 | a57faaf0 | Christos Stathis | * The widget's images.
|
60 | a57faaf0 | Christos Stathis | */
|
61 | a57faaf0 | Christos Stathis | private final Images images; |
62 | a57faaf0 | Christos Stathis | |
63 | a57faaf0 | Christos Stathis | /**
|
64 | a57faaf0 | Christos Stathis | * The image bundle for this widget's images that reuses images defined in
|
65 | a57faaf0 | Christos Stathis | * other menus.
|
66 | a57faaf0 | Christos Stathis | */
|
67 | f6445935 | Christos Stathis | public interface Images extends ClientBundle, FileContextMenu.Images { |
68 | a57faaf0 | Christos Stathis | } |
69 | a57faaf0 | Christos Stathis | |
70 | a57faaf0 | Christos Stathis | private MenuItem pasteItem; |
71 | a57faaf0 | Christos Stathis | |
72 | a57faaf0 | Christos Stathis | /**
|
73 | a57faaf0 | Christos Stathis | * The widget's constructor.
|
74 | a57faaf0 | Christos Stathis | *
|
75 | a57faaf0 | Christos Stathis | * @param newImages the image bundle passed on by the parent object
|
76 | a57faaf0 | Christos Stathis | */
|
77 | a7c43f26 | Christos Stathis | public FolderContextMenu(Pithos app, final Images newImages, Folder folder) { |
78 | a57faaf0 | Christos Stathis | // The popup's constructor's argument is a boolean specifying that it
|
79 | a57faaf0 | Christos Stathis | // auto-close itself when the user clicks outside of it.
|
80 | a57faaf0 | Christos Stathis | super(true); |
81 | a57faaf0 | Christos Stathis | setAnimationEnabled(true);
|
82 | a57faaf0 | Christos Stathis | images = newImages; |
83 | 447407c8 | Christos Stathis | MenuBar contextMenu = new MenuBar(true); |
84 | a57faaf0 | Christos Stathis | |
85 | a7c43f26 | Christos Stathis | MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(app, this, folder, images)); |
86 | 447407c8 | Christos Stathis | contextMenu.addItem(newFolder); |
87 | a57faaf0 | Christos Stathis | |
88 | 390f5c04 | Christos Stathis | if (!folder.isContainer()) {
|
89 | a7c43f26 | Christos Stathis | MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(app, this, folder)); |
90 | 390f5c04 | Christos Stathis | contextMenu.addItem(cut); |
91 | 390f5c04 | Christos Stathis | } |
92 | a57faaf0 | Christos Stathis | |
93 | a7c43f26 | Christos Stathis | MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(app, this, folder)); |
94 | 447407c8 | Christos Stathis | contextMenu.addItem(copy); |
95 | a57faaf0 | Christos Stathis | |
96 | a7c43f26 | Christos Stathis | if (!app.getClipboard().isEmpty()) {
|
97 | a7c43f26 | Christos Stathis | pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(app, this, folder)); |
98 | 390f5c04 | Christos Stathis | contextMenu.addItem(pasteItem); |
99 | 390f5c04 | Christos Stathis | } |
100 | 447407c8 | Christos Stathis | |
101 | 390f5c04 | Christos Stathis | if (!folder.isContainer()) {
|
102 | a7c43f26 | Christos Stathis | MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(app, this, folder)); |
103 | 390f5c04 | Christos Stathis | contextMenu.addItem(moveToTrash); |
104 | 447407c8 | Christos Stathis | |
105 | f6445935 | Christos Stathis | MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(app, this, folder, MessagePanel.images)); |
106 | 390f5c04 | Christos Stathis | contextMenu.addItem(delete); |
107 | ecf95c9e | Christos Stathis | |
108 | ecf95c9e | Christos Stathis | MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(app, this, folder, newImages, 0)); |
109 | ecf95c9e | Christos Stathis | contextMenu.addItem(properties); |
110 | 390f5c04 | Christos Stathis | } |
111 | 447407c8 | Christos Stathis | |
112 | 390f5c04 | Christos Stathis | // MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
|
113 | 390f5c04 | Christos Stathis | // contextMenu.addItem(refresh);
|
114 | 447407c8 | Christos Stathis | |
115 | 390f5c04 | Christos Stathis | // MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1));
|
116 | 390f5c04 | Christos Stathis | // contextMenu.addItem(sharing);
|
117 | 447407c8 | Christos Stathis | |
118 | a57faaf0 | Christos Stathis | |
119 | a57faaf0 | Christos Stathis | add(contextMenu); |
120 | a57faaf0 | Christos Stathis | } |
121 | a57faaf0 | Christos Stathis | } |