root / src / gr / grnet / pithos / web / client / FolderPropertiesDialog.java @ 78989564
History | View | Annotate | Download (12.6 kB)
1 | a57faaf0 | Christos Stathis | /*
|
---|---|---|---|
2 | cae2a8db | Christos Stathis | * Copyright 2011-2012 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | a57faaf0 | Christos Stathis | */
|
35 | a57faaf0 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | a57faaf0 | Christos Stathis | |
37 | d6be39da | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.File; |
38 | 447407c8 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
39 | b651e67f | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Resource; |
40 | b651e67f | Christos Stathis | import gr.grnet.pithos.web.client.rest.PutRequest; |
41 | a57faaf0 | Christos Stathis | import gr.grnet.pithos.web.client.rest.RestException; |
42 | a57faaf0 | Christos Stathis | |
43 | 6b7d024f | Christos Stathis | import java.util.Iterator; |
44 | 6b7d024f | Christos Stathis | |
45 | a57faaf0 | Christos Stathis | import com.google.gwt.core.client.GWT; |
46 | 6b7d024f | Christos Stathis | import com.google.gwt.core.client.Scheduler; |
47 | a57faaf0 | Christos Stathis | import com.google.gwt.dom.client.NativeEvent; |
48 | 903f3402 | Christos Stathis | import com.google.gwt.event.dom.client.ChangeEvent; |
49 | 903f3402 | Christos Stathis | import com.google.gwt.event.dom.client.ChangeHandler; |
50 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
51 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
52 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.KeyCodes; |
53 | 6b7d024f | Christos Stathis | import com.google.gwt.event.dom.client.KeyDownEvent; |
54 | f1b24b82 | Christos Stathis | import com.google.gwt.http.client.Response; |
55 | a57faaf0 | Christos Stathis | import com.google.gwt.i18n.client.DateTimeFormat; |
56 | 6b7d024f | Christos Stathis | import com.google.gwt.user.client.Command; |
57 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.Event.NativePreviewEvent; |
58 | 4420a247 | Christos Stathis | import com.google.gwt.user.client.ui.Anchor; |
59 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.Button; |
60 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.DialogBox; |
61 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.FlexTable; |
62 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
63 | 903f3402 | Christos Stathis | import com.google.gwt.user.client.ui.Label; |
64 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.TextBox; |
65 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.VerticalPanel; |
66 | a57faaf0 | Christos Stathis | |
67 | a57faaf0 | Christos Stathis | /**
|
68 | a57faaf0 | Christos Stathis | * The 'Folder properties' dialog box implementation.
|
69 | a57faaf0 | Christos Stathis | */
|
70 | a57faaf0 | Christos Stathis | public class FolderPropertiesDialog extends DialogBox { |
71 | a57faaf0 | Christos Stathis | |
72 | 7811b9d1 | Christos Stathis | protected Pithos app;
|
73 | b651e67f | Christos Stathis | |
74 | a57faaf0 | Christos Stathis | /**
|
75 | a57faaf0 | Christos Stathis | * The widget that holds the folderName of the folder.
|
76 | a57faaf0 | Christos Stathis | */
|
77 | 903f3402 | Christos Stathis | TextBox folderName = new TextBox();
|
78 | a57faaf0 | Christos Stathis | |
79 | a57faaf0 | Christos Stathis | /**
|
80 | a57faaf0 | Christos Stathis | * A flag that denotes whether the dialog will be used to create or modify a
|
81 | a57faaf0 | Christos Stathis | * folder.
|
82 | a57faaf0 | Christos Stathis | */
|
83 | a57faaf0 | Christos Stathis | private final boolean create; |
84 | a57faaf0 | Christos Stathis | |
85 | 447407c8 | Christos Stathis | final Folder folder;
|
86 | a57faaf0 | Christos Stathis | |
87 | 6b7d024f | Christos Stathis | final VerticalPanel inner;
|
88 | a57faaf0 | Christos Stathis | |
89 | a57faaf0 | Christos Stathis | /**
|
90 | a57faaf0 | Christos Stathis | * The widget's constructor.
|
91 | a57faaf0 | Christos Stathis | */
|
92 | ecf95c9e | Christos Stathis | public FolderPropertiesDialog(final Pithos app, boolean _create, Folder selected) { |
93 | b651e67f | Christos Stathis | this.app = app;
|
94 | 948a9b34 | Christos Stathis | Anchor close = new Anchor("close"); |
95 | 4420a247 | Christos Stathis | close.addStyleName("close");
|
96 | 4420a247 | Christos Stathis | close.addClickHandler(new ClickHandler() {
|
97 | 4420a247 | Christos Stathis | |
98 | 4420a247 | Christos Stathis | @Override
|
99 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
100 | 4420a247 | Christos Stathis | hide(); |
101 | 4420a247 | Christos Stathis | } |
102 | 4420a247 | Christos Stathis | }); |
103 | 4420a247 | Christos Stathis | |
104 | a57faaf0 | Christos Stathis | setAnimationEnabled(true);
|
105 | 4420a247 | Christos Stathis | setGlassEnabled(true);
|
106 | 4420a247 | Christos Stathis | setStyleName("pithos-DialogBox");
|
107 | a57faaf0 | Christos Stathis | |
108 | a57faaf0 | Christos Stathis | // Enable IE selection for the dialog (must disable it upon closing it)
|
109 | 7811b9d1 | Christos Stathis | Pithos.enableIESelection(); |
110 | a57faaf0 | Christos Stathis | |
111 | a57faaf0 | Christos Stathis | create = _create; |
112 | a57faaf0 | Christos Stathis | |
113 | 447407c8 | Christos Stathis | folder = selected; |
114 | a57faaf0 | Christos Stathis | |
115 | a57faaf0 | Christos Stathis | // Use this opportunity to set the dialog's caption.
|
116 | a57faaf0 | Christos Stathis | if (create)
|
117 | a57faaf0 | Christos Stathis | setText("Create folder");
|
118 | a57faaf0 | Christos Stathis | else
|
119 | a57faaf0 | Christos Stathis | setText("Folder properties");
|
120 | a57faaf0 | Christos Stathis | |
121 | a57faaf0 | Christos Stathis | // Outer contains inner and buttons
|
122 | a57faaf0 | Christos Stathis | VerticalPanel outer = new VerticalPanel();
|
123 | 4420a247 | Christos Stathis | outer.add(close); |
124 | a57faaf0 | Christos Stathis | // Inner contains generalPanel and permPanel
|
125 | 6b7d024f | Christos Stathis | inner = new VerticalPanel();
|
126 | 4420a247 | Christos Stathis | inner.addStyleName("inner");
|
127 | ecf95c9e | Christos Stathis | |
128 | a57faaf0 | Christos Stathis | VerticalPanel generalPanel = new VerticalPanel();
|
129 | ecf95c9e | Christos Stathis | FlexTable generalTable = new FlexTable();
|
130 | ecf95c9e | Christos Stathis | generalTable.setText(0, 0, "Name"); |
131 | ecf95c9e | Christos Stathis | generalTable.setText(1, 0, "Parent"); |
132 | ecf95c9e | Christos Stathis | generalTable.setText(2, 0, "Creator"); |
133 | ecf95c9e | Christos Stathis | generalTable.setText(3, 0, "Last modified"); |
134 | 903f3402 | Christos Stathis | |
135 | 903f3402 | Christos Stathis | folderName.setText(create ? "" : folder.getName());
|
136 | 4fe76337 | Christos Stathis | folderName.setReadOnly(folder.isContainer() && !create); |
137 | ecf95c9e | Christos Stathis | generalTable.setWidget(0, 1, folderName); |
138 | ecf95c9e | Christos Stathis | |
139 | 903f3402 | Christos Stathis | final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true); |
140 | 903f3402 | Christos Stathis | folderNameNote.setVisible(false);
|
141 | 903f3402 | Christos Stathis | folderNameNote.setStylePrimaryName("gss-readForAllNote");
|
142 | 903f3402 | Christos Stathis | generalTable.setWidget(0, 2, folderNameNote); |
143 | 903f3402 | Christos Stathis | |
144 | ecf95c9e | Christos Stathis | if (create)
|
145 | ecf95c9e | Christos Stathis | generalTable.setText(1, 1, folder.getName()); |
146 | ecf95c9e | Christos Stathis | else
|
147 | 3c534380 | Christos Stathis | generalTable.setText(1, 1, folder.getParent().getName()); |
148 | 3c534380 | Christos Stathis | if (create)
|
149 | 3c534380 | Christos Stathis | generalTable.setText(2, 1, app.getUsername()); |
150 | 3c534380 | Christos Stathis | else
|
151 | 3c534380 | Christos Stathis | generalTable.setText(2, 1, folder.getOwner()); |
152 | ecf95c9e | Christos Stathis | DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
|
153 | ecf95c9e | Christos Stathis | if(folder.getLastModified() != null) |
154 | ecf95c9e | Christos Stathis | generalTable.setText(3, 1, formatter.format(folder.getLastModified())); |
155 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
156 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); |
157 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); |
158 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(3, 0, "props-labels"); |
159 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
160 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); |
161 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); |
162 | ecf95c9e | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(3, 1, "props-values"); |
163 | ecf95c9e | Christos Stathis | generalTable.setCellSpacing(4);
|
164 | ecf95c9e | Christos Stathis | generalPanel.add(generalTable); |
165 | 6b7d024f | Christos Stathis | inner.add(generalPanel); |
166 | ecf95c9e | Christos Stathis | |
167 | ecf95c9e | Christos Stathis | outer.add(inner); |
168 | ecf95c9e | Christos Stathis | |
169 | a57faaf0 | Christos Stathis | // Create the 'Create/Update' button, along with a listener that hides the dialog
|
170 | a57faaf0 | Christos Stathis | // when the button is clicked and quits the application.
|
171 | a57faaf0 | Christos Stathis | String okLabel;
|
172 | a57faaf0 | Christos Stathis | if (create)
|
173 | a57faaf0 | Christos Stathis | okLabel = "Create";
|
174 | a57faaf0 | Christos Stathis | else
|
175 | a57faaf0 | Christos Stathis | okLabel = "Update";
|
176 | 903f3402 | Christos Stathis | final Button ok = new Button(okLabel, new ClickHandler() { |
177 | a57faaf0 | Christos Stathis | @Override
|
178 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
179 | 447407c8 | Christos Stathis | createOrUpdateFolder(); |
180 | 447407c8 | Christos Stathis | closeDialog(); |
181 | a57faaf0 | Christos Stathis | } |
182 | a57faaf0 | Christos Stathis | }); |
183 | 4420a247 | Christos Stathis | ok.addStyleName("button");
|
184 | 4420a247 | Christos Stathis | outer.add(ok); |
185 | 4420a247 | Christos Stathis | outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
186 | a57faaf0 | Christos Stathis | |
187 | 903f3402 | Christos Stathis | folderName.addChangeHandler(new ChangeHandler() {
|
188 | 903f3402 | Christos Stathis | |
189 | 903f3402 | Christos Stathis | @Override
|
190 | ebead1b5 | Christos Stathis | public void onChange(ChangeEvent event) { |
191 | 903f3402 | Christos Stathis | if(folderName.getText().contains("/")) { |
192 | 903f3402 | Christos Stathis | folderNameNote.setVisible(true);
|
193 | 903f3402 | Christos Stathis | ok.setEnabled(false);
|
194 | 903f3402 | Christos Stathis | } |
195 | 903f3402 | Christos Stathis | else {
|
196 | 903f3402 | Christos Stathis | folderNameNote.setVisible(false);
|
197 | 903f3402 | Christos Stathis | ok.setEnabled(true);
|
198 | 903f3402 | Christos Stathis | } |
199 | 903f3402 | Christos Stathis | } |
200 | 903f3402 | Christos Stathis | }); |
201 | 903f3402 | Christos Stathis | |
202 | ecf95c9e | Christos Stathis | setWidget(outer); |
203 | a57faaf0 | Christos Stathis | } |
204 | a57faaf0 | Christos Stathis | |
205 | a57faaf0 | Christos Stathis | @Override
|
206 | a57faaf0 | Christos Stathis | public void center() { |
207 | a57faaf0 | Christos Stathis | super.center();
|
208 | a57faaf0 | Christos Stathis | folderName.setFocus(true);
|
209 | a57faaf0 | Christos Stathis | } |
210 | a57faaf0 | Christos Stathis | |
211 | a57faaf0 | Christos Stathis | @Override
|
212 | a57faaf0 | Christos Stathis | protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
213 | a57faaf0 | Christos Stathis | super.onPreviewNativeEvent(preview);
|
214 | a57faaf0 | Christos Stathis | |
215 | a57faaf0 | Christos Stathis | NativeEvent evt = preview.getNativeEvent(); |
216 | 447407c8 | Christos Stathis | if (evt.getType().equals(KeyDownEvent.getType().getName()))
|
217 | a57faaf0 | Christos Stathis | // Use the popup's key preview hooks to close the dialog when either
|
218 | a57faaf0 | Christos Stathis | // enter or escape is pressed.
|
219 | a57faaf0 | Christos Stathis | switch (evt.getKeyCode()) {
|
220 | a57faaf0 | Christos Stathis | case KeyCodes.KEY_ENTER:
|
221 | a57faaf0 | Christos Stathis | createOrUpdateFolder(); |
222 | ecf95c9e | Christos Stathis | closeDialog(); |
223 | a57faaf0 | Christos Stathis | break;
|
224 | a57faaf0 | Christos Stathis | case KeyCodes.KEY_ESCAPE:
|
225 | a57faaf0 | Christos Stathis | closeDialog(); |
226 | a57faaf0 | Christos Stathis | break;
|
227 | a57faaf0 | Christos Stathis | } |
228 | a57faaf0 | Christos Stathis | } |
229 | a57faaf0 | Christos Stathis | |
230 | a57faaf0 | Christos Stathis | |
231 | a57faaf0 | Christos Stathis | /**
|
232 | a57faaf0 | Christos Stathis | * Enables IE selection prevention and hides the dialog
|
233 | a57faaf0 | Christos Stathis | * (we disable the prevention on creation of the dialog)
|
234 | a57faaf0 | Christos Stathis | */
|
235 | a57faaf0 | Christos Stathis | public void closeDialog() { |
236 | 7811b9d1 | Christos Stathis | Pithos.preventIESelection(); |
237 | a57faaf0 | Christos Stathis | hide(); |
238 | a57faaf0 | Christos Stathis | } |
239 | a57faaf0 | Christos Stathis | |
240 | a57faaf0 | Christos Stathis | /**
|
241 | a57faaf0 | Christos Stathis | * Generate an RPC request to create a new folder.
|
242 | a57faaf0 | Christos Stathis | */
|
243 | a57faaf0 | Christos Stathis | private void createFolder() { |
244 | 903f3402 | Christos Stathis | String name = folderName.getText().trim();
|
245 | c475a970 | Christos Stathis | if (name.length() == 0) |
246 | c475a970 | Christos Stathis | return;
|
247 | b51c628b | Christos Stathis | String path = folder.getUri() + "/" + name; |
248 | 63ee965c | Christos Stathis | PutRequest createFolder = new PutRequest(app.getApiPath(), folder.getOwner(), path) {
|
249 | b651e67f | Christos Stathis | @Override
|
250 | ebead1b5 | Christos Stathis | public void onSuccess(Resource result) { |
251 | 64f42c0b | Christos Stathis | app.updateFolder(folder, true, new Command() { |
252 | 64f42c0b | Christos Stathis | |
253 | 64f42c0b | Christos Stathis | @Override
|
254 | 64f42c0b | Christos Stathis | public void execute() { |
255 | 64f42c0b | Christos Stathis | app.updateStatistics(); |
256 | 64f42c0b | Christos Stathis | } |
257 | 6acd4df3 | Christos Stathis | }, true);
|
258 | b651e67f | Christos Stathis | } |
259 | b651e67f | Christos Stathis | |
260 | b651e67f | Christos Stathis | @Override
|
261 | b651e67f | Christos Stathis | public void onError(Throwable t) { |
262 | b651e67f | Christos Stathis | GWT.log("", t);
|
263 | 3f8622d4 | Christos Stathis | app.setError(t); |
264 | b651e67f | Christos Stathis | if (t instanceof RestException) { |
265 | b651e67f | Christos Stathis | app.displayError("Unable to create folder:" + ((RestException) t).getHttpStatusText());
|
266 | b651e67f | Christos Stathis | } |
267 | b651e67f | Christos Stathis | else
|
268 | b651e67f | Christos Stathis | app.displayError("System error creating folder:" + t.getMessage());
|
269 | b651e67f | Christos Stathis | } |
270 | 9539e23d | Christos Stathis | |
271 | 9539e23d | Christos Stathis | @Override
|
272 | ebead1b5 | Christos Stathis | protected void onUnauthorized(Response response) { |
273 | 9539e23d | Christos Stathis | app.sessionExpired(); |
274 | 9539e23d | Christos Stathis | } |
275 | 9539e23d | Christos Stathis | }; |
276 | f1aabd89 | Christos Stathis | createFolder.setHeader("X-Auth-Token", app.getToken());
|
277 | b651e67f | Christos Stathis | createFolder.setHeader("Accept", "*/*"); |
278 | b651e67f | Christos Stathis | createFolder.setHeader("Content-Length", "0"); |
279 | b3fd800b | Christos Stathis | createFolder.setHeader("Content-Type", "application/directory"); |
280 | b651e67f | Christos Stathis | Scheduler.get().scheduleDeferred(createFolder); |
281 | a57faaf0 | Christos Stathis | } |
282 | a57faaf0 | Christos Stathis | |
283 | a57faaf0 | Christos Stathis | /**
|
284 | a57faaf0 | Christos Stathis | * Upon closing the dialog by clicking OK or pressing ENTER this method does
|
285 | a57faaf0 | Christos Stathis | * the actual work of modifying folder properties or creating a new Folder
|
286 | a57faaf0 | Christos Stathis | * depending on the value of the create field
|
287 | a57faaf0 | Christos Stathis | */
|
288 | 7811b9d1 | Christos Stathis | protected void createOrUpdateFolder() { |
289 | a57faaf0 | Christos Stathis | if (create)
|
290 | a57faaf0 | Christos Stathis | createFolder(); |
291 | a57faaf0 | Christos Stathis | else
|
292 | a57faaf0 | Christos Stathis | updateFolder(); |
293 | a57faaf0 | Christos Stathis | |
294 | a57faaf0 | Christos Stathis | } |
295 | a57faaf0 | Christos Stathis | |
296 | a57faaf0 | Christos Stathis | private void updateFolder() { |
297 | 5ebc9312 | Christos Stathis | final String newName = folderName.getText().trim(); |
298 | c475a970 | Christos Stathis | if (newName.length() == 0) |
299 | c475a970 | Christos Stathis | return;
|
300 | d6be39da | Christos Stathis | if (!folder.isContainer() && !folder.getName().equals(newName)) {
|
301 | b51c628b | Christos Stathis | final String path = folder.getParent().getUri() + "/" + newName; |
302 | 63ee965c | Christos Stathis | PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getParent().getOwner(), path) {
|
303 | d6be39da | Christos Stathis | @Override
|
304 | ebead1b5 | Christos Stathis | public void onSuccess(Resource result) { |
305 | d6be39da | Christos Stathis | Iterator<File> iter = folder.getFiles().iterator(); |
306 | 63ee965c | Christos Stathis | app.copyFiles(iter, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() { |
307 | d6be39da | Christos Stathis | @Override
|
308 | d6be39da | Christos Stathis | public void execute() { |
309 | d6be39da | Christos Stathis | Iterator<Folder> iterf = folder.getSubfolders().iterator();
|
310 | 63ee965c | Christos Stathis | app.copySubfolders(iterf, folder.getParent().getOwner(), folder.getParent().getUri() + "/" + newName, new Command() { |
311 | d6be39da | Christos Stathis | @Override
|
312 | d6be39da | Christos Stathis | public void execute() { |
313 | 2c801ad7 | Christos Stathis | app.deleteFolder(folder, new Command() {
|
314 | 2c801ad7 | Christos Stathis | |
315 | 2c801ad7 | Christos Stathis | @Override
|
316 | 2c801ad7 | Christos Stathis | public void execute() { |
317 | 2c801ad7 | Christos Stathis | app.updateFolder(folder.getParent(), false, new Command() { |
318 | 2c801ad7 | Christos Stathis | |
319 | 2c801ad7 | Christos Stathis | @Override
|
320 | 2c801ad7 | Christos Stathis | public void execute() { |
321 | 2c801ad7 | Christos Stathis | app.updateMySharedRoot(); |
322 | 2c801ad7 | Christos Stathis | } |
323 | 6acd4df3 | Christos Stathis | }, true);
|
324 | 2c801ad7 | Christos Stathis | } |
325 | 2c801ad7 | Christos Stathis | }); |
326 | d6be39da | Christos Stathis | } |
327 | d6be39da | Christos Stathis | }); |
328 | d6be39da | Christos Stathis | } |
329 | d6be39da | Christos Stathis | }); |
330 | d6be39da | Christos Stathis | } |
331 | d6be39da | Christos Stathis | |
332 | d6be39da | Christos Stathis | @Override
|
333 | d6be39da | Christos Stathis | public void onError(Throwable t) { |
334 | d6be39da | Christos Stathis | GWT.log("", t);
|
335 | 3f8622d4 | Christos Stathis | app.setError(t); |
336 | d6be39da | Christos Stathis | if(t instanceof RestException){ |
337 | d6be39da | Christos Stathis | app.displayError("Unable to update folder: " + ((RestException) t).getHttpStatusText());
|
338 | d6be39da | Christos Stathis | } |
339 | d6be39da | Christos Stathis | else
|
340 | d6be39da | Christos Stathis | app.displayError("System error modifying folder: " + t.getMessage());
|
341 | d6be39da | Christos Stathis | } |
342 | 9539e23d | Christos Stathis | |
343 | 9539e23d | Christos Stathis | @Override
|
344 | ebead1b5 | Christos Stathis | protected void onUnauthorized(Response response) { |
345 | 9539e23d | Christos Stathis | app.sessionExpired(); |
346 | 9539e23d | Christos Stathis | } |
347 | d6be39da | Christos Stathis | }; |
348 | d6be39da | Christos Stathis | newFolder.setHeader("X-Auth-Token", app.getToken());
|
349 | d6be39da | Christos Stathis | newFolder.setHeader("Content-Type", "application/folder"); |
350 | d6be39da | Christos Stathis | newFolder.setHeader("Accept", "*/*"); |
351 | d6be39da | Christos Stathis | newFolder.setHeader("Content-Length", "0"); |
352 | d6be39da | Christos Stathis | Scheduler.get().scheduleDeferred(newFolder); |
353 | d6be39da | Christos Stathis | } |
354 | 5ebc9312 | Christos Stathis | else
|
355 | 8fd8a487 | Christos Stathis | app.updateFolder(folder.getParent(), false, new Command() { |
356 | 6b7d024f | Christos Stathis | |
357 | 6b7d024f | Christos Stathis | @Override
|
358 | 6b7d024f | Christos Stathis | public void execute() { |
359 | 6b7d024f | Christos Stathis | app.updateMySharedRoot(); |
360 | 6b7d024f | Christos Stathis | } |
361 | 6acd4df3 | Christos Stathis | }, true);
|
362 | a57faaf0 | Christos Stathis | } |
363 | a57faaf0 | Christos Stathis | } |