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