Bug 114609 - Java main tab/shortcut should use new type selection dialog
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/AppletMainTab.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/AppletMainTab.java
index 8302d35..8574337 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/AppletMainTab.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/AppletMainTab.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jdt.debug.ui.launchConfigurations;
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -17,14 +19,18 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
-import org.eclipse.jdt.internal.debug.ui.launcher.AppletSelectionDialog;
-import org.eclipse.jdt.internal.debug.ui.launcher.SharedJavaMainTab;
+import org.eclipse.jdt.internal.debug.ui.launcher.AppletLaunchConfigurationUtils;
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
+import org.eclipse.jdt.internal.debug.ui.launcher.SharedJavaMainTab;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.window.Window;
@@ -40,6 +46,7 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
/**
* This tab appears for java applet launch configurations and allows the user to edit
@@ -138,10 +145,45 @@
* Show a dialog that lists all main types
*/
protected void handleSearchButtonSelected() {
- IJavaProject javaProject = getJavaProject();
- AppletSelectionDialog dialog = new AppletSelectionDialog(getShell(), getLaunchConfigurationDialog(), javaProject);
+ IJavaElement[] scope= null;
+ IJavaProject project = getJavaProject();
+ if (scope == null) {
+ try {
+ scope = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
+ }//end try
+ catch (JavaModelException e) {
+ setErrorMessage(e.getMessage());
+ return;
+ }//end catch
+ }//end if
+ else {
+ scope = new IJavaElement[]{project};
+ }//end else
+ IType[] types = null;
+ try {
+ types = AppletLaunchConfigurationUtils.findApplets(getLaunchConfigurationDialog(), scope);
+ }
+ catch (InterruptedException e) {return;}
+ catch (InvocationTargetException e) {
+ setErrorMessage(e.getTargetException().getMessage());
+ return;
+ }//end catch
+ SelectionDialog dialog = null;
+ try {
+ dialog = JavaUI.createTypeDialog(
+ getShell(),
+ getLaunchConfigurationDialog(),
+ SearchEngine.createJavaSearchScope(types),
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false,
+ "**"); //$NON-NLS-1$
+ }//end try
+ catch (JavaModelException e) {
+ setErrorMessage(e.getMessage());
+ return;
+ }//end catch
dialog.setTitle(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_title);
- dialog.setMessage(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_message);
+ dialog.setMessage(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_message);
if (dialog.open() == Window.CANCEL) {
return;
}//end if
@@ -149,8 +191,7 @@
IType type= (IType)results[0];
if (type != null) {
fMainText.setText(type.getFullyQualifiedName());
- javaProject= type.getJavaProject();
- fProjText.setText(javaProject.getElementName());
+ fProjText.setText(type.getJavaProject().getElementName());
}//end if
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaMainTab.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaMainTab.java
index acb849b..353cfa4 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaMainTab.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaMainTab.java
@@ -16,7 +16,6 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -33,11 +32,11 @@
import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
-import org.eclipse.jdt.internal.debug.ui.launcher.SharedJavaMainTab;
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
import org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine;
-import org.eclipse.jdt.internal.debug.ui.launcher.MainTypeSelectionDialog;
+import org.eclipse.jdt.internal.debug.ui.launcher.SharedJavaMainTab;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.window.Window;
@@ -78,11 +77,10 @@
* @since 3.0
*/
public static final String ATTR_CONSIDER_INHERITED_MAIN = IJavaDebugUIConstants.PLUGIN_ID + ".CONSIDER_INHERITED_MAIN"; //$NON-NLS-1$
+
// UI widgets
private Button fSearchExternalJarsCheckButton;
-
private Button fConsiderInheritedMainButton;
-
private Button fStopInMainCheckButton;
/* (non-Javadoc)
@@ -134,11 +132,10 @@
* Show a dialog that lists all main types
*/
protected void handleSearchButtonSelected() {
- IJavaProject javaProject = getJavaProject();
+ IJavaProject project = getJavaProject();
IJavaElement[] elements = null;
- if ((javaProject == null) || !javaProject.exists()) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IJavaModel model = JavaCore.create(root);
+ if ((project == null) || !project.exists()) {
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
if (model != null) {
try {
elements = model.getJavaProjects();
@@ -147,7 +144,7 @@
}//end if
}//end if
else {
- elements = new IJavaElement[]{javaProject};
+ elements = new IJavaElement[]{project};
}//end else
if (elements == null) {
elements = new IJavaElement[]{};
@@ -171,7 +168,19 @@
setErrorMessage(e.getMessage());
return;
}//end catch
- SelectionDialog dialog = new MainTypeSelectionDialog(getShell(), types);
+ SelectionDialog dialog = null;
+ try {
+ dialog = JavaUI.createTypeDialog(
+ getShell(),
+ getLaunchConfigurationDialog(),
+ SearchEngine.createJavaSearchScope(types),
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false,
+ "**"); //$NON-NLS-1$
+ } catch (JavaModelException e) {
+ setErrorMessage(e.getMessage());
+ return;
+ }//end catch
dialog.setTitle(LauncherMessages.JavaMainTab_Choose_Main_Type_11);
dialog.setMessage(LauncherMessages.JavaMainTab_Choose_a_main__type_to_launch__12);
if (dialog.open() == Window.CANCEL) {
@@ -181,8 +190,7 @@
IType type = (IType)results[0];
if (type != null) {
fMainText.setText(type.getFullyQualifiedName());
- javaProject = type.getJavaProject();
- fProjText.setText(javaProject.getElementName());
+ fProjText.setText(type.getJavaProject().getElementName());
}//end if
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java
index e08c01e..399252f 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java
@@ -11,253 +11,77 @@
package org.eclipse.jdt.internal.debug.ui.launcher;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.debug.ui.ILaunchShortcut;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.debug.ui.launchConfigurations.AppletParametersTab;
-import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.jface.operation.IRunnableContext;
-public class JavaAppletLaunchShortcut implements ILaunchShortcut {
-
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- protected void searchAndLaunch(Object[] search, String mode) {
- IType[] types= null;
-
- if (search != null) {
- try {
- types = AppletLaunchConfigurationUtils.findApplets(new WorkspaceOperationRunner(), search);
- } catch (InterruptedException e) {
- JDIDebugUIPlugin.log(e);
- return;
- } catch (InvocationTargetException e) {
- JDIDebugUIPlugin.log(e);
- return;
- }
- IType type = null;
- if (types.length == 0) {
- MessageDialog.openInformation(getShell(), LauncherMessages.appletlauncher_search_dialog_title, LauncherMessages.appletlauncher_search_dialog_error_noapplets); //
- } else if (types.length > 1) {
- type = chooseType(types, mode);
- } else {
- type = types[0];
- }
- if (type != null) {
- launch(type, mode);
- }
- }
- }
+public class JavaAppletLaunchShortcut extends JavaLaunchShortcut {
- /**
- * @see ILaunchShortcut#launch(IEditorPart, String)
- */
- public void launch(IEditorPart editor, String mode) {
- IEditorInput input = editor.getEditorInput();
- IJavaElement javaElement = (IJavaElement) input.getAdapter(IJavaElement.class);
- if (javaElement != null) {
- searchAndLaunch(new Object[] {javaElement}, mode);
- } else {
- MessageDialog.openInformation(getShell(), LauncherMessages.appletlauncher_search_dialog_title, LauncherMessages.appletlauncher_search_dialog_error_noapplets); //
- }
- }
-
- /**
- * @see ILaunchShortcut#launch(ISelection, String)
- */
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- searchAndLaunch(((IStructuredSelection)selection).toArray(), mode);
- }
- }
-
- /**
- * Prompts the user to select a type
- *
- * @return the selected type or <code>null</code> if none.
- */
- protected IType chooseType(IType[] types, String mode) {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider());
- dialog.setElements(types);
- dialog.setTitle(LauncherMessages.appletlauncher_selection_type_dialog_title);
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- dialog.setMessage(LauncherMessages.appletlauncher_selection_type_dialog_message_debug);
- } else {
- dialog.setMessage(LauncherMessages.appletlauncher_selection_type_dialog_message_run);
- }
- dialog.setMultipleSelection(false);
- if (dialog.open() == Window.OK) {
- return (IType)dialog.getFirstResult();
- }
- return null;
- }
-
- /**
- * Launches a configuration for the given type
- */
- protected void launch(IType type, String mode) {
- ILaunchConfiguration config = findLaunchConfiguration(type, mode);
- if (config != null) {
- DebugUITools.launch(config, mode);
- }
- }
-
- /**
- * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
- *
- * @return a re-useable config or <code>null</code> if none
- */
- protected ILaunchConfiguration findLaunchConfiguration(IType type, String mode) {
- ILaunchConfigurationType configType= getAppletLaunchConfigType();
- List candidateConfigs= Collections.EMPTY_LIST;
- try {
- ILaunchConfiguration[] configs= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
- candidateConfigs= new ArrayList(configs.length);
- for (int i= 0; i < configs.length; i++) {
- ILaunchConfiguration config= configs[i];
- if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "").equals(type.getFullyQualifiedName())) { //$NON-NLS-1$
- if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(type.getJavaProject().getElementName())) { //$NON-NLS-1$
- candidateConfigs.add(config);
- }
- }
- }
- } catch (CoreException e) {
- JDIDebugUIPlugin.log(e);
- }
-
- // If there are no existing configs associated with the IType, create one.
- // If there is exactly one config associated with the IType, return it.
- // Otherwise, if there is more than one config associated with the IType, prompt the
- // user to choose one.
- int candidateCount= candidateConfigs.size();
- if (candidateCount < 1) {
- return createConfiguration(type);
- } else if (candidateCount == 1) {
- return (ILaunchConfiguration) candidateConfigs.get(0);
- } else {
- // Prompt the user to choose a config. A null result means the user
- // cancelled the dialog, in which case this method returns null,
- // since cancelling the dialog should also cancel launching anything.
- ILaunchConfiguration config= chooseConfiguration(candidateConfigs, mode);
- if (config != null) {
- return config;
- }
- }
- return null;
- }
-
- /**
- * Create & return a new configuration based on the specified <code>IType</code>.
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#createConfiguration(org.eclipse.jdt.core.IType)
*/
protected ILaunchConfiguration createConfiguration(IType type) {
ILaunchConfiguration config = null;
try {
- ILaunchConfigurationType configType = getAppletLaunchConfigType();
+ ILaunchConfigurationType configType = getConfigurationType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, EMPTY_STRING);
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
config = wc.doSave();
} catch (CoreException ce) {
- JDIDebugUIPlugin.log(ce);
+ reportErorr(ce);
}
return config;
}
-
- /**
- * Show a selection dialog that allows the user to choose one of the specified
- * launch configurations. Return the chosen config, or <code>null</code> if the
- * user cancelled the dialog.
- */
- protected ILaunchConfiguration chooseConfiguration(List configList, String mode) {
- IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setElements(configList.toArray());
- dialog.setTitle(LauncherMessages.appletlauncher_selection_configuration_dialog_title);
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- dialog.setMessage(LauncherMessages.appletlauncher_selection_configuration_dialog_message_debug);
- } else {
- dialog.setMessage(LauncherMessages.appletlauncher_selection_configuration_dialog_message_run);
- }
- dialog.setMultipleSelection(false);
- int result= dialog.open();
- labelProvider.dispose();
- if (result == Window.OK) {
- return (ILaunchConfiguration)dialog.getFirstResult();
- }
- return null;
- }
- /**
- * Returns the local java launch config type
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getConfigurationType()
*/
- protected ILaunchConfigurationType getAppletLaunchConfigType() {
+ protected ILaunchConfigurationType getConfigurationType() {
ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
return lm.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLET);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#findTypes(java.lang.Object[])
+ */
+ protected IType[] findTypes(Object[] elements, IRunnableContext context) throws InterruptedException, CoreException {
+ try {
+ return AppletLaunchConfigurationUtils.findApplets(context, elements);
+ } catch (InvocationTargetException e) {
+ throw (CoreException)e.getTargetException();
+ }
}
-
- /**
- * Convenience method to get the window that owns this action's Shell.
- */
- protected Shell getShell() {
- return JDIDebugUIPlugin.getActiveWorkbenchShell();
- }
-
- /**
- * Determines and returns the selection that provides context for the launch,
- * or <code>null</code> if there is no selection.
- */
- protected IStructuredSelection resolveSelection(IWorkbenchWindow window) {
- if (window == null) {
- return null;
- }
- ISelection selection= window.getSelectionService().getSelection();
- if (selection == null || selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
- // there is no obvious selection - go fishing
- selection = null;
- IWorkbenchPage page = window.getActivePage();
- if (page == null) {
- //workspace is closed
- return null;
- }
- // first, see if there is an active editor, and try its input element
- IEditorPart editor= page.getActiveEditor();
- Object element = null;
- if (editor != null) {
- element = editor.getEditorInput();
- }
-
- if (selection == null && element != null) {
- selection = new StructuredSelection(element);
- }
- }
- return (IStructuredSelection)selection;
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getTypeSelectionTitle()
+ */
+ protected String getTypeSelectionTitle() {
+ return LauncherMessages.JavaAppletLaunchShortcut_0;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getEditorEmptyMessage()
+ */
+ protected String getEditorEmptyMessage() {
+ return LauncherMessages.JavaAppletLaunchShortcut_1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getSelectionEmptyMessage()
+ */
+ protected String getSelectionEmptyMessage() {
+ return LauncherMessages.JavaAppletLaunchShortcut_2;
+ }
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java
index a0fde3e..eff75f8 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java
@@ -13,81 +13,25 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.jface.operation.IRunnableContext;
/**
* Performs single click launching for local Java applications.
*/
-public class JavaApplicationLaunchShortcut implements ILaunchShortcut {
-
- /**
- * @param search the java elements to search for a main type
- * @param mode the mode to launch in
- * @param editor activated on an editor (or from a selection in a viewer)
- */
- public void searchAndLaunch(Object[] search, String mode, boolean editor) {
- IType[] types = null;
- if (search != null) {
- try {
- IJavaElement[] elements = getJavaElements(search);
- MainMethodSearchEngine engine = new MainMethodSearchEngine();
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements, false);
- types = engine.searchMainMethods(PlatformUI.getWorkbench().getProgressService(), scope, true);
- } catch (InterruptedException e) {
- return;
- } catch (InvocationTargetException e) {
- MessageDialog.openError(getShell(), LauncherMessages.JavaApplicationAction_Launch_failed_7, e.getMessage());
- return;
- }
- IType type = null;
- if (types.length == 0) {
- String message = null;
- if (editor) {
- message = LauncherMessages.JavaApplicationLaunchShortcut_The_active_editor_does_not_contain_a_main_type__1;
- } else {
- message = LauncherMessages.JavaApplicationLaunchShortcut_The_selection_does_not_contain_a_main_type__2;
- }
- MessageDialog.openError(getShell(), LauncherMessages.JavaApplicationAction_Launch_failed_7, message);
- } else if (types.length > 1) {
- type = chooseType(types, mode);
- } else {
- type = types[0];
- }
- if (type != null) {
- launch(type, mode);
- }
- }
-
- }
+public class JavaApplicationLaunchShortcut extends JavaLaunchShortcut {
/**
* Returns the Java elements corresponding to the given objects.
@@ -115,177 +59,62 @@
}
return (IJavaElement[]) list.toArray(new IJavaElement[list.size()]);
}
-
- /**
- * Prompts the user to select a type
- *
- * @return the selected type or <code>null</code> if none.
- */
- protected IType chooseType(IType[] types, String mode) {
- MainTypeSelectionDialog dialog= new MainTypeSelectionDialog(getShell(), types);
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- dialog.setTitle(LauncherMessages.JavaApplicationAction_Type_Selection_Debug);
- } else {
- dialog.setTitle(LauncherMessages.JavaApplicationAction_Type_Selection_Run);
- }
- dialog.setMultipleSelection(false);
- if (dialog.open() == Window.OK) {
- return (IType)dialog.getFirstResult();
- }
- return null;
- }
- /**
- * Launches a configuration for the given type
- */
- protected void launch(IType type, String mode) {
- ILaunchConfiguration config = findLaunchConfiguration(type, mode);
- if (config != null) {
- DebugUITools.launch(config, mode);
- }
- }
-
- /**
- * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
- *
- * @return a re-useable config or <code>null</code> if none
- */
- protected ILaunchConfiguration findLaunchConfiguration(IType type, String mode) {
- ILaunchConfigurationType configType = getJavaLaunchConfigType();
- List candidateConfigs = Collections.EMPTY_LIST;
- try {
- ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
- candidateConfigs = new ArrayList(configs.length);
- for (int i = 0; i < configs.length; i++) {
- ILaunchConfiguration config = configs[i];
- if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "").equals(type.getFullyQualifiedName())) { //$NON-NLS-1$
- if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(type.getJavaProject().getElementName())) { //$NON-NLS-1$
- candidateConfigs.add(config);
- }
- }
- }
- } catch (CoreException e) {
- JDIDebugUIPlugin.log(e);
- }
-
- // If there are no existing configs associated with the IType, create one.
- // If there is exactly one config associated with the IType, return it.
- // Otherwise, if there is more than one config associated with the IType, prompt the
- // user to choose one.
- int candidateCount = candidateConfigs.size();
- if (candidateCount < 1) {
- return createConfiguration(type);
- } else if (candidateCount == 1) {
- return (ILaunchConfiguration) candidateConfigs.get(0);
- } else {
- // Prompt the user to choose a config. A null result means the user
- // cancelled the dialog, in which case this method returns null,
- // since cancelling the dialog should also cancel launching anything.
- ILaunchConfiguration config = chooseConfiguration(candidateConfigs, mode);
- if (config != null) {
- return config;
- }
- }
-
- return null;
- }
-
- /**
- * Show a selection dialog that allows the user to choose one of the specified
- * launch configurations. Return the chosen config, or <code>null</code> if the
- * user cancelled the dialog.
- */
- protected ILaunchConfiguration chooseConfiguration(List configList, String mode) {
- IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
- dialog.setElements(configList.toArray());
- dialog.setTitle(LauncherMessages.JavaApplicationAction_Launch_Configuration_Selection_1);
- if (mode.equals(ILaunchManager.DEBUG_MODE)) {
- dialog.setMessage(LauncherMessages.JavaApplicationAction_Choose_a_launch_configuration_to_debug_2);
- } else {
- dialog.setMessage(LauncherMessages.JavaApplicationAction_Choose_a_launch_configuration_to_run_3);
- }
- dialog.setMultipleSelection(false);
- int result = dialog.open();
- labelProvider.dispose();
- if (result == Window.OK) {
- return (ILaunchConfiguration) dialog.getFirstResult();
- }
- return null;
- }
-
- /**
- * Create & return a new configuration based on the specified <code>IType</code>.
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#createConfiguration(org.eclipse.jdt.core.IType)
*/
protected ILaunchConfiguration createConfiguration(IType type) {
ILaunchConfiguration config = null;
ILaunchConfigurationWorkingCopy wc = null;
try {
- ILaunchConfigurationType configType = getJavaLaunchConfigType();
+ ILaunchConfigurationType configType = getConfigurationType();
wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
+ config = wc.doSave();
} catch (CoreException exception) {
- reportCreatingConfiguration(exception);
- return null;
+ reportErorr(exception);
}
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
- try {
- config = wc.doSave();
- } catch (CoreException exception) {
- reportCreatingConfiguration(exception);
- }
return config;
}
- protected void reportCreatingConfiguration(final CoreException exception) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ErrorDialog.openError(getShell(), LauncherMessages.JavaApplicationLaunchShortcut_Error_Launching_1, LauncherMessages.JavaApplicationLaunchShortcut_Exception, exception.getStatus()); //new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, exception.getMessage(), exception));
- }
- });
- }
-
- /**
- * Returns the local java launch config type
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getConfigurationType()
*/
- protected ILaunchConfigurationType getJavaLaunchConfigType() {
+ protected ILaunchConfigurationType getConfigurationType() {
return getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
}
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- /**
- * Convenience method to get the window that owns this action's Shell.
- */
- protected Shell getShell() {
- return JDIDebugUIPlugin.getActiveWorkbenchShell();
- }
-
- /**
- * @see ILaunchShortcut#launch(IEditorPart, String)
- */
- public void launch(IEditorPart editor, String mode) {
- IEditorInput input = editor.getEditorInput();
- IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class);
- if (je != null) {
- searchAndLaunch(new Object[] {je}, mode, true);
- } else {
- MessageDialog.openError(getShell(), LauncherMessages.JavaApplicationAction_Launch_failed_7, LauncherMessages.JavaApplicationLaunchShortcut_The_active_editor_does_not_contain_a_main_type__1); //
- }
-
- }
- /**
- * @see ILaunchShortcut#launch(ISelection, String)
- */
- public void launch(ISelection selection, String mode) {
- if (selection instanceof IStructuredSelection) {
- searchAndLaunch(((IStructuredSelection)selection).toArray(), mode, false);
- } else {
- MessageDialog.openError(getShell(), LauncherMessages.JavaApplicationAction_Launch_failed_7, LauncherMessages.JavaApplicationLaunchShortcut_The_selection_does_not_contain_a_main_type__2); //
+ protected IType[] findTypes(Object[] elements, IRunnableContext context) throws InterruptedException, CoreException {
+ try {
+ IJavaElement[] javaElements = getJavaElements(elements);
+ MainMethodSearchEngine engine = new MainMethodSearchEngine();
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(javaElements, false);
+ return engine.searchMainMethods(context, scope, true);
+ } catch (InvocationTargetException e) {
+ throw (CoreException)e.getTargetException();
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getTypeSelectionTitle()
+ */
+ protected String getTypeSelectionTitle() {
+ return LauncherMessages.JavaApplicationLaunchShortcut_0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getEditorEmptyMessage()
+ */
+ protected String getEditorEmptyMessage() {
+ return LauncherMessages.JavaApplicationLaunchShortcut_1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.debug.ui.launcher.JavaLaunchShortcut#getSelectionEmptyMessage()
+ */
+ protected String getSelectionEmptyMessage() {
+ return LauncherMessages.JavaApplicationLaunchShortcut_2;
+ }
+
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaLaunchShortcut.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaLaunchShortcut.java
new file mode 100644
index 0000000..65c4873
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaLaunchShortcut.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.debug.ui.launcher;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+/**
+ * Common behavior for Java launch shortcuts
+ *
+ * @since 3.2
+ */
+public abstract class JavaLaunchShortcut implements ILaunchShortcut {
+
+ /**
+ * @param search the java elements to search for a main type
+ * @param mode the mode to launch in
+ * @param editor activated on an editor (or from a selection in a viewer)
+ */
+ public void searchAndLaunch(Object[] search, String mode, String selectMessage, String emptyMessage) {
+ IType[] types = null;
+ try {
+ types = findTypes(search, PlatformUI.getWorkbench().getProgressService());
+ } catch (InterruptedException e) {
+ return;
+ } catch (CoreException e) {
+ MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_0, e.getMessage());
+ return;
+ }
+ IType type = null;
+ if (types.length == 0) {
+ MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_1, emptyMessage);
+ } else if (types.length > 1) {
+ try {
+ type = chooseType(types, selectMessage);
+ } catch (JavaModelException e) {
+ reportErorr(e);
+ return;
+ }
+ } else {
+ type = types[0];
+ }
+ if (type != null) {
+ launch(type, mode);
+ }
+ }
+
+ /**
+ * Finds and returns the launchable types in the given selection of elements.
+ *
+ * @param elements scope to search for launchable types
+ * @param context progess reporting context
+ * @return launchable types, possibly empty
+ * @exception InterruptedException if the search is cancelled
+ * @exception org.eclipse.core.runtime.CoreException if the search fails
+ */
+ protected abstract IType[] findTypes(Object[] elements, IRunnableContext context) throws InterruptedException, CoreException;
+
+ /**
+ * Prompts the user to select a type from the given types.
+ *
+ * @param types the types to choose from
+ * @param title the selection dialog title
+ *
+ * @return the selected type or <code>null</code> if none.
+ */
+ protected IType chooseType(IType[] types, String title) throws JavaModelException {
+ SelectionDialog dialog = JavaUI.createTypeDialog(
+ getShell(),
+ PlatformUI.getWorkbench().getProgressService(),
+ SearchEngine.createJavaSearchScope(types),
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false, "**"); //$NON-NLS-1$
+ dialog.setMessage(LauncherMessages.JavaMainTab_Choose_a_main__type_to_launch__12);
+ dialog.setTitle(title);
+ if (dialog.open() == Window.OK) {
+ return (IType)dialog.getResult()[0];
+ }
+ return null;
+ }
+
+ /**
+ * Launches a configuration for the given type
+ */
+ protected void launch(IType type, String mode) {
+ ILaunchConfiguration config = findLaunchConfiguration(type, getConfigurationType());
+ if (config != null) {
+ DebugUITools.launch(config, mode);
+ }
+ }
+
+ /**
+ * Returns the type of configuration this shortcut is applicable to.
+ *
+ * @return the type of configuration this shortcut is applicable to
+ */
+ protected abstract ILaunchConfigurationType getConfigurationType();
+
+ /**
+ * Locate a configuration to relaunch for the given type. If one cannot be found, create one.
+ *
+ * @return a re-useable config or <code>null</code> if none
+ */
+ protected ILaunchConfiguration findLaunchConfiguration(IType type, ILaunchConfigurationType configType) {
+ List candidateConfigs = Collections.EMPTY_LIST;
+ try {
+ ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
+ candidateConfigs = new ArrayList(configs.length);
+ for (int i = 0; i < configs.length; i++) {
+ ILaunchConfiguration config = configs[i];
+ if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "").equals(type.getFullyQualifiedName())) { //$NON-NLS-1$
+ if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(type.getJavaProject().getElementName())) { //$NON-NLS-1$
+ candidateConfigs.add(config);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ JDIDebugUIPlugin.log(e);
+ }
+
+ // If there are no existing configs associated with the IType, create one.
+ // If there is exactly one config associated with the IType, return it.
+ // Otherwise, if there is more than one config associated with the IType, prompt the
+ // user to choose one.
+ int candidateCount = candidateConfigs.size();
+ if (candidateCount < 1) {
+ return createConfiguration(type);
+ } else if (candidateCount == 1) {
+ return (ILaunchConfiguration) candidateConfigs.get(0);
+ } else {
+ // Prompt the user to choose a config. A null result means the user
+ // cancelled the dialog, in which case this method returns null,
+ // since cancelling the dialog should also cancel launching anything.
+ ILaunchConfiguration config = chooseConfiguration(candidateConfigs);
+ if (config != null) {
+ return config;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Show a selection dialog that allows the user to choose one of the specified
+ * launch configurations. Return the chosen config, or <code>null</code> if the
+ * user cancelled the dialog.
+ */
+ protected ILaunchConfiguration chooseConfiguration(List configList) {
+ IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setElements(configList.toArray());
+ dialog.setTitle(getTypeSelectionTitle());
+ dialog.setMessage(LauncherMessages.JavaLaunchShortcut_2);
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ labelProvider.dispose();
+ if (result == Window.OK) {
+ return (ILaunchConfiguration) dialog.getFirstResult();
+ }
+ return null;
+ }
+
+ /**
+ * Create and returns a new configuration based on the specified <code>IType</code>.
+ */
+ protected abstract ILaunchConfiguration createConfiguration(IType type);
+
+ /**
+ * Opens an error dialog on the given excpetion.
+ *
+ * @param exception
+ */
+ protected void reportErorr(CoreException exception) {
+ MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage());
+ }
+
+ protected ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ /**
+ * Convenience method to get the window that owns this action's Shell.
+ */
+ protected Shell getShell() {
+ return JDIDebugUIPlugin.getActiveWorkbenchShell();
+ }
+
+ /**
+ * @see ILaunchShortcut#launch(IEditorPart, String)
+ */
+ public void launch(IEditorPart editor, String mode) {
+ IEditorInput input = editor.getEditorInput();
+ IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class);
+ if (je != null) {
+ searchAndLaunch(new Object[] {je}, mode, getTypeSelectionTitle(), getEditorEmptyMessage());
+ }
+ }
+
+ /**
+ * @see ILaunchShortcut#launch(ISelection, String)
+ */
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ searchAndLaunch(((IStructuredSelection)selection).toArray(), mode, getTypeSelectionTitle(), getSelectionEmptyMessage());
+ }
+ }
+
+ /**
+ * Returns the title for type selection dialog for this launch shortcut.
+ *
+ * @return type selection dialog title
+ */
+ protected abstract String getTypeSelectionTitle();
+
+ /**
+ * Returns an error message to use when the editor does not contain a launchable type.
+ *
+ * @return error message
+ */
+ protected abstract String getEditorEmptyMessage();
+
+ /**
+ * Returns an error message to use when the selection does not contain a launchable type.
+ *
+ * @return error message
+ */
+ protected abstract String getSelectionEmptyMessage();
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.java
index 494bec3..439cd4c 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.java
@@ -77,17 +77,6 @@
public static String JavaSourceLookupTab_Source_1;
- public static String JavaApplicationAction_Type_Selection_Debug;
- public static String JavaApplicationAction_Type_Selection_Run;
- public static String JavaApplicationAction_Launch_failed_7;
- public static String JavaApplicationAction_Launch_Configuration_Selection_1;
- public static String JavaApplicationAction_Choose_a_launch_configuration_to_debug_2;
- public static String JavaApplicationAction_Choose_a_launch_configuration_to_run_3;
-
- public static String MainTypeSelectionDialog_Choose_a_type;
- public static String MainTypeSelectionDialog_Matching_types;
- public static String MainTypeSelectionDialog_Qualifier;
-
public static String WorkingDirectoryBlock_4;
public static String WorkingDirectoryBlock_7;
public static String WorkingDirectoryBlock_0;
@@ -151,13 +140,6 @@
public static String appletlauncher_search_dialog_error_noapplets;
public static String appletlauncher_search_task_inprogress;
- public static String appletlauncher_selection_type_dialog_title;
- public static String appletlauncher_selection_type_dialog_message_debug;
- public static String appletlauncher_selection_type_dialog_message_run;
- public static String appletlauncher_selection_configuration_dialog_title;
- public static String appletlauncher_selection_configuration_dialog_message_debug;
- public static String appletlauncher_selection_configuration_dialog_message_run;
-
public static String AppletParametersTab__optional_applet_instance_name__1;
public static String AppletMainTab_1;
public static String AppletMainTab_2;
@@ -178,12 +160,19 @@
public static String SelectDefaultSystemLibraryQuickFix_Unable_to_update_the_default_system_library__4;
public static String SelectDefaultSystemLibraryQuickFix_Select_default_system_library_5;
- public static String JavaApplicationLaunchShortcut_The_active_editor_does_not_contain_a_main_type__1;
- public static String JavaApplicationLaunchShortcut_The_selection_does_not_contain_a_main_type__2;
- public static String JavaApplicationLaunchShortcut_Error_Launching_1;
- public static String JavaApplicationLaunchShortcut_Exception;
public static String AppletSelectionDialog_Searching____1;
+ public static String JavaAppletLaunchShortcut_0;
+ public static String JavaAppletLaunchShortcut_1;
+ public static String JavaAppletLaunchShortcut_2;
+ public static String JavaApplicationLaunchShortcut_0;
+ public static String JavaApplicationLaunchShortcut_1;
+ public static String JavaApplicationLaunchShortcut_2;
+ public static String JavaLaunchShortcut_0;
+ public static String JavaLaunchShortcut_1;
+ public static String JavaLaunchShortcut_2;
+ public static String JavaLaunchShortcut_3;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, LauncherMessages.class);
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.properties
index 440c48c..5caa4d2 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.properties
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/LauncherMessages.properties
@@ -37,9 +37,20 @@
JavaJRETab_8=Workspace &default JRE ({0})
JavaJRETab_9=&Project JRE ({0})
+JavaMainTab_Choose_a_main__type_to_launch__12=Select &type (? = any character, * = any String, TZ = TimeZone):
+JavaMainTab_Choose_Main_Type_11=Select Main Type
+JavaApplicationLaunchShortcut_0=Select Java Application
+JavaApplicationLaunchShortcut_1=Editor does not contain a main type
+JavaApplicationLaunchShortcut_2=Selection does not contain a main type
+JavaLaunchShortcut_0=Error
+JavaLaunchShortcut_1=Launch Error
+JavaLaunchShortcut_2=&Select existing configuration:
+JavaLaunchShortcut_3=Error
+
+JavaAppletLaunchShortcut_0=Select Java Applet
+JavaAppletLaunchShortcut_1=Editor does not contain an applet
+JavaAppletLaunchShortcut_2=Selection does not contain an applet
JavaMainTab__Main_19=Main
-JavaMainTab_Choose_a_main__type_to_launch__12=Choose a main &type to launch:
-JavaMainTab_Choose_Main_Type_11=Choose Main Type
JavaMainTab_E_xt__jars_6=Includ&e libraries when searching for a main class
JavaMainTab_Main_cla_ss__4=&Main class:
JavaMainTab_Main_type_not_specified_16=Main type not specified
@@ -70,17 +81,6 @@
JavaSourceLookupTab_Source_1=Source
-JavaApplicationAction_Type_Selection_Debug=Debug Type
-JavaApplicationAction_Type_Selection_Run=Run Type
-JavaApplicationAction_Launch_failed_7=Launch Failed
-JavaApplicationAction_Launch_Configuration_Selection_1=Launch Configuration Selection
-JavaApplicationAction_Choose_a_launch_configuration_to_debug_2=Choose a launch configuration to deb&ug:
-JavaApplicationAction_Choose_a_launch_configuration_to_run_3=Choose a launch configuration to r&un:
-
-MainTypeSelectionDialog_Choose_a_type=&Choose a type (? = any character, * = any string):
-MainTypeSelectionDialog_Matching_types=&Matching types:
-MainTypeSelectionDialog_Qualifier=&Qualifier:
-
WorkingDirectoryBlock_4=Select a &workspace relative working directory:
WorkingDirectoryBlock_7=Select a working directory for the launch configuration:
WorkingDirectoryBlock_0=W&orkspace...
@@ -95,7 +95,6 @@
RuntimeClasspathAdvancedDialog_Advanced_Options_1=Advanced Options
RuntimeClasspathAdvancedDialog_Unable_to_create_new_entry__3=Unable to create new entry.
RuntimeClasspathAdvancedDialog_Select_an_advanced_option__1=Select an advanced option:
-
RuntimeClasspathEntryLabelProvider_JRE_System_Library___0___2=JRE System Library [{0}]
RuntimeClasspathEntryLabelProvider_Invalid_path=Invalid path: {0}
@@ -133,13 +132,6 @@
appletlauncher_search_dialog_error_noapplets=No applets found.
appletlauncher_search_task_inprogress=Searching applets...
-appletlauncher_selection_type_dialog_title=Applet selection
-appletlauncher_selection_type_dialog_message_debug=Select applet to debug
-appletlauncher_selection_type_dialog_message_run=Select applet to run
-appletlauncher_selection_configuration_dialog_title=Select an applet Configuration
-appletlauncher_selection_configuration_dialog_message_debug=Select an Applet configuration to debug
-appletlauncher_selection_configuration_dialog_message_run=Select an Applet configuration to run
-
AppletParametersTab__optional_applet_instance_name__1=(optional applet instance name)
AppletMainTab_1=App&let viewer:
AppletMainTab_2=&Use default Applet viewer class
@@ -159,11 +151,6 @@
SelectDefaultSystemLibraryQuickFix_An_exception_occurred_while_updating_the_default_system_library__3=An exception occurred while updating the default system library.
SelectDefaultSystemLibraryQuickFix_Unable_to_update_the_default_system_library__4=Unable to update the default system library.
SelectDefaultSystemLibraryQuickFix_Select_default_system_library_5=Select default system library
-
-JavaApplicationLaunchShortcut_The_active_editor_does_not_contain_a_main_type__1=The active editor does not contain a main type.
-JavaApplicationLaunchShortcut_The_selection_does_not_contain_a_main_type__2=The selection does not contain a main type.
-JavaApplicationLaunchShortcut_Error_Launching_1=Error Launching
-JavaApplicationLaunchShortcut_Exception=An exception occurred attempting to create launch configuration
AppletSelectionDialog_Searching____1=Searching...
VMArgumentsBlock_4=Varia&bles...
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/MainTypeSelectionDialog.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/MainTypeSelectionDialog.java
deleted file mode 100644
index 850ded2..0000000
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/MainTypeSelectionDialog.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.debug.ui.launcher;
-
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.TwoPaneElementSelector;
-
-/**
- * A dialog to select a type from a list of types. The dialog allows
- * multiple selections.
- *
- * @since 2.1
- */
-public class MainTypeSelectionDialog extends TwoPaneElementSelector {
-
- /** The main types. */
- private final IType[] fTypes;
-
- private static class PackageRenderer extends JavaElementLabelProvider {
- public PackageRenderer() {
- super(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT);
- }
-
- public Image getImage(Object element) {
- return super.getImage(((IType)element).getPackageFragment());
- }
-
- public String getText(Object element) {
- return super.getText(((IType)element).getPackageFragment());
- }
- }
-
- public MainTypeSelectionDialog(Shell shell, IType[] types) {
-
- super(shell, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS),
- new PackageRenderer());
-
- Assert.isNotNull(types);
- fTypes= types;
- setMessage(LauncherMessages.MainTypeSelectionDialog_Choose_a_type); //
- setUpperListLabel(LauncherMessages.MainTypeSelectionDialog_Matching_types);
- setLowerListLabel(LauncherMessages.MainTypeSelectionDialog_Qualifier);
- }
-
- /**
- * Returns the main types.
- */
- public IType[] getTypes() {
- return fTypes;
- }
-
- /*
- * @see Windows#configureShell
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaDebugHelpContextIds.MAIN_TYPE_SELECTION_DIALOG);
- }
-
- /*
- * @see Window#open()
- */
- public int open() {
-
- if (fTypes == null)
- return CANCEL;
-
- setElements(fTypes);
- return super.open();
- }
-
- /**
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- public Control createDialogArea(Composite parent) {
- Control control= super.createDialogArea(parent);
- applyDialogFont(control);
- return control;
- }
-}