KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > ui > launcher > OSGiLaunchConfigurationDelegate


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.ui.launcher;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.debug.core.ILaunch;
18 import org.eclipse.debug.core.ILaunchConfiguration;
19 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
20 import org.eclipse.osgi.util.NLS;
21 import org.eclipse.pde.internal.ui.IPDEUIConstants;
22 import org.eclipse.pde.internal.ui.PDEPlugin;
23 import org.eclipse.pde.internal.ui.PDEUIMessages;
24 import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
25
26 /**
27  * A launch delegate for launching OSGi frameworks
28  * <p>
29  * Clients may subclass and instantiate this class.
30  * </p>
31  * @since 3.3
32  */

33 public class OSGiLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
34     
35     /**
36      * Delegates to the launcher delegate associated with the OSGi framwork
37      * selected in the launch configuration.
38      *
39      * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
40      */

41     public void launch(ILaunchConfiguration configuration, String JavaDoc mode,
42             ILaunch launch, IProgressMonitor monitor) throws CoreException {
43         OSGiFrameworkManager manager = PDEPlugin.getDefault().getOSGiFrameworkManager();
44         String JavaDoc id = configuration.getAttribute(IPDELauncherConstants.OSGI_FRAMEWORK_ID,
45                                                manager.getDefaultFramework());
46         LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id);
47         if (launcher != null) {
48             launcher.launch(configuration, mode, launch, monitor);
49         } else {
50             String JavaDoc name = manager.getFrameworkName(id);
51             if (name == null)
52                 name = PDEUIMessages.OSGiLaunchConfiguration_selected;
53             String JavaDoc message = NLS.bind(PDEUIMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name);
54             IStatus status = new Status(IStatus.ERROR, IPDEUIConstants.PLUGIN_ID, IStatus.OK, message , null);
55             throw new CoreException(status);
56         }
57     }
58     
59 }
60
Popular Tags