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.FolderPropertiesDialog;
22 import gr.ebs.gss.client.GSS;
23 import gr.ebs.gss.client.FileMenu.Images;
24 import gr.ebs.gss.client.rest.GetCommand;
25 import gr.ebs.gss.client.rest.MultipleGetCommand;
26 import gr.ebs.gss.client.rest.resource.GroupResource;
27 import gr.ebs.gss.client.rest.resource.GroupsResource;
29 import java.util.ArrayList;
30 import java.util.List;
32 import com.google.gwt.core.client.GWT;
33 import com.google.gwt.user.client.Command;
34 import com.google.gwt.user.client.DeferredCommand;
35 import com.google.gwt.user.client.IncrementalCommand;
36 import com.google.gwt.user.client.ui.PopupPanel;
37 import com.google.gwt.user.client.ui.TreeItem;
41 * Display the 'new folder' dialog for creating a new folder.
45 public class NewFolderCommand implements Command{
46 private PopupPanel containerPanel;
49 private List<GroupResource> groups = null;
52 * @param aContainerPanel
53 * @param newImages the images of the new folder dialog
55 public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){
56 containerPanel = aContainerPanel;
60 public void execute() {
61 containerPanel.hide();
63 DeferredCommand.addCommand(new IncrementalCommand() {
65 public boolean execute() {
66 boolean res = canContinue();
77 private boolean canContinue() {
83 void displayNewFolder() {
84 TreeItem currentFolder = GSS.get().getFolders().getCurrent();
85 if (currentFolder == null) {
86 GSS.get().displayError("You have to select the parent folder first");
89 FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups);
93 private void getGroups() {
94 GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){
97 public void onComplete() {
98 GroupsResource res = getResult();
99 MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){
102 public void onComplete() {
103 List<GroupResource> groupList = getResult();
108 public void onError(Throwable t) {
110 GSS.get().displayError("Unable to fetch groups");
111 groups = new ArrayList<GroupResource>();
115 public void onError(String p, Throwable throwable) {
116 GWT.log("Path:"+p, throwable);
119 DeferredCommand.addCommand(ga);
123 public void onError(Throwable t) {
125 GSS.get().displayError("Unable to fetch groups");
126 groups = new ArrayList<GroupResource>();
129 DeferredCommand.addCommand(gg);