root / src / gr / grnet / pithos / web / client / VersionsList.java @ f6445935
History | View | Annotate | Download (9.7 kB)
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 |
package gr.grnet.pithos.web.client; |
36 |
|
37 |
import gr.grnet.pithos.web.client.FilePropertiesDialog.Images; |
38 |
|
39 |
import java.util.ArrayList; |
40 |
import java.util.Collections; |
41 |
import java.util.Comparator; |
42 |
import java.util.Date; |
43 |
import java.util.List; |
44 |
|
45 |
import com.google.gwt.event.dom.client.ClickEvent; |
46 |
import com.google.gwt.event.dom.client.ClickHandler; |
47 |
import com.google.gwt.i18n.client.DateTimeFormat; |
48 |
import com.google.gwt.user.client.Window; |
49 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
50 |
import com.google.gwt.user.client.ui.Composite; |
51 |
import com.google.gwt.user.client.ui.FlexTable; |
52 |
import com.google.gwt.user.client.ui.HTML; |
53 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
54 |
import com.google.gwt.user.client.ui.VerticalPanel; |
55 |
|
56 |
public class VersionsList extends Composite { |
57 |
|
58 |
// private Pithos app;
|
59 |
//
|
60 |
// int selectedRow = -1;
|
61 |
//
|
62 |
// int permissionCount = -1;
|
63 |
//
|
64 |
// List<FileResource> versions = null;
|
65 |
//
|
66 |
// final Images images;
|
67 |
//
|
68 |
// final VerticalPanel permPanel = new VerticalPanel();
|
69 |
//
|
70 |
// final FlexTable permTable = new FlexTable();
|
71 |
//
|
72 |
// FileResource toRemove = null;
|
73 |
//
|
74 |
// FilePropertiesDialog container;
|
75 |
//
|
76 |
// public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
|
77 |
// app = _app;
|
78 |
// images = theImages;
|
79 |
// container = aContainer;
|
80 |
// versions = theVersions;
|
81 |
// Collections.sort(theVersions, new Comparator<FileResource>(){
|
82 |
//
|
83 |
// @Override
|
84 |
// public int compare(FileResource o1, FileResource o2) {
|
85 |
// return o1.getVersion().compareTo(o2.getVersion());
|
86 |
// }
|
87 |
//
|
88 |
// });
|
89 |
// permTable.setText(0, 0, "Version");
|
90 |
// permTable.setText(0, 1, "Created");
|
91 |
// permTable.setText(0, 2, "Modified");
|
92 |
// permTable.setText(0, 3, "Size");
|
93 |
// permTable.setText(0, 4, "");
|
94 |
// permTable.setText(0, 5, "");
|
95 |
// permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
|
96 |
// permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
|
97 |
// permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
|
98 |
// permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
|
99 |
// permTable.getFlexCellFormatter().setColSpan(0, 1, 2);
|
100 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
|
101 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
|
102 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
|
103 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
|
104 |
// permPanel.add(permTable);
|
105 |
// permPanel.addStyleName("pithos-TabPanelBottom");
|
106 |
// permTable.addStyleName("pithos-permList");
|
107 |
// initWidget(permPanel);
|
108 |
// updateTable();
|
109 |
// }
|
110 |
//
|
111 |
// public void updateTable() {
|
112 |
// copyListAndContinue(versions);
|
113 |
// }
|
114 |
//
|
115 |
// public void showVersionsTable(){
|
116 |
// int i = 1;
|
117 |
// if (toRemove != null) {
|
118 |
// versions.remove(toRemove);
|
119 |
// toRemove = null;
|
120 |
// }
|
121 |
// for (final FileResource dto : versions) {
|
122 |
// HTML restoreVersion = new HTML("<a href='#' class='hidden-link info'><span>"+AbstractImagePrototype.create(images.restore()).getHTML()+"</span><div>Restore this Version</div></a>");
|
123 |
// restoreVersion.addClickHandler(new ClickHandler() {
|
124 |
// @Override
|
125 |
// public void onClick(ClickEvent event) {
|
126 |
// restoreVersion(dto);
|
127 |
// }
|
128 |
// });
|
129 |
//
|
130 |
// permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>");
|
131 |
// permTable.setHTML(i, 1, "<span>" + formatDate(dto.getCreationDate()) + " by " + app.findUserFullName(dto.getCreatedBy()) + "</span>");
|
132 |
// permTable.setHTML(i, 2, "<span>" + formatDate(dto.getModificationDate()) + " by " + app.findUserFullName(dto.getModifiedBy()) + "</span>");
|
133 |
// permTable.setHTML(i, 3, "<span>" + dto.getFileSizeAsString() + "</span>");
|
134 |
// HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>"+AbstractImagePrototype.create(images.download()).getHTML()+"</span><div>View this Version</div></a>");
|
135 |
// downloadHtml.addClickHandler(new ClickHandler() {
|
136 |
// @Override
|
137 |
// public void onClick(ClickEvent event) {
|
138 |
// String fileUrl = dto.getUri() + "?version=" + dto.getVersion();
|
139 |
// Window.open(fileUrl, "_BLANK", "");
|
140 |
// }
|
141 |
// });
|
142 |
// permTable.setWidget(i, 4, downloadHtml);
|
143 |
// permTable.setWidget(i, 5, restoreVersion);
|
144 |
// permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
|
145 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);
|
146 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
|
147 |
// permTable.getFlexCellFormatter().setColSpan(i, 1, 2);
|
148 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
|
149 |
// permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
|
150 |
// i++;
|
151 |
// }
|
152 |
// for (; i < permTable.getRowCount(); i++)
|
153 |
// permTable.removeRow(i);
|
154 |
// }
|
155 |
//
|
156 |
// void restoreVersion(final FileResource version) {
|
157 |
//// FileResource selectedFile = (FileResource) app.getCurrentSelection();
|
158 |
//// PostCommand ep = new PostCommand(app, selectedFile.getUri()+"?restoreVersion="+version.getVersion(),"",200){
|
159 |
////
|
160 |
////
|
161 |
//// @Override
|
162 |
//// public void onComplete() {
|
163 |
//// container.hide();
|
164 |
//// app.getTreeView().refreshCurrentNode(false);
|
165 |
//// }
|
166 |
////
|
167 |
//// @Override
|
168 |
//// public void onError(Throwable t) {
|
169 |
//// GWT.log("", t);
|
170 |
//// if(t instanceof RestException)
|
171 |
//// app.displayError("Unable to restore version:"+((RestException)t).getHttpStatusText());
|
172 |
//// else
|
173 |
//// app.displayError("System error restoring version:"+t.getMessage());
|
174 |
//// }
|
175 |
////
|
176 |
//// };
|
177 |
//// DeferredCommand.addCommand(ep);
|
178 |
// }
|
179 |
//
|
180 |
// private String formatDate(Date date){
|
181 |
// DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy : HH:mm");
|
182 |
// return format.format(date);
|
183 |
// }
|
184 |
//
|
185 |
// /**
|
186 |
// * Copies the input List to a new List
|
187 |
// * @param input
|
188 |
// */
|
189 |
// private void copyListAndContinue(List<FileResource> input){
|
190 |
// List<FileResource> copiedInput = new ArrayList<FileResource>();
|
191 |
// for(FileResource dto : input) {
|
192 |
// copiedInput.add(dto);
|
193 |
// }
|
194 |
// handleFullNames(copiedInput);
|
195 |
// }
|
196 |
//
|
197 |
// /**
|
198 |
// * Examines whether or not the user's full name exists in the
|
199 |
// * userFullNameMap in the Pithos.java for every element of the input list.
|
200 |
// * If the user's full name does not exist in the map then a request is being made
|
201 |
// * for the specific username.
|
202 |
// *
|
203 |
// * @param input
|
204 |
// */
|
205 |
// private void handleFullNames(List<FileResource> input){
|
206 |
// if(input.isEmpty()){
|
207 |
// showVersionsTable();
|
208 |
// return;
|
209 |
// }
|
210 |
//
|
211 |
// if(app.findUserFullName(input.get(0).getOwner()) == null){
|
212 |
// findFullNameAndUpdate(input);
|
213 |
// return;
|
214 |
// }
|
215 |
//
|
216 |
// if(input.size() >= 1){
|
217 |
// input.remove(input.get(0));
|
218 |
// if(input.isEmpty()){
|
219 |
// showVersionsTable();
|
220 |
// }else{
|
221 |
// handleFullNames(input);
|
222 |
// }
|
223 |
// }
|
224 |
// }
|
225 |
//
|
226 |
// /**
|
227 |
// * Makes a request to search for full name from a given username
|
228 |
// * and continues checking the next element of the List.
|
229 |
// *
|
230 |
// * @param input
|
231 |
// */
|
232 |
//
|
233 |
// private void findFullNameAndUpdate(final List<FileResource> input){
|
234 |
//// final String aUserName = input.get(0).getOwner();
|
235 |
//// String path = app.getApiPath() + "users/" + aUserName;
|
236 |
////
|
237 |
//// GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class, path, false,null) {
|
238 |
//// @Override
|
239 |
//// public void onComplete() {
|
240 |
//// final UserSearchResource result = getResult();
|
241 |
//// for (UserResource user : result.getUsers()){
|
242 |
//// String username = user.getUsername();
|
243 |
//// String userFullName = user.getName();
|
244 |
//// app.putUserToMap(username, userFullName);
|
245 |
//// if(input.size() >= 1){
|
246 |
//// input.remove(input.get(0));
|
247 |
//// if(input.isEmpty()){
|
248 |
//// showVersionsTable();
|
249 |
//// return;
|
250 |
//// }
|
251 |
//// handleFullNames(input);
|
252 |
//// }
|
253 |
//// }
|
254 |
//// }
|
255 |
//// @Override
|
256 |
//// public void onError(Throwable t) {
|
257 |
//// app.displayError("Unable to fetch user's full name from the given username " + aUserName);
|
258 |
//// if(input.size() >= 1){
|
259 |
//// input.remove(input.get(0));
|
260 |
//// handleFullNames(input);
|
261 |
//// }
|
262 |
//// }
|
263 |
//// };
|
264 |
//// DeferredCommand.addCommand(gg);
|
265 |
//
|
266 |
// }
|
267 |
//
|
268 |
} |