Fixed various compilation warnings
[pithos-web-client] / src / gr / grnet / pithos / web / client / VersionsList.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 package gr.grnet.pithos.web.client;
36
37 import com.google.gwt.user.client.ui.Composite;
38
39 public class VersionsList extends Composite {
40
41 //    private Pithos app;
42 //
43 //      int selectedRow = -1;
44 //
45 //      int permissionCount = -1;
46 //
47 //      List<FileResource> versions = null;
48 //
49 //      final Images images;
50 //
51 //      final VerticalPanel permPanel = new VerticalPanel();
52 //
53 //      final FlexTable permTable = new FlexTable();
54 //
55 //      FileResource toRemove = null;
56 //
57 //      FilePropertiesDialog container;
58 //
59 //      public VersionsList(Pithos _app, FilePropertiesDialog aContainer, final Images theImages, List<FileResource> theVersions) {
60 //        app = _app;
61 //              images = theImages;
62 //              container = aContainer;
63 //              versions = theVersions;
64 //              Collections.sort(theVersions, new Comparator<FileResource>(){
65 //
66 //                      @Override
67 //                      public int compare(FileResource o1, FileResource o2) {
68 //                              return o1.getVersion().compareTo(o2.getVersion());
69 //                      }
70 //
71 //              });
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);
91 //              updateTable();
92 //      }
93 //
94 //      public void updateTable() {
95 //              copyListAndContinue(versions);
96 //      }
97 //
98 //      public void showVersionsTable(){
99 //              int i = 1;
100 //              if (toRemove != null) {
101 //                      versions.remove(toRemove);
102 //                      toRemove = null;
103 //              }
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() {
107 //                              @Override
108 //                              public void onClick(ClickEvent event) {
109 //                                      restoreVersion(dto);
110 //                              }
111 //                      });
112 //
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() {
119 //                              @Override
120 //                              public void onClick(ClickEvent event) {
121 //                                      String fileUrl = dto.getUri() + "?version=" + dto.getVersion();
122 //                                      Window.open(fileUrl, "_BLANK", "");
123 //                              }
124 //                      });
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);
133 //                      i++;
134 //              }
135 //              for (; i < permTable.getRowCount(); i++)
136 //                      permTable.removeRow(i);
137 //      }
138 //
139 //      void restoreVersion(final FileResource version) {
140 ////            FileResource selectedFile = (FileResource) app.getCurrentSelection();
141 ////            PostCommand ep = new PostCommand(app, selectedFile.getUri()+"?restoreVersion="+version.getVersion(),"",200){
142 ////
143 ////
144 ////                    @Override
145 ////                    public void onComplete() {
146 ////                            container.hide();
147 ////                app.getTreeView().refreshCurrentNode(false);
148 ////                    }
149 ////
150 ////                    @Override
151 ////                    public void onError(Throwable t) {
152 ////                            GWT.log("", t);
153 ////                            if(t instanceof RestException)
154 ////                                    app.displayError("Unable to restore version:"+((RestException)t).getHttpStatusText());
155 ////                            else
156 ////                                    app.displayError("System error restoring version:"+t.getMessage());
157 ////                    }
158 ////
159 ////            };
160 ////            DeferredCommand.addCommand(ep);
161 //      }
162 //
163 //      private String formatDate(Date date){
164 //              DateTimeFormat format = DateTimeFormat.getFormat("dd/MM/yyyy : HH:mm");
165 //              return format.format(date);
166 //      }
167 //
168 //      /**
169 //       * Copies the input List to a new List
170 //       * @param input
171 //       */
172 //      private void copyListAndContinue(List<FileResource> input){
173 //              List<FileResource> copiedInput = new ArrayList<FileResource>();
174 //              for(FileResource dto : input) {
175 //                      copiedInput.add(dto);
176 //              }
177 //              handleFullNames(copiedInput);
178 //      }
179 //
180 //      /**
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.
185 //       *
186 //       * @param input
187 //       */
188 //      private void handleFullNames(List<FileResource> input){
189 //              if(input.isEmpty()){
190 //                      showVersionsTable();
191 //                      return;
192 //              }
193 //
194 //              if(app.findUserFullName(input.get(0).getOwner()) == null){
195 //                      findFullNameAndUpdate(input);
196 //                      return;
197 //              }
198 //
199 //              if(input.size() >= 1){
200 //                      input.remove(input.get(0));
201 //                      if(input.isEmpty()){
202 //                              showVersionsTable();
203 //                      }else{
204 //                              handleFullNames(input);
205 //                      }
206 //              }
207 //      }
208 //
209 //      /**
210 //       * Makes a request to search for full name from a given username
211 //       * and continues checking the next element of the List.
212 //       *
213 //       * @param input
214 //       */
215 //
216 //      private void findFullNameAndUpdate(final List<FileResource> input){
217 ////            final String aUserName = input.get(0).getOwner();
218 ////            String path = app.getApiPath() + "users/" + aUserName;
219 ////
220 ////            GetCommand<UserSearchResource> gg = new GetCommand<UserSearchResource>(app, UserSearchResource.class, path, false,null) {
221 ////                    @Override
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();
232 ////                                                    return;
233 ////                                            }
234 ////                                            handleFullNames(input);
235 ////                                    }
236 ////                            }
237 ////                    }
238 ////                    @Override
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);
244 ////                            }
245 ////                    }
246 ////            };
247 ////            DeferredCommand.addCommand(gg);
248 //
249 //      }
250 //
251 }