Revision 287c3d8d web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java
b/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client.commands; |
36 | 36 |
|
37 |
import com.google.gwt.event.logical.shared.CloseEvent; |
|
38 |
import com.google.gwt.event.logical.shared.CloseHandler; |
|
37 | 39 |
import gr.grnet.pithos.web.client.FileMenu.Images; |
38 | 40 |
import gr.grnet.pithos.web.client.FolderPropertiesDialog; |
39 | 41 |
import gr.grnet.pithos.web.client.GSS; |
42 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
43 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
|
40 | 44 |
import gr.grnet.pithos.web.client.rest.GetCommand; |
41 | 45 |
import gr.grnet.pithos.web.client.rest.MultipleGetCommand; |
42 | 46 |
import gr.grnet.pithos.web.client.rest.resource.GroupResource; |
... | ... | |
58 | 62 |
*/ |
59 | 63 |
public class NewFolderCommand implements Command{ |
60 | 64 |
private PopupPanel containerPanel; |
65 |
|
|
66 |
private Folder folder; |
|
61 | 67 |
final Images images; |
62 | 68 |
|
63 | 69 |
private List<GroupResource> groups = null; |
... | ... | |
66 | 72 |
* @param aContainerPanel |
67 | 73 |
* @param newImages the images of the new folder dialog |
68 | 74 |
*/ |
69 |
public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){ |
|
75 |
public NewFolderCommand(PopupPanel aContainerPanel, Folder folder, final Images newImages){
|
|
70 | 76 |
containerPanel = aContainerPanel; |
71 | 77 |
images=newImages; |
78 |
this.folder = folder; |
|
72 | 79 |
} |
73 | 80 |
|
74 | 81 |
@Override |
75 | 82 |
public void execute() { |
76 | 83 |
containerPanel.hide(); |
77 |
getGroups(); |
|
78 |
DeferredCommand.addCommand(new IncrementalCommand() { |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean execute() { |
|
82 |
boolean res = canContinue(); |
|
83 |
if (res) { |
|
84 |
displayNewFolder(); |
|
85 |
return false; |
|
86 |
} |
|
87 |
return true; |
|
88 |
} |
|
89 |
|
|
90 |
}); |
|
84 |
displayNewFolderDialog(); |
|
91 | 85 |
} |
92 | 86 |
|
93 |
private boolean canContinue() { |
|
94 |
if (groups == null) |
|
95 |
return false; |
|
96 |
return true; |
|
87 |
void displayNewFolderDialog() { |
|
88 |
if (folder != null) { |
|
89 |
FolderPropertiesDialog dlg = new FolderPropertiesDialog(true, folder); |
|
90 |
dlg.center(); |
|
91 |
} |
|
97 | 92 |
} |
98 |
|
|
99 |
void displayNewFolder() { |
|
100 |
RestResource currentFolder = GSS.get().getTreeView().getSelection(); |
|
101 |
if (currentFolder == null) { |
|
102 |
GSS.get().displayError("You have to select the parent folder first"); |
|
103 |
return; |
|
104 |
} |
|
105 |
FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups); |
|
106 |
dlg.center(); |
|
107 |
} |
|
108 |
|
|
109 |
private void getGroups() { |
|
110 |
GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){ |
|
111 |
|
|
112 |
@Override |
|
113 |
public void onComplete() { |
|
114 |
GroupsResource res = getResult(); |
|
115 |
MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){ |
|
116 |
|
|
117 |
@Override |
|
118 |
public void onComplete() { |
|
119 |
List<GroupResource> groupList = getResult(); |
|
120 |
groups = groupList; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void onError(Throwable t) { |
|
125 |
GWT.log("", t); |
|
126 |
GSS.get().displayError("Unable to fetch groups"); |
|
127 |
groups = new ArrayList<GroupResource>(); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public void onError(String p, Throwable throwable) { |
|
132 |
GWT.log("Path:"+p, throwable); |
|
133 |
} |
|
134 |
}; |
|
135 |
DeferredCommand.addCommand(ga); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
public void onError(Throwable t) { |
|
140 |
GWT.log("", t); |
|
141 |
GSS.get().displayError("Unable to fetch groups"); |
|
142 |
groups = new ArrayList<GroupResource>(); |
|
143 |
} |
|
144 |
}; |
|
145 |
DeferredCommand.addCommand(gg); |
|
146 |
} |
|
147 |
|
|
148 | 93 |
} |
Also available in: Unified diff