mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-07 00:05:53 +02:00
launchar: launch target wizard fixes
- removed hack with overloading wizard classes - added wizard contribution, so it can be bound to command or used without launchbar - removed hack with using category to identify launch target wizard - added more comments in schema - fixed hack when parsing wizard if they categorized Change-Id: I791679ef30c395db10ec2528a6e2b90370e56a75
This commit is contained in:
parent
99da8cee74
commit
ca538d05a5
6 changed files with 80 additions and 34 deletions
|
@ -72,13 +72,22 @@
|
||||||
</descriptorUI>
|
</descriptorUI>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<!-- Category for launch targets, wizard that creates a launch target should belong to this category -->
|
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.newWizards">
|
point="org.eclipse.ui.newWizards">
|
||||||
<category
|
<category
|
||||||
id="org.eclipse.launchbar.ui.targetWizards"
|
id="org.eclipse.launchbar.ui.targetWizards"
|
||||||
name="Launch Target">
|
name="Launch Targets">
|
||||||
</category>
|
</category>
|
||||||
|
<wizard
|
||||||
|
category="org.eclipse.launchbar.ui.targetWizards"
|
||||||
|
class="org.eclipse.launchbar.ui.internal.target.NewLaunchTargetWizard"
|
||||||
|
icon="icons/localTarget.png"
|
||||||
|
id="org.eclipse.launchbar.ui.superTargetWizard"
|
||||||
|
name="Launch Target"
|
||||||
|
project="false">
|
||||||
|
</wizard>
|
||||||
|
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
<meta.schema plugin="org.eclipse.launchbar.ui" id="launchTargetTypeUI" name="Launch Target Type UI"/>
|
<meta.schema plugin="org.eclipse.launchbar.ui" id="launchTargetTypeUI" name="Launch Target Type UI"/>
|
||||||
</appinfo>
|
</appinfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
[Enter description of this extension point.]
|
This extension point allow to contribute UI element for launch targets, specifically target label provider
|
||||||
|
and target creation wizard.
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
@ -74,6 +75,11 @@
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
<element name="wizard">
|
<element name="wizard">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Contribute a wizard that can create a launch target, normally it would be a wizard per target type.
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
<complexType>
|
<complexType>
|
||||||
<sequence>
|
<sequence>
|
||||||
<element ref="description" minOccurs="0" maxOccurs="1"/>
|
<element ref="description" minOccurs="0" maxOccurs="1"/>
|
||||||
|
@ -181,7 +187,19 @@ Since 3.0
|
||||||
<meta.section type="examples"/>
|
<meta.section type="examples"/>
|
||||||
</appinfo>
|
</appinfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
[Enter extension point usage example here.]
|
<extension
|
||||||
|
point="org.eclipse.launchbar.ui.launchTargetTypeUI">
|
||||||
|
<launchTargetTypeUI
|
||||||
|
id="com.qnx.tools.ide.target.qconn"
|
||||||
|
labelProvider="com.qnx.tools.ide.target.qconn.internal.ui.QConnLaunchTargetLabelProvider">
|
||||||
|
|
||||||
|
</launchTargetTypeUI>
|
||||||
|
<wizard
|
||||||
|
class="com.qnx.tools.ide.target.qconn.internal.ui.wizards.NewQconnTargetWizard"
|
||||||
|
id="com.qnx.tools.ide.target.qconn.ui.NewQNXTarget"
|
||||||
|
name="New QNX Target">
|
||||||
|
</wizard>
|
||||||
|
</extension>
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
|
|
@ -211,10 +211,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
||||||
MouseListener mouseListener = new MouseAdapter() {
|
MouseListener mouseListener = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(org.eclipse.swt.events.MouseEvent event) {
|
public void mouseUp(org.eclipse.swt.events.MouseEvent event) {
|
||||||
NewLaunchTargetWizardAction newWizardAction = new NewLaunchTargetWizardAction(
|
new NewLaunchTargetWizardAction().run();
|
||||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
|
|
||||||
targetUIManager.getLaunchTargetWizards());
|
|
||||||
newWizardAction.run();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.launchbar.ui.internal.target;
|
package org.eclipse.launchbar.ui.internal.target;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -88,8 +90,22 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager {
|
||||||
return wizards;
|
return wizards;
|
||||||
WizardsRegistryReader reader = new WizardsRegistryReader(Activator.PLUGIN_ID, "launchTargetTypeUI"); //$NON-NLS-1$
|
WizardsRegistryReader reader = new WizardsRegistryReader(Activator.PLUGIN_ID, "launchTargetTypeUI"); //$NON-NLS-1$
|
||||||
WizardCollectionElement wizardElements = reader.getWizardElements();
|
WizardCollectionElement wizardElements = reader.getWizardElements();
|
||||||
WizardCollectionElement otherCategory = (WizardCollectionElement) wizardElements.getChildren(null)[0];
|
List<IWizardDescriptor> result = collectWizards(wizardElements, new ArrayList<>());
|
||||||
wizards = otherCategory.getWizards();
|
wizards = result.toArray(new IWizardDescriptor[result.size()]);
|
||||||
return wizards;
|
return wizards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* we don't show categories we have to flatten the wizards */
|
||||||
|
private List<IWizardDescriptor> collectWizards(WizardCollectionElement element, List<IWizardDescriptor> result) {
|
||||||
|
Object[] children = element.getChildren(null); // children are categories
|
||||||
|
IWizardDescriptor[] wizards = element.getWizards();
|
||||||
|
for (IWizardDescriptor desc : wizards) {
|
||||||
|
result.add(desc);
|
||||||
|
}
|
||||||
|
for (Object cat : children) {
|
||||||
|
WizardCollectionElement category = (WizardCollectionElement) cat;
|
||||||
|
collectWizards(category, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,18 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.launchbar.ui.internal.target;
|
package org.eclipse.launchbar.ui.internal.target;
|
||||||
|
|
||||||
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.wizard.IWizard;
|
import org.eclipse.jface.wizard.IWizard;
|
||||||
import org.eclipse.jface.wizard.Wizard;
|
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.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchWizard;
|
||||||
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
|
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
|
||||||
import org.eclipse.ui.internal.WorkbenchImages;
|
import org.eclipse.ui.internal.WorkbenchImages;
|
||||||
import org.eclipse.ui.internal.WorkbenchMessages;
|
import org.eclipse.ui.internal.WorkbenchMessages;
|
||||||
import org.eclipse.ui.internal.WorkbenchPlugin;
|
import org.eclipse.ui.internal.WorkbenchPlugin;
|
||||||
import org.eclipse.ui.wizards.IWizardCategory;
|
|
||||||
import org.eclipse.ui.wizards.IWizardDescriptor;
|
import org.eclipse.ui.wizards.IWizardDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,9 +29,10 @@ import org.eclipse.ui.wizards.IWizardDescriptor;
|
||||||
* (nested) wizard to run. The set of available new wizards comes from the new
|
* (nested) wizard to run. The set of available new wizards comes from the new
|
||||||
* extension point.
|
* extension point.
|
||||||
*/
|
*/
|
||||||
public class NewLaunchTargetWizard extends Wizard {
|
public class NewLaunchTargetWizard extends Wizard implements IWorkbenchWizard {
|
||||||
private NewLaunchTargetWizardSelectionPage mainPage;
|
private NewLaunchTargetWizardSelectionPage mainPage;
|
||||||
private IWorkbench workbench;
|
private IWorkbench workbench;
|
||||||
|
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the wizard pages
|
* Create the wizard pages
|
||||||
|
@ -40,11 +44,7 @@ public class NewLaunchTargetWizard extends Wizard {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWizardDescriptor[] getWizardDescriptors() {
|
public IWizardDescriptor[] getWizardDescriptors() {
|
||||||
IWizardCategory launchCategory = WorkbenchPlugin.getDefault().getNewWizardRegistry()
|
return targetUIManager.getLaunchTargetWizards();
|
||||||
.findCategory("org.eclipse.launchbar.ui.targetWizards"); //$NON-NLS-1$
|
|
||||||
if (launchCategory != null)
|
|
||||||
return launchCategory.getWizards();
|
|
||||||
return new IWizardDescriptor[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,6 +52,7 @@ public class NewLaunchTargetWizard extends Wizard {
|
||||||
* @param aWorkbench the workbench
|
* @param aWorkbench the workbench
|
||||||
* @param currentSelection the current selection
|
* @param currentSelection the current selection
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void init(IWorkbench aWorkbench,
|
public void init(IWorkbench aWorkbench,
|
||||||
IStructuredSelection currentSelection) {
|
IStructuredSelection currentSelection) {
|
||||||
this.workbench = aWorkbench;
|
this.workbench = aWorkbench;
|
||||||
|
@ -84,6 +85,21 @@ public class NewLaunchTargetWizard extends Wizard {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public boolean canFinish() {
|
public boolean canFinish() {
|
||||||
// we can finish if the first page is current and the the page can finish early.
|
// we can finish if the first page is current and the the page can finish early.
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.eclipse.ui.actions.*;
|
||||||
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
|
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
|
||||||
import org.eclipse.ui.internal.WorkbenchMessages;
|
import org.eclipse.ui.internal.WorkbenchMessages;
|
||||||
import org.eclipse.ui.internal.WorkbenchPlugin;
|
import org.eclipse.ui.internal.WorkbenchPlugin;
|
||||||
import org.eclipse.ui.wizards.IWizardDescriptor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke the resource creation wizard selection Wizard.
|
* Invoke the resource creation wizard selection Wizard.
|
||||||
|
@ -59,20 +58,17 @@ public class NewLaunchTargetWizardAction extends Action implements
|
||||||
* action has been <code>dispose</code>d.
|
* action has been <code>dispose</code>d.
|
||||||
*/
|
*/
|
||||||
private IWorkbenchWindow workbenchWindow;
|
private IWorkbenchWindow workbenchWindow;
|
||||||
private IWizardDescriptor[] desc;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of this class.
|
* Create a new instance of this class.
|
||||||
* @param window
|
|
||||||
* @param iWizardDescriptors
|
|
||||||
*/
|
*/
|
||||||
public NewLaunchTargetWizardAction(IWorkbenchWindow window, IWizardDescriptor[] desc) {
|
public NewLaunchTargetWizardAction() {
|
||||||
super(WorkbenchMessages.NewWizardAction_text);
|
super(WorkbenchMessages.NewWizardAction_text);
|
||||||
|
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
this.workbenchWindow = window;
|
this.workbenchWindow = window;
|
||||||
this.desc = desc;
|
|
||||||
// @issues should be IDE-specific images
|
// @issues should be IDE-specific images
|
||||||
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
|
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
|
||||||
setImageDescriptor(images
|
setImageDescriptor(images
|
||||||
|
@ -110,20 +106,14 @@ public class NewLaunchTargetWizardAction extends Action implements
|
||||||
// action has been disposed
|
// action has been disposed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NewLaunchTargetWizard wizard = new NewLaunchTargetWizard() {
|
NewLaunchTargetWizard wizard = new NewLaunchTargetWizard();
|
||||||
@Override
|
|
||||||
public IWizardDescriptor[] getWizardDescriptors() {
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
wizard.setWindowTitle(windowTitle);
|
wizard.setWindowTitle(windowTitle);
|
||||||
wizard.init(workbenchWindow.getWorkbench(), null);
|
wizard.init(workbenchWindow.getWorkbench(), null);
|
||||||
IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
|
IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
|
||||||
.getDialogSettings();
|
String settingsSection = getClass().getSimpleName();
|
||||||
IDialogSettings wizardSettings = workbenchSettings
|
IDialogSettings wizardSettings = workbenchSettings.getSection(settingsSection);
|
||||||
.getSection("NewLaunchTargetWizardAction"); //$NON-NLS-1$
|
|
||||||
if (wizardSettings == null) {
|
if (wizardSettings == null) {
|
||||||
wizardSettings = workbenchSettings.addNewSection("NewLaunchTargetWizardAction"); //$NON-NLS-1$
|
wizardSettings = workbenchSettings.addNewSection(settingsSection);
|
||||||
}
|
}
|
||||||
wizard.setDialogSettings(wizardSettings);
|
wizard.setDialogSettings(wizardSettings);
|
||||||
wizard.setForcePreviousAndNextButtons(true);
|
wizard.setForcePreviousAndNextButtons(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue