diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java index 19cef3b7bb5..b7d7a3a3016 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/AbstractLaunchConfigProvider.java @@ -61,12 +61,16 @@ public abstract class AbstractLaunchConfigProvider implements ILaunchConfigurati return false; } - // Check for our class name but also that the config name - // matches what we originally set it to. - // This covers the case when the config was duplicated. - // We can own only one, the original one. - return configuration.getAttribute(ATTR_PROVIDER_CLASS, "").equals(getClass().getName()) //$NON-NLS-1$ - && configuration.getAttribute(ATTR_ORIGINAL_NAME, "").equals(configuration.getName()); //$NON-NLS-1$ + if (configuration.getAttribute(ATTR_PROVIDER_CLASS, "").equals(getClass().getName())) { //$NON-NLS-1$ + // We provided the configuration but we need to check if this is a duplicate and + // not own it. Check the original name and if there is still a config with that + // name, this is the duplicate. Otherwise it's simply a rename + String origName = configuration.getAttribute(ATTR_ORIGINAL_NAME, ""); //$NON-NLS-1$ + return origName.equals(configuration.getName()) + || !DebugPlugin.getDefault().getLaunchManager().isExistingLaunchConfigurationName(origName); + } else { + return false; + } } } diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java index 283b53a1f5d..468c6bc0eae 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/LaunchBarManager.java @@ -947,7 +947,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene return; fireLaunchTargetsChanged(); // if we added new target we probably want to use it - if (activeLaunchDesc == null || supportsTarget(activeLaunchDesc, target)) { + if (activeLaunchDesc != null && supportsTarget(activeLaunchDesc, target)) { try { setActiveLaunchTarget(target); } catch (CoreException e) { diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java index e6ce687f956..fe6631c46bc 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetManager.java @@ -205,7 +205,7 @@ public class LaunchTargetManager implements ILaunchTargetManager { } ILaunchTarget target = new LaunchTarget(typeId, id, child); type.put(id, target); - child.flush(); + prefs.flush(); synchronized (listeners) { for (ILaunchTargetListener listener : listeners) { diff --git a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java index f9089b8dc3d..714b1ef29d4 100644 --- a/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java +++ b/bundles/org.eclipse.launchbar.core/src/org/eclipse/launchbar/core/internal/target/LaunchTargetWorkingCopy.java @@ -77,7 +77,7 @@ public class LaunchTargetWorkingCopy extends PlatformObject implements ILaunchTa public ILaunchTarget save() { try { LaunchTarget target; - if (newId == null) { + if (newId == null || newId.equals(original.getId())) { target = original; } else { // make a new one and remove the old one @@ -91,7 +91,13 @@ public class LaunchTargetWorkingCopy extends PlatformObject implements ILaunchTa // set the changed attributes for (Map.Entry entry : changes.entrySet()) { - target.attributes.put(entry.getKey(), entry.getValue()); + String key = entry.getKey(); + String value = entry.getValue(); + if (value != null) { + target.attributes.put(key, value); + } else { + target.attributes.remove(key); + } } target.attributes.flush(); return target; diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java index f084d21f7eb..cbd53e74198 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/TargetSelector.java @@ -18,14 +18,9 @@ import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.SameShellProvider; import org.eclipse.launchbar.core.ILaunchBarManager; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTargetListener; @@ -48,7 +43,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.PropertyDialogAction; public class TargetSelector extends CSelector implements ILaunchTargetListener { @@ -108,7 +102,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { if (status.getCode() == Code.OK) { return baseImage; } else { - String compId = String.format("%s.%s.%s", target.getTypeId(), target.getId(), + String compId = String.format("%s.%s.%s", target.getTypeId(), target.getId(), //$NON-NLS-1$ status.getCode()); Image image = Activator.getDefault().getImageRegistry().get(compId); if (image == null && baseImage != null) { @@ -157,34 +151,9 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener { return true; } - private ISelectionProvider getSelectionProvider() { - return new ISelectionProvider() { - @Override - public void setSelection(ISelection selection) { - // ignore - } - - @Override - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - // ignore - } - - @Override - public ISelection getSelection() { - return new StructuredSelection(TargetSelector.this.getSelection()); - } - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // ignore - } - }; - } - @Override public void handleEdit(Object element) { - // opens property dialog on a selected target - new PropertyDialogAction(new SameShellProvider(getShell()), getSelectionProvider()).run(); + targetUIManager.editLaunchTarget((ILaunchTarget) getSelection()); } @Override diff --git a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF index d29431beb28..a252075c446 100644 --- a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: LaunchBar UI Bundle-SymbolicName: org.eclipse.launchbar.ui;singleton:=true -Bundle-Version: 2.1.1.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Activator: org.eclipse.launchbar.ui.internal.Activator Bundle-Vendor: Eclipse CDT Require-Bundle: org.eclipse.core.runtime, diff --git a/bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd b/bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd index cb66eccd31b..5d964f9875c 100644 --- a/bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd +++ b/bundles/org.eclipse.launchbar.ui/schema/launchTargetTypeUI.exsd @@ -21,6 +21,7 @@ and target creation wizard. + @@ -173,6 +174,53 @@ Since 3.0 + + + + Wizard that supports creation and editing of targets. These wizards are per target type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -187,7 +235,7 @@ Since 3.0 - <extension + <extension point="org.eclipse.launchbar.ui.launchTargetTypeUI"> <launchTargetTypeUI id="com.qnx.tools.ide.target.qconn" diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java index 85b8303cf52..e07cf4a1257 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java @@ -103,4 +103,5 @@ public class Activator extends AbstractUIPlugin { ServiceReference ref = context.getServiceReference(cls); return ref != null ? context.getService(ref) : null; } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarLaunchConfigDialog.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarLaunchConfigDialog.java index 188d13765fe..7b8b9afd306 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarLaunchConfigDialog.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarLaunchConfigDialog.java @@ -3,7 +3,9 @@ package org.eclipse.launchbar.ui.internal; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchMode; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager; import org.eclipse.debug.ui.ILaunchConfigurationTab; @@ -24,6 +26,8 @@ import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.FocusAdapter; import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -31,7 +35,9 @@ 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.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILaunchBarLaunchConfigDialog { @@ -40,8 +46,10 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau private final ILaunchMode mode; private final ILaunchTarget target; private final ILaunchConfigurationTabGroup buildTabGroup; + private final String originalName; private ILaunchConfigurationTabGroup group; + private Text nameText; private CTabFolder tabFolder; private CTabItem lastSelection; private ProgressMonitorPart pmPart; @@ -57,6 +65,7 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau this.mode = mode; this.target = target; this.buildTabGroup = buildTabGroup; + this.originalName = workingCopy.getName(); setShellStyle(getShellStyle() | SWT.RESIZE); } @@ -71,14 +80,6 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau protected Control createDialogArea(Composite parent) { initing = true; - // create the top level composite for the dialog area - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parent.getFont()); - getShell().setText(Messages.LaunchBarLaunchConfigDialog_EditConfiguration); boolean supportsTargets = true; try { @@ -102,6 +103,31 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau setMessage(Messages.LaunchBarLaunchConfigDialog_SetParameters); + // create the top level composite for the dialog area + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.verticalSpacing = 0; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setFont(parent.getFont()); + + Composite nameComp = new Composite(composite, SWT.NONE); + nameComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + nameComp.setLayout(new GridLayout(2, false)); + + Label nameLabel = new Label(nameComp, SWT.NONE); + nameLabel.setText(Messages.LaunchBarLaunchConfigDialog_LaunchConfigName); + + nameText = new Text(nameComp, SWT.BORDER); + nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + nameText.setText(workingCopy.getName()); + nameText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent e) { + updateMessage(); + } + }); + tabFolder = new CTabFolder(composite, SWT.BORDER); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); tabFolder.addFocusListener(new FocusAdapter() { @@ -184,6 +210,11 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau @Override protected void okPressed() { + String newName = nameText.getText().trim(); + if (!newName.equals(originalName)) { + workingCopy.rename(newName); + } + if (buildTabGroup != null) { buildTabGroup.performApply(workingCopy); } @@ -277,6 +308,31 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau return; } + String newName = nameText.getText().trim(); + if (newName.isEmpty()) { + setMessage(Messages.LaunchBarLaunchConfigDialog_LCMustHaveName, IMessageProvider.ERROR); + return; + } + + if (!newName.equals(originalName)) { + // make sure it's not taken + try { + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + + if (manager.isExistingLaunchConfigurationName(newName)) { + setMessage(Messages.LaunchBarLaunchConfigDialog_LCNameExists, IMessageProvider.ERROR); + return; + } + + if (!manager.isValidLaunchConfigurationName(newName)) { + setMessage(Messages.LaunchBarLaunchConfigDialog_LCNameNotValid, IMessageProvider.ERROR); + return; + } + } catch (CoreException e1) { + Activator.log(e1.getStatus()); + } + } + for (ILaunchConfigurationTab tab : getTabs()) { tab.isValid(workingCopy); } @@ -297,13 +353,14 @@ public class LaunchBarLaunchConfigDialog extends TitleAreaDialog implements ILau @Override public void setName(String name) { - // Names aren't setable from this dialog + if (nameText != null && !nameText.isDisposed()) { + nameText.setText(name); + } } @Override public String generateName(String name) { - // Names aren't setable from this dialog - return null; + return DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(name); } @Override diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java index 67473189279..16e62a40677 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/LaunchBarUIManager.java @@ -128,7 +128,8 @@ public class LaunchBarUIManager implements ILaunchBarUIManager { target, buildTabGroup); if (dialog.open() == Window.OK) { if (!workingCopy.getOriginal().equals(workingCopy) - && !workingCopy.getOriginal().getAttributes().equals(workingCopy.getAttributes())) { + && (!workingCopy.getOriginal().getAttributes().equals(workingCopy.getAttributes()) + || !workingCopy.getOriginal().getName().equals(workingCopy.getName()))) { workingCopy.doSave(); } } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java index aa8c1687353..e220d9b1e10 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Messages.java @@ -33,6 +33,8 @@ public class Messages extends NLS { public static String NewLaunchConfigTypePage_2; public static String NewLaunchConfigWizard_0; + public static String NewLaunchTargetWizard_Title; + public static String DescriptorMustNotBeNull; public static String DescriptorMustNotBeNullDesc; public static String NoActiveTarget; @@ -47,10 +49,20 @@ public class Messages extends NLS { public static String LaunchBarLaunchConfigDialog_EditConfiguration; + public static String LaunchBarLaunchConfigDialog_LaunchConfigName; + + public static String LaunchBarLaunchConfigDialog_LCMustHaveName; + + public static String LaunchBarLaunchConfigDialog_LCNameExists; + + public static String LaunchBarLaunchConfigDialog_LCNameNotValid; + public static String LaunchBarLaunchConfigDialog_SetParameters; public static String LaunchConfigurationNotFound; public static String LaunchConfigurationNotFoundDesc; + + public static String LaunchTargetWizardDialog_Delete; public static String NoLaunchTabsDefined; public static String NoLaunchTabsDefinedDesc; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties index 7e55a143a6e..8f0cabb106c 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/messages.properties @@ -25,6 +25,7 @@ NewLaunchConfigTypePage_0=Select Launch Configuration Type NewLaunchConfigTypePage_1=Launch Configuration Type NewLaunchConfigTypePage_2=Select the type of launch configuration to create. NewLaunchConfigWizard_0=Create Launch Configuration +NewLaunchTargetWizard_Title=New Launch Target DescriptorMustNotBeNull=Descriptor must not be null DescriptorMustNotBeNullDesc=The launch descriptor must not be null. @@ -37,8 +38,13 @@ NoLaunchGroupSelected=No launch group found for the current selection. LaunchBarLaunchConfigDialog_Edit1=Edit configuration %s for %s LaunchBarLaunchConfigDialog_Edit2=Edit configuration %s for %s on %s LaunchBarLaunchConfigDialog_EditConfiguration=Edit Configuration +LaunchBarLaunchConfigDialog_LaunchConfigName=Launch Configuration Name: +LaunchBarLaunchConfigDialog_LCMustHaveName=Launch configuration must have a name +LaunchBarLaunchConfigDialog_LCNameExists=A launch configuration with that name already exists. +LaunchBarLaunchConfigDialog_LCNameNotValid=The launch configuration name is not valid. LaunchBarLaunchConfigDialog_SetParameters=Set parameters for the configuration. LaunchConfigurationNotFound=Launch Configuration Not Found LaunchConfigurationNotFoundDesc=No launch configuration is found for the given launch descriptor and target. +LaunchTargetWizardDialog_Delete=Delete NoLaunchTabsDefined=No launch tabs defined. NoLaunchTabsDefinedDesc=No launch tabs have been defined for this launch configuration type. diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java index e32c6b4cfd4..5faf1d91737 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetUIManager.java @@ -7,9 +7,7 @@ *******************************************************************************/ package org.eclipse.launchbar.ui.internal.target; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.eclipse.core.runtime.CoreException; @@ -19,19 +17,27 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.window.SameShellProvider; +import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.ui.internal.Activator; import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; +import org.eclipse.launchbar.ui.target.LaunchTargetWizard; import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.internal.dialogs.WizardCollectionElement; -import org.eclipse.ui.internal.registry.WizardsRegistryReader; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.PropertyDialogAction; import org.eclipse.ui.wizards.IWizardDescriptor; public class LaunchTargetUIManager implements ILaunchTargetUIManager { private Map typeElements; private Map labelProviders = new HashMap<>(); - private IWizardDescriptor[] wizards; + private Map editElements; @Override public synchronized ILabelProvider getLabelProvider(ILaunchTarget target) { @@ -43,13 +49,16 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager { .getExtensionPoint(Activator.getDefault().getBundle().getSymbolicName() + ".launchTargetTypeUI"); //$NON-NLS-1$ for (IExtension extension : point.getExtensions()) { for (IConfigurationElement element : extension.getConfigurationElements()) { - String id = element.getAttribute("id"); //$NON-NLS-1$ - if (id != null) { - typeElements.put(id, element); + if ("launchTargetTypeUI".equals(element.getName())) { //$NON-NLS-1$ + String id = element.getAttribute("id"); //$NON-NLS-1$ + if (id != null) { + typeElements.put(id, element); + } } } } } + String typeId = target.getTypeId(); ILabelProvider labelProvider = labelProviders.get(typeId); if (labelProvider == null) { @@ -85,27 +94,66 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager { } @Override - public synchronized IWizardDescriptor[] getLaunchTargetWizards() { - if (wizards != null) - return wizards; - WizardsRegistryReader reader = new WizardsRegistryReader(Activator.PLUGIN_ID, "launchTargetTypeUI"); //$NON-NLS-1$ - WizardCollectionElement wizardElements = reader.getWizardElements(); - List result = collectWizards(wizardElements, new ArrayList<>()); - wizards = result.toArray(new IWizardDescriptor[result.size()]); - return wizards; + public IWizardDescriptor[] getLaunchTargetWizards() { + // No one one should be using this. The new target wizard is internal. + return null; } - /* we don't show categories we have to flatten the wizards */ - private List collectWizards(WizardCollectionElement element, List result) { - Object[] children = element.getChildren(null); // children are categories - IWizardDescriptor[] wizards = element.getWizards(); - for (IWizardDescriptor desc : wizards) { - result.add(desc); + @Override + public void editLaunchTarget(ILaunchTarget target) { + if (editElements == null) { + // Load them up + editElements = new HashMap<>(); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint point = registry + .getExtensionPoint(Activator.getDefault().getBundle().getSymbolicName() + ".launchTargetTypeUI"); //$NON-NLS-1$ + for (IExtension extension : point.getExtensions()) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + if ("wizard2".equals(element.getName())) { //$NON-NLS-1$ + String id = element.getAttribute("id"); //$NON-NLS-1$ + if (id != null) { + editElements.put(id, element); + } + } + } + } } - for (Object cat : children) { - WizardCollectionElement category = (WizardCollectionElement) cat; - collectWizards(category, result); + + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + IConfigurationElement element = editElements.get(target.getTypeId()); + if (element != null) { + try { + LaunchTargetWizard wizard = (LaunchTargetWizard) element.createExecutableExtension("class"); //$NON-NLS-1$ + wizard.setLaunchTarget(target); + WizardDialog dialog = wizard.canDelete() ? new LaunchTargetWizardDialog(shell, wizard) + : new WizardDialog(shell, wizard); + dialog.open(); + } catch (CoreException e) { + Activator.log(e.getStatus()); + } + } else { + new PropertyDialogAction(new SameShellProvider(shell), new ISelectionProvider() { + @Override + public void setSelection(ISelection selection) { + // ignore + } + + @Override + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + // ignore + } + + @Override + public ISelection getSelection() { + return new StructuredSelection(target); + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + // ignore + } + }).run(); } - return result; } + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetWizardDialog.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetWizardDialog.java new file mode 100644 index 00000000000..24fdf5aca7a --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/LaunchTargetWizardDialog.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.launchbar.ui.internal.target; + +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.launchbar.ui.internal.Messages; +import org.eclipse.launchbar.ui.target.LaunchTargetWizard; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; + +public class LaunchTargetWizardDialog extends WizardDialog { + + public static final int ID_DELETE = IDialogConstants.CLIENT_ID + 0; + + public LaunchTargetWizardDialog(Shell parentShell, IWizard newWizard) { + super(parentShell, newWizard); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, ID_DELETE, Messages.LaunchTargetWizardDialog_Delete, false); + + super.createButtonsForButtonBar(parent); + } + + @Override + protected void buttonPressed(int buttonId) { + if (buttonId == ID_DELETE) { + ((LaunchTargetWizard) getWizard()).performDelete(); + setReturnCode(CANCEL); + close(); + } else { + super.buttonPressed(buttonId); + } + } + +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizard.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizard.java index 7fb746f169e..45a0d66b47e 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizard.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizard.java @@ -10,104 +10,33 @@ *******************************************************************************/ package org.eclipse.launchbar.ui.internal.target; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.launchbar.ui.internal.Activator; -import org.eclipse.launchbar.ui.target.ILaunchTargetUIManager; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.internal.IWorkbenchGraphicConstants; -import org.eclipse.ui.internal.WorkbenchImages; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.wizards.IWizardDescriptor; +import org.eclipse.launchbar.ui.internal.Messages; /** * The new wizard is responsible for allowing the user to choose which new * (nested) wizard to run. The set of available new wizards comes from the new * extension point. */ -public class NewLaunchTargetWizard extends Wizard implements IWorkbenchWizard { - private NewLaunchTargetWizardSelectionPage mainPage; - private IWorkbench workbench; - private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class); +public class NewLaunchTargetWizard extends Wizard { + + public NewLaunchTargetWizard() { + setForcePreviousAndNextButtons(true); + } /** * Create the wizard pages */ @Override public void addPages() { - mainPage = new NewLaunchTargetWizardSelectionPage(workbench, getWizardDescriptors()); - addPage(mainPage); + addPage(new NewLaunchTargetWizardSelectionPage()); + setWindowTitle(Messages.NewLaunchTargetWizard_Title); } - public IWizardDescriptor[] getWizardDescriptors() { - return targetUIManager.getLaunchTargetWizards(); - } - - /** - * Lazily create the wizards pages - * @param aWorkbench the workbench - * @param currentSelection the current selection - */ - @Override - public void init(IWorkbench aWorkbench, - IStructuredSelection currentSelection) { - this.workbench = aWorkbench; - if (getWindowTitle() == null) { - setWindowTitle(WorkbenchMessages.NewWizard_title); - } - setDefaultPageImageDescriptor(WorkbenchImages - .getImageDescriptor(IWorkbenchGraphicConstants.IMG_WIZBAN_NEW_WIZ)); - setNeedsProgressMonitor(true); - } - - /** - * The user has pressed Finish. Instruct self's pages to finish, and answer - * a boolean indicating success. - * - * @return boolean - */ @Override public boolean performFinish() { - //save our selection state - mainPage.saveWidgetValues(); - // if we're finishing from the main page then perform finish on the selected wizard. - if (getContainer().getCurrentPage() == mainPage) { - if (mainPage.canFinishEarly()) { - IWizard wizard = mainPage.getSelectedNode().getWizard(); - wizard.setContainer(getContainer()); - return wizard.performFinish(); - } - } - return true; + // Downstream wizards do finish + return false; } - @Override - public IDialogSettings getDialogSettings() { - IDialogSettings wizardSettings = super.getDialogSettings(); - if (wizardSettings == null) { - IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings(); - String settingsSection = getClass().getSimpleName(); - wizardSettings = workbenchSettings.getSection(settingsSection); - if (wizardSettings == null) { - wizardSettings = workbenchSettings.addNewSection(settingsSection); - } - setDialogSettings(wizardSettings); - } - return wizardSettings; - } - - @Override - public boolean canFinish() { - // we can finish if the first page is current and the the page can finish early. - if (getContainer().getCurrentPage() == mainPage) { - if (mainPage.canFinishEarly()) { - return true; - } - } - return super.canFinish(); - } } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardNewPage.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardNewPage.java deleted file mode 100644 index 8cdb42b1811..00000000000 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardNewPage.java +++ /dev/null @@ -1,518 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 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.launchbar.ui.internal.target; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -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.viewers.TreeViewer; -import org.eclipse.jface.wizard.IWizardContainer; -import org.eclipse.jface.wizard.IWizardContainer2; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -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.Label; -import org.eclipse.ui.IWorkbenchWizard; -import org.eclipse.ui.activities.WorkbenchActivityHelper; -import org.eclipse.ui.dialogs.FilteredTree; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.dialogs.DialogUtil; -import org.eclipse.ui.internal.dialogs.WizardActivityFilter; -import org.eclipse.ui.internal.dialogs.WizardContentProvider; -import org.eclipse.ui.internal.dialogs.WizardPatternFilter; -import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement; -import org.eclipse.ui.internal.dialogs.WorkbenchWizardNode; -import org.eclipse.ui.model.AdaptableList; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.wizards.IWizardCategory; -import org.eclipse.ui.wizards.IWizardDescriptor; - -/** - * New wizard selection tab that allows the user to select a registered 'New' - * wizard to be launched. - */ -class NewLaunchTargetWizardNewPage implements ISelectionChangedListener { - // id constants - private static final String DIALOG_SETTING_SECTION_NAME = "NewWizardSelectionPage."; //$NON-NLS-1$ - private final static int SIZING_LISTS_HEIGHT = 200; - private final static int SIZING_VIEWER_WIDTH = 300; - private final static String STORE_EXPANDED_CATEGORIES_ID = DIALOG_SETTING_SECTION_NAME - + "STORE_EXPANDED_CATEGORIES_ID"; //$NON-NLS-1$ - private final static String STORE_SELECTED_ID = DIALOG_SETTING_SECTION_NAME - + "STORE_SELECTED_ID"; //$NON-NLS-1$ - private NewLaunchTargetWizardSelectionPage page; - private FilteredTree filteredTree; - private WizardPatternFilter filteredTreeFilter; - //Keep track of the wizards we have previously selected - private Hashtable selectedWizards = new Hashtable(); - private IDialogSettings settings; - private Button showAllCheck; - private IWizardDescriptor[] primaryWizards; - private CLabel descImageCanvas; - private Map imageTable = new HashMap(); - private IWizardDescriptor selectedElement; - private WizardActivityFilter filter = new WizardActivityFilter(); - private boolean needShowAll; - - /** - * Create an instance of this class - * @param mainPage - * @param wizardCategories - * @param primaryWizards - * @param projectsOnly - */ - public NewLaunchTargetWizardNewPage(NewLaunchTargetWizardSelectionPage mainPage, - IWizardCategory wizardCategories, - IWizardDescriptor[] primaryWizards) { - this.page = mainPage; - this.primaryWizards = primaryWizards; - needShowAll = !allActivityEnabled(primaryWizards); - } - - /** - * @param category the wizard category - * @return whether all of the wizards in the category are enabled via activity filtering - */ - private boolean allActivityEnabled(IWizardDescriptor[] wizards) { - for (int i = 0; i < wizards.length; i++) { - IWizardDescriptor wizard = wizards[i]; - if (WorkbenchActivityHelper.filterItem(wizard)) { - return false; - } - } - return true; - } - - /** - * @since 3.0 - */ - public void activate() { - page.setDescription(WorkbenchMessages.NewWizardNewPage_description); - } - - /** - * Create this tab's visual components - * - * @param parent Composite - * @return Control - */ - protected Control createControl(Composite parent) { - Font wizardFont = parent.getFont(); - // top level group - Composite outerContainer = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - outerContainer.setLayout(layout); - Label wizardLabel = new Label(outerContainer, SWT.NONE); - GridData data = new GridData(SWT.BEGINNING, SWT.FILL, false, true); - outerContainer.setLayoutData(data); - wizardLabel.setFont(wizardFont); - wizardLabel.setText(WorkbenchMessages.NewWizardNewPage_wizardsLabel); - Composite innerContainer = new Composite(outerContainer, SWT.NONE); - layout = new GridLayout(2, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - innerContainer.setLayout(layout); - innerContainer.setFont(wizardFont); - data = new GridData(SWT.FILL, SWT.FILL, true, true); - innerContainer.setLayoutData(data); - filteredTree = createFilteredTree(innerContainer); - createOptionsButtons(innerContainer); - createImage(innerContainer); - updateDescription(null); - // wizard actions pane...create SWT table directly to - // get single selection mode instead of multi selection. - restoreWidgetValues(); - return outerContainer; - } - - /** - * Create a new FilteredTree in the parent. - * - * @param parent the parent Composite. - * @since 3.0 - */ - protected FilteredTree createFilteredTree(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - data.widthHint = SIZING_VIEWER_WIDTH; - data.horizontalSpan = 2; - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - boolean needsHint = DialogUtil.inRegularFontMode(parent); - //Only give a height hint if the dialog is going to be too small - if (needsHint) { - data.heightHint = SIZING_LISTS_HEIGHT; - } - composite.setLayoutData(data); - filteredTreeFilter = new WizardPatternFilter(); - FilteredTree filterTree = new FilteredTree(composite, - SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, filteredTreeFilter, true); - filterTree.setQuickSelectionMode(true); - final TreeViewer treeViewer = filterTree.getViewer(); - treeViewer.setContentProvider(new WizardContentProvider()); - treeViewer.setLabelProvider(new WorkbenchLabelProvider()); - //treeViewer.setComparator(NewWizardCollectionComparator.INSTANCE); - treeViewer.addSelectionChangedListener(this); - ArrayList inputArray = new ArrayList(); - for (int i = 0; i < primaryWizards.length; i++) { - inputArray.add(primaryWizards[i]); - } - boolean expandTop = false; - // ensure the category is expanded. If there is a remembered expansion it will be set later. - if (expandTop) { - treeViewer.setAutoExpandLevel(2); - } - AdaptableList input = new AdaptableList(inputArray); - treeViewer.setInput(input); - filterTree.setBackground(parent.getDisplay().getSystemColor( - SWT.COLOR_WIDGET_BACKGROUND)); - treeViewer.getTree().setFont(parent.getFont()); - treeViewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - IStructuredSelection s = (IStructuredSelection) event - .getSelection(); - selectionChanged(new SelectionChangedEvent(event.getViewer(), s)); - Object element = s.getFirstElement(); - if (treeViewer.isExpandable(element)) { - treeViewer.setExpandedState(element, !treeViewer - .getExpandedState(element)); - } else if (element instanceof WorkbenchWizardElement) { - page.advanceToNextPageOrFinish(); - } - } - }); - treeViewer.addFilter(filter); - Dialog.applyDialogFont(filterTree); - return filterTree; - } - - /** - * Create the Show All and help buttons at the bottom of the page. - * - * @param parent the parent composite on which to create the widgets - */ - private void createOptionsButtons(Composite parent) { - if (needShowAll) { - showAllCheck = new Button(parent, SWT.CHECK); - GridData data = new GridData(); - showAllCheck.setLayoutData(data); - showAllCheck.setFont(parent.getFont()); - showAllCheck.setText(WorkbenchMessages.NewWizardNewPage_showAll); - showAllCheck.setSelection(false); - // flipping tabs updates the selected node - showAllCheck.addSelectionListener(new SelectionAdapter() { - // the delta of expanded elements between the last 'show all' - // and the current 'no show all' - private Object[] delta = new Object[0]; - - @Override - public void widgetSelected(SelectionEvent e) { - boolean showAll = showAllCheck.getSelection(); - if (showAll) { - filteredTree.getViewer().getControl().setRedraw(false); - } else { - // get the inital expanded elements when going from show - // all-> no show all. - // this isnt really the delta yet, we're just reusing - // the variable. - delta = filteredTree.getViewer().getExpandedElements(); - } - try { - if (showAll) { - filteredTree.getViewer().resetFilters(); - filteredTree.getViewer().addFilter(filteredTreeFilter); - // restore the expanded elements that were present - // in the last show all state but not in the 'no - // show all' state. - Object[] currentExpanded = filteredTree.getViewer() - .getExpandedElements(); - Object[] expanded = new Object[delta.length - + currentExpanded.length]; - System.arraycopy(currentExpanded, 0, expanded, 0, - currentExpanded.length); - System.arraycopy(delta, 0, expanded, - currentExpanded.length, delta.length); - filteredTree.getViewer().setExpandedElements(expanded); - } else { - filteredTree.getViewer().addFilter(filter); - } - filteredTree.getViewer().refresh(false); - if (!showAll) { - // if we're going from show all -> no show all - // record the elements that were expanded in the - // 'show all' state but not the 'no show all' state - // (because they didnt exist). - Object[] newExpanded = filteredTree.getViewer().getExpandedElements(); - List deltaList = new ArrayList(Arrays.asList(delta)); - deltaList.removeAll(Arrays.asList(newExpanded)); - } - } finally { - if (showAll) { - filteredTree.getViewer().getControl().setRedraw(true); - } - } - } - }); - } - } - - /** - * Create the image controls. - * - * @param parent the parent Composite. - * @since 3.0 - */ - private void createImage(Composite parent) { - descImageCanvas = new CLabel(parent, SWT.NONE); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING - | GridData.VERTICAL_ALIGN_BEGINNING); - data.widthHint = 0; - data.heightHint = 0; - descImageCanvas.setLayoutData(data); - // hook a listener to get rid of cached images. - descImageCanvas.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - for (Iterator i = imageTable.values().iterator(); i.hasNext();) { - ((Image) i.next()).dispose(); - } - imageTable.clear(); - } - }); - } - - /** - * Returns the single selected object contained in the passed - * selectionEvent, or null if the selectionEvent contains - * either 0 or 2+ selected objects. - */ - protected Object getSingleSelection(IStructuredSelection selection) { - return selection.size() == 1 ? selection.getFirstElement() : null; - } - - /** - * Set self's widgets to the values that they held last time this page was - * open - * - */ - protected void restoreWidgetValues() { - //expandPreviouslyExpandedCategories(); - selectPreviouslySelected(); - } - - /** - * Store the current values of self's widgets so that they can be restored - * in the next instance of self - * - */ - public void saveWidgetValues() { - storeSelectedCategoryAndWizard(); - } - - /** - * The user selected either new wizard category(s) or wizard element(s). - * Proceed accordingly. - * - * @param selectionEvent ISelection - */ - @Override - public void selectionChanged(SelectionChangedEvent selectionEvent) { - page.setErrorMessage(null); - page.setMessage(null); - Object selectedObject = getSingleSelection((IStructuredSelection) selectionEvent - .getSelection()); - if (selectedObject instanceof IWizardDescriptor) { - if (selectedObject == selectedElement) { - return; - } - updateWizardSelection((IWizardDescriptor) selectedObject); - } else { - selectedElement = null; - page.setHasPages(false); - page.setCanFinishEarly(false); - page.selectWizardNode(null); - updateDescription(null); - } - } - - /** - * Selects the wizard category and wizard in this page that were selected - * last time this page was used. If a category or wizard that was - * previously selected no longer exists then it is ignored. - */ - protected void selectPreviouslySelected() { - String selectedId = settings.get(STORE_SELECTED_ID); - if (selectedId == null) { - return; - } - Object selected = null; - for (int i = 0; i < primaryWizards.length; i++) { - IWizardDescriptor wizard = primaryWizards[i]; - if (wizard.getId().equals(selectedId)) { - selected = wizard; - break; - } - } - if (selected == null) { - // if we cant find either a category or a wizard, abort. - return; - } - //work around for 62039 - final StructuredSelection selection = new StructuredSelection(selected); - filteredTree.getViewer().getControl().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - filteredTree.getViewer().setSelection(selection, true); - } - }); - } - - /** - * Set the dialog store to use for widget value storage and retrieval - * - * @param settings IDialogSettings - */ - public void setDialogSettings(IDialogSettings settings) { - this.settings = settings; - } - - - /** - * Stores the currently-selected element in this page's dialog store, in - * order to recreate this page's state in the next instance of this page. - */ - protected void storeSelectedCategoryAndWizard() { - Object selected = getSingleSelection((IStructuredSelection) filteredTree - .getViewer().getSelection()); - if (selected != null) { - if (selected instanceof IWizardCategory) { - settings.put(STORE_SELECTED_ID, - ((IWizardCategory) selected).getPath() - .toString()); - } else { - // else its a wizard - settings.put(STORE_SELECTED_ID, - ((IWizardDescriptor) selected).getId()); - } - } - } - - /** - * Update the current description controls. - * - * @param selectedObject the new wizard - * @since 3.0 - */ - private void updateDescription(IWizardDescriptor selectedObject) { - String string = ""; //$NON-NLS-1$ - if (selectedObject != null) { - string = selectedObject.getDescription(); - } - page.setDescription(string); - if (hasImage(selectedObject)) { - ImageDescriptor descriptor = null; - if (selectedObject != null) { - descriptor = selectedObject.getDescriptionImage(); - } - if (descriptor != null) { - GridData data = (GridData) descImageCanvas.getLayoutData(); - data.widthHint = SWT.DEFAULT; - data.heightHint = SWT.DEFAULT; - Image image = (Image) imageTable.get(descriptor); - if (image == null) { - image = descriptor.createImage(false); - imageTable.put(descriptor, image); - } - descImageCanvas.setImage(image); - } - } else { - GridData data = (GridData) descImageCanvas.getLayoutData(); - data.widthHint = 0; - data.heightHint = 0; - descImageCanvas.setImage(null); - } - descImageCanvas.getParent().layout(true); - filteredTree.getViewer().getTree().showSelection(); - IWizardContainer container = page.getWizard().getContainer(); - if (container instanceof IWizardContainer2) { - ((IWizardContainer2) container).updateSize(); - } - } - - /** - * Tests whether the given wizard has an associated image. - * - * @param selectedObject the wizard to test - * @return whether the given wizard has an associated image - */ - private boolean hasImage(IWizardDescriptor selectedObject) { - if (selectedObject == null) { - return false; - } - if (selectedObject.getDescriptionImage() != null) { - return true; - } - return false; - } - - /** - * @param selectedObject - */ - private void updateWizardSelection(IWizardDescriptor selectedObject) { - selectedElement = selectedObject; - WorkbenchWizardNode selectedNode; - if (selectedWizards.containsKey(selectedObject)) { - selectedNode = (WorkbenchWizardNode) selectedWizards - .get(selectedObject); - } else { - selectedNode = new WorkbenchWizardNode(page, selectedObject) { - @Override - public IWorkbenchWizard createWizard() throws CoreException { - return wizardElement.createWizard(); - } - }; - selectedWizards.put(selectedObject, selectedNode); - } - page.setCanFinishEarly(selectedObject.canFinishEarly()); - page.setHasPages(selectedObject.hasPages()); - page.selectWizardNode(selectedNode); - updateDescription(selectedObject); - } -} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardSelectionPage.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardSelectionPage.java index 4e13b15d821..ae11b1a9738 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardSelectionPage.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/target/NewLaunchTargetWizardSelectionPage.java @@ -10,111 +10,156 @@ *******************************************************************************/ package org.eclipse.launchbar.ui.internal.target; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.wizard.WizardDialog; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.launchbar.ui.internal.Activator; +import org.eclipse.launchbar.ui.target.LaunchTargetWizard; +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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.internal.IWorkbenchHelpContextIds; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints; -import org.eclipse.ui.internal.dialogs.WorkbenchWizardSelectionPage; -import org.eclipse.ui.wizards.IWizardDescriptor; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.plugin.AbstractUIPlugin; -/** - * New wizard selection tab that allows the user to either select a - * registered 'New' wizard to be launched, or to select a solution or - * projects to be retrieved from an available server. This page - * contains two visual tabs that allow the user to perform these tasks. - * - * Temporarily has two inner pages. The new format page is used if the system - * is currently aware of activity categories. - */ -class NewLaunchTargetWizardSelectionPage extends WorkbenchWizardSelectionPage { - // widgets - private NewLaunchTargetWizardNewPage newResourcePage; - private IWizardDescriptor[] wizards; - private boolean canFinishEarly = false, hasPages = true; +class NewLaunchTargetWizardSelectionPage extends WizardPage { - /** - * Create an instance of this class. - * - * @param workbench the workbench - * @param wizards the primary wizard elements - */ - public NewLaunchTargetWizardSelectionPage(IWorkbench workbench, - IWizardDescriptor[] wizards) { - super("newWizardSelectionPage", workbench, null, null, WorkbenchTriggerPoints.NEW_WIZARDS);//$NON-NLS-1$ - setTitle(WorkbenchMessages.NewWizardSelectionPage_description); - this.wizards = wizards; - } + private Table table; - /** - * Makes the next page visible. - */ - public void advanceToNextPageOrFinish() { - if (canFlipToNextPage()) { - getContainer().showPage(getNextPage()); - } else if (canFinishEarly()) { - if (getWizard().performFinish()) { - ((WizardDialog) getContainer()).close(); - } - } + public NewLaunchTargetWizardSelectionPage() { + super(NewLaunchTargetWizardSelectionPage.class.getName()); } @Override public void createControl(Composite parent) { - IDialogSettings settings = getDialogSettings(); - newResourcePage = new NewLaunchTargetWizardNewPage(this, null, wizards); - newResourcePage.setDialogSettings(settings); - Control control = newResourcePage.createControl(parent); - getWorkbench().getHelpSystem().setHelp(control, - IWorkbenchHelpContextIds.NEW_WIZARD_SELECTION_WIZARD_PAGE); - setControl(control); + Composite comp = new Composite(parent, SWT.NONE); + comp.setLayout(new GridLayout()); + + table = new Table(comp, SWT.BORDER | SWT.SINGLE); + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + List elements = new ArrayList<>(); + IExtensionPoint point = Platform.getExtensionRegistry() + .getExtensionPoint(Activator.PLUGIN_ID + ".launchTargetTypeUI"); //$NON-NLS-1$ + for (IExtension extension : point.getExtensions()) { + for (IConfigurationElement element : extension.getConfigurationElements()) { + String elementName = element.getName(); + if ("wizard2".equals(elementName) || "wizard".equals(elementName)) { //$NON-NLS-1$ //$NON-NLS-2$ + elements.add(element); + } + } + } + + elements.sort(new Comparator() { + @Override + public int compare(IConfigurationElement o1, IConfigurationElement o2) { + String name1 = o1.getAttribute("name"); //$NON-NLS-1$ + String name2 = o2.getAttribute("name"); //$NON-NLS-1$ + return name1.compareTo(name2); + } + }); + + for (IConfigurationElement element : elements) { + String name = element.getAttribute("name"); //$NON-NLS-1$ + TableItem item = new TableItem(table, SWT.NONE); + item.setText(name); + + String iconFile = element.getAttribute("icon"); //$NON-NLS-1$ + if (iconFile != null) { + ImageDescriptor desc = Activator.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconFile); + if (desc != null) { + item.setImage(desc.createImage()); + } + } + + item.setData(element); + } + + table.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + getContainer().updateButtons(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + if (canFlipToNextPage()) { + getContainer().showPage(getNextPage()); + } + } + }); + + setControl(comp); } - /** - * Since Finish was pressed, write widget values to the dialog store so that they - *will persist into the next invocation of this wizard page - */ - protected void saveWidgetValues() { - newResourcePage.saveWidgetValues(); + @Override + public void dispose() { + for (TableItem item : table.getItems()) { + Object obj = item.getData(); + if (obj instanceof Wizard) { + ((Wizard) obj).dispose(); + } + } + super.dispose(); + } + + public ImageDescriptor getDescriptionImage(IConfigurationElement element) { + String descImage = element.getAttribute("icon"); //$NON-NLS-1$ + if (descImage == null) { + return null; + } + return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), descImage); } @Override public boolean canFlipToNextPage() { - // if the current page advertises that it does have pages then ask it via the super call - if (hasPages) { - return super.canFlipToNextPage(); + return table.getSelectionIndex() >= 0; + } + + @Override + public IWizardPage getNextPage() { + int i = table.getSelectionIndex(); + if (i >= 0) { + TableItem item = table.getItem(i); + Object obj = item.getData(); + Wizard nextWizard; + if (obj instanceof IConfigurationElement) { + IConfigurationElement element = (IConfigurationElement) obj; + try { + nextWizard = (Wizard) element.createExecutableExtension("class"); //$NON-NLS-1$ + nextWizard.addPages(); + if (nextWizard instanceof IWorkbenchWizard) { + ((IWorkbenchWizard) nextWizard).init(PlatformUI.getWorkbench(), new StructuredSelection()); + } + item.setData(nextWizard); + } catch (CoreException e) { + Activator.log(e); + return null; + } + } else { + nextWizard = (LaunchTargetWizard) obj; + } + + return nextWizard.getStartingPage(); } - return false; + return super.getNextPage(); } - /** - * Sets whether the selected wizard advertises that it does provide pages. - * - * @param newValue whether the selected wizard has pages - * @since 3.1 - */ - public void setHasPages(boolean newValue) { - hasPages = newValue; - } - - /** - * Sets whether the selected wizard advertises that it can finish early. - * - * @param newValue whether the selected wizard can finish early - */ - public void setCanFinishEarly(boolean newValue) { - canFinishEarly = newValue; - } - - /** - * Answers whether the currently selected page, if any, advertises that it may finish early. - * - * @return whether the page can finish early - */ - public boolean canFinishEarly() { - return canFinishEarly; - } } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/ILaunchTargetUIManager.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/ILaunchTargetUIManager.java index f29dde373d9..4e2a99c1998 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/ILaunchTargetUIManager.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/ILaunchTargetUIManager.java @@ -25,5 +25,19 @@ public interface ILaunchTargetUIManager { */ ILabelProvider getLabelProvider(ILaunchTarget target); + /** + * @deprecated this should never have been in the interface, now returns null + * @return null + */ + @Deprecated public IWizardDescriptor[] getLaunchTargetWizards(); + + /** + * Open a dialog to edit the specified launch target. + * + * @param target + * launch target to edit + */ + void editLaunchTarget(ILaunchTarget target); + } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/LaunchTargetWizard.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/LaunchTargetWizard.java new file mode 100644 index 00000000000..a2100b70fa8 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/LaunchTargetWizard.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2017 QNX Software Systems 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 + *******************************************************************************/ +package org.eclipse.launchbar.ui.target; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.launchbar.core.target.ILaunchTarget; + +public abstract class LaunchTargetWizard extends Wizard { + + protected ILaunchTarget launchTarget; + + public void setLaunchTarget(ILaunchTarget launchTarget) { + this.launchTarget = launchTarget; + } + + public ILaunchTarget getLaunchTarget() { + return launchTarget; + } + + public boolean canDelete() { + return false; + } + + public void performDelete() { + // do nothing by default + } + +} diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java index dff15f08065..83a65250ff4 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/target/NewLaunchTargetWizardAction.java @@ -1,140 +1,27 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2017 QNX Software Systems 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.launchbar.ui.target; import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizard; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.*; -import org.eclipse.ui.internal.IWorkbenchHelpContextIds; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.WorkbenchPlugin; /** - * Invoke the resource creation wizard selection Wizard. - *

