1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.structural.ui.modelBrowser.contributions;
14 import java.util.Collection;
16 import org.simantics.browsing.ui.common.EvaluatorImpl;
17 import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;
18 import org.simantics.browsing.ui.common.extension.EvaluatorFactory;
19 import org.simantics.browsing.ui.content.ComparableContextFactory;
20 import org.simantics.browsing.ui.content.ImagerFactory;
21 import org.simantics.browsing.ui.content.LabelDecoratorFactory;
22 import org.simantics.utils.ReflectionUtils;
24 public abstract class PartialEvaluatorFactory<T> implements EvaluatorFactory {
26 final private Class<?> clazz;
28 public PartialEvaluatorFactory() {
29 clazz = ReflectionUtils.getSingleParameterType(getClass());
33 public Evaluator create(Collection<String> browseContexts) {
34 EvaluatorImpl result = new EvaluatorImpl();
35 double preference = getPreference();
37 ComparableContextFactory factory = createComparableFactory();
39 result.addComparator(factory, preference);
42 LabelDecoratorFactory factory = createLabelDecoratorFactory();
44 result.addLabelDecorator(factory, preference);
47 ImagerFactory factory = createImagerFactory();
49 result.addImager(factory, preference);
54 protected double getPreference() {
58 protected ComparableContextFactory createComparableFactory() {
62 protected LabelDecoratorFactory createLabelDecoratorFactory() {
66 protected ImagerFactory createImagerFactory() {
71 public Class<?> getClazz() {