Revision 26cbae7a web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java
b/web_client/src/gr/grnet/pithos/web/client/commands/UploadFileCommand.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
import gr.grnet.pithos.web.client.FileUploadDialog; |
38 | 38 |
import gr.grnet.pithos.web.client.GSS; |
39 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
39 | 40 |
import gr.grnet.pithos.web.client.rest.GetCommand; |
40 | 41 |
import gr.grnet.pithos.web.client.rest.resource.FileResource; |
41 | 42 |
import gr.grnet.pithos.web.client.rest.resource.FolderResource; |
... | ... | |
58 | 59 |
public class UploadFileCommand implements Command { |
59 | 60 |
|
60 | 61 |
private PopupPanel containerPanel; |
61 |
private List<FileResource> files; |
|
62 | 62 |
|
63 |
public UploadFileCommand(PopupPanel _containerPanel) { |
|
63 |
/* |
|
64 |
* The folder that is the target of the upload |
|
65 |
*/ |
|
66 |
private Folder folder; |
|
67 |
|
|
68 |
public UploadFileCommand(PopupPanel _containerPanel, Folder _folder) { |
|
64 | 69 |
containerPanel = _containerPanel; |
70 |
folder = _folder; |
|
65 | 71 |
} |
66 | 72 |
|
67 | 73 |
@Override |
... | ... | |
75 | 81 |
* Display the 'new file' dialog for uploading a new file to the system. |
76 | 82 |
*/ |
77 | 83 |
private void displayNewFile() { |
78 |
RestResource currentFolder = GSS.get().getTreeView().getSelection(); |
|
79 |
if (currentFolder == null) { |
|
80 |
GSS.get().displayError("You have to select the parent folder first"); |
|
81 |
return; |
|
82 |
} |
|
83 |
getFileList(); |
|
84 |
DeferredCommand.addCommand(new IncrementalCommand() { |
|
85 |
|
|
86 |
@Override |
|
87 |
public boolean execute() { |
|
88 |
boolean res = canContinue(); |
|
89 |
if (res) { |
|
90 |
FileUploadDialog dlg = GWT.create(FileUploadDialog.class); |
|
91 |
dlg.setFiles(files); |
|
92 |
dlg.center(); |
|
93 |
return false; |
|
94 |
} |
|
95 |
return true; |
|
96 |
} |
|
97 |
|
|
98 |
}); |
|
84 |
FileUploadDialog dlg = GWT.create(FileUploadDialog.class); |
|
85 |
dlg.setApp(GSS.get()); |
|
86 |
dlg.setFolder(folder); |
|
87 |
dlg.center(); |
|
99 | 88 |
} |
100 |
|
|
101 |
private boolean canContinue() { |
|
102 |
if (files != null ) |
|
103 |
return true; |
|
104 |
return false; |
|
105 |
} |
|
106 |
|
|
107 |
private void getFileList() { |
|
108 |
GetCommand<FolderResource> eg = new GetCommand<FolderResource>(FolderResource.class,((RestResourceWrapper)GSS.get().getTreeView().getSelection()).getUri(), null){ |
|
109 |
|
|
110 |
@Override |
|
111 |
public void onComplete() { |
|
112 |
files = getResult().getFiles(); |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void onError(Throwable t) { |
|
117 |
files = new ArrayList<FileResource>(); |
|
118 |
} |
|
119 |
|
|
120 |
}; |
|
121 |
DeferredCommand.addCommand(eg); |
|
122 |
} |
|
123 |
|
|
124 | 89 |
} |
Also available in: Unified diff