1 11 package org.eclipse.jdt.internal.debug.ui.launcher; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.debug.core.DebugPlugin; 18 import org.eclipse.debug.core.ILaunchConfiguration; 19 import org.eclipse.debug.core.ILaunchConfigurationType; 20 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 21 import org.eclipse.debug.core.ILaunchManager; 22 import org.eclipse.jdt.core.IType; 23 import org.eclipse.jdt.debug.ui.launchConfigurations.AppletParametersTab; 24 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 25 import org.eclipse.jface.operation.IRunnableContext; 26 27 public class JavaAppletLaunchShortcut extends JavaLaunchShortcut { 28 29 32 protected ILaunchConfiguration createConfiguration(IType type) { 33 ILaunchConfiguration config = null; 34 try { 35 ILaunchConfigurationType configType = getConfigurationType(); 36 ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName())); 37 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); 38 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); 39 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH); 40 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT); 41 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); wc.setMappedResources(new IResource[] {type.getUnderlyingResource()}); 44 config = wc.doSave(); 45 } catch (CoreException ce) { 46 reportErorr(ce); 47 } 48 return config; 49 } 50 51 54 protected ILaunchConfigurationType getConfigurationType() { 55 ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager(); 56 return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET); 57 } 58 59 62 protected IType[] findTypes(Object [] elements, IRunnableContext context) throws InterruptedException , CoreException { 63 try { 64 return AppletLaunchConfigurationUtils.findApplets(context, elements); 65 } catch (InvocationTargetException e) { 66 throw (CoreException)e.getTargetException(); 67 } 68 } 69 70 73 protected String getTypeSelectionTitle() { 74 return LauncherMessages.JavaAppletLaunchShortcut_0; 75 } 76 77 80 protected String getEditorEmptyMessage() { 81 return LauncherMessages.JavaAppletLaunchShortcut_1; 82 } 83 84 87 protected String getSelectionEmptyMessage() { 88 return LauncherMessages.JavaAppletLaunchShortcut_2; 89 } 90 } 91 | Popular Tags |