core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java
changeset 1377 40401ea8b1fd
parent 1363 dfbd4576cd61
child 1378 9a387b0094c7
equal deleted inserted replaced
1376:120480c02651 1377:40401ea8b1fd
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation 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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
     1 package com.nokia.carbide.discovery.ui;
    17 package com.nokia.carbide.discovery.ui;
       
    18 
       
    19 import java.util.Collections;
       
    20 import java.util.Hashtable;
       
    21 import java.util.Map;
     2 
    22 
     3 import org.eclipse.core.runtime.IStatus;
    23 import org.eclipse.core.runtime.IStatus;
     4 import org.eclipse.core.runtime.Status;
    24 import org.eclipse.core.runtime.Status;
       
    25 import org.eclipse.equinox.p2.ui.Policy;
     5 import org.eclipse.jface.resource.ImageDescriptor;
    26 import org.eclipse.jface.resource.ImageDescriptor;
     6 import org.eclipse.ui.plugin.AbstractUIPlugin;
    27 import org.eclipse.ui.plugin.AbstractUIPlugin;
     7 import org.osgi.framework.BundleContext;
    28 import org.osgi.framework.BundleContext;
       
    29 import org.osgi.framework.ServiceRegistration;
     8 
    30 
     9 /**
    31 /**
    10  * The activator class controls the plug-in life cycle
    32  * The activator class controls the plug-in life cycle
    11  */
    33  */
    12 public class Activator extends AbstractUIPlugin {
    34 public class Activator extends AbstractUIPlugin {
    13 	// The plug-in ID
    35 	// The plug-in ID
    14 	public static final String PLUGIN_ID = "com.nokia.carbide.discovery.ui"; //$NON-NLS-1$
    36 	public static final String PLUGIN_ID = "com.nokia.carbide.discovery.ui"; //$NON-NLS-1$
    15 
    37 
    16 	// The shared instance
    38 	// The shared instance
    17 	private static Activator plugin;
    39 	private static Activator plugin;
       
    40 
       
    41 	private ServiceRegistration policyRegistration;
    18 
    42 
    19 	/**
    43 	/**
    20 	 * The constructor
    44 	 * The constructor
    21 	 */
    45 	 */
    22 	public Activator() {
    46 	public Activator() {
    26 	 * (non-Javadoc)
    50 	 * (non-Javadoc)
    27 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
    51 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
    28 	 */
    52 	 */
    29 	public void start(BundleContext context) throws Exception {
    53 	public void start(BundleContext context) throws Exception {
    30 		super.start(context);
    54 		super.start(context);
    31 		plugin = this;
    55 		Policy policy = new Policy();
       
    56 		policy.setRestartPolicy(Policy.RESTART_POLICY_PROMPT);
       
    57 		Map<String, Integer> map = Collections.singletonMap("service.ranking", 100);
       
    58 		policyRegistration = context.registerService(Policy.class.getName(), policy, new Hashtable<Object, Object>(map));
       
    59 		System.setProperty("eclipse.p2.unsignedPolicy", "allow");
    32 	}
    60 	}
    33 
    61 
    34 	/*
    62 	/*
    35 	 * (non-Javadoc)
    63 	 * (non-Javadoc)
    36 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
    64 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
    37 	 */
    65 	 */
    38 	public void stop(BundleContext context) throws Exception {
    66 	public void stop(BundleContext context) throws Exception {
       
    67 		policyRegistration.unregister();
       
    68 		super.stop(context);
    39 		plugin = null;
    69 		plugin = null;
    40 		super.stop(context);
       
    41 	}
    70 	}
    42 
    71 
    43 	/**
    72 	/**
    44 	 * Returns the shared instance
    73 	 * Returns the shared instance
    45 	 *
    74 	 *