plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/internal/Activator.java
changeset 471 06589bf52fa7
child 484 f5df819c1852
equal deleted inserted replaced
470:d4809db37847 471:06589bf52fa7
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Symbian Foundation - initial contribution.
       
    11  * Contributors:
       
    12  * Description:
       
    13  * Overview:
       
    14  * Details:
       
    15  * Platforms/Drives/Compatibility:
       
    16  * Assumptions/Requirement/Pre-requisites:
       
    17  * Failures and causes:
       
    18  *******************************************************************************/
       
    19 package org.symbian.tools.tmw.debug.internal;
       
    20 
       
    21 import java.util.logging.Level;
       
    22 import java.util.logging.Logger;
       
    23 
       
    24 import org.eclipse.core.runtime.IStatus;
       
    25 import org.eclipse.core.runtime.Platform;
       
    26 import org.eclipse.core.runtime.Status;
       
    27 import org.eclipse.jface.resource.ImageRegistry;
       
    28 import org.eclipse.ui.plugin.AbstractUIPlugin;
       
    29 import org.osgi.framework.BundleContext;
       
    30 import org.symbian.tools.tmw.debug.internal.launch.ChromeInstancesManager;
       
    31 
       
    32 /**
       
    33  * The activator class controls the plug-in life cycle
       
    34  */
       
    35 public class Activator extends AbstractUIPlugin {
       
    36 
       
    37 	// The plug-in ID
       
    38 	public static final String PLUGIN_ID = "org.symbian.tools.wrttools.debug.core";
       
    39 
       
    40 	public static final boolean DEBUG = Platform.inDebugMode() && Boolean.valueOf(Platform.getDebugOption(PLUGIN_ID + "/debug")); 
       
    41 	public static final boolean DEBUG_CONNECTION = DEBUG && Boolean.valueOf(Platform.getDebugOption(PLUGIN_ID + "/debugConnection")); 
       
    42 	public static final boolean DEBUG_RESOURCES = DEBUG && Boolean.valueOf(Platform.getDebugOption(PLUGIN_ID + "/debugResources")); 
       
    43 	public static final boolean DEBUG_BREAKPOINTS = DEBUG
       
    44 			&& Boolean.valueOf(Platform.getDebugOption(PLUGIN_ID
       
    45 					+ "/debugBreakpoints")); 
       
    46 	
       
    47 	// The shared instance
       
    48 	private static Activator plugin;
       
    49 
       
    50 	private final ChromeInstancesManager chromes = new ChromeInstancesManager();
       
    51 	
       
    52 	/**
       
    53 	 * The constructor
       
    54 	 */
       
    55 	public Activator() {
       
    56 	}
       
    57 
       
    58 	/*
       
    59 	 * (non-Javadoc)
       
    60 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
       
    61 	 */
       
    62 	public void start(BundleContext context) throws Exception {
       
    63 		super.start(context);
       
    64         Logger.getLogger("org.chromium.sdk").setLevel(Level.WARNING);
       
    65 		plugin = this;
       
    66 	}
       
    67 
       
    68 	/*
       
    69 	 * (non-Javadoc)
       
    70 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
       
    71 	 */
       
    72 	public void stop(BundleContext context) throws Exception {
       
    73 		plugin = null;
       
    74 		chromes.shutdown();
       
    75 		super.stop(context);
       
    76 	}
       
    77 
       
    78 	/**
       
    79 	 * Returns the shared instance
       
    80 	 *
       
    81 	 * @return the shared instance
       
    82 	 */
       
    83 	public static Activator getDefault() {
       
    84 		return plugin;
       
    85 	}
       
    86 
       
    87 	public ChromeInstancesManager getChromeInstancesManager() {
       
    88 		return chromes;
       
    89 	}
       
    90 
       
    91 	public static void log(Throwable e) {
       
    92 		log(e.getLocalizedMessage(), e);
       
    93 	}
       
    94 
       
    95 	private static void log(String message, Throwable exception) {
       
    96 		getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message, exception));
       
    97 	}
       
    98 
       
    99 	@Override
       
   100 	protected void initializeImageRegistry(ImageRegistry reg) {
       
   101 		Images.initImageRegistry(reg);
       
   102 	}
       
   103 
       
   104 	public static void log(String message) {
       
   105 		log(message, null);
       
   106 	}
       
   107 }