import gr.ebs.gss.client.rest.RestException;
import gr.ebs.gss.client.rest.resource.FolderResource;
import gr.ebs.gss.client.rest.resource.MyFolderResource;
+import gr.ebs.gss.client.rest.resource.OtherUserResource;
+import gr.ebs.gss.client.rest.resource.OthersFolderResource;
import gr.ebs.gss.client.rest.resource.OthersResource;
import gr.ebs.gss.client.rest.resource.RestResource;
import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
import gr.ebs.gss.client.rest.resource.SharedResource;
+import gr.ebs.gss.client.rest.resource.TrashFolderResource;
import gr.ebs.gss.client.rest.resource.TrashResource;
import gr.ebs.gss.client.rest.resource.UserResource;
+import gwtquery.plugins.draggable.client.DragAndDropManager;
+import gwtquery.plugins.droppable.client.events.DragAndDropContext;
import gwtquery.plugins.droppable.client.gwt.DragAndDropCellTree;
import java.util.Arrays;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.query.client.plugins.GQueryUi;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.IncrementalCommand;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.view.client.ProvidesKey;
OthersResource others = null;
CellTreeViewModel model;
+ CellTreeViewUtils utils;
public interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images {
super.onBrowserEvent(event);
}
};
+ utils=new CellTreeViewUtils(tree);
tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
Handler selectionHandler = new SelectionChangeEvent.Handler() {
//((DefaultNodeInfo<RestResource>)nodeInfo).getValueUpdater().update(selectionModel.getSelectedObject());
//if(nodeInfo.getProvidesKey() instanceof FolderDataProvider)
//((FolderDataProvider)nodeInfo.getProvidesKey()).onRangeChanged(null);
- if(nodeInfo==null || nodeInfo.getValueUpdater()==null)
- GWT.log("VALUE UPDATER IS NULL");
+ if(nodeInfo==null || nodeInfo.getValueUpdater()==null){}
+
else
nodeInfo.getValueUpdater().update(selectionModel.getSelectedObject());
GSS.get().setCurrentSelection(selectionModel.getSelectedObject());
public void updateNode(RestResource resource){
NodeInfo<RestResource> nodeInfo = (NodeInfo<RestResource>) getModel().getNodeInfo(resource);
- GWT.log("NODE INFO:"+nodeInfo);
if(nodeInfo!=null){
- if(nodeInfo.getValueUpdater()==null)
- GWT.log("VALUE UPDATER IS NULL");
+ if(nodeInfo.getValueUpdater()==null){}
else
nodeInfo.getValueUpdater().update(resource);
}
}
public void updateNodeChildren(final RestResource resource){
- if(resource instanceof RestResourceWrapper)
+
+ if(resource instanceof RestResourceWrapper){
+ boolean updated=false;
if(((RestResourceWrapper)resource).getResource().getFolders().size()==0){
if(model.getMymap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){
model.getMymap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
+ updated=true;
+ }
+ if(model.getOthersmap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){
+ model.getOthersmap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
+ updated=true;
+ }
+ if(model.getSharedmap().get(((RestResourceWrapper)resource).getResource().getParentURI())!=null){
+ model.getSharedmap().get(((RestResourceWrapper)resource).getResource().getParentURI()).refresh(null);
+ updated=true;
+ }
+ if(updated){
+ if(utils.doesSharedNodeContainsResourceIn1stLevel(resource.getUri())){
+ updateMySharedNode();
+ }
return;
}
-
}
+ }
+
+ utils.refreshNodeContainingResource(resource);
+ if(utils.doesSharedNodeContainsResourceIn1stLevel(resource.getUri())){
+ updateMySharedNode();
+ }
- refreshNodeContainingResource(resource);
}
-
+ public void updateNodeChildrenForRemove(final String resource){
+ GWT.log("********************************");
+ GWT.log("[UPDATENODECHILDREN]"+resource);
+ GWT.log("********************************");
+ boolean updated=false;
+ TreeNode node=null;
+ if(tree.getRootTreeNode().isChildOpen(0)){
+ node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(0,true), resource);
+ }
+ GWT.log("CHECK NODE1:"+node+" "+resource);
+ if(node==null)
+ if(tree.getRootTreeNode().isChildOpen(2)){
+ GWT.log("CHECK NODE2:"+node);
+ node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(2,true), resource);
+ }
+ if(node==null)
+ if(tree.getRootTreeNode().isChildOpen(3)){
+ GWT.log("CHECK NODE3:"+node);
+ node = utils.getNodeContainingResource2(tree.getRootTreeNode().setChildOpen(3,true), resource);
+ }
+
+ if(node != null && node.getValue() instanceof RestResourceWrapper){
+ GWT.log("*********************"+((RestResourceWrapper) node.getValue()).getResource().getFolders().size());
+ if(((RestResourceWrapper) node.getValue()).getResource().getFolders().size()==1)
+ updateNodeChildren(((RestResourceWrapper) node.getValue()).getResource().getParentURI());
+ else
+ updateNodeChildren(((RestResource) node.getValue()).getUri());
+ return;
+ /*GWT.log("INSIDE:"+node);
+ RestResourceWrapper rw = (RestResourceWrapper) node.getValue();
+ //if(rw.getResource().getFolders().size()==0){
+ if(model.getMymap().get(rw.getResource().getUri())!=null){
+ model.getMymap().get(rw.getResource().getUri()).refresh(null);
+ updated=true;
+ }
+ if(model.getOthersmap().get(rw.getResource().getUri())!=null){
+ model.getOthersmap().get(rw.getResource().getUri()).refresh(null);
+ updated=true;
+ }
+ if(model.getSharedmap().get(rw.getResource().getUri())!=null){
+ model.getSharedmap().get(rw.getResource().getUri()).refresh(null);
+ updated=true;
+ }
+ if(updated){
+ if(doesSharedNodeContainsResourceIn1stLevel(resource)){
+ updateMySharedNode();
+ }
+ return;
+ }
+ }
+ //}*/
+
+ }
+ updateNodeChildren(resource);
+ }
public void updateNodeChildren(final String resource){
- refreshNodeContainingResource(resource);
+
+
+ GWT.log("REFRESH THE OTHER WAY");
+ utils.refreshNodeContainingResource(resource);
+ if(utils.doesSharedNodeContainsResourceIn1stLevel(resource)){
+ updateMySharedNode();
+ }
}
protected void showPopup(final int x, final int y) {
}
if(myFolders==null||trash==null||myshared==null||others==null)
return !DONE;
- GWT.log("PAPALA");
model.getRootNodes().setList(Arrays.asList((RestResource)myFolders,(RestResource)trash,(RestResource)myshared,(RestResource)others));
tree.getRootTreeNode().setChildOpen(0, true);
selectionModel.setSelected(myFolders, true);
DeferredCommand.addCommand(gf);
}
+ public void updateMySharedNode(){
+ GetCommand<SharedResource> gs = new GetCommand<SharedResource>(SharedResource.class, GSS.get().getCurrentUserResource().getSharedPath(), null) {
+
+ @Override
+ public void onComplete() {
+ myshared=getResult();
+ model.getRootNodes().getList().set(2, myshared);
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ GWT.log("Error fetching Shared Root folder", t);
+ GSS.get().displayError("Unable to fetch Shared Root folder");
+ }
+ };
+ DeferredCommand.addCommand(gs);
+ }
-
+ public void updateOtherNode(){
+ GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
+ GSS.get().getCurrentUserResource().getOthersPath(), null) {
+
+ @Override
+ public void onComplete() {
+ others = getResult();
+ model.getRootNodes().getList().set(3, others);
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ GWT.log("Error fetching Others Root folder", t);
+ GSS.get().displayError("Unable to fetch Others Root folder");
+ }
+ };
+ DeferredCommand.addCommand(go);
+ }
public RestResource getSelection(){
return model;
}
- private void refreshNodeContainingResource(RestResource r){
- TreeNode node = tree.getRootTreeNode();
- refreshNodeContainingResource(node,r);
- }
- private void refreshNodeContainingResource(String uri){
- TreeNode node = tree.getRootTreeNode();
- refreshNodeContainingResource(node,uri);
- }
-
- private void refreshNodeContainingResource(TreeNode node, RestResource resource){
- int count = node.getChildCount();
- for(int i=0;i<count;i++){
- if(node.isChildOpen(i)){
- if(node.getChildValue(i).equals(resource)){
- GWT.log("FOUND RESOURCE");
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- return;
- }
- else{
- TreeNode n = node.setChildOpen(i, true);
- if(n!=null)
- refreshNodeContainingResource(n,resource);
- }
- }
- }
- }
- private void refreshNodeContainingResource(TreeNode node, String uri){
- int count = node.getChildCount();
- for(int i=0;i<count;i++){
- if(node.isChildOpen(i)){
- if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(uri)){
- GWT.log("FOUND RESOURCE");
- node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- return;
- }
- else{
- TreeNode n = node.setChildOpen(i, true);
- if(n!=null)
- refreshNodeContainingResource(n,uri);
- }
- }
- }
- }
- public void openNodeContainingResource(RestResource resource){
- TreeNode node = tree.getRootTreeNode();
- openNodeContainingResource(node,resource);
- }
- private void openNodeContainingResource(TreeNode node, RestResource resource){
- int count = node.getChildCount();
- for(int i=0;i<count;i++){
- if(node.getChildValue(i).equals(resource)){
- GWT.log("FOUND RESOURCE");
- //node.setChildOpen(i, false, true);
- node.setChildOpen(i, true, true);
- return;
- }
- else{
- if(node.isChildOpen(i)){
- TreeNode n = node.setChildOpen(i, true);
- if(n!=null)
- openNodeContainingResource(n,resource);
- }
- }
-
- }
+ /**
+ * Retrieve the utils.
+ *
+ * @return the utils
+ */
+ public CellTreeViewUtils getUtils() {
+ return utils;
}
public interface RefreshHandler{
}
+ public boolean isTrashOrTrashFolderSelected(){
+ return (getSelection() instanceof TrashResource) || (getSelection() instanceof TrashFolderResource);
+ }
+ public OtherUserResource getOtherUserResourceOfOtherFolder(OthersFolderResource res){
+ TreeNode n = utils.getNodeContainingResource(tree.getRootTreeNode().setChildOpen(3, true), res);
+
+ if(n!=null){
+ if(n.getValue() instanceof OtherUserResource)
+ return (OtherUserResource) n.getValue();
+ TreeNode parent = n.getParent();
+
+ while (parent!=null){
+ if(parent.getValue() instanceof OtherUserResource)
+ return (OtherUserResource) parent.getValue();
+ parent = parent.getParent();
+ }
+ }
+ return null;
+ }
}
import gr.ebs.gss.client.rest.resource.SharedResource;
import gr.ebs.gss.client.rest.resource.TrashFolderResource;
import gr.ebs.gss.client.rest.resource.TrashResource;
+import gwtquery.plugins.draggable.client.DragAndDropManager;
import gwtquery.plugins.draggable.client.DraggableOptions;
import gwtquery.plugins.draggable.client.DraggableOptions.CursorAt;
import gwtquery.plugins.draggable.client.DraggableOptions.DragFunction;
import com.google.gwt.cell.client.ValueUpdater;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Cursor;
+import com.google.gwt.query.client.plugins.GQueryUi;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;
final Images images;
SingleSelectionModel<RestResource> selectionModel;
Map<String, MyFolderDataProvider> mymap = new HashMap<String, MyFolderDataProvider>();
+ Map<String, MyFolderDataProvider> sharedmap = new HashMap<String, MyFolderDataProvider>();
+ Map<String, MyFolderDataProvider> othersmap = new HashMap<String, MyFolderDataProvider>();
static interface Templates extends SafeHtmlTemplates {
Templates INSTANCE = GWT.create(Templates.class);
((MyFolderResource) value),MyFolderResource.class);
DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
selectionModel, new ResourceValueUpdater());
+
//nodeInfos.put(((MyFolderResource) value).getUri(), n);
mymap.put(((MyFolderResource) value).getUri(), dataProvider);
DroppableOptions options = n.getDroppableOptions();
options.setOnOver(new DroppableFunction() {
@Override
- public void f(DragAndDropContext context) {
- GWT.log("-->OnActivate:"+context.getDroppableData());
+ public void f(final DragAndDropContext context) {
if(context.getDroppableData()!=null && context.getDroppableData() instanceof RestResource){
- GSS.get().getTreeView().openNodeContainingResource((RestResource) context.getDroppableData());
+ GSS.get().getTreeView().getUtils().openNodeContainingResource((RestResource) context.getDroppableData(), new RefreshHandler() {
+
+ @Override
+ public void onRefresh() {
+
+ DragAndDropManager.getInstance().initialize(context, GQueryUi.Event.create(com.google.gwt.user.client.Event.getCurrentEvent()));
+
+ }
+ });
+
}
+
+
}
});
options.setOnDrop(new DroppableFunction() {
// permission cell are not draggable
//n.setCellDroppableOnly();
configureDragOperation(n.getDraggableOptions());
+
return n;
}
else if (value instanceof SharedResource) {
// Second level.
MyFolderDataProvider dataProvider = new MyFolderDataProvider(
((SharedResource) value), SharedFolderResource.class);
+ sharedmap.put(((SharedResource) value).getUri(), dataProvider);
return new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
selectionModel, new ResourceValueUpdater());
}
((SharedFolderResource) value),SharedFolderResource.class);
DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
selectionModel, new ResourceValueUpdater());
- //nodeInfos.put(((SharedFolderResource) value).getUri(), n);
+ sharedmap.put(((SharedFolderResource) value).getUri(), dataProvider);
DroppableOptions options = n.getDroppableOptions();
options.setDroppableHoverClass("droppableHover");
// use a DroppableFunction here. We can also add a DropHandler in the tree
DragAndDropNodeInfo<RestResource> n = new DragAndDropNodeInfo<RestResource>(dataProvider, departmentCell,
selectionModel, new ResourceValueUpdater());
//nodeInfos.put(((OthersFolderResource) value).getUri(), n);
+ othersmap.put(((SharedFolderResource) value).getUri(), dataProvider);
DroppableOptions options = n.getDroppableOptions();
options.setDroppableHoverClass("droppableHover");
// use a DroppableFunction here. We can also add a DropHandler in the tree
((MyFolderResource)value).setResource(rootResource);
if(GSS.get().getTreeView().getSelection().getUri().equals(value.getUri()))
selectionModel.setSelected(value, true);
- GWT.log("UPDATYING");
GSS.get().onResourceUpdate(value);
}
};
DeferredCommand.addCommand(gf);
}
- if(value instanceof TrashResource){
+ else if(value instanceof TrashResource){
DeferredCommand.addCommand(new GetCommand<TrashResource>(TrashResource.class, GSS.get().getCurrentUserResource().getTrashPath(), null) {
@Override
public void onComplete() {
}
});
}
+ else if(value instanceof OthersFolderResource){
+
+ }
}
}
List<RestResource> res =null;
public void refresh(final RefreshHandler refresh){
- GWT.log("******************************************");
- GWT.log("[REFRESHING]:"+restResource.getUri());
- GWT.log("******************************************");
FolderResource cache = null;
if(restResource instanceof RestResourceWrapper && !((RestResourceWrapper)restResource).getResource().isNeedsExpanding())
cache = ((RestResourceWrapper)restResource).getResource();
((RestResourceWrapper)restResource).getResource().setNeedsExpanding(false);
}
if(usedCachedVersion()&&res!=null){
- updateRowCount(res.size(), true);
- updateRowData(0,res);
+
+ updateRowCount(res.size(), true);
+ updateRowData(0,res);
+
return;
}
String[] folderPaths = null;
else if(resourceClass.equals(MyFolderResource.class))
res.add(new MyFolderResource(r));
else if(resourceClass.equals(SharedFolderResource.class)){
- GWT.log("ADDING:"+r.getUri());
res.add(new SharedFolderResource(r));
}
else if(resourceClass.equals(TrashFolderResource.class))
}
public void refresh(final RefreshHandler refresh){
- GWT.log("******************************************");
- GWT.log("[REFRESHING]:"+restResource.getUri());
- GWT.log("******************************************");
GetCommand<OthersResource> go = new GetCommand<OthersResource>(OthersResource.class,
restResource.getUri(), null) {
public Map<String, MyFolderDataProvider> getMymap() {
return mymap;
}
+
+
+ /**
+ * Retrieve the sharedmap.
+ *
+ * @return the sharedmap
+ */
+ public Map<String, MyFolderDataProvider> getSharedmap() {
+ return sharedmap;
+ }
+
+
+ /**
+ * Retrieve the othersmap.
+ *
+ * @return the othersmap
+ */
+ public Map<String, MyFolderDataProvider> getOthersmap() {
+ return othersmap;
+ }
+
+
--- /dev/null
+/*
+ * Copyright 2011 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client;
+
+import gr.ebs.gss.client.CellTreeView.RefreshHandler;
+import gr.ebs.gss.client.rest.resource.RestResource;
+import gr.ebs.gss.client.rest.resource.RestResourceWrapper;
+
+import com.google.gwt.user.cellview.client.CellTree;
+import com.google.gwt.user.cellview.client.TreeNode;
+
+
+/**
+ * @author kman
+ *
+ */
+public class CellTreeViewUtils {
+ CellTree tree;
+ /**
+ *
+ */
+ public CellTreeViewUtils(CellTree tree) {
+ this.tree = tree;
+ }
+
+ void refreshNodeContainingResource(RestResource r){
+ TreeNode node = tree.getRootTreeNode();
+ refreshNodeContainingResource(node,r);
+ }
+
+ void refreshNodeContainingResource(String uri){
+ TreeNode node = tree.getRootTreeNode();
+ refreshNodeContainingResource(node,uri);
+ }
+
+ private void refreshNodeContainingResource(TreeNode node, RestResource resource){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+ if(node.isChildOpen(i)){
+ if(node.getChildValue(i).equals(resource)){
+ node.setChildOpen(i, false, true);
+ node.setChildOpen(i, true, true);
+ return;
+ }
+ else{
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ refreshNodeContainingResource(n,resource);
+ }
+ }
+ }
+ }
+
+ private void refreshNodeContainingResource(TreeNode node, String uri){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+ if(node.isChildOpen(i)){
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(uri)){
+ if(node.getChildValue(i) instanceof RestResourceWrapper && ((RestResourceWrapper)node.getChildValue(i)).getResource().getFolders().size()==0)
+ return;
+ node.setChildOpen(i, false, true);
+ node.setChildOpen(i, true, true);
+ return;
+ }
+ else{
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ refreshNodeContainingResource(n,uri);
+ }
+ }
+ }
+ }
+ public void openNodeContainingResource(RestResource resource){
+ TreeNode node = tree.getRootTreeNode();
+ openNodeContainingResource(node,resource);
+ }
+ private void openNodeContainingResource(TreeNode node, RestResource resource){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+ if(node.getChildValue(i).equals(resource)){
+ //node.setChildOpen(i, false, true);
+ node.setChildOpen(i, true, true);
+ return;
+ }
+ else{
+ if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ openNodeContainingResource(n,resource);
+ }
+ }
+
+ }
+ }
+
+ public void openNodeContainingResource(RestResource resource, RefreshHandler handler){
+ TreeNode node = tree.getRootTreeNode();
+ openNodeContainingResource(node,resource,handler);
+ }
+ private void openNodeContainingResource(TreeNode node, RestResource resource, RefreshHandler handler){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+ if(node.getChildValue(i).equals(resource)){
+ //node.setChildOpen(i, false, true);
+ node.setChildOpen(i, true, true);
+ handler.onRefresh();
+ return;
+ }
+ else{
+ if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ openNodeContainingResource(n,resource, handler);
+ }
+ }
+
+ }
+ }
+
+
+
+ public boolean doesNodeContainsResource(TreeNode node, RestResource resource){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+ if(node.isChildOpen(i)){
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).equals(resource)){
+ return true;
+ }
+ else if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ return doesNodeContainsResource(n,resource);
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean doesNodeContainsResource(TreeNode node, String resource){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(resource)){
+ return true;
+ }
+ else if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ return doesNodeContainsResource(n,resource);
+ }
+
+ }
+ return false;
+ }
+
+ public TreeNode getNodeContainingResource(TreeNode node, RestResource resource){
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(resource.getUri())){
+ return node;
+ }
+ else if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ return getNodeContainingResource(n,resource);
+ }
+
+ }
+ return null;
+ }
+
+ public TreeNode getNodeContainingResource(TreeNode node, String resource){
+ if(node==null)
+ return null;
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(resource)){
+ return node;
+ }
+ else if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ return getNodeContainingResource(n,resource);
+ }
+
+ }
+ return null;
+ }
+
+ public TreeNode getNodeContainingResource2(TreeNode node, String resource){
+ if(node==null)
+ return null;
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(resource)){
+ return node.setChildOpen(i, node.isChildOpen(i));
+ }
+ else if(node.isChildOpen(i)){
+ TreeNode n = node.setChildOpen(i, true);
+ if(n!=null)
+ return getNodeContainingResource2(n,resource);
+ }
+
+ }
+ return null;
+ }
+ public boolean doesSharedNodeContainsResource( String resource){
+ if(tree.getRootTreeNode().isChildOpen(2)){
+ TreeNode node = tree.getRootTreeNode().setChildOpen(2, true);
+ return doesNodeContainsResource(node, resource);
+ }
+ return false;
+ }
+
+ public boolean doesSharedNodeContainsResourceIn1stLevel( String resource){
+ if(tree.getRootTreeNode().isChildOpen(2)){
+ TreeNode node = tree.getRootTreeNode().setChildOpen(2, true);
+ int count = node.getChildCount();
+ for(int i=0;i<count;i++){
+
+ if(node.getChildValue(i) instanceof RestResource && ((RestResource)node.getChildValue(i)).getUri().equals(resource)){
+ return true;
+ }
+
+ }
+ return false;
+ }
+ return false;
+ }
+
+ public boolean doesRootNodeContainsResource( String resource){
+ if(tree.getRootTreeNode().isChildOpen(0)){
+ TreeNode node = tree.getRootTreeNode().setChildOpen(0, true);
+ return doesNodeContainsResource(node, resource);
+ }
+ return false;
+ }
+
+ public boolean doesSharedNodeContainsResource( RestResource resource){
+ if(tree.getRootTreeNode().isChildOpen(2)){
+ TreeNode node = tree.getRootTreeNode().setChildOpen(2, true);
+ return doesNodeContainsResource(node, resource);
+ }
+ return false;
+ }
+
+ public boolean doesRootNodeContainsResource( RestResource resource){
+ if(tree.getRootTreeNode().isChildOpen(0)){
+ TreeNode node = tree.getRootTreeNode().setChildOpen(0, true);
+ return doesNodeContainsResource(node, resource);
+ }
+ return false;
+ }
+}
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.TrashFolderResource;
import java.util.List;
if(sel instanceof FolderResource)
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
*/
+ if(sel instanceof RestResourceWrapper && !(sel instanceof TrashFolderResource)){
+ contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this));
+ }
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images));
+
} else if (isTrash) {
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + " Restore</span>", true, new RestoreTrashCommand(this));
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, images));
menu = new FileContextMenu(images, false, true);
else return menu;
*/
+ menu = new FileContextMenu(images, false, true);
int left = event.getClientX();
int top = event.getClientY();
menu.setPopupPosition(left, top);
});
}
-
+ public void showContextMenu(Event event){
+ menuShowing = new FileContextMenu(images, false, true);
+ menuShowing=menuShowing.onEmptyEvent(event);
+ }
@Override
public void onBrowserEvent(Event event) {
if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
menuShowing = new FileContextMenu(images, false, true);
menuShowing=menuShowing.onEmptyEvent(event);
+ event.preventDefault();
+ event.cancelBubble(true);
}
return;
}
GWT.log("*****GOING TO SHOW CONTEXT MENU ****", null);
menuShowing = new FileContextMenu(images, false, false);
menuShowing=menuShowing.onEvent(event);
+ event.cancelBubble(true);
+ event.preventDefault();
} else if (DOM.eventGetType(event) == Event.ONCONTEXTMENU && getSelectedFiles().size() == 0) {
menuShowing = new FileContextMenu(images, false, true);
menuShowing=menuShowing.onEmptyEvent(event);
+ event.cancelBubble(true);
+ event.preventDefault();
} else if (DOM.eventGetType(event) == Event.ONDBLCLICK)
if (getSelectedFiles().size() == 1) {
GSS app = GSS.get();
((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource().setUri(newPath);\r
((RestResourceWrapper) GSS.get().getTreeView().getSelection()).setUri(newPath);\r
GSS.get().getTreeView().updateNodeChildren(fres.getParentURI());\r
+ if (permList.hasChanges()) {\r
+ GSS.get().getTreeView().updateMySharedNode();\r
+ }\r
/*\r
if(folderItem.getParentItem() != null && ((DnDTreeItem)folderItem.getParentItem()).getFolderResource() != null){\r
((DnDTreeItem)folderItem.getParentItem()).getFolderResource().removeSubfolderPath(initialPath);\r
import java.util.ArrayList;
import java.util.List;
+
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
GSS.get().getFolders().update(GSS.get().getFolders().getTrashItem());
*/
FolderResource fres = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource();
- GSS.get().getTreeView().updateNodeChildren(fres.getParentURI());
+ GSS.get().getTreeView().updateNodeChildrenForRemove(fres.getParentURI());
//GSS.get().getTreeView().updateNode(GSS.get().getTreeView().getTrash());
GSS.get().getTreeView().updateTrashNode();
GSS.get().showFileList(true);