Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DatacageWidget.java @ 9227:84397da33d17
Allow to control specific behaviour in TwinDatacagePanel
Implemented client logic of 'intelligent datacage filtering' for SINFO
author | gernotbelger |
---|---|
date | Wed, 04 Jul 2018 18:28:08 +0200 |
parents | e3c2ae1887e8 |
children |
comparison
equal
deleted
inserted
replaced
9226:83aee0942eae | 9227:84397da33d17 |
---|---|
46 // TODO: refactor, extract ~DataCageGrid | 46 // TODO: refactor, extract ~DataCageGrid |
47 /** | 47 /** |
48 * Display tree of, for example, previous calculations and allows | 48 * Display tree of, for example, previous calculations and allows |
49 * selection in order to access/clone these. | 49 * selection in order to access/clone these. |
50 */ | 50 */ |
51 public class DatacageWidget extends VLayout { | 51 public final class DatacageWidget extends VLayout { |
52 | |
53 private static final FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
54 | |
52 public static final int MAX_OPEN = 30; | 55 public static final int MAX_OPEN = 30; |
53 | 56 |
54 public interface DatacageFilter { | 57 public interface DatacageFilter { |
55 boolean accept(DataCageNode node); | 58 boolean accept(DataCageNode node); |
56 } | 59 } |
60 public boolean accept(final DataCageNode node) { | 63 public boolean accept(final DataCageNode node) { |
61 return true; | 64 return true; |
62 } | 65 } |
63 }; | 66 }; |
64 | 67 |
68 public static final DatacageFilter ACCEPT_NONE_FILTER = new DatacageFilter() { | |
69 @Override | |
70 public boolean accept(final DataCageNode node) { | |
71 return false; | |
72 } | |
73 }; | |
74 | |
65 private final MetaDataServiceAsync metaDataService = GWT.create(MetaDataService.class); | 75 private final MetaDataServiceAsync metaDataService = GWT.create(MetaDataService.class); |
66 | |
67 private final FLYSConstants messages = GWT.create(FLYSConstants.class); | |
68 | 76 |
69 private final List<DatacageHandler> handlers = new ArrayList<DatacageHandler>(); | 77 private final List<DatacageHandler> handlers = new ArrayList<DatacageHandler>(); |
70 | 78 |
71 private final List<DatacageDoubleClickHandler> doubleHandlers = new ArrayList<DatacageDoubleClickHandler>(); | 79 private final List<DatacageDoubleClickHandler> doubleHandlers = new ArrayList<DatacageDoubleClickHandler>(); |
72 | 80 |
103 this.treeGrid.setWidth100(); | 111 this.treeGrid.setWidth100(); |
104 this.treeGrid.setHeight100(); | 112 this.treeGrid.setHeight100(); |
105 this.treeGrid.setShowRoot(false); | 113 this.treeGrid.setShowRoot(false); |
106 this.treeGrid.setNodeIcon("[SKIN]/../blank.gif"); | 114 this.treeGrid.setNodeIcon("[SKIN]/../blank.gif"); |
107 this.treeGrid.setShowConnectors(true); | 115 this.treeGrid.setShowConnectors(true); |
108 this.treeGrid.setLoadingMessage(this.messages.databasket_loading()); | 116 this.treeGrid.setLoadingMessage(MSG.databasket_loading()); |
109 this.treeGrid.setLoadingDataMessage(this.messages.databasket_loading()); | 117 this.treeGrid.setLoadingDataMessage(MSG.databasket_loading()); |
110 | 118 this.treeGrid.setEmptyMessage(MSG.databasket_empty()); |
111 // FIXME: other message | |
112 this.treeGrid.setEmptyMessage(this.messages.databasket_loading()); | |
113 | 119 |
114 this.treeGrid.setHoverMoveWithMouse(true); | 120 this.treeGrid.setHoverMoveWithMouse(true); |
115 this.treeGrid.setCanHover(true); | 121 this.treeGrid.setCanHover(true); |
116 this.treeGrid.setShowHover(true); | 122 this.treeGrid.setShowHover(true); |
117 this.treeGrid.setHoverOpacity(75); | 123 this.treeGrid.setHoverOpacity(75); |
155 | 161 |
156 if (this.dcTree != null) | 162 if (this.dcTree != null) |
157 updateTree(this.dcTree); | 163 updateTree(this.dcTree); |
158 } | 164 } |
159 | 165 |
166 public TreeGrid getTreeGrid() { | |
167 return this.treeGrid; | |
168 } | |
169 | |
160 /** Disable input, show spinning wheel of joy. */ | 170 /** Disable input, show spinning wheel of joy. */ |
161 private void lockUI() { | 171 private void lockUI() { |
162 this.lockScreen = ScreenLock.lockUI(this, this.lockScreen); | 172 this.lockScreen = ScreenLock.lockUI(this, this.lockScreen); |
163 } | 173 } |
164 | 174 |
209 this.handlers.remove(handler); | 219 this.handlers.remove(handler); |
210 } | 220 } |
211 | 221 |
212 public ToLoad getSelection() { | 222 public ToLoad getSelection() { |
213 // Reset content of toLoads. | 223 // Reset content of toLoads. |
224 | |
225 // FIXME: bad... instead we should react to selection events and update toLoad in this way. | |
226 | |
214 this.toLoad = new ToLoad(); | 227 this.toLoad = new ToLoad(); |
215 | 228 |
216 if (this.treeGrid == null) { | 229 if (this.treeGrid == null) |
217 return this.toLoad; | 230 return this.toLoad; |
218 } | |
219 | 231 |
220 final ListGridRecord[] selection = this.treeGrid.getSelectedRecords(); | 232 final ListGridRecord[] selection = this.treeGrid.getSelectedRecords(); |
221 | 233 |
222 if (selection != null) { | 234 if (selection != null) { |
223 for (final ListGridRecord record : selection) { | 235 for (final ListGridRecord record : selection) { |
276 fireToLoad(); | 288 fireToLoad(); |
277 } | 289 } |
278 } | 290 } |
279 | 291 |
280 private Button createPlusButton() { | 292 private Button createPlusButton() { |
281 final Button plusBtn = new Button(this.messages.datacageAdd()); | 293 final Button plusBtn = new Button(MSG.datacageAdd()); |
282 plusBtn.addClickHandler(new ClickHandler() { | 294 plusBtn.addClickHandler(new ClickHandler() { |
283 @Override | 295 @Override |
284 public void onClick(final ClickEvent event) { | 296 public void onClick(final ClickEvent event) { |
285 plusClicked(); | 297 plusClicked(); |
286 } | 298 } |
310 /** | 322 /** |
311 * Adds to toLoad, from info in node. | 323 * Adds to toLoad, from info in node. |
312 * Afterwards, add all children of node to stack to parse (next time | 324 * Afterwards, add all children of node to stack to parse (next time |
313 * collectToLoads is called). | 325 * collectToLoads is called). |
314 */ | 326 */ |
315 private void collectToLoads(TreeNode node) { | 327 private void collectToLoads(final TreeNode root1) { |
316 final Stack<TreeNode> stack = new Stack<TreeNode>(); | 328 final Stack<TreeNode> stack = new Stack<TreeNode>(); |
317 | 329 |
318 stack.push(node); | 330 stack.push(root1); |
319 | 331 |
320 while (!stack.isEmpty()) { | 332 while (!stack.isEmpty()) { |
321 node = stack.pop(); | 333 final TreeNode node = stack.pop(); |
322 final String factory = node.getAttribute("factory"); | 334 final String factory = node.getAttribute("factory"); |
323 if (factory != null) { // we need at least a factory | 335 if (factory != null) { // we need at least a factory |
324 final String artifact = node.getAttribute("artifact-id"); | 336 final String artifact = node.getAttribute("artifact-id"); |
325 final String out = node.getAttribute("out"); | 337 final String out = node.getAttribute("out"); |
326 final String name = node.getAttribute("facet"); | 338 final String name = node.getAttribute("facet"); |
382 this.tree.destroy(); | 394 this.tree.destroy(); |
383 | 395 |
384 updateTree(this.dcTree); | 396 updateTree(this.dcTree); |
385 } | 397 } |
386 | 398 |
387 private void updateTree(final DataCageTree data) { | 399 private void updateTree(final DataCageTree dcData) { |
388 | 400 |
389 this.tree = new Tree(); | 401 this.tree = new Tree(); |
390 this.tree.setModelType(TreeModelType.CHILDREN); | 402 this.tree.setModelType(TreeModelType.CHILDREN); |
391 this.tree.setNameProperty("name"); | 403 this.tree.setNameProperty("name"); |
392 this.tree.setIdField("id"); | 404 this.tree.setIdField("id"); |
393 this.tree.setChildrenProperty("children-nodes"); | 405 this.tree.setChildrenProperty("children-nodes"); |
394 this.tree.setShowRoot(false); | 406 this.tree.setShowRoot(false); |
395 | 407 |
396 final IdGenerator idGenerator = new IdGenerator(); | 408 final IdGenerator idGenerator = new IdGenerator(); |
397 final DataCageNode dcRoot = data.getRoot(); | 409 final DataCageNode dcRoot = dcData.getRoot(); |
398 final TreeNode root = buildRecursiveChildren(dcRoot, idGenerator); | 410 final TreeNode root = buildRecursiveChildren(dcRoot, idGenerator); |
399 if (root != null) { | 411 if (root != null) { |
400 this.tree.setRoot(root); | 412 this.tree.setRoot(root); |
401 | 413 |
402 // FIXME: why is this necessary? an it only happens for the first level... | 414 // FIXME: why is this necessary? an it only happens for the first level... |
426 public int current() { | 438 public int current() { |
427 return this.current; | 439 return this.current; |
428 } | 440 } |
429 } // class IdGenerator | 441 } // class IdGenerator |
430 | 442 |
431 private String i18n(String s) { | 443 private String i18n(final String s) { |
432 if (!(s.startsWith("${") && s.endsWith("}"))) { | 444 if (!(s.startsWith("${") && s.endsWith("}"))) |
433 return s; | 445 return s; |
434 } | 446 |
435 | 447 final String sub = s.substring(2, s.length() - 1); |
436 s = s.substring(2, s.length() - 1); | |
437 | 448 |
438 try { | 449 try { |
439 return this.messages.getString(s); | 450 return MSG.getString(sub); |
440 } | 451 } |
441 catch (final MissingResourceException mre) { | 452 catch (final MissingResourceException mre) { |
442 GWT.log("cannot find i18n for + '" + s + "'"); | 453 GWT.log("cannot find i18n for + '" + sub + "'", mre); |
443 return s; | 454 return sub; |
444 } | 455 } |
445 } | 456 } |
446 | 457 |
447 private TreeNode buildRecursiveChildren(final DataCageNode node, final IdGenerator idGenerator) { | 458 private TreeNode buildRecursiveChildren(final DataCageNode node, final IdGenerator idGenerator) { |
448 | 459 |