org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (view) (download)

1 : droberts 1.5 /*******************************************************************************
2 : mrennie 1.25 * Copyright (c) 2000, 2007 IBM Corporation and others.
3 : krbarnes 1.17 * All rights reserved. This program and the accompanying materials
4 : darins 1.18 * are made available under the terms of the Eclipse Public License v1.0
5 : droberts 1.5 * which accompanies this distribution, and is available at
6 : darins 1.18 * http://www.eclipse.org/legal/epl-v10.html
7 : darin 1.24 *
8 : droberts 1.5 * Contributors:
9 :     * IBM Corporation - initial API and implementation
10 :     *******************************************************************************/
11 : jszursze 1.1 package org.eclipse.jdt.internal.debug.ui.launcher;
12 :    
13 :     import java.lang.reflect.InvocationTargetException;
14 : darin 1.22
15 : darin 1.23 import org.eclipse.core.resources.IResource;
16 : jszursze 1.1 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 : jszursze 1.4 import org.eclipse.jdt.debug.ui.launchConfigurations.AppletParametersTab;
24 : jszursze 1.1 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
25 : darin 1.22 import org.eclipse.jface.operation.IRunnableContext;
26 : jszursze 1.1
27 : darin 1.22 public class JavaAppletLaunchShortcut extends JavaLaunchShortcut {
28 : jszursze 1.1
29 : darin 1.22 /* (non-Javadoc)
30 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#createConfiguration(org.eclipse.jdt.core.IType)
31 : jszursze 1.1 */
32 :     protected ILaunchConfiguration createConfiguration(IType type) {
33 :     ILaunchConfiguration config = null;
34 :     try {
35 : darin 1.22 ILaunchConfigurationType configType = getConfigurationType();
36 : jszursze 1.1 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 : jszursze 1.4 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
40 :     wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
41 : darin 1.22 wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
42 : mrennie 1.25 //CONTEXTLAUNCHING
43 :     wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
44 : jszursze 1.1 config = wc.doSave();
45 :     } catch (CoreException ce) {
46 : darin 1.22 reportErorr(ce);
47 : jszursze 1.1 }
48 :     return config;
49 :     }
50 :    
51 : darin 1.22 /* (non-Javadoc)
52 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getConfigurationType()
53 : jszursze 1.1 */
54 : darin 1.22 protected ILaunchConfigurationType getConfigurationType() {
55 : jszursze 1.1 ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
56 :     return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET);
57 : darin 1.22 }
58 :    
59 :     /* (non-Javadoc)
60 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#findTypes(java.lang.Object[])
61 :     */
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 : jszursze 1.1 }
69 : darin 1.22
70 :     /* (non-Javadoc)
71 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getTypeSelectionTitle()
72 : jszursze 1.1 */
73 : darin 1.22 protected String getTypeSelectionTitle() {
74 :     return LauncherMessages.JavaAppletLaunchShortcut_0;
75 : jszursze 1.1 }
76 : darin 1.22
77 :     /* (non-Javadoc)
78 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getEditorEmptyMessage()
79 :     */
80 :     protected String getEditorEmptyMessage() {
81 :     return LauncherMessages.JavaAppletLaunchShortcut_1;
82 : jszursze 1.1 }
83 : darins 1.13
84 : darin 1.22 /* (non-Javadoc)
85 :     * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getSelectionEmptyMessage()
86 :     */
87 :     protected String getSelectionEmptyMessage() {
88 :     return LauncherMessages.JavaAppletLaunchShortcut_2;
89 :     }
90 : droberts 1.5 }