Revision 9e8e14e4 web_client/src/gr/grnet/pithos/web/client/GSS.java
b/web_client/src/gr/grnet/pithos/web/client/GSS.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package gr.grnet.pithos.web.client; |
5 | 5 |
|
6 |
import com.google.gwt.core.client.Scheduler; |
|
7 |
import com.google.gwt.core.client.Scheduler.ScheduledCommand; |
|
8 |
import com.google.gwt.user.client.ui.DockPanel; |
|
9 |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
|
6 | 10 |
import gr.grnet.pithos.web.client.clipboard.Clipboard; |
7 | 11 |
import gr.grnet.pithos.web.client.commands.GetUserCommand; |
8 |
import gr.grnet.pithos.web.client.rest.GetCommand; |
|
12 |
import gr.grnet.pithos.web.client.foldertree.AccountResource; |
|
13 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
|
14 |
import gr.grnet.pithos.web.client.rest.GetRequest; |
|
9 | 15 |
import gr.grnet.pithos.web.client.rest.RestException; |
10 | 16 |
import gr.grnet.pithos.web.client.rest.resource.FileResource; |
11 | 17 |
import gr.grnet.pithos.web.client.rest.resource.OtherUserResource; |
... | ... | |
27 | 33 |
import com.google.gwt.event.logical.shared.ResizeHandler; |
28 | 34 |
import com.google.gwt.event.logical.shared.SelectionEvent; |
29 | 35 |
import com.google.gwt.event.logical.shared.SelectionHandler; |
30 |
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
|
31 |
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
|
32 | 36 |
import com.google.gwt.http.client.URL; |
33 | 37 |
import com.google.gwt.i18n.client.DateTimeFormat; |
34 | 38 |
import com.google.gwt.resources.client.ClientBundle; |
... | ... | |
42 | 46 |
import com.google.gwt.user.client.Window; |
43 | 47 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
44 | 48 |
import com.google.gwt.user.client.ui.DecoratedTabPanel; |
45 |
import com.google.gwt.user.client.ui.DockPanel; |
|
46 | 49 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
47 |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
|
48 | 50 |
import com.google.gwt.user.client.ui.HorizontalSplitPanel; |
49 | 51 |
import com.google.gwt.user.client.ui.RootPanel; |
50 | 52 |
import com.google.gwt.user.client.ui.TabPanel; |
51 | 53 |
import com.google.gwt.user.client.ui.VerticalPanel; |
54 |
|
|
52 | 55 |
/** |
53 | 56 |
* Entry point classes define <code>onModuleLoad()</code>. |
54 | 57 |
*/ |
... | ... | |
67 | 70 |
*/ |
68 | 71 |
private static Images images = (Images) GWT.create(Images.class); |
69 | 72 |
|
70 |
private GlassPanel glassPanel = new GlassPanel(); |
|
73 |
public String getUsername() { |
|
74 |
return username; |
|
75 |
} |
|
71 | 76 |
|
72 |
/**
|
|
77 |
/**
|
|
73 | 78 |
* An aggregate image bundle that pulls together all the images for this |
74 | 79 |
* application into a single bundle. |
75 | 80 |
*/ |
76 |
public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, SearchResults.Images, Search.Images, Groups.Images, CellTreeView.Images {
|
|
81 |
public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, Search.Images, CellTreeView.Images {
|
|
77 | 82 |
|
78 | 83 |
@Source("gr/grnet/pithos/resources/document.png") |
79 | 84 |
ImageResource folders(); |
... | ... | |
134 | 139 |
private FileList fileList; |
135 | 140 |
|
136 | 141 |
/** |
137 |
* The group list widget. |
|
138 |
*/ |
|
139 |
private Groups groups = new Groups(images); |
|
140 |
|
|
141 |
/** |
|
142 |
* The search result widget. |
|
143 |
*/ |
|
144 |
private SearchResults searchResults; |
|
145 |
|
|
146 |
/** |
|
147 | 142 |
* The tab panel that occupies the right side of the screen. |
148 | 143 |
*/ |
149 | 144 |
private TabPanel inner = new DecoratedTabPanel(){ |
... | ... | |
153 | 148 |
if(isFileListShowing()){ |
154 | 149 |
getFileList().showContextMenu(event); |
155 | 150 |
} |
156 |
else if(isUserListVisible()){ |
|
157 |
getGroups().setCurrent(null); |
|
158 |
getGroups().showPopup(event.getClientX(),event.getClientY()); |
|
159 |
} |
|
160 | 151 |
} |
161 | 152 |
}; |
162 | 153 |
}; |
... | ... | |
187 | 178 |
*/ |
188 | 179 |
private Object currentSelection; |
189 | 180 |
|
190 |
/** |
|
191 |
* The authentication token of the current user. |
|
192 |
*/ |
|
193 |
private String token; |
|
194 | 181 |
|
195 | 182 |
/** |
196 | 183 |
* The WebDAV password of the current user |
197 | 184 |
*/ |
198 | 185 |
private String webDAVPassword; |
199 | 186 |
|
200 |
|
|
201 |
|
|
202 | 187 |
public HashMap<String, String> userFullNameMap = new HashMap<String, String>(); |
203 | 188 |
|
189 |
private String username = null; |
|
190 |
|
|
191 |
/** |
|
192 |
* The authentication token of the current user. |
|
193 |
*/ |
|
194 |
private String token; |
|
195 |
|
|
196 |
private FolderTreeView folderTreeView = new FolderTreeView(); |
|
197 |
|
|
204 | 198 |
@Override |
205 | 199 |
public void onModuleLoad() { |
206 | 200 |
// Initialize the singleton before calling the constructors of the |
207 | 201 |
// various widgets that might call GSS.get(). |
208 | 202 |
singleton = this; |
209 |
RootPanel.get().add(glassPanel, 0, 0); |
|
210 |
parseUserCredentials(); |
|
211 |
|
|
212 |
topPanel = new TopPanel(GSS.images); |
|
213 |
topPanel.setWidth("100%"); |
|
203 |
if (parseUserCredentials()) |
|
204 |
initialize(); |
|
205 |
} |
|
214 | 206 |
|
215 |
messagePanel.setWidth("100%"); |
|
216 |
messagePanel.setVisible(false); |
|
207 |
private void initialize() { |
|
208 |
topPanel = new TopPanel(GSS.images); |
|
209 |
topPanel.setWidth("100%"); |
|
210 |
|
|
211 |
messagePanel.setWidth("100%"); |
|
212 |
messagePanel.setVisible(false); |
|
217 | 213 |
|
218 | 214 |
search = new Search(images); |
219 | 215 |
searchStatus.add(search, DockPanel.WEST); |
... | ... | |
223 | 219 |
searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE); |
224 | 220 |
searchStatus.setWidth("100%"); |
225 | 221 |
|
226 |
fileList = new FileList(images); |
|
227 |
|
|
228 |
searchResults = new SearchResults(images); |
|
229 |
|
|
230 |
// Inner contains the various lists. |
|
231 |
inner.sinkEvents(Event.ONCONTEXTMENU); |
|
232 |
inner.setAnimationEnabled(true); |
|
233 |
inner.getTabBar().addStyleName("pithos-MainTabBar"); |
|
234 |
inner.getDeckPanel().addStyleName("pithos-MainTabPanelBottom"); |
|
235 |
inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); |
|
236 |
|
|
237 |
inner.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); |
|
238 |
inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); |
|
239 |
//inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); |
|
240 |
inner.setWidth("100%"); |
|
241 |
inner.selectTab(0); |
|
242 |
|
|
243 |
inner.addSelectionHandler(new SelectionHandler<Integer>() { |
|
244 |
|
|
245 |
@Override |
|
246 |
public void onSelection(SelectionEvent<Integer> event) { |
|
247 |
int tabIndex = event.getSelectedItem(); |
|
248 |
// TreeItem treeItem = GSS.get().getFolders().getCurrent(); |
|
249 |
switch (tabIndex) { |
|
250 |
case 0: |
|
251 |
// Files tab selected |
|
252 |
//fileList.clearSelectedRows(); |
|
253 |
fileList.updateCurrentlyShowingStats(); |
|
254 |
break; |
|
255 |
case 1: |
|
256 |
// Groups tab selected |
|
257 |
groups.updateCurrentlyShowingStats(); |
|
258 |
updateHistory("Groups"); |
|
259 |
break; |
|
260 |
case 2: |
|
261 |
// Search tab selected |
|
262 |
searchResults.clearSelectedRows(); |
|
263 |
searchResults.updateCurrentlyShowingStats(); |
|
264 |
updateHistory("Search"); |
|
265 |
break; |
|
266 |
} |
|
267 |
} |
|
268 |
}); |
|
269 |
// If the application starts with no history token, redirect to a new "Files" state |
|
270 |
String initToken = History.getToken(); |
|
271 |
if(initToken.length() == 0) |
|
272 |
History.newItem("Files"); |
|
273 |
// Add history listener to handle any history events |
|
274 |
History.addValueChangeHandler(new ValueChangeHandler<String>() { |
|
275 |
@Override |
|
276 |
public void onValueChange(ValueChangeEvent<String> event) { |
|
277 |
String tokenInput = event.getValue(); |
|
278 |
String historyToken = handleSpecialFolderNames(tokenInput); |
|
279 |
try { |
|
280 |
if(historyToken.equals("Search")) |
|
281 |
inner.selectTab(2); |
|
282 |
else if(historyToken.equals("Groups")) |
|
283 |
inner.selectTab(1); |
|
284 |
else if(historyToken.equals("Files")|| historyToken.length()==0) |
|
285 |
inner.selectTab(0); |
|
286 |
else { |
|
287 |
/*TODO: CELLTREE |
|
288 |
PopupTree popupTree = GSS.get().getFolders().getPopupTree(); |
|
289 |
TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); |
|
290 |
SelectionEvent.fire(popupTree, treeObj); |
|
291 |
*/ |
|
292 |
} |
|
293 |
} catch (IndexOutOfBoundsException e) { |
|
294 |
inner.selectTab(0); |
|
295 |
} |
|
296 |
} |
|
297 |
}); |
|
298 |
|
|
299 |
// Add the left and right panels to the split panel. |
|
300 |
splitPanel.setLeftWidget(treeView); |
|
301 |
splitPanel.setRightWidget(inner); |
|
302 |
splitPanel.setSplitPosition("25%"); |
|
303 |
splitPanel.setSize("100%", "100%"); |
|
304 |
splitPanel.addStyleName("pithos-splitPanel"); |
|
305 |
|
|
306 |
// Create a dock panel that will contain the menu bar at the top, |
|
307 |
// the shortcuts to the left, the status bar at the bottom and the |
|
308 |
// right panel taking the rest. |
|
309 |
VerticalPanel outer = new VerticalPanel(); |
|
310 |
outer.add(topPanel); |
|
222 |
fileList = new FileList(images); |
|
223 |
|
|
224 |
// Inner contains the various lists. |
|
225 |
inner.sinkEvents(Event.ONCONTEXTMENU); |
|
226 |
inner.setAnimationEnabled(true); |
|
227 |
inner.getTabBar().addStyleName("pithos-MainTabBar"); |
|
228 |
inner.getDeckPanel().addStyleName("pithos-MainTabPanelBottom"); |
|
229 |
inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); |
|
230 |
|
|
231 |
inner.setWidth("100%"); |
|
232 |
inner.selectTab(0); |
|
233 |
|
|
234 |
inner.addSelectionHandler(new SelectionHandler<Integer>() { |
|
235 |
|
|
236 |
@Override |
|
237 |
public void onSelection(SelectionEvent<Integer> event) { |
|
238 |
int tabIndex = event.getSelectedItem(); |
|
239 |
switch (tabIndex) { |
|
240 |
case 0: |
|
241 |
fileList.updateCurrentlyShowingStats(); |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
}); |
|
246 |
|
|
247 |
// Add the left and right panels to the split panel. |
|
248 |
splitPanel.setLeftWidget(folderTreeView); |
|
249 |
splitPanel.setRightWidget(inner); |
|
250 |
splitPanel.setSplitPosition("25%"); |
|
251 |
splitPanel.setSize("100%", "100%"); |
|
252 |
splitPanel.addStyleName("pithos-splitPanel"); |
|
253 |
|
|
254 |
// Create a dock panel that will contain the menu bar at the top, |
|
255 |
// the shortcuts to the left, the status bar at the bottom and the |
|
256 |
// right panel taking the rest. |
|
257 |
VerticalPanel outer = new VerticalPanel(); |
|
258 |
outer.add(topPanel); |
|
311 | 259 |
outer.add(searchStatus); |
312 |
outer.add(messagePanel); |
|
313 |
outer.add(splitPanel); |
|
314 |
outer.add(statusPanel); |
|
315 |
outer.setWidth("100%"); |
|
316 |
outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); |
|
317 |
|
|
318 |
outer.setSpacing(4); |
|
319 |
|
|
320 |
// Hook the window resize event, so that we can adjust the UI. |
|
321 |
Window.addResizeHandler(this); |
|
322 |
// Clear out the window's built-in margin, because we want to take |
|
323 |
// advantage of the entire client area. |
|
324 |
Window.setMargin("0px"); |
|
325 |
// Finally, add the outer panel to the RootPanel, so that it will be |
|
326 |
// displayed. |
|
327 |
RootPanel.get().add(outer); |
|
328 |
// Call the window resized handler to get the initial sizes setup. Doing |
|
329 |
// this in a deferred command causes it to occur after all widgets' |
|
330 |
// sizes have been computed by the browser. |
|
331 |
DeferredCommand.addCommand(new Command() { |
|
332 |
|
|
333 |
@Override |
|
334 |
public void execute() { |
|
335 |
onWindowResized(Window.getClientHeight()); |
|
336 |
} |
|
337 |
}); |
|
338 |
} |
|
339 |
|
|
340 |
/** |
|
341 |
* Fetches the User object for the specified username. |
|
342 |
* |
|
343 |
* @param username the username of the user |
|
344 |
*/ |
|
345 |
private void fetchUser(final String username) { |
|
346 |
String path = getApiPath() + username + "/"; |
|
347 |
GetCommand<UserResource> getUserCommand = new GetCommand<UserResource>(UserResource.class, username, path, null) { |
|
348 |
|
|
349 |
@Override |
|
350 |
public void onComplete() { |
|
351 |
|
|
352 |
currentUserResource = getResult(); |
|
353 |
} |
|
354 |
|
|
355 |
@Override |
|
356 |
public void onError(Throwable t) { |
|
357 |
GWT.log("Fetching user error", t); |
|
358 |
if (t instanceof RestException) |
|
359 |
GSS.get().displayError("No user found:" + ((RestException) t).getHttpStatusText()); |
|
360 |
else |
|
361 |
GSS.get().displayError("System error fetching user data:" + t.getMessage()); |
|
362 |
authenticateUser(); |
|
363 |
} |
|
364 |
}; |
|
365 |
DeferredCommand.addCommand(getUserCommand); |
|
366 |
} |
|
260 |
outer.add(messagePanel); |
|
261 |
outer.add(splitPanel); |
|
262 |
outer.add(statusPanel); |
|
263 |
outer.setWidth("100%"); |
|
264 |
outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); |
|
265 |
|
|
266 |
outer.setSpacing(4); |
|
267 |
|
|
268 |
// Hook the window resize event, so that we can adjust the UI. |
|
269 |
Window.addResizeHandler(this); |
|
270 |
// Clear out the window's built-in margin, because we want to take |
|
271 |
// advantage of the entire client area. |
|
272 |
Window.setMargin("0px"); |
|
273 |
// Finally, add the outer panel to the RootPanel, so that it will be |
|
274 |
// displayed. |
|
275 |
RootPanel.get().add(outer); |
|
276 |
// Call the window resized handler to get the initial sizes setup. Doing |
|
277 |
// this in a deferred command causes it to occur after all widgets' |
|
278 |
// sizes have been computed by the browser. |
|
279 |
DeferredCommand.addCommand(new Command() { |
|
280 |
|
|
281 |
@Override |
|
282 |
public void execute() { |
|
283 |
onWindowResized(Window.getClientHeight()); |
|
284 |
} |
|
285 |
}); |
|
286 |
} |
|
367 | 287 |
|
368 | 288 |
/** |
369 | 289 |
* Parse and store the user credentials to the appropriate fields. |
370 | 290 |
*/ |
371 |
private void parseUserCredentials() { |
|
372 |
// Configuration conf = (Configuration) GWT.create(Configuration.class); |
|
373 |
// String cookie = conf.authCookie(); |
|
374 |
// String auth = Cookies.getCookie(cookie); |
|
375 |
// if (auth == null) { |
|
376 |
// authenticateUser(); |
|
377 |
// // Redundant, but silences warnings about possible auth NPE, below. |
|
378 |
// return; |
|
379 |
// } |
|
380 |
// int sepIndex = auth.indexOf(conf.cookieSeparator()); |
|
381 |
// if (sepIndex == -1) |
|
382 |
// authenticateUser(); |
|
383 |
// token = auth.substring(sepIndex + 1); |
|
384 |
// final String username = auth.substring(0, sepIndex); |
|
385 |
// if (username == null) |
|
386 |
// authenticateUser(); |
|
387 |
// |
|
388 |
// refreshWebDAVPassword(); |
|
389 |
|
|
390 |
final String username = "test"; |
|
391 |
DeferredCommand.addCommand(new Command() { |
|
392 |
|
|
393 |
@Override |
|
394 |
public void execute() { |
|
395 |
fetchUser(username); |
|
396 |
} |
|
397 |
}); |
|
291 |
private boolean parseUserCredentials() { |
|
292 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
|
293 |
String cookie = conf.authCookie(); |
|
294 |
String auth = Cookies.getCookie(cookie); |
|
295 |
if (auth == null) { |
|
296 |
authenticateUser(); |
|
297 |
return false; |
|
298 |
} |
|
299 |
else { |
|
300 |
String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2); |
|
301 |
if (authSplit.length != 2) { |
|
302 |
authenticateUser(); |
|
303 |
return false; |
|
304 |
} |
|
305 |
else { |
|
306 |
username = authSplit[0]; |
|
307 |
token = authSplit[1]; |
|
308 |
return true; |
|
309 |
} |
|
310 |
} |
|
398 | 311 |
} |
399 | 312 |
|
400 |
/**
|
|
313 |
/**
|
|
401 | 314 |
* Redirect the user to the login page for authentication. |
402 | 315 |
*/ |
403 | 316 |
protected void authenticateUser() { |
404 |
// Configuration conf = (Configuration) GWT.create(Configuration.class); |
|
405 |
//IMPORTANT: Temporary circumvention of the Shiboleth login process for development and testing |
|
406 |
//Some time in the future the comment line will be restored |
|
407 |
|
|
317 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
|
318 |
|
|
408 | 319 |
// Window.Location.assign(GWT.getModuleBaseURL() + conf.loginUrl() + "?next=" + Window.Location.getHref()); |
409 |
// Cookies.setCookie(conf.authCookie(), "chstath@ebs.gr" + conf.cookieSeparator() + "triapoulakiakathontan");
|
|
410 |
// Window.Location.assign(GWT.getModuleBaseURL());
|
|
320 |
Cookies.setCookie(conf.authCookie(), "demo" + conf.cookieSeparator() + "0000");
|
|
321 |
Window.Location.assign(GWT.getModuleBaseURL() + "GSS.html");
|
|
411 | 322 |
} |
412 | 323 |
|
413 | 324 |
/** |
... | ... | |
447 | 358 |
newHeight = 1; |
448 | 359 |
splitPanel.setHeight("" + newHeight); |
449 | 360 |
inner.setHeight("" + newHeight); |
450 |
/*if(isFileListShowing()){ |
|
451 |
getFileList().setHeight("" + (newHeight-50)); |
|
452 |
}*/ |
|
453 | 361 |
} |
454 | 362 |
|
455 | 363 |
@Override |
... | ... | |
500 | 408 |
RestResource currentFolder = getTreeView().getSelection(); |
501 | 409 |
if(currentFolder!=null){ |
502 | 410 |
showFileList(currentFolder); |
503 |
} |
|
504 | 411 |
} |
505 |
|
|
412 |
} |
|
413 |
|
|
506 | 414 |
} |
507 | 415 |
|
508 | 416 |
public void showFileList(RestResource r) { |
... | ... | |
538 | 446 |
} |
539 | 447 |
|
540 | 448 |
/** |
541 |
* Make the search results visible. |
|
542 |
* |
|
543 |
* @param query the search query string |
|
544 |
*/ |
|
545 |
public void showSearchResults(String query) { |
|
546 |
searchResults.updateFileCache(query); |
|
547 |
searchResults.updateCurrentlyShowingStats(); |
|
548 |
inner.selectTab(2); |
|
549 |
} |
|
550 |
|
|
551 |
/** |
|
552 | 449 |
* Display the 'loading' indicator. |
553 | 450 |
*/ |
554 | 451 |
public void showLoadingIndicator(String message, String path) { |
... | ... | |
651 | 548 |
} |
652 | 549 |
|
653 | 550 |
/** |
654 |
* Retrieve the groups. |
|
655 |
* |
|
656 |
* @return the groups |
|
657 |
*/ |
|
658 |
public Groups getGroups() { |
|
659 |
return groups; |
|
660 |
} |
|
661 |
|
|
662 |
/** |
|
663 | 551 |
* Retrieve the fileList. |
664 | 552 |
* |
665 | 553 |
* @return the fileList |
... | ... | |
668 | 556 |
return fileList; |
669 | 557 |
} |
670 | 558 |
|
671 |
public SearchResults getSearchResults() { |
|
672 |
return searchResults; |
|
673 |
} |
|
674 |
|
|
675 | 559 |
/** |
676 | 560 |
* Retrieve the topPanel. |
677 | 561 |
* |
... | ... | |
713 | 597 |
return webDAVPassword; |
714 | 598 |
} |
715 | 599 |
|
716 |
public void removeGlassPanel() { |
|
717 |
glassPanel.removeFromParent(); |
|
718 |
} |
|
719 |
|
|
720 | 600 |
/** |
721 | 601 |
* Retrieve the currentUserResource. |
722 | 602 |
* |
... | ... | |
749 | 629 |
*/ |
750 | 630 |
public String getApiPath() { |
751 | 631 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
752 |
return GWT.getModuleBaseURL() + conf.apiPath();
|
|
632 |
return conf.apiPath(); |
|
753 | 633 |
} |
754 | 634 |
|
755 | 635 |
/** |
... | ... | |
846 | 726 |
} |
847 | 727 |
|
848 | 728 |
} |
849 |
|
|
850 |
|
|
851 | 729 |
} |
Also available in: Unified diff