Commit 1fdae954 authored by Chen Wenwen's avatar Chen Wenwen
Browse files

finished and tested

refs 41
parent c462106e
......@@ -23,3 +23,5 @@ Export-Package: org.fortiss.af3.mira.ui,
org.fortiss.af3.mira.ui.examples,
org.fortiss.af3.mira.ui.handler,
org.fortiss.af3.mira.ui.views
Import-Package: org.eclipse.swtbot.forms.finder,
org.eclipse.swtbot.forms.finder.widgets
......@@ -55,6 +55,30 @@
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.glossary.GlossaryEntry">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.mira.ui.handler.RequirementSourceHandler">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.RequirementSource">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.mira.ui.handler.StakeholderHandler">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.Stakeholder">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.mira.ui.handler.RequirementDocumentHandler">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.RequirementDocument">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.mira.ui.handler.ExternalSystemHandler">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.ExternalSystem">
</modelElementClass>
</modelElementHandler>
<modelElementHandler
handler="org.fortiss.af3.mira.ui.handler.FormalSpecificationHandler">
......@@ -101,6 +125,24 @@
modelElementClass="org.fortiss.af3.mira.model.glossary.GlossaryEntry">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editorbinding.StakeholderEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.Stakeholder">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editorbinding.RequirementDocumentEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.RequirementDocument">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editorbinding.ExternalSystemEditorbinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.requirementSource.ExternalSystem">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editorbinding.AnalysisEditorBinding">
<modelElementClass
......
......@@ -17,7 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.action;
import static org.fortiss.af3.mira.ui.utils.GlossaryUtils.openGlossaryDialog;
import static org.fortiss.af3.mira.ui.utils.ConnetionUtils.openGlossaryDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossary;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createGlossaryEntry;
......@@ -39,7 +39,7 @@ import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: B8DE9726547B25141632E448EE3470AF
* @ConQAT.Rating YELLOW Hash: 6FDB9E8B5C4E2E3DD126B32CC62AE371
*/
public class CreateGlossaryEntryAction extends EObjectActionBase<Analysis> {
/** the name the entry should get */
......
/*--------------------------------------------------------------------------+
$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 static org.fortiss.af3.mira.ui.utils.ConnetionUtils.openRequirementSourceDialog;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createRequirementSource;
import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.requirementSource.ExternalSystem;
import org.fortiss.af3.mira.model.requirementSource.RequirementDocument;
import org.fortiss.af3.mira.model.requirementSource.RequirementSource;
import org.fortiss.af3.mira.model.requirementSource.RequirementSourceElement;
import org.fortiss.af3.mira.model.requirementSource.Stakeholder;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
/**
*
* @author wenwenchen
* @author $Author: hoelzl $
* @version $Rev: 18709 $
* @ConQAT.Rating YELLOW Hash: DFB4C8CAAE28D1B02B843855E0E87565
*/
public class CreateRequirementSourceAction<T extends RequirementSourceElement> extends
EObjectActionBase<Analysis> {
/** the current shell */
private final Shell shell;
/** created element */
private final T element;
/** the type of to created requirement source element */
/**
* Constructor.
*
* @param analysis
* the analysis in which a stakeholder should be searched to add the
* entry
* @param element
* created element
*/
public CreateRequirementSourceAction(Analysis analysis, T element, Shell shell) {
super(analysis, "Create new requirement source element");
this.element = element;
this.shell = shell;
}
/** {@inheritDoc} */
@Override
public void run() {
final Analysis analysis = getTarget();
RequirementSource requirementSource = null;
// if no requirements source exists create a new one
if(analysis.getRequirementSourceList().size() == 0)
ICommandStackService.INSTANCE.runAsCommand(getTarget(), new Runnable() {
@Override
public void run() {
RequirementSource newRequirementSource =
createRequirementSource("Requirements Source", "");
analysis.getContainedElementsList().add(newRequirementSource);
}
});
// if (now) only a single glossary exits it can be directly
// taken, else a dialog is shown to make the user choose one
if(analysis.getRequirementSourceList().size() == 1)
requirementSource = analysis.getRequirementSourceList().get(0);
else if(analysis.getRequirementSourceList().size() > 1)
requirementSource =
openRequirementSourceDialog(shell, analysis, analysis
.getRequirementSourceList().get(0));
if(requirementSource != null) {
if(element instanceof Stakeholder) {
ICommandStackService.INSTANCE.runAsCommand(requirementSource,
new addToRequirementSourceAction(requirementSource, element));
IModelEditorBindingService.INSTANCE.openInEditor(element);
}
if(element instanceof RequirementDocument) {
ICommandStackService.INSTANCE.runAsCommand(requirementSource,
new addToRequirementSourceAction(requirementSource, element));
IModelEditorBindingService.INSTANCE.openInEditor(element);
}
if(element instanceof ExternalSystem) {
ICommandStackService.INSTANCE.runAsCommand(requirementSource,
new addToRequirementSourceAction(requirementSource, element));
IModelEditorBindingService.INSTANCE.openInEditor(element);
}
}
}
/**
* Helper action to add an glossary entry to a glossary
*/
private class addToRequirementSourceAction implements Runnable {
/** Glossary in which entry should be added */
RequirementSource requirementSource;
/** entry to add */
T t;
/** Constructor. */
public addToRequirementSourceAction(RequirementSource requirementSource, T element) {
super();
this.requirementSource = requirementSource;
this.t = element;
}
/** {@inheritDoc} */
@Override
public void run() {
requirementSource.getContainedElementsList().add(t);
}
}
}
......@@ -36,6 +36,8 @@ import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.glossary.Glossary;
import org.fortiss.af3.mira.model.glossary.GlossaryEntry;
import org.fortiss.af3.mira.model.requirementSource.RequirementSource;
import org.fortiss.af3.mira.model.requirementSource.RequirementSourceElement;
import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
/**
......@@ -44,7 +46,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.EObjectActionBase;
* @author uden
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 4C66BE00DF53EE06880B83E5BDFBF2A1
* @ConQAT.Rating YELLOW Hash: EA788A2823573EECE6A31895CC574E9D
*/
public class ExportReportAction extends EObjectActionBase<EObject> {
......@@ -134,6 +136,10 @@ public class ExportReportAction extends EObjectActionBase<EObject> {
return "/template/ReportTemplateGlossaryEntry.html";
else if(target instanceof Glossary)
return "/template/ReportTemplateGlossary.html";
else if(target instanceof RequirementSource)
return "/template/ReportTemplateRequirementSource.html";
else if(target instanceof RequirementSourceElement)
return "/template/ReportTemplateRequirementSourceElement.html";
throw new IllegalArgumentException(target.getClass().getSimpleName() + " is not supported!");
}
......
......@@ -19,6 +19,7 @@ package org.fortiss.af3.mira.ui.editor;
import static org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.utils.MiraUtils.getDisplayNameFor;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
......@@ -26,7 +27,6 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.utils.MiraUtils;
/**
* The {@link LabelProvider} for the {@link AnalysisEditor}.
......@@ -34,7 +34,7 @@ import org.fortiss.af3.mira.utils.MiraUtils;
* @author teufl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: BD045B6F63E0DD3583FB09DF4963B665
* @ConQAT.Rating YELLOW Hash: 01B112BAC9DDE2C116DB764E3E36ACC2
*/
public class AnalysisLabelProvider implements ITableLabelProvider {
......@@ -105,7 +105,7 @@ public class AnalysisLabelProvider implements ITableLabelProvider {
if(columnIndex == 0) {
return "" + requirement.getReqId();
} else if(columnIndex == 1) {
return MiraUtils.getDisplayNameFor(requirement);
return getDisplayNameFor(requirement);
} else if(columnIndex == 2) {
return requirement.getName();
} else if(columnIndex == 3) {
......
......@@ -20,6 +20,8 @@ package org.fortiss.af3.mira.ui.editor;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.confirm;
import static org.eclipse.core.databinding.UpdateValueStrategy.POLICY_NEVER;
import static org.eclipse.jface.databinding.viewers.ViewersObservables.observeSinglePostSelection;
import static org.eclipse.jface.dialogs.MessageDialog.openConfirm;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__AUTHOR;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__DESCRIPTION;
import static org.fortiss.af3.mira.model.MiraPackage.Literals.REQUIREMENT__PRIORITY;
......@@ -28,7 +30,7 @@ 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.ui.editor.glossary.ScannerManager.getScanner;
import static org.fortiss.af3.mira.ui.editor.connection.ScannerManager.getScanner;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createRequirement;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createUseCase;
import static org.fortiss.af3.mira.utils.MiraUtils.getRequirementInterface;
......@@ -93,20 +95,26 @@ 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.glossary.Glossary;
import org.fortiss.af3.mira.model.requirementSource.ExternalSystem;
import org.fortiss.af3.mira.model.requirementSource.RequirementDocument;
import org.fortiss.af3.mira.model.requirementSource.RequirementSource;
import org.fortiss.af3.mira.model.requirementSource.Stakeholder;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.af3.mira.relation.IRelationService;
import org.fortiss.af3.mira.ui.action.ConvertRequirementAction;
import org.fortiss.af3.mira.ui.action.CreateGlossaryEntryAction;
import org.fortiss.af3.mira.ui.action.CreateRequirementSourceAction;
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.editor.glossary.GlossaryHighlightConfiguration;
import org.fortiss.af3.mira.ui.editor.glossary.ListToWordRuleUpdateStrategy;
import org.fortiss.af3.mira.ui.editor.glossary.ScannerManager;
import org.fortiss.af3.mira.ui.editor.connection.ConnectionHighlightConfiguration;
import org.fortiss.af3.mira.ui.editor.connection.ListToWordRuleUpdateStrategy;
import org.fortiss.af3.mira.ui.editor.connection.ScannerManager;
import org.fortiss.af3.mira.ui.editor.images.ImageSection;
import org.fortiss.af3.mira.ui.utils.GlossaryUtils;
import org.fortiss.af3.mira.ui.utils.ConnetionUtils;
import org.fortiss.af3.mira.utils.MiraModelElementFactory;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.ui.service.IActionService;
......@@ -116,7 +124,7 @@ import org.fortiss.tooling.kernel.ui.service.IActionService;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: CAC7666747A324EF4462F4EFBC7F8303
* @ConQAT.Rating YELLOW Hash: 74EB9729504C0C47C54858BDC4F9A797
*/
public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T> {
......@@ -140,6 +148,9 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
protected static GridDataFactory fillControlFactory = GridDataFactory.swtDefaults()
.align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200);
/** Cached form object */
private ScrolledForm form;
/**
* Listener connected to the observable word rule of the scanner associated
* to the corresponding analysis
......@@ -148,7 +159,7 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
/**
* List of all sourceViewers on the form (needed to inform the on updates of
* glossary)
* glossary and requirement source)
*/
private List<SourceViewer> registeredSourceViewers;
......@@ -188,6 +199,7 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
/** {@inheritDoc} */
@Override
protected void setupScrolledForm(ScrolledForm form) {
this.form = form;
form.setText("Requirement " + editedObject.getReqId());
form.getToolBarManager().add(new ShowHierarchyAction(editedObject, getSite().getPage()));
......@@ -394,7 +406,7 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
protected void createSectionImages() {
Composite imageSection = createNewSection("Images", "");
imageSection.setLayout(new GridLayout(1, false));
new ImageSection(imageSection, toolkit, editedObject, dbc);
new ImageSection(imageSection, toolkit, editedObject, dbc, form);
}
/** Create other composites */
......@@ -513,6 +525,14 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
new UpdateListStrategy(POLICY_NEVER), new ListToWordRuleUpdateStrategy(
editedObject.getAnalysis()));
}
for(RequirementSource requirementSource : editedObject.getAnalysis()
.getRequirementSourceList()) {
dbc.bindList(ScannerManager.getScanner(editedObject.getAnalysis()).getObservableList(),
EMFObservables.observeList(requirementSource,
IHIERARCHIC_ELEMENT_CONTAINER__CONTAINED_ELEMENTS),
new UpdateListStrategy(POLICY_NEVER), new ListToWordRuleUpdateStrategy(
editedObject.getAnalysis()));
}
}
/** create a source viewer to show highlighted texts */
......@@ -520,7 +540,7 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
createSourceViewer(Composite parent, int styles, final Analysis analysis) {
final SourceViewer viewer = new SourceViewer(parent, null, styles);
viewer.setDocument(new Document());
viewer.configure(new GlossaryHighlightConfiguration(viewer, analysis));
viewer.configure(new ConnectionHighlightConfiguration(viewer, analysis));
Menu menu = new Menu(parent.getShell(), SWT.POP_UP);
final StyledText editor = viewer.getTextWidget();
......@@ -536,20 +556,142 @@ public class RequirementEditor<T extends Requirement> extends FormsEditorBase<T>
if(selectedText.equals("")) {
try {
IRegion caretRegion =
GlossaryUtils.findWord(viewer.getDocument(),
ConnetionUtils.findWord(viewer.getDocument(),
editor.getCaretOffset());
if(caretRegion == null || caretRegion.getLength() < 1) {
openError(form.getForm().getBody().getShell(), "no information",
"There is no informtion to create glossary entry");
return;
}
selectedText =
viewer.getDocument().get(caretRegion.getOffset(),
caretRegion.getLength());
if(!openConfirm(form.getForm().getBody().getShell(),
"no selected information", "There is no selected information.\n" +
"Would you like to create glossary entry with " +
selectedText))
return;
} catch(BadLocationException e1) {
return;
}
}
if(!selectedText.equals("")) {
(new CreateGlossaryEntryAction(analysis, selectedText, editor.getShell()))
.run();
// TODO ID problem Bug #983
(new CreateGlossaryEntryAction(analysis, selectedText, editor.getShell())).run();
}
});
MenuItem newStakeholderItem = new MenuItem(menu, SWT.PUSH);
newStakeholderItem.setText("Create stakeholder");
newStakeholderItem.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
String selectedText = editor.getSelectionText();
// if no word was selected take the one at the caret position
if(selectedText.equals("")) {
try {
IRegion caretRegion =
ConnetionUtils.findWord(viewer.getDocument(),
editor.getCaretOffset());
if(caretRegion == null || caretRegion.getLength() < 1) {
openError(form.getForm().getBody().getShell(), "no information",
"There is no informtion to create stakeholder");
return;
}
selectedText =
viewer.getDocument().get(caretRegion.getOffset(),
caretRegion.getLength());
if(!openConfirm(form.getForm().getBody().getShell(),
"no selected information", "There is no selected information.\n" +
"Would you like to create stakeholder with " + selectedText))
return;
} catch(BadLocationException e1) {
return;
}
}
final Stakeholder stakholder =
MiraModelElementFactory.createStakeholder(selectedText, "", "");
(new CreateRequirementSourceAction<Stakeholder>(analysis, stakholder, editor
.getShell())).run();
}
});
MenuItem newDocumentItem = new MenuItem(menu, SWT.PUSH);
newDocumentItem.setText("Create requirement document");
newDocumentItem.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
String selectedText = editor.getSelectionText();
// if no word was selected take the one at the caret position
if(selectedText.equals("")) {
try {
IRegion caretRegion =
ConnetionUtils.findWord(viewer.getDocument(),
editor.getCaretOffset());
if(caretRegion == null || caretRegion.getLength() < 1) {
openError(form.getForm().getBody().getShell(), "no information",
"There is no informtion to create document");
return;
}
selectedText =
viewer.getDocument().get(caretRegion.getOffset(),
caretRegion.getLength());
if(!openConfirm(form.getForm().getBody().getShell(),
"no selected information", "There is no selected information.\n" +
"Would you like to create document with " + selectedText))
return;
} catch(BadLocationException e1) {
return;
}
}
final RequirementDocument document =
MiraModelElementFactory.createRequirementDocument(selectedText, "", "");
(new CreateRequirementSourceAction<RequirementDocument>(analysis, document, editor
.getShell())).run();
}
});
MenuItem newExternalSystemItem = new MenuItem(menu, SWT.PUSH);
newExternalSystemItem.setText("Create external system");
newExternalSystemItem.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
String selectedText = editor.getSelectionText();
// if no word was selected take the one at the caret position
if(selectedText.equals("")) {
try {
IRegion caretRegion =
ConnetionUtils.findWord(viewer.getDocument(),
editor.getCaretOffset());
if(caretRegion == null || caretRegion.getLength() < 1) {
openError(form.getForm().getBody().getShell(), "no information",
"There is no informtion to create external system");
return;
}
selectedText =
viewer.getDocument().get(caretRegion.getOffset(),
caretRegion.getLength());
if(!openConfirm(form.getForm().getBody().getShell(),
"no selected information", "There is no selected information.\n" +
"Would you like to create external system with " +
selectedText))
return;
} catch(BadLocationException e1) {
return;
}
}
final ExternalSystem externalSystem =
MiraModelElementFactory.createExternalSystem(selectedText, "", "");
(new CreateRequirementSourceAction<ExternalSystem>(analysis, externalSystem, editor
.getShell())).run();
}
});
......
......@@ -71,7 +71,7 @@ import org.fortiss.tooling.kernel.ui.util.ObservableUtils;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0C5A0A07918917F97C0939C9E8CBDD28
* @ConQAT.Rating YELLOW Hash: FA6E86952E0867E461A36C67F8F39068