2 * Copyright 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client.commands;
21 import gr.ebs.gss.client.FileUploadDialog;
22 import gr.ebs.gss.client.GSS;
23 import gr.ebs.gss.client.rest.GetCommand;
24 import gr.ebs.gss.client.rest.resource.FileResource;
25 import gr.ebs.gss.client.rest.resource.FolderResource;
27 import java.util.ArrayList;
28 import java.util.List;
30 import com.google.gwt.core.client.GWT;
31 import com.google.gwt.user.client.Command;
32 import com.google.gwt.user.client.DeferredCommand;
33 import com.google.gwt.user.client.IncrementalCommand;
34 import com.google.gwt.user.client.ui.PopupPanel;
35 import com.google.gwt.user.client.ui.TreeItem;
38 * Upload a file command
42 public class UploadFileCommand implements Command {
44 private PopupPanel containerPanel;
45 private List<FileResource> files;
47 public UploadFileCommand(PopupPanel _containerPanel) {
48 containerPanel = _containerPanel;
51 public void execute() {
52 containerPanel.hide();
57 * Display the 'new file' dialog for uploading a new file to the system.
59 private void displayNewFile() {
60 TreeItem currentFolder = GSS.get().getFolders().getCurrent();
61 if (currentFolder == null) {
62 GSS.get().displayError("You have to select the parent folder first");
66 DeferredCommand.addCommand(new IncrementalCommand() {
68 public boolean execute() {
69 boolean res = canContinue();
71 FileUploadDialog dlg = GWT.create(FileUploadDialog.class);
82 private boolean canContinue() {
88 private void getFileList() {
89 GetCommand<FolderResource> eg = new GetCommand<FolderResource>(FolderResource.class,((FolderResource)GSS.get().getFolders().getCurrent().getUserObject()).getUri()){
92 public void onComplete() {
93 files = getResult().getFiles();
97 public void onError(Throwable t) {
98 files = new ArrayList<FileResource>();
102 DeferredCommand.addCommand(eg);