Commit 916939ca authored by Kisslinger's avatar Kisslinger
Browse files

Only one test suite specification part/profile per test suite specification...

Only one test suite specification part/profile per test suite specification can now be active at the same time
parent 21b96776
......@@ -25,12 +25,13 @@ import org.eclipse.core.databinding.observable.list.IListChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.ListChangeEvent;
import org.eclipse.core.databinding.observable.list.ListDiffVisitor;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
......@@ -44,8 +45,10 @@ import org.fortiss.af3.testing.ui.action.GenerateTestSuiteAction;
import org.fortiss.af3.testing.ui.extension.ISpecificationPartHandler;
import org.fortiss.af3.testing.ui.service.ISpecificationPartService;
import org.fortiss.tooling.base.model.element.ElementPackage;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.model.FortissToolingKernelPackage;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -57,7 +60,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: F5DF5A1BF562EB99294350167411F875
* @ConQAT.Rating YELLOW Hash: 0682494B642AE992B2DAE21FE5A9C531
*/
public class TestSuiteSpecificationEditor extends
FormsEditorBase<TestSuiteSpecification> {
......@@ -88,6 +91,7 @@ public class TestSuiteSpecificationEditor extends
public void handleAdd(int index, Object element) {
if (element instanceof TestSuiteSpecificationPart) {
addSpecificationPartSection((TestSuiteSpecificationPart) element);
deactivateAllOtherParts((TestSuiteSpecificationPart) element);
}
}
});
......@@ -158,8 +162,9 @@ public class TestSuiteSpecificationEditor extends
Button enableButton = toolkit.createButton(section, "Enable",
SWT.CHECK);
ISWTObservableValue viewValue = observeSelection(enableButton);
dbc.bindValue(
observeSelection(enableButton),
viewValue,
observeValue(
specPart,
TestingModelPackage.Literals.TEST_SUITE_SPECIFICATION_PART__ACTIVE));
......@@ -168,18 +173,46 @@ public class TestSuiteSpecificationEditor extends
sectionContent.setLayoutData(GridDataFactory.fillDefaults()
.create());
enableButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
viewValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void widgetSelected(SelectionEvent e) {
public void handleValueChange(ValueChangeEvent event) {
GridData layoutData = (GridData) sectionContent
.getLayoutData();
layoutData.exclude = !specPart.isActive();
if (specPart.isActive()) {
deactivateAllOtherParts(specPart);
}
form.reflow(true);
}
});
partHandler.initSettingSection(sectionContent, toolkit, dbc,
specPart);
}
}
/**
* deactivates all other {@link TestSuiteSpecificationPart}s of the edited
* {@link TestSuiteSpecification} except the specified one
*/
private void deactivateAllOtherParts(
final TestSuiteSpecificationPart specPart) {
for (final IModelElementSpecification spec : editedObject
.getSpecifications()) {
if (spec instanceof TestSuiteSpecificationPart && spec != specPart) {
ICommandStackService.INSTANCE.runAsCommand(spec,
new Runnable() {
@Override
public void run() {
((TestSuiteSpecificationPart) spec)
.setActive(false);
}
});
}
}
}
}
Supports Markdown
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