Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java @ 2924:60c375173263
Minor refactoring.
flys-client/trunk@4806 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 27 Jun 2012 06:52:54 +0000 |
parents | 51ed89b754ae |
children | b7e93531322f |
comparison
equal
deleted
inserted
replaced
2923:43e0f6d96206 | 2924:60c375173263 |
---|---|
66 implements ClickHandler | 66 implements ClickHandler |
67 { | 67 { |
68 /** The interface that provides i18n messages. */ | 68 /** The interface that provides i18n messages. */ |
69 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 69 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
70 | 70 |
71 /** Name of the main data item to be fed. */ | 71 /** Part of name of the main data item to be fed. */ |
72 public static final String POINT_DATA = "manualpoints.data"; | 72 public static final String POINT_DATA = "manualpoints.data"; |
73 // TODO with separate point sets in multiple diagrams, we might need | |
74 // different POINT_DATA-names (e.g. one per diagram). | |
75 | 73 |
76 /** When we chaged something, we need a RedrawRequest(Handler). */ | 74 /** When we chaged something, we need a RedrawRequest(Handler). */ |
77 protected RedrawRequestHandler redrawRequestHandler; | 75 protected RedrawRequestHandler redrawRequestHandler; |
78 | 76 |
79 /** The collection */ | 77 /** The collection */ |
93 /** UUID of artifact to feed. */ | 91 /** UUID of artifact to feed. */ |
94 protected String uuid; | 92 protected String uuid; |
95 | 93 |
96 /** Name of the outputmode, important when feeding data. */ | 94 /** Name of the outputmode, important when feeding data. */ |
97 protected String outputModeName; | 95 protected String outputModeName; |
96 | |
97 /** Name of the point data item. */ | |
98 protected String pointDataItemName; | |
98 | 99 |
99 | 100 |
100 /** | 101 /** |
101 * Setup editor dialog. | 102 * Setup editor dialog. |
102 * @param collection The collection to use. | 103 * @param collection The collection to use. |
105 RedrawRequestHandler handler, String outputModeName | 106 RedrawRequestHandler handler, String outputModeName |
106 ) { | 107 ) { |
107 this.collection = collection; | 108 this.collection = collection; |
108 this.redrawRequestHandler = handler; | 109 this.redrawRequestHandler = handler; |
109 this.outputModeName = outputModeName; | 110 this.outputModeName = outputModeName; |
111 this.pointDataItemName = outputModeName + "." + POINT_DATA; | |
110 init(); | 112 init(); |
111 } | 113 } |
112 | 114 |
113 | 115 |
114 /** Searches collection for first artifact to serve (manual) point data. */ | 116 /** Searches collection for first artifact to serve (manual) point data. */ |
116 // TODO Need to be more picky (different points in different diagrams) | 118 // TODO Need to be more picky (different points in different diagrams) |
117 int size = collection.getItemLength(); | 119 int size = collection.getItemLength(); |
118 | 120 |
119 for (int i = 0; i < size; i++) { | 121 for (int i = 0; i < size; i++) { |
120 CollectionItem item = collection.getItem(i); | 122 CollectionItem item = collection.getItem(i); |
121 String dataValue = (String) item.getData().get(outputModeName | 123 String dataValue = (String) item.getData().get(pointDataItemName); |
122 + "." + POINT_DATA); | |
123 if (dataValue != null) { | 124 if (dataValue != null) { |
124 // Found it. | 125 // Found it. |
125 uuid = item.identifier(); | 126 uuid = item.identifier(); |
126 return uuid; | 127 return uuid; |
127 } | 128 } |
298 findManualPointsUUID(); | 299 findManualPointsUUID(); |
299 CollectionItem item = collection.getItem(uuid); | 300 CollectionItem item = collection.getItem(uuid); |
300 | 301 |
301 // Add points to grid. | 302 // Add points to grid. |
302 if (item != null) { | 303 if (item != null) { |
303 String jsonData = item.getData().get(outputModeName + "." + POINT_DATA); | 304 // TODO store this from findPointUUID instead (we touched these). |
305 String jsonData = item.getData().get(pointDataItemName); | |
304 JSONArray jsonArray = (JSONArray) JSONParser.parse(jsonData); | 306 JSONArray jsonArray = (JSONArray) JSONParser.parse(jsonData); |
305 for (int i = 0; i < jsonArray.size(); i++) { | 307 for (int i = 0; i < jsonArray.size(); i++) { |
306 JSONArray point = (JSONArray) jsonArray.get(i); | 308 JSONArray point = (JSONArray) jsonArray.get(i); |
307 listGrid.addData(pointRecordFromJSON(point)); | 309 listGrid.addData(pointRecordFromJSON(point)); |
308 } | 310 } |
387 if(isDialogValid()) { | 389 if(isDialogValid()) { |
388 // Feed JSON-encoded content of listgrid. | 390 // Feed JSON-encoded content of listgrid. |
389 JSONArray list = jsonArrayFromListGrid(); | 391 JSONArray list = jsonArrayFromListGrid(); |
390 | 392 |
391 Data[] feedData = new Data[] { | 393 Data[] feedData = new Data[] { |
392 DefaultData.createSimpleStringData(outputModeName + "." + POINT_DATA, | 394 DefaultData.createSimpleStringData(pointDataItemName, |
393 list.toString()) | 395 list.toString()) |
394 }; | 396 }; |
395 | 397 |
396 feedService.feed( | 398 feedService.feed( |
397 Config.getInstance().getLocale(), | 399 Config.getInstance().getLocale(), |