1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.ui.icons;
\r
14 import org.eclipse.jface.resource.ImageDescriptor;
\r
15 import org.osgi.framework.Bundle;
\r
16 import org.simantics.db.ReadGraph;
\r
17 import org.simantics.db.Resource;
\r
18 import org.simantics.utils.datastructures.cache.ProvisionException;
\r
19 import org.simantics.utils.ui.BundleUtils;
\r
22 * FIXME: http://www.simantics.org/Layer0-1.0/HasModelledIcon no longer exists!
\r
24 public class GraphOrBundleImageDescriptorProvider implements ImageDescriptorProvider {
\r
26 private final Bundle bundle;
\r
27 private final String path;
\r
28 private ImageDescriptor desc;
\r
30 public GraphOrBundleImageDescriptorProvider(ReadGraph graph, final Resource resource, Bundle bundle, String path) {
\r
31 assert bundle != null;
\r
32 assert path != null;
\r
33 this.bundle = bundle;
\r
35 //System.out.println("new bundle image descriptor: " + bundle + ", " + path);
\r
39 public ImageDescriptor get() throws ProvisionException {
\r
41 desc = BundleUtils.getImageDescriptorFromBundle(bundle, path);
\r
43 throw new ProvisionException("Could not find image in bundle '" + bundle + "' at path + '" + path + "'");
\r
44 // desc = ImageDescriptor.getMissingImageDescriptor();
\r