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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.structural.ui.modelBrowser.contributions;
\r
14 import java.util.Collection;
\r
16 import org.simantics.browsing.ui.common.EvaluatorImpl;
\r
17 import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;
\r
18 import org.simantics.browsing.ui.common.extension.EvaluatorFactory;
\r
19 import org.simantics.browsing.ui.content.ComparableContextFactory;
\r
20 import org.simantics.browsing.ui.content.ImagerFactory;
\r
21 import org.simantics.browsing.ui.content.LabelDecoratorFactory;
\r
22 import org.simantics.utils.ReflectionUtils;
\r
24 public abstract class PartialEvaluatorFactory<T> implements EvaluatorFactory {
\r
26 final private Class<?> clazz;
\r
28 public PartialEvaluatorFactory() {
\r
29 clazz = ReflectionUtils.getSingleParameterType(getClass());
\r
33 public Evaluator create(Collection<String> browseContexts) {
\r
34 EvaluatorImpl result = new EvaluatorImpl();
\r
35 double preference = getPreference();
\r
37 ComparableContextFactory factory = createComparableFactory();
\r
39 result.addComparator(factory, preference);
\r
42 LabelDecoratorFactory factory = createLabelDecoratorFactory();
\r
44 result.addLabelDecorator(factory, preference);
\r
47 ImagerFactory factory = createImagerFactory();
\r
49 result.addImager(factory, preference);
\r
54 protected double getPreference() {
\r
58 protected ComparableContextFactory createComparableFactory() {
\r
62 protected LabelDecoratorFactory createLabelDecoratorFactory() {
\r
66 protected ImagerFactory createImagerFactory() {
\r
71 public Class<?> getClazz() {
\r