/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
package gr.grnet.pithos.web.client.mysharedtree;
import gr.grnet.pithos.web.client.FolderContextMenu;
+import gr.grnet.pithos.web.client.PithosDisclosurePanel;
import gr.grnet.pithos.web.client.TreeView;
import gr.grnet.pithos.web.client.foldertree.Folder;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.resources.client.ClientBundle.Source;
import com.google.gwt.resources.client.ImageResource.ImageOptions;
+import com.google.gwt.resources.client.ImageResource.RepeatStyle;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
import com.google.gwt.user.cellview.client.TreeNode;
+import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Tree;
public class MysharedTreeView extends Composite implements TreeView {
public void updateChildren(Folder folder) {
- TreeNode root = ((CellTree) getWidget()).getRootTreeNode();
+ TreeNode root = tree.getRootTreeNode();
updateChildren(root, folder);
}
@Override
@Source({"gr/grnet/pithos/web/client/PithosCellTreeBasic.css"})
CellTree.Style cellTreeStyle();
+
+ @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
+ @ImageOptions(repeatStyle=RepeatStyle.None)
+ ImageResource cellTreeLoadingBasic();
}
public static interface Images extends Tree.Resources, FolderContextMenu.Images {
@Source("gr/grnet/pithos/resources/home22.png")
ImageResource home();
- @Source("gr/grnet/pithos/resources/folder22.png")
+ @Source("gr/grnet/pithos/resources/2folder22.png")
public ImageResource folderYellow();
@Source("gr/grnet/pithos/resources/mimetypes/document.png")
ImageResource document();
- @Source("gr/grnet/pithos/resources/othersshared.png")
- ImageResource othersShared();
-
@Source("gr/grnet/pithos/resources/myshared22.png")
ImageResource myShared();
+ @Source("gr/grnet/pithos/resources/sharedbyme22.png")
+ ImageResource sharedByMe();
+
@Source("gr/grnet/pithos/resources/folder_user.png")
ImageResource sharedFolder();
}
public SafeHtml nameSpan(String name);
}
+ interface Style extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Style {
+ @Override
+ String header();
+ }
+
+ interface Resources extends gr.grnet.pithos.web.client.PithosDisclosurePanel.Resources {
+ @Override
+ @Source("PithosMySharedDisclosurePanel.css")
+ Style pithosDisclosurePanelCss();
+
+ @Override
+ @Source("gr/grnet/pithos/resources/sharedbyme22.png")
+ ImageResource icon();
+ }
+
private MysharedTreeViewModel model;
+ private PithosDisclosurePanel panel;
+
+ private CellTree tree;
+
+ private CellTree.Resources res = GWT.create(BasicResources.class);
+
public MysharedTreeView(MysharedTreeViewModel viewModel) {
this.model = viewModel;
- /*
+
+ panel = new PithosDisclosurePanel((Resources) GWT.create(Resources.class), "Shared by me", false);
+ createTree();
+
+ initWidget(panel);
+ }
+
+ /**
+ *
+ */
+ void createTree() {
+ /*
* Create the tree using the model. We use <code>null</code> as the default
* value of the root node. The default value will be passed to
* CustomTreeModel#getNodeInfo();
*/
- CellTree.Resources res = GWT.create(BasicResources.class);
- CellTree tree = new CellTree(model, null, res);
+ if (tree != null)
+ tree.removeFromParent();
+ tree = new CellTree(model, null, res);
tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
-
- initWidget(tree);
- }
+ panel.setContent(tree);
+ }
@Override
return model.getSelection();
}
- public void updateFolder(Folder folder, boolean showfiles) {
- model.updateFolder(folder, showfiles);
+ public void updateFolder(Folder folder, boolean showfiles, Command callback) {
+ model.updateFolder(folder, showfiles, callback);
}
+
+ public void updateRoot() {
+ model.initialize(new Command() {
+
+ @Override
+ public void execute() {
+ createTree();
+ }
+ });
+ }
}