| 1 | package de.uka.ipd.sdq.pcmbench.tabs.parameters; |
| 2 | |
| 3 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
| 4 | |
| 5 | import de.uka.ipd.sdq.pcm.parameter.VariableUsage; |
| 6 | import de.uka.ipd.sdq.pcm.stochasticexpressions.PCMStoExPrettyPrintVisitor; |
| 7 | |
| 8 | /** |
| 9 | * The class build a container for VariableUsage value. IsEdited value will by |
| 10 | * set: |
| 11 | * - if VariableUsage belong to BasicComponente on 'false'. |
| 12 | * - if VariableUsage belong to AssemblyContect on 'true'. |
| 13 | */ |
| 14 | public class VariableUsageWrapper extends EObjectImpl { |
| 15 | |
| 16 | private VariableUsage variableUsage = null; |
| 17 | private boolean isEdited = false; |
| 18 | |
| 19 | |
| 20 | public VariableUsageWrapper() { |
| 21 | } |
| 22 | |
| 23 | public VariableUsageWrapper(VariableUsage variableUsage) { |
| 24 | this.variableUsage = variableUsage; |
| 25 | } |
| 26 | |
| 27 | |
| 28 | public VariableUsageWrapper(VariableUsage variableUsage, boolean isEdited) { |
| 29 | this.variableUsage = variableUsage; |
| 30 | this.isEdited = isEdited; |
| 31 | } |
| 32 | |
| 33 | |
| 34 | /** |
| 35 | * @return the variableUsage |
| 36 | */ |
| 37 | public VariableUsage getVariableUsage() { |
| 38 | return variableUsage; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * @param variableUsage the variableUsage to set |
| 44 | */ |
| 45 | public void setVariableUsage(VariableUsage variableUsage) { |
| 46 | this.variableUsage = variableUsage; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * @return the isEdited |
| 52 | */ |
| 53 | public boolean isEdited() { |
| 54 | return isEdited; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | /** |
| 59 | * @param isEdited the isEdited to set |
| 60 | */ |
| 61 | public void setEdited(boolean isEdited) { |
| 62 | this.isEdited = isEdited; |
| 63 | } |
| 64 | |
| 65 | /* (non-Javadoc) |
| 66 | * @see java.lang.Object#equals(java.lang.Object) |
| 67 | */ |
| 68 | @Override |
| 69 | public boolean equals(Object eObject) { |
| 70 | if (eObject instanceof VariableUsageWrapper) { |
| 71 | VariableUsageWrapper wrapper = (VariableUsageWrapper) eObject; |
| 72 | return getName(variableUsage).equals( |
| 73 | getName(wrapper.getVariableUsage())); |
| 74 | |
| 75 | } |
| 76 | return super.equals(eObject); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | private String getName(VariableUsage variableUsage){ |
| 81 | return new PCMStoExPrettyPrintVisitor().prettyPrint(variableUsage); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | } |