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.browsing.ui.swt;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
18 import org.simantics.browsing.ui.BuiltinKeys;
19 import org.simantics.browsing.ui.BuiltinKeys.ImageDecoratorKey;
20 import org.simantics.browsing.ui.NodeContext;
21 import org.simantics.browsing.ui.NodeContext.QueryKey;
22 import org.simantics.browsing.ui.NodeQueryManager;
23 import org.simantics.browsing.ui.common.processors.AbstractNodeQueryProcessor;
24 import org.simantics.browsing.ui.content.ImageDecorator;
25 import org.simantics.browsing.ui.content.ImageDecoratorFactory;
27 public class DefaultImageDecoratorsProcessor extends AbstractNodeQueryProcessor<Collection<ImageDecorator>> {
30 public Collection<ImageDecorator> query(NodeQueryManager manager, NodeContext context) {
31 Collection<ImageDecoratorFactory> factories = manager.query(context, BuiltinKeys.SELECTED_IMAGE_DECORATOR_FACTORIES);
32 if (factories.isEmpty())
33 return Collections.emptyList();
35 Collection<ImageDecorator> decorators = new ArrayList<ImageDecorator>(factories.size());
36 for (ImageDecoratorFactory f : factories) {
38 ImageDecorator decorator = manager.query(context, new ImageDecoratorKey(f));
39 if (decorator != null)
40 decorators.add(decorator);
47 public String toString() {
48 return "ImageDecoratorsProcessor";
52 public QueryKey<Collection<ImageDecorator>> getIdentifier() {
53 return BuiltinKeys.IMAGE_DECORATORS;