Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/CollectionView.java @ 9150:23945061daec
gigantic refactoring: exporter, result, results
to support multiple jaspers -> collisions
author | gernotbelger |
---|---|
date | Thu, 14 Jun 2018 16:56:31 +0200 |
parents | 28df64078f27 |
children | abf14917be32 |
comparison
equal
deleted
inserted
replaced
9149:5be112fba832 | 9150:23945061daec |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.client.client.ui; | 9 package org.dive4elements.river.client.client.ui; |
10 | 10 |
11 import com.google.gwt.core.client.GWT; | 11 import java.util.ArrayList; |
12 | 12 import java.util.HashMap; |
13 import com.google.gwt.user.client.rpc.AsyncCallback; | 13 import java.util.List; |
14 | 14 import java.util.Map; |
15 import com.smartgwt.client.util.SC; | 15 import java.util.Set; |
16 | 16 import java.util.Stack; |
17 import com.smartgwt.client.widgets.Window; | |
18 | |
19 import com.smartgwt.client.widgets.events.CloseClickEvent; | |
20 import com.smartgwt.client.widgets.events.CloseClickHandler; | |
21 | |
22 import com.smartgwt.client.widgets.layout.Layout; | |
23 import com.smartgwt.client.widgets.layout.VLayout; | |
24 | |
25 import com.smartgwt.client.widgets.tab.TabSet; | |
26 | |
27 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; | |
28 | 17 |
29 import org.dive4elements.river.client.client.Config; | 18 import org.dive4elements.river.client.client.Config; |
30 import org.dive4elements.river.client.client.FLYS; | 19 import org.dive4elements.river.client.client.FLYS; |
31 import org.dive4elements.river.client.client.FLYSConstants; | 20 import org.dive4elements.river.client.client.FLYSConstants; |
32 | |
33 import org.dive4elements.river.client.client.event.CollectionChangeEvent; | 21 import org.dive4elements.river.client.client.event.CollectionChangeEvent; |
34 import org.dive4elements.river.client.client.event.CollectionChangeHandler; | 22 import org.dive4elements.river.client.client.event.CollectionChangeHandler; |
35 import org.dive4elements.river.client.client.event.HasCollectionChangeHandlers; | 23 import org.dive4elements.river.client.client.event.HasCollectionChangeHandlers; |
36 import org.dive4elements.river.client.client.event.HasOutputModesChangeHandlers; | 24 import org.dive4elements.river.client.client.event.HasOutputModesChangeHandlers; |
37 import org.dive4elements.river.client.client.event.OutputModesChangeEvent; | 25 import org.dive4elements.river.client.client.event.OutputModesChangeEvent; |
38 import org.dive4elements.river.client.client.event.OutputModesChangeHandler; | 26 import org.dive4elements.river.client.client.event.OutputModesChangeHandler; |
39 import org.dive4elements.river.client.client.event.ParameterChangeEvent; | 27 import org.dive4elements.river.client.client.event.ParameterChangeEvent; |
40 import org.dive4elements.river.client.client.event.ParameterChangeHandler; | 28 import org.dive4elements.river.client.client.event.ParameterChangeHandler; |
41 | |
42 import org.dive4elements.river.client.client.services.AddArtifactService; | 29 import org.dive4elements.river.client.client.services.AddArtifactService; |
43 import org.dive4elements.river.client.client.services.AddArtifactServiceAsync; | 30 import org.dive4elements.river.client.client.services.AddArtifactServiceAsync; |
44 import org.dive4elements.river.client.client.services.ArtifactService; | 31 import org.dive4elements.river.client.client.services.ArtifactService; |
45 import org.dive4elements.river.client.client.services.ArtifactServiceAsync; | 32 import org.dive4elements.river.client.client.services.ArtifactServiceAsync; |
46 import org.dive4elements.river.client.client.services.CollectionAttributeService; | 33 import org.dive4elements.river.client.client.services.CollectionAttributeService; |
49 import org.dive4elements.river.client.client.services.CreateCollectionServiceAsync; | 36 import org.dive4elements.river.client.client.services.CreateCollectionServiceAsync; |
50 import org.dive4elements.river.client.client.services.DescribeCollectionService; | 37 import org.dive4elements.river.client.client.services.DescribeCollectionService; |
51 import org.dive4elements.river.client.client.services.DescribeCollectionServiceAsync; | 38 import org.dive4elements.river.client.client.services.DescribeCollectionServiceAsync; |
52 import org.dive4elements.river.client.client.services.LoadArtifactService; | 39 import org.dive4elements.river.client.client.services.LoadArtifactService; |
53 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync; | 40 import org.dive4elements.river.client.client.services.LoadArtifactServiceAsync; |
54 | |
55 import org.dive4elements.river.client.shared.model.Artifact; | 41 import org.dive4elements.river.client.shared.model.Artifact; |
56 import org.dive4elements.river.client.shared.model.ArtifactDescription; | 42 import org.dive4elements.river.client.shared.model.ArtifactDescription; |
57 import org.dive4elements.river.client.shared.model.Collection; | 43 import org.dive4elements.river.client.shared.model.Collection; |
58 import org.dive4elements.river.client.shared.model.ExportMode; | 44 import org.dive4elements.river.client.shared.model.ExportMode; |
59 import org.dive4elements.river.client.shared.model.OutputMode; | 45 import org.dive4elements.river.client.shared.model.OutputMode; |
60 import org.dive4elements.river.client.shared.model.Recommendation; | 46 import org.dive4elements.river.client.shared.model.Recommendation; |
61 import org.dive4elements.river.client.shared.model.ReportMode; | 47 import org.dive4elements.river.client.shared.model.ReportMode; |
62 import org.dive4elements.river.client.shared.model.User; | 48 import org.dive4elements.river.client.shared.model.User; |
63 | 49 |
64 import java.util.ArrayList; | 50 import com.google.gwt.core.client.GWT; |
65 import java.util.HashMap; | 51 import com.google.gwt.user.client.rpc.AsyncCallback; |
66 import java.util.List; | 52 import com.smartgwt.client.util.SC; |
67 import java.util.Map; | 53 import com.smartgwt.client.widgets.Window; |
68 import java.util.Set; | 54 import com.smartgwt.client.widgets.events.CloseClickEvent; |
69 import java.util.Stack; | 55 import com.smartgwt.client.widgets.events.CloseClickHandler; |
70 | 56 import com.smartgwt.client.widgets.layout.Layout; |
57 import com.smartgwt.client.widgets.layout.VLayout; | |
58 import com.smartgwt.client.widgets.tab.TabSet; | |
59 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; | |
71 | 60 |
72 /** | 61 /** |
73 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 62 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
74 */ | 63 */ |
75 public class CollectionView | 64 public class CollectionView extends Window implements CollectionChangeHandler, HasCollectionChangeHandlers, OutputModesChangeHandler, HasOutputModesChangeHandlers, ParameterChangeHandler, CloseClickHandler { |
76 extends Window | |
77 implements CollectionChangeHandler, HasCollectionChangeHandlers, | |
78 OutputModesChangeHandler, HasOutputModesChangeHandlers, | |
79 ParameterChangeHandler, CloseClickHandler | |
80 { | |
81 /** The ArtifactService used to communicate with the Artifact server. */ | 65 /** The ArtifactService used to communicate with the Artifact server. */ |
82 protected CreateCollectionServiceAsync createCollectionService = | 66 protected CreateCollectionServiceAsync createCollectionService = GWT.create(CreateCollectionService.class); |
83 GWT.create(CreateCollectionService.class); | |
84 | 67 |
85 /** The ArtifactService used to communicate with the Artifact server. */ | 68 /** The ArtifactService used to communicate with the Artifact server. */ |
86 protected ArtifactServiceAsync createArtifactService = | 69 protected ArtifactServiceAsync createArtifactService = GWT.create(ArtifactService.class); |
87 GWT.create(ArtifactService.class); | |
88 | 70 |
89 /** The AddArtifactService used to add an artifact to a collection. */ | 71 /** The AddArtifactService used to add an artifact to a collection. */ |
90 protected AddArtifactServiceAsync addArtifactService = | 72 protected AddArtifactServiceAsync addArtifactService = GWT.create(AddArtifactService.class); |
91 GWT.create(AddArtifactService.class); | |
92 | 73 |
93 /** The DescribeCollectionService used to update the existing collection. */ | 74 /** The DescribeCollectionService used to update the existing collection. */ |
94 protected DescribeCollectionServiceAsync describeCollectionService = | 75 protected DescribeCollectionServiceAsync describeCollectionService = GWT.create(DescribeCollectionService.class); |
95 GWT.create(DescribeCollectionService.class); | 76 |
96 | 77 protected CollectionAttributeServiceAsync updater = GWT.create(CollectionAttributeService.class); |
97 protected CollectionAttributeServiceAsync updater = | 78 |
98 GWT.create(CollectionAttributeService.class); | 79 /** The LoadArtifactService used to load recommendations */ |
99 | 80 protected LoadArtifactServiceAsync loadArtifactService = GWT.create(LoadArtifactService.class); |
100 /** The LoadArtifactService used to load recommendations*/ | |
101 protected LoadArtifactServiceAsync loadArtifactService = | |
102 GWT.create(LoadArtifactService.class); | |
103 | 81 |
104 /** The message class that provides i18n strings. */ | 82 /** The message class that provides i18n strings. */ |
105 protected FLYSConstants messages = GWT.create(FLYSConstants.class); | 83 protected FLYSConstants messages = GWT.create(FLYSConstants.class); |
106 | 84 |
107 /** The FLYS instance used to call services. */ | 85 /** The FLYS instance used to call services. */ |
135 | 113 |
136 protected int artifactsQueue; | 114 protected int artifactsQueue; |
137 protected int recommendationQueue; | 115 protected int recommendationQueue; |
138 protected Stack<Recommendation> newRecommendations; | 116 protected Stack<Recommendation> newRecommendations; |
139 | 117 |
140 /** Values for fix analysis charts*/ | 118 /** Values for fix analysis charts */ |
141 protected double currentKm; | 119 protected double currentKm; |
142 protected double minKm; | 120 protected double minKm; |
143 protected double maxKm; | 121 protected double maxKm; |
144 protected double steps; | 122 protected double steps; |
145 | 123 |
146 /** | 124 /** |
147 * This constructor creates a new CollectionView that is used to display the | 125 * This constructor creates a new CollectionView that is used to display the |
148 * <i>collection</i>. | 126 * <i>collection</i>. |
149 */ | 127 */ |
150 public CollectionView(FLYS flys) { | 128 public CollectionView(final FLYS flys) { |
151 this.flys = flys; | 129 this.flys = flys; |
152 this.tabs = new TabSet(); | 130 this.tabs = new TabSet(); |
153 this.outputTabs = new HashMap<String, OutputTab>(); | 131 this.outputTabs = new HashMap<String, OutputTab>(); |
154 this.handlers = new ArrayList<CollectionChangeHandler>(); | 132 this.handlers = new ArrayList<CollectionChangeHandler>(); |
155 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); | 133 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); |
156 this.layout = new VLayout(); | 134 this.layout = new VLayout(); |
157 this.parameterList = new ParameterList( | 135 this.parameterList = new ParameterList(flys, this, this.messages.new_project()); |
158 flys, this, messages.new_project()); | 136 this.artifactsQueue = 0; |
159 this.artifactsQueue = 0; | |
160 this.recommendationQueue = 0; | 137 this.recommendationQueue = 0; |
161 this.newRecommendations = new Stack<Recommendation>(); | 138 this.newRecommendations = new Stack<Recommendation>(); |
162 | 139 |
163 this.currentKm = -1d; | 140 this.currentKm = -1d; |
164 this.minKm = -1d; | 141 this.minKm = -1d; |
165 this.maxKm = -1d; | 142 this.maxKm = -1d; |
166 this.steps = -1d; | 143 this.steps = -1d; |
167 | 144 |
168 addCollectionChangeHandler(this); | 145 addCollectionChangeHandler(this); |
169 addCollectionChangeHandler(parameterList); | 146 addCollectionChangeHandler(this.parameterList); |
170 addCollectionChangeHandler(flys); | 147 addCollectionChangeHandler(flys); |
171 addOutputModesChangeHandler(this); | 148 addOutputModesChangeHandler(this); |
172 addOutputModesChangeHandler(parameterList); | 149 addOutputModesChangeHandler(this.parameterList); |
173 addCloseClickHandler(this); | 150 addCloseClickHandler(this); |
174 | 151 |
175 parameterList.addParameterChangeHandler(this); | 152 this.parameterList.addParameterChangeHandler(this); |
176 | 153 |
177 init(); | 154 init(); |
178 } | 155 } |
179 | 156 |
180 /** | 157 /** |
181 * @param collection The collection to be displayed. | 158 * @param collection |
182 */ | 159 * The collection to be displayed. |
183 public CollectionView(FLYS flys, Collection collection, Artifact artifact) { | 160 */ |
184 this.flys = flys; | 161 public CollectionView(final FLYS flys, final Collection collection, final Artifact artifact) { |
185 this.artifact = artifact; | 162 this.flys = flys; |
186 this.collection = collection; | 163 this.artifact = artifact; |
187 this.tabs = new TabSet(); | 164 this.collection = collection; |
188 this.outputTabs = new HashMap<String, OutputTab>(); | 165 this.tabs = new TabSet(); |
189 this.handlers = new ArrayList<CollectionChangeHandler>(); | 166 this.outputTabs = new HashMap<String, OutputTab>(); |
190 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); | 167 this.handlers = new ArrayList<CollectionChangeHandler>(); |
191 this.layout = new VLayout(); | 168 this.outHandlers = new ArrayList<OutputModesChangeHandler>(); |
169 this.layout = new VLayout(); | |
192 | 170 |
193 this.currentKm = -1d; | 171 this.currentKm = -1d; |
194 this.minKm = -1d; | 172 this.minKm = -1d; |
195 this.maxKm = -1d; | 173 this.maxKm = -1d; |
196 this.steps = -1d; | 174 this.steps = -1d; |
197 | 175 |
198 if (artifact != null) { | 176 if (artifact != null) { |
199 this.parameterList = new ParameterList( | 177 this.parameterList = new ParameterList(flys, this, |
200 flys, | 178 // FIXME: literally every information about the artifact is transported from the server side |
201 this, | 179 // but... the international name is resolved client-side.... Instead also transport the description of the artifact and |
202 // FIXME: literally every information about the artifact is transported from the server side | 180 // use it! |
203 // but... the international name is resolved client-side.... Instead also transport the description of the artifact and use it! | 181 // FIXME: the same holds for a very few other international strings (e.g. names of facets used in Tabs) |
204 // FIXME: the same holds for a very few other international strings (e.g. names of facets used in Tabs) | 182 this.messages.getString(artifact.getName()), artifact); |
205 messages.getString(artifact.getName()), | 183 } else { |
206 artifact); | 184 this.parameterList = new ParameterList(flys, this, this.messages.new_project()); |
207 } | 185 } |
208 else { | 186 |
209 this.parameterList = new ParameterList( | 187 this.artifactsQueue = 0; |
210 flys, this, messages.new_project()); | |
211 } | |
212 | |
213 this.artifactsQueue = 0; | |
214 this.newRecommendations = new Stack<Recommendation>(); | 188 this.newRecommendations = new Stack<Recommendation>(); |
215 | 189 |
216 addCollectionChangeHandler(this); | 190 addCollectionChangeHandler(this); |
217 addCollectionChangeHandler(parameterList); | 191 addCollectionChangeHandler(this.parameterList); |
218 addCollectionChangeHandler(flys); | 192 addCollectionChangeHandler(flys); |
219 addOutputModesChangeHandler(this); | 193 addOutputModesChangeHandler(this); |
220 addOutputModesChangeHandler(parameterList); | 194 addOutputModesChangeHandler(this.parameterList); |
221 addCloseClickHandler(this); | 195 addCloseClickHandler(this); |
222 | 196 |
223 parameterList.addParameterChangeHandler(this); | 197 this.parameterList.addParameterChangeHandler(this); |
224 | 198 |
225 init(); | 199 init(); |
226 | 200 |
227 setCollection(collection); | 201 setCollection(collection); |
228 | 202 |
229 if (artifact != null) { | 203 if (artifact != null) { |
230 setArtifact(artifact); | 204 setArtifact(artifact); |
231 } | 205 } |
232 } | 206 } |
233 | |
234 | 207 |
235 /** | 208 /** |
236 * This method handles the initial layout stuff. | 209 * This method handles the initial layout stuff. |
237 */ | 210 */ |
238 protected void init() { | 211 protected void init() { |
239 setWidth(1010); | 212 setWidth(1010); |
240 setHeight(700); | 213 setHeight(700); |
241 | 214 |
242 setMaximized(true); | 215 setMaximized(true); |
243 | 216 |
244 layout.setWidth100(); | 217 this.layout.setWidth100(); |
245 | 218 |
246 setCanDragReposition(true); | 219 setCanDragReposition(true); |
247 setCanDragResize(true); | 220 setCanDragResize(true); |
248 setShowMaximizeButton(true); | 221 setShowMaximizeButton(true); |
249 setKeepInParentRect(true); | 222 setKeepInParentRect(true); |
250 | 223 |
251 setTitle(""); | 224 setTitle(""); |
252 | 225 |
253 addItem(layout); | 226 addItem(this.layout); |
254 | 227 |
255 layout.addMember(tabs); | 228 this.layout.addMember(this.tabs); |
256 tabs.addTab(parameterList); | 229 this.tabs.addTab(this.parameterList); |
257 } | 230 } |
258 | 231 |
259 protected FLYS getFlys() { | 232 protected FLYS getFlys() { |
260 return flys; | 233 return this.flys; |
261 } | 234 } |
262 | |
263 | 235 |
264 /** | 236 /** |
265 * This method registers a new CollectionChangeHandler. | 237 * This method registers a new CollectionChangeHandler. |
266 * | 238 * |
267 * @param handler The new CollectionChangeHandler. | 239 * @param handler |
240 * The new CollectionChangeHandler. | |
268 */ | 241 */ |
269 @Override | 242 @Override |
270 public void addCollectionChangeHandler(CollectionChangeHandler handler) { | 243 public void addCollectionChangeHandler(final CollectionChangeHandler handler) { |
271 if (handler != null) { | 244 if (handler != null) { |
272 handlers.add(handler); | 245 this.handlers.add(handler); |
273 } | 246 } |
274 } | 247 } |
275 | |
276 | 248 |
277 /** | 249 /** |
278 * This method registers a new OutputModesChangeHandler. | 250 * This method registers a new OutputModesChangeHandler. |
279 * | 251 * |
280 * @param handler The new OutputModesChangeHandler. | 252 * @param handler |
253 * The new OutputModesChangeHandler. | |
281 */ | 254 */ |
282 @Override | 255 @Override |
283 public void addOutputModesChangeHandler(OutputModesChangeHandler handler) { | 256 public void addOutputModesChangeHandler(final OutputModesChangeHandler handler) { |
284 if (handler != null) { | 257 if (handler != null) { |
285 outHandlers.add(handler); | 258 this.outHandlers.add(handler); |
286 } | 259 } |
287 } | 260 } |
288 | |
289 | 261 |
290 /** | 262 /** |
291 * This method calls the <code>onValueChange()</code> method of all | 263 * This method calls the <code>onValueChange()</code> method of all |
292 * registered ValueChangeHanders. | 264 * registered ValueChangeHanders. |
293 */ | 265 */ |
294 protected void fireCollectionChangeEvent( | 266 protected void fireCollectionChangeEvent(final Collection old, final Collection newCol) { |
295 Collection old, Collection newCol) | 267 for (final CollectionChangeHandler handler : this.handlers) { |
296 { | |
297 for (CollectionChangeHandler handler: handlers) { | |
298 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); | 268 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); |
299 } | 269 } |
300 } | 270 } |
301 | 271 |
302 | 272 protected void fireOutputModesChangeEvent(final OutputMode[] outputs) { |
303 protected void fireOutputModesChangeEvent(OutputMode[] outputs) { | 273 if (this.collection == null) { |
304 if (collection == null) { | |
305 return; | 274 return; |
306 } | 275 } |
307 | 276 |
308 for (OutputModesChangeHandler handler: outHandlers) { | 277 for (final OutputModesChangeHandler handler : this.outHandlers) { |
309 handler.onOutputModesChange(new OutputModesChangeEvent(outputs)); | 278 handler.onOutputModesChange(new OutputModesChangeEvent(outputs)); |
310 } | 279 } |
311 } | 280 } |
312 | |
313 | 281 |
314 /** Disables input, grey out, show spinning wheel of joy. */ | 282 /** Disables input, grey out, show spinning wheel of joy. */ |
315 public void lockUI() { | 283 public void lockUI() { |
316 lockScreen = ScreenLock.lockUI(layout, lockScreen); | 284 this.lockScreen = ScreenLock.lockUI(this.layout, this.lockScreen); |
317 } | 285 } |
318 | |
319 | 286 |
320 /** Enable input, remove grey, remove spinning wheel of joy. */ | 287 /** Enable input, remove grey, remove spinning wheel of joy. */ |
321 public void unlockUI() { | 288 public void unlockUI() { |
322 ScreenLock.unlockUI(layout, lockScreen); | 289 ScreenLock.unlockUI(this.layout, this.lockScreen); |
323 } | 290 } |
324 | |
325 | 291 |
326 /** | 292 /** |
327 * This method returns true, if the Collection is new and no plugins has | 293 * This method returns true, if the Collection is new and no plugins has |
328 * been chosen. | 294 * been chosen. |
329 * | 295 * |
330 * @return true, if the Collection is new. | 296 * @return true, if the Collection is new. |
331 */ | 297 */ |
332 public boolean isNew() { | 298 public boolean isNew() { |
333 return collection.hasItems(); | 299 return this.collection.hasItems(); |
334 } | 300 } |
335 | |
336 | 301 |
337 /** | 302 /** |
338 * Returns the artifact that is used for the parameterization. | 303 * Returns the artifact that is used for the parameterization. |
339 * | 304 * |
340 * @return the artifact that is used for the parameterization. | 305 * @return the artifact that is used for the parameterization. |
341 */ | 306 */ |
342 public Artifact getArtifact() { | 307 public Artifact getArtifact() { |
343 return artifact; | 308 return this.artifact; |
344 } | 309 } |
345 | |
346 | 310 |
347 public User getUser() { | 311 public User getUser() { |
348 return getFlys().getCurrentUser(); | 312 return getFlys().getCurrentUser(); |
349 } | 313 } |
350 | 314 |
351 | |
352 /** | 315 /** |
353 * Set the current artifact that is the master of the parameterization. | 316 * Set the current artifact that is the master of the parameterization. |
354 * | 317 * |
355 * @param artifact The new artifact. | 318 * @param artifact |
356 */ | 319 * The new artifact. |
357 public void setArtifact(Artifact artifact) { | 320 */ |
321 public void setArtifact(final Artifact artifact) { | |
358 this.artifact = artifact; | 322 this.artifact = artifact; |
359 | 323 |
360 onArtifactChanged(artifact); | 324 onArtifactChanged(artifact); |
361 } | 325 } |
362 | 326 |
363 | 327 public void onArtifactChanged(final Artifact artifact) { |
364 public void onArtifactChanged(Artifact artifact) { | |
365 artifactChanged(); | 328 artifactChanged(); |
366 | 329 |
367 if (artifact.isInBackground()) { | 330 if (artifact.isInBackground()) { |
368 LoadingPanel p = new LoadingPanel(this, artifact); | 331 final LoadingPanel p = new LoadingPanel(this, artifact); |
369 p.addStepBackHandler(parameterList); | 332 p.addStepBackHandler(this.parameterList); |
370 } | 333 } |
371 } | 334 } |
372 | |
373 | 335 |
374 /** | 336 /** |
375 * Implements the onCollectionChange() method to do update the GUI after the | 337 * Implements the onCollectionChange() method to do update the GUI after the |
376 * parameterization has changed. | 338 * parameterization has changed. |
377 * | 339 * |
378 * @param event The ParameterChangeEvent. | 340 * @param event |
341 * The ParameterChangeEvent. | |
379 */ | 342 */ |
380 @Override | 343 @Override |
381 public void onParameterChange(ParameterChangeEvent event) { | 344 public void onParameterChange(final ParameterChangeEvent event) { |
382 GWT.log("CollectionView.onParameterChange"); | 345 GWT.log("CollectionView.onParameterChange"); |
383 setArtifact(event.getNewValue()); | 346 setArtifact(event.getNewValue()); |
384 } | 347 } |
385 | 348 |
386 | |
387 protected void artifactChanged() { | 349 protected void artifactChanged() { |
388 Collection c = getCollection(); | 350 final Collection c = getCollection(); |
389 | 351 |
390 if (c != null) { | 352 if (c != null) { |
391 loadCollection(c); | 353 loadCollection(c); |
392 } | 354 } else { |
393 else { | |
394 updateView(); | 355 updateView(); |
395 } | 356 } |
396 } | 357 } |
397 | 358 |
398 /** | 359 /** |
399 * Loads all information of a collection. | 360 * Loads all information of a collection. |
400 * If 'recommendations' present, load these. | 361 * If 'recommendations' present, load these. |
401 * @param c the Collection | 362 * |
402 */ | 363 * @param c |
403 private void loadCollection(Collection c) { | 364 * the Collection |
404 ArtifactDescription desc = getArtifact().getArtifactDescription(); | 365 */ |
366 private void loadCollection(final Collection c) { | |
367 final ArtifactDescription desc = getArtifact().getArtifactDescription(); | |
405 final Recommendation[] recom = desc.getRecommendations(); | 368 final Recommendation[] recom = desc.getRecommendations(); |
406 Config config = Config.getInstance(); | 369 final Config config = Config.getInstance(); |
407 String locale = config.getLocale(); | 370 final String locale = config.getLocale(); |
408 | 371 |
409 describeCollectionService.describe(c.identifier(), locale, | 372 this.describeCollectionService.describe(c.identifier(), locale, new AsyncCallback<Collection>() { |
410 new AsyncCallback<Collection>() { | 373 @Override |
411 @Override | 374 public void onFailure(final Throwable caught) { |
412 public void onFailure(Throwable caught) { | 375 GWT.log("Could not DESCRIBE collection."); |
413 GWT.log("Could not DESCRIBE collection."); | 376 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
414 SC.warn(FLYS.getExceptionString(messages, caught)); | 377 } |
415 } | 378 |
416 | 379 @Override |
417 @Override | 380 public void onSuccess(final Collection newCollection) { |
418 public void onSuccess(Collection newCollection) { | 381 GWT.log("Successfully DESCRIBED collection."); |
419 GWT.log("Successfully DESCRIBED collection."); | 382 boolean loaded = true; |
420 boolean loaded = true; | 383 for (final Recommendation r : recom) { |
421 for (Recommendation r: recom) { | 384 if (!newCollection.loadedRecommendation(r)) { |
422 if(!newCollection.loadedRecommendation(r)) { | 385 loaded = false; |
423 loaded = false; | |
424 } | |
425 } | |
426 if (!loaded) { | |
427 loadRecommendedArtifacts(recom); | |
428 } | |
429 else { | |
430 setCollection(newCollection); | |
431 } | 386 } |
432 } | 387 } |
433 } | 388 if (!loaded) { |
434 ); | 389 loadRecommendedArtifacts(recom); |
435 } | 390 } else { |
436 | 391 setCollection(newCollection); |
392 } | |
393 } | |
394 }); | |
395 } | |
437 | 396 |
438 /** | 397 /** |
439 * Returns the collection of displayed by this view. | 398 * Returns the collection of displayed by this view. |
440 * | 399 * |
441 * @return the collection of this view. | 400 * @return the collection of this view. |
442 */ | 401 */ |
443 public Collection getCollection() { | 402 public Collection getCollection() { |
444 return collection; | 403 return this.collection; |
445 } | 404 } |
446 | 405 |
447 | 406 protected void setCollection(final Collection collection) { |
448 protected void setCollection(Collection collection) { | |
449 setCollection(collection, false); | 407 setCollection(collection, false); |
450 } | 408 } |
451 | 409 |
452 | |
453 /** | 410 /** |
454 * Set the current collection. | 411 * Set the current collection. |
455 * | 412 * |
456 * @param collection The new collection. | 413 * @param collection |
457 * @param suppress Whether to fire a collectionchangeevent. | 414 * The new collection. |
458 */ | 415 * @param suppress |
459 protected void setCollection(Collection collection, boolean suppress) { | 416 * Whether to fire a collectionchangeevent. |
417 */ | |
418 protected void setCollection(final Collection collection, final boolean suppress) { | |
460 if (collection != null && this.collection == null) { | 419 if (collection != null && this.collection == null) { |
461 flys.getWorkspace().addView(collection.identifier(), this); | 420 this.flys.getWorkspace().addView(collection.identifier(), this); |
462 } | 421 } |
463 | 422 |
464 Collection tmp = this.collection; | 423 final Collection tmp = this.collection; |
465 this.collection = collection; | 424 this.collection = collection; |
466 | 425 |
467 setTitle(collection.getDisplayName()); | 426 setTitle(collection.getDisplayName()); |
468 | 427 |
469 if (!suppress) { | 428 if (!suppress) { |
470 fireCollectionChangeEvent(tmp, this.collection); | 429 fireCollectionChangeEvent(tmp, this.collection); |
471 } | 430 } |
472 } | 431 } |
473 | 432 |
474 | |
475 @Override | 433 @Override |
476 public void onCollectionChange(CollectionChangeEvent event) { | 434 public void onCollectionChange(final CollectionChangeEvent event) { |
477 if (artifactsQueue > 0) { | 435 if (this.artifactsQueue > 0) { |
478 GWT.log("Do not update UI because we are still loading Artifacts."); | 436 GWT.log("Do not update UI because we are still loading Artifacts."); |
479 return; | 437 return; |
480 } | 438 } |
481 | 439 |
482 Collection newCol = event.getNewValue(); | 440 final Collection newCol = event.getNewValue(); |
483 | 441 |
484 Map<String, OutputMode> outs = newCol.getOutputModes(); | 442 final Map<String, OutputMode> outs = newCol.getOutputModes(); |
485 | 443 |
486 Set<String> keys = outs.keySet(); | 444 final Set<String> keys = outs.keySet(); |
487 OutputMode[] prepared = new OutputMode[outs.size()]; | 445 final OutputMode[] prepared = new OutputMode[outs.size()]; |
488 | 446 |
489 int idx = 0; | 447 int idx = 0; |
490 for (String outname: keys) { | 448 for (final String outname : keys) { |
491 prepared[idx++] = outs.get(outname); | 449 prepared[idx++] = outs.get(outname); |
492 } | 450 } |
493 | 451 |
494 fireOutputModesChangeEvent(prepared); | 452 fireOutputModesChangeEvent(prepared); |
495 | 453 |
496 updateView(); | 454 updateView(); |
497 } | 455 } |
498 | 456 |
499 | |
500 @Override | 457 @Override |
501 public void onOutputModesChange(OutputModesChangeEvent event) { | 458 public void onOutputModesChange(final OutputModesChangeEvent event) { |
502 clearOutputTabs(); | 459 clearOutputTabs(); |
503 OutputMode[] outs = event.getOutputModes(); | 460 final OutputMode[] outs = event.getOutputModes(); |
504 | 461 |
505 if (outs == null) { | 462 if (outs == null) { |
506 return; | 463 return; |
507 } | 464 } |
508 | 465 |
509 boolean hasCSV = false; | 466 boolean hasCSV = false; |
510 | 467 |
511 for (OutputMode out: outs) { | 468 for (final OutputMode out : outs) { |
512 addOutputTab(out.getName(), out); | 469 addOutputTab(out.getName(), out); |
513 | 470 |
514 if (out instanceof ExportMode) { | 471 if (out instanceof ExportMode) { |
515 ExportMode export = (ExportMode) out; | 472 final ExportMode export = (ExportMode) out; |
516 | 473 |
517 if (export.getFacet("csv") != null) { | 474 if (export.getFacet("csv") != null) { |
518 hasCSV = true; | 475 hasCSV = true; |
519 } | 476 } |
520 } | 477 } |
521 } | 478 } |
522 | 479 |
523 if (!hasCSV) { | 480 if (!hasCSV) { |
524 parameterList.removeTable(); | 481 this.parameterList.removeTable(); |
525 } | 482 } |
526 } | 483 } |
527 | |
528 | 484 |
529 /** | 485 /** |
530 * Adds a new tab for the OutputMode <i>out</i>. | 486 * Adds a new tab for the OutputMode <i>out</i>. |
531 * | 487 * |
532 * @param name The name and title of the output. | 488 * @param name |
533 */ | 489 * The name and title of the output. |
534 protected void addOutputTab(String name, OutputMode out) { | 490 */ |
491 protected void addOutputTab(final String name, final OutputMode out) { | |
535 if (out instanceof ExportMode) { | 492 if (out instanceof ExportMode) { |
536 ExportMode export = (ExportMode) out; | 493 final ExportMode export = (ExportMode) out; |
537 | 494 |
538 if (export.getFacet("csv") != null && !parameterList.hasTable()) { | 495 if (export.getFacet("csv") != null && !this.parameterList.hasTable()) { |
539 TableDataPanel p = new TableDataPanel(); | 496 final TableDataPanel p = new TableDataPanel(); |
540 p.setUuid(collection.identifier()); | 497 p.setUuid(this.collection.identifier()); |
541 p.setName(out.getName()); | 498 p.setName(out.getName()); |
542 parameterList.setTable(p); | 499 this.parameterList.setTable(p); |
543 } | 500 } |
544 | 501 |
545 return; | 502 return; |
546 } | 503 } |
547 | 504 |
550 return; | 507 return; |
551 } | 508 } |
552 | 509 |
553 GWT.log("Add new output tab for '" + name + "'"); | 510 GWT.log("Add new output tab for '" + name + "'"); |
554 | 511 |
555 String title = messages.getString(name); | 512 final String title = this.messages.getString(name); |
556 OutputTab tab = out.createOutputTab(title, getCollection(), this); | 513 final OutputTab tab = out.createOutputTab(title, getCollection(), this); |
557 | 514 |
558 if (tab != null) { | 515 if (tab != null) { |
559 outputTabs.put(name, tab); | 516 this.outputTabs.put(name, tab); |
560 } | 517 } |
561 } | 518 } |
562 | |
563 | 519 |
564 /** | 520 /** |
565 * Removes all output mode tabs from tab bar. | 521 * Removes all output mode tabs from tab bar. |
566 */ | 522 */ |
567 protected void clearOutputTabs() { | 523 protected void clearOutputTabs() { |
568 GWT.log("Clear OutputTabs."); | 524 GWT.log("Clear OutputTabs."); |
569 | 525 |
570 int num = tabs.getNumTabs(); | 526 final int num = this.tabs.getNumTabs(); |
571 | 527 |
572 for (int i = num-1; i >= 1; i--) { | 528 for (int i = num - 1; i >= 1; i--) { |
573 tabs.removeTab(i); | 529 this.tabs.removeTab(i); |
574 } | 530 } |
575 | 531 |
576 outputTabs.clear(); | 532 this.outputTabs.clear(); |
577 } | 533 } |
578 | |
579 | 534 |
580 /** | 535 /** |
581 * Update the view (refresh the list of old and current data). | 536 * Update the view (refresh the list of old and current data). |
582 */ | 537 */ |
583 protected void updateView() { | 538 protected void updateView() { |
584 GWT.log("CollectionView.updateView()"); | 539 GWT.log("CollectionView.updateView()"); |
585 updateOutputTabs(); | 540 updateOutputTabs(); |
586 } | 541 } |
587 | 542 |
588 | |
589 /** | 543 /** |
590 * This method is used to update the tabs to show specific output modes. | 544 * This method is used to update the tabs to show specific output modes. |
591 */ | 545 */ |
592 protected void updateOutputTabs() { | 546 protected void updateOutputTabs() { |
593 GWT.log("Update output tabs."); | 547 GWT.log("Update output tabs."); |
594 if (outputTabs != null) { | 548 if (this.outputTabs != null) { |
595 Set<String> keys = outputTabs.keySet(); | 549 final Set<String> keys = this.outputTabs.keySet(); |
596 | 550 |
597 for (String key: keys) { | 551 for (final String key : keys) { |
598 tabs.addTab(outputTabs.get(key)); | 552 this.tabs.addTab(this.outputTabs.get(key)); |
599 } | 553 } |
600 } | 554 } |
601 } | 555 } |
602 | |
603 | 556 |
604 @Override | 557 @Override |
605 public void onCloseClick(CloseClickEvent event) { | 558 public void onCloseClick(final CloseClickEvent event) { |
606 if (collection != null) { | 559 if (this.collection != null) { |
607 if(artifact != null) { | 560 if (this.artifact != null) { |
608 flys.closeProject(collection.identifier()); | 561 this.flys.closeProject(this.collection.identifier()); |
609 } | 562 } else { |
610 else { | 563 this.flys.getProjectList().deleteCollection(this.collection); |
611 flys.getProjectList().deleteCollection(collection); | 564 } |
612 } | 565 } else { |
613 } | |
614 else { | |
615 hide(); | 566 hide(); |
616 destroy(); | 567 destroy(); |
617 } | 568 } |
618 } | 569 } |
619 | 570 |
620 | 571 public void addArtifactToCollection(final Artifact artifact) { |
621 public void addArtifactToCollection(Artifact artifact) { | 572 final Config config = Config.getInstance(); |
622 Config config = Config.getInstance(); | 573 final String locale = config.getLocale(); |
623 final String locale = config.getLocale(); | |
624 final Collection collection = getCollection(); | 574 final Collection collection = getCollection(); |
625 | 575 |
626 GWT.log("CollectionView.addArtifactToCollection " + collection); | 576 GWT.log("CollectionView.addArtifactToCollection " + collection); |
627 | 577 |
628 if (collection != null) { | 578 if (collection != null) { |
629 addArtifactService.add( | 579 this.addArtifactService.add(collection, artifact, locale, new AsyncCallback<Collection>() { |
630 collection, artifact, locale, | 580 @Override |
631 new AsyncCallback<Collection>() { | 581 public void onFailure(final Throwable caught) { |
632 @Override | 582 GWT.log("An error occured while adding artifact."); |
633 public void onFailure(Throwable caught) { | 583 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
634 GWT.log("An error occured while adding artifact."); | |
635 SC.warn(FLYS.getExceptionString(messages, caught)); | |
636 } | |
637 | |
638 @Override | |
639 public void onSuccess(Collection newCollection) { | |
640 GWT.log("Successfully added artifacts."); | |
641 setCollection(newCollection); | |
642 } | |
643 } | 584 } |
644 ); | 585 |
645 } | 586 @Override |
646 else { | 587 public void onSuccess(final Collection newCollection) { |
588 GWT.log("Successfully added artifacts."); | |
589 setCollection(newCollection); | |
590 } | |
591 }); | |
592 } else { | |
647 // Create new collection and add artifact. | 593 // Create new collection and add artifact. |
648 final Artifact art = artifact; | 594 final Artifact art = artifact; |
649 createCollectionService.create( | 595 this.createCollectionService.create(locale, this.flys.getCurrentUser().identifier(), new AsyncCallback<Collection>() { |
650 locale, | 596 @Override |
651 flys.getCurrentUser().identifier(), | 597 public void onFailure(final Throwable caught) { |
652 new AsyncCallback<Collection>() { | 598 GWT.log("Could not create the new collection."); |
653 @Override | 599 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
654 public void onFailure(Throwable caught) { | |
655 GWT.log("Could not create the new collection."); | |
656 SC.warn(FLYS.getExceptionString(messages, caught)); | |
657 } | |
658 | |
659 @Override | |
660 public void onSuccess(Collection collection) { | |
661 GWT.log("Successfully created a new collection."); | |
662 addArtifactService.add( | |
663 collection, art, locale, | |
664 new AsyncCallback<Collection>() { | |
665 @Override | |
666 public void onFailure(Throwable caught) { | |
667 GWT.log("An error occured while " | |
668 + "adding artifact."); | |
669 SC.warn(FLYS.getExceptionString( | |
670 messages, caught)); | |
671 } | |
672 | |
673 @Override | |
674 public void onSuccess( | |
675 Collection newCollection) { | |
676 GWT.log("Successfully added artifacts."); | |
677 setCollection(newCollection); | |
678 } | |
679 } | |
680 ); | |
681 } | |
682 } | 600 } |
683 ); | 601 |
684 } | 602 @Override |
685 } | 603 public void onSuccess(final Collection collection) { |
686 | 604 GWT.log("Successfully created a new collection."); |
605 CollectionView.this.addArtifactService.add(collection, art, locale, new AsyncCallback<Collection>() { | |
606 @Override | |
607 public void onFailure(final Throwable caught) { | |
608 GWT.log("An error occured while " + "adding artifact."); | |
609 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); | |
610 } | |
611 | |
612 @Override | |
613 public void onSuccess(final Collection newCollection) { | |
614 GWT.log("Successfully added artifacts."); | |
615 setCollection(newCollection); | |
616 } | |
617 }); | |
618 } | |
619 }); | |
620 } | |
621 } | |
687 | 622 |
688 protected void addRecommendationsToCollection() { | 623 protected void addRecommendationsToCollection() { |
689 Config config = Config.getInstance(); | 624 final Config config = Config.getInstance(); |
690 final String locale = config.getLocale(); | 625 final String locale = config.getLocale(); |
691 final Collection collection = getCollection(); | 626 final Collection collection = getCollection(); |
692 | 627 |
693 collection.addRecommendations(newRecommendations); | 628 collection.addRecommendations(this.newRecommendations); |
694 | 629 |
695 updater.update(collection, locale, | 630 this.updater.update(collection, locale, new AsyncCallback<Collection>() { |
696 new AsyncCallback<Collection>() { | 631 @Override |
697 @Override | 632 public void onFailure(final Throwable caught) { |
698 public void onFailure(Throwable caught) { | 633 CollectionView.this.newRecommendations.removeAllElements(); |
699 newRecommendations.removeAllElements(); | 634 setCollection(collection); |
700 setCollection(collection); | 635 |
701 | 636 GWT.log("An error occured while saving recommendations."); |
702 GWT.log("An error occured while saving recommendations."); | 637 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
703 SC.warn(FLYS.getExceptionString(messages, caught)); | 638 } |
704 } | 639 |
705 | 640 @Override |
706 @Override | 641 public void onSuccess(final Collection newCol) { |
707 public void onSuccess(Collection newCol) { | 642 GWT.log("Successfully saved recommendations."); |
708 GWT.log("Successfully saved recommendations."); | 643 CollectionView.this.newRecommendations.removeAllElements(); |
709 newRecommendations.removeAllElements(); | 644 setCollection(newCol); |
710 setCollection(newCol); | 645 } |
711 } | 646 }); |
712 } | 647 } |
713 ); | 648 |
714 } | 649 protected void loadRecommendedArtifacts(final Recommendation[] recommendations) { |
715 | 650 final Config config = Config.getInstance(); |
716 | 651 final String locale = config.getLocale(); |
717 protected void loadRecommendedArtifacts(Recommendation[] recommendations) { | |
718 Config config = Config.getInstance(); | |
719 final String locale = config.getLocale(); | |
720 final Collection collection = getCollection(); | 652 final Collection collection = getCollection(); |
721 | 653 |
722 Artifact masterArtifact = getArtifact(); | 654 final Artifact masterArtifact = getArtifact(); |
723 | 655 |
724 if (recommendations == null) { | 656 if (recommendations == null) { |
725 GWT.log("WARNING: Currently no recommendations."); | 657 GWT.log("WARNING: Currently no recommendations."); |
726 return; | 658 return; |
727 } | 659 } |
728 | 660 |
729 for (final Recommendation recommendation: recommendations) { | 661 for (final Recommendation recommendation : recommendations) { |
730 if (collection.loadedRecommendation(recommendation)) { | 662 if (collection.loadedRecommendation(recommendation)) { |
731 continue; | 663 continue; |
732 } | 664 } |
733 newRecommendations.push(recommendation); | 665 this.newRecommendations.push(recommendation); |
734 | 666 |
735 // XXX: UGLY! If no reference artifact given use uuid of | 667 // XXX: UGLY! If no reference artifact given use uuid of |
736 // current artifact as reference. | 668 // current artifact as reference. |
737 if (recommendation.getMasterArtifact() == null) { | 669 if (recommendation.getMasterArtifact() == null) { |
738 recommendation.setMasterArtifact(masterArtifact.getUuid()); | 670 recommendation.setMasterArtifact(masterArtifact.getUuid()); |
739 } | 671 } |
740 | 672 |
741 } | 673 } |
742 | 674 |
743 loadArtifactService.loadMany( | 675 this.loadArtifactService.loadMany(collection, recommendations, null, locale, new AsyncCallback<Artifact[]>() { |
744 collection, | 676 @Override |
745 recommendations, | 677 public void onFailure(final Throwable caught) { |
746 null, | 678 GWT.log("Error loading recommendations: " + caught.getMessage()); |
747 locale, | 679 SC.warn(FLYS.getExceptionString(CollectionView.this.messages, caught)); |
748 new AsyncCallback<Artifact[]>() { | 680 } |
749 @Override | 681 |
750 public void onFailure(Throwable caught) { | 682 @Override |
751 GWT.log("Error loading recommendations: " + | 683 public void onSuccess(final Artifact[] artifacts) { |
752 caught.getMessage()); | 684 GWT.log("Loaded artifacts: " + artifacts.length); |
753 SC.warn(FLYS.getExceptionString(messages, caught)); | 685 addRecommendationsToCollection(); |
754 } | 686 } |
755 | |
756 @Override | |
757 public void onSuccess(Artifact[] artifacts) { | |
758 GWT.log("Loaded artifacts: " + artifacts.length); | |
759 addRecommendationsToCollection(); | |
760 } | |
761 }); | 687 }); |
762 } | 688 } |
763 | 689 |
764 | 690 public void registerTabHandler(final TabSelectedHandler tse) { |
765 public void registerTabHandler(TabSelectedHandler tse) { | 691 this.tabs.addTabSelectedHandler(tse); |
766 tabs.addTabSelectedHandler(tse); | 692 } |
767 } | 693 |
768 | 694 public void setCurrentKm(final double currentKm) { |
769 | |
770 public void setCurrentKm(double currentKm) { | |
771 this.currentKm = currentKm; | 695 this.currentKm = currentKm; |
772 } | 696 } |
773 | 697 |
774 public double getCurrentKm() { | 698 public double getCurrentKm() { |
775 return this.currentKm; | 699 return this.currentKm; |
776 } | 700 } |
777 | 701 |
778 public void setMinKm(double km) { | 702 public void setMinKm(final double km) { |
779 this.minKm = km; | 703 this.minKm = km; |
780 } | 704 } |
781 | 705 |
782 public double getMinKm() { | 706 public double getMinKm() { |
783 return this.minKm; | 707 return this.minKm; |
784 } | 708 } |
785 | 709 |
786 public void setMaxKm(double km) { | 710 public void setMaxKm(final double km) { |
787 this.maxKm = km; | 711 this.maxKm = km; |
788 } | 712 } |
789 | 713 |
790 public double getMaxKm() { | 714 public double getMaxKm() { |
791 return this.maxKm; | 715 return this.maxKm; |
792 } | 716 } |
793 | 717 |
794 public void setSteps(double step) { | 718 public void setSteps(final double step) { |
795 this.steps = step; | 719 this.steps = step; |
796 } | 720 } |
797 | 721 |
798 public double getSteps() { | 722 public double getSteps() { |
799 return this.steps; | 723 return this.steps; |