| ... |
... |
@@ -22,10 +22,17 @@ package fr.ird.observe.client.datasource.editor.api.content.actions.move.layout; |
|
22
|
22
|
* #L%
|
|
23
|
23
|
*/
|
|
24
|
24
|
|
|
25
|
|
-import fr.ird.observe.client.ClientUIContextApplicationComponent;
|
|
|
25
|
+import fr.ird.observe.client.WithClientUIContextApi;
|
|
26
|
26
|
import fr.ird.observe.client.datasource.editor.api.DataSourceEditor;
|
|
27
|
27
|
import fr.ird.observe.client.datasource.editor.api.ObserveKeyStrokesEditorApi;
|
|
|
28
|
+import fr.ird.observe.client.datasource.editor.api.config.TreeConfigUI;
|
|
|
29
|
+import fr.ird.observe.client.datasource.editor.api.config.TreeConfigUIHandler;
|
|
|
30
|
+import fr.ird.observe.client.datasource.editor.api.config.TreeStatistics;
|
|
|
31
|
+import fr.ird.observe.client.datasource.editor.api.config.TreeStatisticsTemplate;
|
|
28
|
32
|
import fr.ird.observe.client.datasource.editor.api.content.actions.mode.ChangeMode;
|
|
|
33
|
+import fr.ird.observe.client.datasource.editor.api.navigation.NavigationTreeModel;
|
|
|
34
|
+import fr.ird.observe.client.datasource.editor.api.navigation.NavigationUI;
|
|
|
35
|
+import fr.ird.observe.client.datasource.editor.api.navigation.tree.root.RootNavigationInitializer;
|
|
29
|
36
|
import fr.ird.observe.client.datasource.usage.UsageUIHandlerSupport;
|
|
30
|
37
|
import fr.ird.observe.client.util.DtoIconHelper;
|
|
31
|
38
|
import fr.ird.observe.client.util.UIHelper;
|
| ... |
... |
@@ -33,9 +40,15 @@ import fr.ird.observe.dto.BusinessDto; |
|
33
|
40
|
import fr.ird.observe.dto.ToolkitIdDtoBean;
|
|
34
|
41
|
import fr.ird.observe.dto.ToolkitIdLabel;
|
|
35
|
42
|
import fr.ird.observe.dto.data.DataDto;
|
|
|
43
|
+import fr.ird.observe.dto.data.DataGroupByDto;
|
|
36
|
44
|
import fr.ird.observe.dto.data.DataGroupByParameter;
|
|
|
45
|
+import fr.ird.observe.dto.reference.DataGroupByDtoSet;
|
|
37
|
46
|
import fr.ird.observe.navigation.id.CloseNodeVetoException;
|
|
38
|
47
|
import fr.ird.observe.navigation.id.IdNode;
|
|
|
48
|
+import fr.ird.observe.navigation.tree.GroupByHelper;
|
|
|
49
|
+import fr.ird.observe.navigation.tree.TreeConfig;
|
|
|
50
|
+import fr.ird.observe.navigation.tree.io.request.ToolkitTreeFlatModelRootRequest;
|
|
|
51
|
+import fr.ird.observe.services.service.NavigationService;
|
|
39
|
52
|
import fr.ird.observe.services.service.data.MoveLayoutRequest;
|
|
40
|
53
|
import fr.ird.observe.spi.decoration.I18nDecoratorHelper;
|
|
41
|
54
|
import io.ultreia.java4all.decoration.Decorator;
|
| ... |
... |
@@ -46,15 +59,21 @@ import org.apache.logging.log4j.Logger; |
|
46
|
59
|
import javax.swing.AbstractAction;
|
|
47
|
60
|
import javax.swing.Action;
|
|
48
|
61
|
import javax.swing.ActionMap;
|
|
|
62
|
+import javax.swing.BorderFactory;
|
|
|
63
|
+import javax.swing.DefaultComboBoxModel;
|
|
49
|
64
|
import javax.swing.InputMap;
|
|
50
|
65
|
import javax.swing.JButton;
|
|
51
|
66
|
import javax.swing.JCheckBox;
|
|
|
67
|
+import javax.swing.JComboBox;
|
|
52
|
68
|
import javax.swing.JComponent;
|
|
|
69
|
+import javax.swing.JDialog;
|
|
53
|
70
|
import javax.swing.JLabel;
|
|
54
|
71
|
import javax.swing.JLayeredPane;
|
|
55
|
72
|
import javax.swing.JOptionPane;
|
|
56
|
73
|
import javax.swing.JPanel;
|
|
|
74
|
+import javax.swing.JPopupMenu;
|
|
57
|
75
|
import javax.swing.JSeparator;
|
|
|
76
|
+import javax.swing.JToolBar;
|
|
58
|
77
|
import javax.swing.KeyStroke;
|
|
59
|
78
|
import javax.swing.SwingConstants;
|
|
60
|
79
|
import javax.swing.SwingUtilities;
|
| ... |
... |
@@ -62,6 +81,7 @@ import java.awt.BorderLayout; |
|
62
|
81
|
import java.awt.Font;
|
|
63
|
82
|
import java.awt.GridLayout;
|
|
64
|
83
|
import java.awt.event.ActionEvent;
|
|
|
84
|
+import java.awt.event.ItemEvent;
|
|
65
|
85
|
import java.util.LinkedHashSet;
|
|
66
|
86
|
import java.util.List;
|
|
67
|
87
|
import java.util.Objects;
|
| ... |
... |
@@ -79,7 +99,7 @@ import static io.ultreia.java4all.i18n.I18n.t; |
|
79
|
99
|
* @since 8.0.1
|
|
80
|
100
|
*/
|
|
81
|
101
|
@SuppressWarnings("UnusedReturnValue")
|
|
82
|
|
-public class MoveLayoutRequestBuilder {
|
|
|
102
|
+public class MoveLayoutRequestBuilder implements WithClientUIContextApi {
|
|
83
|
103
|
|
|
84
|
104
|
private static final Logger log = LogManager.getLogger(MoveLayoutRequestBuilder.class);
|
|
85
|
105
|
/**
|
| ... |
... |
@@ -102,6 +122,10 @@ public class MoveLayoutRequestBuilder { |
|
102
|
122
|
* Apply action.
|
|
103
|
123
|
*/
|
|
104
|
124
|
private final AbstractAction applyAction;
|
|
|
125
|
+ /**
|
|
|
126
|
+ * Apply action.
|
|
|
127
|
+ */
|
|
|
128
|
+ private final AbstractAction configureAction;
|
|
105
|
129
|
/**
|
|
106
|
130
|
* Optional edit node.
|
|
107
|
131
|
*/
|
| ... |
... |
@@ -144,6 +168,16 @@ public class MoveLayoutRequestBuilder { |
|
144
|
168
|
* Selected layout types.
|
|
145
|
169
|
*/
|
|
146
|
170
|
private Set<Class<? extends DataDto>> selectedLayoutTypes;
|
|
|
171
|
+ private DataSourceEditor dataSourceEditor;
|
|
|
172
|
+ private FilterableComboBox<ToolkitIdLabel> parentEditor;
|
|
|
173
|
+ private JPanel groupByNamePanel;
|
|
|
174
|
+ private JLabel groupByNameLabel;
|
|
|
175
|
+ private GroupByHelper groupByHelper;
|
|
|
176
|
+ private ToolkitTreeFlatModelRootRequest rootRequest;
|
|
|
177
|
+ private JComboBox<DataGroupByDto<?>> groupByValuesEditor;
|
|
|
178
|
+ private DataGroupByDtoSet<?, ?> dataGroupByDtoSet;
|
|
|
179
|
+ private TreeConfig treeConfig;
|
|
|
180
|
+ private String groupByParameterValue;
|
|
147
|
181
|
|
|
148
|
182
|
static class BuilderImpl implements StepSetParentCandidates, StepBuild {
|
|
149
|
183
|
private final MoveLayoutRequestBuilder builder;
|
| ... |
... |
@@ -215,12 +249,24 @@ public class MoveLayoutRequestBuilder { |
|
215
|
249
|
applyAction = new AbstractAction() {
|
|
216
|
250
|
@Override
|
|
217
|
251
|
public void actionPerformed(ActionEvent e) {
|
|
218
|
|
- log.info("Apply :)");
|
|
219
|
252
|
jButton.doClick();
|
|
220
|
253
|
}
|
|
221
|
254
|
};
|
|
222
|
255
|
applyAction.putValue(Action.ACCELERATOR_KEY, keyStroke);
|
|
223
|
256
|
applyAction.putValue(Action.NAME, t);
|
|
|
257
|
+ keyStroke = ObserveKeyStrokesEditorApi.KEY_STROKE_INSERT_CONFIGURE;
|
|
|
258
|
+ t = ObserveKeyStrokesEditorApi.suffixTextWithKeyStroke("", keyStroke);
|
|
|
259
|
+ String tip = ObserveKeyStrokesEditorApi.suffixTextWithKeyStroke(t("observe.ui.tree.action.configure.tip"), keyStroke);
|
|
|
260
|
+ configureAction = new AbstractAction() {
|
|
|
261
|
+ @Override
|
|
|
262
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
263
|
+ doConfigure();
|
|
|
264
|
+ }
|
|
|
265
|
+ };
|
|
|
266
|
+ configureAction.putValue(Action.LARGE_ICON_KEY, UIHelper.getUIManagerActionIcon("generate"));
|
|
|
267
|
+ configureAction.putValue(Action.ACCELERATOR_KEY, keyStroke);
|
|
|
268
|
+ configureAction.putValue(Action.NAME, t);
|
|
|
269
|
+ configureAction.putValue(Action.SHORT_DESCRIPTION, tip);
|
|
224
|
270
|
}
|
|
225
|
271
|
|
|
226
|
272
|
private MoveLayoutRequestBuilder setEditNode(IdNode<?> editNode) {
|
| ... |
... |
@@ -244,6 +290,7 @@ public class MoveLayoutRequestBuilder { |
|
244
|
290
|
}
|
|
245
|
291
|
|
|
246
|
292
|
public Optional<MoveLayoutRequest> build(DataSourceEditor dataSourceEditor) {
|
|
|
293
|
+ this.dataSourceEditor = dataSourceEditor;
|
|
247
|
294
|
if (parentTargetDtoType == null) {
|
|
248
|
295
|
parentTargetDtoType = oldParentId.getType();
|
|
249
|
296
|
}
|
| ... |
... |
@@ -254,8 +301,19 @@ public class MoveLayoutRequestBuilder { |
|
254
|
301
|
askNewParentMessage = I18nDecoratorHelper.getPropertyI18nKey(dtoType, "action.move.all.choose.parent.message");
|
|
255
|
302
|
}
|
|
256
|
303
|
Objects.requireNonNull(availableLayoutTypes, "No availableLayoutTypes declared in builder");
|
|
257
|
|
- DataGroupByParameter groupBy = Objects.requireNonNull(this.groupByValueSupplier, "No groupByValue supplier set.").get();
|
|
258
|
|
- List<ToolkitIdLabel> parentCandidates = Objects.requireNonNull(this.parentCandidates, "No parent candidates set.").apply(groupBy, oldParentId.getId());
|
|
|
304
|
+ DataGroupByParameter dataGroupByParameter = Objects.requireNonNull(this.groupByValueSupplier, "No groupByValue supplier set.").get();
|
|
|
305
|
+
|
|
|
306
|
+ groupByParameterValue = dataGroupByParameter.getValue();
|
|
|
307
|
+
|
|
|
308
|
+ NavigationTreeModel navigationTreeModel = dataSourceEditor.getNavigationUI().getTree().getModel();
|
|
|
309
|
+ groupByHelper = navigationTreeModel.getGroupByHelper();
|
|
|
310
|
+
|
|
|
311
|
+ RootNavigationInitializer initializer = navigationTreeModel.getRoot().getInitializer();
|
|
|
312
|
+ rootRequest = initializer.getRequest();
|
|
|
313
|
+ dataGroupByDtoSet = initializer.getGroupBy();
|
|
|
314
|
+ treeConfig = new TreeConfig();
|
|
|
315
|
+ treeConfig.init(navigationTreeModel.getConfig());
|
|
|
316
|
+ List<ToolkitIdLabel> parentCandidates = Objects.requireNonNull(this.parentCandidates, "No parent candidates set.").apply(dataGroupByParameter, oldParentId.getId());
|
|
259
|
317
|
ToolkitIdLabel newParentId = askNewParent(parentCandidates, askNewParentTitle, askNewParentMessage).orElse(null);
|
|
260
|
318
|
if (newParentId == null) {
|
|
261
|
319
|
return Optional.empty();
|
| ... |
... |
@@ -275,14 +333,13 @@ public class MoveLayoutRequestBuilder { |
|
275
|
333
|
}
|
|
276
|
334
|
|
|
277
|
335
|
private Optional<ToolkitIdLabel> askNewParent(List<ToolkitIdLabel> parentCandidates, String dialogTitle, String dialogMessage) {
|
|
278
|
|
- Decorator decorator = ClientUIContextApplicationComponent.value().getDecoratorService().getToolkitIdLabelDecoratorByType(parentTargetDtoType);
|
|
279
|
|
- FilterableComboBox<ToolkitIdLabel> editor = UIHelper.newToolkitIdLabelFilterableComboBox(parentTargetDtoType, decorator, parentCandidates);
|
|
|
336
|
+ Decorator decorator = getDecoratorService().getToolkitIdLabelDecoratorByType(parentTargetDtoType);
|
|
|
337
|
+ parentEditor = UIHelper.newToolkitIdLabelFilterableComboBox(parentTargetDtoType, decorator, parentCandidates);
|
|
280
|
338
|
|
|
281
|
339
|
String continueActionText = (String) applyAction.getValue(Action.NAME);
|
|
282
|
340
|
Object[] options = {continueActionText};
|
|
283
|
341
|
JPanel panel = new JPanel(new BorderLayout(3, 3));
|
|
284
|
342
|
|
|
285
|
|
- JPanel panelNorth = new JPanel(new BorderLayout());
|
|
286
|
343
|
JPanel panelMessages = new JPanel(new BorderLayout(3, 3));
|
|
287
|
344
|
boolean single = availableLayoutTypes.size() == 1;
|
|
288
|
345
|
|
| ... |
... |
@@ -297,20 +354,42 @@ public class MoveLayoutRequestBuilder { |
|
297
|
354
|
|
|
298
|
355
|
panelMessages.add(BorderLayout.NORTH, new JLabel(message));
|
|
299
|
356
|
|
|
300
|
|
- JPanel panelMessage2 = new JPanel(new GridLayout(0, 1));
|
|
301
|
|
- panelMessage2.add(new JLabel());
|
|
302
|
|
- panelMessage2.add(new JLabel(t(dialogMessage)));
|
|
303
|
|
- panelMessages.add(BorderLayout.SOUTH, panelMessage2);
|
|
|
357
|
+ groupByNamePanel = new JPanel(new BorderLayout());
|
|
|
358
|
+ groupByNamePanel.setBorder(BorderFactory.createTitledBorder(/*BorderFactory.createLoweredBevelBorder(),*/ t("observe.Common.navigation.config.groupByName") + " "));
|
|
304
|
359
|
|
|
305
|
|
- panelNorth.add(BorderLayout.NORTH, panelMessages);
|
|
306
|
|
- panelNorth.add(BorderLayout.CENTER, editor);
|
|
|
360
|
+ JToolBar toolBar = new JToolBar();
|
|
|
361
|
+ toolBar.setBorderPainted(false);
|
|
|
362
|
+ toolBar.setFloatable(false);
|
|
|
363
|
+ toolBar.add(new JButton(configureAction));
|
|
|
364
|
+
|
|
|
365
|
+ groupByNamePanel.add(BorderLayout.CENTER, groupByNameLabel = new JLabel(""));
|
|
|
366
|
+ groupByNamePanel.add(BorderLayout.EAST, toolBar);
|
|
|
367
|
+ groupByNamePanel.add(BorderLayout.SOUTH, groupByValuesEditor = new JComboBox<>());
|
|
|
368
|
+
|
|
|
369
|
+
|
|
|
370
|
+ JPanel panelConfiguration = new JPanel(new BorderLayout());
|
|
|
371
|
+ parentEditor.setBorder(BorderFactory.createTitledBorder(/*BorderFactory.createLoweredBevelBorder(),*/t(dialogMessage) + " "));
|
|
|
372
|
+
|
|
|
373
|
+ panelConfiguration.add(BorderLayout.CENTER, groupByNamePanel);
|
|
|
374
|
+ panelConfiguration.add(BorderLayout.SOUTH, parentEditor);
|
|
|
375
|
+
|
|
|
376
|
+ updateConfigurationLabel();
|
|
|
377
|
+
|
|
|
378
|
+ updateGroupByValues();
|
|
|
379
|
+
|
|
|
380
|
+ groupByValuesEditor.addItemListener(e -> {
|
|
|
381
|
+ if (e.getStateChange() != ItemEvent.SELECTED) {
|
|
|
382
|
+ return;
|
|
|
383
|
+ }
|
|
|
384
|
+ DataGroupByDto<?> newGroupByValue = (DataGroupByDto<?>) e.getItem();
|
|
|
385
|
+ onGroupByValueChanged(newGroupByValue);
|
|
|
386
|
+ });
|
|
307
|
387
|
|
|
308
|
388
|
JPanel panelSelectTarget = new JPanel(new GridLayout(0, 1));
|
|
309
|
389
|
//FIXME:Move Add a default client configuration option to set this value
|
|
310
|
390
|
selectTarget.setSelected(true);
|
|
311
|
391
|
panelSelectTarget.add(new JLabel());
|
|
312
|
392
|
panelSelectTarget.add(selectTarget);
|
|
313
|
|
- panelNorth.add(BorderLayout.SOUTH, panelSelectTarget);
|
|
314
|
393
|
|
|
315
|
394
|
JPanel panelSouth = new JPanel(new GridLayout(0, 1));
|
|
316
|
395
|
panelSouth.add(BorderLayout.NORTH, new JSeparator(SwingConstants.HORIZONTAL));
|
| ... |
... |
@@ -318,19 +397,27 @@ public class MoveLayoutRequestBuilder { |
|
318
|
397
|
information.setFont(information.getFont().deriveFont(Font.ITALIC).deriveFont(11f));
|
|
319
|
398
|
panelSouth.add(BorderLayout.CENTER, information);
|
|
320
|
399
|
|
|
|
400
|
+ JPanel panelNorth = new JPanel(new BorderLayout());
|
|
|
401
|
+ panelNorth.add(BorderLayout.NORTH, panelMessages);
|
|
|
402
|
+ panelNorth.add(BorderLayout.CENTER, panelConfiguration);
|
|
|
403
|
+ panelNorth.add(BorderLayout.SOUTH, panelSelectTarget);
|
|
|
404
|
+
|
|
321
|
405
|
panel.add(BorderLayout.NORTH, panelNorth);
|
|
322
|
406
|
panel.add(BorderLayout.SOUTH, panelSouth);
|
|
323
|
407
|
|
|
324
|
408
|
InputMap inputMap1 = panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
|
325
|
409
|
inputMap1.put((KeyStroke) selectTargetAction.getValue(Action.ACCELERATOR_KEY), "selectTarget");
|
|
|
410
|
+ inputMap1.put((KeyStroke) configureAction.getValue(Action.ACCELERATOR_KEY), "configure");
|
|
326
|
411
|
|
|
327
|
412
|
InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
|
|
328
|
413
|
inputMap.put((KeyStroke) selectTargetAction.getValue(Action.ACCELERATOR_KEY), "selectTarget");
|
|
329
|
414
|
inputMap.put((KeyStroke) applyAction.getValue(Action.ACCELERATOR_KEY), "apply");
|
|
|
415
|
+ inputMap.put((KeyStroke) configureAction.getValue(Action.ACCELERATOR_KEY), "configure");
|
|
330
|
416
|
|
|
331
|
417
|
ActionMap actionMap = panel.getActionMap();
|
|
332
|
418
|
actionMap.put("selectTarget", selectTargetAction);
|
|
333
|
419
|
actionMap.put("apply", applyAction);
|
|
|
420
|
+ actionMap.put("configure", configureAction);
|
|
334
|
421
|
|
|
335
|
422
|
|
|
336
|
423
|
optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[0]) {
|
| ... |
... |
@@ -343,18 +430,18 @@ public class MoveLayoutRequestBuilder { |
|
343
|
430
|
|
|
344
|
431
|
inputMap.put(KeyStroke.getKeyStroke("pressed ENTER"), "none");
|
|
345
|
432
|
inputMap.put(KeyStroke.getKeyStroke("ctrl pressed ENTER"), "none");
|
|
346
|
|
- if (editor.getCombobox().getModel().getSize() == 1) {
|
|
|
433
|
+ if (parentEditor.getCombobox().getModel().getSize() == 1) {
|
|
347
|
434
|
// auto-select unique data
|
|
348
|
|
- editor.setSelectedItem(parentCandidates.get(0));
|
|
|
435
|
+ parentEditor.setSelectedItem(parentCandidates.get(0));
|
|
349
|
436
|
}
|
|
350
|
|
- SwingUtilities.invokeLater(editor.getCombobox()::requestFocus);
|
|
|
437
|
+ SwingUtilities.invokeLater(parentEditor.getCombobox()::requestFocus);
|
|
351
|
438
|
}
|
|
352
|
439
|
};
|
|
|
440
|
+ optionPane.setComponentPopupMenu(new JPopupMenu());
|
|
353
|
441
|
jButton = UsageUIHandlerSupport.findButton(optionPane, continueActionText);
|
|
354
|
442
|
Objects.requireNonNull(jButton).setIcon(UIHelper.getUIManagerActionIcon("move"));
|
|
355
|
443
|
jButton.setEnabled(false);
|
|
356
|
|
- editor.getModel().addPropertyChangeListener("selectedItem", evt -> jButton.setEnabled(canMove(evt.getNewValue())));
|
|
357
|
|
-
|
|
|
444
|
+ parentEditor.getModel().addPropertyChangeListener("selectedItem", evt -> jButton.setEnabled(canMove(evt.getNewValue())));
|
|
358
|
445
|
if (!single) {
|
|
359
|
446
|
JPanel typesPanel = new JPanel(new GridLayout(0, 1));
|
|
360
|
447
|
int index = 1;
|
| ... |
... |
@@ -363,7 +450,7 @@ public class MoveLayoutRequestBuilder { |
|
363
|
450
|
Action typeAction = new AbstractAction() {
|
|
364
|
451
|
@Override
|
|
365
|
452
|
public void actionPerformed(ActionEvent e) {
|
|
366
|
|
- jButton.setEnabled(updateSelectedType(typeEditor, type, editor));
|
|
|
453
|
+ jButton.setEnabled(updateSelectedType(typeEditor, type, parentEditor));
|
|
367
|
454
|
}
|
|
368
|
455
|
};
|
|
369
|
456
|
String actionName = "Select-" + type.getName();
|
| ... |
... |
@@ -382,15 +469,15 @@ public class MoveLayoutRequestBuilder { |
|
382
|
469
|
typesPanel.add(typeEditor);
|
|
383
|
470
|
index++;
|
|
384
|
471
|
}
|
|
385
|
|
-
|
|
386
|
472
|
panelMessages.add(BorderLayout.CENTER, typesPanel);
|
|
387
|
473
|
}
|
|
388
|
|
- int response = UIHelper.askUser(ClientUIContextApplicationComponent.value().getMainUI(), optionPane, t(dialogTitle), options);
|
|
|
474
|
+ panelMessages.add(BorderLayout.SOUTH, new JLabel(""));
|
|
|
475
|
+ int response = UIHelper.askUser(getMainUI(), optionPane, t(dialogTitle), options);
|
|
389
|
476
|
|
|
390
|
477
|
ToolkitIdLabel newParent = null;
|
|
391
|
478
|
if (response == 0) {
|
|
392
|
479
|
// will replace and delete
|
|
393
|
|
- newParent = editor.getModel().getSelectedItem();
|
|
|
480
|
+ newParent = parentEditor.getModel().getSelectedItem();
|
|
394
|
481
|
log.info(String.format("Selected parent id: %s", newParent));
|
|
395
|
482
|
}
|
|
396
|
483
|
if (newParent == null || selectedLayoutTypes.isEmpty()) {
|
| ... |
... |
@@ -399,6 +486,82 @@ public class MoveLayoutRequestBuilder { |
|
399
|
486
|
return Optional.of(newParent);
|
|
400
|
487
|
}
|
|
401
|
488
|
|
|
|
489
|
+ private void onGroupByValueChanged(DataGroupByDto<?> newGroupByValue) {
|
|
|
490
|
+ DataGroupByParameter newGroupBy = new DataGroupByParameter(rootRequest.getGroupByName(), rootRequest.getGroupByFlavor(), newGroupByValue.getFilterValue());
|
|
|
491
|
+
|
|
|
492
|
+ List<ToolkitIdLabel> newParentCandidates = parentCandidates.apply(newGroupBy, oldParentId.getId());
|
|
|
493
|
+ ToolkitIdLabel selectedItem = parentEditor.getModel().getSelectedItem();
|
|
|
494
|
+ parentEditor.setData(newParentCandidates);
|
|
|
495
|
+ parentEditor.setSelectedItem(newParentCandidates.contains(selectedItem) ? selectedItem : null);
|
|
|
496
|
+
|
|
|
497
|
+ if (parentEditor.getCombobox().getModel().getSize() == 1) {
|
|
|
498
|
+ // auto-select unique data
|
|
|
499
|
+ parentEditor.setSelectedItem(newParentCandidates.get(0));
|
|
|
500
|
+ }
|
|
|
501
|
+ SwingUtilities.invokeLater(parentEditor.getCombobox()::requestFocus);
|
|
|
502
|
+ }
|
|
|
503
|
+
|
|
|
504
|
+ private void doConfigure() {
|
|
|
505
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
506
|
+ NavigationUI ui = dataSourceEditor.getNavigationUI();
|
|
|
507
|
+
|
|
|
508
|
+ TreeConfigUI configUI = TreeConfigUIHandler.createUI(ui,
|
|
|
509
|
+ treeConfig,
|
|
|
510
|
+ ui.getTree().getModel().getGroupByHelper(),
|
|
|
511
|
+ new MoveLayoutApplyNavigationConfiguration(this),
|
|
|
512
|
+ ui.getTree());
|
|
|
513
|
+
|
|
|
514
|
+ TreeConfigUIHandler.hideOptions(configUI);
|
|
|
515
|
+ TreeConfigUIHandler.hideModule(configUI);
|
|
|
516
|
+ configUI.getHandler().updateOptions();
|
|
|
517
|
+ configUI.setComponentPopupMenu(optionPane.getComponentPopupMenu());
|
|
|
518
|
+ SwingUtilities.invokeLater(() -> TreeConfigUIHandler.showPanel(groupByNamePanel, configUI));
|
|
|
519
|
+ });
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ public void updateConfiguration(TreeConfig bean) {
|
|
|
523
|
+ treeConfig = bean;
|
|
|
524
|
+ rootRequest = bean.toRootRequest(groupByHelper);
|
|
|
525
|
+ log.warn(String.format("Will use new request: %s", rootRequest));
|
|
|
526
|
+
|
|
|
527
|
+ updateConfigurationLabel();
|
|
|
528
|
+
|
|
|
529
|
+ NavigationService navigationService = getDataSourcesManager().getMainDataSource().getNavigationService();
|
|
|
530
|
+ dataGroupByDtoSet = navigationService.getGroupByDtoSet(rootRequest);
|
|
|
531
|
+ getDecoratorService().installDecorator(dataGroupByDtoSet);
|
|
|
532
|
+
|
|
|
533
|
+ groupByParameterValue = dataGroupByDtoSet.size() == 0 ? null : dataGroupByDtoSet.toList().get(0).getFilterValue();
|
|
|
534
|
+ updateGroupByValues();
|
|
|
535
|
+ SwingUtilities.invokeLater(() -> {
|
|
|
536
|
+ JDialog dialog = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, optionPane);
|
|
|
537
|
+ dialog.pack();
|
|
|
538
|
+ });
|
|
|
539
|
+ }
|
|
|
540
|
+
|
|
|
541
|
+ private void updateConfigurationLabel() {
|
|
|
542
|
+ TreeStatistics statistics = new TreeStatistics(
|
|
|
543
|
+ rootRequest,
|
|
|
544
|
+ groupByHelper,
|
|
|
545
|
+ () -> 0,
|
|
|
546
|
+ () -> 0L,
|
|
|
547
|
+ () -> 0L);
|
|
|
548
|
+ String statisticsText = TreeStatisticsTemplate.generateTreeStatisticsText(statistics);
|
|
|
549
|
+ groupByNameLabel.setText(statisticsText.substring(0, statisticsText.lastIndexOf(" /")));
|
|
|
550
|
+
|
|
|
551
|
+ }
|
|
|
552
|
+
|
|
|
553
|
+ private void updateGroupByValues() {
|
|
|
554
|
+
|
|
|
555
|
+ @SuppressWarnings("unchecked") List<DataGroupByDto<?>> groupByValues = (List<DataGroupByDto<?>>) dataGroupByDtoSet.toList();
|
|
|
556
|
+
|
|
|
557
|
+ DataGroupByDto<?> selectedGroupByValue = groupByParameterValue == null ? null : dataGroupByDtoSet.tryGetReferenceById(groupByParameterValue).orElse(null);
|
|
|
558
|
+
|
|
|
559
|
+ DefaultComboBoxModel<DataGroupByDto<?>> model = (DefaultComboBoxModel<DataGroupByDto<?>>) groupByValuesEditor.getModel();
|
|
|
560
|
+ model.removeAllElements();
|
|
|
561
|
+ model.addAll(groupByValues);
|
|
|
562
|
+ model.setSelectedItem(selectedGroupByValue != null ? selectedGroupByValue : groupByValues.isEmpty() ? null : groupByValues.get(0));
|
|
|
563
|
+ }
|
|
|
564
|
+
|
|
402
|
565
|
private boolean updateSelectedType(JCheckBox typeEditor, Class<? extends DataDto> type, FilterableComboBox<ToolkitIdLabel> editor) {
|
|
403
|
566
|
if (selectedLayoutTypes.contains(type)) {
|
|
404
|
567
|
selectedLayoutTypes.remove(type);
|
| ... |
... |
@@ -416,6 +579,7 @@ public class MoveLayoutRequestBuilder { |
|
416
|
579
|
|
|
417
|
580
|
public interface StepSetParentCandidates {
|
|
418
|
581
|
|
|
|
582
|
+
|
|
419
|
583
|
StepSetParentCandidates setEditNode(IdNode<?> editNode);
|
|
420
|
584
|
|
|
421
|
585
|
StepSetParentCandidates setGroupByValue(Supplier<DataGroupByParameter> groupByValue);
|