X-Git-Url: https://code.grnet.gr/git/pithos-web-client/blobdiff_plain/006ec41a8f00600ee787510dbf1809be360b0947..5f91f72debed85ff6ce474bac9d306026886eac0:/src/gr/grnet/pithos/web/client/ToolsMenu.java
diff --git a/src/gr/grnet/pithos/web/client/ToolsMenu.java b/src/gr/grnet/pithos/web/client/ToolsMenu.java
index 9b12832..f1d1dfb 100644
--- a/src/gr/grnet/pithos/web/client/ToolsMenu.java
+++ b/src/gr/grnet/pithos/web/client/ToolsMenu.java
@@ -41,10 +41,8 @@ import gr.grnet.pithos.web.client.commands.CutCommand;
import gr.grnet.pithos.web.client.commands.DeleteCommand;
import gr.grnet.pithos.web.client.commands.DeleteGroupCommand;
import gr.grnet.pithos.web.client.commands.EmptyTrashCommand;
-import gr.grnet.pithos.web.client.commands.NewFolderCommand;
import gr.grnet.pithos.web.client.commands.PasteCommand;
import gr.grnet.pithos.web.client.commands.PropertiesCommand;
-import gr.grnet.pithos.web.client.commands.RefreshCommand;
import gr.grnet.pithos.web.client.commands.RemoveUserCommand;
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand;
import gr.grnet.pithos.web.client.commands.ToTrashCommand;
@@ -82,7 +80,7 @@ public class ToolsMenu extends PopupPanel {
private MenuItem pasteItem;
- private boolean empty = false;;
+ private boolean empty = true;
/**
* The widget's constructor.
@@ -113,25 +111,30 @@ public class ToolsMenu extends PopupPanel {
else if (!folder.isContainer()) {
cut = new MenuItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut folder", true, new CutCommand(app, this, folder));
}
- if (cut != null)
+ if (cut != null) {
contextMenu.addItem(cut);
+ empty = false;
+ }
}
}
MenuItem copy = null;
if (files != null && !files.isEmpty())
copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy files", true, new CopyCommand(app, this, files));
- else if (!folder.isContainer())
+ else if (isFolderTreeSelected && !folder.isContainer())
copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy folder", true, new CopyCommand(app, this, folder));
- if (copy != null)
+ if (copy != null) {
contextMenu.addItem(copy);
+ empty = false;
+ }
if (canWrite) {
if (!app.getClipboard().isEmpty()) {
Object item = app.getClipboard().getItem();
boolean showPaste = false;
if (item instanceof List) {
- List _files = (List) item;
+ @SuppressWarnings("unchecked")
+ List _files = (List) item;
if (_files.get(0).getOwner().equals(folder.getOwner()))
showPaste = true;
}
@@ -143,6 +146,7 @@ public class ToolsMenu extends PopupPanel {
if (showPaste) {
pasteItem = new MenuItem("", true, new PasteCommand(app, this, folder));
contextMenu.addItem(pasteItem);
+ empty = false;
}
}
@@ -154,8 +158,10 @@ public class ToolsMenu extends PopupPanel {
else if (!folder.isContainer()) {
moveToTrash = new MenuItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move folder to Trash", true, new ToTrashCommand(app, this, folder));
}
- if (moveToTrash != null)
+ if (moveToTrash != null) {
contextMenu.addItem(moveToTrash);
+ empty = false;
+ }
MenuItem delete = null;
if (files != null && !files.isEmpty()) {
@@ -163,16 +169,22 @@ public class ToolsMenu extends PopupPanel {
}
else if (!folder.isContainer())
delete = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete folder", true, new DeleteCommand(app, this, folder, MessagePanel.images));
- if (delete != null)
+ if (delete != null) {
contextMenu.addItem(delete);
+ empty = false;
+ }
- MenuItem properties = null;
- if (files != null && files.size() == 1)
- properties = new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " File properties", true, new PropertiesCommand(app, this, files, images, 0));
- else if (!folder.isContainer())
- properties = new MenuItem("", true, new PropertiesCommand(app, this, folder, newImages, 0));
- if (properties != null)
- contextMenu.addItem(properties);
+ if (files != null && files.size() == 1) {
+ contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " File properties", true, new PropertiesCommand(app, this, files, PropertiesCommand.PROPERTIES)));
+ contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.group()).getHTML() + " Sharing", true, new PropertiesCommand(app, this, files, PropertiesCommand.PERMISSIONS)));
+ contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.versions()).getHTML() + " Versions", true, new PropertiesCommand(app, this, files, PropertiesCommand.VERSIONS)));
+ empty = false;
+ }
+ else if (!folder.isContainer()) {
+ contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Folder properties", true, new PropertiesCommand(app, this, folder, PropertiesCommand.PROPERTIES)));
+ contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Folder sharing", true, new PropertiesCommand(app, this, folder, PropertiesCommand.PERMISSIONS)));
+ empty = false;
+ }
}
if (files != null && !files.isEmpty()) {
contextMenu.addItem(new MenuItem("" + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download", true, new Command() {
@@ -180,9 +192,10 @@ public class ToolsMenu extends PopupPanel {
@Override
public void execute() {
for (File f: files)
- Window.open(app.getApiPath() + files.get(0).getOwner() + files.get(0).getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
+ Window.open(app.getApiPath() + f.getOwner() + f.getUri() + "?X-Auth-Token=" + app.getToken(), "_blank", "");
}
}));
+ empty = false;
}
}
}
@@ -194,13 +207,15 @@ public class ToolsMenu extends PopupPanel {
else
restore = new MenuItem("" + AbstractImagePrototype.create(images.versions()).getHTML() + " Restore", true, new RestoreTrashCommand(app, this, folder));
contextMenu.addItem(restore);
-
+
MenuItem delete = new MenuItem("", true, new DeleteCommand(app, this, folder, MessagePanel.images));
contextMenu.addItem(delete);
+ empty = false;
}
else {
MenuItem emptyTrash = new MenuItem("" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + " Empty Trash", true, new EmptyTrashCommand(app, this));
contextMenu.addItem(emptyTrash);
+ empty = false;
}
}
}
@@ -210,6 +225,7 @@ public class ToolsMenu extends PopupPanel {
if (o instanceof User) {
MenuItem removeUser = new MenuItem("" + AbstractImagePrototype.create(images.delete()).getHTML() + " Remove User", true, new RemoveUserCommand(app, this, (User) o));
contextMenu.addItem(removeUser);
+ empty = false;
}
else if (o instanceof Group) {
MenuItem addUser = new MenuItem("" + AbstractImagePrototype.create(images.user()).getHTML() + " Add User", true, new AddUserCommand(app, this, (Group) o));
@@ -217,14 +233,14 @@ public class ToolsMenu extends PopupPanel {
MenuItem deleteGroup = new MenuItem("" + AbstractImagePrototype.create(images.delete()).getHTML() + " Delete Group", true, new DeleteGroupCommand(app, this, (Group) o));
contextMenu.addItem(deleteGroup);
+ empty = false;
}
else {
MenuItem createGroup = new MenuItem("" + AbstractImagePrototype.create(images.group()).getHTML() + " Create Group", true, new CreateGroupCommand(app, this));
contextMenu.addItem(createGroup);
+ empty = false;
}
}
- else
- empty = true;
}
add(contextMenu);
}