diff options
author | Michael Rennie | 2006-01-11 21:56:52 +0000 |
---|---|---|
committer | Michael Rennie | 2006-01-11 21:56:52 +0000 |
commit | 61cc7d86e557cf57c6033765857fcb03779e5f78 (patch) | |
tree | f10c61ffb709b7bb6c19e20e2c61e82661bb2b2d /org.eclipse.debug.ui | |
parent | 58ccca350f598dda3f0e062b43a495c3703cb78c (diff) | |
download | eclipse.platform.debug-61cc7d86e557cf57c6033765857fcb03779e5f78.tar.gz eclipse.platform.debug-61cc7d86e557cf57c6033765857fcb03779e5f78.tar.xz eclipse.platform.debug-61cc7d86e557cf57c6033765857fcb03779e5f78.zip |
leverages the mapped resource in part to fix bugs 19521 and 113772, includes new pref page and changes to LCD
Diffstat (limited to 'org.eclipse.debug.ui')
24 files changed, 1949 insertions, 1206 deletions
diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/clear_co.gif b/org.eclipse.debug.ui/icons/full/dlcl16/clear_co.gif Binary files differnew file mode 100644 index 000000000..6775edfab --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/dlcl16/clear_co.gif diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/filter_ps.gif b/org.eclipse.debug.ui/icons/full/dlcl16/filter_ps.gif Binary files differnew file mode 100644 index 000000000..6c54da9ad --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/dlcl16/filter_ps.gif diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/prop_ps.gif b/org.eclipse.debug.ui/icons/full/dlcl16/prop_ps.gif Binary files differnew file mode 100644 index 000000000..0fbf9d05c --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/dlcl16/prop_ps.gif diff --git a/org.eclipse.debug.ui/icons/full/elcl16/filter_ps.gif b/org.eclipse.debug.ui/icons/full/elcl16/filter_ps.gif Binary files differnew file mode 100644 index 000000000..a4c9e60e2 --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/elcl16/filter_ps.gif diff --git a/org.eclipse.debug.ui/icons/full/elcl16/prop_ps.gif b/org.eclipse.debug.ui/icons/full/elcl16/prop_ps.gif Binary files differnew file mode 100644 index 000000000..6223cfcb2 --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/elcl16/prop_ps.gif diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index a8b6c7413..90e30231d 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties @@ -136,7 +136,8 @@ LinkRenderingPanesAction.name = Link Memory Rendering Panes AddRemoveRenderingMenu.name = Add/Remove Rendering AddRenderingAction.name = Add Rendering RemoveRenderingAction.name = Remove Rendering -PerspectivePreferencePage.name = Perspectives +PerspectivePreferencePage.name = Perspective Switching +LaunchConfigurationsPage.name = Launch Configurations #string subtitution variables string_prompt.description=Returns the text value entered into a prompt dialog. When one argument is provided, it is used as a prompt hint on the input dialog. When a second argument is provided, it is used as an initial value in the input dialog. The first and second arguments must be separated with a ':'. diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 22325cc4b..92c20adef 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -134,6 +134,13 @@ name="%PerspectivePreferencePage.name"> <keywordReference id="org.eclipse.debug.ui.perspectivesPref"/> </page> + <page + category="org.eclipse.debug.ui.LaunchingPreferencePage" + class="org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage" + id="org.eclipse.debug.ui.LaunchConfigurations" + name="%LaunchConfigurationsPage.name"> + <keywordReference id="org.eclipse.debug.ui.launchconfigurations"/> + </page> </extension> <extension point="org.eclipse.ui.actionSets"> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java index 166411c84..cde78eda7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java @@ -105,7 +105,10 @@ public class DebugPluginImages { declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_REMOVE_MEMORY, DLCL + "removememory_tsk.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_RESET_MEMORY, DLCL + "memoryreset_tsk.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_COPY_VIEW_TO_CLIPBOARD, DLCL + "copyviewtoclipboard_tsk.gif"); //$NON-NLS-1$ - declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_PRINT_TOP_VIEW_TAB, DLCL + "printview_tsk.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_PRINT_TOP_VIEW_TAB, DLCL + "printview_tsk.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_DUPLICATE_CONFIG, DLCL + "copy_edit_co.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_NEW_CONFIG, DLCL + "prop_ps.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_FILTER_CONFIGS, DLCL + "filter_ps.gif"); //$NON-NLS-1$ // enabled local toolbars declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_DETAIL_PANE, ELCL + "toggledetailpane_co.gif"); //$NON-NLS-1$ @@ -125,6 +128,9 @@ public class DebugPluginImages { declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_REMOVE_ALL, ELCL + "rem_all_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_REMOVE, ELCL + "rem_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_HIERARCHICAL, ELCL + "hierarchicalLayout.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS, ELCL + "filter_ps.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG, ELCL + "copy_edit_co.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG, ELCL + "prop_ps.gif"); //$NON-NLS-1$ //Object declareRegistryImage(IDebugUIConstants.IMG_OBJS_LAUNCH_DEBUG, OBJECT + "ldebug_obj.gif"); //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java index 62821b6aa..4e4235eea 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java @@ -115,5 +115,7 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE); prefs.setDefault(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK, IDebugPreferenceConstants.RESET_VISIBLE); + prefs.setDefault(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED, true); + prefs.setDefault(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED, true); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java index 086dc0177..ee557aa9c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java @@ -69,8 +69,8 @@ public interface IDebugHelpContextIds { public static final String LAUNCH_HISTORY_PREFERENCE_PAGE = PREFIX + "launch_history_preference_page_context"; //$NON-NLS-1$ public static final String SIMPLE_VARIABLE_PREFERENCE_PAGE = PREFIX + "simple_variable_preference_page_context"; //$NON-NLS-1$ public static final String PERSPECTIVE_PREFERENCE_PAGE = PREFIX + "perspective_preference_page_context"; //$NON-NLS-1$ -// public static final String LAUNCHING_PREFERENCE_PAGE = PREFIX + "launching_preference_page_context"; //$NON-NLS-1$ -// public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$ + public static final String LAUNCHING_PREFERENCE_PAGE = PREFIX + "launching_preference_page_context"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$ public static final String VIEW_MANAGEMENT_PREFERENCE_PAGE = PREFIX + "view_management_preference_page_context"; //$NON-NLS-1$ // Dialogs diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java index 144ddc1e0..fbf6ea295 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java @@ -58,6 +58,9 @@ public interface IInternalDebugUIConstants { public static final String IMG_DLCL_RESET_MEMORY= "IMG_DLCL_RESET_MEMORY"; //$NON-NLS-1$ public static final String IMG_DLCL_COPY_VIEW_TO_CLIPBOARD= "IMG_DLCL_COPY_VIEW_TO_CLIPBOARD"; //$NON-NLS-1$ public static final String IMG_DLCL_PRINT_TOP_VIEW_TAB= "IMG_DLCL_PRINT_TOP_VIEW_TAB"; //$NON-NLS-1$ + public static final String IMG_DLCL_NEW_CONFIG = "IMG_DLCL_NEW_CONFIG"; //$NON-NLS-1$ + public static final String IMG_DLCL_DUPLICATE_CONFIG = "IMG_DLCL_DUPLICATE_CONFIG"; //$NON-NLS-1$ + public static final String IMG_DLCL_FILTER_CONFIGS = "IMG_DLCL_FILTER_CONFIGS"; //$NON-NLS-1$ // enabled local tool images public static final String IMG_ELCL_LOCK= "IMG_ELCL_LOCK"; //$NON-NLS-1$ @@ -80,6 +83,9 @@ public interface IInternalDebugUIConstants { public static final String IMG_ELCL_REMOVE = "IMG_ELCL_REMOVE"; //$NON-NLS-1$ public static final String IMG_ELCL_HIERARCHICAL = "IMG_ELCL_HIERARCHICAL"; //$NON-NLS-1$ public static final String IMG_ELCL_HELP = "IMG_ELCL_HELP"; //$NON-NLS-1$ + public static final String IMG_ELCL_NEW_CONFIG = "IMG_ELCL_NEW_CONFIG"; //$NON-NLS-1$ + public static final String IMG_ELCL_FILTER_CONFIGS = "IMG_ELCL_FILTER_CONFIGS"; //$NON-NLS-1$ + public static final String IMG_ELCL_DUPLICATE_CONFIG = "IMG_ELCL_DUPLICATE_CONFIG"; //$NON-NLS-1$ // object images public static final String IMG_OBJS_INSTRUCTION_POINTER_TOP = "IMG_OBJS_INSTRUCTION_POINTER_TOP"; //$NON-NLS-1$ @@ -109,13 +115,41 @@ public interface IInternalDebugUIConstants { public static final String PREF_LAUNCH_PERSPECTIVES = IDebugUIConstants.PLUGIN_ID + ".PREF_LAUNCH_PERSPECTIVES"; //$NON-NLS-1$ /** + * Preference for enabling/disabling launch configuration filtering based on project accessibilty status + * + * @since 3.2 + */ + public static final String PREF_FILTER_LAUNCH_CLOSED = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_LAUNCH_CLOSED"; //$NON-NLS-1$ + + /** + * Preference for enabling/disabling launch configuraiton filtering based on project context + * + * @since 3.2 + */ + public static final String PREF_FILTER_LAUNCH_DELETED = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_LAUNCH_DELETED"; //$NON-NLS-1$ + + /** + * Preference for enabling/disabling filtering based on selected items from the launch configuration type table + * @since 3.2 + */ + public static final String PREF_FILTER_LAUNCH_TYPES = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_LAUNCH_TYPES"; //$NON-NLS-1$ + + /** + * Preference that saves which launch configuration types have been checked on the Launch Configuraitons pref page + * @since 3.2 + */ + public static final String PREF_FILTER_TYPE_LIST = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_TYPE_LIST"; //$NON-NLS-1$ + + /** * Preference for using step filters. * * @since 3.0 */ public static final String PREF_USE_STEP_FILTERS = IDebugUIConstants.PLUGIN_ID + ".USE_STEP_FILTERS"; //$NON-NLS-1$ - /** Transparent overlay image identifier. */ + /** + * Transparent overlay image identifier. + */ public static final String IMG_OVR_TRANSPARENT = "IMG_OVR_TRANSPARENT"; //$NON-NLS-1$ /** @@ -139,8 +173,8 @@ public interface IInternalDebugUIConstants { * * @since 3.0 */ - public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH= IDebugUIConstants.PLUGIN_ID + ".save_dirty_editors_before_launch"; //$NON-NLS-1$ - + public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".save_dirty_editors_before_launch"; //$NON-NLS-1$ + /** * Preference specifiying that all launches should be DEBUG_MODE if breakpoints exist in the workspace * @since 3.0 diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ClosedProjectFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ClosedProjectFilter.java new file mode 100644 index 000000000..48547edfb --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ClosedProjectFilter.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2005, 2006 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.debug.internal.ui.launchConfigurations; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +/** + * + * This implementation is used to filter closed projects from the launch configuration dialog. + * It is (de)activated via the <code>IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED</code> preference, and is + * provided to fix bug 19521. + * + * @since 3.2 + * + */ +public class ClosedProjectFilter extends ViewerFilter { + + /** + * Constructor + */ + public ClosedProjectFilter() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public boolean select(Viewer viewer, Object parent, Object element) { + //always let through types, we only care about configs + if(element instanceof ILaunchConfigurationType) { + return true; + } + if(element instanceof ILaunchConfiguration) { + try { + IResource[] resources = ((ILaunchConfiguration)element).getMappedResources(); + //if ithas no mapping, it might be have migration delegate, so let it pass + if(resources == null) { + return true; + } + for(int i = 0; i < resources.length; i++) { + if(resources[i] instanceof IProject) { + IProject project = (IProject)resources[i]; + //we don't want overlap with the deleted projects filter, so we need to allow projects taht don't exist through + if(project.isOpen() || !project.exists()) { + return true; + } + } + } + } + catch (CoreException e) {} + } + return false; + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeletedProjectFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeletedProjectFilter.java new file mode 100644 index 000000000..cd4fc0b07 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DeletedProjectFilter.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2005, 2006 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.debug.internal.ui.launchConfigurations; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +/** + * + * Provides implementaiton to filter unavailable projects form the launch configuration dialog. + * It is (de) activated via the <code>IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED</code> preference. + * + * @since 3.2 + * + */ +public class DeletedProjectFilter extends ViewerFilter { + + /** + * Constructor + */ + public DeletedProjectFilter() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public boolean select(Viewer viewer, Object parentElement, Object element) { + //always let through types, we only care about configs + if (element instanceof ILaunchConfigurationType) { + return true; + } + if(element instanceof ILaunchConfiguration) { + try { + IResource[] resources = ((ILaunchConfiguration)element).getMappedResources(); + if(resources == null) { + return true; + } + for(int i = 0; i < resources.length; i++) { + if(resources[i] instanceof IProject) { + IProject project = (IProject)resources[i]; + if(project.exists()) { + return true; + } + } + } + } + catch(CoreException e) {e.printStackTrace();} + } + return false; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java index c2da9d5e3..a4472dce0 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java @@ -195,16 +195,16 @@ public class LaunchConfigurationManager implements ILaunchListener { List filteredConfigs= new ArrayList(); for (int i = 0; i < configurations.length; i++) { - ILaunchConfiguration configuration= configurations[i]; + ILaunchConfiguration configuration = configurations[i]; ILaunchConfigurationType type= null; try { - type= configuration.getType(); - LaunchConfigurationTypeContribution contribution = new LaunchConfigurationTypeContribution(type); - if (!WorkbenchActivityHelper.filterItem(contribution)) + type = configuration.getType(); + LaunchConfigurationTypeContribution contribution = new LaunchConfigurationTypeContribution(type); + if (doExtraFiltering(configuration) & !WorkbenchActivityHelper.filterItem(contribution)) { filteredConfigs.add(configuration); - } catch (CoreException e) { - DebugUIPlugin.log(e.getStatus()); - } + } + } + catch (CoreException e) {DebugUIPlugin.log(e.getStatus());} } return (ILaunchConfiguration[]) filteredConfigs.toArray(new ILaunchConfiguration[filteredConfigs.size()]); } @@ -222,6 +222,30 @@ public class LaunchConfigurationManager implements ILaunchListener { } /** + * performs extra filtering for launch configuraitons based on the prefs set on the + * Launch Configuraitons page + * @param config the config to filter + * @return true if it should pass the filter, false otherwise + * @since 3.2 + */ + private static boolean doExtraFiltering(ILaunchConfiguration config) { + boolean ret = true; + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED)) { + ret &= new ClosedProjectFilter().select(null, null, config); + } + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED)) { + ret &= new DeletedProjectFilter().select(null, null, config); + } + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES)) { + try { + ret &= new LaunchConfigurationTypeFilter().select(null, null, config.getType()); + } + catch(CoreException e) {e.printStackTrace();} + } + return ret; + } + + /** * @see ILaunchListener#launchRemoved(ILaunch) */ public void launchRemoved(ILaunch launch) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java index 9a855beee..3bc962029 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java @@ -25,6 +25,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.SWTUtil; +import org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage; import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; @@ -356,6 +357,20 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { } public void widgetDefaultSelected(SelectionEvent e) {} }); + + createSpacer(parent, 2); + link = new Link(parent, SWT.LEFT | SWT.WRAP); + link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_7); + link.setFont(font); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = parent.getBounds().width - 30; + link.setLayoutData(gd); + link.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + showPreferencePage("org.eclipse.debug.ui.LaunchConfigurationsPreferenecPage", new LaunchConfigurationsPreferencePage()); //$NON-NLS-1$ + } + public void widgetDefaultSelected(SelectionEvent e) {} + }); } /** @@ -380,7 +395,6 @@ public class LaunchConfigurationTabGroupViewer extends Viewer { */ private void showPreferencePage(String id, IPreferencePage page) { final IPreferenceNode targetNode = new PreferenceNode(id, page); - PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); final PreferenceDialog dialog = new PreferenceDialog(DebugUIPlugin.getShell(), manager); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTypeFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTypeFilter.java new file mode 100644 index 000000000..86d5d6035 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTypeFilter.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2005, 2006 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.debug.internal.ui.launchConfigurations; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +/** + * Provides the implementation of the filter for filtering the launch configuration viewer based on the preference + * <code>IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES</code> + * + * @since 3.2 + */ +public class LaunchConfigurationTypeFilter extends ViewerFilter { + + /** + * Constructor + */ + public LaunchConfigurationTypeFilter() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + public boolean select(Viewer viewer, Object parentElement, Object element) { + if(element instanceof ILaunchConfiguration) { + return true; + } + //we only care about launch configuration types + if(element instanceof ILaunchConfigurationType) { + IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); + String[] types = store.getString(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST).split("\\,"); //$NON-NLS-1$ + for(int i = 0; i < types.length; i++) { + if(types[i].equals(((ILaunchConfigurationType)element).getIdentifier())) { + return false; + } + } + return true; + } + return false; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 53cb0aed6..ebf6bf512 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.launchConfigurations; - import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; import java.util.HashMap; @@ -27,9 +26,10 @@ import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.DialogSettingsHelper; import org.eclipse.debug.internal.ui.IDebugHelpContextIds; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.PixelConverter; -import org.eclipse.debug.internal.ui.SWTUtil; import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugView; @@ -38,6 +38,7 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.ILaunchConfigurationTabGroup; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.dialogs.ControlEnableState; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -49,7 +50,13 @@ import org.eclipse.jface.dialogs.PageChangedEvent; import org.eclipse.jface.dialogs.TitleAreaDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.ModalContext; +import org.eclipse.jface.preference.IPreferenceNode; +import org.eclipse.jface.preference.PreferenceDialog; +import org.eclipse.jface.preference.PreferenceManager; +import org.eclipse.jface.preference.PreferenceNode; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -57,12 +64,13 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.window.Window; import org.eclipse.jface.wizard.ProgressMonitorPart; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -76,36 +84,99 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.ToolBar; import org.eclipse.ui.PlatformUI; - /** * The dialog used to edit and launch launch configurations. */ -public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaunchConfigurationDialog, IPageChangeProvider { +public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaunchConfigurationDialog, IPageChangeProvider, IPropertyChangeListener { /** * Keep track of the currently visible dialog instance */ private static ILaunchConfigurationDialog fgCurrentlyVisibleLaunchConfigurationDialog; + + /** + * Default weights for the SashForm that specify how wide the selection and + * edit areas aree relative to each other. + */ + private static final int[] DEFAULT_SASH_WEIGHTS = new int[] {11, 30}; + + /** + * Id for 'Launch' button. + */ + protected static final int ID_LAUNCH_BUTTON = IDialogConstants.CLIENT_ID + 1; /** - * The label appearing above tree of configs & config types. + * Id for 'Close' button. */ - private Label fTreeLabel; + protected static final int ID_CLOSE_BUTTON = IDialogConstants.CLIENT_ID + 2; /** - * The Composite used to insert an adjustable 'sash' between the tree and the tabs. + * Id for 'Cancel' button. */ - private SashForm fSashForm; + protected static final int ID_CANCEL_BUTTON = IDialogConstants.CLIENT_ID + 3; + + /** + * Constrant String used as key for setting and retrieving current Control with focus + */ + private static final String FOCUS_CONTROL = "focusControl";//$NON-NLS-1$ + + /** + * Constant specifying how wide this dialog is allowed to get (as a percentage of + * total available screen width) as a result of tab labels in the edit area. + */ + protected static final float MAX_DIALOG_WIDTH_PERCENT = 0.50f; + + /** + * Constant specifying how tall this dialog is allowed to get (as a percentage of + * total available screen height) as a result of preferred tab size. + */ + protected static final float MAX_DIALOG_HEIGHT_PERCENT = 0.50f; + + /** + * Size of this dialog if there is no preference specifying a size. + */ + protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(620, 560); + /** + * Constant specifying that this dialog should be opened with the last configuration launched + * in the workspace selected. + */ + public static final int LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED = 2; + /** + * Constant specifying that this dialog should be opened with the value specified via + * <code>setInitialSelection()</code> selected. + */ + public static final int LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION = 3; + /** + * Constant specifying that a new launch configuration dialog was not opened. Instead + * an existing launch configuration dialog was used. + */ + public static final int LAUNCH_CONFIGURATION_DIALOG_REUSE_OPEN = 4; /** - * Default weights for the SashForm that specify how wide the selection and - * edit areas aree relative to each other. + * Returns the currently visibile dialog + * @return the currently visible launch dialog */ - private static final int[] DEFAULT_SASH_WEIGHTS = new int[] {11, 30}; + public static ILaunchConfigurationDialog getCurrentlyVisibleLaunchConfigurationDialog() { + return fgCurrentlyVisibleLaunchConfigurationDialog; + } + + /** + * Sets which launch dialog is currently the visible one + * @param dialog the dialog to set as the visible one + */ + public static void setCurrentlyVisibleLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { + fgCurrentlyVisibleLaunchConfigurationDialog = dialog; + } /** + * The Composite used to insert an adjustable 'sash' between the tree and the tabs. + */ + private SashForm fSashForm; + + /** * The launch configuration selection area. */ private Composite fSelectionArea; @@ -113,47 +184,52 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun /** * Tree view of launch configurations */ - private LaunchConfigurationView fLaunchConfigurationView; + private LaunchConfigurationView fLaunchConfigurationView; /** * Tab edit area */ private LaunchConfigurationTabGroupViewer fTabViewer; - + /** * The launch configuration edit area. */ private Composite fEditArea; - - /** - * The 'New configuration' action. - */ - private ButtonAction fButtonActionNew; - - /** - * The 'Delete configuration' action. - */ - private ButtonAction fButtonActionDelete; - + /** * The 'cancel' button that appears when the in-dialog progress monitor is shown. */ - private Button fProgressMonitorCancelButton; - + private Button fProgressMonitorCancelButton; + /** * When this dialog is opened in <code>LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION</code> * mode, this specifies the selection that is initially shown in the dialog. */ private IStructuredSelection fInitialSelection; - + /** * The status to open the dialog on, or <code>null</code> if none. */ private IStatus fInitialStatus; - + + /** + * progress monitor part + */ private ProgressMonitorPart fProgressMonitorPart; + + /** + * Default cursor for waiting + */ private Cursor waitCursor; + + /** + * Default cursor for the arrow + */ private Cursor arrowCursor; + + /** + * Listener for a list + */ private ListenerList changeListeners = new ListenerList(); /** @@ -175,66 +251,39 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun * Double-click action */ private IAction fDoubleClickAction; - - /** - * Id for 'Launch' button. - */ - protected static final int ID_LAUNCH_BUTTON = IDialogConstants.CLIENT_ID + 1; - - /** - * Id for 'Close' button. - */ - protected static final int ID_CLOSE_BUTTON = IDialogConstants.CLIENT_ID + 2; /** - * Id for 'Cancel' button. + * The 'New' toolbar action + * @since 3.2 */ - protected static final int ID_CANCEL_BUTTON = IDialogConstants.CLIENT_ID + 3; + private IAction fNewAction; /** - * Constrant String used as key for setting and retrieving current Control with focus + * the 'Delete' toolbar action + * @since 3.2 */ - private static final String FOCUS_CONTROL = "focusControl";//$NON-NLS-1$ + private IAction fDeleteAction; /** - * Constant specifying how wide this dialog is allowed to get (as a percentage of - * total available screen width) as a result of tab labels in the edit area. + * the 'Filter' toolbar action + * @since 3.2 */ - protected static final float MAX_DIALOG_WIDTH_PERCENT = 0.50f; - - /** - * Constant specifying how tall this dialog is allowed to get (as a percentage of - * total available screen height) as a result of preferred tab size. - */ - protected static final float MAX_DIALOG_HEIGHT_PERCENT = 0.50f; - - /** - * Empty array - */ - protected static final Object[] EMPTY_ARRAY = new Object[0]; + private IAction fFilterAction; /** - * Size of this dialog if there is no preference specifying a size. - */ - protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(620, 560); - - /** - * Constant specifying that this dialog should be opened with the last configuration launched - * in the workspace selected. - */ - public static final int LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED = 2; - - /** - * Constant specifying that this dialog should be opened with the value specified via - * <code>setInitialSelection()</code> selected. + * the 'Duplicate' toolbar action + * @since 3.2 */ - public static final int LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION = 3; + private IAction fDuplicateAction; /** - * Constant specifying that a new launch configuration dialog was not opened. Instead - * an existing launch configuration dialog was used. + * Filters for the LCD + * @since 3.2 */ - public static final int LAUNCH_CONFIGURATION_DIALOG_REUSE_OPEN = 4; + private ClosedProjectFilter fClosedProjectFilter; + private DeletedProjectFilter fDeletedProjectFilter; + private LaunchConfigurationTypeFilter fLCTFilter; + private Label fFilteringLabel; /** * Specifies how this dialog behaves when opened. Value is one of the @@ -254,35 +303,107 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun setShellStyle(getShellStyle() | SWT.RESIZE); setLaunchGroup(group); } - + /** - * Set the flag indicating how this dialog behaves when the <code>open()</code> method is called. - * Valid values are defined by the LAUNCH_CONFIGURATION_DIALOG... constants in this class. + * About to start a long running operation triggered through + * the dialog. Shows the progress monitor and disables the dialog's + * buttons and controls. + * + * @return the saved UI state */ - public void setOpenMode(int mode) { - fOpenMode = mode; - } + private Object aboutToStart() { + Map savedState = null; + if (getShell() != null) { + // Save focus control + Control focusControl = getShell().getDisplay().getFocusControl(); + if (focusControl != null && focusControl.getShell() != getShell()) { + focusControl = null; + } + + // Set the busy cursor to all shells. + Display d = getShell().getDisplay(); + waitCursor = new Cursor(d, SWT.CURSOR_WAIT); + setDisplayCursor(waitCursor); + + // Set the arrow cursor to the cancel component. + arrowCursor= new Cursor(d, SWT.CURSOR_ARROW); + getProgressMonitorCancelButton().setCursor(arrowCursor); - protected int getOpenMode() { - return fOpenMode; + // Deactivate shell + savedState = saveUIState(); + if (focusControl != null) { + savedState.put(FOCUS_CONTROL, focusControl); + } + + // Attach the progress monitor part to the cancel button + getProgressMonitorCancelButton().setEnabled(true); + getProgressMonitorPart().attachToCancelComponent(getProgressMonitorCancelButton()); + getProgressMonitorPart().getParent().setVisible(true); + getProgressMonitorCancelButton().setFocus(); + } + return savedState; } /** - * A launch configuration dialog overrides this method - * to create a custom set of buttons in the button bar. - * This dialog has 'Launch' and 'Cancel' - * buttons. + * Adds content to the dialog area * - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + * @param dialogComp */ - protected void createButtonsForButtonBar(Composite parent) { - Button button = createButton(parent, ID_LAUNCH_BUTTON, getLaunchButtonText(), true); - button.setEnabled(false); - createButton(parent, ID_CLOSE_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Close_1, false); + protected void addContent(Composite dialogComp) { + GridData gd; + Composite topComp = new Composite(dialogComp, SWT.NONE); + gd = new GridData(GridData.FILL_BOTH); + topComp.setLayoutData(gd); + GridLayout topLayout = new GridLayout(2, false); + topLayout.marginHeight = 5; + topLayout.marginWidth = 0; + topComp.setLayout(topLayout); + + // Set the things that TitleAreaDialog takes care of + setTitle(LaunchConfigurationsMessages.LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8); + setMessage(LaunchConfigurationsMessages.LaunchConfigurationDialog_Ready_to_launch_2); + setModeLabelState(); + + // Create the SashForm that contains the selection area on the left, + // and the edit area on the right + setSashForm(new SashForm(topComp, SWT.NONE)); + getSashForm().setOrientation(SWT.HORIZONTAL); + gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = 2; + getSashForm().setLayoutData(gd); + getSashForm().setFont(dialogComp.getFont()); + + // Build the launch configuration selection area and put it into the composite. + Control launchConfigSelectionArea = createLaunchConfigurationSelectionArea(getSashForm()); + gd = new GridData(GridData.FILL_VERTICAL); + launchConfigSelectionArea.setLayoutData(gd); + + // Build the launch configuration edit area and put it into the composite. + Composite editAreaComp = createLaunchConfigurationEditArea(getSashForm()); + setEditArea(editAreaComp); + gd = new GridData(GridData.FILL_BOTH); + editAreaComp.setLayoutData(gd); + + // Build the separator line that demarcates the button bar + Label separator = new Label(topComp, SWT.HORIZONTAL | SWT.SEPARATOR); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + separator.setLayoutData(gd); + + dialogComp.layout(true); + applyDialogFont(dialogComp); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IPageChangeProvider#addPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) + */ + public void addPageChangedListener(IPageChangedListener listener) { + changeListeners.add(listener); } /** - * Handle the 'save and launch' & 'launch' buttons here, all others are handled + * Handle the 'close' & 'launch' buttons here, all others are handled * in <code>Dialog</code> * * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) @@ -296,101 +417,35 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun super.buttonPressed(buttonId); } } - - /** - * Returns the appropriate text for the launch button - run or debug. - */ - protected String getLaunchButtonText() { - return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(getMode()).getLabel(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control contents = super.createContents(parent); - initializeContent(); - return contents; - } - - protected void initializeContent() { - doInitialTreeSelection(); - IStatus status = getInitialStatus(); - if (status != null) { - handleStatus(status); - } - } - - - /** - * Initialize the relative weights (widths) of the 2 sides of the sash. - */ - private void initializeSashForm() { - if (getSashForm() != null) { - IDialogSettings settings = getDialogSettings(); - int[] sashWeights; - try { - int w1, w2; - w1 = settings.getInt(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_1); - w2 = settings.getInt(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_2); - sashWeights = new int[] {w1, w2}; - } catch (NumberFormatException e) { - sashWeights = DEFAULT_SASH_WEIGHTS; - } - getSashForm().setWeights(sashWeights); - } - } - - /** - * Check if the selection area is currently wide enough so that both the 'New' & - * 'Delete' buttons are shown without truncation. If so, do nothing. Otherwise, - * increase the width of this dialog's Shell just enough so that both buttons - * are shown cleanly. - */ - private void ensureSelectionAreaWidth() { - if (fLaunchConfigurationView != null) { - Button newButton = getButtonActionNew().getButton(); - Button deleteButton = getButtonActionDelete().getButton(); - int requiredWidth = newButton.getBounds().width + deleteButton.getBounds().width; - int marginWidth = ((GridLayout)getSelectionArea().getLayout()).marginWidth; - int horizontalSpacing = ((GridLayout)getSelectionArea().getLayout()).horizontalSpacing; - requiredWidth += (2 * marginWidth) + horizontalSpacing; - int currentWidth = getSelectionArea().getBounds().width; - - if (requiredWidth > currentWidth) { - int[] newSashWeights = new int[2]; - newSashWeights[0] = requiredWidth; - newSashWeights[1] = getEditArea().getBounds().width; - Shell shell= getShell(); - Point shellSize= shell.getSize(); - setShellSize(shellSize.x + (requiredWidth - currentWidth), shellSize.y); - getSashForm().setWeights(newSashWeights); - } - } - } /** - * Set the initial selection in the tree. - */ - public void doInitialTreeSelection() { - fLaunchConfigurationView.getViewer().setSelection(getInitialSelection()); + * Calculate & return a 2 element integer array that specifies the relative + * weights of the selection area and the edit area, based on the specified + * increase in width of the owning shell. The point of this method is calculate + * sash weights such that when the shell gets wider, all of the increase in width + * is given to the edit area (tab folder), and the selection area (tree) stays + * the same width. + * + * @return an array of the new sash weights + */ + private int[] calculateNewSashWeights(int widthIncrease) { + int[] newWeights = new int[2]; + newWeights[0] = getSelectionArea().getBounds().width; + newWeights[1] = getEditArea().getBounds().width + widthIncrease; + return newWeights; } /** - * Write out this dialog's Shell size, location to the preference store. + * Return whether the current configuration can be discarded. This involves determining + * if it is dirty, and if it is, asking the user what to do. + * + * @return if we can discard the current config or not */ - protected void persistShellGeometry() { - DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName()); - } - - protected void persistSashWeights() { - IDialogSettings settings = getDialogSettings(); - SashForm sashForm = getSashForm(); - if (sashForm != null) { - int[] sashWeights = getSashForm().getWeights(); - settings.put(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_1, sashWeights[0]); - settings.put(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_2, sashWeights[1]); + private boolean canDiscardCurrentConfig() { + if (getTabViewer().isDirty()) { + return showUnsavedChangesDialog(); } + return true; } /* (non-Javadoc) @@ -408,42 +463,88 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun if (fLaunchConfigurationView != null) { fLaunchConfigurationView.dispose(); } + DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); return super.close(); } /** - * Returns whether the dialog can be closed + * Sets the title for the dialog, and establishes the help context. * - * @return whether the dialog can be closed + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell); */ - protected boolean isSafeToClose() { - return fActiveRunningOperations == 0; + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(getShellTitle()); + PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, getHelpContextId()); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#create() + */ + public void create() { + super.create(); + // bug 27011 + if (getTabViewer().getInput() == null) { + getTabViewer().inputChanged(null); + } } + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected Control createButtonBar(Composite parent) { + Font font = parent.getFont(); + Composite composite= new Composite(parent, SWT.NULL); + + GridLayout layout= new GridLayout(); + layout.numColumns= 2; + layout.marginHeight= 0; + layout.marginWidth= 0; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + composite.setFont(font); + + Composite monitorComposite = new Composite(composite, SWT.NULL); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; + monitorComposite.setLayout(layout); + monitorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + GridLayout pmLayout = new GridLayout(); + setProgressMonitorPart(new ProgressMonitorPart(monitorComposite, pmLayout)); + Button cancelButton = createButton(monitorComposite, ID_CANCEL_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_3, true); + setProgressMonitorCancelButton(cancelButton); + getProgressMonitorCancelButton().setFont(font); + getProgressMonitorPart().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + getProgressMonitorPart().setFont(font); + monitorComposite.setVisible(false); + + return super.createButtonBar(composite); + } + /** - * Determine the initial configuration for this dialog. - * Open the dialog in the mode set using #setOpenMode(int) and return one of - * <code>Window. OK</code> or <code>Window.CANCEL</code>. + * A launch configuration dialog overrides this method + * to create a custom set of buttons in the button bar. + * This dialog has 'Launch' and 'Cancel' + * buttons. * - * @see org.eclipse.jface.window.Window#open() + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ - public int open() { - int mode = getOpenMode(); - setCurrentlyVisibleLaunchConfigurationDialog(this); - if (mode == LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED) { - ILaunchConfiguration lastLaunchedConfig = getLastLaunchedWorkbenchConfiguration(); - if (lastLaunchedConfig != null) { - setInitialSelection(new StructuredSelection(lastLaunchedConfig)); - } - } - return super.open(); + protected void createButtonsForButtonBar(Composite parent) { + Button button = createButton(parent, ID_LAUNCH_BUTTON, getLaunchButtonText(), true); + button.setEnabled(false); + createButton(parent, ID_CLOSE_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Close_1, false); } - /** - * Return the last launched configuration in the workspace. + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) */ - protected ILaunchConfiguration getLastLaunchedWorkbenchConfiguration() { - return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLastLaunch(getLaunchGroup().getIdentifier()); + protected Control createContents(Composite parent) { + Control contents = super.createContents(parent); + initializeContent(); + return contents; } /* (non-Javadoc) @@ -454,82 +555,104 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun addContent(dialogComp); return dialogComp; } - + /** - * Adds content to the dialog area + * Creates the launch configuration edit area of the dialog. + * This area displays the name of the launch configuration + * currently being edited, as well as a tab folder of tabs + * that are applicable to the launch configuration. * - * @param dialogComp + * @return the composite used for launch configuration editing + */ + protected Composite createLaunchConfigurationEditArea(Composite parent) { + setTabViewer(new LaunchConfigurationTabGroupViewer(parent, this)); + getTabViewer().addSelectionChangedListener(new ISelectionChangedListener() { + /** + * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) + */ + public void selectionChanged(SelectionChangedEvent event) { + handleTabSelectionChanged(); + } + }); + return (Composite)getTabViewer().getControl(); + } + + /** + * Creates the toolbar and actions for the New, Delete and Filter actions + * @param parent the parent to add the toolbar to + * @return a new composite with the toolbar attached + * + * @since 3.2 */ - protected void addContent(Composite dialogComp) { - GridData gd; - Composite topComp = new Composite(dialogComp, SWT.NONE); - gd = new GridData(GridData.FILL_BOTH); - topComp.setLayoutData(gd); - GridLayout topLayout = new GridLayout(); - topLayout.numColumns = 2; - topLayout.marginHeight = 5; - topLayout.marginWidth = 0; - topComp.setLayout(topLayout); + protected Composite createToolbarArea(Composite parent) { + GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END); + Composite toolbarcomp = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + toolbarcomp.setLayout(layout); + toolbarcomp.setLayoutData(gd); - // Set the things that TitleAreaDialog takes care of - setTitle(LaunchConfigurationsMessages.LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8); - setMessage(LaunchConfigurationsMessages.LaunchConfigurationDialog_Ready_to_launch_2); - setModeLabelState(); + ToolBar toolbar = new ToolBar(toolbarcomp, SWT.FLAT); + toolbar.setLayout(new GridLayout()); + toolbar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); + ToolBarManager tmanager = new ToolBarManager(toolbar); - // Create the SashForm that contains the selection area on the left, - // and the edit area on the right - setSashForm(new SashForm(topComp, SWT.NONE)); - getSashForm().setOrientation(SWT.HORIZONTAL); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 2; - getSashForm().setLayoutData(gd); - getSashForm().setFont(dialogComp.getFont()); + fNewAction = new Action(LaunchConfigurationsMessages.LaunchConfigurationDialog_Ne_w_13, DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG)) { + public void run() { + getNewAction().run(); + } + }; + fNewAction.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_NEW_CONFIG)); + fNewAction.setToolTipText(LaunchConfigurationsMessages.LaunchConfigurationsDialog_0); - // Build the launch configuration selection area and put it into the composite. - Control launchConfigSelectionArea = createLaunchConfigurationSelectionArea(getSashForm()); - gd = new GridData(GridData.FILL_VERTICAL); - launchConfigSelectionArea.setLayoutData(gd); + fDeleteAction = new Action(LaunchConfigurationsMessages.LaunchConfigurationDialog_Dele_te_14, DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_REMOVE)) { + public void run() { + getDeleteAction().run(); + } + }; + fDeleteAction.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE)); + fDeleteAction.setToolTipText(LaunchConfigurationsMessages.LaunchConfigurationsDialog_1); - // Build the launch configuration edit area and put it into the composite. - Composite editAreaComp = createLaunchConfigurationEditArea(getSashForm()); - setEditArea(editAreaComp); - gd = new GridData(GridData.FILL_BOTH); - editAreaComp.setLayoutData(gd); - - // Build the separator line that demarcates the button bar - Label separator = new Label(topComp, SWT.HORIZONTAL | SWT.SEPARATOR); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - separator.setLayoutData(gd); + fFilterAction = new Action(LaunchConfigurationsMessages.LaunchConfigurationsDialog_2, DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS)) { + public void run() { + final IPreferenceNode targetNode = new PreferenceNode(LaunchConfigurationsMessages.LaunchConfigurationsDialog_3, + new LaunchConfigurationsPreferencePage()); + PreferenceManager manager = new PreferenceManager(); + manager.addToRoot(targetNode); + final PreferenceDialog dialog = new PreferenceDialog(DebugUIPlugin.getShell(), manager); + final boolean [] result = new boolean[] { false }; + BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), new Runnable() { + public void run() { + dialog.create(); + dialog.setMessage(targetNode.getLabelText()); + result[0]= (dialog.open() == Window.OK); + } + }); + } + }; + fFilterAction.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS)); + fFilterAction.setToolTipText(LaunchConfigurationsMessages.LaunchConfigurationsDialog_4); - dialogComp.layout(true); - applyDialogFont(dialogComp); - } - - /** - * Set the title area image based on the mode this dialog was initialized with - */ - protected void setModeLabelState() { - setTitleImage(getBannerImage()); + fDuplicateAction = new Action(LaunchConfigurationsMessages.DuplicateLaunchConfigurationAction__Duplicate_1, DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG)) { + public void run() { + getDuplicateAction().run(); + } + }; + fDuplicateAction.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DUPLICATE_CONFIG)); + fDuplicateAction.setToolTipText(LaunchConfigurationsMessages.LaunchConfigurationsDialog_5); + + tmanager.add(fNewAction); + tmanager.add(fDuplicateAction); + tmanager.add(fDeleteAction); + tmanager.add(fFilterAction); + tmanager.update(true); + + DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); + return toolbarcomp; } /** - * Update buttons and message. - */ - protected void refreshStatus() { - updateMessage(); - updateButtons(); - } - - protected Display getDisplay() { - Shell shell = getShell(); - if (shell != null) { - return shell.getDisplay(); - } - return Display.getDefault(); - } - - /** * Creates the launch configuration selection area of the dialog. * This area displays a tree of launch configurations that the user * may select, and allows users to create new configurations, and @@ -548,144 +671,224 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun comp.setLayout(layout); comp.setFont(font); - setTreeLabel(new Label(comp, SWT.NONE)); - getTreeLabel().setFont(font); - getTreeLabel().setText(LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Con_figurations__1); + //create the toolbar area + createToolbarArea(comp); + //create the tree view + Label treelabel = new Label(comp, SWT.NONE); + treelabel.setText(LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Con_figurations__1); + treelabel.setFont(font); fLaunchConfigurationView = new LaunchConfigurationView(getLaunchGroup()); fLaunchConfigurationView.createLaunchDialogControl(comp); + fDoubleClickAction = new Action() { + public void run() { + IStructuredSelection selection = (IStructuredSelection)fLaunchConfigurationView.getViewer().getSelection(); + Object target = selection.getFirstElement(); + if (target instanceof ILaunchConfiguration) { + if (getTabViewer().canLaunch()) { + handleLaunchPressed(); + } + } else { + getNewAction().run(); + } + } + }; + fLaunchConfigurationView.setAction(IDebugView.DOUBLE_CLICK_ACTION, fDoubleClickAction); Viewer viewer = fLaunchConfigurationView.getViewer(); - Control control = viewer.getControl(); + //set up the filters + fClosedProjectFilter = new ClosedProjectFilter(); + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED)) { + ((StructuredViewer)viewer).addFilter(fClosedProjectFilter); + } + fDeletedProjectFilter = new DeletedProjectFilter(); + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED)) { + ((StructuredViewer)viewer).addFilter(fDeletedProjectFilter); + } + fLCTFilter = new LaunchConfigurationTypeFilter(); + if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES)) { + ((StructuredViewer)viewer).addFilter(fLCTFilter); + } + + Control control = viewer.getControl(); GridData gd = new GridData(GridData.FILL_BOTH); control.setLayoutData(gd); control.setFont(font); - fDoubleClickAction = new DoubleClickAction(); - fLaunchConfigurationView.setAction(IDebugView.DOUBLE_CLICK_ACTION, fDoubleClickAction); - - Composite buttonComposite= new Composite(comp, SWT.NONE); - layout= new GridLayout(2, false); - layout.marginHeight= 0; - layout.marginWidth= 0; - buttonComposite.setLayout(layout); - gd= new GridData(GridData.FILL_HORIZONTAL); - buttonComposite.setLayoutData(gd); - buttonComposite.setFont(comp.getFont()); - - final Button newButton = SWTUtil.createPushButton(buttonComposite, LaunchConfigurationsMessages.LaunchConfigurationDialog_Ne_w_13, null); - setButtonActionNew(new ButtonActionNew(newButton.getText(), newButton)); - - final Button deleteButton = SWTUtil.createPushButton(buttonComposite, LaunchConfigurationsMessages.LaunchConfigurationDialog_Dele_te_14, null); - setButtonActionDelete(new ButtonActionDelete(deleteButton.getText(), deleteButton)); + fFilteringLabel = new Label(comp, SWT.NONE); + fFilteringLabel.setFont(font); + refreshFilteringLabel(); - AbstractLaunchConfigurationAction.IConfirmationRequestor requestor = - new AbstractLaunchConfigurationAction.IConfirmationRequestor() { - /** - * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractLaunchConfigurationAction.IConfirmationRequestor#getConfirmation() - */ - public boolean getConfirmation() { - return canDiscardCurrentConfig(); - } - }; - // confirmation requestors + AbstractLaunchConfigurationAction.IConfirmationRequestor requestor = new AbstractLaunchConfigurationAction.IConfirmationRequestor() { + public boolean getConfirmation() { + return canDiscardCurrentConfig(); + } + }; getDuplicateAction().setConfirmationRequestor(requestor); getNewAction().setConfirmationRequestor(requestor); - + + //listeners ((StructuredViewer) viewer).addPostSelectionChangedListener(new ISelectionChangedListener() { - /** - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ public void selectionChanged(SelectionChangedEvent event) { handleLaunchConfigurationSelectionChanged(event); - newButton.setEnabled(getNewAction().isEnabled()); - deleteButton.setEnabled(getDeleteAction().isEnabled()); + fNewAction.setEnabled(getNewAction().isEnabled()); + fDeleteAction.setEnabled(getDeleteAction().isEnabled()); + fDuplicateAction.setEnabled(getDuplicateAction().isEnabled()); } }); return comp; } /** - * Creates the launch configuration edit area of the dialog. - * This area displays the name of the launch configuration - * currently being edited, as well as a tab folder of tabs - * that are applicable to the launch configuration. - * - * @return the composite used for launch configuration editing - */ - protected Composite createLaunchConfigurationEditArea(Composite parent) { - setTabViewer(new LaunchConfigurationTabGroupViewer(parent, this)); - getTabViewer().addSelectionChangedListener(new ISelectionChangedListener() { - /** - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - handleTabSelectionChanged(); - } - }); - return (Composite)getTabViewer().getControl(); + * Displays how many of the items showing matched the filtering currently in operation + * @since 3.2 + */ + private void refreshFilteringLabel() { + try { + int total = getLaunchManager().getLaunchConfigurations().length + getLaunchManager().getLaunchConfigurationTypes().length; + TreeViewer viewer = ((TreeViewer)fLaunchConfigurationView.getViewer()); + viewer.getTree().selectAll(); + int filtered = ((IStructuredSelection)viewer.getSelection()).size(); + viewer.getTree().deselectAll(); + fFilteringLabel.setText(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationsDialog_6, new Object[] {new Integer(filtered), new Integer(total)})); + + } + catch(CoreException e) {e.printStackTrace();} + } + + /** + * Set the initial selection in the tree. + */ + public void doInitialTreeSelection() { + fLaunchConfigurationView.getViewer().setSelection(getInitialSelection()); } + /** + * Notifies any selection changed listeners that the selected page + * has changed. + * Only listeners registered at the time this method is called are notified. + * + * @param event a selection changed event + * + * @see IPageChangedListener#pageChanged + */ + protected void firePageChanged(final PageChangedEvent event) { + Object[] listeners = changeListeners.getListeners(); + for (int i = 0; i < listeners.length; ++i) { + final IPageChangedListener l = (IPageChangedListener) listeners[i]; + Platform.run(new SafeRunnable() { + public void run() { + l.pageChanged(event); + } + }); + } + } + /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonBar(org.eclipse.swt.widgets.Composite) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#generateName(java.lang.String) */ - protected Control createButtonBar(Composite parent) { - Font font = parent.getFont(); - Composite composite= new Composite(parent, SWT.NULL); - - GridLayout layout= new GridLayout(); - layout.numColumns= 2; - layout.marginHeight= 0; - layout.marginWidth= 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - composite.setFont(font); - - Composite monitorComposite = new Composite(composite, SWT.NULL); - layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - layout.numColumns = 2; - monitorComposite.setLayout(layout); - monitorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - GridLayout pmLayout = new GridLayout(); - setProgressMonitorPart(new ProgressMonitorPart(monitorComposite, pmLayout)); - Button cancelButton = createButton(monitorComposite, ID_CANCEL_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_3, true); - setProgressMonitorCancelButton(cancelButton); - getProgressMonitorCancelButton().setFont(font); - getProgressMonitorPart().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - getProgressMonitorPart().setFont(font); - monitorComposite.setVisible(false); - - return super.createButtonBar(composite); + public String generateName(String name) { + if (name == null) { + name = ""; //$NON-NLS-1$ + } + return getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getActiveTab() + */ + public ILaunchConfigurationTab getActiveTab() { + return getTabViewer().getActiveTab(); } /** - * Sets the title for the dialog, and establishes the help context. - * - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell); + * Returns the banner image to display in the title area */ - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(getShellTitle()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, getHelpContextId()); + protected Image getBannerImage() { + if (fBannerImage == null) { + ImageDescriptor descriptor = getLaunchGroup().getBannerImageDescriptor(); + if (descriptor != null) { + fBannerImage = descriptor.createImage(); + } + } + return fBannerImage; } + /** + * Gets the delete menu action + * + * @return the delete menu action + */ + protected AbstractLaunchConfigurationAction getDeleteAction() { + return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DeleteLaunchConfigurationAction.ID_DELETE_ACTION); + } + + /** + * Returns the dialog settings for this dialog. Subclasses should override + * <code>getDialogSettingsKey()</code>. + * + * @return IDialogSettings + */ + protected IDialogSettings getDialogSettings() { + IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); + if (section == null) { + section = settings.addNewSection(getDialogSettingsSectionName()); + } + return section; + } + + /** + * Returns the name of the section that this dialog stores its settings in + * + * @return String + */ + protected String getDialogSettingsSectionName() { + return IDebugUIConstants.PLUGIN_ID + ".LAUNCH_CONFIGURATIONS_DIALOG_SECTION"; //$NON-NLS-1$ + } + + /** + * Gets the current display + * + * @return the display + */ + protected Display getDisplay() { + Shell shell = getShell(); + if (shell != null) { + return shell.getDisplay(); + } + return Display.getDefault(); + } + + /** + * Gets the duplicate menu action + * + * @return the duplicate menu action + */ + protected AbstractLaunchConfigurationAction getDuplicateAction() { + return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DuplicateLaunchConfigurationAction.ID_DUPLICATE_ACTION); + } + + /** + * Returns the launch configuration edit area control. + * + * @return control + */ + protected Composite getEditArea() { + return fEditArea; + } + + /** + * Gets the hlep context id + * + * @return the help context id + */ protected String getHelpContextId() { return IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG; } - - protected String getShellTitle() { - String title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel()); - if (title == null) { - title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; - } - return title; - } - - /* (non-Javadoc) + + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point) */ protected Point getInitialLocation(Point initialSize) { @@ -699,8 +902,18 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun } return super.getInitialLocation(initialSize); } - - /* (non-Javadoc) + + /** + * Returns the initial selection shown in this dialog when opened in + * <code>LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION</code> mode. + * + * @return the initial selection of the dialog + */ + private IStructuredSelection getInitialSelection() { + return fInitialSelection; + } + + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#getInitialSize() */ protected Point getInitialSize() { @@ -714,16 +927,44 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun } return DEFAULT_INITIAL_DIALOG_SIZE; } - - private void setSashForm(SashForm sashForm) { - fSashForm = sashForm; + + /** + * Returns the status the dialog was opened on or <code>null</code> if none. + * + * @return IStatus + */ + protected IStatus getInitialStatus() { + return fInitialStatus; } - - private SashForm getSashForm() { - return fSashForm; + + /** + * Return the last launched configuration in the workspace. + * + * @return the last launched configuration + */ + protected ILaunchConfiguration getLastLaunchedWorkbenchConfiguration() { + return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLastLaunch(getLaunchGroup().getIdentifier()); } - /** + /** + * Returns the appropriate text for the launch button - run or debug. + * + * @return the laucnh button text + */ + protected String getLaunchButtonText() { + return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(getMode()).getLabel(); + } + + /** + * Returns the launch group being displayed. + * + * @return launch group + */ + public LaunchGroupExtension getLaunchGroup() { + return fGroup; + } + + /** * Returns the launch manager. * * @return the launch manager @@ -731,14 +972,126 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun private ILaunchManager getLaunchManager() { return DebugPlugin.getDefault().getLaunchManager(); } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getMode() + */ + public String getMode() { + return getLaunchGroup().getMode(); + } + + /** + * Gets the new menu action + * + * @return the new menu action + */ + protected AbstractLaunchConfigurationAction getNewAction() { + return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(CreateLaunchConfigurationAction.ID_CREATE_ACTION); + } + + /** + * returns the open mode + * + * @return the open mode + */ + protected int getOpenMode() { + return fOpenMode; + } + + /** + * returns the progress monitor for the cancel button + * + * @return the progress monitor for the cancel button + */ + private Button getProgressMonitorCancelButton() { + return fProgressMonitorCancelButton; + } + + /** + * returns the local prgress monitor part + * + * @return the local progress monitor part + */ + private ProgressMonitorPart getProgressMonitorPart() { + return fProgressMonitorPart; + } + + /** + * returns the sash form + * @return the sash form + */ + private SashForm getSashForm() { + return fSashForm; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage() + */ + public Object getSelectedPage() { + return getActiveTab(); + } + + /** + * Returns the launch configuration selection area control. + * + * @return control + */ + private Composite getSelectionArea() { + return fSelectionArea; + } + + /** + * Returns the title of the shell + * @return the shell title + */ + protected String getShellTitle() { + String title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel()); + if (title == null) { + title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; + } + return title; + } /** - * Returns whether this dialog is currently open + * Returns the current tab group + * + * @return the current tab group, or <code>null</code> if none + */ + public ILaunchConfigurationTabGroup getTabGroup() { + if (getTabViewer() != null) { + return getTabViewer().getTabGroup(); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getTabs() + */ + public ILaunchConfigurationTab[] getTabs() { + if (getTabGroup() == null) { + return null; + } + return getTabGroup().getTabs(); + } + + /** + * Returns the viewer used to display the tabs for a launch configuration. + * + * @return LaunchConfigurationTabGroupViewer */ - private boolean isVisible() { - return getShell() != null && getShell().isVisible(); - } - + protected LaunchConfigurationTabGroupViewer getTabViewer() { + return fTabViewer; + } + + /** + * Notification the 'Close' button has been pressed. + */ + protected void handleClosePressed() { + if (canDiscardCurrentConfig()) { + cancelPressed(); + } + } + /** * Notification that selection has changed in the launch configuration tree. * <p> @@ -807,8 +1160,112 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun } } } - - protected boolean isEqual(Object o1, Object o2) { + + /** + * Notification the 'launch' button has been pressed. + * Save and launch. + */ + protected void handleLaunchPressed() { + ILaunchConfiguration config = getTabViewer().getOriginal(); + if (getTabViewer().isDirty()) { + getTabViewer().handleApplyPressed(); + config = getTabViewer().getOriginal(); + } + String mode = getMode(); + close(); + if(config != null) { + DebugUITools.launch(config, mode); + }//end if + } + + /** + * Consult a status handler for the given status, if any. The status handler + * is passed this launch config dialog as an argument. + * + * @param status the status to be handled + */ + public void handleStatus(IStatus status) { + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); + if (handler != null) { + try { + handler.handleStatus(status, this); + return; + } catch (CoreException e) { + status = e.getStatus(); + } + } + // if no handler, or handler failed, display error/warning dialog + String title = null; + switch (status.getSeverity()) { + case IStatus.ERROR: + title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Error_1; + break; + case IStatus.WARNING: + title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Warning_2; + break; + default: + title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Information_3; + break; + } + ErrorDialog.openError(getShell(), title, null, status); + } + + /** + * Notification that tab selection has changed. + * + */ + protected void handleTabSelectionChanged() { + updateMessage(); + firePageChanged(new PageChangedEvent(this, getSelectedPage())); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#initializeBounds() + */ + protected void initializeBounds() { + super.initializeBounds(); + initializeSashForm(); + resize(); + } + + /** + * Performs initialization of the content by setting the initial tree selection + */ + protected void initializeContent() { + doInitialTreeSelection(); + IStatus status = getInitialStatus(); + if (status != null) { + handleStatus(status); + } + } + + /** + * Initialize the relative weights (widths) of the 2 sides of the sash. + */ + private void initializeSashForm() { + if (getSashForm() != null) { + IDialogSettings settings = getDialogSettings(); + int[] sashWeights; + try { + int w1, w2; + w1 = settings.getInt(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_1); + w2 = settings.getInt(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_2); + sashWeights = new int[] {w1, w2}; + } catch (NumberFormatException e) { + sashWeights = DEFAULT_SASH_WEIGHTS; + } + getSashForm().setWeights(sashWeights); + } + } + + /** + * Compares two objects to determine their equality + * + * @param o1 the first object + * @param o2 the object to compare to object one + * @return true if they are equal, false if object 1 is null, the result of o1.equals(o2) otherwise + */ + protected boolean isEqual(Object o1, Object o2) { if (o1 == o2) { return true; } else if (o1 == null) { @@ -817,9 +1274,84 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun return o1.equals(o2); } } - - - protected void resize() { + + /** + * Returns whether the dialog can be closed + * + * @return whether the dialog can be closed + */ + protected boolean isSafeToClose() { + return fActiveRunningOperations == 0; + } + + /** + * Returns whether this dialog is currently open + * + * @return if the current shell is visible or not + */ + private boolean isVisible() { + return getShell() != null && getShell().isVisible(); + } + + /** + * Determine the initial configuration for this dialog. + * Open the dialog in the mode set using #setOpenMode(int) and return one of + * <code>Window. OK</code> or <code>Window.CANCEL</code>. + * + * @see org.eclipse.jface.window.Window#open() + * @return the int status of opening the dialog + */ + public int open() { + int mode = getOpenMode(); + setCurrentlyVisibleLaunchConfigurationDialog(this); + if (mode == LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED) { + ILaunchConfiguration lastLaunchedConfig = getLastLaunchedWorkbenchConfiguration(); + if (lastLaunchedConfig != null) { + setInitialSelection(new StructuredSelection(lastLaunchedConfig)); + } + } + return super.open(); + } + + /** + * Save the current sash weights + */ + protected void persistSashWeights() { + IDialogSettings settings = getDialogSettings(); + SashForm sashForm = getSashForm(); + if (sashForm != null) { + int[] sashWeights = getSashForm().getWeights(); + settings.put(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_1, sashWeights[0]); + settings.put(IDebugPreferenceConstants.DIALOG_SASH_WEIGHTS_2, sashWeights[1]); + } + } + + /** + * Write out this dialog's Shell size, location to the preference store. + */ + protected void persistShellGeometry() { + DialogSettingsHelper.persistShellGeometry(getShell(), getDialogSettingsSectionName()); + } + + /** + * Update buttons and message. + */ + protected void refreshStatus() { + updateMessage(); + updateButtons(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IPageChangeProvider#removePageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) + */ + public void removePageChangedListener(IPageChangedListener listener) { + changeListeners.remove(listener); + } + + /** + * resize the dialog to show all relevant content + */ + protected void resize() { // determine the maximum tab dimensions PixelConverter pixelConverter = new PixelConverter(getEditArea()); int runningTabWidth = 0; @@ -897,196 +1429,43 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun } } } - - /** - * Notification that tab selection has changed. - * - */ - protected void handleTabSelectionChanged() { - updateMessage(); - firePageChanged(new PageChangedEvent(this, getSelectedPage())); - } - - private void setProgressMonitorPart(ProgressMonitorPart part) { - fProgressMonitorPart = part; - } - - private ProgressMonitorPart getProgressMonitorPart() { - return fProgressMonitorPart; - } - - private void setProgressMonitorCancelButton(Button button) { - fProgressMonitorCancelButton = button; - } - - private Button getProgressMonitorCancelButton() { - return fProgressMonitorCancelButton; - } - - /** - * Calculate & return a 2 element integer array that specifies the relative - * weights of the selection area and the edit area, based on the specified - * increase in width of the owning shell. The point of this method is calculate - * sash weights such that when the shell gets wider, all of the increase in width - * is given to the edit area (tab folder), and the selection area (tree) stays - * the same width. - */ - private int[] calculateNewSashWeights(int widthIncrease) { - int[] newWeights = new int[2]; - newWeights[0] = getSelectionArea().getBounds().width; - newWeights[1] = getEditArea().getBounds().width + widthIncrease; - return newWeights; - } - - /** - * Increase the size of this dialog's <code>Shell</code> by the specified amounts. - * Do not increase the size of the Shell beyond the bounds of the Display. - */ - protected void setShellSize(int width, int height) { - Rectangle bounds = getShell().getDisplay().getBounds(); - getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height)); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getMode() - */ - public String getMode() { - return getLaunchGroup().getMode(); - } - - /** - * Returns the current tab group - * - * @return the current tab group, or <code>null</code> if none - */ - public ILaunchConfigurationTabGroup getTabGroup() { - if (getTabViewer() != null) { - return getTabViewer().getTabGroup(); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getTabs() - */ - public ILaunchConfigurationTab[] getTabs() { - if (getTabGroup() == null) { - return null; - } - return getTabGroup().getTabs(); - } - - /** - * Return whether the current configuration can be discarded. This involves determining - * if it is dirty, and if it is, asking the user what to do. - */ - private boolean canDiscardCurrentConfig() { - if (getTabViewer().isDirty()) { - return showUnsavedChangesDialog(); - } - return true; - } - - /** - * Show the user a dialog appropriate to whether the unsaved changes in the current config - * can be saved or not. Return <code>true</code> if the user indicated that they wish to replace - * the current config, either by saving changes or by discarding the, return <code>false</code> - * otherwise. - */ - private boolean showUnsavedChangesDialog() { - if (getTabViewer().canSave()) { - return showSaveChangesDialog(); - } - return showDiscardChangesDialog(); - } - - /** - * Create and return a dialog that asks the user whether they want to save - * unsaved changes. Return <code>true </code> if they chose to save changes, - * <code>false</code> otherwise. - */ - private boolean showSaveChangesDialog() { - String message = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___29, new String[]{getTabViewer().getWorkingCopy().getName()}); - MessageDialog dialog = new MessageDialog(getShell(), - LaunchConfigurationsMessages.LaunchConfigurationDialog_Save_changes__31, - null, - message, - MessageDialog.QUESTION, - new String[] {LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32, LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_34}, // - 0); - // If user clicked 'Cancel' or closed dialog, return false - int selectedButton = dialog.open(); - if ((selectedButton < 0) || (selectedButton == 2)) { - return false; - } - - // If they hit 'Yes', save the working copy - if (selectedButton == 0) { - // Turn off auto select if prompting to save changes. The user - // has made another selection and we don't want a 'rename' to - // cause an auto-select. - if (fLaunchConfigurationView != null) { - fLaunchConfigurationView.setAutoSelect(false); - } - getTabViewer().handleApplyPressed(); - if (fLaunchConfigurationView != null) { - fLaunchConfigurationView.setAutoSelect(true); - } - } - - return true; - } /** - * Create and return a dialog that asks the user whether they want to discard - * unsaved changes. Return <code>true</code> if they chose to discard changes, - * <code>false</code> otherwise. - */ - private boolean showDiscardChangesDialog() { - StringBuffer buffer = new StringBuffer(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___35, new String[]{getTabViewer().getWorkingCopy().getName()})); - buffer.append(getTabViewer().getErrorMesssage()); - buffer.append(LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_discard_changes_37); - MessageDialog dialog = new MessageDialog(getShell(), - LaunchConfigurationsMessages.LaunchConfigurationDialog_Discard_changes__38, - null, - buffer.toString(), - MessageDialog.QUESTION, - new String[] {LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32, LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33}, // - 1); - // If user clicked 'Yes', return true - int selectedButton = dialog.open(); - if (selectedButton == 0) { - return true; - } - return false; - } - - /** - * Notification the 'Close' button has been pressed. + * Restores the enabled/disabled state of the given control. + * + * @param w the control + * @param h the map (key type: <code>String</code>, element type: + * <code>Boolean</code>) + * @param key the key + * @see #saveEnableStateAndSet */ - protected void handleClosePressed() { - if (canDiscardCurrentConfig()) { - cancelPressed(); + private void restoreEnableState(Control w, Map h, String key) { + if (w != null) { + Boolean b = (Boolean) h.get(key); + if (b != null) + w.setEnabled(b.booleanValue()); } } - + /** - * Notification the 'launch' button has been pressed. - * Save and launch. + * Restores the enabled/disabled state of the wizard dialog's + * buttons and the tree of controls for the currently showing page. + * + * @param state a map containing the saved state as returned by + * <code>saveUIState</code> + * @see #saveUIState */ - protected void handleLaunchPressed() { - ILaunchConfiguration config = getTabViewer().getOriginal(); - if (getTabViewer().isDirty()) { - getTabViewer().handleApplyPressed(); - config = getTabViewer().getOriginal(); + private void restoreUIState(Map state) { + restoreEnableState(getButton(ID_LAUNCH_BUTTON), state, "launch");//$NON-NLS-1$ + restoreEnableState(getButton(ID_CLOSE_BUTTON), state, "close");//$NON-NLS-1$ + ControlEnableState treeState = (ControlEnableState) state.get("selectionarea");//$NON-NLS-1$ + if (treeState != null) { + treeState.restore(); } - String mode = getMode(); - close(); - if(config != null) { - DebugUITools.launch(config, mode); - }//end if + ControlEnableState tabState = (ControlEnableState) state.get("editarea");//$NON-NLS-1$ + tabState.restore(); } - + /*************************************************************************************** * * ProgressMonitor & IRunnableContext related methods @@ -1112,72 +1491,23 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable); } } - - /** - * About to start a long running operation triggered through - * the dialog. Shows the progress monitor and disables the dialog's - * buttons and controls. - * - * @return the saved UI state - */ - private Object aboutToStart() { - Map savedState = null; - if (getShell() != null) { - // Save focus control - Control focusControl = getShell().getDisplay().getFocusControl(); - if (focusControl != null && focusControl.getShell() != getShell()) { - focusControl = null; - } - - // Set the busy cursor to all shells. - Display d = getShell().getDisplay(); - waitCursor = new Cursor(d, SWT.CURSOR_WAIT); - setDisplayCursor(waitCursor); - - // Set the arrow cursor to the cancel component. - arrowCursor= new Cursor(d, SWT.CURSOR_ARROW); - getProgressMonitorCancelButton().setCursor(arrowCursor); - - // Deactivate shell - savedState = saveUIState(); - if (focusControl != null) { - savedState.put(FOCUS_CONTROL, focusControl); - } - - // Attach the progress monitor part to the cancel button - getProgressMonitorCancelButton().setEnabled(true); - getProgressMonitorPart().attachToCancelComponent(getProgressMonitorCancelButton()); - getProgressMonitorPart().getParent().setVisible(true); - getProgressMonitorCancelButton().setFocus(); - } - return savedState; - } /** - * A long running operation triggered through the dialog - * was stopped either by user input or by normal end. - * Hides the progress monitor and restores the enable state - * of the dialog's buttons and controls. + * Saves the enabled/disabled state of the given control in the + * given map, which must be modifiable. * - * @param savedState the saved UI state as returned by <code>aboutToStart</code> - * @see #aboutToStart + * @param w the control, or <code>null</code> if none + * @param h the map (key type: <code>String</code>, element type: + * <code>Boolean</code>) + * @param key the key + * @param enabled <code>true</code> to enable the control, + * and <code>false</code> to disable it + * @see #restoreEnableStateAndSet */ - private void stopped(Object savedState) { - if (getShell() != null) { - getProgressMonitorPart().getParent().setVisible(false); - getProgressMonitorPart().removeFromCancelComponent(getProgressMonitorCancelButton()); - Map state = (Map)savedState; - restoreUIState(state); - - setDisplayCursor(null); - waitCursor.dispose(); - waitCursor = null; - arrowCursor.dispose(); - arrowCursor = null; - Control focusControl = (Control)state.get(FOCUS_CONTROL); - if (focusControl != null) { - focusControl.setFocus(); - } + private void saveEnableStateAndSet(Control w, Map h, String key, boolean enabled) { + if (w != null) { + h.put(key, Boolean.valueOf(w.isEnabled())); + w.setEnabled(enabled); } } @@ -1202,62 +1532,21 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun return savedState; } - /** - * Saves the enabled/disabled state of the given control in the - * given map, which must be modifiable. - * - * @param w the control, or <code>null</code> if none - * @param h the map (key type: <code>String</code>, element type: - * <code>Boolean</code>) - * @param key the key - * @param enabled <code>true</code> to enable the control, - * and <code>false</code> to disable it - * @see #restoreEnableStateAndSet + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setActiveTab(org.eclipse.debug.ui.ILaunchConfigurationTab) */ - private void saveEnableStateAndSet(Control w, Map h, String key, boolean enabled) { - if (w != null) { - h.put(key, Boolean.valueOf(w.isEnabled())); - w.setEnabled(enabled); - } + public void setActiveTab(ILaunchConfigurationTab tab) { + getTabViewer().setActiveTab(tab); } - - /** - * Restores the enabled/disabled state of the wizard dialog's - * buttons and the tree of controls for the currently showing page. - * - * @param state a map containing the saved state as returned by - * <code>saveUIState</code> - * @see #saveUIState + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setActiveTab(int) */ - private void restoreUIState(Map state) { - restoreEnableState(getButton(ID_LAUNCH_BUTTON), state, "launch");//$NON-NLS-1$ - restoreEnableState(getButton(ID_CLOSE_BUTTON), state, "close");//$NON-NLS-1$ - ControlEnableState treeState = (ControlEnableState) state.get("selectionarea");//$NON-NLS-1$ - if (treeState != null) { - treeState.restore(); - } - ControlEnableState tabState = (ControlEnableState) state.get("editarea");//$NON-NLS-1$ - tabState.restore(); + public void setActiveTab(int index) { + getTabViewer().setActiveTab(index); } /** - * Restores the enabled/disabled state of the given control. - * - * @param w the control - * @param h the map (key type: <code>String</code>, element type: - * <code>Boolean</code>) - * @param key the key - * @see #saveEnableStateAndSet - */ - private void restoreEnableState(Control w, Map h, String key) { - if (w != null) { - Boolean b = (Boolean) h.get(key); - if (b != null) - w.setEnabled(b.booleanValue()); - } - } - - /** * Sets the given cursor for all shells currently active * for this window's display. * @@ -1271,68 +1560,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun } /** - * Convenience method that replies whether the tab viewer is in a launchable state. - */ - private boolean canLaunch() { - return getTabViewer().canLaunch(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#updateButtons() - */ - public void updateButtons() { - // New & Delete buttons - getButtonActionNew().setEnabled(getNewAction().isEnabled()); - getButtonActionDelete().setEnabled(getDeleteAction().isEnabled()); - - // Launch button - getTabViewer().refresh(); - getButton(ID_LAUNCH_BUTTON).setEnabled(canLaunch()); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getActiveTab() - */ - public ILaunchConfigurationTab getActiveTab() { - return getTabViewer().getActiveTab(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#updateMessage() - */ - public void updateMessage() { - setErrorMessage(getTabViewer().getErrorMesssage()); - setMessage(getTabViewer().getMessage()); - } - - /** - * Returns the launch configuration selection area control. - * - * @return control - */ - private Composite getSelectionArea() { - return fSelectionArea; - } - - /** - * Sets the launch configuration selection area control. - * - * @param selectionArea control - */ - private void setSelectionArea(Composite selectionArea) { - fSelectionArea = selectionArea; - } - - /** - * Returns the launch configuration edit area control. - * - * @return control - */ - protected Composite getEditArea() { - return fEditArea; - } - - /** * Sets the launch configuration edit area control. * * @param editArea control @@ -1341,31 +1568,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun fEditArea = editArea; } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setName(java.lang.String) - */ - public void setName(String name) { - getTabViewer().setName(name); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#generateName(java.lang.String) - */ - public String generateName(String name) { - if (name == null) { - name = ""; //$NON-NLS-1$ - } - return getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name); - } - - /** - * Returns the initial selection shown in this dialog when opened in - * <code>LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION</code> mode. - */ - private IStructuredSelection getInitialSelection() { - return fInitialSelection; - } - /** * Sets the initial selection for the dialog when opened in * <code>LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION</code> mode. @@ -1374,326 +1576,246 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun fInitialSelection = selection; } - private void setButtonActionNew(ButtonAction action) { - fButtonActionNew = action; - } - - private ButtonAction getButtonActionNew() { - return fButtonActionNew; - } - - private void setButtonActionDelete(ButtonAction action) { - fButtonActionDelete = action; - } - - private ButtonAction getButtonActionDelete() { - return fButtonActionDelete; - } - - private void setTreeLabel(Label treeLabel) { - fTreeLabel = treeLabel; - } - - private Label getTreeLabel() { - return fTreeLabel; - } - - public static void setCurrentlyVisibleLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { - fgCurrentlyVisibleLaunchConfigurationDialog = dialog; - } - - public static ILaunchConfigurationDialog getCurrentlyVisibleLaunchConfigurationDialog() { - return fgCurrentlyVisibleLaunchConfigurationDialog; - } - /** - * Extension of <code>Action</code> that manages a <code>Button</code> - * widget. This allows common handling for actions that must appear in - * a pop-up menu and also as a (non-toolbar) button in the UI. + * Sets the status to open the dialog on. + * + * @param status the intial status for the dialog */ - private abstract class ButtonAction extends Action { - - protected Button fButton; - - /** - * Construct a ButtonAction handler. All details of the specified - * <code>Button</code>'s layout and appearance should be handled - * external to this class. - */ - public ButtonAction(String text, Button button) { - super(text); - fButton = button; - if (fButton != null) { - fButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent evt) { - ButtonAction.this.run(); - } - }); - } - } - - public Button getButton() { - return fButton; - } - - /** - * @see IAction#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (fButton != null) { - fButton.setEnabled(enabled); - } - } + public void setInitialStatus(IStatus status) { + fInitialStatus = status; } /** - * Handler for creating a new configuration. + * Sets the launch group to display. + * + * @param group launch group */ - private class ButtonActionNew extends ButtonAction { - - public ButtonActionNew(String text, Button button) { - super(text, button); - } - - public void run() { - getNewAction().run(); - getTabViewer().setFocusOnName(); - } + protected void setLaunchGroup(LaunchGroupExtension group) { + fGroup = group; } - + /** - * Handler for deleting a configuration. + * Set the title area image based on the mode this dialog was initialized with */ - private class ButtonActionDelete extends ButtonAction { - - public ButtonActionDelete(String text, Button button) { - super(text, button); - } - - public void run() { - getDeleteAction().run(); - } - } - - private class DoubleClickAction extends Action { - /** - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - IStructuredSelection selection = (IStructuredSelection)fLaunchConfigurationView.getViewer().getSelection(); - Object target = selection.getFirstElement(); - if (target instanceof ILaunchConfiguration) { - if (canLaunch()) { - handleLaunchPressed(); - } - } else { - getNewAction().run(); - } - } + protected void setModeLabelState() { + setTitleImage(getBannerImage()); + } - } - - /** - * Returns the banner image to display in the title area + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setName(java.lang.String) */ - protected Image getBannerImage() { - if (fBannerImage == null) { - ImageDescriptor descriptor = getLaunchGroup().getBannerImageDescriptor(); - if (descriptor != null) { - fBannerImage = descriptor.createImage(); - } - } - return fBannerImage; + public void setName(String name) { + getTabViewer().setName(name); } /** - * Sets the launch group to display. - * - * @param group launch group + * Set the flag indicating how this dialog behaves when the <code>open()</code> method is called. + * Valid values are defined by the LAUNCH_CONFIGURATION_DIALOG... constants in this class. */ - protected void setLaunchGroup(LaunchGroupExtension group) { - fGroup = group; + public void setOpenMode(int mode) { + fOpenMode = mode; } /** - * Returns the launch group being displayed. + * Sets the progress monitor on the cancel button * - * @return launch group + * @param button */ - public LaunchGroupExtension getLaunchGroup() { - return fGroup; - } + private void setProgressMonitorCancelButton(Button button) { + fProgressMonitorCancelButton = button; + } - protected AbstractLaunchConfigurationAction getNewAction() { - return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(CreateLaunchConfigurationAction.ID_CREATE_ACTION); - } + private void setProgressMonitorPart(ProgressMonitorPart part) { + fProgressMonitorPart = part; + } - protected AbstractLaunchConfigurationAction getDeleteAction() { - return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DeleteLaunchConfigurationAction.ID_DELETE_ACTION); + private void setSashForm(SashForm sashForm) { + fSashForm = sashForm; } - - protected AbstractLaunchConfigurationAction getDuplicateAction() { - return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DuplicateLaunchConfigurationAction.ID_DUPLICATE_ACTION); - } /** - * Returns the dialog settings for this dialog. Subclasses should override - * <code>getDialogSettingsKey()</code>. + * Sets the launch configuration selection area control. * - * @return IDialogSettings + * @param selectionArea control */ - protected IDialogSettings getDialogSettings() { - IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); - IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); - if (section == null) { - section = settings.addNewSection(getDialogSettingsSectionName()); - } - return section; + private void setSelectionArea(Composite selectionArea) { + fSelectionArea = selectionArea; } - + /** - * Returns the name of the section that this dialog stores its settings in - * - * @return String - */ - protected String getDialogSettingsSectionName() { - return IDebugUIConstants.PLUGIN_ID + ".LAUNCH_CONFIGURATIONS_DIALOG_SECTION"; //$NON-NLS-1$ + * Increase the size of this dialog's <code>Shell</code> by the specified amounts. + * Do not increase the size of the Shell beyond the bounds of the Display. + */ + protected void setShellSize(int width, int height) { + Rectangle bounds = getShell().getDisplay().getBounds(); + getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height)); } - + /** * Sets the viewer used to display the tabs for a launch configuration. * - * @param viewer + * @param viewer the new view to set */ protected void setTabViewer(LaunchConfigurationTabGroupViewer viewer) { fTabViewer = viewer; } - - /** - * Returns the viewer used to display the tabs for a launch configuration. - * - * @return LaunchConfigurationTabGroupViewer - */ - protected LaunchConfigurationTabGroupViewer getTabViewer() { - return fTabViewer; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#initializeBounds() - */ - protected void initializeBounds() { - super.initializeBounds(); - initializeSashForm(); - ensureSelectionAreaWidth(); - resize(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#create() - */ - public void create() { - super.create(); - // bug 27011 - if (getTabViewer().getInput() == null) { - getTabViewer().inputChanged(null); - } - } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setActiveTab(org.eclipse.debug.ui.ILaunchConfigurationTab) + /** + * Create and return a dialog that asks the user whether they want to discard + * unsaved changes. + * + * @return Return <code>true</code> if they chose to discard changes, + * <code>false</code> otherwise. */ - public void setActiveTab(ILaunchConfigurationTab tab) { - getTabViewer().setActiveTab(tab); + private boolean showDiscardChangesDialog() { + StringBuffer buffer = new StringBuffer(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___35, new String[]{getTabViewer().getWorkingCopy().getName()})); + buffer.append(getTabViewer().getErrorMesssage()); + buffer.append(LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_discard_changes_37); + MessageDialog dialog = new MessageDialog(getShell(), + LaunchConfigurationsMessages.LaunchConfigurationDialog_Discard_changes__38, + null, + buffer.toString(), + MessageDialog.QUESTION, + new String[] {LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32, LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33}, // + 1); + if (dialog.open() == IDialogConstants.OK_ID) { + return true; + } + return false; } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#setActiveTab(int) - */ - public void setActiveTab(int index) { - getTabViewer().setActiveTab(index); - } - /** - * Sets the status to open the dialog on. + * Create and return a dialog that asks the user whether they want to save + * unsaved changes. * - * @param status the intial status for the dialog + * @return Return <code>true </code> if they chose to save changes, + * <code>false</code> otherwise. */ - public void setInitialStatus(IStatus status) { - fInitialStatus = status; + private boolean showSaveChangesDialog() { + String message = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___29, new String[]{getTabViewer().getWorkingCopy().getName()}); + MessageDialog dialog = new MessageDialog(getShell(), + LaunchConfigurationsMessages.LaunchConfigurationDialog_Save_changes__31, + null, + message, + MessageDialog.QUESTION, + new String[] {LaunchConfigurationsMessages.LaunchConfigurationDialog_Yes_32, LaunchConfigurationsMessages.LaunchConfigurationDialog_No_33, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_34}, // + 0); + if (dialog.open() == IDialogConstants.OK_ID) { + // Turn off auto select if prompting to save changes. The user + // has made another selection and we don't want a 'rename' to + // cause an auto-select. + if (fLaunchConfigurationView != null) { + fLaunchConfigurationView.setAutoSelect(false); + } + getTabViewer().handleApplyPressed(); + if (fLaunchConfigurationView != null) { + fLaunchConfigurationView.setAutoSelect(true); + } + return true; + } + return false; } - + /** - * Returns the status the dialog was opened on or <code>null</code> if none. + * Show the user a dialog appropriate to whether the unsaved changes in the current config + * can be saved or not. Return <code>true</code> if the user indicated that they wish to replace + * the current config, either by saving changes or by discarding the, return <code>false</code> + * otherwise. * - * @return IStatus + * @return returns the <code>showSaveChangesDialog</code> return value */ - protected IStatus getInitialStatus() { - return fInitialStatus; + private boolean showUnsavedChangesDialog() { + if (getTabViewer().canSave()) { + return showSaveChangesDialog(); + } + return showDiscardChangesDialog(); } /** - * Consult a status handler for the given status, if any. The status handler - * is passed this launch config dialog as an argument. - * - * @param status the status to be handled + * A long running operation triggered through the dialog + * was stopped either by user input or by normal end. + * Hides the progress monitor and restores the enable state + * of the dialog's buttons and controls. + * + * @param savedState the saved UI state as returned by <code>aboutToStart</code> + * @see #aboutToStart */ - public void handleStatus(IStatus status) { - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); - if (handler != null) { - try { - handler.handleStatus(status, this); - return; - } catch (CoreException e) { - status = e.getStatus(); - } - } - // if no handler, or handler failed, display error/warning dialog - String title = null; - switch (status.getSeverity()) { - case IStatus.ERROR: - title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Error_1; - break; - case IStatus.WARNING: - title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Warning_2; - break; - default: - title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Information_3; - break; + private void stopped(Object savedState) { + if (getShell() != null) { + getProgressMonitorPart().getParent().setVisible(false); + getProgressMonitorPart().removeFromCancelComponent(getProgressMonitorCancelButton()); + Map state = (Map)savedState; + restoreUIState(state); + setDisplayCursor(null); + waitCursor.dispose(); + waitCursor = null; + arrowCursor.dispose(); + arrowCursor = null; + Control focusControl = (Control)state.get(FOCUS_CONTROL); + if (focusControl != null) { + focusControl.setFocus(); + } } - ErrorDialog.openError(getShell(), title, null, status); } - public Object getSelectedPage() { - return getActiveTab(); + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#updateButtons() + */ + public void updateButtons() { + // New, Delete, & Duplicate toolbar actions + fNewAction.setEnabled(getNewAction().isEnabled()); + fDeleteAction.setEnabled(getDeleteAction().isEnabled()); + fDuplicateAction.setEnabled(getDuplicateAction().isEnabled()); + + // Launch button + getTabViewer().refresh(); + getButton(ID_LAUNCH_BUTTON).setEnabled(getTabViewer().canLaunch()); } - public void addPageChangedListener(IPageChangedListener listener) { - changeListeners.add(listener); + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationDialog#updateMessage() + */ + public void updateMessage() { + setErrorMessage(getTabViewer().getErrorMesssage()); + setMessage(getTabViewer().getMessage()); } - public void removePageChangedListener(IPageChangedListener listener) { - changeListeners.remove(listener); + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + StructuredViewer viewer = (StructuredViewer)fLaunchConfigurationView.getViewer(); + if(event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED)) { + if(((Boolean)event.getNewValue()).booleanValue()) { + viewer.addFilter(fClosedProjectFilter); + } + else { + viewer.removeFilter(fClosedProjectFilter); + } + } + else if(event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED)) { + if(((Boolean)event.getNewValue()).booleanValue()) { + viewer.addFilter(fDeletedProjectFilter); + } + else { + viewer.removeFilter(fDeletedProjectFilter); + } + } + else if(event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES)) { + if(((Boolean)event.getNewValue()).booleanValue()) { + viewer.addFilter(fLCTFilter); + } + else { + viewer.removeFilter(fLCTFilter); + } + } + else if(event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST)) { + viewer.removeFilter(fLCTFilter); + viewer.addFilter(fLCTFilter); + } + refreshFilteringLabel(); + updateButtons(); + updateMessage(); } - /** - * Notifies any selection changed listeners that the selected page - * has changed. - * Only listeners registered at the time this method is called are notified. - * - * @param event a selection changed event - * - * @see IPageChangedListener#pageChanged - */ - protected void firePageChanged(final PageChangedEvent event) { - Object[] listeners = changeListeners.getListeners(); - for (int i = 0; i < listeners.length; ++i) { - final IPageChangedListener l = (IPageChangedListener) listeners[i]; - Platform.run(new SafeRunnable() { - public void run() { - l.pageChanged(event); - } - }); - } - } -} +}
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java index aa1198afd..17fc15f37 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java @@ -161,4 +161,20 @@ public class LaunchConfigurationsMessages extends NLS { public static String FavoritesDialog_8; + public static String LaunchConfigurationTabGroupViewer_7; + + public static String LaunchConfigurationsDialog_0; + + public static String LaunchConfigurationsDialog_1; + + public static String LaunchConfigurationsDialog_2; + + public static String LaunchConfigurationsDialog_3; + + public static String LaunchConfigurationsDialog_4; + + public static String LaunchConfigurationsDialog_5; + + public static String LaunchConfigurationsDialog_6; + }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties index a9efaf6c9..6309b2bef 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties @@ -51,6 +51,7 @@ LaunchConfigurationTabGroupViewer_3=\t- Edit or view an existing application by LaunchConfigurationTabGroupViewer_4=\t- Delete an existing application by selecting it and pressing 'Delete'. LaunchConfigurationTabGroupViewer_6=\t- Duplicate an existing application by selecting 'Duplicate' in the context menu. LaunchConfigurationTabGroupViewer_5=Configure launch perspective settings from the <a>Perspectives</a> preference page. +LaunchConfigurationTabGroupViewer_7=Configure launch configuration filtering settings on the <a>Launch Configurations</a> preference page. LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations LaunchConfigurationDialog_Dele_te_14=Dele&te LaunchConfigurationDialog_Discard_changes__38=Discard changes? @@ -81,6 +82,13 @@ LaunchConfigurationsDialog_Error_1=Error LaunchConfigurationsDialog_Warning_2=Warning LaunchConfigurationsDialog_Information_3=Information LaunchConfigurationsDialog_45=Perspective settings for {0} have unsaved changes. Do you wish to save them? +LaunchConfigurationsDialog_0=New launch configuration +LaunchConfigurationsDialog_1=Delete selected launch configuration(s) +LaunchConfigurationsDialog_2=&Filter +LaunchConfigurationsDialog_3=org.eclipse.debug.ui.LaunchConfigurationsPreferenecPage +LaunchConfigurationsDialog_4=Filter launch configurations... +LaunchConfigurationsDialog_5=Duplicates the currently selected launch configuration +LaunchConfigurationsDialog_6=Filter matched {0} of {1} items LaunchConfigurationManager_0=Remove Terminated Launches LaunchConfigurationPresentationManager_Launch_configuration_tab_group_extension__0__does_not_specify_launch_configuration_type_1=Launch configuration tab group extension {0} does not specify launch configuration type diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java index efa67415f..7e7e7f566 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchHistory.java @@ -77,7 +77,7 @@ public class LaunchHistory implements ILaunchListener, ILaunchConfigurationListe } /** - * Adds the givev configuration to this hisotry + * Adds the given configuration to this hisotry * * @param configuration * @param prepend whether the configuration should be added to the beginning of diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java index 613ceaf5f..0544e7c2a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java @@ -62,11 +62,33 @@ public class DebugPreferencesMessages extends NLS { public static String LaunchingPreferencePage_16; public static String LaunchingPreferencePage_17; public static String LaunchingPreferencePage_18; - public static String LaunchingPreferencePage_20; public static String LaunchingPreferencePage_21; public static String LaunchingPreferencePage_22; public static String LaunchingPreferencePage_23; - + public static String LaunchingPreferencePage_26; + public static String LaunchingPreferencePage_27; + public static String LaunchingPreferencePage_0; + public static String LaunchingPreferencePage_28; + public static String LaunchingPreferencePage_29; + public static String LaunchingPreferencePage_30; + public static String LaunchingPreferencePage_31; + public static String LaunchingPreferencePage_32; + public static String LaunchingPreferencePage_33; + public static String LaunchingPreferencePage_34; + public static String LaunchingPreferencePage_35; + public static String LaunchingPreferencePage_36; + + public static String PerspectivePreferencePage_0; + public static String PerspectivePreferencePage_1; + public static String PerspectivePreferencePage_2; + public static String PerspectivePreferencePage_3; + public static String PerspectivePreferencePage_4; + public static String PerspectivePreferencePage_5; + public static String PerspectivePreferencePage_6; + + public static String LaunchConfigurationsPreferencePage_1; + public static String LaunchConfigurationsPreferencePage_0; + public static String ProcessPropertyPage_Command_Line__1; public static String SimpleVariablePreferencePage_3; @@ -100,41 +122,12 @@ public class DebugPreferencesMessages extends NLS { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, DebugPreferencesMessages.class); } + + - public static String PerspectivePreferencePage_0; + - public static String PerspectivePreferencePage_1; - - public static String PerspectivePreferencePage_2; - public static String PerspectivePreferencePage_3; - - public static String PerspectivePreferencePage_4; - public static String PerspectivePreferencePage_5; - - public static String PerspectivePreferencePage_6; - - public static String LaunchingPreferencePage_26; - - public static String LaunchingPreferencePage_27; - - public static String LaunchingPreferencePage_0; - - public static String LaunchingPreferencePage_28; - - public static String LaunchingPreferencePage_29; - - public static String LaunchingPreferencePage_30; - - public static String LaunchingPreferencePage_31; - - public static String LaunchingPreferencePage_32; - - public static String LaunchingPreferencePage_33; - - public static String LaunchingPreferencePage_34; - - public static String LaunchingPreferencePage_35; }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties index 70eedc184..6d89baaee 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties @@ -58,7 +58,6 @@ LaunchingPreferencePage_15=Launch in debug mode when workspace contains breakpoi LaunchingPreferencePage_16=Alway&s LaunchingPreferencePage_17=Neve&r LaunchingPreferencePage_18=Promp&t -LaunchingPreferencePage_20=General Settings for Launching LaunchingPreferencePage_21=Continue launch if project contains errors LaunchingPreferencePage_22=Al&ways LaunchingPreferencePage_23=Pr&ompt @@ -69,9 +68,10 @@ LaunchingPreferencePage_29=No Candidates LaunchingPreferencePage_30=None of the available launch configurations require migration. LaunchingPreferencePage_31=Migrating launch configurations LaunchingPreferencePage_32=Launch Configuration Filtering -LaunchingPreferencePage_33=&Filter out configurations for unavailable projects. -LaunchingPreferencePage_34=Sho&w configurations for current project(s) only. +LaunchingPreferencePage_33=&Filter configurations for closed projects. +LaunchingPreferencePage_34=Filter configurations for dele&ted projects. LaunchingPreferencePage_35=Migration +LaunchingPreferencePage_36=General Options ProcessPropertyPage_Command_Line__1=Command Line: @@ -108,3 +108,5 @@ PerspectivePreferencePage_3={0}: PerspectivePreferencePage_4=None PerspectivePreferencePage_5=These settings assign perspectives to each application type and launch mode. Select "None" to indicate that a perspective should not be opened. PerspectivePreferencePage_6=Perspectives +LaunchConfigurationsPreferencePage_0=Filter out &specified launch configuration types. +LaunchConfigurationsPreferencePage_1=Launch Configurations diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java new file mode 100644 index 000000000..ce3d5e2b0 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationsPreferencePage.java @@ -0,0 +1,327 @@ +/******************************************************************************* + * Copyright (c) 2004, 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.debug.internal.ui.preferences; + +import java.util.ArrayList; +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.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IDebugHelpContextIds; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.SWTUtil; +import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupFilter; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.wizard.ProgressMonitorPart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ListSelectionDialog; +import org.eclipse.ui.model.AdaptableList; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchViewerSorter; + +/** + * Provides the Launch Configuraiton preference page to the Run/Debug preferences + * + * This page allows users to set filtering options as well as perform migration tasks. + * This class is not intended to be subclasssed + * @since 3.2 + */ +public class LaunchConfigurationsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + /** + * Content provider for the launch configuraiton type table + */ + class TableContentProvider implements IStructuredContentProvider { + + public Object[] getElements(Object inputElement) { + return getLaunchConfigurationTypes(); + } + + public void dispose() {} + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + } + + /** + * describes the debug launch group + */ + private static final String DEBUG_LAUNCH_GROUP = "org.eclipse.debug.ui.launchGroup.debug"; //$NON-NLS-1$ + + /** + * to monitor the proress of the migration process + */ + private ProgressMonitorPart fMonitor; + + /** + * the migrate now button + */ + private Button fMigrateNow; + + /** + * a list of the field editors + */ + private List fFieldEditors; + + /** + * The table for the launch configuration types + */ + private Table fTable; + + /** + * Constructor + */ + public LaunchConfigurationsPreferencePage() { + super(); + setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore()); + setTitle(DebugPreferencesMessages.LaunchConfigurationsPreferencePage_1); + } + + /** + * creates a composite to place tab controls on + * @param parent the parent to create to composite for + * @return a composite for settgin as a tabitem control + */ + private Composite createComposite(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + comp.setLayoutData(gd); + return comp; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + super.createControl(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_PREFERENCE_PAGE); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(Composite parent) { + fFieldEditors = new ArrayList(); + Composite comp = createComposite(parent); + //filtering options + Group group = createGroupComposite(comp, DebugPreferencesMessages.LaunchingPreferencePage_32); + Composite spacer = createComposite(group); + FieldEditor edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED, DebugPreferencesMessages.LaunchingPreferencePage_33, SWT.NONE, spacer); + fFieldEditors.add(edit); + edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED, DebugPreferencesMessages.LaunchingPreferencePage_34, SWT.NONE, spacer); + fFieldEditors.add(edit); + + //add table options + createTypeFiltering(group); + + //migration + group = createGroupComposite(comp, DebugPreferencesMessages.LaunchingPreferencePage_35); + Label label = new Label(group, SWT.LEFT | SWT.WRAP); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 350; + label.setLayoutData(gd); + label.setText(DebugPreferencesMessages.LaunchingPreferencePage_26); + fMigrateNow = SWTUtil.createPushButton(group, DebugPreferencesMessages.LaunchingPreferencePage_27, null); + gd = new GridData(SWT.BEGINNING); + gd.widthHint = 100; + fMigrateNow.setLayoutData(gd); + fMigrateNow.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) {} + public void widgetSelected(SelectionEvent e) { + handleMigrateNowSelected(); + } + }); + + //init field editors + initFieldEditors(); + fTable.setEnabled(getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES)); + return comp; + } + + /** + * @param parent the parent ot add this composite to + * @return the new composite with the type selction table in it + */ + private Composite createTypeFiltering(Composite parent) { + Composite comp = createComposite(parent); + BooleanFieldEditor2 editor = new BooleanFieldEditor2(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES, DebugPreferencesMessages.LaunchConfigurationsPreferencePage_0, SWT.NONE, comp); + editor.setPropertyChangeListener(new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if(((Boolean)event.getNewValue()).booleanValue()) { + fTable.setEnabled(true); + } + else { + fTable.setEnabled(false); + } + } + }); + fFieldEditors.add(editor); + fTable = new Table(comp, SWT.CHECK | SWT.BORDER); + fTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + CheckboxTableViewer tviewer = new CheckboxTableViewer(fTable); + tviewer.setLabelProvider(DebugUITools.newDebugModelPresentation()); + tviewer.setContentProvider(new TableContentProvider()); + tviewer.setSorter(new WorkbenchViewerSorter()); + tviewer.addFilter(new LaunchGroupFilter(DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(DEBUG_LAUNCH_GROUP))); + tviewer.setInput(getLaunchConfigurationTypes()); + return comp; + } + + /** + * Creates a standard grouping for this pref page + * @param parent the parent to add the group to + * @param title text the test for the group + * @return the new group + * @since 3.2 + */ + private Group createGroupComposite(Composite parent, String text) { + Group group = new Group(parent, SWT.NONE); + group.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalIndent = 0; + gd.verticalIndent = 0; + group.setLayoutData(gd); + group.setText(text); + return group; + } + + /** + * returns the launch configuration types + * @return the launch configuration types + */ + private ILaunchConfigurationType[] getLaunchConfigurationTypes() { + return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); + } + + /** + * handles the Migrate button being clicked + * + * @since 3.2 + */ + private void handleMigrateNowSelected() { + try { + ILaunchManager lmanager = DebugPlugin.getDefault().getLaunchManager(); + ILaunchConfiguration[] configurations = lmanager.getMigrationCandidates(); + if(configurations.length == 0) { + MessageDialog.openInformation(getShell(), DebugPreferencesMessages.LaunchingPreferencePage_29, DebugPreferencesMessages.LaunchingPreferencePage_30); + return; + } + ListSelectionDialog listd = new ListSelectionDialog(getShell(), new AdaptableList(configurations), + new WorkbenchContentProvider(), DebugUITools.newDebugModelPresentation(), + DebugPreferencesMessages.LaunchingPreferencePage_0); + listd.setTitle(DebugPreferencesMessages.LaunchingPreferencePage_28); + listd.setInitialSelections(configurations); + if(listd.open() == IDialogConstants.OK_ID) { + fMonitor = new ProgressMonitorPart(fMigrateNow.getParent(), new GridLayout()); + Object[] objs = listd.getResult(); + fMonitor.beginTask(DebugPreferencesMessages.LaunchingPreferencePage_31, objs.length); + for(int i = 0; i < objs.length; i++) { + if(objs[i] instanceof ILaunchConfiguration) { + ((ILaunchConfiguration)objs[i]).migrate(); + } + fMonitor.worked(i); + } + fMonitor.done(); + fMonitor.dispose(); + } + } + catch (CoreException e) {DebugUIPlugin.log(e);} + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) {} + + /** + * Initializes the field editors to their values + * @since 3.2 + */ + private void initFieldEditors() { + FieldEditor editor; + for(int i = 0; i < fFieldEditors.size(); i++) { + editor = (FieldEditor)fFieldEditors.get(i); + editor.setPreferenceStore(getPreferenceStore()); + editor.load(); + } + //restore the tables' checked state + String[] types = getPreferenceStore().getString(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST).split("\\,"); //$NON-NLS-1$ + TableItem[] items = fTable.getItems(); + ILaunchConfigurationType type; + for(int i = 0; i < types.length; i++) { + for(int j = 0; j < items.length; j++) { + type = (ILaunchConfigurationType)items[j].getData(); + if(type.getIdentifier().equals(types[i])) { + items[j].setChecked(true); + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + protected void performDefaults() { + for(int i = 0; i < fFieldEditors.size(); i++) { + ((FieldEditor)fFieldEditors.get(i)).loadDefault(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performOk() + */ + public boolean performOk() { + //save field editors + for(int i = 0; i < fFieldEditors.size(); i++) { + ((FieldEditor)fFieldEditors.get(i)).store(); + } + //save table + String types = ""; //$NON-NLS-1$ + TableItem[] items = fTable.getItems(); + ILaunchConfigurationType type; + for(int i = 0; i < items.length; i++) { + if(items[i].getChecked()) { + type = (ILaunchConfigurationType)items[i].getData(); + types += type.getIdentifier()+","; //$NON-NLS-1$ + } + } + getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST, types); + return super.performOk(); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java index d2418c831..a705275d1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java @@ -11,109 +11,131 @@ package org.eclipse.debug.internal.ui.preferences; import java.text.MessageFormat; +import java.util.ArrayList; +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.ILaunchManager; import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IDebugHelpContextIds; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.SWTUtil; -import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.wizard.ProgressMonitorPart; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.PlatformUI; /** * A preference page for configuring launching preferences. */ -public class LaunchingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { +public class LaunchingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + /** - * to monitor the proress of the migration process + * a list of the field editors + * @since 3.2 */ - private ProgressMonitorPart fMonitor; + private List fFieldEditors; /** * The default contsructor */ public LaunchingPreferencePage() { - super(GRID); - IPreferenceStore store= DebugUIPlugin.getDefault().getPreferenceStore(); - setPreferenceStore(store); - setDescription(DebugPreferencesMessages.LaunchingPreferencePage_20); + super(); + setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore()); } /* (non-Javadoc) - * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + super.createControl(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCHING_PREFERENCE_PAGE); + } + + /** + * creates a composite to place tab controls on + * @param parent the parent to create to composite for + * @return a composite for settgin as a tabitem control + * @since 3.2 */ - protected void createFieldEditors() { - Composite parent = getFieldEditorParent(); - addField(new BooleanFieldEditor(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_1, SWT.NONE, parent)); - addField(new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_2, 3, + private Composite createComposite(Composite parent) { + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + comp.setLayoutData(gd); + return comp; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) + */ + protected Control createContents(Composite parent) { + fFieldEditors = new ArrayList(); + Composite comp = createComposite(parent); + //save dirty editors + FieldEditor edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_2, 3, new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_3, MessageDialogWithToggle.ALWAYS}, {DebugPreferencesMessages.LaunchingPreferencePage_4, MessageDialogWithToggle.NEVER}, {DebugPreferencesMessages.LaunchingPreferencePage_5, MessageDialogWithToggle.PROMPT}}, - parent, - true)); - addField(new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_WAIT_FOR_BUILD, + comp, + true); + fFieldEditors.add(edit); + + //wait for build + edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_WAIT_FOR_BUILD, DebugPreferencesMessages.LaunchingPreferencePage_6, 3, new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_7, MessageDialogWithToggle.ALWAYS}, {DebugPreferencesMessages.LaunchingPreferencePage_8, MessageDialogWithToggle.NEVER}, {DebugPreferencesMessages.LaunchingPreferencePage_9, MessageDialogWithToggle.PROMPT}}, - parent, - true)); - createSpacer(parent, 2); - addField(new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, DebugPreferencesMessages.LaunchingPreferencePage_10, SWT.NONE, parent)); - addField(new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, + comp, + true); + fFieldEditors.add(edit); + + //relaunch in debug mode + edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, DebugPreferencesMessages.LaunchingPreferencePage_15, 3, new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_16, MessageDialogWithToggle.ALWAYS}, {DebugPreferencesMessages.LaunchingPreferencePage_17, MessageDialogWithToggle.NEVER}, {DebugPreferencesMessages.LaunchingPreferencePage_18, MessageDialogWithToggle.PROMPT}}, - parent, - true)); - addField(new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, + comp, + true); + fFieldEditors.add(edit); + + //continue with compile errors + edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, DebugPreferencesMessages.LaunchingPreferencePage_21, 2, new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_22, MessageDialogWithToggle.ALWAYS}, {DebugPreferencesMessages.LaunchingPreferencePage_23, MessageDialogWithToggle.PROMPT}}, - parent, - true)); - createLaunchHistoryEditor(parent); - createSpacer(parent, 2); - createMigrationEditor(parent); - createSpacer(parent, 1); - fMonitor = new ProgressMonitorPart(parent, new GridLayout()); - } - - /** - * Creates the launch history section of the page - */ - private void createLaunchHistoryEditor(Composite parent) { - final IntegerFieldEditor editor = new IntegerFieldEditor(IDebugUIConstants.PREF_MAX_HISTORY_SIZE, DebugPreferencesMessages.DebugPreferencePage_10, parent); + comp, + true); + fFieldEditors.add(edit); + + //filtering options + Group group = createGroupComposite(comp, DebugPreferencesMessages.LaunchingPreferencePage_36); + Composite spacer = createComposite(group); + edit = new BooleanFieldEditor(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_1, SWT.NONE, spacer); + edit.fillIntoGrid(spacer, 2); + fFieldEditors.add(edit); + edit = new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, DebugPreferencesMessages.LaunchingPreferencePage_10, SWT.NONE, spacer); + edit.fillIntoGrid(spacer, 2); + fFieldEditors.add(edit); + + //history list size pref + final IntegerFieldEditor editor = new IntegerFieldEditor(IDebugUIConstants.PREF_MAX_HISTORY_SIZE, DebugPreferencesMessages.DebugPreferencePage_10, spacer); + editor.fillIntoGrid(spacer, 2); + fFieldEditors.add(editor); int historyMax = IDebugPreferenceConstants.MAX_LAUNCH_HISTORY_SIZE; editor.setTextLimit(Integer.toString(historyMax).length()); editor.setErrorMessage(MessageFormat.format(DebugPreferencesMessages.DebugPreferencePage_11, new Object[] { new Integer(1), new Integer(historyMax)})); @@ -125,88 +147,62 @@ public class LaunchingPreferencePage extends FieldEditorPreferencePage implement setValid(editor.isValid()); } }); - addField(editor); + + //init the field editors + initFieldEditors(); + return comp; } - + /** - * Create the section that handles migration - * + * Creates a standard grouping for this pref page + * @param parent the parent to add the group to + * @param title text the test for the group + * @return the new group * @since 3.2 */ - private void createMigrationEditor(Composite parent) { + private Group createGroupComposite(Composite parent, String text) { Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout(1, true)); + group.setLayout(new GridLayout()); GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; group.setLayoutData(gd); - group.setText(DebugPreferencesMessages.LaunchingPreferencePage_35); - Label label = new Label(group, SWT.LEFT | SWT.WRAP); - gd.widthHint = 450; - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.verticalIndent = 4; - label.setLayoutData(gd); - label.setText(DebugPreferencesMessages.LaunchingPreferencePage_26); - Button migratenow = SWTUtil.createPushButton(group, DebugPreferencesMessages.LaunchingPreferencePage_27, null); - gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.widthHint = 100; - gd.verticalIndent = 4; - migratenow.setLayoutData(gd); - migratenow.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) {} - public void widgetSelected(SelectionEvent e) { - handleMigrateNowSelected(); - } - }); + group.setText(text); + return group; } - /** - * Creates a horozontal spacer in a composite which is as wide as the specified column span - * @param composite the parent to add the spacer to - * @param columnSpan the number of columns to add the spacer to. + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ - protected void createSpacer(Composite composite, int columnSpan) { - Label label = new Label(composite, SWT.NONE); - GridData gd = new GridData(); - gd.horizontalSpan = columnSpan; - label.setLayoutData(gd); - } - + public void init(IWorkbench workbench) {} /** - * handles the Migrate button being clicked - * + * Initializes the field editors to their values * @since 3.2 */ - private void handleMigrateNowSelected() { - try { - ILaunchManager lmanager = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfiguration[] configurations = lmanager.getMigrationCandidates(); - if(configurations.length == 0) { - MessageDialog.openInformation(getShell(), DebugPreferencesMessages.LaunchingPreferencePage_29, DebugPreferencesMessages.LaunchingPreferencePage_30); - return; - } - ListSelectionDialog listd = new ListSelectionDialog(getShell(), new AdaptableList(configurations), - new WorkbenchContentProvider(), DebugUITools.newDebugModelPresentation(), - DebugPreferencesMessages.LaunchingPreferencePage_0); - listd.setTitle(DebugPreferencesMessages.LaunchingPreferencePage_28); - listd.setInitialSelections(configurations); - if(listd.open() == IDialogConstants.OK_ID) { - Object[] objs = listd.getResult(); - fMonitor.beginTask(DebugPreferencesMessages.LaunchingPreferencePage_31, objs.length); - for(int i = 0; i < objs.length; i++) { - if(objs[i] instanceof ILaunchConfiguration) { - ((ILaunchConfiguration)objs[i]).migrate(); - } - fMonitor.worked(i); - } - fMonitor.done(); - } + private void initFieldEditors() { + FieldEditor editor; + for(int i = 0; i < fFieldEditors.size(); i++) { + editor = (FieldEditor)fFieldEditors.get(i); + editor.setPreferenceStore(getPreferenceStore()); + editor.load(); } - catch (CoreException e) {DebugUIPlugin.log(e);} } - + /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() */ - public void init(IWorkbench workbench) {} + protected void performDefaults() { + for(int i = 0; i < fFieldEditors.size(); i++) { + ((FieldEditor)fFieldEditors.get(i)).loadDefault(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performOk() + */ + public boolean performOk() { + for(int i = 0; i < fFieldEditors.size(); i++) { + ((FieldEditor)fFieldEditors.get(i)).store(); + } + return super.performOk(); + } } |