Commit 2ba515b3 authored by Florian Rosenberger's avatar Florian Rosenberger
Browse files

Requirement Specification Editor added

refs 582
parent c74fddc4
......@@ -95,6 +95,12 @@
modelElementClass="org.fortiss.af3.mira.model.glossary.GlossaryEntry">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.mira.ui.editorbinding.RequirementSpecificationEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.mira.model.RequirementSpecification">
</modelElementClass>
</modelEditorBinding>
</extension>
<extension
point="org.eclipse.ui.views">
......@@ -112,5 +118,4 @@
restorable="false">
</view>
</extension>
</plugin>
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.editor;
import static org.eclipse.wb.swt.ResourceManager.getPluginImage;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_COMMENTED_ELEMENT__COMMENT;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.DECORATION_KEY;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import org.eclipse.jface.fieldassist.ControlDecoration;
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.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.fortiss.af3.mira.model.RequirementSpecification;
import org.fortiss.tooling.base.ui.editor.FormsEditorBase;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
/**
* Editor to edit a {@link RequirementSpecification}
*
* @author rosenberger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0E707906116FFBB8355E4FF725A711DC
*/
public class RequirementSpecificationEditor<T extends RequirementSpecification>
extends FormsEditorBase<T> {
/** single line label grid data factory */
protected static GridDataFactory singleLineLabelFactory = GridDataFactory
.swtDefaults().align(SWT.RIGHT, SWT.CENTER).grab(false, false);
/** single line input grid data factory */
protected static GridDataFactory singleLineInputFactory = GridDataFactory
.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
/** multi line label grid data factory */
protected static GridDataFactory multiLineLabelFactory = GridDataFactory
.swtDefaults().align(SWT.RIGHT, SWT.TOP).grab(false, false);
/** multi line input grid data factory */
protected static GridDataFactory multiLineInputFactory = GridDataFactory
.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.hint(SWT.DEFAULT, 120);
/** fill control grid data factory */
protected static GridDataFactory fillControlFactory = GridDataFactory
.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.hint(SWT.DEFAULT, 200);
/** {@inheritDoc} */
@Override
protected void setupScrolledForm(ScrolledForm form) {
form.setText("Requirement Specification " + editedObject.getName());
}
/** {@inheritDoc} */
@Override
protected void createSections() {
createSectionGeneral();
}
/** create general section */
protected void createSectionGeneral() {
Composite generalComposite = createNewSection("General",
"General information");
generalComposite.setLayout(new GridLayout(2, false));
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);
typeInput.setData(DECORATION_KEY, new ControlDecoration(typeInput,
SWT.LEFT | SWT.TOP));
Label titleLabel = toolkit.createLabel(generalComposite, "Title ",
SWT.READ_ONLY);
singleLineLabelFactory.applyTo(titleLabel);
Text titleInput = toolkit.createText(generalComposite,
editedObject.getName());
singleLineInputFactory.applyTo(titleInput);
bind(dbc, titleInput, editedObject, INAMED_ELEMENT__NAME);
Label fromLabel = toolkit.createLabel(generalComposite, "From ",
SWT.READ_ONLY);
singleLineLabelFactory.applyTo(fromLabel);
Button fromButton = toolkit.createButton(generalComposite, editedObject
.getRequirement().getReqId()
+ " - "
+ editedObject.getRequirement().getName(), SWT.PUSH);
fromButton.setImage(IModelElementHandlerService.INSTANCE
.getModelElementHandler(editedObject.getRequirement())
.getIcon());
fromButton.setToolTipText("Open "
+ editedObject.getReference().eClass().getName() + " Editor");
fromButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
IModelEditorBindingService.INSTANCE.openInEditor(editedObject
.getRequirement());
}
});
Label toLabel = toolkit.createLabel(generalComposite, "To ",
SWT.READ_ONLY);
singleLineLabelFactory.applyTo(toLabel);
Button toButton = toolkit.createButton(generalComposite, editedObject
.getSpecificationOf().eGet(INAMED_ELEMENT__NAME).toString(),
SWT.PUSH);
toButton.setImage(getPluginImage(PLUGIN_ID, "/icons/component.gif"));
toButton.setToolTipText("Open Component Editor");
toButton.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
IModelEditorBindingService.INSTANCE.openInEditor(editedObject
.getSpecificationOf());
}
});
Label commentLabel = toolkit.createLabel(generalComposite, "Comment ",
SWT.READ_ONLY);
multiLineLabelFactory.applyTo(commentLabel);
Text commentInput = toolkit.createText(generalComposite, "");
fillControlFactory.applyTo(commentInput);
bind(dbc, commentInput, editedObject, INAMED_COMMENTED_ELEMENT__COMMENT);
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.editorbinding;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.mira.model.RequirementSpecification;
import org.fortiss.af3.mira.ui.editor.RequirementSpecificationEditor;
import org.fortiss.tooling.kernel.ui.extension.IModelEditorBinding;
/**
* {@link IModelEditorBinding} for {@link RequirementSpecification}
*
* @author rosenberger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: F0DF092951DC624BCE270FF95AD2194E
*/
public class RequirementSpecificationEditorBinding implements
IModelEditorBinding<RequirementSpecification> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return RequirementSpecificationEditor.class;
}
/** {@inheritDoc} */
@Override
public String getLabel() {
return "RequirementSpecification";
}
/** {@inheritDoc} */
@Override
public int getPriority() {
return 2;
}
}
......@@ -23,6 +23,7 @@ import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import java.util.ArrayList;
import java.util.List;
import org.conqat.lib.commons.string.StringUtils;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.fortiss.af3.mira.model.RequirementSpecification;
......@@ -35,7 +36,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: F3F1370C6959786CC0462086C7C8BDA1
* @ConQAT.Rating YELLOW Hash: 54EF78CA374F347E5B9746E26761FD51
*/
public class RequirementSpecificationHandler extends
ModelElementHandlerBase<RequirementSpecification> {
......@@ -49,7 +50,8 @@ public class RequirementSpecificationHandler extends
/** {@inheritDoc} */
@Override
public String getDescription(RequirementSpecification element) {
return element.getComment();
return StringUtils.isEmpty(element.getComment()) ? "" : element
.getComment();
}
/** {@inheritDoc} */
......
......@@ -94,7 +94,13 @@
<eLiterals name="High" value="1" literal="High - Must-be"/>
<eLiterals name="Low" value="3" literal="Low - Delighter"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RequirementSpecification" eSuperTypes="platform:/plugin/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification platform:/plugin/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementReference platform:/plugin/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement"/>
<eClassifiers xsi:type="ecore:EClass" name="RequirementSpecification" eSuperTypes="platform:/plugin/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementSpecification platform:/plugin/org.fortiss.tooling.base/model/base.ecore#//element/IModelElementReference platform:/plugin/org.fortiss.tooling.kernel/model/kernel.ecore#//INamedCommentedElement">
<eOperations name="getRequirement" eType="#//Requirement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return RequirementSpecificationStaticImpl.getRequirement(this);"/>
</eAnnotations>
</eOperations>
</eClassifiers>
<eSubpackages name="usecase" nsURI="http://www.fortiss.org/af3/mira/usecase" nsPrefix="org-fortiss-af3-mira-usecase">
<eClassifiers xsi:type="ecore:EClass" name="UseCase" eSuperTypes="#//Requirement platform:/plugin/org.fortiss.tooling.base/model/base.ecore#//element/IHierarchicElementContainer">
<eOperations name="getScenariosList">
......
......@@ -46,7 +46,9 @@
<genOperations ecoreOperation="mira.ecore#//RequirementRelation/getTargetRequirement"/>
</genClasses>
<genClasses ecoreClass="mira.ecore#//RequirementConnector"/>
<genClasses ecoreClass="mira.ecore#//RequirementSpecification"/>
<genClasses ecoreClass="mira.ecore#//RequirementSpecification">
<genOperations ecoreOperation="mira.ecore#//RequirementSpecification/getRequirement"/>
</genClasses>
<nestedGenPackages prefix="Usecase" basePackage="org.fortiss.af3.mira.model" disposableProviderFactory="true"
ecorePackage="mira.ecore#//usecase">
<genEnums typeSafeEnumCompatible="false" ecoreEnum="mira.ecore#//usecase/ScenarioStepActionType">
......
......@@ -30,7 +30,7 @@ import org.fortiss.tooling.base.model.element.IModelElementReference;
* @author mou
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 102F98531F6E49D9A272AD8E83F103E9
* @ConQAT.Rating YELLOW Hash: F2C6B247F37A83FAD9CB0AF1BF29A66B
*/
public class CreateRequirementSpecificationCommand implements Runnable {
......@@ -65,7 +65,7 @@ public class CreateRequirementSpecificationCommand implements Runnable {
EcoreUtil.delete(ref);
}
}
spec.setName("Ref: " + req.getReqId());
spec.setName("Ref: " + req.getReqId() + " - " + req.getName());
target.getSpecificationsList().add(spec);
spec.setReference(req);
}
......
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.model.impl;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.RequirementSpecification;
/**
* Static implementation of {@link RequirementSpecification}
*
* @author rosenberger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 639150961F0E6E4B3F414B8A70340DAA
*/
public class RequirementSpecificationStaticImpl {
/**
* @param requirementSpecification
* @return Requirement
*/
public static Requirement getRequirement(
RequirementSpecification requirementSpecification) {
return (Requirement) requirementSpecification.getReference();
}
}
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