Commit ff6634b4 authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '3589_Refinemnet_errors' into 'master'

3589

See merge request af3/af3!141
parents de93801f 6be2ec30
RefinementContentProvider.java e376db45ede8a79771a72c74d4dc0c8d7ad553ad GREEN
RefinementEditor.java 1f60042cece92f277da02217a2ae3ec785fa30b5 GREEN
RefinementEditor.java c9db7d163e6d0758ec7a381a1e6a07ca977cf755 GREEN
RefinementSpecificationEditor.java 5275ef81f2c44c15057bd8698ee30677e4f87ed8 GREEN
RefinementTestSuiteEditor.java 5db72b518a027c11ba73c310046e210e2f7d541a GREEN
......@@ -238,10 +238,10 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
if(sel instanceof ITreeSelection) {
final TreePath[] paths = ((ITreeSelection)sel).getPaths();
boolean noPath = paths.length == 0;
boolean isUniquePath = paths.length == 1;
// [0] because it is checked below whether the path exists.
boolean isCompositePath = paths[0].getLastSegment() instanceof CompositeRule;
add.setEnabled(noPath || (isUniquePath && isCompositePath));
// paths[0] is only accessed if there is exactly one element
boolean isComposite =
paths.length == 1 && paths[0].getLastSegment() instanceof CompositeRule;
add.setEnabled(noPath || isComposite);
}
}
});
......@@ -265,7 +265,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectSourceAction(rule, sourceItem);
selectSourceAction(rule);
}
});
ColumnViewerToolTipSupport.enableFor(sourceItem);
......@@ -289,7 +289,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectTargetClassAction(rule, targetClassItem);
selectTargetClassAction(rule);
}
});
......@@ -307,7 +307,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
selectTargetAction(rule, targetItem);
selectTargetAction(rule);
}
});
ColumnViewerToolTipSupport.enableFor(targetItem);
......@@ -323,7 +323,6 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** Create value mapping panel. */
private void createValueMapping(final Composite parent, final ValueRule rule) {
List<IType> types = ExpressionUtils.getAllVisibleTypes(rule);
parent.setLayout(new GridLayout(3, false));
// Source type part
......@@ -336,14 +335,15 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
dbc.bindValue(singlePostSelection().observe(sourceTypeViewer),
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__SOURCE_TYPE));
toolkit.createLabel(parent, "");
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} */
......@@ -367,14 +367,15 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
dbc.bindValue(singlePostSelection().observe(targetTypeViewer),
observeValue(rule, RefinementPackage.Literals.VALUE_RULE__TARGET_TYPE));
toolkit.createLabel(parent, "");
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} */
......@@ -539,7 +540,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;
......@@ -548,8 +549,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. */
......@@ -558,8 +557,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) {
......@@ -569,17 +567,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;
......@@ -587,14 +578,12 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
executeCommand(() -> {
rule.setTarget(rv);
});
targetItem.setInput(new Object[] {rv});
}
/** Action to select the source type. */
private void selectSourceTypeAction(final ValueRule rule) {
final IExpressionTerm sourceValue = openCDD(getEditorSite().getShell(), dbc, "Source Value",
"", rule, rule.getSourceType(), (IExpressionTerm)rule.getSourceValue(), true);
"source", rule, rule.getSourceType(), (IExpressionTerm)rule.getSourceValue(), true);
if(sourceValue != null) {
executeCommand(() -> {
rule.setSourceValue(sourceValue);
......@@ -605,7 +594,7 @@ public class RefinementEditor extends FormsEditorBase<Refinement> {
/** Action to select the target type. */
private void selectTargetTypeAction(final ValueRule rule) {
final IExpressionTerm targetValue = openCDD(getEditorSite().getShell(), dbc, "Target Value",
"", rule, rule.getTargetType(), (IExpressionTerm)rule.getTargetValue(), true);
"target", rule, rule.getTargetType(), (IExpressionTerm)rule.getTargetValue(), true);
if(targetValue != null) {
executeCommand(() -> {
rule.setTargetValue(targetValue);
......
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