Commit 86557c8c authored by Chen Wenwen's avatar Chen Wenwen
Browse files

finished

refs 845
parent 89462dc5
......@@ -27,7 +27,6 @@ import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__REQ_I
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__SOURCES;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__STATUS;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__TODO;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__TYPE;
import static org.fortiss.af3.mira.ui.editor.glossary.ScannerManager.getScanner;
import static org.fortiss.tooling.base.model.element.ElementPackage.Literals.IHIERARCHIC_ELEMENT_CONTAINER__CONTAINED_ELEMENTS;
import static org.fortiss.tooling.base.model.element.ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTIONS;
......@@ -56,8 +55,11 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
......@@ -87,15 +89,18 @@ import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementPriority;
import org.fortiss.af3.mira.model.RequirementRelation;
import org.fortiss.af3.mira.model.RequirementStatus;
import org.fortiss.af3.mira.model.RequirementType;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.relation.IRelationService;
import org.fortiss.af3.mira.ui.action.ChangeRequirementToUseCase;
import org.fortiss.af3.mira.ui.action.ChangeUseCaseToRequirement;
import org.fortiss.af3.mira.ui.action.CreateGlossaryEntryAction;
import org.fortiss.af3.mira.ui.action.ExportReportAction;
import org.fortiss.af3.mira.ui.action.ExportReportSummarizationAction;
import org.fortiss.af3.mira.ui.action.ExportReqIFAction;
import org.fortiss.af3.mira.ui.action.ShowHierarchyAction;
import org.fortiss.af3.mira.ui.action.VerifyAction;
import org.fortiss.af3.mira.ui.dialog.ChangeWarningDialog;
import org.fortiss.af3.mira.ui.editor.glossary.GlossaryHighlightConfiguration;
import org.fortiss.af3.mira.ui.editor.glossary.ListToWordRuleUpdateStrategy;
import org.fortiss.af3.mira.ui.editor.glossary.ScannerManager;
......@@ -109,7 +114,7 @@ import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: E84EB26E07AE0A979F0D050101C25CFD
* @ConQAT.Rating YELLOW Hash: 487B00B00D0D4F064A766F43509DA6DF
*/
public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T> {
......@@ -169,8 +174,9 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
/** {@inheritDoc} */
@Override
public void dispose() {
getScanner(editedObject.getAnalysis()).getObservableWordRule().removeChangeListener(
wordRuleUpdateListener);
if(editedObject.getAnalysis() != null)
getScanner(editedObject.getAnalysis()).getObservableWordRule().removeChangeListener(
wordRuleUpdateListener);
wordRuleUpdateListener = null;
idObservable.dispose();
......@@ -245,64 +251,49 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
/* edit Requirement Type */
Label typeLabel = toolkit.createLabel(generalComposite, "Type ", SWT.READ_ONLY);
singleLineLabelFactory.applyTo(typeLabel);
/*
* Text typeInput =
* toolkit.createText(generalComposite, editedObject.eClass().getName(), SWT.READ_ONLY);
* singleLineInputFactory.applyTo(typeInput);
*/
final ComboViewer typeInput = new ComboViewer(generalComposite, SWT.READ_ONLY);
singleLineInputFactory.applyTo(typeInput.getCombo());
toolkit.adapt(typeInput.getCombo());
typeInput.setContentProvider(new ArrayContentProvider());
typeInput.setLabelProvider(new LabelProvider());
// char[] c = editedObject.eClass().getName().toCharArray(); // zu kompliziert, aber es mir
// keine andere Wahl bleibt,
// weil
// editedObject.eClass().getName()).equals("Requirement")
// funktioniert nicht
typeInput.setInput(RequirementType.VALUES);
dbc.bindValue(observeSinglePostSelection(typeInput),
observeValue(editedObject, REQUIREMENT__TYPE));
/*
* if(c[0] == 'R') {
* typeInput.setSelection(new StructuredSelection(typeInput.getElementAt(0)));
* } else
* typeInput.setSelection(new StructuredSelection(typeInput.getElementAt(1)));
* typeInput.addSelectionChangedListener(new ISelectionChangedListener() {
*
* @Override
* public void selectionChanged(SelectionChangedEvent event) {
*
* char[] c = editedObject.eClass().getName().toCharArray();
* if(c[0] == 'R') {
* executeCommand(new ChangeRequirementToUseCase(editedObject));
* } else {
* /**
* int option =
* JOptionPane
* .showConfirmDialog(
* null,
* "Changing the requirements type deletes all information\n"
* + "that is not contained in the new requirements type!\n Continue?",
* "warnung", JOptionPane.YES_NO_OPTION);
*
* if(option == JOptionPane.YES_OPTION) {
* System.out.println("ich musst change to Requirement");
* } else {
* System.out.print("I don't want to change");
* typeInput.setSelection(new StructuredSelection(typeInput.getElementAt(1)));
*
* // System.out.println("r " + r.eClass().getName());
*/
/*
* executeCommand(new ChangeUseCaseToRequirement<T>(editedObject));
* // System.out.println("editedObject " + editedObject.eClass().getName());
* }
* }
*
* });
*/
String[] type = {"Requirement", "UseCase"};
typeInput.setInput(type);
if(editedObject instanceof UseCase) {
typeInput.setSelection(new StructuredSelection(typeInput.getElementAt(1)));
} else {
typeInput.setSelection(new StructuredSelection(typeInput.getElementAt(0)));
}
final StructuredSelection curr = (StructuredSelection)typeInput.getSelection();
typeInput.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
if(!((StructuredSelection)event.getSelection()).getFirstElement().equals(curr)) {
if(editedObject instanceof UseCase) {
int result = ChangeWarningDialog.dialog();
if(result == 1) {
// replace
executeCommand(new ChangeUseCaseToRequirement<T>(editedObject));
} else {
typeInput.removePostSelectionChangedListener(this);
typeInput.setSelection(new StructuredSelection(typeInput
.getElementAt(1)));
typeInput.addPostSelectionChangedListener(this);
}
} else {
executeCommand(new ChangeRequirementToUseCase(editedObject));
}
}
}
});
/* edit Requirement Title */
Label titleLabel = toolkit.createLabel(generalComposite, "Title ", SWT.READ_ONLY);
singleLineLabelFactory.applyTo(titleLabel);
......
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