1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-08 19:13:27 +02:00

launchbar: open stanard eclipse launch configs dialog on edit

- when we click gear on launch descriptor we open a custom dialog,
there is no really need for it we can just open standard eclipse launch
configuration dialog and select configuration from the descriptor

Change-Id: I40f52baa5cc161a7281231600c29a4f5609733a5
This commit is contained in:
Alena Laskavaia 2016-01-14 13:58:34 -05:00
parent cd852c72c5
commit 7972418551
2 changed files with 4 additions and 171 deletions

View file

@ -26,12 +26,12 @@ import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.internal.LaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@ -135,15 +135,13 @@ public class ConfigureActiveLaunchHandler extends AbstractHandler {
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(desc, target);
ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(configType,
mode.getIdentifier());
LaunchGroupExtension groupExt = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
.getLaunchGroup(group.getIdentifier());
ILaunchConfiguration config = manager.getLaunchConfiguration(desc, target);
if (config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).isDirty()) {
config = ((ILaunchConfigurationWorkingCopy) config).doSave();
}
final LaunchConfigurationEditDialog dialog = new LaunchConfigurationEditDialog(shell, config, groupExt);
dialog.setInitialStatus(Status.OK_STATUS);
dialog.open();
// open real eclipse launch configurations dialog
DebugUIPlugin.openLaunchConfigurationsDialog(shell, new StructuredSelection(config),
group.getIdentifier(), false);
} catch (CoreException e2) {
Activator.log(e2);
}

View file

@ -1,165 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 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:
* Doug Schaefer
*******************************************************************************/
package org.eclipse.launchbar.ui.internal.dialogs;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.launchbar.ui.internal.Activator;
import org.eclipse.launchbar.ui.internal.Messages;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
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.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
@SuppressWarnings("restriction")
public class LaunchConfigurationEditDialog extends LaunchConfigurationPropertiesDialog {
private static final int DELETE_ID = 64;
private static final int DUPLICATE_ID = 65;
private static final int LAUNCH_ID = 66;
public LaunchConfigurationEditDialog(Shell shell, ILaunchConfiguration launchConfiguration, LaunchGroupExtension group) {
super(shell, launchConfiguration, group);
}
@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
}
@Override
protected Control createButtonBar(Composite parent) {
// Clone super's implementation, removes the monitor since we don't run from here
// And adds in the left button bar.
Font font = parent.getFont();
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
composite.setFont(font);
// create help control if needed
if (isHelpAvailable()) {
createHelpControl(composite);
}
Composite leftButtonComp = new Composite(composite, SWT.NULL);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.numColumns = 0;
leftButtonComp.setLayout(layout);
leftButtonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
leftButtonComp.setFont(parent.getFont());
createButton(leftButtonComp, DELETE_ID, Messages.LaunchConfigurationEditDialog_0, false);
createButton(leftButtonComp, DUPLICATE_ID, Messages.LaunchConfigurationEditDialog_1, false);
// launch button text same as in eclipse LaunchConfigurationDialog - mode name
createButton(leftButtonComp, LAUNCH_ID, getLaunchButtonText(), false);
Composite mainButtonComp = new Composite(composite, SWT.NONE);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.numColumns = 0;
mainButtonComp.setLayout(layout);
mainButtonComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
mainButtonComp.setFont(parent.getFont());
createButton(mainButtonComp, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(mainButtonComp, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
return composite;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
// Do nothing since we now have the buttons created above.
}
@Override
protected void buttonPressed(int buttonId) {
switch (buttonId) {
case DELETE_ID:
ILaunchConfiguration c = getLaunchConfiguration();
if (c.isWorkingCopy())
c = ((ILaunchConfigurationWorkingCopy)c).getOriginal();
final ILaunchConfiguration config = c;
if (MessageDialog.openConfirm(getShell(), Messages.LaunchConfigurationEditDialog_3,
Messages.LaunchConfigurationEditDialog_4 + config.getName())) {
new Job(Messages.LaunchConfigurationEditDialog_5) {
protected IStatus run(IProgressMonitor monitor) {
try {
config.delete();
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
};
}.schedule();
cancelPressed();
}
break;
case DUPLICATE_ID:
final ILaunchConfiguration original = getLaunchConfiguration();
final String newName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(original.getName());
final Shell shell = getParentShell();
final LaunchGroupExtension group = getLaunchGroup();
new UIJob(Messages.LaunchConfigurationEditDialog_6) {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
try {
final ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName);
final ILaunchConfiguration newConfig = newWorkingCopy.doSave();
new LaunchConfigurationEditDialog(shell, newConfig, group).open();
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
}.schedule();
cancelPressed();
break;
case LAUNCH_ID:
okPressed();
Activator.runCommand(Activator.CMD_LAUNCH);
break;
default:
super.buttonPressed(buttonId);
}
}
}