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