+ private void createEdgeArrowsHeaderRow(Composite parent) {
+
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Label");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ label = new Label(parent, SWT.NONE);
+ label.setText("Used");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ label = new Label(parent, SWT.NONE);
+ label.setText("Variable");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ label = new Label(parent, SWT.NONE);
+ label.setText("Gain");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ label = new Label(parent, SWT.NONE);
+ label.setText("Bias");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ label = new Label(parent, SWT.NONE);
+ label.setText("Default");
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+ }
+
+ private Supplier<Pair<String, DynamicArrowContribution>> createEdgeArrowRow(Composite parent, DynamicArrowObject object) {
+
+ Map<String, DynamicArrowContribution> arrowContributions = object.getArrowContributions();
+ if (arrowContributions.isEmpty()) {
+ // ok, no point in showing empty combo boxes
+ return null;
+ }
+
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(object.getArrowObject().getName());
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(label);
+
+ Button usedButton = new Button(parent, SWT.CHECK);
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(usedButton);
+ addSelectionListener(usedButton);
+
+ Combo variableCombo = new Combo(parent, SWT.READ_ONLY);
+ variableCombo.setItems(arrowContributions.keySet().toArray(new String[arrowContributions.size()]));
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(variableCombo);
+
+ Text gainText = new Text(parent, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(gainText);
+ addSelectionListener(gainText);
+
+ Text biasText = new Text(parent, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).align(SWT.CENTER, SWT.CENTER).applyTo(biasText);
+ addSelectionListener(biasText);
+
+ Button defaultButton = new Button(parent, SWT.CHECK);
+ GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(defaultButton);
+ defaultButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = variableCombo.getSelectionIndex();
+ if (index >= 0) {
+ String key = variableCombo.getItem(index);
+ DynamicArrowContribution cont = arrowContributions.get(key);
+
+ gainText.setText(Double.toString(cont.getDefaultGain()));
+ gainText.setEnabled(!defaultButton.getSelection());
+ biasText.setText(Double.toString(cont.getDefaultBias()));
+ biasText.setEnabled(!defaultButton.getSelection());
+
+ }
+ }
+ });
+ addSelectionListener(defaultButton);
+
+ variableCombo.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ // handle update for others
+ String key = variableCombo.getItem(variableCombo.getSelectionIndex());
+ DynamicArrowContribution cont = arrowContributions.get(key);
+
+ if (gainText.getText().isEmpty()) {
+ gainText.setText(Double.toString(cont.getDefaultGain()));
+ }
+ if (biasText.getText().isEmpty()) {
+ biasText.setText(Double.toString(cont.getDefaultBias()));
+ }
+
+ defaultButton.setSelection(true);
+ }
+ });
+ addSelectionListener(variableCombo);
+
+ arrowRows.put(object.getArrowObject().getName(), new ArrowObjectRow(label, usedButton, variableCombo, gainText, biasText, defaultButton));
+
+ return new Supplier<Pair<String, DynamicArrowContribution>>() {
+
+ @Override
+ public Pair<String, DynamicArrowContribution> get() {
+ int selectionIndex = variableCombo.getSelectionIndex();
+ if (selectionIndex >= 0) {
+ String key = variableCombo.getItem(selectionIndex);
+ DynamicArrowContribution cont = arrowContributions.get(key);
+ if (cont != null) {
+ String label = variableCombo.getItem(variableCombo.getSelectionIndex());
+
+ double gain = cont.getDefaultGain();
+ String gainS = gainText.getText();
+ if (gainS != null && !gainS.isEmpty()) {
+ gain = Double.parseDouble(gainS);
+ }
+ double bias = cont.getDefaultBias();
+ String biasS = biasText.getText();
+ if (biasS != null && !biasS.isEmpty()) {
+ bias = Double.parseDouble(biasText.getText());
+ }
+
+ DynamicArrowContribution dsc = new DynamicArrowContribution(label, cont.getModuleName(), cont.getAttributeName(), gain, bias);
+ dsc.setUsed(usedButton.getSelection());
+ dsc.setUseDefault(defaultButton.getSelection());
+
+ return Pair.make(object.getArrowObject().getName(), dsc);
+ }
+ }
+ return null;
+ }
+ };
+ }
+