]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.platform/src/org/simantics/browsing/ui/platform/debug/EvaluatorContribution.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.platform / src / org / simantics / browsing / ui / platform / debug / EvaluatorContribution.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.browsing.ui.platform.debug;\r
13 \r
14 import java.util.ArrayList;\r
15 import java.util.Collection;\r
16 \r
17 import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
18 import org.simantics.browsing.ui.common.EvaluatorData.EvaluatorTree;\r
19 import org.simantics.browsing.ui.common.contributor.FinalRootViewpointContributionContributor;\r
20 \r
21 public class EvaluatorContribution extends FinalRootViewpointContributionContributor<Evaluator> {\r
22 \r
23     private boolean isEmpty(EvaluatorTree<?> tree) {\r
24         return tree.getAcceptedFactories().isEmpty() && tree.getChildren().isEmpty();\r
25     }\r
26 \r
27     private void addNonEmpty(Collection<EvaluatorTree<?>> result, EvaluatorTree<?>... trees) {\r
28         for (EvaluatorTree<?> tree : trees)\r
29             if (!isEmpty(tree))\r
30                 result.add(tree);\r
31     }\r
32 \r
33     @Override\r
34     public Collection<?> getContribution(Evaluator input) {\r
35         //return NodeContextUtil.toContextCollectionWithInput(input.getViewpointTree(), input.getLabelerTree(), input.getImagerTree(), input.getLabelDecoratorTree(), input.getComparatorTree());\r
36         Collection<EvaluatorTree<?>> result = new ArrayList<EvaluatorTree<?>>();\r
37         addNonEmpty(result, input.getViewpointTree(), input.getLabelerTree(), input.getLabelDecoratorTree(), input.getImagerTree(), input.getComparableContextTree());\r
38         return result;\r
39     }\r
40 \r
41     @Override\r
42     public String getViewpointId() {\r
43         return "Evaluators";\r
44     }\r
45 \r
46 }\r