X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/5c6b4b2c4cf6ba7db2ab1225ccec56d3a8dcbd14..25cc4c1bef49746c8fd3e1758cebcd5b215a0760:/src/gr/ebs/gss/client/FolderContextMenu.java
diff --git a/src/gr/ebs/gss/client/FolderContextMenu.java b/src/gr/ebs/gss/client/FolderContextMenu.java
index e61114c..21d6ead 100644
--- a/src/gr/ebs/gss/client/FolderContextMenu.java
+++ b/src/gr/ebs/gss/client/FolderContextMenu.java
@@ -29,12 +29,21 @@ import gr.ebs.gss.client.commands.RefreshCommand;
import gr.ebs.gss.client.commands.RestoreTrashCommand;
import gr.ebs.gss.client.commands.ToTrashCommand;
import gr.ebs.gss.client.commands.UploadFileCommand;
+import gr.ebs.gss.client.rest.resource.MyFolderResource;
import gr.ebs.gss.client.rest.resource.OtherUserResource;
+import gr.ebs.gss.client.rest.resource.OthersFolderResource;
+import gr.ebs.gss.client.rest.resource.OthersResource;
+import gr.ebs.gss.client.rest.resource.RestResource;
+import gr.ebs.gss.client.rest.resource.SharedFolderResource;
+import gr.ebs.gss.client.rest.resource.SharedResource;
+import gr.ebs.gss.client.rest.resource.TrashFolderResource;
+import gr.ebs.gss.client.rest.resource.TrashResource;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.TreeItem;
/**
* The 'Folder Context' menu implementation.
@@ -50,7 +59,7 @@ public class FolderContextMenu extends PopupPanel {
* The image bundle for this widget's images that reuses images defined in
* other menus.
*/
- public interface Images extends FileMenu.Images, EditMenu.Images {
+ public interface Images extends ClientBundle,FileMenu.Images, EditMenu.Images {
}
private MenuItem pasteItem;
@@ -67,63 +76,121 @@ public class FolderContextMenu extends PopupPanel {
setAnimationEnabled(true);
images = newImages;
- pasteItem = new MenuItem("" + newImages.paste().getHTML() + " Paste", true, new PasteCommand(this));
+ pasteItem = new MenuItem("" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste", true, new PasteCommand(this));
MenuBar contextMenu = new MenuBar(true);
- Folders folders = GSS.get().getFolders();
- TreeItem selectedItem = folders.getCurrent();
+
+
+
+ RestResource selectedItem = GSS.get().getTreeView().getSelection();
if(selectedItem != null)
- if(folders.isTrashItem(selectedItem)){
- if (folders.isTrash(selectedItem)){
- contextMenu.addItem("" + newImages.delete().getHTML() + " Empty Trash", true, new EmptyTrashCommand(this));
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
- }
- else {
- contextMenu.addItem("" + newImages.viewText().getHTML() + " Restore folder and contents", true, new RestoreTrashCommand(this));
- contextMenu.addItem("" + newImages.delete().getHTML() + " Delete", true, new DeleteCommand(this, newImages));
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
- }
- }
- else if(folders.isFileItem(selectedItem)){
- contextMenu.addItem("" + newImages.folderNew().getHTML() + " New Folder", true, new NewFolderCommand(this, images));
- contextMenu.addItem("" + newImages.fileUpdate().getHTML() + " Upload", true, new UploadFileCommand(this));
- boolean notRootFolder = !folders.getRootItem().equals(selectedItem);
+ if(selectedItem instanceof MyFolderResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this));
+ boolean notRootFolder = !GSS.get().getTreeView().getMyFolders().equals(selectedItem);
if (notRootFolder) {
// do not show the copy & cut option for the user's root folder
- contextMenu.addItem("" + newImages.cut().getHTML() + " Cut", true, new CutCommand(this));
- contextMenu.addItem("" + newImages.copy().getHTML() + " Copy", true, new CopyCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(this));
}
contextMenu.addItem(pasteItem);
if (notRootFolder) {
// do not show delete options for the user's root folder
- contextMenu.addItem("" + newImages.emptyTrash().getHTML() + " Move to Trash", true, new ToTrashCommand(this));
- contextMenu.addItem("" + newImages.delete().getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ }
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ }
+ if(selectedItem instanceof SharedFolderResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(this));
+ contextMenu.addItem(pasteItem);
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ }
+ if(selectedItem instanceof TrashFolderResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Restore folder and contents", true, new RestoreTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ }
+ if(selectedItem instanceof OthersFolderResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(this));
+ contextMenu.addItem(pasteItem);
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ }
+ if(selectedItem instanceof TrashResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Restore Trash", true, new RestoreTrashCommand(this));
+
+ MenuItem emptyTrash = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Empty Trash", true, new EmptyTrashCommand(this));
+ emptyTrash.getElement().setId("folderContextMenu.emptyTrash");
+ contextMenu.addItem(emptyTrash);
+
+ MenuItem refresh = new MenuItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ emptyTrash.getElement().setId("folderContextMenu.refresh");
+ contextMenu.addItem(refresh);
+
+ }
+ if(selectedItem instanceof SharedResource || selectedItem instanceof OthersResource || selectedItem instanceof OtherUserResource){
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ }
+
+ /*
+ if(folders.isTrashItem(selectedItem)){
+ if (folders.isTrash(selectedItem)){
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Empty Trash", true, new EmptyTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ }
+ else {
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Restore folder and contents", true, new RestoreTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
}
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
- contextMenu.addItem("" + newImages.sharing().getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
- contextMenu.addItem("" + newImages.viewText().getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ }
+ else if(folders.isFileItem(selectedItem)){
+
}
else if(!folders.isMyShares(selectedItem) && folders.isMySharedItem(selectedItem)){
- contextMenu.addItem("" + newImages.folderNew().getHTML() + " New Folder", true, new NewFolderCommand(this, images));
- contextMenu.addItem("" + newImages.fileUpdate().getHTML() + " Upload", true, new UploadFileCommand(this));
- contextMenu.addItem("" + newImages.cut().getHTML() + " Cut", true, new CutCommand(this));
- contextMenu.addItem("" + newImages.copy().getHTML() + " Copy", true, new CopyCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(this));
contextMenu.addItem(pasteItem);
- contextMenu.addItem("" + newImages.emptyTrash().getHTML() + " Move to Trash", true, new ToTrashCommand(this));
- contextMenu.addItem("" + newImages.delete().getHTML() + " Delete", true, new DeleteCommand(this, newImages));
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
- contextMenu.addItem("" + newImages.viewText().getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
}
else if(!folders.isOthersShared(selectedItem) && folders.isOthersSharedItem(selectedItem) && !(GSS.get().getCurrentSelection() instanceof OtherUserResource)){
- contextMenu.addItem("" + newImages.folderNew().getHTML() + " New Folder", true, new NewFolderCommand(this, images));
- contextMenu.addItem("" + newImages.fileUpdate().getHTML() + " Upload", true, new UploadFileCommand(this));
- contextMenu.addItem("" + newImages.copy().getHTML() + " Copy", true, new CopyCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder", true, new NewFolderCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload", true, new UploadFileCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut", true, new CutCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy", true, new CopyCommand(this));
contextMenu.addItem(pasteItem);
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
- contextMenu.addItem("" + newImages.viewText().getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash", true, new ToTrashCommand(this));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteCommand(this, newImages));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing", true, new PropertiesCommand(this, newImages, 1));
+ contextMenu.addItem("" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties", true, new PropertiesCommand(this, newImages, 0));
} else if(!selectedItem.equals(folders.getSharesItem()))
- contextMenu.addItem("" + images.refresh().getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ contextMenu.addItem("" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh", true, new RefreshCommand(this, images));
+ */
+
add(contextMenu);
if (GSS.get().getClipboard().hasFolderOrFileItem())
pasteItem.setVisible(true);