mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Combine Mode and Type into a single page for new configs.
Change-Id: Ic8c6a4580ecd7dcb4435b204c10f37703ad1443a
This commit is contained in:
parent
36555cd219
commit
bc661996aa
4 changed files with 216 additions and 53 deletions
|
@ -19,28 +19,25 @@ import org.eclipse.debug.core.ILaunchConfiguration;
|
|||
import org.eclipse.debug.core.ILaunchConfigurationListener;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchMode;
|
||||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.wizard.IWizardContainer;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.launchbar.ui.internal.Activator;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigEditPage;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigModePage;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigTypePage;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.launchbar.ui.internal.dialogs.NewLaunchConfigTypePage2;
|
||||
|
||||
public class NewLaunchConfigWizard extends Wizard implements ILaunchConfigurationListener {
|
||||
|
||||
private NewLaunchConfigModePage modePage = new NewLaunchConfigModePage();
|
||||
private NewLaunchConfigTypePage typePage = new NewLaunchConfigTypePage();
|
||||
private NewLaunchConfigEditPage editPage = new NewLaunchConfigEditPage();
|
||||
private NewLaunchConfigTypePage2 typePage;
|
||||
private NewLaunchConfigEditPage editPage;
|
||||
|
||||
private List<ILaunchConfiguration> configsToDelete = new ArrayList<>();
|
||||
|
||||
public NewLaunchConfigWizard() {
|
||||
editPage = new NewLaunchConfigEditPage();
|
||||
typePage = new NewLaunchConfigTypePage2(editPage);
|
||||
|
||||
setWindowTitle(Messages.NewLaunchConfigWizard_0);
|
||||
|
||||
// while the wizard is open, some ill behaved launch config tabs save the working copy.
|
||||
|
@ -50,46 +47,6 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio
|
|||
DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPageControls(Composite pageContainer) {
|
||||
super.createPageControls(pageContainer);
|
||||
|
||||
// Link the pages
|
||||
SelectionListener modePageListener = new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
ILaunchGroup selectedGroup = modePage.getSelectedGroup();
|
||||
typePage.setLaunchGroup(selectedGroup);
|
||||
editPage.setLaunchGroup(selectedGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
widgetSelected(e);
|
||||
getContainer().showPage(modePage.getNextPage());
|
||||
}
|
||||
};
|
||||
modePage.addGroupSelectionListener(modePageListener);
|
||||
modePageListener.widgetSelected(null);
|
||||
|
||||
SelectionListener typePageListener = new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
editPage.setLaunchConfigType(typePage.getSelectedType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
widgetSelected(e);
|
||||
getContainer().showPage(typePage.getNextPage());
|
||||
}
|
||||
};
|
||||
typePage.addTypeSelectionListener(typePageListener);
|
||||
typePageListener.widgetSelected(null);
|
||||
|
||||
editPage.setLaunchConfigType(typePage.getSelectedType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContainer(IWizardContainer wizardContainer) {
|
||||
super.setContainer(wizardContainer);
|
||||
|
@ -102,7 +59,6 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio
|
|||
|
||||
@Override
|
||||
public void addPages() {
|
||||
addPage(modePage);
|
||||
addPage(typePage);
|
||||
addPage(editPage);
|
||||
}
|
||||
|
@ -120,8 +76,9 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio
|
|||
}
|
||||
|
||||
public ILaunchMode getLaunchMode() {
|
||||
String initMode = modePage.getSelectedGroup().getMode();
|
||||
return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(initMode);
|
||||
// TODO we want to make sure the newly created config has the right mode
|
||||
// selected in the launch bar
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,10 @@ public class Messages extends NLS {
|
|||
public static String NewLaunchConfigTypePage_0;
|
||||
public static String NewLaunchConfigTypePage_1;
|
||||
public static String NewLaunchConfigTypePage_2;
|
||||
|
||||
public static String NewLaunchConfigTypePage2_Mode;
|
||||
|
||||
public static String NewLaunchConfigTypePage2_Type;
|
||||
public static String NewLaunchConfigWizard_0;
|
||||
|
||||
public static String NewLaunchTargetWizard_Title;
|
||||
|
|
|
@ -0,0 +1,200 @@
|
|||
/*******************************************************************************
|
||||
* 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.dialogs;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.launchbar.ui.internal.Messages;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
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.Group;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
|
||||
public class NewLaunchConfigTypePage2 extends WizardPage {
|
||||
|
||||
private final NewLaunchConfigEditPage editPage;
|
||||
|
||||
private Table modeTable;
|
||||
private Table typeTable;
|
||||
|
||||
public NewLaunchConfigTypePage2(NewLaunchConfigEditPage editPage) {
|
||||
super(NewLaunchConfigTypePage2.class.getName());
|
||||
this.editPage = editPage;
|
||||
setTitle(Messages.NewLaunchConfigTypePage_1);
|
||||
setDescription(Messages.NewLaunchConfigTypePage_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
comp.setLayout(new GridLayout());
|
||||
|
||||
Group modeGroup = new Group(comp, SWT.NONE);
|
||||
modeGroup.setText(Messages.NewLaunchConfigTypePage2_Mode);
|
||||
modeGroup.setLayout(new GridLayout());
|
||||
modeGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
|
||||
modeTable = new Table(modeGroup, SWT.SINGLE | SWT.BORDER);
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
data.heightHint = 100;
|
||||
modeTable.setLayoutData(data);
|
||||
modeTable.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
modeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
Group typeGroup = new Group(comp, SWT.NONE);
|
||||
typeGroup.setText(Messages.NewLaunchConfigTypePage2_Type);
|
||||
typeGroup.setLayout(new GridLayout());
|
||||
typeGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
typeTable = new Table(typeGroup, SWT.SINGLE | SWT.BORDER);
|
||||
typeTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
typeTable.addSelectionListener(new SelectionListener() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
typeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
widgetSelected(e);
|
||||
getContainer().showPage(getNextPage());
|
||||
}
|
||||
});
|
||||
|
||||
populateMode();
|
||||
|
||||
setControl(comp);
|
||||
}
|
||||
|
||||
private void populateMode() {
|
||||
int select = -1;
|
||||
|
||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
||||
if (group.getMode().equals("run")) { //$NON-NLS-1$
|
||||
if (createModeItem(modeTable, group)) {
|
||||
select++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
||||
if (group.getMode().equals("debug")) { //$NON-NLS-1$
|
||||
if (createModeItem(modeTable, group)) {
|
||||
select++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ILaunchGroup group : DebugUITools.getLaunchGroups()) {
|
||||
if (!group.getMode().equals("run") && !group.getMode().equals("debug")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
createModeItem(modeTable, group);
|
||||
}
|
||||
}
|
||||
|
||||
if (select >= 0) {
|
||||
modeTable.select(select);
|
||||
modeChanged();
|
||||
} else if (modeTable.getItemCount() > 0) {
|
||||
modeTable.select(0);
|
||||
modeChanged();
|
||||
} else {
|
||||
setPageComplete(false);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean createModeItem(Table table, ILaunchGroup group) {
|
||||
if (group.getCategory() != null || !group.isPublic())
|
||||
return false;
|
||||
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
item.setText(group.getLabel().replace("&", "")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
ImageDescriptor imageDesc = group.getImageDescriptor();
|
||||
if (imageDesc != null) {
|
||||
item.setImage(imageDesc.createImage());
|
||||
}
|
||||
item.setData(group);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void modeChanged() {
|
||||
TableItem[] selection = modeTable.getSelection();
|
||||
if (selection.length == 0) {
|
||||
editPage.setLaunchGroup(null);
|
||||
setPageComplete(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ILaunchGroup group = (ILaunchGroup) selection[0].getData();
|
||||
editPage.setLaunchGroup(group);
|
||||
|
||||
ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
|
||||
Arrays.sort(types, new Comparator<ILaunchConfigurationType>() {
|
||||
@Override
|
||||
public int compare(ILaunchConfigurationType type0, ILaunchConfigurationType type1) {
|
||||
int comp = type0.getPluginIdentifier().compareTo(type1.getPluginIdentifier());
|
||||
if (comp != 0) {
|
||||
return comp;
|
||||
} else {
|
||||
return type0.getName().compareTo(type1.getName());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
typeTable.removeAll();
|
||||
for (ILaunchConfigurationType type : types) {
|
||||
if (!type.isPublic() || type.getCategory() != null || !type.supportsMode(group.getMode()))
|
||||
continue;
|
||||
|
||||
TableItem item = new TableItem(typeTable, SWT.NONE);
|
||||
item.setText(type.getName());
|
||||
ImageDescriptor imageDesc = DebugUITools.getDefaultImageDescriptor(type);
|
||||
if (imageDesc != null)
|
||||
item.setImage(imageDesc.createImage());
|
||||
item.setData(type);
|
||||
}
|
||||
|
||||
if (typeTable.getItemCount() > 0) {
|
||||
typeTable.select(0);
|
||||
typeChanged();
|
||||
} else {
|
||||
setPageComplete(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void typeChanged() {
|
||||
TableItem[] selection = typeTable.getSelection();
|
||||
if (selection.length == 0) {
|
||||
editPage.setLaunchConfigType(null);
|
||||
setPageComplete(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ILaunchConfigurationType type = (ILaunchConfigurationType) selection[0].getData();
|
||||
editPage.setLaunchConfigType(type);
|
||||
setPageComplete(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,9 @@ NewLaunchConfigModePage_1=Initial Launch Mode
|
|||
NewLaunchConfigModePage_2=Select initial launch mode.
|
||||
NewLaunchConfigTypePage_0=Select Launch Configuration Type
|
||||
NewLaunchConfigTypePage_1=Launch Configuration Type
|
||||
NewLaunchConfigTypePage_2=Select the type of launch configuration to create.
|
||||
NewLaunchConfigTypePage_2=Select the mode and type of the launch configuration to create.
|
||||
NewLaunchConfigTypePage2_Mode=Launch Mode
|
||||
NewLaunchConfigTypePage2_Type=Launch Configuration Type
|
||||
NewLaunchConfigWizard_0=Create Launch Configuration
|
||||
NewLaunchTargetWizard_Title=New Launch Target
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue