]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/DefaultImageDecoratorsProcessor.java
Use RuntimeEnvironmentRequest2 where applicable
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / DefaultImageDecoratorsProcessor.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.swt;
13
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17
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;
26
27 public class DefaultImageDecoratorsProcessor extends AbstractNodeQueryProcessor<Collection<ImageDecorator>> {
28
29     @Override
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();
34
35         Collection<ImageDecorator> decorators = new ArrayList<ImageDecorator>(factories.size());
36         for (ImageDecoratorFactory f : factories) {
37             assert f != null;
38             ImageDecorator decorator = manager.query(context, new ImageDecoratorKey(f));
39             if (decorator != null)
40                 decorators.add(decorator);
41         }
42
43         return decorators;
44     }
45
46     @Override
47     public String toString() {
48         return "ImageDecoratorsProcessor";
49     }
50
51     @Override
52     public QueryKey<Collection<ImageDecorator>> getIdentifier() {
53         return BuiltinKeys.IMAGE_DECORATORS;
54     }
55
56 }