Commit 045e8131 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Refinement-Exceptions: Readd binding conditionals / rm control updates

* Readds conditionals to the binding logic. This hack is needed to
  handle the mixed widget creation and model update logic. Reasonable
  defaults in the widgets may (at least for the types) resolve some of
  this weird design.
* The widget update logic in the selectXYZAction methods is removed,
  since the widget to be called would be disposed anyways. It is
  overridden by a new Widget that automatically receives the new value
  due to the duplicate call of the create methods.
* One might consider correcting this create/update behavior in future
  since the code is quite hard to follow and unlogical.

Issue-Ref: 3589
Issue-Url: https://af3-developer.fortiss.org/issues/3589

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 31d6b630
RefinementContentProvider.java e376db45ede8a79771a72c74d4dc0c8d7ad553ad GREEN
RefinementEditor.java 5313f0abded86a680218da32ae7bbddc044d1db4 YELLOW
RefinementEditor.java fdf1ec4a3a345dc1d4f7dd3fb9f428327caff05e YELLOW
RefinementSpecificationEditor.java 5275ef81f2c44c15057bd8698ee30677e4f87ed8 GREEN
RefinementTestSuiteEditor.java 5db72b518a027c11ba73c310046e210e2f7d541a GREEN
......@@ -266,7 +266,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectSourceAction(rule, sourceItem);
selectSourceAction(rule);
}
});
ColumnViewerToolTipSupport.enableFor(sourceItem);
......@@ -290,7 +290,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectTargetClassAction(rule, targetClassItem);
selectTargetClassAction(rule);
}
});
......@@ -308,7 +308,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectTargetAction(rule, targetItem);
selectTargetAction(rule);
}
});
ColumnViewerToolTipSupport.enableFor(targetItem);
......@@ -339,10 +339,12 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
toolkit.createLabel(parent, "Source Value");
Text sourceValue = createTextWithUndo(toolkit, parent, "");
fillDefaults().grab(true, false).applyTo(sourceValue);
performComplexTextBinding(dbc, sourceValue,
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__SOURCE_VALUE),
new ITermToStringConverter(), new StringToIExpressionTermConverter(rule),
new TypedIExpressionTermValidatorForAllTypes(rule), null);
if(rule.getSourceValue() != null) {
performComplexTextBinding(dbc, sourceValue,
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__SOURCE_VALUE),
new ITermToStringConverter(), new StringToIExpressionTermConverter(rule),
new TypedIExpressionTermValidatorForAllTypes(rule), null);
}
final Button sourceButton = toolkit.createButton(parent, "...", SWT.FLAT);
sourceButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
......@@ -369,10 +371,12 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
toolkit.createLabel(parent, "Target Value");
Text targetValue = createTextWithUndo(toolkit, parent, "");
fillDefaults().grab(true, false).applyTo(targetValue);
performComplexTextBinding(dbc, targetValue,
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__TARGET_VALUE),
new ITermToStringConverter(), new StringToIExpressionTermConverter(rule),
new TypedIExpressionTermValidatorForAllTypes(rule), null);
if(rule.getTargetValue() != null) {
performComplexTextBinding(dbc, targetValue,
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__TARGET_VALUE),
new ITermToStringConverter(), new StringToIExpressionTermConverter(rule),
new TypedIExpressionTermValidatorForAllTypes(rule), null);
}
Button targetButton = toolkit.createButton(parent, "...", SWT.FLAT);
targetButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
......@@ -537,7 +541,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
}
/** Action to select a source element. */
private void selectSourceAction(final DirectMappingRule rule, final TableViewer sourceItem) {
private void selectSourceAction(final DirectMappingRule rule) {
final EObject rv = doSelectSource(getRoot(rule));
if(rv == null) {
return;
......@@ -546,8 +550,6 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
executeCommand(() -> {
rule.setSource(rv);
});
sourceItem.setInput(new Object[] {rv});
}
/** Gets the root model element of the given object. */
......@@ -556,8 +558,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
}
/** Action to select a target class. */
private void selectTargetClassAction(final DirectMappingRule rule,
final TableViewer targetClassItem) {
private void selectTargetClassAction(final DirectMappingRule rule) {
final EClass rv = doSelectClass();
if(rv == null) {
......@@ -567,17 +568,10 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
executeCommand(() -> {
rule.setTargetClass(rv);
});
for(Prototype proto : IPrototypeService.getInstance().getAllPrototypes()) {
if(proto.getPrototype().eClass().equals(rv)) {
targetClassItem.setInput(new Object[] {proto.getPrototype()});
break;
}
}
}
/** Action to select a target element. */
private void selectTargetAction(final DirectMappingRule rule, final TableViewer targetItem) {
private void selectTargetAction(final DirectMappingRule rule) {
final EObject rv = doSelectTarget(rule.getTargetClass(), getRoot(rule));
if(rv == null) {
return;
......@@ -585,8 +579,6 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
executeCommand(() -> {
rule.setTarget(rv);
});
targetItem.setInput(new Object[] {rv});
}
/** Action to select the source type. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment