X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/8e76db3e5c4f6b9c086aa8e9434c503289165876..a5f972b31d13440a71201e7112bc7a0bdb96d29d:/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 31b7bf3..d5d662d 100644 --- a/src/gr/ebs/gss/client/GSS.java +++ b/src/gr/ebs/gss/client/GSS.java @@ -19,25 +19,20 @@ package gr.ebs.gss.client; import gr.ebs.gss.client.clipboard.Clipboard; -import gr.ebs.gss.client.commands.GetUserCommand; -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; import gr.ebs.gss.client.rest.resource.FolderResource; +import gr.ebs.gss.client.rest.resource.RestResource; +import gr.ebs.gss.client.rest.resource.RestResourceWrapper; import gr.ebs.gss.client.rest.resource.TrashResource; import gr.ebs.gss.client.rest.resource.UserResource; import java.util.Arrays; import java.util.Date; import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import com.allen_sauer.gwt.dnd.client.DragContext; -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; @@ -51,25 +46,18 @@ 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.History; import com.google.gwt.user.client.Window; -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; 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.TabPanel; -import com.google.gwt.user.client.ui.TreeItem; import com.google.gwt.user.client.ui.VerticalPanel; -import com.google.gwt.user.client.ui.Widget; - /** * Entry point classes define onModuleLoad(). */ @@ -94,7 +82,7 @@ public class GSS implements EntryPoint, ResizeHandler { * An aggregate image bundle that pulls together all the images for this * application into a single bundle. */ - 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, CellTreeView.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, CellTreeView.Images { @Source("gr/ebs/gss/resources/document.png") ImageResource folders(); @@ -187,8 +175,8 @@ public class GSS implements EntryPoint, ResizeHandler { /** * The widget that displays the tree of folders. */ - private Folders folders = new Folders(images); - + + private CellTreeView treeView = new CellTreeView(images); /** * The currently selected item in the application, for use by the Edit menu * commands. Potential types are Folder, File, User and Group. @@ -205,7 +193,7 @@ public class GSS implements EntryPoint, ResizeHandler { */ private String webDAVPassword; - private PickupDragController dragController; + public HashMap userFullNameMap = new HashMap(); @@ -216,75 +204,7 @@ public class GSS implements EntryPoint, ResizeHandler { singleton = this; RootPanel.get().add(glassPanel, 0, 0); parseUserCredentials(); - dragController = new PickupDragController(RootPanel.get(), false) { - - @Override - public void previewDragStart() throws VetoDragException { - super.previewDragStart(); - if (context.selectedWidgets.isEmpty()) - 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 - protected Widget newDragProxy(DragContext aContext) { - AbsolutePanel container = new AbsolutePanel(); - HTML html = null; - DOM.setStyleAttribute(container.getElement(), "overflow", "visible"); - if(aContext.draggable!=null && aContext.draggable.getParent()!= null && aContext.draggable.getParent() instanceof FileTable){ - if(getFileList().getSelectedFiles().size()>1){ - html=new HTML(getFileList().getSelectedFiles().size()+ " files"); - container.add(html); - return container; - } - FileTable proxy; - proxy = new FileTable(1,8); - proxy.addStyleName("gss-List"); - FileTable draggableTable = (FileTable) context.draggable.getParent(); - int dragRow = FileTable.getWidgetRow(context.draggable, draggableTable); - FileTable.copyRow(draggableTable, proxy, dragRow, 0); - return proxy; - - } - for (Iterator iterator = aContext.selectedWidgets.iterator(); iterator.hasNext();) { - Widget widget = (Widget) iterator.next(); - 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 - container.add(html); - return container; - } - return container; - } - }; - dragController.setBehaviorDragProxy(true); - dragController.setBehaviorMultipleSelection(false); + topPanel = new TopPanel(GSS.images); topPanel.setWidth("100%"); @@ -311,7 +231,7 @@ public class GSS implements EntryPoint, ResizeHandler { inner.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); - inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); + //inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); inner.setWidth("100%"); inner.selectTab(0); @@ -359,9 +279,11 @@ public class GSS implements EntryPoint, ResizeHandler { else if(historyToken.equals("Files")|| historyToken.length()==0) inner.selectTab(0); else { + /*TODO: CELLTREE PopupTree popupTree = GSS.get().getFolders().getPopupTree(); TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); SelectionEvent.fire(popupTree, treeObj); + */ } } catch (IndexOutOfBoundsException e) { inner.selectTab(0); @@ -370,7 +292,7 @@ public class GSS implements EntryPoint, ResizeHandler { }); // Add the left and right panels to the split panel. - splitPanel.setLeftWidget(folders); + splitPanel.setLeftWidget(treeView); splitPanel.setRightWidget(inner); splitPanel.setSplitPosition("25%"); splitPanel.setSize("100%", "100%"); @@ -516,6 +438,10 @@ public class GSS implements EntryPoint, ResizeHandler { if (newHeight < 1) newHeight = 1; splitPanel.setHeight("" + newHeight); + inner.setHeight("" + newHeight); + /*if(isFileListShowing()){ + getFileList().setHeight("" + (newHeight-50)); + }*/ } @Override @@ -559,7 +485,40 @@ public class GSS implements EntryPoint, ResizeHandler { * @param update */ public void showFileList(boolean update) { - TreeItem currentFolder = getFolders().getCurrent(); + /*TreeItem currentFolder = getFolders().getCurrent(); + if (currentFolder != null) { + List files = null; + Object cachedObject = currentFolder.getUserObject(); + if (cachedObject instanceof FolderResource) { + FolderResource folder = (FolderResource) cachedObject; + files = folder.getFiles(); + } else if (cachedObject instanceof TrashResource) { + TrashResource folder = (TrashResource) cachedObject; + files = folder.getFiles(); + } + if (files != null) + getFileList().setFiles(files); + }*/ + RestResource currentFolder = getTreeView().getSelection(); + GWT.log("SELECTED:"+currentFolder); + if(currentFolder!=null){ + List files = null; + if (currentFolder instanceof RestResourceWrapper) { + RestResourceWrapper folder = (RestResourceWrapper) currentFolder; + files = folder.getResource().getFiles(); + } else if (currentFolder instanceof TrashResource) { + TrashResource folder = (TrashResource) currentFolder; + files = folder.getFiles(); + } + if (files != null) + getFileList().setFiles(files); + } + fileList.updateFileCache(update, true /*clear selection*/); + inner.selectTab(0); + } + + public void showFileList(RestResource r,boolean update) { + /*TreeItem currentFolder = getFolders().getCurrent(); if (currentFolder != null) { List files = null; Object cachedObject = currentFolder.getUserObject(); @@ -572,6 +531,20 @@ public class GSS implements EntryPoint, ResizeHandler { } if (files != null) getFileList().setFiles(files); + }*/ + RestResource currentFolder = r; + GWT.log("SELECTED:"+currentFolder); + if(currentFolder!=null){ + List files = null; + if (currentFolder instanceof RestResourceWrapper) { + RestResourceWrapper folder = (RestResourceWrapper) currentFolder; + files = folder.getResource().getFiles(); + } else if (currentFolder instanceof TrashResource) { + TrashResource folder = (TrashResource) currentFolder; + files = folder.getFiles(); + } + if (files != null) + getFileList().setFiles(files); } fileList.updateFileCache(update, true /*clear selection*/); inner.selectTab(0); @@ -654,10 +627,10 @@ public class GSS implements EntryPoint, ResizeHandler { * Retrieve the folders. * * @return the folders - */ + public Folders getFolders() { return folders; - } + }*/ /** * Retrieve the search. @@ -739,14 +712,7 @@ public class GSS implements EntryPoint, ResizeHandler { return userDetailsPanel; } - /** - * Retrieve the dragController. - * - * @return the dragController - */ - public PickupDragController getDragController() { - return dragController; - } + public String getToken() { return token; @@ -869,5 +835,21 @@ public class GSS implements EntryPoint, ResizeHandler { public String findUserFullName(String _userName){ return userFullNameMap.get(_userName); } - + + /** + * Retrieve the treeView. + * + * @return the treeView + */ + public CellTreeView getTreeView() { + return treeView; + } + + public void onResourceUpdate(RestResource resource){ + if(resource instanceof RestResourceWrapper){ + if(getTreeView().getSelection()!=null&&getTreeView().getSelection().getUri().equals(resource.getUri())) + showFileList(resource,true); + } + + } }