Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-01-13 15:55:37 +0000
committerStephane Begaudeau2016-01-28 08:41:05 +0000
commit08333be9d80edbf1bf5bc3c6f8ea6d1b033033eb (patch)
tree04085ff4cea251567a1c42ce3243067f388bbb07
parentbba8378db4dfec0d850b5003f46c351e9f6ff109 (diff)
downloadorg.eclipse.eef-08333be9d80edbf1bf5bc3c6f8ea6d1b033033eb.tar.gz
org.eclipse.eef-08333be9d80edbf1bf5bc3c6f8ea6d1b033033eb.tar.xz
org.eclipse.eef-08333be9d80edbf1bf5bc3c6f8ea6d1b033033eb.zip
[482528] Simplify EEFViewImpl.createPage()
Bug: 482528 Change-Id: I7c24bb9008b2f4b6b1b30e4e8d8760eb1b08bf82 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/EEFViewImpl.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/EEFViewImpl.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/EEFViewImpl.java
index bcad88703..109e453fc 100644
--- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/EEFViewImpl.java
+++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/EEFViewImpl.java
@@ -118,20 +118,12 @@ public class EEFViewImpl implements EEFView {
* @return an actual {@link EEFPage} setup according to the description.
*/
private EEFPageImpl createPage(EEFPageDescription description) {
- EEFPageImpl page = null;
- final String semanticCandidateExpression = description.getSemanticCandidateExpression();
- if (!isBlank(semanticCandidateExpression)) {
- IEvaluationResult evaluationResult = this.interpreter
- .evaluateExpression(this.variableManager.getVariables(), semanticCandidateExpression);
- if (evaluationResult.success()) {
- IVariableManager childVariableManager = this.variableManager.createChild();
- childVariableManager.put(EEFExpressionUtils.SELF, evaluationResult.getValue());
- page = new EEFPageImpl(this, description, childVariableManager, this.interpreter, this.editingDomain);
- }
- } else {
- page = new EEFPageImpl(this, description, this.variableManager.createChild(), this.interpreter, this.editingDomain);
+ Object candidate = computeCandidate(this.variableManager, description.getSemanticCandidateExpression());
+ IVariableManager childVariableManager = this.variableManager.createChild();
+ if (candidate != null) {
+ childVariableManager.put(EEFExpressionUtils.SELF, candidate);
}
- return page;
+ return new EEFPageImpl(this, description, childVariableManager, this.interpreter, this.editingDomain);
}
/**
@@ -197,6 +189,25 @@ public class EEFViewImpl implements EEFView {
}
/**
+ * Helper to evaluate a SemanticCandidateExpression.
+ *
+ * @param context
+ * the evaluation context (variables).
+ * @param expression
+ * the expression to evaluate.
+ * @return the result, or <code>null</code> if the evaluation failed.
+ */
+ private Object computeCandidate(IVariableManager context, String expression) {
+ if (!isBlank(expression)) {
+ IEvaluationResult evaluationResult = interpreter.evaluateExpression(context.getVariables(), expression);
+ if (evaluationResult.success()) {
+ return evaluationResult.getValue();
+ }
+ }
+ return null;
+ }
+
+ /**
* Tests if a string is blank (i.e. null, empty, or containing only whitespace).
*
* @param s

Back to the top