core/com.nokia.carbide.cpp/src/com/nokia/carbide/cpp/ProductPlugin.java
changeset 1377 40401ea8b1fd
parent 1373 512ef0799e33
child 1773 8d51e542dce4
equal deleted inserted replaced
1376:120480c02651 1377:40401ea8b1fd
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 package com.nokia.carbide.cpp;
    17 package com.nokia.carbide.cpp;
    18 
    18 
    19 import java.util.Collections;
       
    20 import java.util.Hashtable;
       
    21 import java.util.Map;
       
    22 
       
    23 import org.eclipse.ui.plugin.*;
       
    24 import org.eclipse.equinox.p2.ui.Policy;
       
    25 import org.eclipse.jface.resource.ImageDescriptor;
    19 import org.eclipse.jface.resource.ImageDescriptor;
       
    20 import org.eclipse.ui.plugin.AbstractUIPlugin;
    26 import org.osgi.framework.BundleContext;
    21 import org.osgi.framework.BundleContext;
    27 import org.osgi.framework.ServiceRegistration;
       
    28 
    22 
    29 /**
    23 /**
    30  * The main plugin class to be used in the desktop.
    24  * The main plugin class to be used in the desktop.
    31  */
    25  */
    32 public class ProductPlugin extends AbstractUIPlugin {
    26 public class ProductPlugin extends AbstractUIPlugin {
    33 
    27 
    34 	//The shared instance.
    28 	//The shared instance.
    35 	private static ProductPlugin plugin;
    29 	private static ProductPlugin plugin;
    36 	
    30 	
    37 	private ServiceRegistration policyRegistration;
       
    38 
       
    39 	/**
    31 	/**
    40 	 * The constructor.
    32 	 * The constructor.
    41 	 */
    33 	 */
    42 	public ProductPlugin() {
    34 	public ProductPlugin() {
    43 		plugin = this;
    35 		plugin = this;
    46 	/**
    38 	/**
    47 	 * This method is called upon plug-in activation
    39 	 * This method is called upon plug-in activation
    48 	 */
    40 	 */
    49 	public void start(BundleContext context) throws Exception {
    41 	public void start(BundleContext context) throws Exception {
    50 		super.start(context);
    42 		super.start(context);
    51 		Policy policy = new Policy();
       
    52 		policy.setRestartPolicy(Policy.RESTART_POLICY_PROMPT);
       
    53 		Map<String, Integer> map = Collections.singletonMap("service.ranking", 100);
       
    54 		policyRegistration = context.registerService(Policy.class.getName(), policy, new Hashtable<Object, Object>(map));
       
    55 	}
    43 	}
    56 
    44 
    57 	/**
    45 	/**
    58 	 * This method is called when the plug-in is stopped
    46 	 * This method is called when the plug-in is stopped
    59 	 */
    47 	 */
    60 	public void stop(BundleContext context) throws Exception {
    48 	public void stop(BundleContext context) throws Exception {
    61 		policyRegistration.unregister();
       
    62 		super.stop(context);
    49 		super.stop(context);
    63 		plugin = null;
    50 		plugin = null;
    64 	}
    51 	}
    65 
    52 
    66 	/**
    53 	/**