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.grnet.pithos.web.client.commands;
21 import gr.grnet.pithos.web.client.FileMenu.Images;
22 import gr.grnet.pithos.web.client.FolderPropertiesDialog;
23 import gr.grnet.pithos.web.client.GSS;
24 import gr.grnet.pithos.web.client.rest.GetCommand;
25 import gr.grnet.pithos.web.client.rest.MultipleGetCommand;
26 import gr.grnet.pithos.web.client.rest.resource.GroupResource;
27 import gr.grnet.pithos.web.client.rest.resource.GroupsResource;
28 import gr.grnet.pithos.web.client.rest.resource.RestResource;
30 import java.util.ArrayList;
31 import java.util.List;
33 import com.google.gwt.core.client.GWT;
34 import com.google.gwt.user.client.Command;
35 import com.google.gwt.user.client.DeferredCommand;
36 import com.google.gwt.user.client.IncrementalCommand;
37 import com.google.gwt.user.client.ui.PopupPanel;
40 * Display the 'new folder' dialog for creating a new folder.
44 public class NewFolderCommand implements Command{
45 private PopupPanel containerPanel;
48 private List<GroupResource> groups = null;
51 * @param aContainerPanel
52 * @param newImages the images of the new folder dialog
54 public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){
55 containerPanel = aContainerPanel;
60 public void execute() {
61 containerPanel.hide();
63 DeferredCommand.addCommand(new IncrementalCommand() {
66 public boolean execute() {
67 boolean res = canContinue();
78 private boolean canContinue() {
84 void displayNewFolder() {
85 RestResource currentFolder = GSS.get().getTreeView().getSelection();
86 if (currentFolder == null) {
87 GSS.get().displayError("You have to select the parent folder first");
90 FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups);
94 private void getGroups() {
95 GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){
98 public void onComplete() {
99 GroupsResource res = getResult();
100 MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){
103 public void onComplete() {
104 List<GroupResource> groupList = getResult();
109 public void onError(Throwable t) {
111 GSS.get().displayError("Unable to fetch groups");
112 groups = new ArrayList<GroupResource>();
116 public void onError(String p, Throwable throwable) {
117 GWT.log("Path:"+p, throwable);
120 DeferredCommand.addCommand(ga);
124 public void onError(Throwable t) {
126 GSS.get().displayError("Unable to fetch groups");
127 groups = new ArrayList<GroupResource>();
130 DeferredCommand.addCommand(gg);