2 * Copyright (c) 2011 Greek Research and Technology Network
4 package gr.grnet.pithos.web.client.commands;
6 import gr.grnet.pithos.web.client.FileMenu.Images;
7 import gr.grnet.pithos.web.client.FolderPropertiesDialog;
8 import gr.grnet.pithos.web.client.GSS;
9 import gr.grnet.pithos.web.client.rest.GetCommand;
10 import gr.grnet.pithos.web.client.rest.MultipleGetCommand;
11 import gr.grnet.pithos.web.client.rest.resource.GroupResource;
12 import gr.grnet.pithos.web.client.rest.resource.GroupsResource;
13 import gr.grnet.pithos.web.client.rest.resource.RestResource;
15 import java.util.ArrayList;
16 import java.util.List;
18 import com.google.gwt.core.client.GWT;
19 import com.google.gwt.user.client.Command;
20 import com.google.gwt.user.client.DeferredCommand;
21 import com.google.gwt.user.client.IncrementalCommand;
22 import com.google.gwt.user.client.ui.PopupPanel;
25 * Display the 'new folder' dialog for creating a new folder.
28 public class NewFolderCommand implements Command{
29 private PopupPanel containerPanel;
32 private List<GroupResource> groups = null;
35 * @param aContainerPanel
36 * @param newImages the images of the new folder dialog
38 public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){
39 containerPanel = aContainerPanel;
44 public void execute() {
45 containerPanel.hide();
47 DeferredCommand.addCommand(new IncrementalCommand() {
50 public boolean execute() {
51 boolean res = canContinue();
62 private boolean canContinue() {
68 void displayNewFolder() {
69 RestResource currentFolder = GSS.get().getTreeView().getSelection();
70 if (currentFolder == null) {
71 GSS.get().displayError("You have to select the parent folder first");
74 FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups);
78 private void getGroups() {
79 GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){
82 public void onComplete() {
83 GroupsResource res = getResult();
84 MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){
87 public void onComplete() {
88 List<GroupResource> groupList = getResult();
93 public void onError(Throwable t) {
95 GSS.get().displayError("Unable to fetch groups");
96 groups = new ArrayList<GroupResource>();
100 public void onError(String p, Throwable throwable) {
101 GWT.log("Path:"+p, throwable);
104 DeferredCommand.addCommand(ga);
108 public void onError(Throwable t) {
110 GSS.get().displayError("Unable to fetch groups");
111 groups = new ArrayList<GroupResource>();
114 DeferredCommand.addCommand(gg);