-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.structural.ui.modelBrowser.contributions;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.browsing.ui.common.EvaluatorImpl;\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.common.extension.EvaluatorFactory;\r
-import org.simantics.browsing.ui.content.ComparableContextFactory;\r
-import org.simantics.browsing.ui.content.ImagerFactory;\r
-import org.simantics.browsing.ui.content.LabelDecoratorFactory;\r
-import org.simantics.utils.ReflectionUtils;\r
-\r
-public abstract class PartialEvaluatorFactory<T> implements EvaluatorFactory {\r
-\r
- final private Class<?> clazz;\r
-\r
- public PartialEvaluatorFactory() {\r
- clazz = ReflectionUtils.getSingleParameterType(getClass());\r
- }\r
- \r
- @Override\r
- public Evaluator create(Collection<String> browseContexts) {\r
- EvaluatorImpl result = new EvaluatorImpl();\r
- double preference = getPreference();\r
- {\r
- ComparableContextFactory factory = createComparableFactory();\r
- if(factory != null)\r
- result.addComparator(factory, preference);\r
- }\r
- {\r
- LabelDecoratorFactory factory = createLabelDecoratorFactory();\r
- if(factory != null)\r
- result.addLabelDecorator(factory, preference);\r
- }\r
- {\r
- ImagerFactory factory = createImagerFactory();\r
- if(factory != null)\r
- result.addImager(factory, preference);\r
- }\r
- return result;\r
- }\r
- \r
- protected double getPreference() {\r
- return 1.0;\r
- }\r
- \r
- protected ComparableContextFactory createComparableFactory() {\r
- return null;\r
- }\r
- \r
- protected LabelDecoratorFactory createLabelDecoratorFactory() {\r
- return null;\r
- } \r
- \r
- protected ImagerFactory createImagerFactory() {\r
- return null;\r
- } \r
-\r
- @Override\r
- public Class<?> getClazz() {\r
- return clazz;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.structural.ui.modelBrowser.contributions;
+
+import java.util.Collection;
+
+import org.simantics.browsing.ui.common.EvaluatorImpl;
+import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;
+import org.simantics.browsing.ui.common.extension.EvaluatorFactory;
+import org.simantics.browsing.ui.content.ComparableContextFactory;
+import org.simantics.browsing.ui.content.ImagerFactory;
+import org.simantics.browsing.ui.content.LabelDecoratorFactory;
+import org.simantics.utils.ReflectionUtils;
+
+public abstract class PartialEvaluatorFactory<T> implements EvaluatorFactory {
+
+ final private Class<?> clazz;
+
+ public PartialEvaluatorFactory() {
+ clazz = ReflectionUtils.getSingleParameterType(getClass());
+ }
+
+ @Override
+ public Evaluator create(Collection<String> browseContexts) {
+ EvaluatorImpl result = new EvaluatorImpl();
+ double preference = getPreference();
+ {
+ ComparableContextFactory factory = createComparableFactory();
+ if(factory != null)
+ result.addComparator(factory, preference);
+ }
+ {
+ LabelDecoratorFactory factory = createLabelDecoratorFactory();
+ if(factory != null)
+ result.addLabelDecorator(factory, preference);
+ }
+ {
+ ImagerFactory factory = createImagerFactory();
+ if(factory != null)
+ result.addImager(factory, preference);
+ }
+ return result;
+ }
+
+ protected double getPreference() {
+ return 1.0;
+ }
+
+ protected ComparableContextFactory createComparableFactory() {
+ return null;
+ }
+
+ protected LabelDecoratorFactory createLabelDecoratorFactory() {
+ return null;
+ }
+
+ protected ImagerFactory createImagerFactory() {
+ return null;
+ }
+
+ @Override
+ public Class<?> getClazz() {
+ return clazz;
+ }
+
+}