- * This class may be instantiated; it is not intended to be subclassed. - *

- *

- * This method automatically registers listeners so that it can keep its - * enablement state up to date. Ordinarily, the window's references to these - * listeners will be dropped automatically when the window closes. However, - * if the client needs to get rid of an action while the window is still open, - * the client must call #dispose() to give the - * action an opportunity to deregister its listeners and to perform any other - * cleanup. - *

- * @noextend This class is not intended to be subclassed by clients. + * Open the new launch target wizard. */ -public class NewLaunchTargetWizardAction extends Action implements - ActionFactory.IWorkbenchAction { - /** - * The wizard dialog width - */ - private static final int SIZING_WIZARD_WIDTH = 500; - /** - * The wizard dialog height - */ - private static final int SIZING_WIZARD_HEIGHT = 500; - /** - * The title of the wizard window or null to use the default - * wizard window title. - */ - private String windowTitle = null; - /** - * The workbench window; or null if this - * action has been disposed. - */ - private IWorkbenchWindow workbenchWindow; - - /** - * Create a new instance of this class. - */ - public NewLaunchTargetWizardAction() { - super(WorkbenchMessages.NewWizardAction_text); - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window == null) { - throw new IllegalArgumentException(); - } - this.workbenchWindow = window; - // @issues should be IDE-specific images - ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); - setImageDescriptor(images - .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD)); - setDisabledImageDescriptor(images - .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED)); - setToolTipText(WorkbenchMessages.NewWizardAction_toolTip); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, - IWorkbenchHelpContextIds.NEW_ACTION); - } - - /** - *

- * Sets the title of the wizard window - *

- * - *

- * If the title of the wizard window is null, the default - * wizard window title will be used. - *

- * - * @param windowTitle - * The title of the wizard window, otherwise null - * (default wizard window title). - * - * @since 3.6 - */ - public void setWizardWindowTitle(String windowTitle) { - this.windowTitle = windowTitle; - } +public class NewLaunchTargetWizardAction extends Action { @Override public void run() { - if (workbenchWindow == null) { - // action has been disposed - return; - } - NewLaunchTargetWizard wizard = new NewLaunchTargetWizard(); - wizard.setWindowTitle(windowTitle); - wizard.init(workbenchWindow.getWorkbench(), null); - IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings(); - String settingsSection = getClass().getSimpleName(); - IDialogSettings wizardSettings = workbenchSettings.getSection(settingsSection); - if (wizardSettings == null) { - wizardSettings = workbenchSettings.addNewSection(settingsSection); - } - wizard.setDialogSettings(wizardSettings); - wizard.setForcePreviousAndNextButtons(true); - Shell parent = workbenchWindow.getShell(); - WizardDialog dialog = new WizardDialog(parent, wizard); - dialog.create(); - dialog.getShell().setSize( - Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), - SIZING_WIZARD_HEIGHT); - PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), - IWorkbenchHelpContextIds.NEW_WIZARD); - dialog.open(); + Wizard wizard = new NewLaunchTargetWizard(); + new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard).open(); } - @Override - public void dispose() { - if (workbenchWindow == null) { - // action has already been disposed - return; - } - workbenchWindow = null; - } } diff --git a/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProviderTest.java b/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProviderTest.java index f1211ff6627..f898541b011 100644 --- a/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProviderTest.java +++ b/tests/org.eclipse.launchbar.core.tests/src/org/eclipse/launchbar/core/PerTargetLaunchConfigProviderTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; @@ -27,7 +26,6 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.launchbar.core.internal.Activator; -import org.eclipse.launchbar.core.internal.LaunchBarManager2Test; import org.eclipse.launchbar.core.target.ILaunchTarget; import org.eclipse.launchbar.core.target.ILaunchTargetManager; import org.junit.After; @@ -54,7 +52,7 @@ public class PerTargetLaunchConfigProviderTest { null); localTarget = mock(ILaunchTarget.class); - doReturn("Local").when(localTarget).getName(); + doReturn("Local").when(localTarget).getId(); doReturn(ILaunchTargetManager.localLaunchTargetTypeId).when(localTarget).getTypeId(); doReturn(localTarget).when(targetManager).getLaunchTarget(ILaunchTargetManager.localLaunchTargetTypeId, "Local"); @@ -62,7 +60,7 @@ public class PerTargetLaunchConfigProviderTest { // other mocked remote connections otherTarget = mock(ILaunchTarget.class); doReturn("otherTargetType").when(otherTarget).getTypeId(); - doReturn("otherTarget").when(otherTarget).getName(); + doReturn("otherTarget").when(otherTarget).getId(); doReturn(otherTarget).when(targetManager).getLaunchTarget("otherTargetType", "otherTarget"); doReturn(new ILaunchTarget[] { localTarget, otherTarget }).when(targetManager).getLaunchTargets(); @@ -94,7 +92,7 @@ public class PerTargetLaunchConfigProviderTest { public class PerTargetLaunchConfigProvider1 extends PerTargetLaunchConfigProvider { public static final String CONNECTION_NAME_ATTR = "connectionName"; - private ILaunchBarManager manager; + private ILaunchBarManager manager = mock(ILaunchBarManager.class); @Override public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException { @@ -111,7 +109,7 @@ public class PerTargetLaunchConfigProviderTest { protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException { super.populateLaunchConfiguration(descriptor, target, workingCopy); - workingCopy.setAttribute(CONNECTION_NAME_ATTR, target.getName()); + workingCopy.setAttribute(CONNECTION_NAME_ATTR, target.getId()); } @Override @@ -122,9 +120,9 @@ public class PerTargetLaunchConfigProviderTest { @Override protected ILaunchTarget getLaunchTarget(ILaunchConfiguration configuration) throws CoreException { String name = configuration.getAttribute(CONNECTION_NAME_ATTR, ""); - if (localTarget.getName().equals(name)) { + if (localTarget.getId().equals(name)) { return localTarget; - } else if (otherTarget.getName().equals(name)) { + } else if (otherTarget.getId().equals(name)) { return otherTarget; } else { return null; @@ -133,9 +131,6 @@ public class PerTargetLaunchConfigProviderTest { @Override protected ILaunchBarManager getManager() { - if (manager == null) { - manager = mock(ILaunchBarManager.class); - } return manager; } @@ -230,7 +225,7 @@ public class PerTargetLaunchConfigProviderTest { ILaunchConfiguration launchConfiguration1 = provider.getLaunchConfiguration(descriptor, localTarget); assertNotNull(launchConfiguration1); ILaunchConfigurationWorkingCopy wc = launchConfiguration1.getWorkingCopy(); - wc.setAttribute(PerTargetLaunchConfigProvider1.CONNECTION_NAME_ATTR, otherTarget.getName()); + wc.setAttribute(PerTargetLaunchConfigProvider1.CONNECTION_NAME_ATTR, otherTarget.getId()); wc.doSave(); provider.launchConfigurationChanged(launchConfiguration1); // provider.launchConfigurationChanged(lc3); @@ -244,13 +239,15 @@ public class PerTargetLaunchConfigProviderTest { ILaunchConfiguration launchConfiguration1 = provider.getLaunchConfiguration(descriptor, localTarget); assertNotNull(launchConfiguration1); ILaunchConfigurationWorkingCopy wc = launchConfiguration1.getWorkingCopy(); - wc.setAttribute(LaunchBarManager2Test.ATTR_ORIGINAL_NAME, "bla"); + wc.rename("blah"); launchConfiguration1 = wc.doSave(); provider.launchConfigurationChanged(launchConfiguration1); - // we should have lost ownership - assertFalse(provider.ownsLaunchConfiguration(launchConfiguration1)); - verify(provider.manager).launchConfigurationRemoved(launchConfiguration1); - verify(provider.manager).launchConfigurationAdded(launchConfiguration1); + // we should still maintain ownership on a rename + assertTrue(provider.ownsLaunchConfiguration(launchConfiguration1)); + // provider not hooked up properly to verify these. + // TODO not sure this test is valid as a result + // verify(provider.manager).launchConfigurationAdded(launchConfiguration1); + // verify(provider.manager).launchConfigurationRemoved(launchConfiguration1); // have to fake out the remove provider.launchConfigurationRemoved(launchConfiguration1); ILaunchConfiguration launchConfiguration2 = provider.getLaunchConfiguration(descriptor, localTarget);