mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 14:45:25 +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>
|
||||
</extension>
|
||||
|
||||
<!-- Category for launch targets, wizard that creates a launch target should belong to this category -->
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.newWizards">
|
||||
<category
|
||||
id="org.eclipse.launchbar.ui.targetWizards"
|
||||
name="Launch Target">
|
||||
name="Launch Targets">
|
||||
</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>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
<meta.schema plugin="org.eclipse.launchbar.ui" id="launchTargetTypeUI" name="Launch Target Type UI"/>
|
||||
</appinfo>
|
||||
<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>
|
||||
</annotation>
|
||||
|
||||
|
@ -74,6 +75,11 @@
|
|||
</element>
|
||||
|
||||
<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>
|
||||
<sequence>
|
||||
<element ref="description" minOccurs="0" maxOccurs="1"/>
|
||||
|
@ -181,7 +187,19 @@ Since 3.0
|
|||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<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>
|
||||
</annotation>
|
||||
|
||||
|
|
|
@ -211,10 +211,7 @@ public class TargetSelector extends CSelector implements ILaunchTargetListener {
|
|||
MouseListener mouseListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseUp(org.eclipse.swt.events.MouseEvent event) {
|
||||
NewLaunchTargetWizardAction newWizardAction = new NewLaunchTargetWizardAction(
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
|
||||
targetUIManager.getLaunchTargetWizards());
|
||||
newWizardAction.run();
|
||||
new NewLaunchTargetWizardAction().run();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
*******************************************************************************/
|
||||
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;
|
||||
|
@ -88,8 +90,22 @@ public class LaunchTargetUIManager implements ILaunchTargetUIManager {
|
|||
return wizards;
|
||||
WizardsRegistryReader reader = new WizardsRegistryReader(Activator.PLUGIN_ID, "launchTargetTypeUI"); //$NON-NLS-1$
|
||||
WizardCollectionElement wizardElements = reader.getWizardElements();
|
||||
WizardCollectionElement otherCategory = (WizardCollectionElement) wizardElements.getChildren(null)[0];
|
||||
wizards = otherCategory.getWizards();
|
||||
List<IWizardDescriptor> result = collectWizards(wizardElements, new ArrayList<>());
|
||||
wizards = result.toArray(new IWizardDescriptor[result.size()]);
|
||||
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;
|
||||
|
||||
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.IWizardCategory;
|
||||
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
|
||||
* extension point.
|
||||
*/
|
||||
public class NewLaunchTargetWizard extends Wizard {
|
||||
public class NewLaunchTargetWizard extends Wizard implements IWorkbenchWizard {
|
||||
private NewLaunchTargetWizardSelectionPage mainPage;
|
||||
private IWorkbench workbench;
|
||||
private final ILaunchTargetUIManager targetUIManager = Activator.getService(ILaunchTargetUIManager.class);
|
||||
|
||||
/**
|
||||
* Create the wizard pages
|
||||
|
@ -40,11 +44,7 @@ public class NewLaunchTargetWizard extends Wizard {
|
|||
}
|
||||
|
||||
public IWizardDescriptor[] getWizardDescriptors() {
|
||||
IWizardCategory launchCategory = WorkbenchPlugin.getDefault().getNewWizardRegistry()
|
||||
.findCategory("org.eclipse.launchbar.ui.targetWizards"); //$NON-NLS-1$
|
||||
if (launchCategory != null)
|
||||
return launchCategory.getWizards();
|
||||
return new IWizardDescriptor[0];
|
||||
return targetUIManager.getLaunchTargetWizards();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,7 @@ public class NewLaunchTargetWizard extends Wizard {
|
|||
* @param aWorkbench the workbench
|
||||
* @param currentSelection the current selection
|
||||
*/
|
||||
@Override
|
||||
public void init(IWorkbench aWorkbench,
|
||||
IStructuredSelection currentSelection) {
|
||||
this.workbench = aWorkbench;
|
||||
|
@ -84,6 +85,21 @@ public class NewLaunchTargetWizard extends Wizard {
|
|||
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
|
||||
public boolean canFinish() {
|
||||
// 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.WorkbenchMessages;
|
||||
import org.eclipse.ui.internal.WorkbenchPlugin;
|
||||
import org.eclipse.ui.wizards.IWizardDescriptor;
|
||||
|
||||
/**
|
||||
* Invoke the resource creation wizard selection Wizard.
|
||||
|
@ -59,20 +58,17 @@ public class NewLaunchTargetWizardAction extends Action implements
|
|||
* action has been <code>dispose</code>d.
|
||||
*/
|
||||
private IWorkbenchWindow workbenchWindow;
|
||||
private IWizardDescriptor[] desc;
|
||||
|
||||
/**
|
||||
* Create a new instance of this class.
|
||||
* @param window
|
||||
* @param iWizardDescriptors
|
||||
*/
|
||||
public NewLaunchTargetWizardAction(IWorkbenchWindow window, IWizardDescriptor[] desc) {
|
||||
public NewLaunchTargetWizardAction() {
|
||||
super(WorkbenchMessages.NewWizardAction_text);
|
||||
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||
if (window == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.workbenchWindow = window;
|
||||
this.desc = desc;
|
||||
// @issues should be IDE-specific images
|
||||
ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
|
||||
setImageDescriptor(images
|
||||
|
@ -110,20 +106,14 @@ public class NewLaunchTargetWizardAction extends Action implements
|
|||
// action has been disposed
|
||||
return;
|
||||
}
|
||||
NewLaunchTargetWizard wizard = new NewLaunchTargetWizard() {
|
||||
@Override
|
||||
public IWizardDescriptor[] getWizardDescriptors() {
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
NewLaunchTargetWizard wizard = new NewLaunchTargetWizard();
|
||||
wizard.setWindowTitle(windowTitle);
|
||||
wizard.init(workbenchWindow.getWorkbench(), null);
|
||||
IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
|
||||
.getDialogSettings();
|
||||
IDialogSettings wizardSettings = workbenchSettings
|
||||
.getSection("NewLaunchTargetWizardAction"); //$NON-NLS-1$
|
||||
IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
|
||||
String settingsSection = getClass().getSimpleName();
|
||||
IDialogSettings wizardSettings = workbenchSettings.getSection(settingsSection);
|
||||
if (wizardSettings == null) {
|
||||
wizardSettings = workbenchSettings.addNewSection("NewLaunchTargetWizardAction"); //$NON-NLS-1$
|
||||
wizardSettings = workbenchSettings.addNewSection(settingsSection);
|
||||
}
|
||||
wizard.setDialogSettings(wizardSettings);
|
||||
wizard.setForcePreviousAndNextButtons(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue