2 * Copyright 2011 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
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.
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.
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.
35 package gr.grnet.pithos.web.client;
37 import com.google.gwt.user.client.ui.Composite;
39 public class VersionsList extends Composite {
41 // private Pithos app;
43 // int selectedRow = -1;
45 // int permissionCount = -1;
47 // List<FileResource> versions = null;
49 // final Images images;
51 // final VerticalPanel permPanel = new VerticalPanel();
53 // final FlexTable permTable = new FlexTable();
55 // FileResource toRemove = null;
57 // FilePropertiesDialog container;
59 // public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
61 // images = theImages;
62 // container = aContainer;
63 // versions = theVersions;
64 // Collections.sort(theVersions, new Comparator<FileResource>(){
67 // public int compare(FileResource o1, FileResource o2) {
68 // return o1.getVersion().compareTo(o2.getVersion());
72 // permTable.setText(0, 0, "Version");
73 // permTable.setText(0, 1, "Created");
74 // permTable.setText(0, 2, "Modified");
75 // permTable.setText(0, 3, "Size");
76 // permTable.setText(0, 4, "");
77 // permTable.setText(0, 5, "");
78 // permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
79 // permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
80 // permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
81 // permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
82 // permTable.getFlexCellFormatter().setColSpan(0, 1, 2);
83 // permTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
84 // permTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
85 // permTable.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
86 // permTable.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
87 // permPanel.add(permTable);
88 // permPanel.addStyleName("pithos-TabPanelBottom");
89 // permTable.addStyleName("pithos-permList");
90 // initWidget(permPanel);
94 // public void updateTable() {
95 // copyListAndContinue(versions);
98 // public void showVersionsTable(){
100 // if (toRemove != null) {
101 // versions.remove(toRemove);
104 // for (final FileResource dto : versions) {
105 // HTML restoreVersion = new HTML("<a href='#' class='hidden-link info'><span>"+AbstractImagePrototype.create(images.restore()).getHTML()+"</span><div>Restore this Version</div></a>");
106 // restoreVersion.addClickHandler(new ClickHandler() {
108 // public void onClick(ClickEvent event) {
109 // restoreVersion(dto);
113 // permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>");
114 // permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + app.findUserFullName(dto.getCreatedBy()) + "</span>");
115 // permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + app.findUserFullName(dto.getModifiedBy()) + "</span>");
116 // permTable.setHTML(i, 3, "<span>" + dto.getFileSizeAsString() + "</span>");
117 // HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>"+AbstractImagePrototype.create(images.download()).getHTML()+"</span><div>View this Version</div></a>");
118 // downloadHtml.addClickHandler(new ClickHandler() {
120 // public void onClick(ClickEvent event) {
121 // String fileUrl = dto.getUri() + "?version=" + dto.getVersion();
122 // Window.open(fileUrl, "_BLANK", "");
125 // permTable.setWidget(i, 4, downloadHtml);
126 // permTable.setWidget(i, 5, restoreVersion);
127 // permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
128 // permTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);
129 // permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
130 // permTable.getFlexCellFormatter().setColSpan(i, 1, 2);
131 // permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
132 // permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
135 // for (; i < permTable.getRowCount(); i++)
136 // permTable.removeRow(i);
139 // void restoreVersion(final FileResource version) {
140 //// FileResource selectedFile = (FileResource) app.getCurrentSelection();
141 //// PostCommand ep = new PostCommand(app, selectedFile.getUri()+"?restoreVersion="+version.getVersion(),"",200){
145 //// public void onComplete() {
146 //// container.hide();
147 //// app.getTreeView().refreshCurrentNode(false);
151 //// public void onError(Throwable t) {
153 //// if(t instanceof RestException)
154 //// app.displayError("Unable to restore version:"+((RestException)t).getHttpStatusText());
156 //// app.displayError("System error restoring version:"+t.getMessage());
160 //// DeferredCommand.addCommand(ep);
163 // private String formatDate(Date date){
164 // DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy : HH:mm");
165 // return format.format(date);
169 // * Copies the input List to a new List
172 // private void copyListAndContinue(List<FileResource> input){
173 // List<FileResource> copiedInput = new ArrayList<FileResource>();
174 // for(FileResource dto : input) {
175 // copiedInput.add(dto);
177 // handleFullNames(copiedInput);
181 // * Examines whether or not the user's full name exists in the
182 // * userFullNameMap in the Pithos.java for every element of the input list.
183 // * If the user's full name does not exist in the map then a request is being made
184 // * for the specific username.
188 // private void handleFullNames(List<FileResource> input){
189 // if(input.isEmpty()){
190 // showVersionsTable();
194 // if(app.findUserFullName(input.get(0).getOwner()) == null){
195 // findFullNameAndUpdate(input);
199 // if(input.size() >= 1){
200 // input.remove(input.get(0));
201 // if(input.isEmpty()){
202 // showVersionsTable();
204 // handleFullNames(input);
210 // * Makes a request to search for full name from a given username
211 // * and continues checking the next element of the List.
216 // private void findFullNameAndUpdate(final List<FileResource> input){
217 //// final String aUserName = input.get(0).getOwner();
218 //// String path = app.getApiPath() + "users/" + aUserName;
220 //// GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class, path, false,null) {
222 //// public void onComplete() {
223 //// final UserSearchResource result = getResult();
224 //// for (UserResource user : result.getUsers()){
225 //// String username = user.getUsername();
226 //// String userFullName = user.getName();
227 //// app.putUserToMap(username, userFullName);
228 //// if(input.size() >= 1){
229 //// input.remove(input.get(0));
230 //// if(input.isEmpty()){
231 //// showVersionsTable();
234 //// handleFullNames(input);
239 //// public void onError(Throwable t) {
240 //// app.displayError("Unable to fetch user's full name from the given username " + aUserName);
241 //// if(input.size() >= 1){
242 //// input.remove(input.get(0));
243 //// handleFullNames(input);
247 //// DeferredCommand.addCommand(gg);