Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54503 Details for
Bug 74480
[launching] Simplify the launch experience for less technical users of Eclipse
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch
def-launch-2.patch (text/plain), 41.76 KB, created by
Darin Wright
on 2006-11-24 16:55:54 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2006-11-24 16:55:54 EST
Size:
41.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.debug.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/plugin.xml,v >retrieving revision 1.381 >diff -u -r1.381 plugin.xml >--- plugin.xml 17 Nov 2006 21:21:20 -0000 1.381 >+++ plugin.xml 24 Nov 2006 21:47:16 -0000 >@@ -1452,6 +1452,13 @@ > </or> > </enabledWhen> > </page> >+ <page >+ adaptable="true" >+ class="org.eclipse.debug.internal.ui.launchConfigurations.properties.ExecutionPropertiesPage" >+ id="org.eclipse.debug.ui.properties.execution" >+ name="Execution" >+ objectClass="org.eclipse.core.resources.IResource"> >+ </page> > </extension> > <!-- commands and their bindings > NOTE: >Index: ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java,v >retrieving revision 1.59 >diff -u -r1.59 IDebugHelpContextIds.java >--- ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java 26 Oct 2006 20:12:40 -0000 1.59 >+++ ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java 24 Nov 2006 21:47:16 -0000 >@@ -105,6 +105,7 @@ > // Property pages > public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$ > public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$ >+ public static final String EXECUTION_PROPERTY_PAGE = PREFIX + "execution_property_page"; //$NON-NLS-1$ > > // Launch configuration dialog pages > public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$ >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/CategoryFilter.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/CategoryFilter.java >diff -N ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/CategoryFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/CategoryFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 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.properties; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+ >+/** >+ * Filters configurations in non-default launch categories. >+ * >+ * @since 3.3 >+ */ >+public class CategoryFilter extends ViewerFilter { >+ >+ /* (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) { >+ try { >+ return ((ILaunchConfiguration)element).getType().getCategory() == null; >+ } catch (CoreException e) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationComparator.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationComparator.java >diff -N ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationComparator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationComparator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/******************************************************************************* >+ * Copyright (c) 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.properties; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+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.ui.model.WorkbenchViewerComparator; >+ >+/** >+ * Groups configurations by type. >+ * >+ * @since 3.3 >+ */ >+public class LaunchConfigurationComparator extends WorkbenchViewerComparator { >+ >+ private static Map categories; >+ >+ public int category(Object element) { >+ Map map = getCategories(); >+ if (element instanceof ILaunchConfiguration) { >+ ILaunchConfiguration configuration = (ILaunchConfiguration) element; >+ try { >+ Integer i = (Integer) map.get(configuration.getType()); >+ if (i != null) { >+ return i.intValue(); >+ } >+ } catch (CoreException e) { >+ } >+ } >+ return map.size(); >+ } >+ >+ private Map getCategories() { >+ if (categories == null) { >+ categories = new HashMap(); >+ ILaunchConfigurationType[] lcts = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); >+ List types = new ArrayList(lcts.length); >+ for (int i = 0; i < lcts.length; i++) { >+ types.add(lcts[i]); >+ } >+ Collections.sort(types, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1; >+ ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2; >+ return t1.getName().compareTo(t2.getName()); >+ } >+ >+ }); >+ Iterator iterator = types.iterator(); >+ int i = 0; >+ while (iterator.hasNext()) { >+ categories.put(iterator.next(), new Integer(i)); >+ i++; >+ } >+ } >+ return categories; >+ } >+ >+ >+} >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java >diff -N ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,449 @@ >+/******************************************************************************* >+ * Copyright (c) 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.properties; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; >+import org.eclipse.debug.core.ILaunchManager; >+import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.DefaultLabelProvider; >+import org.eclipse.debug.internal.ui.IDebugHelpContextIds; >+import org.eclipse.debug.internal.ui.SWTUtil; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.ILaunchGroup; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.CheckStateChangedEvent; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.ICheckStateListener; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.window.Window; >+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.Table; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.ListDialog; >+import org.eclipse.ui.dialogs.PropertyPage; >+ >+import com.ibm.icu.text.MessageFormat; >+ >+/** >+ * Displays execution settings for a resource - associated launch configurations. >+ * >+ * @since 3.3 >+ */ >+public class ExecutionPropertiesPage extends PropertyPage implements ICheckStateListener, ISelectionChangedListener, SelectionListener { >+ >+ private CheckboxTableViewer viewer; >+ private Button newButton; >+ private Button copyButton; >+ private Button editButton; >+ private Button deleteButton; >+ >+ /** >+ * List of configurations to be deleted >+ */ >+ private List deletedConfigurations = new ArrayList(); >+ >+ /** >+ * List of original default candidates for the resource >+ */ >+ private List originalCandidates; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createContents(Composite parent) { >+ // TODO: add help to documentation >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.EXECUTION_PROPERTY_PAGE); >+ >+ Composite composite = new Composite(parent, SWT.NONE); >+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ GridLayout layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ composite.setLayout(layout); >+ >+ SWTUtil.createLabel(composite, MessageFormat.format("&Select default launch settings for {0}:", new String[]{getResource().getName()}), 2); >+ >+ Composite tableAndButtons = new Composite(composite, SWT.NONE); >+ tableAndButtons.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ layout.numColumns = 2; >+ tableAndButtons.setLayout(layout); >+ >+ viewer= CheckboxTableViewer.newCheckList(tableAndButtons, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); >+ viewer.setLabelProvider(new DefaultLabelProvider()); >+ viewer.setContentProvider(new ArrayContentProvider()); >+ viewer.setComparator(new LaunchConfigurationComparator()); >+ viewer.addCheckStateListener(this); >+ // Only filter private configurations and external tools to avoid filtering a default >+ viewer.addFilter(new PrivateConfigurationFilter()); >+ viewer.addFilter(new CategoryFilter()); >+ Table builderTable= viewer.getTable(); >+ GridData gridData = new GridData(GridData.FILL_BOTH); >+ gridData.heightHint = 300; >+ builderTable.setLayoutData(gridData); >+ >+ IResource resource = getResource(); >+ originalCandidates = getDefaultCandidates(resource); >+ viewer.setInput(originalCandidates); >+ try { >+ ILaunchConfiguration configuration = DebugPlugin.getDefault().getLaunchManager().getDefaultConfiguration(resource); >+ if (configuration != null) { >+ Iterator iterator = originalCandidates.iterator(); >+ while (iterator.hasNext()) { >+ ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next(); >+ if (configuration.equals(wc.getOriginal())) { >+ viewer.setChecked(wc, true); >+ break; >+ } >+ } >+ } >+ } catch (CoreException e) { >+ setErrorMessage(e.getMessage()); >+ } >+ >+ Composite buttonArea = new Composite(tableAndButtons, SWT.NONE); >+ layout = new GridLayout(); >+ layout.marginHeight = 0; >+ layout.marginWidth = 0; >+ buttonArea.setLayout(layout); >+ buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL)); >+ newButton = SWTUtil.createPushButton(buttonArea, "New...", null); >+ newButton.addSelectionListener(this); >+ copyButton = SWTUtil.createPushButton(buttonArea, "Copy...", null); >+ copyButton.addSelectionListener(this); >+ editButton = SWTUtil.createPushButton(buttonArea, "Edit...", null); >+ editButton.addSelectionListener(this); >+ deleteButton = SWTUtil.createPushButton(buttonArea, "Delete", null); >+ deleteButton.addSelectionListener(this); >+ >+ viewer.addSelectionChangedListener(this); >+ applyDialogFont(composite); >+ updateButtons(new StructuredSelection()); >+ return composite; >+ } >+ >+ /** >+ * Returns the resource this property page is open on. >+ * >+ * @return resource >+ */ >+ protected IResource getResource() { >+ Object element = getElement(); >+ IResource resource = null; >+ if (element instanceof IResource) { >+ resource = (IResource) element; >+ } else if (element instanceof IAdaptable) { >+ resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class); >+ } >+ return resource; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) >+ */ >+ public void checkStateChanged(CheckStateChangedEvent event) { >+ ILaunchConfiguration configuration = (ILaunchConfiguration) event.getElement(); >+ // only allow one check >+ viewer.setCheckedElements(new Object[]{configuration}); >+ // validate >+ if (!configuration.isLocal()) { >+ if (!getResource().getProject().equals(configuration.getFile().getProject())) { >+ // a config must be stored in the same project that it is a default config for >+ setErrorMessage(MessageFormat.format("Configuration must be located in project {0}", new String[]{getResource().getProject().getName()})); >+ setValid(false); >+ return; >+ } >+ } >+ setErrorMessage(null); >+ setValid(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performOk() >+ */ >+ public boolean performOk() { >+ Object[] checked = viewer.getCheckedElements(); >+ try { >+ ILaunchConfiguration def = null; >+ if (checked.length == 1) { >+ def = (ILaunchConfiguration) checked[0]; >+ } >+ DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def); >+ } catch (CoreException e) { >+ setErrorMessage(e.getMessage()); >+ return false; >+ } >+ return super.performOk(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults() >+ */ >+ protected void performDefaults() { >+ viewer.setAllChecked(false); >+ setErrorMessage(null); >+ setValid(true); >+ super.performDefaults(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) >+ */ >+ public void selectionChanged(SelectionChangedEvent event) { >+ ISelection s = event.getSelection(); >+ if (s instanceof IStructuredSelection) { >+ updateButtons((IStructuredSelection) s); >+ } >+ >+ } >+ >+ /** >+ * Update buttons based on the given selection. >+ * >+ * @param selection >+ */ >+ private void updateButtons(IStructuredSelection selection) { >+ if (selection.size() == 0) { >+ editButton.setEnabled(false); >+ copyButton.setEnabled(false); >+ deleteButton.setEnabled(false); >+ } else if (selection.size() == 1) { >+ editButton.setEnabled(true); >+ copyButton.setEnabled(true); >+ deleteButton.setEnabled(true); >+ } else { >+ editButton.setEnabled(false); >+ copyButton.setEnabled(false); >+ deleteButton.setEnabled(true); >+ } >+ } >+ >+ /** >+ * Returns a list of potential default configurations candidates for the given >+ * resource. The configurations are working copies. >+ * >+ * @param resource resource >+ * @return list of default candidates >+ */ >+ private List getDefaultCandidates(IResource resource) { >+ IPath resourcePath = resource.getFullPath(); >+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); >+ List list = new ArrayList(); >+ try { >+ ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(); >+ for (int i = 0; i < configurations.length; i++) { >+ ILaunchConfiguration configuration = configurations[i]; >+ IResource[] resources = configuration.getMappedResources(); >+ if (resources != null) { >+ for (int j = 0; j < resources.length; j++) { >+ IResource mappedResource = resources[j]; >+ if (resource.equals(mappedResource) || >+ resourcePath.isPrefixOf(mappedResource.getFullPath())) { >+ list.add(configuration.getWorkingCopy()); >+ break; >+ } >+ } >+ } else { >+ // 1. similar to launch dialog - if no resource mapping, display the config >+ // 2. only consider the default launch category (applications, *not* external tools) >+ if (configuration.getType().getCategory() == null) { >+ list.add(configuration.getWorkingCopy()); >+ } >+ } >+ } >+ } catch (CoreException e) { >+ list.clear(); >+ DebugUIPlugin.log(e); >+ } >+ return list; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ if (e.widget == newButton) { >+ handleNew(); >+ } else if (e.widget == copyButton) { >+ handleCopy(); >+ } else if (e.widget == deleteButton) { >+ handleDelete(); >+ } else if (e.widget == editButton) { >+ handleEdit(); >+ } >+ } >+ >+ /** >+ * Returns selected configurations. >+ * >+ * @return selected configurations >+ */ >+ private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() { >+ Object[] array = ((IStructuredSelection)viewer.getSelection()).toArray(); >+ ILaunchConfigurationWorkingCopy[] lcs = new ILaunchConfigurationWorkingCopy[array.length]; >+ System.arraycopy(array, 0, lcs, 0, array.length); >+ return lcs; >+ } >+ >+ /** >+ * Copy the selection >+ */ >+ private void handleCopy() { >+ ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0]; >+ try { >+ ILaunchConfigurationWorkingCopy copy = configuration.copy( >+ DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configuration.getName())); >+ copy.setAttributes(configuration.getAttributes()); >+ int code = edit(copy); >+ if (code == Window.OK) { >+ originalCandidates.add(copy); >+ viewer.refresh(); >+ viewer.setSelection(new StructuredSelection(copy)); >+ } >+ } catch (CoreException e) { >+ setErrorMessage(e.getMessage()); >+ } >+ } >+ >+ /** >+ * Delete the selection >+ */ >+ private void handleDelete() { >+ Table table = viewer.getTable(); >+ int[] indices = table.getSelectionIndices(); >+ Arrays.sort(indices); >+ ILaunchConfiguration[] configurations = getSelectedConfigurations(); >+ for (int i = 0; i < configurations.length; i++) { >+ deletedConfigurations.add(configurations[i]); >+ originalCandidates.remove(configurations[i]); >+ } >+ viewer.refresh(); >+ if (indices[0] < table.getItemCount()) { >+ viewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData())); >+ } else if (table.getItemCount() > 0) { >+ viewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData())); >+ } >+ } >+ >+ /** >+ * Edit the selection >+ */ >+ private void handleEdit() { >+ edit(getSelectedConfigurations()[0]); >+ viewer.refresh(); >+ } >+ >+ /** >+ * Edits the given configuration as a nested working copy. >+ * Returns the code from the dialog used to edit the configuration. >+ * >+ * @param configuration >+ * @return dialog return code - OK or CANCEL >+ */ >+ private int edit(ILaunchConfigurationWorkingCopy configuration) { >+ try { >+ ILaunchConfigurationWorkingCopy copy = configuration.getNestedWorkingCopy(); >+ ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE); >+ if (group == null) { >+ group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.DEBUG_MODE); >+ } >+ int code = DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(), copy, group.getIdentifier()); >+ if (code == Window.OK) { >+ copy.doSave(); >+ } >+ return code; >+ } catch (CoreException e) { >+ setErrorMessage(e.getMessage()); >+ } >+ return Window.CANCEL; >+ } >+ >+ /** >+ * Create a new configuration >+ */ >+ private void handleNew() { >+ ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes(); >+ List avail = new ArrayList(types.length); >+ for (int i = 0; i < types.length; i++) { >+ ILaunchConfigurationType type = types[i]; >+ if (type.getCategory() == null) { >+ // TODO: external tools? >+ avail.add(type); >+ } >+ } >+ Collections.sort(avail, new Comparator() { >+ public int compare(Object o1, Object o2) { >+ ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1; >+ ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2; >+ return t1.getName().compareTo(t2.getName()); >+ } >+ >+ }); >+ ListDialog dialog = new ListDialog(getShell()); >+ dialog.setTitle("Selection Configuration Type"); >+ dialog.setContentProvider(new ArrayContentProvider()); >+ dialog.setLabelProvider(new DefaultLabelProvider()); >+ dialog.setAddCancelButton(true); >+ dialog.setMessage("&Select the kind of configuration to create:"); >+ dialog.setInput(avail); >+ if (dialog.open() == Window.OK) { >+ Object[] result = dialog.getResult(); >+ if (result.length == 1) { >+ ILaunchConfigurationType type = (ILaunchConfigurationType) result[0]; >+ try { >+ ILaunchConfigurationWorkingCopy wc = type.newInstance(null, DebugPlugin.getDefault().getLaunchManager(). >+ generateUniqueLaunchConfigurationNameFrom("New Configuration")); >+ if (edit(wc) == Window.OK) { >+ originalCandidates.add(wc); >+ viewer.refresh(); >+ viewer.setSelection(new StructuredSelection(wc)); >+ } >+ } catch (CoreException e) { >+ setErrorMessage(e.getMessage()); >+ } >+ } >+ } >+ } >+ >+} >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/PrivateConfigurationFilter.java >=================================================================== >RCS file: ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/PrivateConfigurationFilter.java >diff -N ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/PrivateConfigurationFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/PrivateConfigurationFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 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.properties; >+ >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+ >+/** >+ * Filters private configurations. >+ * >+ * @since 3.3 >+ */ >+public class PrivateConfigurationFilter extends ViewerFilter { >+ >+ /* (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 !DebugUITools.isPrivate((ILaunchConfiguration) element); >+ } >+ return true; >+ } >+ >+} >#P org.eclipse.debug.core >Index: core/org/eclipse/debug/internal/core/LaunchManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java,v >retrieving revision 1.175 >diff -u -r1.175 LaunchManager.java >--- core/org/eclipse/debug/internal/core/LaunchManager.java 14 Nov 2006 20:07:24 -0000 1.175 >+++ core/org/eclipse/debug/internal/core/LaunchManager.java 24 Nov 2006 21:47:19 -0000 >@@ -57,6 +57,7 @@ > import org.eclipse.core.resources.IResourceDeltaVisitor; > import org.eclipse.core.resources.IResourceProxy; > import org.eclipse.core.resources.IResourceProxyVisitor; >+import org.eclipse.core.resources.ProjectScope; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; >@@ -65,11 +66,13 @@ > import org.eclipse.core.runtime.ISafeRunnable; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.PlatformObject; > import org.eclipse.core.runtime.Preferences; > import org.eclipse.core.runtime.SafeRunner; > import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.core.DebugPlugin; >@@ -77,6 +80,7 @@ > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.core.ILaunchConfigurationListener; > import org.eclipse.debug.core.ILaunchConfigurationType; >+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; > import org.eclipse.debug.core.ILaunchDelegate; > import org.eclipse.debug.core.ILaunchListener; > import org.eclipse.debug.core.ILaunchManager; >@@ -94,6 +98,7 @@ > import org.eclipse.debug.internal.core.sourcelookup.SourceContainerType; > import org.eclipse.debug.internal.core.sourcelookup.SourcePathComputer; > import org.eclipse.osgi.service.environment.Constants; >+import org.osgi.service.prefs.BackingStoreException; > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.Node; >@@ -116,6 +121,10 @@ > > > /** >+ * >+ */ >+ private static final String DEFAULT_CONFIGURATION = "defaultConfiguration"; >+ /** > * Constants for xml node names > * > * @since 3.3 >@@ -2312,5 +2321,101 @@ > } > } > return title; >- } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchManager#getDefaultConfiguration(org.eclipse.core.resources.IResource) >+ */ >+ public ILaunchConfiguration getDefaultConfiguration(IResource resource) throws CoreException { >+ IProject project = resource.getProject(); >+ if (project != null) { >+ org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource); >+ String configValue = projectNode.get(DEFAULT_CONFIGURATION, null); >+ if (configValue != null) { >+ // shared config >+ IFile file = project.getFile(Path.fromPortableString(configValue)); >+ return getLaunchConfiguration(file); >+ } else { >+ org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource); >+ configValue = instanceNode.get(DEFAULT_CONFIGURATION, null); >+ if (configValue != null) { >+ // local config >+ return getLaunchConfiguration(configValue); >+ } >+ } >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchManager#setDefaultConfiguration(org.eclipse.core.resources.IResource, org.eclipse.debug.core.ILaunchConfiguration) >+ */ >+ public void setDefaultConfiguration(IResource resource, ILaunchConfiguration configuration) throws CoreException { >+ IProject project = resource.getProject(); >+ if (project == null) { >+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), >+ DebugPlugin.INTERNAL_ERROR, "Illegal argument: can only set default launch configuration on and within projects.", null)); >+ } >+ if (configuration != null && !configuration.isLocal()) { >+ if (!configuration.getFile().getProject().equals(project)) { >+ throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), >+ DebugPlugin.INTERNAL_ERROR, "A shared launch configuration must be shared in same project that it is a default configuration for.", null)); >+ } >+ } >+ >+ // remove previous settings, if any >+ org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource); >+ projectNode.remove(DEFAULT_CONFIGURATION); >+ flush(projectNode); >+ org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource); >+ instanceNode.remove(DEFAULT_CONFIGURATION); >+ flush(instanceNode); >+ >+ if (configuration != null) { >+ org.osgi.service.prefs.Preferences node = null; >+ String configurationValue = null; >+ if (configuration.isLocal()) { >+ // for local configurations, use workspace (instance) scope preferences >+ node = instanceNode; >+ if (configuration.isWorkingCopy()) { >+ configurationValue = ((ILaunchConfigurationWorkingCopy)configuration).getOriginal().getMemento(); >+ } else { >+ configurationValue = configuration.getMemento(); >+ } >+ } else { >+ // for shared configurations, use project scope preferences >+ node = projectNode; >+ configurationValue = configuration.getFile().getProjectRelativePath().toPortableString(); >+ } >+ node.put(DEFAULT_CONFIGURATION, configurationValue); >+ flush(node); >+ } >+ >+ } >+ >+ private void flush(org.osgi.service.prefs.Preferences node) { >+ try { >+ node.flush(); >+ } catch (BackingStoreException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ >+ private org.osgi.service.prefs.Preferences getProjectNode(IResource resource) { >+ org.osgi.service.prefs.Preferences node = Platform.getPreferencesService().getRootNode(); >+ ProjectScope scope = new ProjectScope(resource.getProject()); >+ node = scope.getNode(DebugPlugin.getUniqueIdentifier()); >+ IProject project = resource.getProject(); >+ if (!resource.equals(project)) { >+ node = node.node(resource.getProjectRelativePath().toString()); >+ } >+ return node; >+ } >+ >+ private org.osgi.service.prefs.Preferences getInstanceNode(IResource resource) { >+ org.osgi.service.prefs.Preferences node = Platform.getPreferencesService().getRootNode(); >+ node = node.node(InstanceScope.SCOPE).node(DebugPlugin.getUniqueIdentifier()); >+ return node.node(resource.getFullPath().makeRelative().toString()); >+ } > } >Index: core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java,v >retrieving revision 1.63 >diff -u -r1.63 LaunchConfigurationWorkingCopy.java >--- core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java 23 Oct 2006 13:53:16 -0000 1.63 >+++ core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java 24 Nov 2006 21:47:18 -0000 >@@ -86,6 +86,12 @@ > private IContainer fContainer; > > /** >+ * Parent working copy. >+ * @since 3.3 >+ */ >+ private LaunchConfigurationWorkingCopy fParent = null; >+ >+ /** > * Constructs a working copy of the specified launch > * configuration. > * >@@ -103,6 +109,23 @@ > } > > /** >+ * Constructs a working copy of the specified launch configuration as its parent. >+ * >+ * @param parent launch configuration to make >+ * a working copy of >+ * @exception CoreException if unable to initialize this >+ * working copy's attributes based on the original configuration >+ */ >+ protected LaunchConfigurationWorkingCopy(LaunchConfigurationWorkingCopy parent) throws CoreException { >+ super(parent.getLocation()); >+ setName(parent.getName()); >+ copyFrom(parent); >+ setOriginal((LaunchConfiguration) parent.getOriginal()); >+ fParent = parent; >+ fSuppressChange = false; >+ } >+ >+ /** > * Constructs a copy of the specified launch > * configuration, with the given (new) name. > * >@@ -149,35 +172,42 @@ > * @see ILaunchConfigurationWorkingCopy#doSave() > */ > public synchronized ILaunchConfiguration doSave() throws CoreException { >- if (isDirty()) { >- boolean useRunnable= true; >- if (isLocal()) { >- if (isMoved()) { >- // If this config was moved from a shared location, saving >- // it will delete the original from the workspace. Use runnable. >- useRunnable= !isNew() && !getOriginal().isLocal(); >+ if (fParent == null) { >+ if (isDirty()) { >+ boolean useRunnable= true; >+ if (isLocal()) { >+ if (isMoved()) { >+ // If this config was moved from a shared location, saving >+ // it will delete the original from the workspace. Use runnable. >+ useRunnable= !isNew() && !getOriginal().isLocal(); >+ } else { >+ useRunnable= false; >+ } >+ } >+ >+ if (useRunnable) { >+ IWorkspaceRunnable wr = new IWorkspaceRunnable() { >+ public void run(IProgressMonitor pm) throws CoreException { >+ doSave0(); >+ } >+ }; >+ >+ ResourcesPlugin.getWorkspace().run(wr, null, 0, null); > } else { >- useRunnable= false; >+ //file is persisted in the metadata not the workspace >+ doSave0(); > } >+ >+ getLaunchManager().setMovedFromTo(null, null); > } >- >- if (useRunnable) { >- IWorkspaceRunnable wr = new IWorkspaceRunnable() { >- public void run(IProgressMonitor pm) throws CoreException { >- doSave0(); >- } >- }; >- >- ResourcesPlugin.getWorkspace().run(wr, null, 0, null); >- } else { >- //file is persisted in the metadata not the workspace >- doSave0(); >- } >- >- getLaunchManager().setMovedFromTo(null, null); >+ >+ return new LaunchConfiguration(getLocation()); >+ } else { >+ // save to parent working copy >+ fParent.setName(getName()); >+ fParent.copyFrom(this); >+ return fParent; > } >- >- return new LaunchConfiguration(getLocation()); > } > > >@@ -610,6 +640,32 @@ > setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS, paths); > setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.internal.core.LaunchConfiguration#getWorkingCopy() >+ */ >+ public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException { >+ if (fParent == null) { >+ return super.getWorkingCopy(); >+ } else { >+ return getNestedWorkingCopy(); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getNestedWorkingCopy() >+ */ >+ public ILaunchConfigurationWorkingCopy getNestedWorkingCopy() throws CoreException { >+ return new LaunchConfigurationWorkingCopy(this); >+ } > >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getParent() >+ */ >+ public ILaunchConfigurationWorkingCopy getParent() { >+ return fParent; >+ } >+ >+ > } > >Index: core/org/eclipse/debug/core/ILaunchManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchManager.java,v >retrieving revision 1.62 >diff -u -r1.62 ILaunchManager.java >--- core/org/eclipse/debug/core/ILaunchManager.java 19 Oct 2006 21:37:53 -0000 1.62 >+++ core/org/eclipse/debug/core/ILaunchManager.java 24 Nov 2006 21:47:18 -0000 >@@ -14,6 +14,7 @@ > import java.util.Map; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.debug.core.model.IDebugTarget; > import org.eclipse.debug.core.model.IPersistableSourceLocator; >@@ -459,6 +460,42 @@ > */ > public void removeLaunchListener(ILaunchListener listener); > >+ /** >+ * Sets the given launch configuration as the default configuration for the specified >+ * resource. There is only one default configuration per resource and this replaces >+ * any previously existing launch configuration for the resource, if any. Specifying >+ * a configuration of <code>null</code> clears the default configuration for the >+ * given resource. >+ * >+ * @param resource resource >+ * @param configuration launch configuration or <code>null</code> >+ * @exception CoreException if unable to set as default >+ * @since 3.3 >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This method has been added as >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.3 release cycle. Please do not use this API >+ * without consulting with the Platform/Debug team. >+ * </p> >+ */ >+ public void setDefaultConfiguration(IResource resource, ILaunchConfiguration configuration) throws CoreException; >+ >+ /** >+ * Returns the default launch configuration for the specified resource, or <code>null</code> >+ * if none. >+ * >+ * @param configuration launch configuration >+ * @return launch configuration or <code>null</code> >+ * @exception CoreException if an error occurs retrieving the configuration >+ * @since 3.3 >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This method has been added as >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.3 release cycle. Please do not use this API >+ * without consulting with the Platform/Debug team. >+ * </p> >+ */ >+ public ILaunchConfiguration getDefaultConfiguration(IResource resource) throws CoreException; > } > > >Index: core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.core/core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java,v >retrieving revision 1.21 >diff -u -r1.21 ILaunchConfigurationWorkingCopy.java >--- core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java 23 Oct 2006 13:53:16 -0000 1.21 >+++ core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java 24 Nov 2006 21:47:18 -0000 >@@ -50,7 +50,12 @@ > * a handle to the resulting launch configuration. > * Has no effect if this configuration does not need saving. > * Creates the underlying file if not yet created. >- * >+ * <p> >+ * <strong>EXPERIMENTAL</strong> - Since 3.3, if this is a nested >+ * working copy, the contents of this working copy are saved to the >+ * parent working copy and the parent working copy is returned without >+ * effecting the original launch configuration. >+ * </p> > * @exception CoreException if an exception occurs while > * writing this configuration to its underlying file. > */ >@@ -231,4 +236,43 @@ > * @since 3.3 > */ > public void removeModes(Set modes); >+ >+ /** >+ * Returns a working copy of this working copy. Changes to the working copy will >+ * be applied to this working copy when saved. The working copy will >+ * refer to this launch configuration as its parent. Changes are only >+ * saved to the underlying original configuration when the root working >+ * copy is saved. >+ * >+ * @return a working copy of this working copy >+ * @exception CoreException if this method fails. Reasons include: >+ * <ul> >+ * <li>An exception occurs while initializing the contents of the >+ * working copy from this configuration's underlying storage.</li> >+ * </ul> >+ * @see ILaunchConfigurationWorkingCopy#getOriginal() >+ * @see ILaunchConfigurationWorkingCopy#getParent() >+ * @since 3.3 >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This method has been added as >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.3 release cycle. Please do not use this API >+ * without consulting with the Platform/Debug team. >+ * </p> >+ */ >+ public ILaunchConfigurationWorkingCopy getNestedWorkingCopy() throws CoreException; >+ >+ /** >+ * Returns the parent of this working copy or <code>null</code> if this working >+ * copy is not a nested copy of another working copy. >+ * >+ * @return parent or <code>null</code> >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This method has been added as >+ * part of a work in progress. There is no guarantee that this API will >+ * remain unchanged during the 3.3 release cycle. Please do not use this API >+ * without consulting with the Platform/Debug team. >+ * </p> >+ */ >+ public ILaunchConfigurationWorkingCopy getParent(); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 74480
:
53335
|
54442
|
54503
|
55420
|
56341
|
56426
|
56666
|
56675
|
56736
|
56804
|
56849
|
56854
|
57047
|
57181
|
57350
|
58480
|
58788
|
58895