root / src / gr / grnet / pithos / web / client / foldertree / FolderTreeView.java @ 447407c8
History | View | Annotate | Download (4 kB)
1 | 6084aa02 | Christos Stathis | /*
|
---|---|---|---|
2 | 63366925 | Christos Stathis | * Copyright 2011 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | 6084aa02 | Christos Stathis | */
|
35 | 6084aa02 | Christos Stathis | |
36 | 6084aa02 | Christos Stathis | package gr.grnet.pithos.web.client.foldertree; |
37 | 6084aa02 | Christos Stathis | |
38 | 6084aa02 | Christos Stathis | import com.google.gwt.core.client.GWT; |
39 | 6084aa02 | Christos Stathis | import com.google.gwt.resources.client.ClientBundle; |
40 | 6084aa02 | Christos Stathis | import com.google.gwt.resources.client.ImageResource; |
41 | 6084aa02 | Christos Stathis | import com.google.gwt.resources.client.ImageResource.ImageOptions; |
42 | 6084aa02 | Christos Stathis | import com.google.gwt.safehtml.client.SafeHtmlTemplates; |
43 | 6084aa02 | Christos Stathis | import com.google.gwt.safehtml.shared.SafeHtml; |
44 | 6084aa02 | Christos Stathis | import com.google.gwt.user.cellview.client.CellTree; |
45 | 6084aa02 | Christos Stathis | import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; |
46 | 6084aa02 | Christos Stathis | import com.google.gwt.user.client.ui.Composite; |
47 | 6084aa02 | Christos Stathis | import com.google.gwt.user.client.ui.Tree; |
48 | 6084aa02 | Christos Stathis | import gr.grnet.pithos.web.client.FolderContextMenu; |
49 | 6084aa02 | Christos Stathis | |
50 | 6084aa02 | Christos Stathis | public class FolderTreeView extends Composite { |
51 | 6084aa02 | Christos Stathis | |
52 | 6084aa02 | Christos Stathis | static interface BasicResources extends CellTree.Resources { |
53 | 6084aa02 | Christos Stathis | |
54 | 6084aa02 | Christos Stathis | @ImageOptions(flipRtl = true) |
55 | 6084aa02 | Christos Stathis | @Source("cellTreeClosedItem.gif") |
56 | 6084aa02 | Christos Stathis | ImageResource cellTreeClosedItem(); |
57 | 6084aa02 | Christos Stathis | |
58 | 6084aa02 | Christos Stathis | @ImageOptions(flipRtl = true) |
59 | 6084aa02 | Christos Stathis | @Source("cellTreeLoadingBasic.gif") |
60 | 6084aa02 | Christos Stathis | ImageResource cellTreeLoading(); |
61 | 6084aa02 | Christos Stathis | |
62 | 6084aa02 | Christos Stathis | @ImageOptions(flipRtl = true) |
63 | 6084aa02 | Christos Stathis | @Source("cellTreeOpenItem.gif") |
64 | 6084aa02 | Christos Stathis | ImageResource cellTreeOpenItem(); |
65 | 6084aa02 | Christos Stathis | |
66 | 6084aa02 | Christos Stathis | @Source({"GssCellTreeBasic.css"}) |
67 | 6084aa02 | Christos Stathis | CellTree.Style cellTreeStyle(); |
68 | 6084aa02 | Christos Stathis | } |
69 | 6084aa02 | Christos Stathis | |
70 | 6084aa02 | Christos Stathis | static interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images { |
71 | 6084aa02 | Christos Stathis | |
72 | 6084aa02 | Christos Stathis | @Source("gr/grnet/pithos/resources/folder_home.png") |
73 | 6084aa02 | Christos Stathis | ImageResource home(); |
74 | 6084aa02 | Christos Stathis | |
75 | 6084aa02 | Christos Stathis | @Source("gr/grnet/pithos/resources/folder_yellow.png") |
76 | 447407c8 | Christos Stathis | public ImageResource folderYellow();
|
77 | 6084aa02 | Christos Stathis | } |
78 | 6084aa02 | Christos Stathis | |
79 | 447407c8 | Christos Stathis | static Images images = GWT.create(Images.class);
|
80 | 6084aa02 | Christos Stathis | |
81 | 6084aa02 | Christos Stathis | static interface Templates extends SafeHtmlTemplates { |
82 | 447407c8 | Christos Stathis | public Templates INSTANCE = GWT.create(Templates.class); |
83 | 6084aa02 | Christos Stathis | |
84 | 6084aa02 | Christos Stathis | @Template("<span>{0}</span>") |
85 | 6084aa02 | Christos Stathis | public SafeHtml nameSpan(String name); |
86 | 6084aa02 | Christos Stathis | } |
87 | 6084aa02 | Christos Stathis | |
88 | 7c818c14 | Christos Stathis | private FolderTreeViewModel model;
|
89 | 7c818c14 | Christos Stathis | |
90 | 7c818c14 | Christos Stathis | public FolderTreeView(FolderTreeViewModel viewModel) {
|
91 | 7c818c14 | Christos Stathis | this.model = viewModel;
|
92 | 6084aa02 | Christos Stathis | /*
|
93 | 6084aa02 | Christos Stathis | * Create the tree using the model. We use <code>null</code> as the default
|
94 | 6084aa02 | Christos Stathis | * value of the root node. The default value will be passed to
|
95 | 6084aa02 | Christos Stathis | * CustomTreeModel#getNodeInfo();
|
96 | 6084aa02 | Christos Stathis | */
|
97 | 6084aa02 | Christos Stathis | CellTree.Resources res = GWT.create(BasicResources.class); |
98 | 3009106c | Christos Stathis | CellTree tree = new CellTree(model, null, res); |
99 | 6084aa02 | Christos Stathis | |
100 | 6084aa02 | Christos Stathis | tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); |
101 | 6084aa02 | Christos Stathis | |
102 | 6084aa02 | Christos Stathis | initWidget(tree); |
103 | 6084aa02 | Christos Stathis | } |
104 | 875a0179 | Christos Stathis | |
105 | 447407c8 | Christos Stathis | |
106 | 875a0179 | Christos Stathis | public Folder getSelection() {
|
107 | 875a0179 | Christos Stathis | return model.getSelection();
|
108 | 875a0179 | Christos Stathis | } |
109 | 6084aa02 | Christos Stathis | } |