root / src / gr / ebs / gss / client / GSS.java @ a60ea262
History | View | Annotate | Download (25.2 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 | 8c999b8c | Natasa Kapravelou | 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 { |
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 | 14ad7326 | pastith | inner.setWidth("100%");
|
315 | 14ad7326 | pastith | inner.selectTab(0);
|
316 | 14ad7326 | pastith | |
317 | afd3a0ef | Giannis Koutsoubos | inner.addSelectionHandler(new SelectionHandler<Integer>() { |
318 | afd3a0ef | Giannis Koutsoubos | |
319 | afd3a0ef | Giannis Koutsoubos | @Override
|
320 | afd3a0ef | Giannis Koutsoubos | public void onSelection(SelectionEvent<Integer> event) { |
321 | 8c999b8c | Natasa Kapravelou | int tabIndex = event.getSelectedItem();
|
322 | 98b59163 | Natasa Kapravelou | // TreeItem treeItem = GSS.get().getFolders().getCurrent();
|
323 | afd3a0ef | Giannis Koutsoubos | switch (tabIndex) {
|
324 | 8c999b8c | Natasa Kapravelou | case 0: |
325 | 8c550474 | Natasa Kapravelou | // Files tab selected
|
326 | 8c999b8c | Natasa Kapravelou | fileList.clearSelectedRows(); |
327 | 8c999b8c | Natasa Kapravelou | fileList.updateCurrentlyShowingStats(); |
328 | 8c999b8c | Natasa Kapravelou | break;
|
329 | 8c999b8c | Natasa Kapravelou | case 1: |
330 | 8c550474 | Natasa Kapravelou | // Groups tab selected
|
331 | 8c999b8c | Natasa Kapravelou | groups.updateCurrentlyShowingStats(); |
332 | 98b59163 | Natasa Kapravelou | updateHistory("Groups");
|
333 | 8c999b8c | Natasa Kapravelou | break;
|
334 | 8c999b8c | Natasa Kapravelou | case 2: |
335 | 8c550474 | Natasa Kapravelou | // Search tab selected
|
336 | 8c999b8c | Natasa Kapravelou | searchResults.clearSelectedRows(); |
337 | 8c999b8c | Natasa Kapravelou | searchResults.updateCurrentlyShowingStats(); |
338 | 98b59163 | Natasa Kapravelou | updateHistory("Search");
|
339 | 8c999b8c | Natasa Kapravelou | break;
|
340 | 8c999b8c | Natasa Kapravelou | } |
341 | b3c6d52e | fstamatelopoulos | } |
342 | b3c6d52e | fstamatelopoulos | }); |
343 | 8c550474 | Natasa Kapravelou | // If the application starts with no history token, redirect to a new "Files" state
|
344 | 0174fdb2 | Natasa Kapravelou | String initToken = History.getToken();
|
345 | 0174fdb2 | Natasa Kapravelou | if(initToken.length() == 0) |
346 | 0174fdb2 | Natasa Kapravelou | History.newItem("Files");
|
347 | 8c550474 | Natasa Kapravelou | // Add history listener to handle any history events
|
348 | 037fabb5 | Natasa Kapravelou | History.addValueChangeHandler(new ValueChangeHandler<String>() { |
349 | 037fabb5 | Natasa Kapravelou | @Override
|
350 | 037fabb5 | Natasa Kapravelou | public void onValueChange(ValueChangeEvent<String> event) { |
351 | 037fabb5 | Natasa Kapravelou | String tokenInput = event.getValue();
|
352 | 037fabb5 | Natasa Kapravelou | String historyToken = handleSpecialFolderNames(tokenInput);
|
353 | 037fabb5 | Natasa Kapravelou | try {
|
354 | 037fabb5 | Natasa Kapravelou | if(historyToken.equals("Search")) |
355 | 037fabb5 | Natasa Kapravelou | inner.selectTab(2);
|
356 | 037fabb5 | Natasa Kapravelou | else if(historyToken.equals("Groups")) |
357 | 037fabb5 | Natasa Kapravelou | inner.selectTab(1);
|
358 | 037fabb5 | Natasa Kapravelou | else if(historyToken.equals("Files")|| historyToken.length()==0) |
359 | 037fabb5 | Natasa Kapravelou | inner.selectTab(0);
|
360 | 037fabb5 | Natasa Kapravelou | else {
|
361 | 037fabb5 | Natasa Kapravelou | PopupTree popupTree = GSS.get().getFolders().getPopupTree(); |
362 | 037fabb5 | Natasa Kapravelou | TreeItem treeObj = GSS.get().getFolders().getPopupTree().getTreeItem(historyToken); |
363 | 037fabb5 | Natasa Kapravelou | SelectionEvent.fire(popupTree, treeObj); |
364 | 037fabb5 | Natasa Kapravelou | } |
365 | 44873f3d | Christos V. Stathis | } catch (IndexOutOfBoundsException e) { |
366 | 44873f3d | Christos V. Stathis | inner.selectTab(0);
|
367 | 44873f3d | Christos V. Stathis | } |
368 | 44873f3d | Christos V. Stathis | } |
369 | 44873f3d | Christos V. Stathis | }); |
370 | b3c6d52e | fstamatelopoulos | |
371 | 14ad7326 | pastith | // Add the left and right panels to the split panel.
|
372 | 14ad7326 | pastith | splitPanel.setLeftWidget(folders); |
373 | 14ad7326 | pastith | splitPanel.setRightWidget(inner); |
374 | a44876bf | fstamatelopoulos | splitPanel.setSplitPosition("25%");
|
375 | a52ea5e4 | pastith | splitPanel.setSize("100%", "100%"); |
376 | 5c6b2883 | Panagiotis Astithas | splitPanel.addStyleName("gss-splitPanel");
|
377 | 14ad7326 | pastith | |
378 | 14ad7326 | pastith | // Create a dock panel that will contain the menu bar at the top,
|
379 | 14ad7326 | pastith | // the shortcuts to the left, the status bar at the bottom and the
|
380 | 14ad7326 | pastith | // right panel taking the rest.
|
381 | 14ad7326 | pastith | VerticalPanel outer = new VerticalPanel();
|
382 | 14ad7326 | pastith | outer.add(topPanel); |
383 | 14ad7326 | pastith | outer.add(searchStatus); |
384 | 14ad7326 | pastith | outer.add(messagePanel); |
385 | 14ad7326 | pastith | outer.add(splitPanel); |
386 | a44876bf | fstamatelopoulos | outer.add(statusPanel); |
387 | 14ad7326 | pastith | outer.setWidth("100%");
|
388 | 14ad7326 | pastith | outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER); |
389 | 14ad7326 | pastith | |
390 | 14ad7326 | pastith | outer.setSpacing(4);
|
391 | 14ad7326 | pastith | |
392 | 14ad7326 | pastith | // Hook the window resize event, so that we can adjust the UI.
|
393 | afd3a0ef | Giannis Koutsoubos | Window.addResizeHandler(this); |
394 | 14ad7326 | pastith | // Clear out the window's built-in margin, because we want to take
|
395 | 14ad7326 | pastith | // advantage of the entire client area.
|
396 | 14ad7326 | pastith | Window.setMargin("0px"); |
397 | 14ad7326 | pastith | // Finally, add the outer panel to the RootPanel, so that it will be
|
398 | 14ad7326 | pastith | // displayed.
|
399 | 14ad7326 | pastith | RootPanel.get().add(outer); |
400 | 14ad7326 | pastith | // Call the window resized handler to get the initial sizes setup. Doing
|
401 | 14ad7326 | pastith | // this in a deferred command causes it to occur after all widgets'
|
402 | 9ac50c9e | pastith | // sizes have been computed by the browser.
|
403 | 14ad7326 | pastith | DeferredCommand.addCommand(new Command() {
|
404 | 8c999b8c | Natasa Kapravelou | |
405 | 037fabb5 | Natasa Kapravelou | @Override
|
406 | 14ad7326 | pastith | public void execute() { |
407 | be05fc7b | Panagiotis Astithas | onWindowResized(Window.getClientHeight());
|
408 | 14ad7326 | pastith | } |
409 | 14ad7326 | pastith | }); |
410 | 14ad7326 | pastith | } |
411 | 14ad7326 | pastith | |
412 | 14ad7326 | pastith | /**
|
413 | 14ad7326 | pastith | * Fetches the User object for the specified username.
|
414 | 14ad7326 | pastith | *
|
415 | 14ad7326 | pastith | * @param username the username of the user
|
416 | 14ad7326 | pastith | */
|
417 | 14ad7326 | pastith | private void fetchUser(final String username) { |
418 | bbad17b4 | pastith | String path = getApiPath() + username + "/"; |
419 | 8c999b8c | Natasa Kapravelou | GetCommand<UserResource> getUserCommand = new GetCommand<UserResource>(UserResource.class, username, path, null) { |
420 | 14ad7326 | pastith | |
421 | 9ac50c9e | pastith | @Override
|
422 | a52ea5e4 | pastith | public void onComplete() { |
423 | a52ea5e4 | pastith | currentUserResource = getResult(); |
424 | 50135fa5 | pastith | final String announcement = currentUserResource.getAnnouncement(); |
425 | 50135fa5 | pastith | if (announcement != null) |
426 | 50135fa5 | pastith | DeferredCommand.addCommand(new Command() {
|
427 | 8c999b8c | Natasa Kapravelou | |
428 | 037fabb5 | Natasa Kapravelou | @Override
|
429 | 50135fa5 | pastith | public void execute() { |
430 | 50135fa5 | pastith | displayInformation(announcement); |
431 | 50135fa5 | pastith | } |
432 | 50135fa5 | pastith | }); |
433 | 14ad7326 | pastith | } |
434 | a52ea5e4 | pastith | |
435 | 9ac50c9e | pastith | @Override
|
436 | a52ea5e4 | pastith | public void onError(Throwable t) { |
437 | a52ea5e4 | pastith | GWT.log("Fetching user error", t);
|
438 | 8c999b8c | Natasa Kapravelou | if (t instanceof RestException) |
439 | 8c999b8c | Natasa Kapravelou | GSS.get().displayError("No user found:" + ((RestException) t).getHttpStatusText());
|
440 | a52ea5e4 | pastith | else
|
441 | 8c999b8c | Natasa Kapravelou | GSS.get().displayError("System error fetching user data:" + t.getMessage());
|
442 | 6e6e914e | Panagiotis Astithas | authenticateUser(); |
443 | a52ea5e4 | pastith | } |
444 | a52ea5e4 | pastith | }; |
445 | a52ea5e4 | pastith | DeferredCommand.addCommand(getUserCommand); |
446 | 14ad7326 | pastith | } |
447 | 14ad7326 | pastith | |
448 | 14ad7326 | pastith | /**
|
449 | 14ad7326 | pastith | * Parse and store the user credentials to the appropriate fields.
|
450 | 14ad7326 | pastith | */
|
451 | 14ad7326 | pastith | private void parseUserCredentials() { |
452 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
453 | bbad17b4 | pastith | String cookie = conf.authCookie();
|
454 | bbad17b4 | pastith | String auth = Cookies.getCookie(cookie);
|
455 | 14ad7326 | pastith | if (auth == null) { |
456 | 14ad7326 | pastith | authenticateUser(); |
457 | 14ad7326 | pastith | // Redundant, but silences warnings about possible auth NPE, below.
|
458 | 14ad7326 | pastith | return;
|
459 | 14ad7326 | pastith | } |
460 | bbad17b4 | pastith | int sepIndex = auth.indexOf(conf.cookieSeparator());
|
461 | 14ad7326 | pastith | if (sepIndex == -1) |
462 | 14ad7326 | pastith | authenticateUser(); |
463 | 30e14a2f | Panagiotis Astithas | token = auth.substring(sepIndex + 1);
|
464 | 14ad7326 | pastith | final String username = auth.substring(0, sepIndex); |
465 | 14ad7326 | pastith | if (username == null) |
466 | 14ad7326 | pastith | authenticateUser(); |
467 | 3ef7b691 | Dimitris Routsis | |
468 | 3ef7b691 | Dimitris Routsis | refreshWebDAVPassword(); |
469 | 3ef7b691 | Dimitris Routsis | |
470 | 14ad7326 | pastith | DeferredCommand.addCommand(new Command() {
|
471 | 8c999b8c | Natasa Kapravelou | |
472 | 037fabb5 | Natasa Kapravelou | @Override
|
473 | 14ad7326 | pastith | public void execute() { |
474 | 14ad7326 | pastith | fetchUser(username); |
475 | 14ad7326 | pastith | } |
476 | 14ad7326 | pastith | }); |
477 | 14ad7326 | pastith | } |
478 | 14ad7326 | pastith | |
479 | 14ad7326 | pastith | /**
|
480 | 14ad7326 | pastith | * Redirect the user to the login page for authentication.
|
481 | 14ad7326 | pastith | */
|
482 | 05f65955 | koutsoub | protected void authenticateUser() { |
483 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
484 | bbad17b4 | pastith | Window.Location.assign(conf.loginUrl() + "?next=" + GWT.getModuleBaseURL()); |
485 | 14ad7326 | pastith | } |
486 | 14ad7326 | pastith | |
487 | 14ad7326 | pastith | /**
|
488 | 312631e1 | Panagiotis Astithas | * Clear the cookie and redirect the user to the logout page.
|
489 | 14ad7326 | pastith | */
|
490 | 14ad7326 | pastith | void logout() {
|
491 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
492 | 312631e1 | Panagiotis Astithas | String cookie = conf.authCookie();
|
493 | 312631e1 | Panagiotis Astithas | String domain = Window.Location.getHostName(); |
494 | 312631e1 | Panagiotis Astithas | String path = Window.Location.getPath(); |
495 | 312631e1 | Panagiotis Astithas | Cookies.setCookie(cookie, "", null, domain, path, false); |
496 | bbad17b4 | pastith | Window.Location.assign(conf.logoutUrl());
|
497 | 14ad7326 | pastith | } |
498 | 14ad7326 | pastith | |
499 | 14ad7326 | pastith | /**
|
500 | 14ad7326 | pastith | * Creates an HTML fragment that places an image & caption together, for use
|
501 | 14ad7326 | pastith | * in a group header.
|
502 | 14ad7326 | pastith | *
|
503 | 14ad7326 | pastith | * @param imageProto an image prototype for an image
|
504 | 14ad7326 | pastith | * @param caption the group caption
|
505 | 14ad7326 | pastith | * @return the header HTML fragment
|
506 | 14ad7326 | pastith | */
|
507 | 14ad7326 | pastith | private String createHeaderHTML(AbstractImagePrototype imageProto, String caption) { |
508 | 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>"; |
509 | 14ad7326 | pastith | return captionHTML;
|
510 | 14ad7326 | pastith | } |
511 | 14ad7326 | pastith | |
512 | 6e6e914e | Panagiotis Astithas | private void onWindowResized(int height) { |
513 | 14ad7326 | pastith | // Adjust the split panel to take up the available room in the window.
|
514 | 9ac50c9e | pastith | int newHeight = height - splitPanel.getAbsoluteTop() - 44; |
515 | 14ad7326 | pastith | if (newHeight < 1) |
516 | 14ad7326 | pastith | newHeight = 1;
|
517 | 14ad7326 | pastith | splitPanel.setHeight("" + newHeight);
|
518 | 14ad7326 | pastith | } |
519 | 14ad7326 | pastith | |
520 | afd3a0ef | Giannis Koutsoubos | @Override
|
521 | afd3a0ef | Giannis Koutsoubos | public void onResize(ResizeEvent event) { |
522 | be05fc7b | Panagiotis Astithas | int height = event.getHeight();
|
523 | be05fc7b | Panagiotis Astithas | onWindowResized(height); |
524 | afd3a0ef | Giannis Koutsoubos | } |
525 | afd3a0ef | Giannis Koutsoubos | |
526 | 8c999b8c | Natasa Kapravelou | public boolean isFileListShowing() { |
527 | 14ad7326 | pastith | int tab = inner.getTabBar().getSelectedTab();
|
528 | 8c999b8c | Natasa Kapravelou | if (tab == 0) |
529 | 8c999b8c | Natasa Kapravelou | return true; |
530 | 14ad7326 | pastith | return false; |
531 | 14ad7326 | pastith | } |
532 | 14ad7326 | pastith | |
533 | 8c999b8c | Natasa Kapravelou | public boolean isSearchResultsShowing() { |
534 | 14ad7326 | pastith | int tab = inner.getTabBar().getSelectedTab();
|
535 | 8c999b8c | Natasa Kapravelou | if (tab == 2) |
536 | 8c999b8c | Natasa Kapravelou | return true; |
537 | 14ad7326 | pastith | return false; |
538 | 14ad7326 | pastith | } |
539 | 14ad7326 | pastith | |
540 | 14ad7326 | pastith | /**
|
541 | 14ad7326 | pastith | * Make the user list visible.
|
542 | 14ad7326 | pastith | */
|
543 | 14ad7326 | pastith | public void showUserList() { |
544 | 14ad7326 | pastith | inner.selectTab(1);
|
545 | 14ad7326 | pastith | } |
546 | 14ad7326 | pastith | |
547 | 14ad7326 | pastith | /**
|
548 | 14ad7326 | pastith | * Make the file list visible.
|
549 | 14ad7326 | pastith | */
|
550 | 14ad7326 | pastith | public void showFileList() { |
551 | 18a508ee | fstamatelopoulos | fileList.updateFileCache(false, true /*clear selection*/); |
552 | a52ea5e4 | pastith | inner.selectTab(0);
|
553 | a52ea5e4 | pastith | } |
554 | a52ea5e4 | pastith | |
555 | a52ea5e4 | pastith | /**
|
556 | a52ea5e4 | pastith | * Make the file list visible.
|
557 | 8c999b8c | Natasa Kapravelou | *
|
558 | 9ac50c9e | pastith | * @param update
|
559 | a52ea5e4 | pastith | */
|
560 | a52ea5e4 | pastith | public void showFileList(boolean update) { |
561 | c018c4de | pastith | TreeItem currentFolder = getFolders().getCurrent(); |
562 | c018c4de | pastith | if (currentFolder != null) { |
563 | c018c4de | pastith | List<FileResource> files = null; |
564 | c018c4de | pastith | Object cachedObject = currentFolder.getUserObject();
|
565 | c018c4de | pastith | if (cachedObject instanceof FolderResource) { |
566 | c018c4de | pastith | FolderResource folder = (FolderResource) cachedObject; |
567 | c018c4de | pastith | files = folder.getFiles(); |
568 | c018c4de | pastith | } else if (cachedObject instanceof TrashResource) { |
569 | c018c4de | pastith | TrashResource folder = (TrashResource) cachedObject; |
570 | c018c4de | pastith | files = folder.getFiles(); |
571 | c018c4de | pastith | } |
572 | c018c4de | pastith | if (files != null) |
573 | c018c4de | pastith | getFileList().setFiles(files); |
574 | c018c4de | pastith | } |
575 | 18a508ee | fstamatelopoulos | fileList.updateFileCache(update, true /*clear selection*/); |
576 | 14ad7326 | pastith | inner.selectTab(0);
|
577 | 14ad7326 | pastith | } |
578 | 14ad7326 | pastith | |
579 | 14ad7326 | pastith | /**
|
580 | 14ad7326 | pastith | * Make the search results visible.
|
581 | 8c999b8c | Natasa Kapravelou | *
|
582 | 14ad7326 | pastith | * @param query the search query string
|
583 | 14ad7326 | pastith | */
|
584 | 14ad7326 | pastith | public void showSearchResults(String query) { |
585 | a52ea5e4 | pastith | searchResults.updateFileCache(query); |
586 | b3c6d52e | fstamatelopoulos | searchResults.updateCurrentlyShowingStats(); |
587 | 14ad7326 | pastith | inner.selectTab(2);
|
588 | 14ad7326 | pastith | } |
589 | 14ad7326 | pastith | |
590 | 14ad7326 | pastith | /**
|
591 | 14ad7326 | pastith | * Display the 'loading' indicator.
|
592 | 14ad7326 | pastith | */
|
593 | 14ad7326 | pastith | public void showLoadingIndicator() { |
594 | 12231a24 | Panagiotis Astithas | topPanel.getLoading().setVisible(true);
|
595 | 14ad7326 | pastith | } |
596 | 14ad7326 | pastith | |
597 | 14ad7326 | pastith | /**
|
598 | 14ad7326 | pastith | * Hide the 'loading' indicator.
|
599 | 14ad7326 | pastith | */
|
600 | 14ad7326 | pastith | public void hideLoadingIndicator() { |
601 | 12231a24 | Panagiotis Astithas | topPanel.getLoading().setVisible(false);
|
602 | 14ad7326 | pastith | } |
603 | 14ad7326 | pastith | |
604 | 14ad7326 | pastith | /**
|
605 | 14ad7326 | pastith | * A native JavaScript method to reach out to the browser's window and
|
606 | 14ad7326 | pastith | * invoke its resizeTo() method.
|
607 | 14ad7326 | pastith | *
|
608 | 14ad7326 | pastith | * @param x the new width
|
609 | 14ad7326 | pastith | * @param y the new height
|
610 | 14ad7326 | pastith | */
|
611 | 14ad7326 | pastith | public static native void resizeTo(int x, int y) /*-{ |
612 | 06b48563 | Natasa Kapravelou | $wnd.resizeTo(x,y);
|
613 | 06b48563 | Natasa Kapravelou | }-*/;
|
614 | 14ad7326 | pastith | |
615 | 14ad7326 | pastith | /**
|
616 | 14ad7326 | pastith | * A helper method that returns true if the user's list is currently visible
|
617 | 14ad7326 | pastith | * and false if it is hidden.
|
618 | 14ad7326 | pastith | *
|
619 | 14ad7326 | pastith | * @return true if the user list is visible
|
620 | 14ad7326 | pastith | */
|
621 | 14ad7326 | pastith | public boolean isUserListVisible() { |
622 | 14ad7326 | pastith | return inner.getTabBar().getSelectedTab() == 1; |
623 | 14ad7326 | pastith | } |
624 | 14ad7326 | pastith | |
625 | 14ad7326 | pastith | /**
|
626 | 14ad7326 | pastith | * Display an error message.
|
627 | 14ad7326 | pastith | *
|
628 | 14ad7326 | pastith | * @param msg the message to display
|
629 | 14ad7326 | pastith | */
|
630 | 14ad7326 | pastith | public void displayError(String msg) { |
631 | 14ad7326 | pastith | messagePanel.displayError(msg); |
632 | 14ad7326 | pastith | } |
633 | 14ad7326 | pastith | |
634 | 14ad7326 | pastith | /**
|
635 | 14ad7326 | pastith | * Display a warning message.
|
636 | 14ad7326 | pastith | *
|
637 | 14ad7326 | pastith | * @param msg the message to display
|
638 | 14ad7326 | pastith | */
|
639 | 14ad7326 | pastith | public void displayWarning(String msg) { |
640 | 14ad7326 | pastith | messagePanel.displayWarning(msg); |
641 | 14ad7326 | pastith | } |
642 | 14ad7326 | pastith | |
643 | 14ad7326 | pastith | /**
|
644 | 14ad7326 | pastith | * Display an informational message.
|
645 | 14ad7326 | pastith | *
|
646 | 14ad7326 | pastith | * @param msg the message to display
|
647 | 14ad7326 | pastith | */
|
648 | 14ad7326 | pastith | public void displayInformation(String msg) { |
649 | 14ad7326 | pastith | messagePanel.displayInformation(msg); |
650 | 14ad7326 | pastith | } |
651 | 14ad7326 | pastith | |
652 | 14ad7326 | pastith | /**
|
653 | 14ad7326 | pastith | * Retrieve the folders.
|
654 | 14ad7326 | pastith | *
|
655 | 14ad7326 | pastith | * @return the folders
|
656 | 14ad7326 | pastith | */
|
657 | 14ad7326 | pastith | public Folders getFolders() {
|
658 | 14ad7326 | pastith | return folders;
|
659 | 14ad7326 | pastith | } |
660 | 14ad7326 | pastith | |
661 | 14ad7326 | pastith | /**
|
662 | 14ad7326 | pastith | * Retrieve the search.
|
663 | 14ad7326 | pastith | *
|
664 | 14ad7326 | pastith | * @return the search
|
665 | 14ad7326 | pastith | */
|
666 | 14ad7326 | pastith | Search getSearch() { |
667 | 14ad7326 | pastith | return search;
|
668 | 14ad7326 | pastith | } |
669 | 14ad7326 | pastith | |
670 | 14ad7326 | pastith | /**
|
671 | 14ad7326 | pastith | * Retrieve the currentSelection.
|
672 | 14ad7326 | pastith | *
|
673 | 14ad7326 | pastith | * @return the currentSelection
|
674 | 14ad7326 | pastith | */
|
675 | 14ad7326 | pastith | public Object getCurrentSelection() { |
676 | 14ad7326 | pastith | return currentSelection;
|
677 | 14ad7326 | pastith | } |
678 | 14ad7326 | pastith | |
679 | 14ad7326 | pastith | /**
|
680 | 14ad7326 | pastith | * Modify the currentSelection.
|
681 | 14ad7326 | pastith | *
|
682 | 14ad7326 | pastith | * @param newCurrentSelection the currentSelection to set
|
683 | 14ad7326 | pastith | */
|
684 | 14ad7326 | pastith | public void setCurrentSelection(Object newCurrentSelection) { |
685 | 14ad7326 | pastith | currentSelection = newCurrentSelection; |
686 | 14ad7326 | pastith | } |
687 | 14ad7326 | pastith | |
688 | 14ad7326 | pastith | /**
|
689 | 14ad7326 | pastith | * Retrieve the groups.
|
690 | 14ad7326 | pastith | *
|
691 | 14ad7326 | pastith | * @return the groups
|
692 | 14ad7326 | pastith | */
|
693 | 14ad7326 | pastith | public Groups getGroups() {
|
694 | 14ad7326 | pastith | return groups;
|
695 | 14ad7326 | pastith | } |
696 | 14ad7326 | pastith | |
697 | 14ad7326 | pastith | /**
|
698 | 14ad7326 | pastith | * Retrieve the fileList.
|
699 | 14ad7326 | pastith | *
|
700 | 14ad7326 | pastith | * @return the fileList
|
701 | 14ad7326 | pastith | */
|
702 | 14ad7326 | pastith | public FileList getFileList() {
|
703 | 14ad7326 | pastith | return fileList;
|
704 | 14ad7326 | pastith | } |
705 | 14ad7326 | pastith | |
706 | 8c999b8c | Natasa Kapravelou | public SearchResults getSearchResults() {
|
707 | 14ad7326 | pastith | return searchResults;
|
708 | 14ad7326 | pastith | } |
709 | 9ac50c9e | pastith | |
710 | 14ad7326 | pastith | /**
|
711 | 14ad7326 | pastith | * Retrieve the topPanel.
|
712 | 14ad7326 | pastith | *
|
713 | 14ad7326 | pastith | * @return the topPanel
|
714 | 14ad7326 | pastith | */
|
715 | 14ad7326 | pastith | TopPanel getTopPanel() { |
716 | 14ad7326 | pastith | return topPanel;
|
717 | 14ad7326 | pastith | } |
718 | 14ad7326 | pastith | |
719 | 14ad7326 | pastith | /**
|
720 | 14ad7326 | pastith | * Retrieve the clipboard.
|
721 | 14ad7326 | pastith | *
|
722 | 14ad7326 | pastith | * @return the clipboard
|
723 | 14ad7326 | pastith | */
|
724 | 14ad7326 | pastith | public Clipboard getClipboard() { |
725 | 14ad7326 | pastith | return clipboard;
|
726 | 14ad7326 | pastith | } |
727 | 14ad7326 | pastith | |
728 | 8c999b8c | Natasa Kapravelou | public StatusPanel getStatusPanel() {
|
729 | 14ad7326 | pastith | return statusPanel;
|
730 | 14ad7326 | pastith | } |
731 | 14ad7326 | pastith | |
732 | d333ebbc | Panagiotis Astithas | /**
|
733 | d333ebbc | Panagiotis Astithas | * Retrieve the userDetailsPanel.
|
734 | d333ebbc | Panagiotis Astithas | *
|
735 | d333ebbc | Panagiotis Astithas | * @return the userDetailsPanel
|
736 | d333ebbc | Panagiotis Astithas | */
|
737 | d333ebbc | Panagiotis Astithas | public UserDetailsPanel getUserDetailsPanel() {
|
738 | d333ebbc | Panagiotis Astithas | return userDetailsPanel;
|
739 | d333ebbc | Panagiotis Astithas | } |
740 | d333ebbc | Panagiotis Astithas | |
741 | 14ad7326 | pastith | /**
|
742 | 14ad7326 | pastith | * Retrieve the dragController.
|
743 | 14ad7326 | pastith | *
|
744 | 14ad7326 | pastith | * @return the dragController
|
745 | 14ad7326 | pastith | */
|
746 | 14ad7326 | pastith | public PickupDragController getDragController() {
|
747 | 14ad7326 | pastith | return dragController;
|
748 | 14ad7326 | pastith | } |
749 | 14ad7326 | pastith | |
750 | 8c999b8c | Natasa Kapravelou | public String getToken() { |
751 | 14ad7326 | pastith | return token;
|
752 | 14ad7326 | pastith | } |
753 | 14ad7326 | pastith | |
754 | 3ef7b691 | Dimitris Routsis | public String getWebDAVPassword() { |
755 | 3ef7b691 | Dimitris Routsis | return webDAVPassword;
|
756 | 3ef7b691 | Dimitris Routsis | } |
757 | 3ef7b691 | Dimitris Routsis | |
758 | 8c999b8c | Natasa Kapravelou | public void removeGlassPanel() { |
759 | 14ad7326 | pastith | glassPanel.removeFromParent(); |
760 | 14ad7326 | pastith | } |
761 | 14ad7326 | pastith | |
762 | a52ea5e4 | pastith | /**
|
763 | a52ea5e4 | pastith | * Retrieve the currentUserResource.
|
764 | a52ea5e4 | pastith | *
|
765 | a52ea5e4 | pastith | * @return the currentUserResource
|
766 | a52ea5e4 | pastith | */
|
767 | a52ea5e4 | pastith | public UserResource getCurrentUserResource() {
|
768 | a52ea5e4 | pastith | return currentUserResource;
|
769 | a52ea5e4 | pastith | } |
770 | a52ea5e4 | pastith | |
771 | d333ebbc | Panagiotis Astithas | /**
|
772 | d333ebbc | Panagiotis Astithas | * Modify the currentUserResource.
|
773 | d333ebbc | Panagiotis Astithas | *
|
774 | d333ebbc | Panagiotis Astithas | * @param newUser the new currentUserResource
|
775 | d333ebbc | Panagiotis Astithas | */
|
776 | d333ebbc | Panagiotis Astithas | public void setCurrentUserResource(UserResource newUser) { |
777 | d333ebbc | Panagiotis Astithas | currentUserResource = newUser; |
778 | d333ebbc | Panagiotis Astithas | } |
779 | d333ebbc | Panagiotis Astithas | |
780 | 18cd8128 | fstamatelopoulos | public static native void preventIESelection() /*-{ |
781 | 06b48563 | Natasa Kapravelou | $doc.body.onselectstart = function () { return false; };
|
782 | 06b48563 | Natasa Kapravelou | }-*/;
|
783 | 18cd8128 | fstamatelopoulos | |
784 | 18cd8128 | fstamatelopoulos | public static native void enableIESelection() /*-{ |
785 | 06b48563 | Natasa Kapravelou | if ($doc.body.onselectstart != null)
|
786 | 06b48563 | Natasa Kapravelou | $doc.body.onselectstart = null;
|
787 | 06b48563 | Natasa Kapravelou | }-*/;
|
788 | 18cd8128 | fstamatelopoulos | |
789 | bbad17b4 | pastith | /**
|
790 | bbad17b4 | pastith | * @return the absolute path of the API root URL
|
791 | bbad17b4 | pastith | */
|
792 | bbad17b4 | pastith | public String getApiPath() { |
793 | bbad17b4 | pastith | Configuration conf = (Configuration) GWT.create(Configuration.class); |
794 | bbad17b4 | pastith | return GWT.getModuleBaseURL() + conf.apiPath();
|
795 | bbad17b4 | pastith | } |
796 | bbad17b4 | pastith | |
797 | 3ef7b691 | Dimitris Routsis | public void refreshWebDAVPassword() { |
798 | 3ef7b691 | Dimitris Routsis | Configuration conf = (Configuration) GWT.create(Configuration.class); |
799 | 3ef7b691 | Dimitris Routsis | String domain = Window.Location.getHostName(); |
800 | 3ef7b691 | Dimitris Routsis | String path = Window.Location.getPath(); |
801 | 3ef7b691 | Dimitris Routsis | String cookie = conf.webdavCookie();
|
802 | 3ef7b691 | Dimitris Routsis | webDAVPassword = Cookies.getCookie(cookie); |
803 | 3ef7b691 | Dimitris Routsis | Cookies.setCookie(cookie, "", null, domain, path, false); |
804 | 3ef7b691 | Dimitris Routsis | } |
805 | 8c550474 | Natasa Kapravelou | |
806 | 0174fdb2 | Natasa Kapravelou | /**
|
807 | 1510f141 | Giannis Koutsoubos | * Convert server date to local time according to browser timezone
|
808 | 1510f141 | Giannis Koutsoubos | * and format it according to localized pattern.
|
809 | 1510f141 | Giannis Koutsoubos | * Time is always formatted to 24hr format.
|
810 | 1510f141 | Giannis Koutsoubos | * NB: This assumes that server runs in UTC timezone. Otherwise
|
811 | 1510f141 | Giannis Koutsoubos | * we would need to adjust for server time offset as well.
|
812 | 1510f141 | Giannis Koutsoubos | *
|
813 | 1510f141 | Giannis Koutsoubos | * @param date
|
814 | 1510f141 | Giannis Koutsoubos | * @return String
|
815 | 1510f141 | Giannis Koutsoubos | */
|
816 | 1510f141 | Giannis Koutsoubos | public static String formatLocalDateTime(Date date) { |
817 | 1510f141 | Giannis Koutsoubos | Date convertedDate = new Date(date.getTime() - date.getTimezoneOffset()); |
818 | 1510f141 | Giannis Koutsoubos | final DateTimeFormat dateFormatter = DateTimeFormat.getShortDateFormat();
|
819 | 1510f141 | Giannis Koutsoubos | final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm"); |
820 | 1510f141 | Giannis Koutsoubos | String datePart = dateFormatter.format(convertedDate);
|
821 | 1510f141 | Giannis Koutsoubos | String timePart = timeFormatter.format(convertedDate);
|
822 | 1510f141 | Giannis Koutsoubos | return datePart + " " + timePart; |
823 | 1510f141 | Giannis Koutsoubos | } |
824 | 1510f141 | Giannis Koutsoubos | |
825 | 1510f141 | Giannis Koutsoubos | /**
|
826 | 98b59163 | Natasa Kapravelou | * History support for folder navigation
|
827 | 2487ac7b | Natasa Kapravelou | * adds a new browser history entry
|
828 | 2487ac7b | Natasa Kapravelou | *
|
829 | 0174fdb2 | Natasa Kapravelou | * @param key
|
830 | 0174fdb2 | Natasa Kapravelou | */
|
831 | 98b59163 | Natasa Kapravelou | public void updateHistory(String key){ |
832 | 8c550474 | Natasa Kapravelou | // Replace any whitespace of the initial string to "+"
|
833 | 2487ac7b | Natasa Kapravelou | // String result = key.replaceAll("\\s","+");
|
834 | 8c550474 | Natasa Kapravelou | // Add a new browser history entry.
|
835 | 2487ac7b | Natasa Kapravelou | // History.newItem(result);
|
836 | 2487ac7b | Natasa Kapravelou | History.newItem(key); |
837 | 0174fdb2 | Natasa Kapravelou | } |
838 | df9802b9 | Natasa Kapravelou | |
839 | df9802b9 | Natasa Kapravelou | /**
|
840 | df9802b9 | Natasa Kapravelou | * This method examines the token input and add a "/" at the end in case it's omitted.
|
841 | df9802b9 | Natasa Kapravelou | * This happens only in Files/trash/, Files/shared/, Files/others.
|
842 | df9802b9 | Natasa Kapravelou | *
|
843 | df9802b9 | Natasa Kapravelou | * @param tokenInput
|
844 | df9802b9 | Natasa Kapravelou | * @return the formated token with a "/" at the end or the same tokenInput parameter
|
845 | df9802b9 | Natasa Kapravelou | */
|
846 | df9802b9 | Natasa Kapravelou | |
847 | f47d99c4 | Natasa Kapravelou | private String handleSpecialFolderNames(String tokenInput){ |
848 | df9802b9 | Natasa Kapravelou | List<String> pathsToCheck = Arrays.asList("Files/trash", "Files/shared", "Files/others"); |
849 | df9802b9 | Natasa Kapravelou | if(pathsToCheck.contains(tokenInput))
|
850 | df9802b9 | Natasa Kapravelou | return tokenInput + "/"; |
851 | df9802b9 | Natasa Kapravelou | return tokenInput;
|
852 | df9802b9 | Natasa Kapravelou | |
853 | df9802b9 | Natasa Kapravelou | } |
854 | 4315bcc5 | Panagiotis Astithas | |
855 | 4315bcc5 | Panagiotis Astithas | /**
|
856 | 8b79a1c8 | Natasa Kapravelou | * Reject illegal resource names, like '.' or '..' or slashes '/'.
|
857 | 4315bcc5 | Panagiotis Astithas | */
|
858 | 4315bcc5 | Panagiotis Astithas | static boolean isValidResourceName(String name) { |
859 | 8b79a1c8 | Natasa Kapravelou | if (".".equals(name) || "..".equals(name) || name.contains("/")) |
860 | 4315bcc5 | Panagiotis Astithas | return false; |
861 | 4315bcc5 | Panagiotis Astithas | return true; |
862 | 4315bcc5 | Panagiotis Astithas | } |
863 | 4315bcc5 | Panagiotis Astithas | |
864 | 9ab5db6d | Natasa Kapravelou | public void putUserToMap(String _userName, String _userFullName){ |
865 | 9ab5db6d | Natasa Kapravelou | userFullNameMap.put(_userName, _userFullName); |
866 | 9ab5db6d | Natasa Kapravelou | } |
867 | 9ab5db6d | Natasa Kapravelou | |
868 | 9ab5db6d | Natasa Kapravelou | public String findUserFullName(String _userName){ |
869 | 9ab5db6d | Natasa Kapravelou | return userFullNameMap.get(_userName);
|
870 | 9ab5db6d | Natasa Kapravelou | } |
871 | 9ab5db6d | Natasa Kapravelou | |
872 | 4bf05cad | Natasa Kapravelou | public String getUserFullName(String _userName) { |
873 | 41fbadbc | Natasa Kapravelou | if (GSS.get().findUserFullName(_userName) == null) |
874 | 41fbadbc | Natasa Kapravelou | //if there is no userFullName found then the map fills with the given _userName,
|
875 | 41fbadbc | Natasa Kapravelou | //so userFullName = _userName
|
876 | 4bf05cad | Natasa Kapravelou | GSS.get().putUserToMap(_userName, _userName); |
877 | 41fbadbc | Natasa Kapravelou | else if(GSS.get().findUserFullName(_userName).indexOf('@') != -1){ |
878 | 41fbadbc | Natasa Kapravelou | //if the userFullName = _userName the GetUserCommand updates the userFullName in the map
|
879 | 4bf05cad | Natasa Kapravelou | GetUserCommand guc = new GetUserCommand(_userName);
|
880 | 4bf05cad | Natasa Kapravelou | guc.execute(); |
881 | 4bf05cad | Natasa Kapravelou | } |
882 | 4bf05cad | Natasa Kapravelou | return GSS.get().findUserFullName(_userName);
|
883 | ce2716a9 | Natasa Kapravelou | } |
884 | 14ad7326 | pastith | } |