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