]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ProviderImager.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / ProviderImager.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 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 org.simantics.browsing.ui.content.Imager;
15 import org.simantics.utils.datastructures.cache.IMapProvider;
16 import org.simantics.utils.datastructures.cache.ProvisionException;
17 import org.simantics.utils.ui.ErrorLogger;
18
19 /**
20  * @author Tuukka Lehtonen
21  */
22 public class ProviderImager<ImageDescriptor> implements Imager {
23
24     private final IMapProvider<String, ImageDescriptor> provider;
25
26     public ProviderImager(IMapProvider<String, ImageDescriptor> constants) {
27         this.provider = constants;
28     }
29
30     @SuppressWarnings("unchecked")
31     @Override
32     public ImageDescriptor getImage(String key) {
33         try {
34             return provider.get(key);
35         } catch (ProvisionException e) {
36             ErrorLogger.defaultLogError(e);
37             return null;
38         }
39     }
40
41 }