1 8 package com.mountainminds.eclemma.internal.ui.launching; 9 10 import org.eclipse.core.runtime.CoreException; 11 import org.eclipse.core.runtime.IConfigurationElement; 12 import org.eclipse.core.runtime.IExecutableExtension; 13 import org.eclipse.core.runtime.IExtensionPoint; 14 import org.eclipse.core.runtime.Platform; 15 import org.eclipse.debug.ui.IDebugUIConstants; 16 import org.eclipse.debug.ui.ILaunchShortcut; 17 import org.eclipse.jface.viewers.ISelection; 18 import org.eclipse.ui.IEditorPart; 19 20 import com.mountainminds.eclemma.core.CoverageTools; 21 import com.mountainminds.eclemma.internal.ui.EclEmmaUIPlugin; 22 23 35 public class CoverageLaunchShortcut implements ILaunchShortcut, IExecutableExtension { 36 37 private String delegateId; 38 private ILaunchShortcut delegate; 39 40 private ILaunchShortcut getDelegate() { 41 if (delegate == null) { 42 IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_LAUNCH_SHORTCUTS); 43 IConfigurationElement[] configs = extensionPoint.getConfigurationElements(); 44 for (int i = 0; i < configs.length; i++) { 45 if (delegateId.equals(configs[i].getAttribute("id"))) { try { 47 delegate = (ILaunchShortcut) configs[i].createExecutableExtension("class"); } catch (CoreException e) { 49 EclEmmaUIPlugin.log(e); 50 } 51 break; 52 } 53 } 54 if (delegate == null) { 55 String msg = "ILaunchShortcut declaration not found: " + delegateId; EclEmmaUIPlugin.getInstance().getLog().log(EclEmmaUIPlugin.errorStatus(msg, null)); 57 } 58 } 59 return delegate; 60 } 61 62 64 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { 65 delegateId = String.valueOf(data); 66 } 67 68 70 public void launch(ISelection selection, String mode) { 71 ILaunchShortcut delegate = getDelegate(); 72 if (delegate != null) { 73 delegate.launch(selection, CoverageTools.LAUNCH_MODE); 74 } 75 } 76 77 public void launch(IEditorPart editor, String mode) { 78 ILaunchShortcut delegate = getDelegate(); 79 if (delegate != null) { 80 delegate.launch(editor, CoverageTools.LAUNCH_MODE); 81 } 82 } 83 84 } 85 | Popular Tags |