KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > launcher > JavaAppletLaunchShortcut


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.jdt.internal.debug.ui.launcher;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
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     /* (non-Javadoc)
30      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#createConfiguration(org.eclipse.jdt.core.IType)
31      */

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, ""); //$NON-NLS-1$
42
//CONTEXTLAUNCHING
43
wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
44             config = wc.doSave();
45         } catch (CoreException ce) {
46             reportErorr(ce);
47         }
48         return config;
49     }
50     
51     /* (non-Javadoc)
52      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getConfigurationType()
53      */

54     protected ILaunchConfigurationType getConfigurationType() {
55         ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
56         return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET);
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#findTypes(java.lang.Object[])
61      */

62     protected IType[] findTypes(Object JavaDoc[] elements, IRunnableContext context) throws InterruptedException JavaDoc, CoreException {
63         try {
64             return AppletLaunchConfigurationUtils.findApplets(context, elements);
65         } catch (InvocationTargetException JavaDoc e) {
66             throw (CoreException)e.getTargetException();
67         }
68     }
69
70     /* (non-Javadoc)
71      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getTypeSelectionTitle()
72      */

73     protected String JavaDoc getTypeSelectionTitle() {
74         return LauncherMessages.JavaAppletLaunchShortcut_0;
75     }
76
77     /* (non-Javadoc)
78      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getEditorEmptyMessage()
79      */

80     protected String JavaDoc getEditorEmptyMessage() {
81         return LauncherMessages.JavaAppletLaunchShortcut_1;
82     }
83
84     /* (non-Javadoc)
85      * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getSelectionEmptyMessage()
86      */

87     protected String JavaDoc getSelectionEmptyMessage() {
88         return LauncherMessages.JavaAppletLaunchShortcut_2;
89     }
90 }
91
Popular Tags