org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/TMWCoreUI.java
changeset 461 7a8f9fa8d278
child 463 aea4c83725d8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/TMWCoreUI.java	Mon Aug 09 15:18:34 2010 -0700
@@ -0,0 +1,108 @@
+package org.symbian.tools.tmw.ui;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.symbian.tools.tmw.core.projects.IMTWProject;
+import org.symbian.tools.tmw.internal.deployment.DeploymentTargetPresentationsManager;
+import org.symbian.tools.tmw.internal.deployment.DeploymentTargetTypesRegistry;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class TMWCoreUI extends AbstractUIPlugin {
+    private final Map<IProject, ProjectMemo> MEMOS = new WeakHashMap<IProject, ProjectMemo>();
+    private final DeploymentTargetTypesRegistry typesRegistry = new DeploymentTargetTypesRegistry();
+
+    // The plug-in ID
+    public static final String PLUGIN_ID = "org.symbian.tools.tmw.ui"; //$NON-NLS-1$
+
+    // The shared instance
+    private static TMWCoreUI plugin;
+    private Images images;
+    private final DeploymentTargetPresentationsManager presentations = new DeploymentTargetPresentationsManager();
+
+    /**
+     * The constructor
+     */
+    public TMWCoreUI() {
+    }
+
+    @Override
+    protected void initializeImageRegistry(ImageRegistry reg) {
+        super.initializeImageRegistry(reg);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+     */
+    public void start(BundleContext context) throws Exception {
+        super.start(context);
+        plugin = this;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+     */
+    public void stop(BundleContext context) throws Exception {
+        plugin = null;
+        super.stop(context);
+    }
+
+    /**
+     * Returns the shared instance
+     *
+     * @return the shared instance
+     */
+    public static TMWCoreUI getDefault() {
+        return plugin;
+    }
+
+    public static void log(String message, Exception e) {
+        getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, e));
+    }
+
+    public static void log(String message, Object... args) {
+        log(String.format(message, args), (Exception) null);
+    }
+
+    public static void log(Exception e) {
+        log(null, e);
+    }
+
+    public static ProjectMemo getMemo(IMTWProject project) {
+        return getDefault().getMemoForProject(project);
+    }
+
+    private synchronized ProjectMemo getMemoForProject(IMTWProject project) {
+        ProjectMemo memo = MEMOS.get(project.getProject());
+        if (memo == null) {
+            memo = new ProjectMemo(project);
+            MEMOS.put(project.getProject(), memo);
+        }
+        return memo;
+    }
+
+    public DeploymentTargetTypesRegistry getDeploymentTypesRegistry() {
+        return typesRegistry;
+    }
+
+    public static Images getImages() {
+        if (getDefault().images == null) {
+            getDefault().images = new Images(getDefault().getImageRegistry());
+        }
+        return getDefault().images;
+    }
+
+    public DeploymentTargetPresentationsManager getPresentations() {
+        return presentations;
+    }
+}