Commit 831c7949 authored by Saad bin Abid's avatar Saad bin Abid
Browse files

Corrected EnumPropertySection.java and EnumerationMemberPropertySection.Java...

Corrected EnumPropertySection.java and EnumerationMemberPropertySection.Java classes as per reviews of Sudeep and turned them to Yellow.
parent cf4cbbbb
......@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
......@@ -54,7 +55,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @author eder
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 81258176678CFCE066C480961FCA3763
* @ConQAT.Rating YELLOW Hash: EA36FC4CB351DCB4EBFF141540E16ABC
*/
public class EnumPropertySection extends PropertySectionBase {
......@@ -69,8 +70,10 @@ public class EnumPropertySection extends PropertySectionBase {
/** The detach button. */
private Button detachButton;
// TODO (SK,4) Please rephrase
/** Stores enumeration implement the requirement correctly check button. */
/**
* Check button that enables the user to make the choice if enumeration implements the
* requirement.
*/
private Button enumerationImplReqButton;
/** Label for the "enumeration implement requirement" text. */
private Label enumerationImplreqLabel;
......@@ -128,10 +131,10 @@ public class EnumPropertySection extends PropertySectionBase {
@Override
protected void setSectionInput(Object input) {
enumeration = (Enumeration)input;
// TODO (SK,19) following expression should be refactored.
EList<ExternalRelationSpecification> externalRelationSpecs =
pickInstanceOf(ExternalRelationSpecification.class, enumeration.getSpecifications());
traces =
pickInstanceOf(ExternalRelationSpecification.class, enumeration.getSpecifications())
.stream()
externalRelationSpecs.stream()
.map(e -> e.getExternalRelation().getSourceRequirement().getReqId())
.collect(Collectors.toSet());
showTraces.setText(StringUtils.join(traces, ", "));
......@@ -143,14 +146,9 @@ public class EnumPropertySection extends PropertySectionBase {
enumerationImplReqButton.setEnabled(true);
enumerationImplreqLabel.setEnabled(true);
// check if the first instance of externalRelationSpecification is not null using get(0)
if(pickInstanceOf(ExternalRelationSpecification.class, enumeration.getSpecifications())
.get(0) != null) {
if(externalRelationSpecs.get(0) != null) {
// get(0) is to get the first instance of the externalRelationSpecification
// TODO (SK,20) pickInstanceOf(ExternalRelationSpecification.class,
// member.getSpecifications()) is used 3 times. Please make a local variable for it.
spec =
pickInstanceOf(ExternalRelationSpecification.class,
enumeration.getSpecifications()).get(0);
spec = externalRelationSpecs.get(0);
}
}
}
......
......@@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.swt.SWT;
......@@ -45,7 +46,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.PropertySectionBase;
* @author eder
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: BECACA0D25288CB31FD0F0579E0F2E4C
* @ConQAT.Rating YELLOW Hash: A4074EA9CDAAA3666905F425630A8FBD
*/
public final class EnumerationMemberPropertySection extends PropertySectionBase {
......@@ -58,8 +59,10 @@ public final class EnumerationMemberPropertySection extends PropertySectionBase
/** Text section showing the traces */
private Text showTraces;
// TODO (SK,4) Please rephrase
/** enumeration member implement the requirement correctly check button. */
/**
* Check button that enables the user to make the choice if enumerationMember implements the
* requirement.
*/
private Button enumerationMemberImplReqButton;
/** Label for the "enumeration member implement requirement" text. */
private Label enumerationMemberImplreqLabel;
......@@ -84,10 +87,10 @@ public final class EnumerationMemberPropertySection extends PropertySectionBase
@Override
protected void setSectionInput(Object input) {
member = (EnumerationMember)input;
// TODO (SK,19) following expression should be refactored.
EList<ExternalRelationSpecification> externalRelationSpecs =
pickInstanceOf(ExternalRelationSpecification.class, member.getSpecifications());
traces =
pickInstanceOf(ExternalRelationSpecification.class, member.getSpecifications())
.stream()
externalRelationSpecs.stream()
.map(e -> e.getExternalRelation().getSourceRequirement().getReqId())
.collect(Collectors.toSet());
showTraces.setText(StringUtils.join(traces, ", "));
......@@ -98,14 +101,9 @@ public final class EnumerationMemberPropertySection extends PropertySectionBase
enumerationMemberImplReqButton.setEnabled(true);
enumerationMemberImplreqLabel.setEnabled(true);
// check if the first instance of externalRelationSpecification is not null using get(0)
if(pickInstanceOf(ExternalRelationSpecification.class, member.getSpecifications()).get(
0) != null) {
if(externalRelationSpecs.get(0) != null) {
// get(0) is to get the first instance of the externalRelationSpecification
// TODO (SK,20) pickInstanceOf(ExternalRelationSpecification.class,
// member.getSpecifications()) is used 3 times. Please make a local variable for it.
spec =
pickInstanceOf(ExternalRelationSpecification.class,
member.getSpecifications()).get(0);
spec = externalRelationSpecs.get(0);
}
}
}
......
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