X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/16baf609bb746ccbc6cd8da7213ee74cf474f2a9..302b2750560cd22321da9aa99da9a93b9612ed68:/src/gr/ebs/gss/client/GSS.java diff --git a/src/gr/ebs/gss/client/GSS.java b/src/gr/ebs/gss/client/GSS.java index 3f9f8f8..426d266 100644 --- a/src/gr/ebs/gss/client/GSS.java +++ b/src/gr/ebs/gss/client/GSS.java @@ -20,6 +20,7 @@ package gr.ebs.gss.client; import gr.ebs.gss.client.clipboard.Clipboard; import gr.ebs.gss.client.dnd.DnDFocusPanel; +import gr.ebs.gss.client.dnd.DnDSimpleFocusPanel; import gr.ebs.gss.client.rest.GetCommand; import gr.ebs.gss.client.rest.RestException; import gr.ebs.gss.client.rest.resource.FileResource; @@ -35,14 +36,20 @@ import com.allen_sauer.gwt.dnd.client.PickupDragController; import com.allen_sauer.gwt.dnd.client.VetoDragException; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.logical.shared.ResizeEvent; +import com.google.gwt.event.logical.shared.ResizeHandler; +import com.google.gwt.event.logical.shared.SelectionEvent; +import com.google.gwt.event.logical.shared.SelectionHandler; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Cookies; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.WindowResizeListener; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.AbstractImagePrototype; +import com.google.gwt.user.client.ui.DecoratedTabPanel; import com.google.gwt.user.client.ui.DockPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; @@ -50,8 +57,6 @@ import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HorizontalSplitPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.SourcesTabEvents; -import com.google.gwt.user.client.ui.TabListener; import com.google.gwt.user.client.ui.TabPanel; import com.google.gwt.user.client.ui.TreeItem; import com.google.gwt.user.client.ui.VerticalPanel; @@ -61,7 +66,7 @@ import com.google.gwt.user.client.ui.Widget; /** * Entry point classes define onModuleLoad(). */ -public class GSS implements EntryPoint, WindowResizeListener { +public class GSS implements EntryPoint, ResizeHandler { /** * A constant that denotes the completion of an IncrementalCommand. @@ -81,16 +86,16 @@ public class GSS implements EntryPoint, WindowResizeListener { * An aggregate image bundle that pulls together all the images for this * application into a single bundle. */ - public interface Images extends TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, SearchResults.Images, Search.Images, Groups.Images, Folders.Images { + 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, Folders.Images { - @Resource("gr/ebs/gss/resources/document.png") - AbstractImagePrototype folders(); + @Source("gr/ebs/gss/resources/document.png") + ImageResource folders(); - @Resource("gr/ebs/gss/resources/edit_group_22.png") - AbstractImagePrototype groups(); + @Source("gr/ebs/gss/resources/edit_group_22.png") + ImageResource groups(); - @Resource("gr/ebs/gss/resources/search.png") - AbstractImagePrototype search(); + @Source("gr/ebs/gss/resources/search.png") + ImageResource search(); } /** @@ -152,15 +157,9 @@ public class GSS implements EntryPoint, WindowResizeListener { private SearchResults searchResults; /** - * A widget that displays a message indicating that communication with the - * server is underway. - */ - private LoadingIndicator loading; - - /** * The tab panel that occupies the right side of the screen. */ - private TabPanel inner = new TabPanel(); + private TabPanel inner = new DecoratedTabPanel(); /** * The split panel that will contain the left and right panels. @@ -193,6 +192,11 @@ public class GSS implements EntryPoint, WindowResizeListener { */ private String token; + /** + * The WebDAV password of the current user + */ + private String webDAVPassword; + private PickupDragController dragController; public void onModuleLoad() { @@ -209,17 +213,24 @@ public class GSS implements EntryPoint, WindowResizeListener { if (context.selectedWidgets.isEmpty()) throw new VetoDragException(); - if(context.draggable != null){ - DnDFocusPanel toDrop = (DnDFocusPanel) context.draggable; - //prevent drag and drop for trashed files and for unselected tree items - if(toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent())) - throw new VetoDragException(); - else if(toDrop.getItem() != null && !toDrop.getItem().equals(folders.getCurrent())) - throw new VetoDragException(); - else if(toDrop.getItem() != null && !toDrop.getItem().isDraggable()) - throw new VetoDragException(); - - } + if(context.draggable != null) + if(context.draggable instanceof DnDFocusPanel){ + DnDFocusPanel toDrop = (DnDFocusPanel) context.draggable; + //prevent drag and drop for trashed files and for unselected tree items + if(toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent())) + throw new VetoDragException(); + else if(toDrop.getItem() != null && !toDrop.getItem().equals(folders.getCurrent())) + throw new VetoDragException(); + else if(toDrop.getItem() != null && !toDrop.getItem().isDraggable()) + throw new VetoDragException(); + + } + else if(context.draggable instanceof DnDSimpleFocusPanel){ + DnDSimpleFocusPanel toDrop = (DnDSimpleFocusPanel) context.draggable; + //prevent drag and drop for trashed files and for unselected tree items + if(toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent())) + throw new VetoDragException(); + } } @Override @@ -227,9 +238,16 @@ public class GSS implements EntryPoint, WindowResizeListener { AbsolutePanel container = new AbsolutePanel(); DOM.setStyleAttribute(container.getElement(), "overflow", "visible"); for (Iterator iterator = aContext.selectedWidgets.iterator(); iterator.hasNext();) { + HTML html = null; Widget widget = (Widget) iterator.next(); - DnDFocusPanel book = (DnDFocusPanel) widget; - HTML html = book.cloneHTML(); + if(widget instanceof DnDFocusPanel){ + DnDFocusPanel book = (DnDFocusPanel) widget; + html = book.cloneHTML(); + } + else if(widget instanceof DnDSimpleFocusPanel){ + DnDSimpleFocusPanel book = (DnDSimpleFocusPanel) widget; + html = book.cloneHTML(); + } if(html == null) container.add(new Label("Drag ME")); else @@ -259,33 +277,35 @@ public class GSS implements EntryPoint, WindowResizeListener { searchResults = new SearchResults(images); // Inner contains the various lists. - inner.getTabBar().setStyleName("gss-TabBar"); - inner.setStyleName("gss-TabPanel"); - inner.add(fileList, createHeaderHTML(images.folders(), "Files"), true); + inner.setAnimationEnabled(true); + inner.getTabBar().addStyleName("gss-MainTabBar"); + inner.getDeckPanel().addStyleName("gss-MainTabPanelBottom"); + inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); - inner.add(groups, createHeaderHTML(images.groups(), "Groups"), true); - inner.add(searchResults, createHeaderHTML(images.search(), "Search Results"), true); + inner.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); + inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); inner.setWidth("100%"); inner.selectTab(0); - inner.addTabListener(new TabListener() { - public void onTabSelected(SourcesTabEvents sender, int tabIndex) { - switch (tabIndex) { + inner.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + int tabIndex= event.getSelectedItem(); + switch (tabIndex) { case 0: + fileList.clearSelectedRows(); fileList.updateCurrentlyShowingStats(); break; case 1: groups.updateCurrentlyShowingStats(); break; case 2: + searchResults.clearSelectedRows(); searchResults.updateCurrentlyShowingStats(); break; } } - - public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) { - return true; - } }); // Add the left and right panels to the split panel. @@ -293,6 +313,7 @@ public class GSS implements EntryPoint, WindowResizeListener { splitPanel.setRightWidget(inner); splitPanel.setSplitPosition("25%"); splitPanel.setSize("100%", "100%"); + splitPanel.addStyleName("gss-splitPanel"); // Create a dock panel that will contain the menu bar at the top, // the shortcuts to the left, the status bar at the bottom and the @@ -308,25 +329,20 @@ public class GSS implements EntryPoint, WindowResizeListener { outer.setSpacing(4); - loading = new LoadingIndicator(); - // Hook the window resize event, so that we can adjust the UI. - Window.addWindowResizeListener(this); - + Window.addResizeHandler(this); // Clear out the window's built-in margin, because we want to take // advantage of the entire client area. Window.setMargin("0px"); - // Finally, add the outer panel to the RootPanel, so that it will be // displayed. RootPanel.get().add(outer); - // Call the window resized handler to get the initial sizes setup. Doing // this in a deferred command causes it to occur after all widgets' // sizes have been computed by the browser. DeferredCommand.addCommand(new Command() { public void execute() { - onWindowResized(Window.getClientWidth(), Window.getClientHeight()); + onWindowResized(Window.getClientHeight()); } }); } @@ -338,7 +354,7 @@ public class GSS implements EntryPoint, WindowResizeListener { */ private void fetchUser(final String username) { String path = getApiPath() + username + "/"; - GetCommand getUserCommand = new GetCommand(UserResource.class, username, path){ + GetCommand getUserCommand = new GetCommand(UserResource.class, username, path, null){ @Override public void onComplete() { @@ -369,20 +385,6 @@ public class GSS implements EntryPoint, WindowResizeListener { * Parse and store the user credentials to the appropriate fields. */ private void parseUserCredentials() { - //------------------------ - // XXX This part is only for development environments! - // XXX Remove/comment for production deployment! - final String _username = Window.Location.getParameter("user"); - token = Window.Location.getParameter("token"); - if (_username != null) { - DeferredCommand.addCommand(new Command() { - public void execute() { - fetchUser(_username); - } - }); - return; - } - //------------------------ Configuration conf = (Configuration) GWT.create(Configuration.class); String cookie = conf.authCookie(); String auth = Cookies.getCookie(cookie); @@ -401,6 +403,9 @@ public class GSS implements EntryPoint, WindowResizeListener { final String username = auth.substring(0, sepIndex); if (username == null) authenticateUser(); + + refreshWebDAVPassword(); + DeferredCommand.addCommand(new Command() { public void execute() { fetchUser(username); @@ -440,12 +445,8 @@ public class GSS implements EntryPoint, WindowResizeListener { return captionHTML; } - /* - * (non-Javadoc) - * - * @see com.google.gwt.user.client.WindowResizeListener#onWindowResized(int,int) - */ - public void onWindowResized(int width, int height) { + + private void onWindowResized(int height) { // Adjust the split panel to take up the available room in the window. int newHeight = height - splitPanel.getAbsoluteTop() - 44; if (newHeight < 1) @@ -453,6 +454,12 @@ public class GSS implements EntryPoint, WindowResizeListener { splitPanel.setHeight("" + newHeight); } + @Override + public void onResize(ResizeEvent event) { + int height = event.getHeight(); + onWindowResized(height); + } + public boolean isFileListShowing(){ int tab = inner.getTabBar().getSelectedTab(); if(tab == 0) return true; @@ -517,14 +524,14 @@ public class GSS implements EntryPoint, WindowResizeListener { * Display the 'loading' indicator. */ public void showLoadingIndicator() { - loading.center(); + topPanel.getLoading().setVisible(true); } /** * Hide the 'loading' indicator. */ public void hideLoadingIndicator() { - loading.hide(); + topPanel.getLoading().setVisible(false); } /** @@ -656,6 +663,16 @@ public class GSS implements EntryPoint, WindowResizeListener { return statusPanel; } + + /** + * Retrieve the userDetailsPanel. + * + * @return the userDetailsPanel + */ + public UserDetailsPanel getUserDetailsPanel() { + return userDetailsPanel; + } + /** * Retrieve the dragController. * @@ -669,6 +686,10 @@ public class GSS implements EntryPoint, WindowResizeListener { return token; } + public String getWebDAVPassword() { + return webDAVPassword; + } + public void removeGlassPanel(){ glassPanel.removeFromParent(); } @@ -682,6 +703,15 @@ public class GSS implements EntryPoint, WindowResizeListener { return currentUserResource; } + /** + * Modify the currentUserResource. + * + * @param newUser the new currentUserResource + */ + public void setCurrentUserResource(UserResource newUser) { + currentUserResource = newUser; + } + public static native void preventIESelection() /*-{ $doc.body.onselectstart = function () { return false; }; }-*/; @@ -699,4 +729,14 @@ public class GSS implements EntryPoint, WindowResizeListener { return GWT.getModuleBaseURL() + conf.apiPath(); } + public void refreshWebDAVPassword() { + Configuration conf = (Configuration) GWT.create(Configuration.class); + String domain = Window.Location.getHostName(); + String path = Window.Location.getPath(); + String cookie = conf.webdavCookie(); + webDAVPassword = Cookies.getCookie(cookie); + Cookies.setCookie(cookie, "", null, domain, path, false); + } + + }