01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.ui.launcher;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.core.runtime.IProgressMonitor;
14: import org.eclipse.core.runtime.IStatus;
15: import org.eclipse.core.runtime.Status;
16: import org.eclipse.debug.core.ILaunch;
17: import org.eclipse.debug.core.ILaunchConfiguration;
18: import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
19: import org.eclipse.osgi.util.NLS;
20: import org.eclipse.pde.internal.ui.IPDEUIConstants;
21: import org.eclipse.pde.internal.ui.PDEPlugin;
22: import org.eclipse.pde.internal.ui.PDEUIMessages;
23: import org.eclipse.pde.internal.ui.launcher.OSGiFrameworkManager;
24:
25: /**
26: * A launch delegate for launching OSGi frameworks
27: * <p>
28: * Clients may subclass and instantiate this class.
29: * </p>
30: * @since 3.3
31: */
32: public class OSGiLaunchConfigurationDelegate extends
33: 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 mode,
42: ILaunch launch, IProgressMonitor monitor)
43: throws CoreException {
44: OSGiFrameworkManager manager = PDEPlugin.getDefault()
45: .getOSGiFrameworkManager();
46: String id = configuration.getAttribute(
47: IPDELauncherConstants.OSGI_FRAMEWORK_ID, manager
48: .getDefaultFramework());
49: LaunchConfigurationDelegate launcher = manager
50: .getFrameworkLauncher(id);
51: if (launcher != null) {
52: launcher.launch(configuration, mode, launch, monitor);
53: } else {
54: String name = manager.getFrameworkName(id);
55: if (name == null)
56: name = PDEUIMessages.OSGiLaunchConfiguration_selected;
57: String message = NLS
58: .bind(
59: PDEUIMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration,
60: name);
61: IStatus status = new Status(IStatus.ERROR,
62: IPDEUIConstants.PLUGIN_ID, IStatus.OK, message,
63: null);
64: throw new CoreException(status);
65: }
66: }
67:
68: }
|