comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageTwinPanel.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 36f52c80b7ac
children 28df64078f27
comparison
equal deleted inserted replaced
8855:d7c005e12af0 8856:5e38e2924c07
72 protected List<RecommendationPairRecord> removedPairs = 72 protected List<RecommendationPairRecord> removedPairs =
73 new ArrayList<RecommendationPairRecord>(); 73 new ArrayList<RecommendationPairRecord>();
74 74
75 /** Service handle to clone and add artifacts to collection. */ 75 /** Service handle to clone and add artifacts to collection. */
76 LoadArtifactServiceAsync loadArtifactService = GWT.create( 76 LoadArtifactServiceAsync loadArtifactService = GWT.create(
77 org.dive4elements.river.client.client.services.LoadArtifactService.class); 77 org.dive4elements.river.client.client.services
78 .LoadArtifactService.class);
78 79
79 /** Service to remove artifacts from collection. */ 80 /** Service to remove artifacts from collection. */
80 RemoveArtifactServiceAsync removeArtifactService = GWT.create( 81 RemoveArtifactServiceAsync removeArtifactService = GWT.create(
81 org.dive4elements.river.client.client.services.RemoveArtifactService.class); 82 org.dive4elements.river.client.client.services
83 .RemoveArtifactService.class);
82 84
83 85
84 public DatacageTwinPanel(User user) { 86 public DatacageTwinPanel(User user) {
85 super(); 87 super();
86 this.user = user; 88 this.user = user;
114 /** 116 /**
115 * Create a recommendation from a string representation of it. 117 * Create a recommendation from a string representation of it.
116 * @param from string in format as shown above. 118 * @param from string in format as shown above.
117 * @return recommendation from input string. 119 * @return recommendation from input string.
118 */ 120 */
119 public Recommendation createRecommendationFromString(String from, String factory) { 121 public Recommendation createRecommendationFromString(
122 String from,
123 String factory
124 ) {
120 // TODO Construct "real" filter. 125 // TODO Construct "real" filter.
121 String[] parts = unbracket(from).split(";"); 126 String[] parts = unbracket(from).split(";");
122 Recommendation.Filter filter = new Recommendation.Filter(); 127 Recommendation.Filter filter = new Recommendation.Filter();
123 Recommendation.Facet facet = new Recommendation.Facet( 128 Recommendation.Facet facet = new Recommendation.Facet(
124 parts[1], 129 parts[1],
158 } 163 }
159 } 164 }
160 165
161 166
162 /** 167 /**
163 * Creates the graphical representation and interaction widgets for the data. 168 * Creates the graphical representation and interaction widgets
169 * for the data.
164 * @param dataList the data. 170 * @param dataList the data.
165 * @return graphical representation and interaction widgets for data. 171 * @return graphical representation and interaction widgets for data.
166 */ 172 */
167 @Override 173 @Override
168 public Canvas create(DataList dataList) { 174 public Canvas create(DataList dataList) {
187 193
188 protected void populateGrid(DataList dataList, String factory) { 194 protected void populateGrid(DataList dataList, String factory) {
189 Data data = dataList.get(0); 195 Data data = dataList.get(0);
190 this.dataName = data.getLabel(); 196 this.dataName = data.getLabel();
191 for (int i = 0; i < dataList.size(); i++) { 197 for (int i = 0; i < dataList.size(); i++) {
192 if (dataList.get(i) != null && dataList.get(i).getItems() != null) { 198 if (dataList.get(i) != null
199 && dataList.get(i).getItems() != null
200 ) {
193 if (dataList.get(i).getItems() != null) { 201 if (dataList.get(i).getItems() != null) {
194 populateGridFromString( 202 populateGridFromString(
195 dataList.get(i).getItems()[0].getStringValue(), 203 dataList.get(i).getItems()[0].getStringValue(),
196 factory); 204 factory);
197 } 205 }
256 264
257 differencesList.addRecordClickHandler(new RecordClickHandler() { 265 differencesList.addRecordClickHandler(new RecordClickHandler() {
258 @Override 266 @Override
259 public void onRecordClick(final RecordClickEvent event) { 267 public void onRecordClick(final RecordClickEvent event) {
260 // Just handle remove-clicks 268 // Just handle remove-clicks
261 if(!event.getField().getName().equals(removeField.getName())) { 269 if(!event.getField().getName()
270 .equals(removeField.getName())
271 ) {
262 return; 272 return;
263 } 273 }
264 trackRemoved(event.getRecord()); 274 trackRemoved(event.getRecord());
265 event.getViewer().removeData(event.getRecord()); 275 event.getViewer().removeData(event.getRecord());
266 } 276 }
283 * Set factory of recommendation such that the correct artifacts will 293 * Set factory of recommendation such that the correct artifacts will
284 * be cloned for difference calculations. 294 * be cloned for difference calculations.
285 */ 295 */
286 public void adjustRecommendation(Recommendation recommendation) { 296 public void adjustRecommendation(Recommendation recommendation) {
287 // XXX: THIS IS AN EVIL HACK TO MAKE W-DIFFERENCES WORK AGAIN! 297 // XXX: THIS IS AN EVIL HACK TO MAKE W-DIFFERENCES WORK AGAIN!
288 // TODO: Throw all this code away and do it with server side recommendations! 298 // TODO: Throw all this code away and do it with server side
299 // recommendations!
289 recommendation.setTargetOut("w_differences"); 300 recommendation.setTargetOut("w_differences");
290 301
291 if (recommendation.getIDs() != null) { 302 if (recommendation.getIDs() != null) {
292 GWT.log("Setting staticwkms factory for rec with ID " 303 GWT.log("Setting staticwkms factory for rec with ID "
293 + recommendation.getIDs()); 304 + recommendation.getIDs());
348 all.add(r.getFirst()); 359 all.add(r.getFirst());
349 all.add(r.getSecond()); 360 all.add(r.getSecond());
350 } 361 }
351 } 362 }
352 363
353 final Recommendation[] toClone = ar.toArray(new Recommendation[ar.size()]); 364 final Recommendation[] toClone = ar.toArray(
354 final Recommendation[] toUse = all.toArray(new Recommendation[all.size()]); 365 new Recommendation[ar.size()]);
366 final Recommendation[] toUse = all.toArray(
367 new Recommendation[all.size()]);
355 368
356 // Find out whether "old" artifacts have to be removed. 369 // Find out whether "old" artifacts have to be removed.
357 List<String> artifactIdsToRemove = new ArrayList<String>(); 370 List<String> artifactIdsToRemove = new ArrayList<String>();
358 for (RecommendationPairRecord rp: this.removedPairs) { 371 for (RecommendationPairRecord rp: this.removedPairs) {
359 Recommendation first = rp.getFirst(); 372 Recommendation first = rp.getFirst();
360 Recommendation second = rp.getSecond(); 373 Recommendation second = rp.getSecond();
361 374
362 for (Recommendation recommendation: toUse) { 375 for (Recommendation recommendation: toUse) {
363 if (first != null && first.getIDs().equals(recommendation.getIDs())) { 376 if (first != null
377 && first.getIDs().equals(recommendation.getIDs())
378 ) {
364 first = null; 379 first = null;
365 } 380 }
366 if (second != null && second.getIDs().equals(recommendation.getIDs())) { 381 if (second != null
382 && second.getIDs().equals(recommendation.getIDs())
383 ) {
367 second = null; 384 second = null;
368 } 385 }
369 386
370 if (first == null && second == null) { 387 if (first == null && second == null) {
371 break; 388 break;
467 return new Data[] { new DefaultData( 484 return new Data[] { new DefaultData(
468 dataName, null, null, new DataItem[] {item}) }; 485 dataName, null, null, new DataItem[] {item}) };
469 } 486 }
470 487
471 488
472 protected String createDataString(String artifact, Recommendation recommendation) { 489 protected String createDataString(
490 String artifact,
491 Recommendation recommendation
492 ) {
473 return createDataString(artifact, recommendation, "staticwkms"); 493 return createDataString(artifact, recommendation, "staticwkms");
474 } 494 }
475 495
476 /** 496 /**
477 * Creates part of the String that encodes minuend or subtrahend. 497 * Creates part of the String that encodes minuend or subtrahend.

http://dive4elements.wald.intevation.org