mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Bug 517813: Remove long since deprecated Multi Launch
The multi launch was moved to Eclipse platform 3 years ago, this change removes the now deprecated version that was in CDT. Change-Id: Ida3c4873b182a9e84955ac187ca9525703dc0298
This commit is contained in:
parent
2c94bb09a0
commit
d75b778f6f
7 changed files with 7 additions and 1649 deletions
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2005, 2010 QNX Software Systems and others.
|
||||
# Copyright (c) 2005, 2020 QNX Software Systems and others.
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License 2.0
|
||||
|
@ -17,8 +17,6 @@ providerName=Eclipse CDT
|
|||
|
||||
LocalCDTLaunch.name=Run Process
|
||||
LocalCDTLaunch.description=Execute the specified process
|
||||
LaunchGroup.name=Launch Group (Deprecated)
|
||||
LaunchGroup.description=This version of Launch Group is now deprecated, a newer and better one is now available as part of the Eclipse Platform.
|
||||
|
||||
MainLaunchTab.name=Main
|
||||
ArgumentsLaunchTab.name=Arguments
|
||||
|
|
|
@ -17,21 +17,10 @@
|
|||
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
|
||||
</launchDelegate>
|
||||
|
||||
<!-- Deprecated, See Bug 517722 -->
|
||||
<launchDelegate
|
||||
delegate="org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate"
|
||||
delegateDescription="%LaunchGroup.description"
|
||||
id="org.eclipse.cdt.launch.launchGroup.delegate"
|
||||
type="org.eclipse.cdt.launch.launchGroup"
|
||||
modes="run,debug,profile"
|
||||
name="%LaunchGroup.name"
|
||||
sourceLocatorId="org.eclipse.cdt.debug.core.sourceLocator"
|
||||
sourcePathComputerId="org.eclipse.cdt.debug.core.sourcePathComputer">
|
||||
</launchDelegate>
|
||||
</extension>
|
||||
|
||||
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabs">
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabs">
|
||||
<!-- Run launch tabs-->
|
||||
<tab
|
||||
id="org.eclipse.cdt.cdi.launch.runApplicationLaunch.mainTab"
|
||||
|
@ -72,50 +61,20 @@
|
|||
plugin="org.eclipse.cdt.launch"
|
||||
class="org.eclipse.cdt.launch.internal.ui.ProcessPrompter"
|
||||
id="org.eclipse.cdt.launch.statusHandler.processPrompter">
|
||||
</statusHandler>
|
||||
</statusHandler>
|
||||
<statusHandler
|
||||
class="org.eclipse.cdt.launch.internal.ui.BuildErrPrompter"
|
||||
code="1002"
|
||||
id="org.eclipse.cdt.launch.statusHandler.buildErrPrompter"
|
||||
plugin="org.eclipse.cdt.launch">
|
||||
</statusHandler>
|
||||
</statusHandler>
|
||||
<statusHandler
|
||||
class="org.eclipse.cdt.launch.internal.ui.BuildErrPrompter"
|
||||
code="1003"
|
||||
id="org.eclipse.cdt.launch.statusHandler.buildErrPrompter"
|
||||
plugin="org.eclipse.cdt.launch">
|
||||
</statusHandler>
|
||||
</statusHandler>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.debug.core.launchConfigurationTypes">
|
||||
<!-- Deprecated, See Bug 517722 -->
|
||||
<launchConfigurationType
|
||||
id="org.eclipse.cdt.launch.launchGroup"
|
||||
name="%LaunchGroup.name"
|
||||
public="true">
|
||||
</launchConfigurationType>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
|
||||
<!-- Deprecated, See Bug 517722 -->
|
||||
<launchConfigurationTabGroup
|
||||
class="org.eclipse.cdt.launch.internal.ui.MultiLaunchConfigurationTabGroup"
|
||||
id="org.eclipse.cdt.launch.launchGroup.tabgroup"
|
||||
type="org.eclipse.cdt.launch.launchGroup">
|
||||
</launchConfigurationTabGroup>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.launchConfigurationTypeImages">
|
||||
<!-- Deprecated, See Bug 517722 -->
|
||||
<launchConfigurationTypeImage
|
||||
icon="icons/obj16/exec_obj.gif"
|
||||
configTypeID="org.eclipse.cdt.launch.launchGroup"
|
||||
id="org.eclipse.cdt.launch.launchGroup.image">
|
||||
</launchConfigurationTypeImage>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ltk.core.refactoring.renameParticipants">
|
||||
<renameParticipant
|
||||
|
|
|
@ -1,600 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2016 QNX Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Freescale Semiconductor
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
|
||||
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.core.ILaunchesListener2;
|
||||
import org.eclipse.debug.core.Launch;
|
||||
import org.eclipse.debug.core.model.IProcess;
|
||||
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
|
||||
import org.eclipse.debug.internal.core.DebugCoreMessages;
|
||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.activities.WorkbenchActivityHelper;
|
||||
|
||||
/**
|
||||
* Group Launch delegate. Launches each configuration in the user selected mode
|
||||
* @deprecated See Bug 517722, Launch Groups are now part of Platform.
|
||||
*/
|
||||
@Deprecated
|
||||
public class MultiLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
|
||||
public static final String DEFAULT_MODE = "default"; //$NON-NLS-1$
|
||||
private static final String NAME_PROP = "name"; //$NON-NLS-1$
|
||||
private static final String ENABLED_PROP = "enabled"; //$NON-NLS-1$
|
||||
private static final String MODE_PROP = "mode"; //$NON-NLS-1$
|
||||
private static final String ACTION_PROP = "action"; //$NON-NLS-1$
|
||||
private static final String ACTION_PARAM_PROP = "actionParam"; //$NON-NLS-1$
|
||||
public static String MULTI_LAUNCH_CONSTANTS_PREFIX = "org.eclipse.cdt.launch.launchGroup"; //$NON-NLS-1$
|
||||
|
||||
public static class LaunchElement {
|
||||
public static enum EPostLaunchAction {
|
||||
NONE, WAIT_FOR_TERMINATION, DELAY
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows us decouple the enum identifier in the code from its textual representation in the GUI
|
||||
*/
|
||||
public static String actionEnumToStr(EPostLaunchAction action) {
|
||||
switch (action) {
|
||||
case NONE:
|
||||
return LaunchMessages.MultiLaunchConfigurationDelegate_Action_None;
|
||||
case WAIT_FOR_TERMINATION:
|
||||
return LaunchMessages.MultiLaunchConfigurationDelegate_Action_WaitUntilTerminated;
|
||||
case DELAY:
|
||||
return LaunchMessages.MultiLaunchConfigurationDelegate_Action_Delay;
|
||||
default:
|
||||
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||
return LaunchMessages.MultiLaunchConfigurationDelegate_Action_None;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows us decouple the enum identifier in the code from its textual representation in the GUI
|
||||
*/
|
||||
public static EPostLaunchAction strToActionEnum(String str) {
|
||||
if (str.equals(LaunchMessages.MultiLaunchConfigurationDelegate_Action_None)) {
|
||||
return EPostLaunchAction.NONE;
|
||||
} else if (str.equals(LaunchMessages.MultiLaunchConfigurationDelegate_Action_WaitUntilTerminated)) {
|
||||
return EPostLaunchAction.WAIT_FOR_TERMINATION;
|
||||
} else if (str.equals(LaunchMessages.MultiLaunchConfigurationDelegate_Action_Delay)) {
|
||||
return EPostLaunchAction.DELAY;
|
||||
} else {
|
||||
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||
return EPostLaunchAction.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
public int index;
|
||||
public boolean enabled;
|
||||
public String mode;
|
||||
public EPostLaunchAction action;
|
||||
public Object actionParam;
|
||||
public String name;
|
||||
public ILaunchConfiguration data;
|
||||
}
|
||||
|
||||
public MultiLaunchConfigurationDelegate() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialization of launch to track sublaunches lifecycle, also terminates itself when all sublaunches are terminated
|
||||
*
|
||||
*/
|
||||
private class MultiLaunch extends Launch implements ILaunchesListener2 {
|
||||
|
||||
/**
|
||||
* Whether this process has been terminated
|
||||
*/
|
||||
private boolean fTerminated;
|
||||
|
||||
/**
|
||||
* A map of all our sub-launches and the current processes that belong
|
||||
* to each one.
|
||||
*/
|
||||
private Map<ILaunch, IProcess[]> subLaunches = new HashMap<>();
|
||||
|
||||
public MultiLaunch(ILaunchConfiguration launchConfiguration, String mode) {
|
||||
super(launchConfiguration, mode, null);
|
||||
getLaunchManager().addLaunchListener((ILaunchesListener2) this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate the launch
|
||||
* @param subLaunch
|
||||
*/
|
||||
public void addSubLaunch(ILaunch subLaunch) {
|
||||
subLaunches.put(subLaunch, new IProcess[] {});
|
||||
}
|
||||
|
||||
private ILaunch[] getSubLaunches() {
|
||||
return subLaunches.keySet().toArray(new ILaunch[subLaunches.keySet().size()]);
|
||||
}
|
||||
|
||||
private boolean isChild(ILaunch launch) {
|
||||
for (ILaunch subLaunch : getSubLaunches()) {
|
||||
if (subLaunch == launch) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default behavior by querying all sub-launches to see if they are terminated
|
||||
* @see org.eclipse.debug.core.Launch#isTerminated()
|
||||
*/
|
||||
@Override
|
||||
public boolean isTerminated() {
|
||||
if (fTerminated)
|
||||
return true;
|
||||
|
||||
if (subLaunches.size() == 0)
|
||||
return false;
|
||||
|
||||
for (ILaunch launch : getSubLaunches()) {
|
||||
if (!launch.isTerminated()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default behavior by querying all sub-launches if they can be terminated
|
||||
* @see org.eclipse.debug.core.Launch#canTerminate()
|
||||
*/
|
||||
@Override
|
||||
public boolean canTerminate() {
|
||||
if (subLaunches.size() == 0)
|
||||
return false;
|
||||
|
||||
for (ILaunch launch : getSubLaunches()) {
|
||||
if (launch.canTerminate()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override default behavior by terminating all sub-launches
|
||||
* @see org.eclipse.debug.core.Launch#terminate()
|
||||
*/
|
||||
@Override
|
||||
public void terminate() throws DebugException {
|
||||
MultiStatus status = new MultiStatus(DebugPlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED,
|
||||
DebugCoreMessages.Launch_terminate_failed, null);
|
||||
|
||||
for (ILaunch launch : getSubLaunches()) {
|
||||
if (launch.canTerminate()) {
|
||||
try {
|
||||
launch.terminate();
|
||||
} catch (DebugException e) {
|
||||
status.merge(e.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (status.isOK()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IStatus[] children = status.getChildren();
|
||||
if (children.length == 1) {
|
||||
throw new DebugException(children[0]);
|
||||
}
|
||||
|
||||
throw new DebugException(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle terminated sub-launch
|
||||
* @param launch
|
||||
*/
|
||||
private void launchTerminated(ILaunch launch) {
|
||||
if (this == launch)
|
||||
return;
|
||||
|
||||
// Remove sub launch, keeping the processes of the terminated launch to
|
||||
// show the association and to keep the console content accessible
|
||||
if (subLaunches.remove(launch) != null) {
|
||||
// terminate ourselves if this is the last sub launch
|
||||
if (subLaunches.size() == 0) {
|
||||
fTerminated = true;
|
||||
fireTerminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.Launch#launchChanged(org.eclipse.debug.core.ILaunch)
|
||||
*/
|
||||
@Override
|
||||
public void launchChanged(ILaunch launch) {
|
||||
if (this == launch)
|
||||
return;
|
||||
|
||||
// add/remove processes
|
||||
if (isChild(launch)) {
|
||||
// Remove old processes
|
||||
IProcess[] oldProcesses = subLaunches.get(launch);
|
||||
IProcess[] newProcesses = launch.getProcesses();
|
||||
|
||||
// avoid notifications when processes have not changed.
|
||||
if (!Arrays.equals(oldProcesses, newProcesses)) {
|
||||
for (IProcess oldProcess : oldProcesses) {
|
||||
removeProcess(oldProcess);
|
||||
}
|
||||
|
||||
// Add new processes
|
||||
for (IProcess newProcess : newProcesses) {
|
||||
addProcess(newProcess);
|
||||
}
|
||||
|
||||
// Replace the processes of the changed launch
|
||||
subLaunches.put(launch, newProcesses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.Launch#launchRemoved(org.eclipse.debug.core.ILaunch)
|
||||
*/
|
||||
@Override
|
||||
public void launchRemoved(ILaunch launch) {
|
||||
if (this == launch) {
|
||||
super.launchRemoved(launch);
|
||||
// Remove the processes we got from the sub-launches from this launch
|
||||
IProcess[] processes = getProcesses();
|
||||
for (IProcess process : processes) {
|
||||
removeProcess(process);
|
||||
}
|
||||
|
||||
getLaunchManager().removeLaunchListener((ILaunchesListener2) this);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.ILaunchesListener2#launchesTerminated(org.eclipse.debug.core.ILaunch[])
|
||||
*/
|
||||
@Override
|
||||
public void launchesTerminated(ILaunch[] launches) {
|
||||
for (ILaunch launch : launches) {
|
||||
launchTerminated(launch);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[])
|
||||
*/
|
||||
@Override
|
||||
public void launchesAdded(ILaunch[] launches) {
|
||||
for (ILaunch launch : launches) {
|
||||
launchAdded(launch);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
|
||||
*/
|
||||
@Override
|
||||
public void launchesChanged(ILaunch[] launches) {
|
||||
for (ILaunch launch : launches) {
|
||||
launchChanged(launch);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[])
|
||||
*/
|
||||
@Override
|
||||
public void launchesRemoved(ILaunch[] launches) {
|
||||
for (ILaunch launch : launches) {
|
||||
launchRemoved(launch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
|
||||
return new MultiLaunch(configuration, mode);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
||||
// Have to temporarily turn off the "remove terminated launches when new one created"
|
||||
// preference because it does not work well for multilaunch
|
||||
|
||||
final IPreferenceStore prefStore = DebugUIPlugin.getDefault().getPreferenceStore();
|
||||
boolean dstore = prefStore.getBoolean(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES);
|
||||
|
||||
try {
|
||||
monitor.beginTask(LaunchMessages.MultiLaunchConfigurationDelegate_0 + configuration.getName(), 1000);
|
||||
|
||||
prefStore.setValue(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, false);
|
||||
|
||||
List<LaunchElement> launches = createLaunchElements(configuration, new ArrayList<LaunchElement>());
|
||||
for (LaunchElement le : launches) {
|
||||
if (!le.enabled)
|
||||
continue;
|
||||
|
||||
// find launch; if not found, skip (error?)
|
||||
final ILaunchConfiguration conf = findLaunch(le.name);
|
||||
if (conf == null)
|
||||
continue;
|
||||
|
||||
// determine mode for each launch
|
||||
final String localMode;
|
||||
if (le.mode != null && !le.mode.equals(DEFAULT_MODE)) {
|
||||
localMode = le.mode;
|
||||
} else {
|
||||
localMode = mode;
|
||||
}
|
||||
if (!conf.supportsMode(localMode)) {
|
||||
PlatformUI.getWorkbench().getDisplay()
|
||||
.asyncExec(() -> MessageDialog.openError(
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
|
||||
LaunchMessages.LaunchUIPlugin_Error,
|
||||
NLS.bind(LaunchMessages.MultiLaunchConfigurationDelegate_Cannot, conf.toString(),
|
||||
localMode)));
|
||||
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (configuration.getName().equals(conf.getName()))
|
||||
throw new StackOverflowError();
|
||||
|
||||
// LAUNCH child here
|
||||
ILaunch subLaunch = DebugUIPlugin.buildAndLaunch(conf, localMode,
|
||||
new SubProgressMonitor(monitor, 1000 / launches.size()));
|
||||
((MultiLaunch) launch).addSubLaunch(subLaunch);
|
||||
|
||||
// Now that we added the launch in our list, we have already
|
||||
// received the real launchChanged event, and did not know it was part of our list
|
||||
// So, fake another event now.
|
||||
((MultiLaunch) launch).launchChanged(subLaunch);
|
||||
|
||||
//Now we need to override the history to make multi-launch appear last, if we
|
||||
//don't do it last launch would be our child's launch which is not correct
|
||||
//for repeating the experience
|
||||
DebugUIPlugin.getDefault().getLaunchConfigurationManager().setRecentLaunch(launch);
|
||||
|
||||
postLaunchAction(subLaunch, le.action, le.actionParam, monitor);
|
||||
|
||||
} catch (StackOverflowError e) {
|
||||
PlatformUI.getWorkbench().getDisplay()
|
||||
.asyncExec(() -> MessageDialog.openError(
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
|
||||
LaunchMessages.LaunchUIPlugin_Error,
|
||||
NLS.bind(LaunchMessages.MultiLaunchConfigurationDelegate_Loop, conf.toString())));
|
||||
}
|
||||
}
|
||||
if (!launch.hasChildren()) {
|
||||
DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
|
||||
}
|
||||
} finally {
|
||||
prefStore.setValue(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, dstore);
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
private void postLaunchAction(ILaunch subLaunch, EPostLaunchAction action, Object actionParam,
|
||||
IProgressMonitor monitor) {
|
||||
switch (action) {
|
||||
case NONE:
|
||||
return;
|
||||
case WAIT_FOR_TERMINATION:
|
||||
monitor.subTask(LaunchMessages.MultiLaunchConfigurationDelegate_Action_WaitingForTermination + " " //$NON-NLS-1$
|
||||
+ subLaunch.getLaunchConfiguration().getName());
|
||||
while (!subLaunch.isTerminated() && !monitor.isCanceled()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
monitor.subTask(""); //$NON-NLS-1$
|
||||
break;
|
||||
case DELAY:
|
||||
Integer waitSecs = (Integer) actionParam;
|
||||
if (waitSecs != null) {
|
||||
monitor.subTask(
|
||||
NLS.bind(LaunchMessages.MultiLaunchConfigurationDelegate_Action_Delaying, waitSecs.toString()));
|
||||
try {
|
||||
Thread.sleep(waitSecs * 1000); // param is milliseconds
|
||||
} catch (InterruptedException e) {
|
||||
// ok
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
assert false : "new post launch action type is missing logic"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#buildProjects(org.eclipse.core.resources.IProject[], org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
protected void buildProjects(IProject[] projects, IProgressMonitor monitor) throws CoreException {
|
||||
// do nothing, project can be rebuild for each launch individually
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#buildForLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// not build for this one
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static ILaunchConfiguration findLaunch(String name) throws CoreException {
|
||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
||||
ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations();
|
||||
for (int i = 0; i < launchConfigurations.length; i++) {
|
||||
ILaunchConfiguration lConf = launchConfigurations[i];
|
||||
if (lConf.getName().equals(name))
|
||||
return lConf;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<LaunchElement> createLaunchElements(ILaunchConfiguration configuration,
|
||||
List<MultiLaunchConfigurationDelegate.LaunchElement> input) {
|
||||
try {
|
||||
Map<?, ?> attrs = configuration.getAttributes();
|
||||
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
String attr = (String) iterator.next();
|
||||
try {
|
||||
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
||||
String prop = attr
|
||||
.substring(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX.length() + 1);
|
||||
int k = prop.indexOf('.');
|
||||
String num = prop.substring(0, k);
|
||||
int index = Integer.parseInt(num);
|
||||
String name = prop.substring(k + 1);
|
||||
if (name.equals(NAME_PROP)) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
||||
el.index = index;
|
||||
el.name = (String) attrs.get(attr);
|
||||
|
||||
Object actionParam = null;
|
||||
String actionStr = (String) attrs.get(getProp(index, ACTION_PROP));
|
||||
|
||||
EPostLaunchAction action;
|
||||
try {
|
||||
action = EPostLaunchAction.valueOf(actionStr);
|
||||
} catch (Exception e) {
|
||||
action = EPostLaunchAction.NONE;
|
||||
}
|
||||
if (action == EPostLaunchAction.DELAY) {
|
||||
try {
|
||||
actionParam = Integer
|
||||
.parseInt((String) attrs.get(getProp(index, ACTION_PARAM_PROP)));
|
||||
} catch (NumberFormatException exc) {
|
||||
LaunchUIPlugin.log(exc);
|
||||
}
|
||||
}
|
||||
el.action = action;
|
||||
el.actionParam = actionParam;
|
||||
el.mode = (String) attrs.get(getProp(index, MODE_PROP));
|
||||
el.enabled = Boolean.parseBoolean((String) attrs.get(getProp(index, ENABLED_PROP)));
|
||||
try {
|
||||
el.data = findLaunch(el.name);
|
||||
} catch (Exception e) {
|
||||
el.data = null;
|
||||
}
|
||||
while (index >= input.size()) {
|
||||
input.add(null);
|
||||
}
|
||||
input.set(index, el);
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LaunchUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
LaunchUIPlugin.log(e);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
public static void storeLaunchElements(ILaunchConfigurationWorkingCopy configuration, List<LaunchElement> input) {
|
||||
int i = 0;
|
||||
removeLaunchElements(configuration);
|
||||
for (LaunchElement el : input) {
|
||||
if (el == null)
|
||||
continue;
|
||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, NAME_PROP), el.name);
|
||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PROP), el.action.toString());
|
||||
// note: the saving of the action param will need to be enhanced if ever an action type is introduced that uses something that can't be reconstructed from its toString()
|
||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ACTION_PARAM_PROP),
|
||||
el.actionParam != null ? el.actionParam.toString() : null);
|
||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, MODE_PROP), el.mode);
|
||||
configuration.setAttribute(MultiLaunchConfigurationDelegate.getProp(i, ENABLED_PROP), el.enabled + ""); //$NON-NLS-1$
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeLaunchElements(ILaunchConfigurationWorkingCopy configuration) {
|
||||
try {
|
||||
Map<?, ?> attrs = configuration.getAttributes();
|
||||
for (Iterator<?> iterator = attrs.keySet().iterator(); iterator.hasNext();) {
|
||||
String attr = (String) iterator.next();
|
||||
try {
|
||||
if (attr.startsWith(MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX)) {
|
||||
configuration.removeAttribute(attr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LaunchUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
LaunchUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getProp(int index, String string) {
|
||||
return MultiLaunchConfigurationDelegate.MULTI_LAUNCH_CONSTANTS_PREFIX + "." + index + "." + string; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a launch configuration is a valid reference.
|
||||
* @param config configuration reference
|
||||
* @return <code>true</code> if it is a valid reference, <code>false</code> if launch configuration should be filtered
|
||||
*/
|
||||
public static boolean isValidLaunchReference(ILaunchConfiguration config) {
|
||||
return DebugUIPlugin.doLaunchConfigurationFiltering(config) && !WorkbenchActivityHelper.filterItem(config);
|
||||
}
|
||||
}
|
|
@ -164,40 +164,6 @@ public class LaunchMessages extends NLS {
|
|||
public static String LocalCDILaunchDelegate_8;
|
||||
public static String LocalCDILaunchDelegate_9;
|
||||
public static String LocalCDILaunchDelegate_10;
|
||||
public static String MultiLaunchConfigurationDelegate_0;
|
||||
public static String MultiLaunchConfigurationDelegate_Cannot;
|
||||
public static String MultiLaunchConfigurationDelegate_Loop;
|
||||
public static String MultiLaunchConfigurationDelegate_Action_None;
|
||||
public static String MultiLaunchConfigurationDelegate_Action_WaitUntilTerminated;
|
||||
public static String MultiLaunchConfigurationDelegate_Action_Delay;
|
||||
public static String MultiLaunchConfigurationDelegate_Action_WaitingForTermination;
|
||||
public static String MultiLaunchConfigurationDelegate_Action_Delaying;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_0;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_4;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_5;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_7;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_8;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_9;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_10;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_11;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_12;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_13;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_14;
|
||||
public static String MultiLaunchConfigurationSelectionDialog_15;
|
||||
public static String MultiLaunchConfigurationTabGroup_1;
|
||||
public static String MultiLaunchConfigurationTabGroup_2;
|
||||
public static String MultiLaunchConfigurationTabGroup_3;
|
||||
public static String MultiLaunchConfigurationTabGroup_4;
|
||||
public static String MultiLaunchConfigurationTabGroup_5;
|
||||
public static String MultiLaunchConfigurationTabGroup_6;
|
||||
public static String MultiLaunchConfigurationTabGroup_7;
|
||||
public static String MultiLaunchConfigurationTabGroup_10;
|
||||
public static String MultiLaunchConfigurationTabGroup_11;
|
||||
public static String MultiLaunchConfigurationTabGroup_12;
|
||||
public static String MultiLaunchConfigurationTabGroup_13;
|
||||
public static String MultiLaunchConfigurationTabGroup_14;
|
||||
public static String MultiLaunchConfigurationTabGroup_15;
|
||||
public static String MultiLaunchConfigurationTabGroup_16;
|
||||
public static String ProjectRenameChange_name;
|
||||
public static String ProjectRenameChange_saveFailed;
|
||||
public static String BuildErrPrompter_error_in_specific_config;
|
||||
|
|
|
@ -187,40 +187,7 @@ LocalCDILaunchDelegate_7=Core file does not exist or is not readable.
|
|||
LocalCDILaunchDelegate_8=Error starting process.
|
||||
LocalCDILaunchDelegate_9=Eclipse runtime does not support working directory.
|
||||
LocalCDILaunchDelegate_10=Failed to set program arguments, environment or working directory.
|
||||
MultiLaunchConfigurationDelegate_0=Launching\u0020
|
||||
MultiLaunchConfigurationDelegate_Cannot=Cannot launch ''{0}'' in the ''{1}'' mode
|
||||
MultiLaunchConfigurationDelegate_Loop=Infinite loop detected for ''{0}'' configuration
|
||||
MultiLaunchConfigurationDelegate_Action_None=None
|
||||
MultiLaunchConfigurationDelegate_Action_WaitUntilTerminated=Wait until terminated
|
||||
MultiLaunchConfigurationDelegate_Action_Delay=Delay
|
||||
MultiLaunchConfigurationDelegate_Action_WaitingForTermination=Waiting for termination of
|
||||
MultiLaunchConfigurationDelegate_Action_Delaying=Delaying next launch by {0} seconds
|
||||
MultiLaunchConfigurationSelectionDialog_0=Launch Configuration Selector
|
||||
MultiLaunchConfigurationSelectionDialog_4=Launch Mode:
|
||||
MultiLaunchConfigurationSelectionDialog_5=Use default mode when launching
|
||||
MultiLaunchConfigurationSelectionDialog_7=Select a launch configuration
|
||||
MultiLaunchConfigurationSelectionDialog_8=Post launch action:
|
||||
MultiLaunchConfigurationSelectionDialog_9=Seconds:
|
||||
MultiLaunchConfigurationSelectionDialog_10=Enter valid number of seconds
|
||||
MultiLaunchConfigurationSelectionDialog_11=Select only one launch configuration
|
||||
MultiLaunchConfigurationSelectionDialog_12=Add Launch Configuration
|
||||
MultiLaunchConfigurationSelectionDialog_13=Edit Launch Configuration
|
||||
MultiLaunchConfigurationSelectionDialog_14=Add one or more launch configurations to the launch group
|
||||
MultiLaunchConfigurationSelectionDialog_15=Edit an existing entry in the launch group
|
||||
MultiLaunchConfigurationTabGroup_1=Up
|
||||
MultiLaunchConfigurationTabGroup_2=Down
|
||||
MultiLaunchConfigurationTabGroup_3=Edit...
|
||||
MultiLaunchConfigurationTabGroup_4=Add...
|
||||
MultiLaunchConfigurationTabGroup_5=Remove
|
||||
MultiLaunchConfigurationTabGroup_6=Name
|
||||
MultiLaunchConfigurationTabGroup_7=Mode
|
||||
MultiLaunchConfigurationTabGroup_10=Launches
|
||||
MultiLaunchConfigurationTabGroup_11=seconds
|
||||
MultiLaunchConfigurationTabGroup_12=Action
|
||||
MultiLaunchConfigurationTabGroup_13=Delay {0} seconds
|
||||
MultiLaunchConfigurationTabGroup_14=Launch {0} does not exist.
|
||||
MultiLaunchConfigurationTabGroup_15=Launch {0} is filtered.
|
||||
MultiLaunchConfigurationTabGroup_16=Must have at least one valid enabled launch.
|
||||
|
||||
ProjectRenameChange_name=Update launch configuration "{0}"
|
||||
ProjectRenameChange_saveFailed=Failed to save updated launch configuration "{0}"
|
||||
|
||||
|
|
|
@ -1,383 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2016 QNX Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Freescale Semiconductor
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.internal.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||
import org.eclipse.cdt.launch.ui.ComboControlledStackComposite;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.debug.core.ILaunchManager;
|
||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationFilteredTree;
|
||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
|
||||
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupFilter;
|
||||
import org.eclipse.debug.ui.ILaunchGroup;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
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.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.swt.SWT;
|
||||
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.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
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;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.ui.dialogs.FilteredTree;
|
||||
import org.eclipse.ui.dialogs.PatternFilter;
|
||||
|
||||
/**
|
||||
* Dialog to select launch configuration(s)
|
||||
* @deprecated See Bug 517722, Launch Groups are now part of Platform.
|
||||
*/
|
||||
@Deprecated
|
||||
public class MultiLaunchConfigurationSelectionDialog extends TitleAreaDialog implements ISelectionChangedListener {
|
||||
private ViewerFilter[] fFilters = null;
|
||||
private ISelection fSelection;
|
||||
private ILaunchGroup[] launchGroups;
|
||||
private String mode;
|
||||
private EPostLaunchAction action = EPostLaunchAction.NONE;
|
||||
private Object actionParam;
|
||||
private boolean isDefaultMode;
|
||||
private ViewerFilter emptyTypeFilter;
|
||||
private IStructuredSelection fInitialSelection;
|
||||
private ComboControlledStackComposite fStackComposite;
|
||||
private Label fDelayAmountLabel;
|
||||
private Text fDelayAmountWidget; // in seconds
|
||||
private boolean fForEditing; // true if dialog was opened to edit an entry, otherwise it was opened to add one
|
||||
|
||||
public MultiLaunchConfigurationSelectionDialog(Shell shell, String initMode, boolean forEditing) {
|
||||
super(shell);
|
||||
LaunchConfigurationManager manager = DebugUIPlugin.getDefault().getLaunchConfigurationManager();
|
||||
launchGroups = manager.getLaunchGroups();
|
||||
mode = initMode;
|
||||
fForEditing = forEditing;
|
||||
fFilters = null;
|
||||
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||
emptyTypeFilter = new ViewerFilter() {
|
||||
@Override
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (element instanceof ILaunchConfigurationType) {
|
||||
try {
|
||||
ILaunchConfigurationType type = (ILaunchConfigurationType) element;
|
||||
return getLaunchManager().getLaunchConfigurations(type).length > 0;
|
||||
} catch (CoreException e) {
|
||||
return false;
|
||||
}
|
||||
} else if (element instanceof ILaunchConfiguration) {
|
||||
return MultiLaunchConfigurationDelegate.isValidLaunchReference((ILaunchConfiguration) element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected ILaunchManager getLaunchManager() {
|
||||
return DebugPlugin.getDefault().getLaunchManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Control x = super.createContents(parent);
|
||||
validate();
|
||||
setErrorMessage(null);
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent2) {
|
||||
Composite comp = (Composite) super.createDialogArea(parent2);
|
||||
|
||||
// title bar
|
||||
getShell().setText(fForEditing ? LaunchMessages.MultiLaunchConfigurationSelectionDialog_13
|
||||
: LaunchMessages.MultiLaunchConfigurationSelectionDialog_12);
|
||||
|
||||
// dialog message area (not title bar)
|
||||
setTitle(fForEditing ? LaunchMessages.MultiLaunchConfigurationSelectionDialog_15
|
||||
: LaunchMessages.MultiLaunchConfigurationSelectionDialog_14);
|
||||
|
||||
fStackComposite = new ComboControlledStackComposite(comp, SWT.NONE);
|
||||
HashMap<String, ILaunchGroup> modes = new HashMap<>();
|
||||
for (ILaunchGroup launchGroup : launchGroups) {
|
||||
if (!modes.containsKey(launchGroup.getMode())) {
|
||||
modes.put(launchGroup.getMode(), launchGroup);
|
||||
}
|
||||
}
|
||||
if (this.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE)) {
|
||||
try {
|
||||
this.mode = "run"; //$NON-NLS-1$
|
||||
ILaunchConfiguration[] configs = getSelectedLaunchConfigurations();
|
||||
if (configs.length > 0) {
|
||||
// we care only about the first selected element
|
||||
for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
|
||||
String mode = iterator.next();
|
||||
if (configs[0].supportsMode(mode)) {
|
||||
this.mode = mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
for (Iterator<String> iterator = modes.keySet().iterator(); iterator.hasNext();) {
|
||||
String mode = iterator.next();
|
||||
ILaunchGroup launchGroup = modes.get(mode);
|
||||
LaunchConfigurationFilteredTree fTree = new LaunchConfigurationFilteredTree(
|
||||
fStackComposite.getStackParent(), SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER,
|
||||
new PatternFilter(), launchGroup, fFilters);
|
||||
String label = mode;
|
||||
fStackComposite.addItem(label, fTree);
|
||||
fTree.createViewControl();
|
||||
ViewerFilter[] filters = fTree.getViewer().getFilters();
|
||||
for (ViewerFilter viewerFilter : filters) {
|
||||
if (viewerFilter instanceof LaunchGroupFilter) {
|
||||
fTree.getViewer().removeFilter(viewerFilter);
|
||||
}
|
||||
}
|
||||
fTree.getViewer().addFilter(emptyTypeFilter);
|
||||
fTree.getViewer().addSelectionChangedListener(this);
|
||||
if (launchGroup.getMode().equals(this.mode)) {
|
||||
fStackComposite.setSelection(label);
|
||||
}
|
||||
if (fInitialSelection != null) {
|
||||
|
||||
fTree.getViewer().setSelection(fInitialSelection, true);
|
||||
}
|
||||
}
|
||||
fStackComposite.setLabelText(LaunchMessages.MultiLaunchConfigurationSelectionDialog_4);
|
||||
fStackComposite.pack();
|
||||
Rectangle bounds = fStackComposite.getBounds();
|
||||
// adjust size
|
||||
GridData data = ((GridData) fStackComposite.getLayoutData());
|
||||
if (data == null) {
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
fStackComposite.setLayoutData(data);
|
||||
}
|
||||
data.heightHint = Math.max(convertHeightInCharsToPixels(15), bounds.height);
|
||||
data.widthHint = Math.max(convertWidthInCharsToPixels(40), bounds.width);
|
||||
fStackComposite.getCombo().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
mode = ((Combo) e.widget).getText();
|
||||
}
|
||||
});
|
||||
// "Use default mode" checkbox. Use a parent composite to provide consistent left-side padding
|
||||
Composite checkboxComp = new Composite(comp, SWT.NONE);
|
||||
checkboxComp.setLayout(new GridLayout(1, false));
|
||||
checkboxComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Button checkBox = new Button(checkboxComp, SWT.CHECK);
|
||||
checkBox.setText(LaunchMessages.MultiLaunchConfigurationSelectionDialog_5);
|
||||
checkBox.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
isDefaultMode = ((Button) e.widget).getSelection();
|
||||
}
|
||||
});
|
||||
checkBox.setSelection(isDefaultMode);
|
||||
|
||||
createPostLaunchControl(comp);
|
||||
return comp;
|
||||
}
|
||||
|
||||
private void createPostLaunchControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
comp.setLayout(new GridLayout(4, false));
|
||||
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Label label = new Label(comp, SWT.NONE);
|
||||
label.setText(LaunchMessages.MultiLaunchConfigurationSelectionDialog_8);
|
||||
Combo combo = new Combo(comp, SWT.READ_ONLY);
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.NONE));
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.WAIT_FOR_TERMINATION));
|
||||
combo.add(LaunchElement.actionEnumToStr(EPostLaunchAction.DELAY));
|
||||
combo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
final String actionStr = ((Combo) e.widget).getText();
|
||||
action = MultiLaunchConfigurationDelegate.LaunchElement.strToActionEnum(actionStr);
|
||||
showHideDelayAmountWidgets();
|
||||
validate();
|
||||
}
|
||||
});
|
||||
combo.setText(MultiLaunchConfigurationDelegate.LaunchElement.actionEnumToStr(action));
|
||||
|
||||
fDelayAmountLabel = new Label(comp, SWT.NONE);
|
||||
fDelayAmountLabel.setText(LaunchMessages.MultiLaunchConfigurationSelectionDialog_9);
|
||||
|
||||
fDelayAmountWidget = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||
GridData gridData = new GridData();
|
||||
gridData.widthHint = convertWidthInCharsToPixels(8);
|
||||
fDelayAmountWidget.setLayoutData(gridData);
|
||||
fDelayAmountWidget.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
String text = ((Text) e.widget).getText();
|
||||
try {
|
||||
actionParam = Integer.valueOf(text);
|
||||
} catch (NumberFormatException exc) {
|
||||
actionParam = null;
|
||||
}
|
||||
validate();
|
||||
}
|
||||
});
|
||||
if (actionParam instanceof Integer) {
|
||||
fDelayAmountWidget.setText(((Integer) actionParam).toString());
|
||||
}
|
||||
|
||||
showHideDelayAmountWidgets();
|
||||
}
|
||||
|
||||
private void showHideDelayAmountWidgets() {
|
||||
final boolean visible = action == EPostLaunchAction.DELAY;
|
||||
fDelayAmountLabel.setVisible(visible);
|
||||
fDelayAmountWidget.setVisible(visible);
|
||||
}
|
||||
|
||||
public ILaunchConfiguration[] getSelectedLaunchConfigurations() {
|
||||
List<ILaunchConfiguration> configs = new ArrayList<>();
|
||||
if (fSelection != null && !fSelection.isEmpty()) {
|
||||
for (Iterator<?> iter = ((IStructuredSelection) fSelection).iterator(); iter.hasNext();) {
|
||||
Object selection = iter.next();
|
||||
if (selection instanceof ILaunchConfiguration) {
|
||||
configs.add((ILaunchConfiguration) selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return configs.toArray(new ILaunchConfiguration[configs.size()]);
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return isDefaultMode ? MultiLaunchConfigurationDelegate.DEFAULT_MODE : mode;
|
||||
}
|
||||
|
||||
public EPostLaunchAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public Object getActionParam() {
|
||||
return actionParam;
|
||||
}
|
||||
|
||||
public static MultiLaunchConfigurationSelectionDialog createDialog(Shell shell, String groupId,
|
||||
boolean forEditing) {
|
||||
return new MultiLaunchConfigurationSelectionDialog(shell, groupId, forEditing);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
|
||||
*/
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
|
||||
// This listener gets called for a selection change in the launch
|
||||
// configuration viewer embedded in the dialog. Problem is, there are
|
||||
// numerous viewers--one for each platform debug ILaunchGroup (run,
|
||||
// debug, profile). These viewers are stacked, so only one is ever
|
||||
// visible to the user. During initialization, we get a selection change
|
||||
// notification for every viewer. We need to ignore all but the one that
|
||||
// matters--the visible one.
|
||||
|
||||
Tree topTree = null;
|
||||
final Control topControl = fStackComposite.getTopControl();
|
||||
if (topControl instanceof FilteredTree) {
|
||||
final TreeViewer viewer = ((FilteredTree) topControl).getViewer();
|
||||
if (viewer != null) {
|
||||
topTree = viewer.getTree();
|
||||
}
|
||||
}
|
||||
if (topTree == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean selectionIsForVisibleViewer = false;
|
||||
final Object src = event.getSource();
|
||||
if (src instanceof Viewer) {
|
||||
final Control viewerControl = ((Viewer) src).getControl();
|
||||
if (viewerControl == topTree) {
|
||||
selectionIsForVisibleViewer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectionIsForVisibleViewer) {
|
||||
return;
|
||||
}
|
||||
|
||||
fSelection = event.getSelection();
|
||||
validate();
|
||||
}
|
||||
|
||||
protected void validate() {
|
||||
Button ok_button = getButton(IDialogConstants.OK_ID);
|
||||
boolean isValid = true;
|
||||
if (getSelectedLaunchConfigurations().length < 1) {
|
||||
setErrorMessage(LaunchMessages.MultiLaunchConfigurationSelectionDialog_7);
|
||||
isValid = false;
|
||||
} else {
|
||||
setErrorMessage(null);
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
if (fForEditing) {
|
||||
// must have only one selection
|
||||
if (getSelectedLaunchConfigurations().length > 1) {
|
||||
setErrorMessage(LaunchMessages.MultiLaunchConfigurationSelectionDialog_11);
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
if (action == EPostLaunchAction.DELAY) {
|
||||
isValid = (actionParam instanceof Integer) && ((Integer) actionParam > 0);
|
||||
setErrorMessage(isValid ? null : LaunchMessages.MultiLaunchConfigurationSelectionDialog_10);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok_button != null)
|
||||
ok_button.setEnabled(isValid);
|
||||
}
|
||||
|
||||
public void setInitialSelection(LaunchElement el) {
|
||||
action = el.action;
|
||||
actionParam = el.actionParam;
|
||||
isDefaultMode = el.mode.equals(MultiLaunchConfigurationDelegate.DEFAULT_MODE);
|
||||
fInitialSelection = new StructuredSelection(el.data);
|
||||
fSelection = fInitialSelection;
|
||||
}
|
||||
}
|
|
@ -1,549 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2012 QNX Software Systems and others.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License 2.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Freescale Semiconductor
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.launch.internal.ui;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate;
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement;
|
||||
import org.eclipse.cdt.launch.internal.MultiLaunchConfigurationDelegate.LaunchElement.EPostLaunchAction;
|
||||
import org.eclipse.cdt.launch.ui.CommonTabLite;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||
import org.eclipse.debug.internal.ui.DebugPluginImages;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
|
||||
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||
import org.eclipse.debug.ui.ILaunchConfigurationTab;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.BaseLabelProvider;
|
||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.CheckboxTreeViewer;
|
||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||
import org.eclipse.jface.viewers.ICheckStateProvider;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
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.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.Tree;
|
||||
import org.eclipse.swt.widgets.TreeColumn;
|
||||
import org.eclipse.swt.widgets.Widget;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
* Tab group for Launch Group.
|
||||
* @deprecated See Bug 517722, Launch Groups are now part of Platform.
|
||||
*/
|
||||
@Deprecated
|
||||
public class MultiLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
|
||||
static class ContentProvider implements ITreeContentProvider {
|
||||
protected List<LaunchElement> input;
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return getChildren(inputElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
input = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // nothing we can do about this
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
if (newInput instanceof List<?>)
|
||||
input = (List<LaunchElement>) newInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
return (parentElement == input) ? input.toArray() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
return (element == input) ? null : input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
return (element == input) ? (input.size() > 0) : false;
|
||||
}
|
||||
}
|
||||
|
||||
static class LabelProvider extends BaseLabelProvider implements ITableLabelProvider {
|
||||
@Override
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
if (!(element instanceof MultiLaunchConfigurationDelegate.LaunchElement))
|
||||
return null;
|
||||
if (columnIndex == 0) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
||||
if (el.data == null || !MultiLaunchConfigurationDelegate.isValidLaunchReference(el.data)) {
|
||||
Image errorImage = PlatformUI.getWorkbench().getSharedImages()
|
||||
.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
|
||||
return errorImage;
|
||||
}
|
||||
|
||||
try {
|
||||
String key = el.data.getType().getIdentifier();
|
||||
return DebugPluginImages.getImage(key);
|
||||
} catch (CoreException e) {
|
||||
Image errorImage = PlatformUI.getWorkbench().getSharedImages()
|
||||
.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
|
||||
return errorImage;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (!(element instanceof MultiLaunchConfigurationDelegate.LaunchElement))
|
||||
return null;
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) element;
|
||||
|
||||
// launch name
|
||||
if (columnIndex == 0) {
|
||||
try {
|
||||
return (el.data != null) ? el.data.getType().getName() + "::" + el.name : el.name; //$NON-NLS-1$
|
||||
} catch (CoreException e) {
|
||||
return el.name;
|
||||
}
|
||||
}
|
||||
|
||||
// launch mode
|
||||
if (columnIndex == 1)
|
||||
return el.mode;
|
||||
|
||||
// launch post action
|
||||
if (columnIndex == 2) {
|
||||
EPostLaunchAction action = el.action;
|
||||
switch (action) {
|
||||
case NONE:
|
||||
return ""; //$NON-NLS-1$
|
||||
case WAIT_FOR_TERMINATION:
|
||||
return LaunchMessages.MultiLaunchConfigurationDelegate_Action_WaitUntilTerminated;
|
||||
case DELAY:
|
||||
final Object actionParam = el.actionParam;
|
||||
return NLS.bind(LaunchMessages.MultiLaunchConfigurationTabGroup_13,
|
||||
actionParam instanceof Integer ? Integer.toString((Integer) actionParam) : "?"); //$NON-NLS-1$
|
||||
default:
|
||||
assert false : "new post launch action missing logic here"; //$NON-NLS-1$
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static class CheckStateProvider implements ICheckStateProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean isChecked(Object element) {
|
||||
if (element instanceof LaunchElement) {
|
||||
return ((LaunchElement) element).enabled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean isGrayed(Object element) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class ButtonComposite extends Composite implements SelectionListener {
|
||||
Button upButton;
|
||||
Button downButton;
|
||||
Button addButton;
|
||||
Button deleteButton;
|
||||
Button editButton;
|
||||
|
||||
public ButtonComposite(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
setLayout(new GridLayout());
|
||||
upButton = createPushButton(this, LaunchMessages.MultiLaunchConfigurationTabGroup_1);
|
||||
downButton = createPushButton(this, LaunchMessages.MultiLaunchConfigurationTabGroup_2);
|
||||
editButton = createPushButton(this, LaunchMessages.MultiLaunchConfigurationTabGroup_3);
|
||||
addButton = createPushButton(this, LaunchMessages.MultiLaunchConfigurationTabGroup_4);
|
||||
deleteButton = createPushButton(this, LaunchMessages.MultiLaunchConfigurationTabGroup_5);
|
||||
|
||||
}
|
||||
|
||||
protected void updateWidgetEnablement() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a push button.
|
||||
*
|
||||
* @param parent
|
||||
* the parent control
|
||||
* @param key
|
||||
* the resource name used to supply the button's label text
|
||||
* @return Button
|
||||
*/
|
||||
protected Button createPushButton(Composite parent, String key) {
|
||||
Button button = new Button(parent, SWT.PUSH);
|
||||
button.setText(key);
|
||||
button.setFont(parent.getFont());
|
||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
button.setLayoutData(data);
|
||||
button.addSelectionListener(this);
|
||||
return button;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
Widget widget = e.widget;
|
||||
if (widget == upButton) {
|
||||
upPressed();
|
||||
} else if (widget == downButton) {
|
||||
downPressed();
|
||||
} else if (widget == addButton) {
|
||||
addPressed();
|
||||
} else if (widget == deleteButton) {
|
||||
deletePressed();
|
||||
} else if (widget == editButton) {
|
||||
editPressed();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void addPressed();
|
||||
|
||||
protected abstract void editPressed();
|
||||
|
||||
protected abstract void deletePressed();
|
||||
|
||||
protected abstract void downPressed();
|
||||
|
||||
protected abstract void upPressed();
|
||||
}
|
||||
|
||||
static class GroupLaunchTab extends AbstractLaunchConfigurationTab {
|
||||
protected CheckboxTreeViewer treeViewer;
|
||||
protected List<LaunchElement> input = new ArrayList<>();
|
||||
private String mode;
|
||||
|
||||
public GroupLaunchTab(String mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
setControl(comp);
|
||||
//comp.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN));
|
||||
comp.setLayout(new GridLayout(2, false));
|
||||
treeViewer = new CheckboxTreeViewer(comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
Tree table = treeViewer.getTree();
|
||||
table.setFont(parent.getFont());
|
||||
treeViewer.setContentProvider(new ContentProvider());
|
||||
treeViewer.setLabelProvider(new LabelProvider());
|
||||
treeViewer.setCheckStateProvider(new CheckStateProvider());
|
||||
table.setHeaderVisible(true);
|
||||
table.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
TreeColumn col1 = new TreeColumn(table, SWT.NONE);
|
||||
col1.setText(LaunchMessages.MultiLaunchConfigurationTabGroup_6);
|
||||
col1.setWidth(300);
|
||||
TreeColumn col2 = new TreeColumn(table, SWT.NONE);
|
||||
col2.setText(LaunchMessages.MultiLaunchConfigurationTabGroup_7);
|
||||
col2.setWidth(100);
|
||||
TreeColumn col3 = new TreeColumn(table, SWT.NONE);
|
||||
col3.setText(LaunchMessages.MultiLaunchConfigurationTabGroup_12);
|
||||
col3.setWidth(100);
|
||||
|
||||
treeViewer.setInput(input);
|
||||
final ButtonComposite buts = new ButtonComposite(comp, SWT.NONE) {
|
||||
@Override
|
||||
protected void addPressed() {
|
||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog
|
||||
.createDialog(treeViewer.getControl().getShell(), mode, false);
|
||||
if (dialog.open() == Dialog.OK) {
|
||||
ILaunchConfiguration[] configs = dialog.getSelectedLaunchConfigurations();
|
||||
if (configs.length < 1)
|
||||
return;
|
||||
for (ILaunchConfiguration config : configs) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = new MultiLaunchConfigurationDelegate.LaunchElement();
|
||||
input.add(el);
|
||||
el.index = input.size() - 1;
|
||||
el.enabled = true;
|
||||
el.name = config.getName();
|
||||
el.data = config;
|
||||
el.mode = dialog.getMode();
|
||||
el.action = dialog.getAction();
|
||||
el.actionParam = dialog.getActionParam();
|
||||
treeViewer.refresh(true);
|
||||
treeViewer.setChecked(el, el.enabled);
|
||||
}
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWidgetEnablement() {
|
||||
downButton.setEnabled(isDownEnabled());
|
||||
upButton.setEnabled(isUpEnabled());
|
||||
|
||||
int selectionCount = getSelectionCount();
|
||||
editButton.setEnabled(selectionCount == 1);
|
||||
deleteButton.setEnabled(selectionCount > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void editPressed() {
|
||||
int index = getSingleSelectionIndex();
|
||||
if (index < 0)
|
||||
return;
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = input.get(index);
|
||||
MultiLaunchConfigurationSelectionDialog dialog = MultiLaunchConfigurationSelectionDialog
|
||||
.createDialog(treeViewer.getControl().getShell(), el.mode, true);
|
||||
if (MultiLaunchConfigurationDelegate.isValidLaunchReference(el.data)) {
|
||||
dialog.setInitialSelection(el);
|
||||
}
|
||||
if (dialog.open() == Dialog.OK) {
|
||||
ILaunchConfiguration[] confs = dialog.getSelectedLaunchConfigurations();
|
||||
if (confs.length < 0)
|
||||
return;
|
||||
assert confs.length == 1 : "invocation of the dialog for editing an entry sholdn't allow OK to be hit if the user chooses multiple launch configs in the dialog"; //$NON-NLS-1$
|
||||
el.name = confs[0].getName();
|
||||
el.data = confs[0];
|
||||
el.mode = dialog.getMode();
|
||||
el.action = dialog.getAction();
|
||||
el.actionParam = dialog.getActionParam();
|
||||
treeViewer.refresh(true);
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deletePressed() {
|
||||
int[] indices = getMultiSelectionIndices();
|
||||
if (indices.length < 1)
|
||||
return;
|
||||
// need to delete from high to low
|
||||
for (int i = indices.length - 1; i >= 0; i--) {
|
||||
input.remove(indices[i]);
|
||||
}
|
||||
treeViewer.refresh(true);
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the index of the selection if a single item is
|
||||
* selected. If zero or multiple are selected, -1 is
|
||||
* returned
|
||||
*/
|
||||
private int getSingleSelectionIndex() {
|
||||
StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
|
||||
if (sel.size() != 1)
|
||||
return -1;
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = ((MultiLaunchConfigurationDelegate.LaunchElement) sel
|
||||
.getFirstElement());
|
||||
return input.indexOf(el);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the indices of one or more selected items. Indices
|
||||
* are always returned in ascending order
|
||||
*/
|
||||
private int[] getMultiSelectionIndices() {
|
||||
StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
|
||||
List<Integer> indices = new ArrayList<>();
|
||||
|
||||
for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
|
||||
MultiLaunchConfigurationDelegate.LaunchElement el = (MultiLaunchConfigurationDelegate.LaunchElement) iter
|
||||
.next();
|
||||
indices.add(input.indexOf(el));
|
||||
|
||||
}
|
||||
int[] result = new int[indices.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i] = indices.get(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getSelectionCount() {
|
||||
return ((StructuredSelection) treeViewer.getSelection()).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void downPressed() {
|
||||
if (!isDownEnabled())
|
||||
return;
|
||||
int index = getSingleSelectionIndex();
|
||||
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||
input.set(index, input.get(index + 1));
|
||||
input.set(index + 1, x);
|
||||
treeViewer.refresh(true);
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
|
||||
protected boolean isDownEnabled() {
|
||||
final int index = getSingleSelectionIndex();
|
||||
return (index >= 0) && (index != input.size() - 1);
|
||||
}
|
||||
|
||||
protected boolean isUpEnabled() {
|
||||
return getSingleSelectionIndex() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void upPressed() {
|
||||
if (!isUpEnabled())
|
||||
return;
|
||||
int index = getSingleSelectionIndex();
|
||||
MultiLaunchConfigurationDelegate.LaunchElement x = input.get(index);
|
||||
input.set(index, input.get(index - 1));
|
||||
input.set(index - 1, x);
|
||||
treeViewer.refresh(true);
|
||||
updateWidgetEnablement();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
};
|
||||
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
buts.updateWidgetEnablement();
|
||||
}
|
||||
});
|
||||
|
||||
treeViewer.getTree().addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
buts.editPressed();
|
||||
}
|
||||
});
|
||||
|
||||
treeViewer.addCheckStateListener(new ICheckStateListener() {
|
||||
@Override
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
((LaunchElement) event.getElement()).enabled = event.getChecked();
|
||||
updateLaunchConfigurationDialog();
|
||||
}
|
||||
});
|
||||
buts.updateWidgetEnablement();
|
||||
GridData layoutData = new GridData(GridData.GRAB_VERTICAL);
|
||||
layoutData.verticalAlignment = SWT.BEGINNING;
|
||||
buts.setLayoutData(layoutData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return LaunchMessages.MultiLaunchConfigurationTabGroup_10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeFrom(ILaunchConfiguration configuration) {
|
||||
// replace the input from previously shown launch configurations
|
||||
input = MultiLaunchConfigurationDelegate.createLaunchElements(configuration,
|
||||
new ArrayList<LaunchElement>());
|
||||
if (treeViewer != null) {
|
||||
treeViewer.setInput(input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
|
||||
MultiLaunchConfigurationDelegate.storeLaunchElements(configuration, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
|
||||
// defaults is empty list
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(ILaunchConfiguration launchConfig) {
|
||||
setMessage(null);
|
||||
setErrorMessage(null);
|
||||
int validLaunches = 0;
|
||||
// test if each launch is valid
|
||||
for (LaunchElement element : input) {
|
||||
if (element.enabled) {
|
||||
if (element.data == null) {
|
||||
// error referencing invalid launch
|
||||
setErrorMessage(
|
||||
MessageFormat.format(LaunchMessages.MultiLaunchConfigurationTabGroup_14, element.name));
|
||||
return false;
|
||||
} else if (!MultiLaunchConfigurationDelegate.isValidLaunchReference(element.data)) {
|
||||
// error referencing invalid launch
|
||||
setErrorMessage(
|
||||
MessageFormat.format(LaunchMessages.MultiLaunchConfigurationTabGroup_15, element.name));
|
||||
return false;
|
||||
}
|
||||
validLaunches++;
|
||||
}
|
||||
}
|
||||
if (validLaunches < 1) {
|
||||
// must have at least one valid and enabled launch
|
||||
setErrorMessage(LaunchMessages.MultiLaunchConfigurationTabGroup_16);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public MultiLaunchConfigurationTabGroup() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
|
||||
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { //
|
||||
new GroupLaunchTab(mode), //
|
||||
new CommonTabLite() //
|
||||
};
|
||||
setTabs(tabs);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue