Revision a6592a15

b/src/gr/grnet/pithos/web/client/GSS.java
68 68
import gr.grnet.pithos.web.client.rest.resource.TrashResource;
69 69
import gr.grnet.pithos.web.client.rest.resource.UserResource;
70 70

  
71
import gr.grnet.pithos.web.client.tagtree.Tag;
72
import gr.grnet.pithos.web.client.tagtree.TagTreeView;
73
import gr.grnet.pithos.web.client.tagtree.TagTreeViewModel;
71 74
import java.util.ArrayList;
72 75
import java.util.Arrays;
73 76
import java.util.Date;
......
246 249
    private FolderTreeViewModel folderTreeViewModel;
247 250
    private FolderTreeView folderTreeView;
248 251

  
252
    private SingleSelectionModel<Tag> tagTreeSelectionModel;
253
    private TagTreeViewModel tagTreeViewModel;
254
    private TagTreeView tagTreeView;
255

  
249 256
    private AccountResource account;
250 257

  
251 258
	@Override
......
301 308
        fileList = new FileList(images, folderTreeView);
302 309
        inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true);
303 310

  
311
        tagTreeSelectionModel = new SingleSelectionModel<Tag>();
312
        tagTreeViewModel = new TagTreeViewModel(tagTreeSelectionModel);
313
        tagTreeView = new TagTreeView(tagTreeViewModel);
314
        
315
        VerticalPanel trees = new VerticalPanel();
316
        trees.add(folderTreeView);
317
        trees.add(tagTreeView);
304 318
        // Add the left and right panels to the split panel.
305
        splitPanel.setLeftWidget(folderTreeView);
319
        splitPanel.setLeftWidget(trees);
306 320
        splitPanel.setRightWidget(inner);
307 321
        splitPanel.setSplitPosition("25%");
308 322
        splitPanel.setSize("100%", "100%");
b/src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java
52 52
    static interface BasicResources extends CellTree.Resources {
53 53

  
54 54
        @ImageOptions(flipRtl = true)
55
        @Source("cellTreeClosedItem.gif")
55
        @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.gif")
56 56
        ImageResource cellTreeClosedItem();
57 57

  
58 58
        @ImageOptions(flipRtl = true)
59
        @Source("cellTreeLoadingBasic.gif")
59
        @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
60 60
        ImageResource cellTreeLoading();
61 61

  
62 62
        @ImageOptions(flipRtl = true)
63
        @Source("cellTreeOpenItem.gif")
63
        @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.gif")
64 64
        ImageResource cellTreeOpenItem();
65 65

  
66
        @Source({"GssCellTreeBasic.css"})
66
        @Source({"gr/grnet/pithos/web/client/GssCellTreeBasic.css"})
67 67
        CellTree.Style cellTreeStyle();
68 68
    }
69 69

  
/dev/null
1
/*
2
 * Copyright 2010 Google Inc.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 * 
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 * 
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
/* Incremental changes from CellTable.css */ 
17
.cellTableFooter {
18
  padding: 3px 9px;
19
}
20

  
21
.cellTableHeader {
22
  /*padding: 3px 9px;*/
23
  border:none;
24
	background-color: #E0EDFE;
25
	font-weight: bold;
26
	cursor: pointer;
27
}
28

  
29
.cellTableCell {
30
  padding: 4px 9px;
31
  border-width: 0;
32
}
33

  
34
.cellTableFirstColumn {
35
  padding: 0px;
36
}
37

  
38
.cellTableLastColumn {
39
  padding: 0px;
40
}
41

  
42
.cellTableFirstColumnFooter {
43
  border: 0px;
44
  padding: 0px;
45
}
46

  
47
.cellTableFirstColumnHeader {
48
  border: 0px;
49
  padding: 0px;
50
}
51

  
52
.cellTableLastColumnFooter {
53
  border: 0px;
54
  padding: 0px;
55
}
56

  
57
.cellTableLastColumnHeader {
58
  border: 0px;
59
  padding: 0px;
60
}
61

  
62
.cellTableEvenRow {
63
  cursor: hand;
64
  cursor: pointer;
65
}
66

  
67
.cellTableOddRow {
68
  cursor: hand;
69
  cursor: pointer;
70
}
71

  
72
.cellTableSelectedRow {
73
  background: #628cd5;
74
  color: white;
75
  height: auto;
76
  overflow: auto;
77
}
78

  
79
 .cellTableHoveredRow {
80
  
81
  /*background-color: #E0EDFE;
82
  color: white;
83
  height: auto;
84
  overflow: auto;*/
85
}
/dev/null
1
/*
2
 * Copyright 2010 Google Inc.
3
 * 
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 * 
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 * 
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
.cellTreeWidget {
17
  
18
}
19

  
20
.cellTreeEmptyMessage {
21
  padding-left: 16px;
22
  font-style: italic;
23
}
24

  
25
.cellTreeItem {
26
  padding-top: 4px;
27
  padding-bottom: 4px;
28
  cursor: hand;
29
  cursor: pointer;
30
  zoom: 1;
31
}
32

  
33
.cellTreeItemImage {
34
  
35
}
36

  
37
.cellTreeItemImageValue {
38
  zoom: 1;
39
}
40

  
41
.cellTreeItemValue {
42
  padding-left: 3px;
43
  padding-right: 3px;
44
  outline: none;
45
}
46

  
47
.cellTreeOpenItem {
48
  
49
}
50

  
51
.cellTreeTopItem {
52
  
53
}
54

  
55
.cellTreeTopItemImage {
56
  
57
}
58

  
59
.cellTreeTopItemImageValue {
60
  
61
}
62

  
63
.cellTreeKeyboardSelectedItem {
64
  background-color: #ffc;
65
  outline: none;
66
}
67

  
68
.cellTreeSelectedItem {
69
  background-color: #628cd5;
70
  color: white;
71
  height: auto;
72
  overflow: visible;
73
}
74

  
75
.cellTreeShowMoreButton {
76
  padding-left: 16px;
77
  outline: none;
78
}
b/src/gr/grnet/pithos/web/client/tagtree/Tag.java
1
/*
2
 * Copyright 2011 GRNET S.A. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or
5
 * without modification, are permitted provided that the following
6
 * conditions are met:
7
 *
8
 *   1. Redistributions of source code must retain the above
9
 *      copyright notice, this list of conditions and the following
10
 *      disclaimer.
11
 *
12
 *   2. Redistributions in binary form must reproduce the above
13
 *      copyright notice, this list of conditions and the following
14
 *      disclaimer in the documentation and/or other materials
15
 *      provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
 * POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * The views and conclusions contained in the software and
31
 * documentation are those of the authors and should not be
32
 * interpreted as representing official policies, either expressed
33
 * or implied, of GRNET S.A.
34
 */
35

  
36
package gr.grnet.pithos.web.client.tagtree;
37

  
38
import com.google.gwt.http.client.Response;
39
import com.google.gwt.i18n.client.DateTimeFormat;
40
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
41
import com.google.gwt.json.client.JSONArray;
42
import com.google.gwt.json.client.JSONObject;
43
import com.google.gwt.json.client.JSONParser;
44
import com.google.gwt.json.client.JSONValue;
45
import gr.grnet.pithos.web.client.foldertree.File;
46
import gr.grnet.pithos.web.client.foldertree.Resource;
47
import java.util.Date;
48
import java.util.Iterator;
49
import java.util.LinkedHashSet;
50
import java.util.Set;
51

  
52
public class Tag extends Resource {
53
    /*
54
     * The name of the tag.
55
     */
56
    private String name = null;
57

  
58
    private Set<File> files = new LinkedHashSet<File>();
59

  
60
    public Tag() {};
61

  
62
    public Tag(String name) {
63
        this.name = name;
64
    }
65
    
66
    public String getName() {
67
        return name;
68
    }
69

  
70
//    public void populate(Response response) {
71
//        String header = response.getHeader("Last-Modified");
72
//        if (header != null)
73
//            lastModified = DateTimeFormat.getFormat(PredefinedFormat.RFC_2822).parse(header);
74
//
75
//        header = response.getHeader("X-Container-Bytes-Used");
76
//        if (header != null)
77
//            bytesUsed = Long.valueOf(header);
78
//
79
//        header = response.getHeader("X-Object-Meta-Trash");
80
//        if (header != null && header.equals("true"))
81
//            inTrash = true;
82
//
83
//        subfolders.clear(); //This is necessary in case we update a pre-existing Tag so that stale subfolders won't show up
84
//        files.clear();
85
//        JSONValue json = JSONParser.parseStrict(response.getText());
86
//        JSONArray array = json.isArray();
87
//        if (array != null) {
88
//            for (int i=0; i<array.size(); i++) {
89
//                JSONObject o = array.get(i).isObject();
90
//                if (o != null) {
91
//                    String contentType = unmarshallString(o, "content_type");
92
//                    if (o.containsKey("subdir") || (contentType != null && (contentType.startsWith("application/directory") || contentType.startsWith("application/folder")))) {
93
//                        Tag f = new Tag();
94
//                        f.populate(this, o, container);
95
//                        subfolders.add(f);
96
//                    }
97
//                    else if (!(o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true"))) {
98
//                        File file = new File();
99
//                        file.populate(this, o, container);
100
//                        files.add(file);
101
//                    }
102
//                }
103
//            }
104
//            //This step is necessary to remove the trashed folders. Trashed folders are added initially because we need to
105
//            //avoid having in the list the virtual folders of the form {"subdir":"folder1"} which have no indication of thrash
106
//            Iterator<Tag> iter = subfolders.iterator();
107
//            while (iter.hasNext()) {
108
//                Tag f = iter.next();
109
//                if (f.isInTrash())
110
//                    iter.remove();
111
//            }
112
//        }
113
//    }
114
//
115
//    public void populate(Tag parent, JSONObject o, String aContainer) {
116
//        this.parent = parent;
117
//        String path = null;
118
//        if (o.containsKey("subdir")) {
119
//            path = unmarshallString(o, "subdir");
120
//        }
121
//        else {
122
//            path = unmarshallString(o, "name");
123
//            lastModified = unmarshallDate(o, "last_modified");
124
//        }
125
//        if (path.endsWith("/"))
126
//            path = path.substring(0, path.length() - 1);
127
//        if (path.contains("/"))
128
//            name = path.substring(path.lastIndexOf("/") + 1, path.length()); //strip the prefix
129
//        else
130
//            name = path;
131
//        if (aContainer != null) {
132
//            container = aContainer;
133
//            prefix = path;
134
//        }
135
//        else {
136
//            container = name;
137
//            prefix = "";
138
//        }
139
//        if (o.containsKey("x_object_meta_trash") && o.get("x_object_meta_trash").isString().stringValue().equals("true"))
140
//            inTrash = true;
141
//    }
142
//
143
//    public static Tag createFromResponse(Response response, Tag result) {
144
//        Tag f = null;
145
//        if (result == null)
146
//            f = new Tag();
147
//        else
148
//            f = result;
149
//
150
//        f.populate(response);
151
//        return f;
152
//    }
153

  
154
    @Override
155
    public boolean equals(Object other) {
156
        if (other instanceof Tag) {
157
            Tag o = (Tag) other;
158
            return name.equals(o.getName());
159
        }
160
        return false;
161
    }
162

  
163
    @Override
164
    public int hashCode() {
165
        return name.hashCode();
166
    }
167

  
168
    public Set<File> getFiles() {
169
        return files;
170
    }
171
}
b/src/gr/grnet/pithos/web/client/tagtree/TagTreeView.java
1
/*
2
 * Copyright 2011 GRNET S.A. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or
5
 * without modification, are permitted provided that the following
6
 * conditions are met:
7
 *
8
 *   1. Redistributions of source code must retain the above
9
 *      copyright notice, this list of conditions and the following
10
 *      disclaimer.
11
 *
12
 *   2. Redistributions in binary form must reproduce the above
13
 *      copyright notice, this list of conditions and the following
14
 *      disclaimer in the documentation and/or other materials
15
 *      provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
 * POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * The views and conclusions contained in the software and
31
 * documentation are those of the authors and should not be
32
 * interpreted as representing official policies, either expressed
33
 * or implied, of GRNET S.A.
34
 */
35

  
36
package gr.grnet.pithos.web.client.tagtree;
37

  
38
import com.google.gwt.core.client.GWT;
39
import com.google.gwt.resources.client.ClientBundle;
40
import com.google.gwt.resources.client.ImageResource;
41
import com.google.gwt.resources.client.ImageResource.ImageOptions;
42
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
43
import com.google.gwt.safehtml.shared.SafeHtml;
44
import com.google.gwt.user.cellview.client.CellTree;
45
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy;
46
import com.google.gwt.user.client.ui.Composite;
47
import com.google.gwt.user.client.ui.Tree;
48
import gr.grnet.pithos.web.client.FolderContextMenu;
49

  
50
public class TagTreeView extends Composite {
51

  
52
    static interface BasicResources extends CellTree.Resources {
53

  
54
        @ImageOptions(flipRtl = true)
55
        @Source("gr/grnet/pithos/web/client/cellTreeClosedItem.gif")
56
        ImageResource cellTreeClosedItem();
57

  
58
        @ImageOptions(flipRtl = true)
59
        @Source("gr/grnet/pithos/web/client/cellTreeLoadingBasic.gif")
60
        ImageResource cellTreeLoading();
61

  
62
        @ImageOptions(flipRtl = true)
63
        @Source("gr/grnet/pithos/web/client/cellTreeOpenItem.gif")
64
        ImageResource cellTreeOpenItem();
65

  
66
        @Source({"gr/grnet/pithos/web/client/GssCellTreeBasic.css"})
67
        CellTree.Style cellTreeStyle();
68
    }
69

  
70
    static interface Images extends ClientBundle,Tree.Resources, FolderContextMenu.Images {
71

  
72
        @Source("gr/grnet/pithos/resources/folder_home.png")
73
        ImageResource home();
74

  
75
        @Source("gr/grnet/pithos/resources/info.png")
76
        public ImageResource tag();
77
    }
78

  
79
    static Images images = GWT.create(Images.class);
80

  
81
    static interface Templates extends SafeHtmlTemplates {
82
        public Templates INSTANCE = GWT.create(Templates.class);
83

  
84
        @Template("<span>{0}</span>")
85
        public SafeHtml nameSpan(String name);
86
      }
87

  
88
    private TagTreeViewModel model;
89

  
90
    public TagTreeView(TagTreeViewModel viewModel) {
91
        this.model = viewModel;
92
        /*
93
         * Create the tree using the model. We use <code>null</code> as the default
94
         * value of the root node. The default value will be passed to
95
         * CustomTreeModel#getNodeInfo();
96
         */
97
        CellTree.Resources res = GWT.create(BasicResources.class);
98
        CellTree tree = new CellTree(model, null, res);
99

  
100
        tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
101

  
102
        initWidget(tree);
103
    }
104

  
105

  
106
    public Tag getSelection() {
107
       return model.getSelection();
108
    }
109

  
110
    public void updateTag(Tag tag) {
111
        model.updateTag(tag);
112
    }
113
}
b/src/gr/grnet/pithos/web/client/tagtree/TagTreeViewModel.java
1
/*
2
 * Copyright 2011 GRNET S.A. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or
5
 * without modification, are permitted provided that the following
6
 * conditions are met:
7
 *
8
 *   1. Redistributions of source code must retain the above
9
 *      copyright notice, this list of conditions and the following
10
 *      disclaimer.
11
 *
12
 *   2. Redistributions in binary form must reproduce the above
13
 *      copyright notice, this list of conditions and the following
14
 *      disclaimer in the documentation and/or other materials
15
 *      provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
 * POSSIBILITY OF SUCH DAMAGE.
29
 *
30
 * The views and conclusions contained in the software and
31
 * documentation are those of the authors and should not be
32
 * interpreted as representing official policies, either expressed
33
 * or implied, of GRNET S.A.
34
 */
35

  
36
package gr.grnet.pithos.web.client.tagtree;
37

  
38
import com.google.gwt.cell.client.AbstractCell;
39
import com.google.gwt.cell.client.Cell;
40
import com.google.gwt.cell.client.TextCell;
41
import com.google.gwt.event.dom.client.ContextMenuEvent;
42
import com.google.gwt.safehtml.shared.SafeHtml;
43
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
44
import com.google.gwt.text.shared.SafeHtmlRenderer;
45
import com.google.gwt.user.client.ui.AbstractImagePrototype;
46
import com.google.gwt.view.client.ListDataProvider;
47
import com.google.gwt.view.client.SingleSelectionModel;
48
import com.google.gwt.view.client.TreeViewModel;
49
import gr.grnet.pithos.web.client.tagtree.TagTreeView.Templates;
50

  
51
public class TagTreeViewModel implements TreeViewModel {
52

  
53
    private Cell<Tag> tagCell = new AbstractCell<Tag>(ContextMenuEvent.getType().getName()) {
54

  
55
       @Override
56
        public void render(Context context, Tag tag, SafeHtmlBuilder safeHtmlBuilder) {
57
            String html = AbstractImagePrototype.create(TagTreeView.images.info()).getHTML();
58
            safeHtmlBuilder.appendHtmlConstant(html);
59
            safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(tag.getName()));
60
        }
61

  
62
        @Override
63
        public void onBrowserEvent(Context context, com.google.gwt.dom.client.Element parent, Tag tag, com.google.gwt.dom.client.NativeEvent event, com.google.gwt.cell.client.ValueUpdater<Tag> valueUpdater) {
64
            if (event.getType().equals(com.google.gwt.event.dom.client.ContextMenuEvent.getType().getName())) {
65
                TagTreeViewModel.this.selectionModel.setSelected(tag, true);
66
            }
67
        }
68
    };
69

  
70
    private ListDataProvider<String> rootDataProvider = new ListDataProvider<String>();
71
    private ListDataProvider<Tag> tagDataProvider = new ListDataProvider<Tag>();
72

  
73
    private SingleSelectionModel<Tag> selectionModel;
74

  
75
    public TagTreeViewModel(SingleSelectionModel<Tag> selectionModel) {
76
        this.selectionModel = selectionModel;
77
    }
78

  
79
    @Override
80
    public <T> NodeInfo<?> getNodeInfo(T value) {
81
        if (value == null) {
82
            rootDataProvider.getList().add("Tags");
83
            return new DefaultNodeInfo<String>(rootDataProvider, new TextCell(new SafeHtmlRenderer<String>() {
84
                @Override
85
                public SafeHtml render(String object) {
86
                    SafeHtmlBuilder builder = new SafeHtmlBuilder();
87
                    String html = AbstractImagePrototype.create(TagTreeView.images.tag()).getHTML();
88
                    builder.appendHtmlConstant(html);
89
                    builder.append(Templates.INSTANCE.nameSpan(object));
90
                    return builder.toSafeHtml();
91
                }
92

  
93
                @Override
94
                public void render(String object, SafeHtmlBuilder builder) {
95
                    String html = AbstractImagePrototype.create(TagTreeView.images.tag()).getHTML();
96
                    builder.appendHtmlConstant(html);
97
                    builder.append(Templates.INSTANCE.nameSpan(object));
98
                }
99
            }), new SingleSelectionModel<String>(), null);
100
        }
101
        else if (value instanceof String) {
102
            //fetchAllTags();
103
            return new DefaultNodeInfo<Tag>(tagDataProvider, tagCell, selectionModel, null);
104
        }
105
        else
106
            return null;
107
    }
108

  
109
    @Override
110
    public boolean isLeaf(Object o) {
111
        if (o == null)
112
            return false;
113
        if (o instanceof String)
114
            return false;
115
        else
116
            return true;
117
    }
118

  
119
//    private void fetchFolder(final Iterator<Tag> iter, final ListDataProvider<Tag> dataProvider, final Set<Tag> tags) {
120
//        final GSS app = GSS.get();
121
//        if (iter.hasNext()) {
122
//            final Tag f = iter.next();
123
//
124
//            String path = app.getApiPath() + app.getUsername() + "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
125
//            GetRequest<Tag> getFolder = new GetRequest<Tag>(Tag.class, path, f) {
126
//                @Override
127
//                public void onSuccess(Tag result) {
128
//                    fetchFolder(iter, dataProvider, tags);
129
//                }
130
//
131
//                @Override
132
//                public void onError(Throwable t) {
133
//                    GWT.log("Error getting folder", t);
134
//                    if (t instanceof RestException)
135
//                        GSS.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
136
//                    else
137
//                        GSS.get().displayError("System error fetching folder: " + t.getMessage());
138
//                }
139
//            };
140
//            getFolder.setHeader("X-Auth-Token", app.getToken());
141
//            Scheduler.get().scheduleDeferred(getFolder);
142
//        }
143
//        else {
144
//            dataProvider.getList().clear();
145
//            dataProvider.getList().addAll(tags);
146
//            if (dataProvider.equals(rootDataProvider)) {
147
//                selectionModel.setSelected(dataProvider.getList().get(0), true);
148
//
149
//                Tag f = new Tag("Trash");
150
//                f.setTrash(true);
151
//                f.setContainer("trash");
152
//                dataProvider.getList().add(f);
153
//
154
//                f = new Tag("Shared");
155
//                f.setContainer("shared");
156
//                dataProvider.getList().add(f);
157
//
158
//                f = new Tag("Others");
159
//                f.setContainer("others");
160
//                dataProvider.getList().add(f);
161
//
162
//                f = new Tag("Tags");
163
//                f.setContainer("tags");
164
//                dataProvider.getList().add(f);
165
//
166
//                f = new Tag("Groups");
167
//                f.setContainer("groups");
168
//                dataProvider.getList().add(f);
169
//            }
170
//        }
171
//    }
172
//
173
//    public void initialize(AccountResource account) {
174
//        Iterator<Tag> iter = account.getContainers().iterator();
175
//        fetchFolder(iter, rootDataProvider, account.getContainers());
176
//    }
177
//
178
    public Tag getSelection() {
179
        return selectionModel.getSelectedObject();
180
    }
181

  
182
    public void updateTag(Tag tag) {
183
//        if (dataProviderMap.get(tag) == null) {
184
//            dataProviderMap.put(tag, new ListDataProvider<Tag>());
185
//        }
186
//        final ListDataProvider<Tag> dataProvider = dataProviderMap.get(tag);
187
//        if (!tag.isTrash())
188
//            fetchFolder(tag, dataProvider);
189
//        else
190
//            GSS.get().showFiles(tag);
191
    }
192

  
193
//    public void fetchFolder(final Tag f, final ListDataProvider<Tag> dataProvider) {
194
//        dataProvider.flush();
195
//        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
196
//            @Override
197
//            public void execute() {
198
//                final GSS app = GSS.get();
199
//                String path = app.getApiPath() + app.getUsername() + "/" + f.getContainer() + "?format=json&delimiter=/&prefix=" + f.getPrefix();
200
//                GetRequest<Tag> getFolder = new GetRequest<Tag>(Tag.class, path, f) {
201
//                    @Override
202
//                    public void onSuccess(Tag result) {
203
//                        app.showFiles(result);
204
//                        Iterator<Tag> iter = result.getSubfolders().iterator();
205
//                        fetchFolder(iter, dataProvider, result.getSubfolders());
206
//                    }
207
//
208
//                    @Override
209
//                    public void onError(Throwable t) {
210
//                        GWT.log("Error getting folder", t);
211
//                        if (t instanceof RestException)
212
//                            GSS.get().displayError("Error getting folder: " + ((RestException) t).getHttpStatusText());
213
//                        else
214
//                            GSS.get().displayError("System error fetching folder: " + t.getMessage());
215
//                    }
216
//                };
217
//                getFolder.setHeader("X-Auth-Token", app.getToken());
218
//                Scheduler.get().scheduleDeferred(getFolder);
219
//            }
220
//        });
221
//    }
222
}

Also available in: Unified diff