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.structural.ui;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.resource.JFaceResources;
16 import org.eclipse.jface.resource.LocalResourceManager;
17 import org.eclipse.jface.resource.ResourceManager;
18 import org.eclipse.swt.widgets.Display;
19 import org.eclipse.ui.plugin.AbstractUIPlugin;
20 import org.osgi.framework.Bundle;
21 import org.osgi.framework.BundleContext;
24 * The activator class controls the plug-in life cycle
26 public class Activator extends AbstractUIPlugin {
29 public static final String PLUGIN_ID = "org.simantics.structural.ui";
31 // The shared instance
32 private static Activator plugin;
34 private static LocalResourceManager resourceManager;
36 public static ImageDescriptor SYNCED_ICON;
37 public static ImageDescriptor SHOW_ALL_CHILDREN_ICON;
38 public static ImageDescriptor LOCK;
48 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
51 public void start(BundleContext context) throws Exception {
55 Bundle bundle = context.getBundle();
57 SYNCED_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/synced.gif"));
58 SHOW_ALL_CHILDREN_ICON = ImageDescriptor.createFromURL(bundle.getResource("icons/text_linespacing.png"));
59 LOCK = ImageDescriptor.createFromURL(bundle.getResource("icons/lock.png"));
64 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
67 public void stop(BundleContext context) throws Exception {
68 if (resourceManager != null) {
69 resourceManager.dispose();
70 resourceManager = null;
78 * Returns the shared instance
80 * @return the shared instance
82 public static Activator getDefault() {
86 public static ResourceManager initializeResourceManager(Display display) {
87 if (resourceManager == null) {
88 resourceManager = new LocalResourceManager(JFaceResources.getResources(display));
90 return resourceManager;
93 public static ResourceManager getResources() {
94 if (resourceManager == null)
95 throw new IllegalStateException("ResourceManager of bundle '" + PLUGIN_ID + "' is not initialized.");
96 return resourceManager;