Fixed various compilation warnings
[pithos-web-client] / src / gr / grnet / pithos / web / client / commands / DeleteCommand.java
index f286e9f..dcfc719 100644 (file)
@@ -36,15 +36,13 @@ package gr.grnet.pithos.web.client.commands;
 
 import gr.grnet.pithos.web.client.DeleteFileDialog;
 import gr.grnet.pithos.web.client.DeleteFolderDialog;
-import gr.grnet.pithos.web.client.EditMenu.Images;
-import gr.grnet.pithos.web.client.GSS;
-import gr.grnet.pithos.web.client.rest.resource.FileResource;
-import gr.grnet.pithos.web.client.rest.resource.GroupUserResource;
-import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
+import gr.grnet.pithos.web.client.MessagePanel.Images;
+import gr.grnet.pithos.web.client.Pithos;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 
 import java.util.List;
 
-import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.ui.PopupPanel;
 
@@ -57,38 +55,32 @@ public class DeleteCommand implements Command{
        private PopupPanel containerPanel;
        final Images newImages;
 
+    private Object resource;
+
+    private Pithos app;
        /**
         * @param _containerPanel
         * @param _newImages the images of all the possible delete dialogs
         */
-       public DeleteCommand( PopupPanel _containerPanel, final Images _newImages ){
+       public DeleteCommand(Pithos _app, PopupPanel _containerPanel, Object resource, final Images _newImages ){
+        app = _app;
                containerPanel = _containerPanel;
-               newImages=_newImages;
+               newImages = _newImages;
+        this.resource = resource;
        }
 
        @Override
        public void execute() {
-               containerPanel.hide();
-               displayDelete();
+        if (containerPanel != null)
+               containerPanel.hide();
+
+        if (resource instanceof Folder) {
+            DeleteFolderDialog dlg = new DeleteFolderDialog(app, newImages, (Folder) resource);
+            dlg.center();
+        } else if (resource instanceof List) {
+            @SuppressWarnings("unchecked")
+                       DeleteFileDialog dlg = new DeleteFileDialog(app, newImages, (List<File>) resource);
+            dlg.center();
+        }
        }
-       /**
-        * Display the delete dialog, according to the selected object.
-        *
-        *
-        */
-       void displayDelete() {
-               Object selection = GSS.get().getCurrentSelection();
-               if (selection == null)
-                       return;
-               GWT.log("selection: " + selection.toString(), null);
-               if (selection instanceof RestResourceWrapper) {
-                       DeleteFolderDialog dlg = new DeleteFolderDialog(newImages);
-                       dlg.center();
-               } else if (selection instanceof FileResource || selection instanceof List) {
-                       DeleteFileDialog dlg = new DeleteFileDialog(newImages);
-                       dlg.center();
-               } else if (selection instanceof GroupUserResource) {
-                       // TODO implement user deletion
-               }
-    }
 }