root / src / gr / ebs / gss / client / GSS.java @ 8e76db3e
History | View | Annotate | Download (24.8 kB)
1 | 14ad7326 | pastith | /*
|
---|---|---|---|
2 | 06b48563 | Natasa Kapravelou | * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.
|
3 | 06b48563 | Natasa Kapravelou | *
|
4 | 06b48563 | Natasa Kapravelou | * This file is part of GSS.
|
5 | 06b48563 | Natasa Kapravelou | *
|
6 | 06b48563 | Natasa Kapravelou | * GSS is free software: you can redistribute it and/or modify
|
7 | 06b48563 | Natasa Kapravelou | * it under the terms of the GNU General Public License as published by
|
8 | 06b48563 | Natasa Kapravelou | * the Free Software Foundation, either version 3 of the License, or
|
9 | 06b48563 | Natasa Kapravelou | * (at your option) any later version.
|
10 | 06b48563 | Natasa Kapravelou | *
|
11 | 06b48563 | Natasa Kapravelou | * GSS is distributed in the hope that it will be useful,
|
12 | 06b48563 | Natasa Kapravelou | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 06b48563 | Natasa Kapravelou | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 06b48563 | Natasa Kapravelou | * GNU General Public License for more details.
|
15 | 06b48563 | Natasa Kapravelou | *
|
16 | 06b48563 | Natasa Kapravelou | * You should have received a copy of the GNU General Public License
|
17 | 06b48563 | Natasa Kapravelou | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | 14ad7326 | pastith | */
|
19 | 14ad7326 | pastith | package gr.ebs.gss.client; |
20 | 14ad7326 | pastith | |
21 | 14ad7326 | pastith | import gr.ebs.gss.client.clipboard.Clipboard; |
22 | 4bf05cad | Natasa Kapravelou | import gr.ebs.gss.client.commands.GetUserCommand; |
23 | 14ad7326 | pastith | import gr.ebs.gss.client.dnd.DnDFocusPanel; |
24 | d8924393 | Giannis Koutsoubos | import gr.ebs.gss.client.dnd.DnDSimpleFocusPanel; |
25 | 895035a2 | pastith | import gr.ebs.gss.client.rest.GetCommand; |
26 | e08c358f | koutsoub | import gr.ebs.gss.client.rest.RestException; |
27 | c018c4de | pastith | import gr.ebs.gss.client.rest.resource.FileResource; |
28 | c018c4de | pastith | import gr.ebs.gss.client.rest.resource.FolderResource; |
29 | c018c4de | pastith | import gr.ebs.gss.client.rest.resource.TrashResource; |
30 | a52ea5e4 | pastith | import gr.ebs.gss.client.rest.resource.UserResource; |
31 | 14ad7326 | pastith | |
32 | df9802b9 | Natasa Kapravelou | import java.util.Arrays; |
33 | 1510f141 | Giannis Koutsoubos | import java.util.Date; |
34 | 9ab5db6d | Natasa Kapravelou | import java.util.HashMap; |
35 | 14ad7326 | pastith | import java.util.Iterator; |
36 | c018c4de | pastith | import java.util.List; |
37 | 14ad7326 | pastith | |
38 | 14ad7326 | pastith | import com.allen_sauer.gwt.dnd.client.DragContext; |
39 | 14ad7326 | pastith | import com.allen_sauer.gwt.dnd.client.PickupDragController; |
40 | 14ad7326 | pastith | import com.allen_sauer.gwt.dnd.client.VetoDragException; |
41 | 14ad7326 | pastith | import com.google.gwt.core.client.EntryPoint; |
42 | 14ad7326 | pastith | import com.google.gwt.core.client.GWT; |
43 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.logical.shared.ResizeEvent; |
44 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.logical.shared.ResizeHandler; |
45 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.logical.shared.SelectionEvent; |
46 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.event.logical.shared.SelectionHandler; |
47 | 0174fdb2 | Natasa Kapravelou | import com.google.gwt.event.logical.shared.ValueChangeEvent; |
48 | 0174fdb2 | Natasa Kapravelou | import com.google.gwt.event.logical.shared.ValueChangeHandler; |
49 | 1510f141 | Giannis Koutsoubos | import com.google.gwt.i18n.client.DateTimeFormat; |
50 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.resources.client.ClientBundle; |
51 | afd3a0ef | Giannis Koutsoubos | import com.google.gwt.resources.client.ImageResource; |
52 | 14ad7326 | pastith | import com.google.gwt.user.client.Command; |
53 | 14ad7326 | pastith | import com.google.gwt.user.client.Cookies; |
54 | 14ad7326 | pastith | import com.google.gwt.user.client.DOM; |
55 | 14ad7326 | pastith | import com.google.gwt.user.client.DeferredCommand; |
56 | 8c999b8c | Natasa Kapravelou | import com.google.gwt.user.client.History; |
57 | 14ad7326 | pastith | import com.google.gwt.user.client.Window; |
58 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.AbsolutePanel; |
59 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.AbstractImagePrototype; |
60 | 5c6b2883 | Panagiotis Astithas | import com.google.gwt.user.client.ui.DecoratedTabPanel; |
61 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.DockPanel; |
62 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HTML; |
63 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
64 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HasVerticalAlignment; |
65 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.HorizontalSplitPanel; |
66 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Label; |
67 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.RootPanel; |
68 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.TabPanel; |
69 | c018c4de | pastith | import com.google.gwt.user.client.ui.TreeItem; |
70 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.VerticalPanel; |
71 | 14ad7326 | pastith | import com.google.gwt.user.client.ui.Widget; |
72 | 14ad7326 | pastith | |
73 | 14ad7326 | pastith | /**
|
74 | 14ad7326 | pastith | * Entry point classes define <code>onModuleLoad()</code>.
|
75 | 14ad7326 | pastith | */
|
76 | afd3a0ef | Giannis Koutsoubos | public class GSS implements EntryPoint, ResizeHandler { |
77 | 9ac50c9e | pastith | |
78 | 14ad7326 | pastith | /**
|
79 | 14ad7326 | pastith | * A constant that denotes the completion of an IncrementalCommand.
|
80 | 14ad7326 | pastith | */
|
81 | 14ad7326 | pastith | public static final boolean DONE = false; |
82 | 14ad7326 | pastith | |
83 | 1152ac2c | Panagiotis Astithas | public static final int VISIBLE_FILE_COUNT = 100; |
84 | a52ea5e4 | pastith | |
85 | 14ad7326 | pastith | /**
|
86 | 14ad7326 | pastith | * Instantiate an application-level image bundle. This object will provide
|
87 | 14ad7326 | pastith | * programmatic access to all the images needed by widgets.
|
88 | 14ad7326 | pastith | */
|
89 | 14ad7326 | pastith | private static Images images = (Images) GWT.create(Images.class); |
90 | 8c999b8c | Natasa Kapravelou | |
91 | 9ac50c9e | pastith | private GlassPanel glassPanel = new GlassPanel(); |
92 | 14ad7326 | pastith | |
93 | 14ad7326 | pastith | /**
|
94 | 14ad7326 | pastith | * An aggregate image bundle that pulls together all the images for this
|
95 | 14ad7326 | pastith | * application into a single bundle.
|
96 | 14ad7326 | pastith | */
|
97 | b2b07869 | koutsoub | public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FileMenu.Images, EditMenu.Images, SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images, SearchResults.Images, Search.Images, Groups.Images, Folders.Images, CellTreeView.Images { |
98 | 14ad7326 | pastith | |
99 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/document.png") |
100 | afd3a0ef | Giannis Koutsoubos | ImageResource folders(); |
101 | 14ad7326 | pastith | |
102 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/edit_group_22.png") |
103 | afd3a0ef | Giannis Koutsoubos | ImageResource groups(); |
104 | 14ad7326 | pastith | |
105 | afd3a0ef | Giannis Koutsoubos | @Source("gr/ebs/gss/resources/search.png") |
106 | afd3a0ef | Giannis Koutsoubos | ImageResource search(); |
107 | 14ad7326 | pastith | } |
108 | 14ad7326 | pastith | |
109 | 14ad7326 | pastith | /**
|
110 | 14ad7326 | pastith | * The single GSS instance.
|
111 | 14ad7326 | pastith | */
|
112 | 14ad7326 | pastith | private static GSS singleton; |
113 | 14ad7326 | pastith | |
114 | 14ad7326 | pastith | /**
|
115 | 14ad7326 | pastith | * Gets the singleton GSS instance.
|
116 | 14ad7326 | pastith | *
|
117 | 14ad7326 | pastith | * @return the GSS object
|
118 | 14ad7326 | pastith | */
|
119 | 14ad7326 | pastith | public static GSS get() { |
120 | 14ad7326 | pastith | if (GSS.singleton == null) |
121 | 14ad7326 | pastith | GSS.singleton = new GSS();
|
122 | 14ad7326 | pastith | return GSS.singleton;
|
123 | 14ad7326 | pastith | } |
124 | 14ad7326 | pastith | |
125 | 14ad7326 | pastith | /**
|
126 | 14ad7326 | pastith | * The Application Clipboard implementation;
|
127 | 14ad7326 | pastith | */
|
128 | 14ad7326 | pastith | private Clipboard clipboard = new Clipboard(); |
129 | 14ad7326 | pastith | |
130 | a52ea5e4 | pastith | private UserResource currentUserResource;
|
131 | a52ea5e4 | pastith | |
132 | 14ad7326 | pastith | /**
|
133 | 14ad7326 | pastith | * The top panel that contains the menu bar.
|
134 | 14ad7326 | pastith | */
|
135 | 14ad7326 | pastith | private TopPanel topPanel;
|
136 | 14ad7326 | pastith | |
137 | 14ad7326 | pastith | /**
|
138 | 14ad7326 | pastith | * The panel that contains the various system messages.
|
139 | 14ad7326 | pastith | */
|
140 | 14ad7326 | pastith | private MessagePanel messagePanel = new MessagePanel(GSS.images); |
141 | 14ad7326 | pastith | |
142 | 14ad7326 | pastith | /**
|
143 | 14ad7326 | pastith | * The bottom panel that contains the status bar.
|
144 | 14ad7326 | pastith | */
|
145 | 14ad7326 | pastith | private StatusPanel statusPanel = new StatusPanel(GSS.images); |
146 | 14ad7326 | pastith | |
147 | 14ad7326 | pastith | /**
|
148 | a44876bf | fstamatelopoulos | * The top right panel that displays the logged in user details
|
149 | a44876bf | fstamatelopoulos | */
|
150 | a44876bf | fstamatelopoulos | private UserDetailsPanel userDetailsPanel = new UserDetailsPanel(); |
151 | a44876bf | fstamatelopoulos | |
152 | a44876bf | fstamatelopoulos | /**
|
153 | 14ad7326 | pastith | * The file list widget.
|
154 | 14ad7326 | pastith | */
|
155 | 14ad7326 | pastith | private FileList fileList;
|
156 | 14ad7326 | pastith | |
157 | 14ad7326 | pastith | /**
|
158 | 14ad7326 | pastith | * The group list widget.
|
159 | 14ad7326 | pastith | */
|
160 | 8c999b8c | Natasa Kapravelou | private Groups groups = new Groups(images); |
161 | 14ad7326 | pastith | |
162 | 14ad7326 | pastith | /**
|
163 | 14ad7326 | pastith | * The search result widget.
|
164 | 14ad7326 | pastith | */
|
165 | 14ad7326 | pastith | private SearchResults searchResults;
|
166 | 14ad7326 | pastith | |
167 | 14ad7326 | pastith | /**
|
168 | 14ad7326 | pastith | * The tab panel that occupies the right side of the screen.
|
169 | 14ad7326 | pastith | */
|
170 | 5c6b2883 | Panagiotis Astithas | private TabPanel inner = new DecoratedTabPanel(); |
171 | 14ad7326 | pastith | |
172 | 14ad7326 | pastith | /**
|
173 | 14ad7326 | pastith | * The split panel that will contain the left and right panels.
|
174 | 14ad7326 | pastith | */
|
175 | 14ad7326 | pastith | private HorizontalSplitPanel splitPanel = new HorizontalSplitPanel(); |
176 | 14ad7326 | pastith | |
177 | 14ad7326 | pastith | /**
|
178 | 14ad7326 | pastith | * The horizontal panel that will contain the search and status panels.
|
179 | 14ad7326 | pastith | */
|
180 | 14ad7326 | pastith | private DockPanel searchStatus = new DockPanel(); |
181 | 14ad7326 | pastith | |
182 | 14ad7326 | pastith | /**
|
183 | 14ad7326 | pastith | * The search widget.
|
184 | 14ad7326 | pastith | */
|
185 | 14ad7326 | pastith | private Search search;
|
186 | 14ad7326 | pastith | |
187 | 14ad7326 | pastith | /**
|
188 | 14ad7326 | pastith | * The widget that displays the tree of folders.
|
189 | 14ad7326 | pastith | */
|
190 | 14ad7326 | pastith | private Folders folders = new Folders(images); |
191 | 14ad7326 | pastith | |
192 | 14ad7326 | pastith | /**
|
193 | 14ad7326 | pastith | * The currently selected item in the application, for use by the Edit menu
|
194 | 14ad7326 | pastith | * commands. Potential types are Folder, File, User and Group.
|
195 | 14ad7326 | pastith | */
|
196 | 14ad7326 | pastith | private Object currentSelection; |
197 | 14ad7326 | pastith | |
198 | 14ad7326 | pastith | /**
|
199 | 14ad7326 | pastith | * The authentication token of the current user.
|
200 | 14ad7326 | pastith | */
|
201 | 14ad7326 | pastith | private String token; |
202 | 14ad7326 | pastith | |
203 | 3ef7b691 | Dimitris Routsis | /**
|
204 | 3ef7b691 | Dimitris Routsis | * The WebDAV password of the current user
|
205 | 3ef7b691 | Dimitris Routsis | */
|
206 | 3ef7b691 | Dimitris Routsis | private String webDAVPassword; |
207 | 3ef7b691 | Dimitris Routsis | |
208 | a52ea5e4 | pastith | private PickupDragController dragController;
|
209 | 14ad7326 | pastith | |
210 | 9ab5db6d | Natasa Kapravelou | public HashMap<String, String> userFullNameMap = new HashMap<String, String>(); |
211 | 9ab5db6d | Natasa Kapravelou | |
212 | 037fabb5 | Natasa Kapravelou | @Override
|
213 | 14ad7326 | pastith | public void onModuleLoad() { |
214 | 14ad7326 | pastith | // Initialize the singleton before calling the constructors of the
|
215 | 14ad7326 | pastith | // various widgets that might call GSS.get().
|
216 | 14ad7326 | pastith | singleton = this;
|
217 | 14ad7326 | pastith | RootPanel.get().add(glassPanel, 0, 0); |
218 | 14ad7326 | pastith | parseUserCredentials(); |
219 | 14ad7326 | pastith | dragController = new PickupDragController(RootPanel.get(), false) { |
220 | 14ad7326 | pastith | |
221 | 14ad7326 | pastith | @Override
|
222 | 14ad7326 | pastith | public void previewDragStart() throws VetoDragException { |
223 | 4be3ad42 | koutsoub | super.previewDragStart();
|
224 | 4be3ad42 | koutsoub | if (context.selectedWidgets.isEmpty())
|
225 | 14ad7326 | pastith | throw new VetoDragException(); |
226 | 14ad7326 | pastith | |
227 | 4be3ad42 | koutsoub | if(context.draggable != null) |
228 | 4be3ad42 | koutsoub | if(context.draggable instanceof DnDFocusPanel){ |
229 | d8924393 | Giannis Koutsoubos | DnDFocusPanel toDrop = (DnDFocusPanel) context.draggable; |
230 | 8c999b8c | Natasa Kapravelou | // prevent drag and drop for trashed files and for
|
231 | 8c999b8c | Natasa Kapravelou | // unselected tree items
|
232 | 4be3ad42 | koutsoub | if(toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent())) |
233 | d8924393 | Giannis Koutsoubos | throw new VetoDragException(); |
234 | 4be3ad42 | koutsoub | else if(toDrop.getItem() != null && !toDrop.getItem().equals(folders.getCurrent())) |
235 | d8924393 | Giannis Koutsoubos | throw new VetoDragException(); |
236 | 4be3ad42 | koutsoub | else if(toDrop.getItem() != null && !toDrop.getItem().isDraggable()) |
237 | d8924393 | Giannis Koutsoubos | throw new VetoDragException(); |
238 | d8924393 | Giannis Koutsoubos | |
239 | 8c999b8c | Natasa Kapravelou | } else if (context.draggable instanceof DnDSimpleFocusPanel) { |
240 | 4be3ad42 | koutsoub | DnDSimpleFocusPanel toDrop = (DnDSimpleFocusPanel) context.draggable; |
241 | 8c999b8c | Natasa Kapravelou | // prevent drag and drop for trashed files and for
|
242 | 8c999b8c | Natasa Kapravelou | // unselected tree items
|
243 | 4be3ad42 | koutsoub | if(toDrop.getFiles() != null && folders.isTrashItem(folders.getCurrent())) |
244 | d8924393 | Giannis Koutsoubos | throw new VetoDragException(); |
245 | 4be3ad42 | koutsoub | } |
246 | 4be3ad42 | koutsoub | } |
247 | 14ad7326 | pastith | |
248 | 14ad7326 | pastith | @Override
|
249 | 9ac50c9e | pastith | protected Widget newDragProxy(DragContext aContext) {
|
250 | 14ad7326 | pastith | AbsolutePanel container = new AbsolutePanel();
|
251 | 4be3ad42 | koutsoub | HTML html = null; |
252 | 14ad7326 | pastith | DOM.setStyleAttribute(container.getElement(), "overflow", "visible"); |
253 | 4be3ad42 | koutsoub | if(aContext.draggable!=null && aContext.draggable.getParent()!= null && aContext.draggable.getParent() instanceof FileTable){ |
254 | 4be3ad42 | koutsoub | if(getFileList().getSelectedFiles().size()>1){ |
255 | 4be3ad42 | koutsoub | html=new HTML(getFileList().getSelectedFiles().size()+ " files"); |
256 | 4be3ad42 | koutsoub | container.add(html); |
257 | 4be3ad42 | koutsoub | return container;
|
258 | 4be3ad42 | koutsoub | } |
259 | 4be3ad42 | koutsoub | FileTable proxy; |
260 | 4be3ad42 | koutsoub | proxy = new FileTable(1,8); |
261 | 4be3ad42 | koutsoub | proxy.addStyleName("gss-List");
|
262 | 4be3ad42 | koutsoub | FileTable draggableTable = (FileTable) context.draggable.getParent(); |
263 | 4be3ad42 | koutsoub | int dragRow = FileTable.getWidgetRow(context.draggable, draggableTable);
|
264 | 4be3ad42 | koutsoub | FileTable.copyRow(draggableTable, proxy, dragRow, 0);
|
265 | 4be3ad42 | koutsoub | return proxy;
|
266 | 4be3ad42 | koutsoub | |
267 | 4be3ad42 | koutsoub | } |
268 | 9ac50c9e | pastith | for (Iterator iterator = aContext.selectedWidgets.iterator(); iterator.hasNext();) { |
269 | 14ad7326 | pastith | Widget widget = (Widget) iterator.next(); |
270 | 8c999b8c | Natasa Kapravelou | if (widget instanceof DnDFocusPanel) { |
271 | d8924393 | Giannis Koutsoubos | DnDFocusPanel book = (DnDFocusPanel) widget; |
272 | 4be3ad42 | koutsoub | html = book.cloneHTML(); |
273 | 8c999b8c | Natasa Kapravelou | } else if (widget instanceof DnDSimpleFocusPanel) { |
274 | d8924393 | Giannis Koutsoubos | DnDSimpleFocusPanel book = (DnDSimpleFocusPanel) widget; |
275 | 4be3ad42 | koutsoub | html = book.cloneHTML(); |
276 | d8924393 | Giannis Koutsoubos | } |
277 | 4be3ad42 | koutsoub | if(html == null) |
278 | 14ad7326 | pastith | container.add(new Label("Drag ME")); |
279 | 14ad7326 | pastith | else
|
280 | 14ad7326 | pastith | container.add(html); |
281 | 4be3ad42 | koutsoub | return container;
|
282 | 14ad7326 | pastith | } |
283 | 14ad7326 | pastith | return container;
|
284 | 14ad7326 | pastith | } |
285 | 14ad7326 | pastith | }; |
286 | 14ad7326 | pastith | dragController.setBehaviorDragProxy(true);
|
287 | 14ad7326 | pastith | dragController.setBehaviorMultipleSelection(false);
|
288 | 14ad7326 | pastith | topPanel = new TopPanel(GSS.images);
|
289 | 14ad7326 | pastith | topPanel.setWidth("100%");
|
290 | 14ad7326 | pastith | |
291 | 14ad7326 | pastith | messagePanel.setWidth("100%");
|
292 | 14ad7326 | pastith | messagePanel.setVisible(false);
|
293 | 14ad7326 | pastith | |
294 | 14ad7326 | pastith | search = new Search(images);
|
295 | 14ad7326 | pastith | searchStatus.add(search, DockPanel.WEST); |
296 | a44876bf | fstamatelopoulos | searchStatus.add(userDetailsPanel, DockPanel.EAST); |
297 | a44876bf | fstamatelopoulos | searchStatus.setCellHorizontalAlignment(userDetailsPanel, HasHorizontalAlignment.ALIGN_RIGHT); |
298 | 14ad7326 | pastith | searchStatus.setCellVerticalAlignment(search, HasVerticalAlignment.ALIGN_MIDDLE); |
299 | a44876bf | fstamatelopoulos | searchStatus.setCellVerticalAlignment(userDetailsPanel, HasVerticalAlignment.ALIGN_MIDDLE); |
300 | 14ad7326 | pastith | searchStatus.setWidth("100%");
|
301 | 14ad7326 | pastith | |
302 | 14ad7326 | pastith | fileList = new FileList(images);
|
303 | 14ad7326 | pastith | |
304 | 14ad7326 | pastith | searchResults = new SearchResults(images);
|
305 | 14ad7326 | pastith | |
306 | 14ad7326 | pastith | // Inner contains the various lists.
|
307 | 5c6b2883 | Panagiotis Astithas | inner.setAnimationEnabled(true);
|
308 | 5c6b2883 | Panagiotis Astithas | inner.getTabBar().addStyleName("gss-MainTabBar");
|
309 | 5c6b2883 | Panagiotis Astithas | inner.getDeckPanel().addStyleName("gss-MainTabPanelBottom");
|
310 | afd3a0ef | Giannis Koutsoubos | inner.add(fileList, createHeaderHTML(AbstractImagePrototype.create(images.folders()), "Files"), true); |
311 | 14ad7326 | pastith | |
312 | afd3a0ef | Giannis Koutsoubos | inner.add(groups, createHeaderHTML(AbstractImagePrototype.create(images.groups()), "Groups"), true); |
313 | afd3a0ef | Giannis Koutsoubos | inner.add(searchResults, createHeaderHTML(AbstractImagePrototype.create(images.search()), "Search Results"), true); |
314 | b2b07869 | koutsoub | inner.add(new CellTreeView(images), createHeaderHTML(AbstractImagePrototype.create(images.search()), "Cell tree sample"), true); |
315 | 14ad7326 | pastith | inner.setWidth("100%");
|
316 | 14ad7326 | pastith | inner.selectTab(0);
|
317 | 14ad7326 | pastith | |
318 | afd3a0ef | Giannis Koutsoubos | inner.addSelectionHandler(new SelectionHandler<Integer>() { |
319 | afd3a0ef | Giannis Koutsoubos | |
320 | afd3a0ef | Giannis Koutsoubos | @Override
|
321 | afd3a0ef | Giannis Koutsoubos | public void onSelection(SelectionEvent<Integer> event) { |
322 | 8c999b8c | Natasa Kapravelou | int tabIndex = event.getSelectedItem();
|
323 | 98b59163 | Natasa Kapravelou | // TreeItem treeItem = GSS.get().getFolders().getCurrent();
|
324 | afd3a0ef | Giannis Koutsoubos | switch (tabIndex) {
|
325 | 8c999b8c | Natasa Kapravelou | case 0: |
326 | 8c550474 | Natasa Kapravelou | // Files tab selected
|
327 | 8c999b8c | Natasa Kapravelou | fileList.clearSelectedRows(); |
328 | 8c999b8c | Natasa Kapravelou | fileList.updateCurrentlyShowingStats(); |
329 | 8c999b8c | Natasa Kapravelou | break;
|
330 | 8c999b8c | Natasa Kapravelou | case 1: |
331 | 8c550474 | Natasa Kapravelou | // Groups tab selected
|
332 | 8c999b8c | Natasa Kapravelou | groups.updateCurrentlyShowingStats(); |
333 | 98b59163 | Natasa Kapravelou | updateHistory("Groups");
|
334 | 8c999b8c | Natasa Kapravelou | break;
|
335 | 8c999b8c | Natasa Kapravelou | case 2: |
336 | 8c550474 | Natasa Kapravelou | // Search tab selected
|
337 | 8c999b8c | Natasa Kapravelou | searchResults.clearSelectedRows(); |
338 | 8c999b8c | Natasa Kapravelou | searchResults.updateCurrentlyShowingStats(); |
339 | 98b59163 | Natasa Kapravelou | updateHistory("Search");
|
340 | 8c999b8c | Natasa Kapravelou | break;
|
341 | 8c999b8c | Natasa Kapravelou | } |
342 | b3c6d52e | fstamatelopoulos | } |
343 | b3c6d52e | fstamatelopoulos | }); |
344 | 8c550474 | Natasa Kapravelou | // If the application starts with no history token, redirect to a new "Files" state
|
345 | 0174fdb2 | Natasa Kapravelou | String initToken = History.getToken();
|
346 | 0174fdb2 | Natasa Kapravelou | if(initToken.length() == 0) |
347 | 0174fdb2 | Natasa Kapravelou | History.newItem("Files");
|
348 | 8c550474 | Natasa Kapravelou | // Add history listener to handle any history events
|
349 | 037fabb5 | Natasa Kapravelou | History.addValueChangeHandler(new ValueChangeHandler<String>() { |
350 | 037fabb5 | Natasa Kapravelou | @Override
|
351 | 037fabb5 | Natasa Kapravelou | public void onValueChange(ValueChangeEvent<String> event) { |
352 | 037fabb5 | Natasa Kapravelou | String tokenInput = event.getValue();
|
353 | 037fabb5 | Natasa Kapravelou | String historyToken = handleSpecialFolderNames(tokenInput);
|
354 | 037fabb5 | Natasa Kapravelou | try {
|
355 | 037fabb5 | Natasa Kapravelou | if(historyToken.equals("Search")) |
356 | 037fabb5 | Natasa Kapravelou | inner.selectTab(2);
|
357 | 037fabb5 | Natasa Kapravelou | else if(historyToken.equals("Groups")) |
358 | 037fabb5 | Natasa Kapravelou | inner.selectTab(1);
|
359 | 037fabb5 | Natasa Kapravelou | else if(historyToken.equals("Files")|| historyToken.length()==0) |
360 | 037fabb5 | Natasa Kapravelou | inner.selectTab(0);
|
361 | 037fabb5 | Natasa Kapravelou | else {
|
362 | 037fabb5 | Natasa Kapravelou | PopupTree popupTree = GSS.get().getFolders().getPopupTree(); |
363 | 037fabb5 | Natasa Kapravelou | TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); |
364 | 037fabb5 | Natasa Kapravelou | SelectionEvent.fire(popupTree, treeObj); |
365 | 037fabb5 | Natasa Kapravelou | } |
366 | 44873f3d | Christos V. Stathis | } catch (IndexOutOfBoundsException e) { |
367 | 44873f3d | Christos V. Stathis | inner.selectTab(0);
|
368 | 44873f3d | Christos V. Stathis | } |
369 | 44873f3d | Christos V. Stathis | } |
370 | 44873f3d | Christos V. Stathis | }); |
371 | b3c6d52e | fstamatelopoulos | |
372 | 14ad7326 | pastith | // Add the left and right panels to the split panel.
|
373 | 14ad7326 | pastith | splitPanel.setLeftWidget(folders); |
374 | 14ad7326 | pastith | splitPanel.setRightWidget(inner); |
375 | a44876bf | fstamatelopoulos | splitPanel.setSplitPosition("25%");
|
376 | a52ea5e4 | pastith | splitPanel.setSize("100%", "100%"); |
377 | 5c6b2883 | Panagiotis Astithas | splitPanel.addStyleName("gss-splitPanel");
|
378 | 14ad7326 | pastith | |
379 | 14ad7326 | pastith | // Create a dock panel that will contain the menu bar at the top,
|
380 | 14ad7326 | pastith | // the shortcuts to the left, the status bar at the bottom and the
|
381 | 14ad7326 | pastith | // right panel taking the rest.
|
382 | 14ad7326 | pastith | VerticalPanel outer = new VerticalPanel();
|
383 | 14ad7326 | pastith | outer.add(topPanel); |
384 | 14ad7326 | pastith | outer.add(searchStatus); |
385 | 14ad7326 | pastith | outer.add(messagePanel); |
386 | 14ad7326 | pastith | outer.add(splitPanel); |
387 | a44876bf | fstamatelopoulos | outer.add(statusPanel); |
388 | 14ad7326 | pastith | outer.setWidth("100%");
|
389 | 14ad7326 | pastith | outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); |
390 | 14ad7326 | pastith | |
391 | 14ad7326 | pastith | outer.setSpacing(4);
|
392 | 14ad7326 | pastith | |
393 | 14ad7326 | pastith | // Hook the window resize event, so that we can adjust the UI.
|
394 | afd3a0ef | Giannis Koutsoubos | Window.addResizeHandler(this); |
395 | 14ad7326 | pastith | // Clear out the window's built-in margin, because we want to take
|
396 | 14ad7326 | pastith | // advantage of the entire client area.
|
397 | 14ad7326 | pastith | Window.setMargin("0px"); |
398 | 14ad7326 | pastith | // Finally, add the outer panel to the RootPanel, so that it will be
|
399 | 14ad7326 | pastith | // displayed.
|
400 | 14ad7326 | pastith | RootPanel.get().add(outer); |
401 | 14ad7326 | pastith | // Call the window resized handler to get the initial sizes setup. Doing
|
402 | 14ad7326 | pastith | // this in a deferred command causes it to occur after all widgets'
|
403 | 9ac50c9e | pastith | // sizes have been computed by the browser.
|
404 | 14ad7326 | pastith | DeferredCommand.addCommand(new Command() {
|
405 | 8c999b8c | Natasa Kapravelou | |
406 | 037fabb5 | Natasa Kapravelou | @Override
|
407 | 14ad7326 | pastith | public void execute() { |
408 | be05fc7b | Panagiotis Astithas | onWindowResized(Window.getClientHeight());
|
409 | 14ad7326 | pastith | } |
410 | 14ad7326 | pastith | }); |
411 | 14ad7326 | pastith | } |
412 | 14ad7326 | pastith | |
413 | 14ad7326 | pastith | /**
|
414 | 14ad7326 | pastith | * Fetches the User object for the specified username.
|
415 | 14ad7326 | pastith | *
|
416 | 14ad7326 | pastith | * @param username the username of the user
|
417 | 14ad7326 | pastith | */
|
418 | 14ad7326 | pastith | private void fetchUser(final String username) { |
419 | bbad17b4 | pastith | String path = getApiPath() + username + "/"; |
420 | 8c999b8c | Natasa Kapravelou | GetCommand<UserResource> getUserCommand = new GetCommand<UserResource>(UserResource.class, username, path, null) { |
421 | 14ad7326 | pastith | |
422 | 9ac50c9e | pastith | @Override
|
423 | a52ea5e4 | pastith | public void onComplete() { |
424 | a52ea5e4 | pastith | currentUserResource = getResult(); |
425 | 50135fa5 | pastith | final String announcement = currentUserResource.getAnnouncement(); |
426 | 50135fa5 | pastith | if (announcement != null) |
427 | 50135fa5 | pastith | DeferredCommand.addCommand(new Command() {
|
428 | 8c999b8c | Natasa Kapravelou | |
429 | 037fabb5 | Natasa Kapravelou | @Override
|
430 | 50135fa5 | pastith | public void execute() { |
431 | 50135fa5 | pastith | displayInformation(announcement); |
432 | 50135fa5 | pastith | } |
433 | 50135fa5 | pastith | }); |
434 | 14ad7326 | pastith | } |
435 | a52ea5e4 | pastith | |
436 | 9ac50c9e | pastith | @Override
|
437 | a52ea5e4 | pastith | public void onError(Throwable t) { |
438 | a52ea5e4 | pastith | GWT.log("Fetching user error", t);
|
439 | 8c999b8c | Natasa Kapravelou | if (t instanceof RestException) |
440 | 8c999b8c | Natasa Kapravelou | GSS.get().displayError("No user found:" + ((RestException) t).getHttpStatusText());
|
441 | a52ea5e4 | pastith | else
|
442 | 8c999b8c | Natasa Kapravelou | GSS.get().displayError("System error fetching user data:" + t.getMessage());
|
443 | 6e6e914e | Panagiotis Astithas | authenticateUser(); |
444 | a52ea5e4 | pastith | } |
445 | a52ea5e4 | pastith | }; |
446 | a52ea5e4 | pastith | DeferredCommand.addCommand(getUserCommand); |
447 | 14ad7326 | pastith | } |
448 | 14ad7326 | pastith | |
449 | 14ad7326 | pastith | /**
|
450 | 14ad7326 | pastith | * Parse and store the user credentials to the appropriate fields.
|
451 | 14ad7326 | pastith | */
|
452 | 14ad7326 | pastith | private void parseUserCredentials() { |
453 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
454 | bbad17b4 | pastith | String cookie = conf.authCookie();
|
455 | bbad17b4 | pastith | String auth = Cookies.getCookie(cookie);
|
456 | 14ad7326 | pastith | if (auth == null) { |
457 | 14ad7326 | pastith | authenticateUser(); |
458 | 14ad7326 | pastith | // Redundant, but silences warnings about possible auth NPE, below.
|
459 | 14ad7326 | pastith | return;
|
460 | 14ad7326 | pastith | } |
461 | bbad17b4 | pastith | int sepIndex = auth.indexOf(conf.cookieSeparator());
|
462 | 14ad7326 | pastith | if (sepIndex == -1) |
463 | 14ad7326 | pastith | authenticateUser(); |
464 | 30e14a2f | Panagiotis Astithas | token = auth.substring(sepIndex + 1);
|
465 | 14ad7326 | pastith | final String username = auth.substring(0, sepIndex); |
466 | 14ad7326 | pastith | if (username == null) |
467 | 14ad7326 | pastith | authenticateUser(); |
468 | 3ef7b691 | Dimitris Routsis | |
469 | 3ef7b691 | Dimitris Routsis | refreshWebDAVPassword(); |
470 | 3ef7b691 | Dimitris Routsis | |
471 | 14ad7326 | pastith | DeferredCommand.addCommand(new Command() {
|
472 | 8c999b8c | Natasa Kapravelou | |
473 | 037fabb5 | Natasa Kapravelou | @Override
|
474 | 14ad7326 | pastith | public void execute() { |
475 | 14ad7326 | pastith | fetchUser(username); |
476 | 14ad7326 | pastith | } |
477 | 14ad7326 | pastith | }); |
478 | 14ad7326 | pastith | } |
479 | 14ad7326 | pastith | |
480 | 14ad7326 | pastith | /**
|
481 | 14ad7326 | pastith | * Redirect the user to the login page for authentication.
|
482 | 14ad7326 | pastith | */
|
483 | 05f65955 | koutsoub | protected void authenticateUser() { |
484 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
485 | bbad17b4 | pastith | Window.Location.assign(conf.loginUrl() + "?next=" + GWT.getModuleBaseURL()); |
486 | 14ad7326 | pastith | } |
487 | 14ad7326 | pastith | |
488 | 14ad7326 | pastith | /**
|
489 | 312631e1 | Panagiotis Astithas | * Clear the cookie and redirect the user to the logout page.
|
490 | 14ad7326 | pastith | */
|
491 | 14ad7326 | pastith | void logout() {
|
492 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
493 | 312631e1 | Panagiotis Astithas | String cookie = conf.authCookie();
|
494 | 312631e1 | Panagiotis Astithas | String domain = Window.Location.getHostName(); |
495 | 312631e1 | Panagiotis Astithas | String path = Window.Location.getPath(); |
496 | 312631e1 | Panagiotis Astithas | Cookies.setCookie(cookie, "", null, domain, path, false); |
497 | bbad17b4 | pastith | Window.Location.assign(conf.logoutUrl());
|
498 | 14ad7326 | pastith | } |
499 | 14ad7326 | pastith | |
500 | 14ad7326 | pastith | /**
|
501 | 14ad7326 | pastith | * Creates an HTML fragment that places an image & caption together, for use
|
502 | 14ad7326 | pastith | * in a group header.
|
503 | 14ad7326 | pastith | *
|
504 | 14ad7326 | pastith | * @param imageProto an image prototype for an image
|
505 | 14ad7326 | pastith | * @param caption the group caption
|
506 | 14ad7326 | pastith | * @return the header HTML fragment
|
507 | 14ad7326 | pastith | */
|
508 | 14ad7326 | pastith | private String createHeaderHTML(AbstractImagePrototype imageProto, String caption) { |
509 | 8c999b8c | Natasa Kapravelou | String captionHTML = "<table class='caption' cellpadding='0' " + "cellspacing='0'>" + "<tr><td class='lcaption'>" + imageProto.getHTML() + "</td><td class='rcaption'><b style='white-space:nowrap'> " + caption + "</b></td></tr></table>"; |
510 | 14ad7326 | pastith | return captionHTML;
|
511 | 14ad7326 | pastith | } |
512 | 14ad7326 | pastith | |
513 | 6e6e914e | Panagiotis Astithas | private void onWindowResized(int height) { |
514 | 14ad7326 | pastith | // Adjust the split panel to take up the available room in the window.
|
515 | 9ac50c9e | pastith | int newHeight = height - splitPanel.getAbsoluteTop() - 44; |
516 | 14ad7326 | pastith | if (newHeight < 1) |
517 | 14ad7326 | pastith | newHeight = 1;
|
518 | 14ad7326 | pastith | splitPanel.setHeight("" + newHeight);
|
519 | 14ad7326 | pastith | } |
520 | 14ad7326 | pastith | |
521 | afd3a0ef | Giannis Koutsoubos | @Override
|
522 | afd3a0ef | Giannis Koutsoubos | public void onResize(ResizeEvent event) { |
523 | be05fc7b | Panagiotis Astithas | int height = event.getHeight();
|
524 | be05fc7b | Panagiotis Astithas | onWindowResized(height); |
525 | afd3a0ef | Giannis Koutsoubos | } |
526 | afd3a0ef | Giannis Koutsoubos | |
527 | 8c999b8c | Natasa Kapravelou | public boolean isFileListShowing() { |
528 | 14ad7326 | pastith | int tab = inner.getTabBar().getSelectedTab();
|
529 | 8c999b8c | Natasa Kapravelou | if (tab == 0) |
530 | 8c999b8c | Natasa Kapravelou | return true; |
531 | 14ad7326 | pastith | return false; |
532 | 14ad7326 | pastith | } |
533 | 14ad7326 | pastith | |
534 | 8c999b8c | Natasa Kapravelou | public boolean isSearchResultsShowing() { |
535 | 14ad7326 | pastith | int tab = inner.getTabBar().getSelectedTab();
|
536 | 8c999b8c | Natasa Kapravelou | if (tab == 2) |
537 | 8c999b8c | Natasa Kapravelou | return true; |
538 | 14ad7326 | pastith | return false; |
539 | 14ad7326 | pastith | } |
540 | 14ad7326 | pastith | |
541 | 14ad7326 | pastith | /**
|
542 | 14ad7326 | pastith | * Make the user list visible.
|
543 | 14ad7326 | pastith | */
|
544 | 14ad7326 | pastith | public void showUserList() { |
545 | 14ad7326 | pastith | inner.selectTab(1);
|
546 | 14ad7326 | pastith | } |
547 | 14ad7326 | pastith | |
548 | 14ad7326 | pastith | /**
|
549 | 14ad7326 | pastith | * Make the file list visible.
|
550 | 14ad7326 | pastith | */
|
551 | 14ad7326 | pastith | public void showFileList() { |
552 | 18a508ee | fstamatelopoulos | fileList.updateFileCache(false, true /*clear selection*/); |
553 | a52ea5e4 | pastith | inner.selectTab(0);
|
554 | a52ea5e4 | pastith | } |
555 | a52ea5e4 | pastith | |
556 | a52ea5e4 | pastith | /**
|
557 | a52ea5e4 | pastith | * Make the file list visible.
|
558 | 8c999b8c | Natasa Kapravelou | *
|
559 | 9ac50c9e | pastith | * @param update
|
560 | a52ea5e4 | pastith | */
|
561 | a52ea5e4 | pastith | public void showFileList(boolean update) { |
562 | c018c4de | pastith | TreeItem currentFolder = getFolders().getCurrent(); |
563 | c018c4de | pastith | if (currentFolder != null) { |
564 | c018c4de | pastith | List<FileResource> files = null; |
565 | c018c4de | pastith | Object cachedObject = currentFolder.getUserObject();
|
566 | c018c4de | pastith | if (cachedObject instanceof FolderResource) { |
567 | c018c4de | pastith | FolderResource folder = (FolderResource) cachedObject; |
568 | c018c4de | pastith | files = folder.getFiles(); |
569 | c018c4de | pastith | } else if (cachedObject instanceof TrashResource) { |
570 | c018c4de | pastith | TrashResource folder = (TrashResource) cachedObject; |
571 | c018c4de | pastith | files = folder.getFiles(); |
572 | c018c4de | pastith | } |
573 | c018c4de | pastith | if (files != null) |
574 | c018c4de | pastith | getFileList().setFiles(files); |
575 | c018c4de | pastith | } |
576 | 18a508ee | fstamatelopoulos | fileList.updateFileCache(update, true /*clear selection*/); |
577 | 14ad7326 | pastith | inner.selectTab(0);
|
578 | 14ad7326 | pastith | } |
579 | 14ad7326 | pastith | |
580 | 14ad7326 | pastith | /**
|
581 | 14ad7326 | pastith | * Make the search results visible.
|
582 | 8c999b8c | Natasa Kapravelou | *
|
583 | 14ad7326 | pastith | * @param query the search query string
|
584 | 14ad7326 | pastith | */
|
585 | 14ad7326 | pastith | public void showSearchResults(String query) { |
586 | a52ea5e4 | pastith | searchResults.updateFileCache(query); |
587 | b3c6d52e | fstamatelopoulos | searchResults.updateCurrentlyShowingStats(); |
588 | 14ad7326 | pastith | inner.selectTab(2);
|
589 | 14ad7326 | pastith | } |
590 | 14ad7326 | pastith | |
591 | 14ad7326 | pastith | /**
|
592 | 14ad7326 | pastith | * Display the 'loading' indicator.
|
593 | 14ad7326 | pastith | */
|
594 | 14ad7326 | pastith | public void showLoadingIndicator() { |
595 | 12231a24 | Panagiotis Astithas | topPanel.getLoading().setVisible(true);
|
596 | 14ad7326 | pastith | } |
597 | 14ad7326 | pastith | |
598 | 14ad7326 | pastith | /**
|
599 | 14ad7326 | pastith | * Hide the 'loading' indicator.
|
600 | 14ad7326 | pastith | */
|
601 | 14ad7326 | pastith | public void hideLoadingIndicator() { |
602 | 12231a24 | Panagiotis Astithas | topPanel.getLoading().setVisible(false);
|
603 | 14ad7326 | pastith | } |
604 | 14ad7326 | pastith | |
605 | 14ad7326 | pastith | /**
|
606 | 14ad7326 | pastith | * A native JavaScript method to reach out to the browser's window and
|
607 | 14ad7326 | pastith | * invoke its resizeTo() method.
|
608 | 14ad7326 | pastith | *
|
609 | 14ad7326 | pastith | * @param x the new width
|
610 | 14ad7326 | pastith | * @param y the new height
|
611 | 14ad7326 | pastith | */
|
612 | 14ad7326 | pastith | public static native void resizeTo(int x, int y) /*-{ |
613 | 06b48563 | Natasa Kapravelou | $wnd.resizeTo(x,y);
|
614 | 06b48563 | Natasa Kapravelou | }-*/;
|
615 | 14ad7326 | pastith | |
616 | 14ad7326 | pastith | /**
|
617 | 14ad7326 | pastith | * A helper method that returns true if the user's list is currently visible
|
618 | 14ad7326 | pastith | * and false if it is hidden.
|
619 | 14ad7326 | pastith | *
|
620 | 14ad7326 | pastith | * @return true if the user list is visible
|
621 | 14ad7326 | pastith | */
|
622 | 14ad7326 | pastith | public boolean isUserListVisible() { |
623 | 14ad7326 | pastith | return inner.getTabBar().getSelectedTab() == 1; |
624 | 14ad7326 | pastith | } |
625 | 14ad7326 | pastith | |
626 | 14ad7326 | pastith | /**
|
627 | 14ad7326 | pastith | * Display an error message.
|
628 | 14ad7326 | pastith | *
|
629 | 14ad7326 | pastith | * @param msg the message to display
|
630 | 14ad7326 | pastith | */
|
631 | 14ad7326 | pastith | public void displayError(String msg) { |
632 | 14ad7326 | pastith | messagePanel.displayError(msg); |
633 | 14ad7326 | pastith | } |
634 | 14ad7326 | pastith | |
635 | 14ad7326 | pastith | /**
|
636 | 14ad7326 | pastith | * Display a warning message.
|
637 | 14ad7326 | pastith | *
|
638 | 14ad7326 | pastith | * @param msg the message to display
|
639 | 14ad7326 | pastith | */
|
640 | 14ad7326 | pastith | public void displayWarning(String msg) { |
641 | 14ad7326 | pastith | messagePanel.displayWarning(msg); |
642 | 14ad7326 | pastith | } |
643 | 14ad7326 | pastith | |
644 | 14ad7326 | pastith | /**
|
645 | 14ad7326 | pastith | * Display an informational message.
|
646 | 14ad7326 | pastith | *
|
647 | 14ad7326 | pastith | * @param msg the message to display
|
648 | 14ad7326 | pastith | */
|
649 | 14ad7326 | pastith | public void displayInformation(String msg) { |
650 | 14ad7326 | pastith | messagePanel.displayInformation(msg); |
651 | 14ad7326 | pastith | } |
652 | 14ad7326 | pastith | |
653 | 14ad7326 | pastith | /**
|
654 | 14ad7326 | pastith | * Retrieve the folders.
|
655 | 14ad7326 | pastith | *
|
656 | 14ad7326 | pastith | * @return the folders
|
657 | 14ad7326 | pastith | */
|
658 | 14ad7326 | pastith | public Folders getFolders() {
|
659 | 14ad7326 | pastith | return folders;
|
660 | 14ad7326 | pastith | } |
661 | 14ad7326 | pastith | |
662 | 14ad7326 | pastith | /**
|
663 | 14ad7326 | pastith | * Retrieve the search.
|
664 | 14ad7326 | pastith | *
|
665 | 14ad7326 | pastith | * @return the search
|
666 | 14ad7326 | pastith | */
|
667 | 14ad7326 | pastith | Search getSearch() { |
668 | 14ad7326 | pastith | return search;
|
669 | 14ad7326 | pastith | } |
670 | 14ad7326 | pastith | |
671 | 14ad7326 | pastith | /**
|
672 | 14ad7326 | pastith | * Retrieve the currentSelection.
|
673 | 14ad7326 | pastith | *
|
674 | 14ad7326 | pastith | * @return the currentSelection
|
675 | 14ad7326 | pastith | */
|
676 | 14ad7326 | pastith | public Object getCurrentSelection() { |
677 | 14ad7326 | pastith | return currentSelection;
|
678 | 14ad7326 | pastith | } |
679 | 14ad7326 | pastith | |
680 | 14ad7326 | pastith | /**
|
681 | 14ad7326 | pastith | * Modify the currentSelection.
|
682 | 14ad7326 | pastith | *
|
683 | 14ad7326 | pastith | * @param newCurrentSelection the currentSelection to set
|
684 | 14ad7326 | pastith | */
|
685 | 14ad7326 | pastith | public void setCurrentSelection(Object newCurrentSelection) { |
686 | 14ad7326 | pastith | currentSelection = newCurrentSelection; |
687 | 14ad7326 | pastith | } |
688 | 14ad7326 | pastith | |
689 | 14ad7326 | pastith | /**
|
690 | 14ad7326 | pastith | * Retrieve the groups.
|
691 | 14ad7326 | pastith | *
|
692 | 14ad7326 | pastith | * @return the groups
|
693 | 14ad7326 | pastith | */
|
694 | 14ad7326 | pastith | public Groups getGroups() {
|
695 | 14ad7326 | pastith | return groups;
|
696 | 14ad7326 | pastith | } |
697 | 14ad7326 | pastith | |
698 | 14ad7326 | pastith | /**
|
699 | 14ad7326 | pastith | * Retrieve the fileList.
|
700 | 14ad7326 | pastith | *
|
701 | 14ad7326 | pastith | * @return the fileList
|
702 | 14ad7326 | pastith | */
|
703 | 14ad7326 | pastith | public FileList getFileList() {
|
704 | 14ad7326 | pastith | return fileList;
|
705 | 14ad7326 | pastith | } |
706 | 14ad7326 | pastith | |
707 | 8c999b8c | Natasa Kapravelou | public SearchResults getSearchResults() {
|
708 | 14ad7326 | pastith | return searchResults;
|
709 | 14ad7326 | pastith | } |
710 | 9ac50c9e | pastith | |
711 | 14ad7326 | pastith | /**
|
712 | 14ad7326 | pastith | * Retrieve the topPanel.
|
713 | 14ad7326 | pastith | *
|
714 | 14ad7326 | pastith | * @return the topPanel
|
715 | 14ad7326 | pastith | */
|
716 | 14ad7326 | pastith | TopPanel getTopPanel() { |
717 | 14ad7326 | pastith | return topPanel;
|
718 | 14ad7326 | pastith | } |
719 | 14ad7326 | pastith | |
720 | 14ad7326 | pastith | /**
|
721 | 14ad7326 | pastith | * Retrieve the clipboard.
|
722 | 14ad7326 | pastith | *
|
723 | 14ad7326 | pastith | * @return the clipboard
|
724 | 14ad7326 | pastith | */
|
725 | 14ad7326 | pastith | public Clipboard getClipboard() { |
726 | 14ad7326 | pastith | return clipboard;
|
727 | 14ad7326 | pastith | } |
728 | 14ad7326 | pastith | |
729 | 8c999b8c | Natasa Kapravelou | public StatusPanel getStatusPanel() {
|
730 | 14ad7326 | pastith | return statusPanel;
|
731 | 14ad7326 | pastith | } |
732 | 14ad7326 | pastith | |
733 | d333ebbc | Panagiotis Astithas | /**
|
734 | d333ebbc | Panagiotis Astithas | * Retrieve the userDetailsPanel.
|
735 | d333ebbc | Panagiotis Astithas | *
|
736 | d333ebbc | Panagiotis Astithas | * @return the userDetailsPanel
|
737 | d333ebbc | Panagiotis Astithas | */
|
738 | d333ebbc | Panagiotis Astithas | public UserDetailsPanel getUserDetailsPanel() {
|
739 | d333ebbc | Panagiotis Astithas | return userDetailsPanel;
|
740 | d333ebbc | Panagiotis Astithas | } |
741 | d333ebbc | Panagiotis Astithas | |
742 | 14ad7326 | pastith | /**
|
743 | 14ad7326 | pastith | * Retrieve the dragController.
|
744 | 14ad7326 | pastith | *
|
745 | 14ad7326 | pastith | * @return the dragController
|
746 | 14ad7326 | pastith | */
|
747 | 14ad7326 | pastith | public PickupDragController getDragController() {
|
748 | 14ad7326 | pastith | return dragController;
|
749 | 14ad7326 | pastith | } |
750 | 14ad7326 | pastith | |
751 | 8c999b8c | Natasa Kapravelou | public String getToken() { |
752 | 14ad7326 | pastith | return token;
|
753 | 14ad7326 | pastith | } |
754 | 14ad7326 | pastith | |
755 | 3ef7b691 | Dimitris Routsis | public String getWebDAVPassword() { |
756 | 3ef7b691 | Dimitris Routsis | return webDAVPassword;
|
757 | 3ef7b691 | Dimitris Routsis | } |
758 | 3ef7b691 | Dimitris Routsis | |
759 | 8c999b8c | Natasa Kapravelou | public void removeGlassPanel() { |
760 | 14ad7326 | pastith | glassPanel.removeFromParent(); |
761 | 14ad7326 | pastith | } |
762 | 14ad7326 | pastith | |
763 | a52ea5e4 | pastith | /**
|
764 | a52ea5e4 | pastith | * Retrieve the currentUserResource.
|
765 | a52ea5e4 | pastith | *
|
766 | a52ea5e4 | pastith | * @return the currentUserResource
|
767 | a52ea5e4 | pastith | */
|
768 | a52ea5e4 | pastith | public UserResource getCurrentUserResource() {
|
769 | a52ea5e4 | pastith | return currentUserResource;
|
770 | a52ea5e4 | pastith | } |
771 | a52ea5e4 | pastith | |
772 | d333ebbc | Panagiotis Astithas | /**
|
773 | d333ebbc | Panagiotis Astithas | * Modify the currentUserResource.
|
774 | d333ebbc | Panagiotis Astithas | *
|
775 | d333ebbc | Panagiotis Astithas | * @param newUser the new currentUserResource
|
776 | d333ebbc | Panagiotis Astithas | */
|
777 | d333ebbc | Panagiotis Astithas | public void setCurrentUserResource(UserResource newUser) { |
778 | d333ebbc | Panagiotis Astithas | currentUserResource = newUser; |
779 | d333ebbc | Panagiotis Astithas | } |
780 | d333ebbc | Panagiotis Astithas | |
781 | 18cd8128 | fstamatelopoulos | public static native void preventIESelection() /*-{ |
782 | 06b48563 | Natasa Kapravelou | $doc.body.onselectstart = function () { return false; };
|
783 | 06b48563 | Natasa Kapravelou | }-*/;
|
784 | 18cd8128 | fstamatelopoulos | |
785 | 18cd8128 | fstamatelopoulos | public static native void enableIESelection() /*-{ |
786 | 06b48563 | Natasa Kapravelou | if ($doc.body.onselectstart != null)
|
787 | 06b48563 | Natasa Kapravelou | $doc.body.onselectstart = null;
|
788 | 06b48563 | Natasa Kapravelou | }-*/;
|
789 | 18cd8128 | fstamatelopoulos | |
790 | bbad17b4 | pastith | /**
|
791 | bbad17b4 | pastith | * @return the absolute path of the API root URL
|
792 | bbad17b4 | pastith | */
|
793 | bbad17b4 | pastith | public String getApiPath() { |
794 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
795 | bbad17b4 | pastith | return GWT.getModuleBaseURL() + conf.apiPath();
|
796 | bbad17b4 | pastith | } |
797 | bbad17b4 | pastith | |
798 | 3ef7b691 | Dimitris Routsis | public void refreshWebDAVPassword() { |
799 | 3ef7b691 | Dimitris Routsis | Configuration conf = (Configuration) GWT.create(Configuration.class); |
800 | 3ef7b691 | Dimitris Routsis | String domain = Window.Location.getHostName(); |
801 | 3ef7b691 | Dimitris Routsis | String path = Window.Location.getPath(); |
802 | 3ef7b691 | Dimitris Routsis | String cookie = conf.webdavCookie();
|
803 | 3ef7b691 | Dimitris Routsis | webDAVPassword = Cookies.getCookie(cookie); |
804 | 3ef7b691 | Dimitris Routsis | Cookies.setCookie(cookie, "", null, domain, path, false); |
805 | 3ef7b691 | Dimitris Routsis | } |
806 | 8c550474 | Natasa Kapravelou | |
807 | 0174fdb2 | Natasa Kapravelou | /**
|
808 | 1510f141 | Giannis Koutsoubos | * Convert server date to local time according to browser timezone
|
809 | 1510f141 | Giannis Koutsoubos | * and format it according to localized pattern.
|
810 | 1510f141 | Giannis Koutsoubos | * Time is always formatted to 24hr format.
|
811 | 1510f141 | Giannis Koutsoubos | * NB: This assumes that server runs in UTC timezone. Otherwise
|
812 | 1510f141 | Giannis Koutsoubos | * we would need to adjust for server time offset as well.
|
813 | 1510f141 | Giannis Koutsoubos | *
|
814 | 1510f141 | Giannis Koutsoubos | * @param date
|
815 | 1510f141 | Giannis Koutsoubos | * @return String
|
816 | 1510f141 | Giannis Koutsoubos | */
|
817 | 1510f141 | Giannis Koutsoubos | public static String formatLocalDateTime(Date date) { |
818 | 1510f141 | Giannis Koutsoubos | Date convertedDate = new Date(date.getTime() - date.getTimezoneOffset()); |
819 | 1510f141 | Giannis Koutsoubos | final DateTimeFormat dateFormatter = DateTimeFormat.getShortDateFormat();
|
820 | 1510f141 | Giannis Koutsoubos | final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm"); |
821 | 1510f141 | Giannis Koutsoubos | String datePart = dateFormatter.format(convertedDate);
|
822 | 1510f141 | Giannis Koutsoubos | String timePart = timeFormatter.format(convertedDate);
|
823 | 1510f141 | Giannis Koutsoubos | return datePart + " " + timePart; |
824 | 1510f141 | Giannis Koutsoubos | } |
825 | 1510f141 | Giannis Koutsoubos | |
826 | 1510f141 | Giannis Koutsoubos | /**
|
827 | 98b59163 | Natasa Kapravelou | * History support for folder navigation
|
828 | 2487ac7b | Natasa Kapravelou | * adds a new browser history entry
|
829 | 2487ac7b | Natasa Kapravelou | *
|
830 | 0174fdb2 | Natasa Kapravelou | * @param key
|
831 | 0174fdb2 | Natasa Kapravelou | */
|
832 | 98b59163 | Natasa Kapravelou | public void updateHistory(String key){ |
833 | 8c550474 | Natasa Kapravelou | // Replace any whitespace of the initial string to "+"
|
834 | 2487ac7b | Natasa Kapravelou | // String result = key.replaceAll("\\s","+");
|
835 | 8c550474 | Natasa Kapravelou | // Add a new browser history entry.
|
836 | 2487ac7b | Natasa Kapravelou | // History.newItem(result);
|
837 | 2487ac7b | Natasa Kapravelou | History.newItem(key); |
838 | 0174fdb2 | Natasa Kapravelou | } |
839 | df9802b9 | Natasa Kapravelou | |
840 | df9802b9 | Natasa Kapravelou | /**
|
841 | df9802b9 | Natasa Kapravelou | * This method examines the token input and add a "/" at the end in case it's omitted.
|
842 | df9802b9 | Natasa Kapravelou | * This happens only in Files/trash/, Files/shared/, Files/others.
|
843 | df9802b9 | Natasa Kapravelou | *
|
844 | df9802b9 | Natasa Kapravelou | * @param tokenInput
|
845 | df9802b9 | Natasa Kapravelou | * @return the formated token with a "/" at the end or the same tokenInput parameter
|
846 | df9802b9 | Natasa Kapravelou | */
|
847 | df9802b9 | Natasa Kapravelou | |
848 | f47d99c4 | Natasa Kapravelou | private String handleSpecialFolderNames(String tokenInput){ |
849 | df9802b9 | Natasa Kapravelou | List<String> pathsToCheck = Arrays.asList("Files/trash", "Files/shared", "Files/others"); |
850 | df9802b9 | Natasa Kapravelou | if(pathsToCheck.contains(tokenInput))
|
851 | df9802b9 | Natasa Kapravelou | return tokenInput + "/"; |
852 | df9802b9 | Natasa Kapravelou | return tokenInput;
|
853 | df9802b9 | Natasa Kapravelou | |
854 | df9802b9 | Natasa Kapravelou | } |
855 | 4315bcc5 | Panagiotis Astithas | |
856 | 4315bcc5 | Panagiotis Astithas | /**
|
857 | 8b79a1c8 | Natasa Kapravelou | * Reject illegal resource names, like '.' or '..' or slashes '/'.
|
858 | 4315bcc5 | Panagiotis Astithas | */
|
859 | 4315bcc5 | Panagiotis Astithas | static boolean isValidResourceName(String name) { |
860 | 8b79a1c8 | Natasa Kapravelou | if (".".equals(name) || "..".equals(name) || name.contains("/")) |
861 | 4315bcc5 | Panagiotis Astithas | return false; |
862 | 4315bcc5 | Panagiotis Astithas | return true; |
863 | 4315bcc5 | Panagiotis Astithas | } |
864 | 4315bcc5 | Panagiotis Astithas | |
865 | 9ab5db6d | Natasa Kapravelou | public void putUserToMap(String _userName, String _userFullName){ |
866 | 9ab5db6d | Natasa Kapravelou | userFullNameMap.put(_userName, _userFullName); |
867 | 9ab5db6d | Natasa Kapravelou | } |
868 | 9ab5db6d | Natasa Kapravelou | |
869 | 9ab5db6d | Natasa Kapravelou | public String findUserFullName(String _userName){ |
870 | 9ab5db6d | Natasa Kapravelou | return userFullNameMap.get(_userName);
|
871 | 9ab5db6d | Natasa Kapravelou | } |
872 | 9ab5db6d | Natasa Kapravelou | |
873 | 14ad7326 | pastith | } |