--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.browsing.ui.swt;\r
+\r
+import org.simantics.browsing.ui.content.Imager;\r
+import org.simantics.utils.datastructures.cache.IMapProvider;\r
+import org.simantics.utils.datastructures.cache.ProvisionException;\r
+import org.simantics.utils.ui.ErrorLogger;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ProviderImager<ImageDescriptor> implements Imager {\r
+\r
+ private final IMapProvider<String, ImageDescriptor> provider;\r
+\r
+ public ProviderImager(IMapProvider<String, ImageDescriptor> constants) {\r
+ this.provider = constants;\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public ImageDescriptor getImage(String key) {\r
+ try {\r
+ return provider.get(key);\r
+ } catch (ProvisionException e) {\r
+ ErrorLogger.defaultLogError(e);\r
+ return null;\r
+ }\r
+ }\r
+\r
+}\r