Commit bf36418b authored by Chen Wenwen's avatar Chen Wenwen
Browse files

now Requirement can change to Usecase and back, but Relation lost and still no box with a warning

refs 845
parent 33dab156
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.action;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
/**
*
* @author wenwenchen
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class ChangeRequirementToUseCase implements Runnable {
/** the selected relation */
private Requirement re;
/** a new Usecase called u */
private UseCase u = MiraModelElementFactory.createUseCase();
/** Create the command with the selected relation */
public ChangeRequirementToUseCase(Requirement re) {
this.re = re;
}
/** {@inheritDoc} */
@Override
public void run() {
u.setName(re.getName());
u.setReqId(re.getReqId());
u.setDescription(re.getDescription());
u.setRationale(re.getRationale());
u.setAuthor(re.getAuthor());
u.setSources(re.getSources());
u.setStatus(re.getStatus());
u.setPriority(re.getPriority());
u.setTodo(re.getTodo());
u.setRationale(re.getRationale());
// fehlt noch getAnalysis,get RequirementConnector, getIncommingRelationsList,
// getOutgoingRelationsList;
EcoreUtil.replace(re, u);
}
}
/*--------------------------------------------------------------------------+
$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
| |
| Copyright 2012 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.action;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
/**
*
* @author wenwenchen
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating RED Hash:
*/
public class ChangeUseCaseToRequirement<T extends Requirement> implements Runnable {
/** subclass Instance to change */
private T t;
/** new Requirement called r */
private Requirement r = MiraModelElementFactory.createRequirement();
/** Create the command with the selected relation */
public ChangeUseCaseToRequirement(T t) {
this.t = t;
}
/** {@inheritDoc} */
@Override
public void run() {
r.setName(t.getName());
r.setReqId(t.getReqId());
r.setDescription(t.getDescription());
r.setRationale(t.getRationale());
r.setAuthor(t.getAuthor());
r.setSources(t.getSources());
r.setStatus(t.getStatus());
r.setPriority(t.getPriority());
r.setTodo(t.getTodo());
r.setRationale(t.getRationale());
// fehlt noch getAnalysis,get RequirementConnector, getIncommingRelationsList,
// getOutgoingRelationsList;
EcoreUtil.replace(t, r);
}
}
...@@ -44,12 +44,13 @@ public final class DateToStringConverter extends Converter { ...@@ -44,12 +44,13 @@ public final class DateToStringConverter extends Converter {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public Object convert(Object fromObject) { public Object convert(Object fromObject) {
if (fromObject != null) { if(fromObject != null) {
Date date = (Date) fromObject; Date date = (Date)fromObject;
SimpleDateFormat formatter = new SimpleDateFormat(format); SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.format(date); return formatter.format(date);
} }
return null; return null;
} }
}
\ No newline at end of file }
...@@ -27,7 +27,6 @@ import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__REQ_I ...@@ -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__SOURCES;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__STATUS; 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__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.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_CONTAINER__CONTAINED_ELEMENTS;
import static org.fortiss.tooling.base.model.element.ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTIONS; import static org.fortiss.tooling.base.model.element.ElementPackage.Literals.IHIERARCHIC_ELEMENT__CONNECTIONS;
...@@ -56,8 +55,11 @@ import org.eclipse.jface.text.IRegion; ...@@ -56,8 +55,11 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer; import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider; 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.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
...@@ -90,6 +92,8 @@ import org.fortiss.af3.mira.model.RequirementStatus; ...@@ -90,6 +92,8 @@ import org.fortiss.af3.mira.model.RequirementStatus;
import org.fortiss.af3.mira.model.RequirementType; import org.fortiss.af3.mira.model.RequirementType;
import org.fortiss.af3.mira.model.glossary.Glossary; import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.relation.IRelationService; 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.CreateGlossaryEntryAction;
import org.fortiss.af3.mira.ui.action.ExportReportAction; import org.fortiss.af3.mira.ui.action.ExportReportAction;
import org.fortiss.af3.mira.ui.action.ExportReportSummarizationAction; import org.fortiss.af3.mira.ui.action.ExportReportSummarizationAction;
...@@ -250,16 +254,53 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T> ...@@ -250,16 +254,53 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
* toolkit.createText(generalComposite, editedObject.eClass().getName(), SWT.READ_ONLY); * toolkit.createText(generalComposite, editedObject.eClass().getName(), SWT.READ_ONLY);
* singleLineInputFactory.applyTo(typeInput); * singleLineInputFactory.applyTo(typeInput);
*/ */
ComboViewer typeInput = new ComboViewer(generalComposite, SWT.READ_ONLY); final ComboViewer typeInput = new ComboViewer(generalComposite, SWT.READ_ONLY);
singleLineInputFactory.applyTo(typeInput.getCombo()); singleLineInputFactory.applyTo(typeInput.getCombo());
toolkit.adapt(typeInput.getCombo()); toolkit.adapt(typeInput.getCombo());
typeInput.setContentProvider(new ArrayContentProvider()); typeInput.setContentProvider(new ArrayContentProvider());
typeInput.setLabelProvider(new LabelProvider()); typeInput.setLabelProvider(new LabelProvider());
typeInput.setInput(RequirementType.values()); char[] c = editedObject.eClass().getName().toCharArray(); // zu kompliziert, aber es mir
dbc.bindValue(observeSinglePostSelection(typeInput), // keine andere Wahl bleibt,
observeValue(editedObject, REQUIREMENT__TYPE)); // weil
// changeBinding(dbc, typeInput, observeSinglePostSelection(typeInput), // editedObject.eClass().getName()).equals("Requirement")
// observeValue(editedObject, REQUIREMENT__STATUS)); // funktioniert nicht
typeInput.setInput(RequirementType.VALUES);
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());
}
}
});
/* edit Requirement Title */ /* edit Requirement Title */
Label titleLabel = toolkit.createLabel(generalComposite, "Title ", SWT.READ_ONLY); Label titleLabel = toolkit.createLabel(generalComposite, "Title ", SWT.READ_ONLY);
......
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