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.FileMenu.Images;
22 import gr.ebs.gss.client.FolderPropertiesDialog;
23 import gr.ebs.gss.client.GSS;
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;
28 import gr.ebs.gss.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;
38 import com.google.gwt.user.client.ui.TreeItem;
42 * Display the 'new folder' dialog for creating a new folder.
46 public class NewFolderCommand implements Command{
47 private PopupPanel containerPanel;
50 private List<GroupResource> groups = null;
53 * @param aContainerPanel
54 * @param newImages the images of the new folder dialog
56 public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){
57 containerPanel = aContainerPanel;
62 public void execute() {
63 containerPanel.hide();
65 DeferredCommand.addCommand(new IncrementalCommand() {
68 public boolean execute() {
69 boolean res = canContinue();
80 private boolean canContinue() {
86 void displayNewFolder() {
87 RestResource currentFolder = GSS.get().getTreeView().getSelection();
88 if (currentFolder == null) {
89 GSS.get().displayError("You have to select the parent folder first");
92 FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups);
96 private void getGroups() {
97 GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){
100 public void onComplete() {
101 GroupsResource res = getResult();
102 MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){
105 public void onComplete() {
106 List<GroupResource> groupList = getResult();
111 public void onError(Throwable t) {
113 GSS.get().displayError("Unable to fetch groups");
114 groups = new ArrayList<GroupResource>();
118 public void onError(String p, Throwable throwable) {
119 GWT.log("Path:"+p, throwable);
122 DeferredCommand.addCommand(ga);
126 public void onError(Throwable t) {
128 GSS.get().displayError("Unable to fetch groups");
129 groups = new ArrayList<GroupResource>();
132 DeferredCommand.addCommand(gg);