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.dnd.DnDTreeItem;
import gr.ebs.gss.client.rest.resource.FileResource;
import gr.ebs.gss.client.rest.resource.FolderResource;
+import gr.ebs.gss.client.rest.resource.RestResource;
+import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
+import gr.ebs.gss.client.rest.resource.TrashFolderResource;
import java.util.List;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.ContextMenuEvent;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.Command;
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 'File Context' menu implementation.
@Source("gr/ebs/gss/resources/doc_versions.png")
ImageResource versions();
+ @Override
@Source("gr/ebs/gss/resources/group.png")
ImageResource sharing();
+ @Override
@Source("gr/ebs/gss/resources/border_remove.png")
ImageResource unselectAll();
// The command that does some validation before downloading a file.
Command downloadCmd = new Command() {
+ @Override
public void execute() {
hide();
GSS.get().getTopPanel().getFileMenu().preDownloadCheck();
};
pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(this));
-
+ pasteItem.getElement().setId("FileContextMenu.paste");
+ RestResource sel = GSS.get().getTreeView().getSelection();
MenuBar contextMenu = new MenuBar(true);
if (isEmpty) {
contextMenu.addItem(pasteItem);
- if (GSS.get().getFolders().getCurrent() != null)
- if (GSS.get().getFolders().isFileItem(GSS.get().getFolders().getCurrent()))
+ if (sel != null)
+ /*TODO:CELLTREE
+ if (GSS.get().getTreeView().isFileItem(GSS.get().getTreeView().getCurrent()))
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
- else if (GSS.get().getFolders().isMySharedItem(GSS.get().getFolders().getCurrent()) || GSS .get()
- .getFolders()
+ else if (GSS.get().getTreeView().isMySharedItem(GSS.get().getTreeView().getCurrent()) || GSS .get()
+ .getTreeView()
.isOthersSharedItem(GSS .get()
- .getFolders()
+ .getTreeView()
.getCurrent()))
- if(GSS.get().getFolders().getCurrent().getUserObject() instanceof FolderResource)
+ if(sel instanceof FolderResource)
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
- contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
+ */
+ if(sel instanceof RestResourceWrapper && !(sel instanceof TrashFolderResource)){
+ MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
+ upload.getElement().setId("fileContextMenu.upload");
+ contextMenu.addItem(upload);
+ }
+ MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
+ refresh.getElement().setId("fileContextMenu.refresh");
+ contextMenu.addItem(refresh);
+
} else if (isTrash) {
- contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(this));
- contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, images));
+ MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(this));
+ restore.getElement().setId("fileContextMenu.restore");
+ contextMenu.addItem(restore);
+
+ MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, images));
+ delete.getElement().setId("fileContextMenu.delete");
+ contextMenu.addItem(delete);
} else {
final Command unselectAllCommand = new Command() {
+ @Override
public void execute() {
hide();
if(GSS.get().isFileListShowing())
GSS.get().getSearchResults().clearSelectedRows();
}
};
- cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this));
+ cutItem = new MenuItem("<span id='fileContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this));
+ cutItem.getElement().setId("fileContextMenu.cut");
+
copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this));
-
+ copyItem.getElement().setId("fileContextMenu.copy");
+
updateItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
+ updateItem.getElement().setId("fileContextMenu.upload");
trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this));
+ trashItem.getElement().setId("fileContextMenu.moveToTrash");
+
deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, images));
+ deleteItem.getElement().setId("fileContextMenu.delete");
sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, images, 1));
+ sharingItem.getElement().setId("fileContextMenu.sharing");
+
propItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, images, 0));
+ propItem.getElement().setId("fileContextMenu.properties");
- TreeItem currentFolder = gss.getFolders().getCurrent();
- if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
+
+ if(sel!=null && sel instanceof FolderResource)
contextMenu.addItem(updateItem);
String[] link = {"", ""};
gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
downloadItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);
+ downloadItem.getElement().setId("fileContextMenu.download");
contextMenu.addItem(downloadItem);
+
gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
+ saveAsItem.getElement().setId("fileContextMenu.saveAs");
contextMenu.addItem(saveAsItem);
contextMenu.addItem(cutItem);
contextMenu.addItem(copyItem);
- if(currentFolder!=null && currentFolder.getUserObject() instanceof FolderResource)
+ if(sel!=null && sel instanceof FolderResource)
contextMenu.addItem(pasteItem);
- contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect</span>", true, unselectAllCommand);
+ MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + " Unselect</span>", true, unselectAllCommand);
+ unSelect.getElement().setId("fileContextMenu.unSelect");
+ contextMenu.addItem(unSelect);
+
contextMenu.addItem(trashItem);
contextMenu.addItem(deleteItem);
- contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
+
+ MenuItem refresh = new MenuItem("<span id='fileContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
+// refresh.getElement().setId("fileContextMenu.refresh");
+ contextMenu.addItem(refresh);
+
contextMenu.addItem(sharingItem);
contextMenu.addItem(propItem);
}
menu.show();
} else if (GSS.get().getCurrentSelection() instanceof List) {
FileContextMenu menu;
- if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
+ /*TODO: CELLTREE
+ if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
menu = new FileContextMenu(images, true, false);
else {
menu = new FileContextMenu(images, false, false);
menu.onMultipleSelection();
}
+ */
+ menu = new FileContextMenu(images, false, false);
+ menu.onMultipleSelection();
int left = event.getRelativeElement().getAbsoluteLeft();
int top = event.getRelativeElement().getAbsoluteTop() + event.getRelativeElement().getOffsetHeight();
menu.setPopupPosition(left, top);
}
}
- public void onEvent(Event event) {
+
+ public void onContextEvent(ContextMenuEvent event) {
if (GSS.get().getCurrentSelection() != null)
if (GSS.get().getCurrentSelection() instanceof FileResource) {
FileResource res = (FileResource) GSS.get().getCurrentSelection();
menu = new FileContextMenu(images, true, false);
else
menu = new FileContextMenu(images, false, false);
- int left = event.getClientX();
- int top = event.getClientY();
+ int left = event.getNativeEvent().getClientX();
+ int top = event.getNativeEvent().getClientY();
menu.setPopupPosition(left, top);
menu.show();
+
} else if (GSS.get().getCurrentSelection() instanceof List) {
FileContextMenu menu;
- if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
+ /*TODO: CELLTREE
+ if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
menu = new FileContextMenu(images, true, false);
else {
menu = new FileContextMenu(images, false, false);
menu.onMultipleSelection();
}
+ */
+ int left = event.getNativeEvent().getClientX();
+ int top = event.getNativeEvent().getClientY();
+ //menu.setPopupPosition(left, top);
+ //menu.show();
+ }
+ }
+
+ public FileContextMenu onEvent(Event event) {
+ FileContextMenu menu=null;
+ if (GSS.get().getCurrentSelection() != null)
+ if (GSS.get().getCurrentSelection() instanceof FileResource) {
+ FileResource res = (FileResource) GSS.get().getCurrentSelection();
+
+ if (res.isDeleted())
+ menu = new FileContextMenu(images, true, false);
+ else
+ menu = new FileContextMenu(images, false, false);
+ int left = event.getClientX();
+ int top = event.getClientY();
+ menu.setPopupPosition(left, top);
+ menu.show();
+ } else if (GSS.get().getCurrentSelection() instanceof List) {
+ /*TODO: CELLTREE
+ if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getSelection()))
+ menu = new FileContextMenu(images, true, false);
+ else {
+ menu = new FileContextMenu(images, false, false);
+ menu.onMultipleSelection();
+ }*/
+ menu = new FileContextMenu(images, false, false);
+ menu.onMultipleSelection();
int left = event.getClientX();
int top = event.getClientY();
menu.setPopupPosition(left, top);
menu.show();
}
+ return menu;
}
- public void onEmptyEvent(Event event) {
- FileContextMenu menu;
- if (GSS.get().getFolders().isTrashItem(GSS.get().getFolders().getCurrent()))
+ public FileContextMenu onEmptyEvent(Event event) {
+ FileContextMenu menu=null;
+ /*TODO: CELLTREE
+ if (GSS.get().getTreeView().isTrashItem(GSS.get().getTreeView().getCurrent()))
menu = new FileContextMenu(images, true, true);
- else if(((DnDTreeItem)GSS.get().getFolders().getCurrent()).getFolderResource() != null)
+ else if(((DnDTreeItem)GSS.get().getTreeView().getCurrent()).getFolderResource() != null)
menu = new FileContextMenu(images, false, true);
- else return;
+ else return menu;
+ */
+ menu = new FileContextMenu(images, false, true);
int left = event.getClientX();
int top = event.getClientY();
menu.setPopupPosition(left, top);
menu.show();
+ return menu;
}