1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Serial Flash Target and Launch. Clean up Generic Launch.

Adds target, launch classes, and launch bar support for targets
intended to upload their code to flash using a Serial Port. The
port is co-ordinated with the Serial Terminal so that the terminal
is paused during the upload.

Also cleaned up the Generic Launch so it's not using the
External Tools launch which has a number of UX issues. This
simplifies the settings and gives us more control. And it's made
reusable for the Serial Flash launch.

Change-Id: I31e9970243fbf1cf22d027bbdb892fde104dbefe
This commit is contained in:
Doug Schaefer 2017-11-13 15:25:52 -05:00
parent f1f9ddf0f7
commit 15c8bad95d
46 changed files with 2052 additions and 162 deletions

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.launch.serial-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1 @@
bin.includes = feature.xml

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.eclipse.cdt.launch.serial.feature"
label="Launch over Serial"
version="1.0.0.qualifier">
<description url="http://www.example.com/description">
[Enter Feature Description here.]
</description>
<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
</copyright>
<license url="http://www.example.com/license">
[Enter License Description here.]
</license>
<plugin
id="org.eclipse.cdt.launch.serial.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.cdt.launch.serial.core"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.launch.serial.core</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View file

@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Launch over Serial Core Plugin
Bundle-SymbolicName: org.eclipse.cdt.launch.serial.core;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Eclipse CDT
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.debug.core;bundle-version="3.11.0",
org.eclipse.launchbar.core;bundle-version="2.2.0",
org.eclipse.cdt.core;bundle-version="6.4.0",
org.eclipse.cdt.debug.core;bundle-version="8.3.0",
org.eclipse.cdt.native.serial;bundle-version="1.1.0"
Export-Package: org.eclipse.cdt.launch.serial
Bundle-Activator: org.eclipse.cdt.launch.serial.internal.Activator
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
delegate="org.eclipse.cdt.launch.serial.internal.SerialFlashLaunchConfigDelegate"
id="org.eclipse.cdt.launch.serial.launchConfigurationType"
modes="run"
name="Launch over Serial">
</launchConfigurationType>
</extension>
<extension
point="org.eclipse.launchbar.core.launchTargetTypes">
<launchTargetType
id="org.eclipse.cdt.launch.serial.core.serialFlashTarget"
provider="org.eclipse.cdt.launch.serial.SerialFlashLaunchTargetProvider">
</launchTargetType>
</extension>
<extension
point="org.eclipse.launchbar.core.launchBarContributions">
<configProvider
class="org.eclipse.cdt.launch.serial.internal.SerialFlashLaunchConfigProvider"
descriptorType="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
priority="10">
</configProvider>
</extension>
</plugin>

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* 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.cdt.launch.serial;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
import org.eclipse.launchbar.core.target.TargetStatus;
/**
* Launch Target used to flash images to a device over a serial port, usually
* USB serial.
*/
public class SerialFlashLaunchTargetProvider implements ILaunchTargetProvider {
public static final String TYPE_ID = "org.eclipse.cdt.launch.serial.core.serialFlashTarget"; //$NON-NLS-1$
public static final String ATTR_SERIAL_PORT = "org.eclipse.cdt.launch.serial.core.serialPort"; //$NON-NLS-1$
@Override
public void init(ILaunchTargetManager targetManager) {
// Nothing to do at init time
}
@Override
public TargetStatus getStatus(ILaunchTarget target) {
// Always OK
return TargetStatus.OK_STATUS;
}
}

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* 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.cdt.launch.serial.internal;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
public class Activator extends Plugin {
public static final String PLUGIN_ID = "org.eclipse.cdt.launch.serial.core"; //$NON-NLS-1$
private static Activator plugin;
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
public static void log(IStatus status) {
plugin.getLog().log(status);
}
}

View file

@ -0,0 +1,23 @@
/*******************************************************************************
* 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.cdt.launch.serial.internal;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.serial.internal.messages"; //$NON-NLS-1$
public static String SerialFlashLaunch_Pause;
public static String SerialFlashLaunch_Resume;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,67 @@
/*******************************************************************************
* 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.cdt.launch.serial.internal;
import java.io.IOException;
import org.eclipse.cdt.launch.serial.SerialFlashLaunchTargetProvider;
import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.TargetedLaunch;
public class SerialFlashLaunch extends TargetedLaunch {
private SerialPort serialPort;
private boolean wasOpen;
public SerialFlashLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator,
ILaunchTarget target) {
super(launchConfiguration, mode, target, locator);
String serialPortName = target.getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT, ""); //$NON-NLS-1$
if (!serialPortName.isEmpty()) {
serialPort = SerialPort.get(serialPortName);
}
DebugPlugin.getDefault().addDebugEventListener(this);
}
public void start() {
if (serialPort != null) {
wasOpen = serialPort.isOpen();
if (wasOpen) {
try {
serialPort.pause();
} catch (IOException e) {
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SerialFlashLaunch_Pause, e));
}
}
} else {
wasOpen = false;
}
}
@Override
public void handleDebugEvents(DebugEvent[] events) {
super.handleDebugEvents(events);
if (isTerminated() && wasOpen) {
try {
serialPort.resume();
} catch (IOException e) {
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.SerialFlashLaunch_Resume, e));
}
wasOpen = false;
}
}
}

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* 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.cdt.launch.serial.internal;
import org.eclipse.cdt.debug.core.launch.CoreBuildGenericLaunchConfigDelegate;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.ITargetedLaunch;
public class SerialFlashLaunchConfigDelegate extends CoreBuildGenericLaunchConfigDelegate {
public static final String TYPE_ID = "org.eclipse.cdt.launch.serial.launchConfigurationType"; //$NON-NLS-1$
@Override
public ITargetedLaunch getLaunch(ILaunchConfiguration configuration, String mode, ILaunchTarget target)
throws CoreException {
return new SerialFlashLaunch(configuration, mode, null, target);
}
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
// Start the launch (pause the serial port)
((SerialFlashLaunch) launch).start();
super.launch(configuration, mode, launch, monitor);
}
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* 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.cdt.launch.serial.internal;
import org.eclipse.cdt.debug.core.launch.CoreBuildGenericLaunchConfigProvider;
import org.eclipse.cdt.launch.serial.SerialFlashLaunchTargetProvider;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
public class SerialFlashLaunchConfigProvider extends CoreBuildGenericLaunchConfigProvider {
@Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
return target.getTypeId().equals(SerialFlashLaunchTargetProvider.TYPE_ID);
}
@Override
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
return DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurationType(SerialFlashLaunchConfigDelegate.TYPE_ID);
}
}

View file

@ -0,0 +1,9 @@
################################################################################
# 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
################################################################################
SerialFlashLaunch_Pause=Pausing serial port
SerialFlashLaunch_Resume=Resuming serial port

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.launch.serial.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View file

@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: org.eclipse.cdt.launch.serial.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.ui;bundle-version="3.109.0",
org.eclipse.debug.ui;bundle-version="3.12.50",
org.eclipse.launchbar.core;bundle-version="2.2.0",
org.eclipse.launchbar.ui;bundle-version="2.2.0",
org.eclipse.cdt.launch.serial.core;bundle-version="1.0.0",
org.eclipse.cdt.native.serial;bundle-version="1.1.0",
org.eclipse.cdt.launch;bundle-version="9.2.0"
Bundle-Activator: org.eclipse.cdt.launch.serial.ui.internal.Activator
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.launchbar.ui.launchTargetTypeUI">
<launchTargetTypeUI
id="org.eclipse.cdt.launch.serial.core.serialFlashTarget"
labelProvider="org.eclipse.cdt.launch.serial.ui.internal.SerialFlashLaunchTargetLabelProvider">
</launchTargetTypeUI>
<wizard2
class="org.eclipse.cdt.launch.serial.ui.internal.NewSerialFlashTargetWizard"
icon="icons/cdt_logo_16.png"
id="org.eclipse.cdt.launch.serial.core.serialFlashTarget"
name="Serial Flash Target">
</wizard2>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
class="org.eclipse.cdt.launch.serial.ui.internal.SerialFlashLaunchConfigTabGroup"
id="org.eclipse.cdt.launch.serial.ui.launchConfigurationTabGroup"
type="org.eclipse.cdt.launch.serial.launchConfigurationType">
</launchConfigurationTabGroup>
</extension>
</plugin>

View file

@ -0,0 +1,52 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class Activator extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.eclipse.cdt.launch.serial.ui"; //$NON-NLS-1$
public static final String IMG_CDT_LOGO = "org.eclipse.cdt.launch.serial.ui.cdt_logo_16"; //$NON-NLS-1$
private static AbstractUIPlugin plugin;
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
protected void initializeImageRegistry(ImageRegistry reg) {
super.initializeImageRegistry(reg);
reg.put(IMG_CDT_LOGO, imageDescriptorFromPlugin(PLUGIN_ID, "icons/cdt_logo_16.png")); //$NON-NLS-1$
}
public static Image getImage(String key) {
return plugin.getImageRegistry().get(key);
}
public static void log(IStatus status) {
plugin.getLog().log(status);
}
public static <T> T getService(Class<T> service) {
BundleContext context = plugin.getBundle().getBundleContext();
ServiceReference<T> ref = context.getServiceReference(service);
return ref != null ? context.getService(ref) : null;
}
}

View file

@ -0,0 +1,29 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.serial.ui.internal.messages"; //$NON-NLS-1$
public static String NewSerialFlashTargetWizard_Title;
public static String NewSerialFlashTargetWizardPage_CPUArchitecture;
public static String NewSerialFlashTargetWizardPage_Description;
public static String NewSerialFlashTargetWizardPage_Fetching;
public static String NewSerialFlashTargetWizardPage_Name;
public static String NewSerialFlashTargetWizardPage_OperatingSystem;
public static String NewSerialFlashTargetWizardPage_SerialPort;
public static String NewSerialFlashTargetWizardPage_Title;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import org.eclipse.cdt.launch.serial.SerialFlashLaunchTargetProvider;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
public class NewSerialFlashTargetWizard extends LaunchTargetWizard {
private NewSerialFlashTargetWizardPage page;
public NewSerialFlashTargetWizard() {
setWindowTitle(Messages.NewSerialFlashTargetWizard_Title);
}
@Override
public void addPages() {
super.addPages();
page = new NewSerialFlashTargetWizardPage(getLaunchTarget());
addPage(page);
}
@Override
public boolean performFinish() {
ILaunchTargetManager manager = Activator.getService(ILaunchTargetManager.class);
String typeId = SerialFlashLaunchTargetProvider.TYPE_ID;
String id = page.getTargetName();
ILaunchTarget target = getLaunchTarget();
if (target == null) {
target = manager.addLaunchTarget(typeId, id);
}
ILaunchTargetWorkingCopy wc = target.getWorkingCopy();
wc.setId(id);
wc.setAttribute(ILaunchTarget.ATTR_OS, page.getOS());
wc.setAttribute(ILaunchTarget.ATTR_ARCH, page.getArch());
wc.setAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT, page.getSerialPortName());
wc.save();
return true;
}
}

View file

@ -0,0 +1,130 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import java.io.IOException;
import org.eclipse.cdt.launch.serial.SerialFlashLaunchTargetProvider;
import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class NewSerialFlashTargetWizardPage extends WizardPage {
private ILaunchTarget launchTarget;
private Text nameText;
private Text osText;
private Text archText;
private Combo serialPortCombo;
public NewSerialFlashTargetWizardPage(ILaunchTarget launchTarget) {
super(NewSerialFlashTargetWizardPage.class.getName());
this.launchTarget = launchTarget;
setTitle(Messages.NewSerialFlashTargetWizardPage_Title);
setDescription(Messages.NewSerialFlashTargetWizardPage_Description);
}
@Override
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout(2, false));
setControl(comp);
Label label = new Label(comp, SWT.NONE);
label.setText(Messages.NewSerialFlashTargetWizardPage_Name);
nameText = new Text(comp, SWT.BORDER);
nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (launchTarget != null) {
nameText.setText(launchTarget.getId());
}
label = new Label(comp, SWT.NONE);
label.setText(Messages.NewSerialFlashTargetWizardPage_OperatingSystem);
osText = new Text(comp, SWT.BORDER);
osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (launchTarget != null) {
String os = launchTarget.getAttribute(ILaunchTarget.ATTR_OS, null);
if (os != null) {
osText.setText(os);
}
}
label = new Label(comp, SWT.NONE);
label.setText(Messages.NewSerialFlashTargetWizardPage_CPUArchitecture);
archText = new Text(comp, SWT.BORDER);
archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (launchTarget != null) {
String arch = launchTarget.getAttribute(ILaunchTarget.ATTR_ARCH, null);
if (arch != null) {
archText.setText(arch);
}
}
label = new Label(comp, SWT.NONE);
label.setText(Messages.NewSerialFlashTargetWizardPage_SerialPort);
serialPortCombo = new Combo(comp, SWT.NONE);
try {
String[] ports = SerialPort.list();
for (String port : ports) {
serialPortCombo.add(port);
}
if (serialPortCombo.getItemCount() > 0) {
if (launchTarget != null) {
String targetPort = launchTarget.getAttribute(SerialFlashLaunchTargetProvider.ATTR_SERIAL_PORT,
null);
if (targetPort != null) {
int i = 0;
for (String port : ports) {
if (port.equals(targetPort)) {
serialPortCombo.select(i);
break;
}
}
}
}
if (serialPortCombo.getSelectionIndex() < 0) {
serialPortCombo.select(0);
}
}
} catch (IOException e) {
Activator.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NewSerialFlashTargetWizardPage_Fetching, e));
}
}
public String getTargetName() {
return nameText.getText();
}
public String getOS() {
return osText.getText();
}
public String getArch() {
return archText.getText();
}
public String getSerialPortName() {
return serialPortCombo.getText();
}
}

View file

@ -0,0 +1,24 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import org.eclipse.cdt.launch.ui.corebuild.GenericMainTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
public class SerialFlashLaunchConfigTabGroup extends AbstractLaunchConfigurationTabGroup {
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
setTabs(new ILaunchConfigurationTab[] { new GenericMainTab(), new EnvironmentTab(), new CommonTab() });
}
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* 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.cdt.launch.serial.ui.internal;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.graphics.Image;
public class SerialFlashLaunchTargetLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
if (element instanceof ILaunchTarget) {
return ((ILaunchTarget) element).getId();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof ILaunchTarget) {
Image image = Activator.getImage(Activator.IMG_CDT_LOGO);
if (image != null) {
return image;
}
}
return super.getImage(element);
}
}

View file

@ -0,0 +1,15 @@
################################################################################
# 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
################################################################################
NewSerialFlashTargetWizard_Title=New Serial Flash Target
NewSerialFlashTargetWizardPage_CPUArchitecture=CPU Architecture:
NewSerialFlashTargetWizardPage_Description=Enter name and properties for the target.
NewSerialFlashTargetWizardPage_Fetching=Fetching serial ports
NewSerialFlashTargetWizardPage_Name=Name:
NewSerialFlashTargetWizardPage_OperatingSystem=Operating System:
NewSerialFlashTargetWizardPage_SerialPort=Serial Port:
NewSerialFlashTargetWizardPage_Title=Serial Flash Target

View file

@ -470,6 +470,13 @@
name="%localApplicationLaunch.name"
public="false">
</launchConfigurationType>
<launchConfigurationType
delegate="org.eclipse.cdt.debug.core.launch.CoreBuildGenericLaunchConfigDelegate"
id="org.eclipse.cdt.debug.core.genericLaunchConfigType"
modes="run"
name="Auto Generic Launch"
public="false">
</launchConfigurationType>
</extension>
<extension
point="org.eclipse.launchbar.core.launchTargetTypes">
@ -491,7 +498,7 @@
priority="10">
</configProvider>
<configProvider
class="org.eclipse.cdt.debug.internal.core.launch.CoreBuildGenericLaunchConfigProvider"
class="org.eclipse.cdt.debug.core.launch.CoreBuildGenericLaunchConfigProvider"
descriptorType="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
priority="10">
</configProvider>

View file

@ -285,6 +285,16 @@ public interface ICDTLaunchConfigurationConstants {
*/
public static final String ATTR_DEBUGGER_POST_MORTEM_TYPE = "org.eclipse.cdt.dsf.gdb" + ".POST_MORTEM_TYPE"; //$NON-NLS-1$ //$NON-NLS-2$
/**
* @since 8.3
*/
public final static String ATTR_LOCATION = CDT_LAUNCH_ID + ".ATTR_LOCATION"; //$NON-NLS-1$
/**
* @since 8.3
*/
public final static String ATTR_TOOL_ARGUMENTS = CDT_LAUNCH_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$
/**
* Launch configuration attribute value. The key is
* ATTR_DEBUGGER_STOP_AT_MAIN.

View file

@ -0,0 +1,88 @@
/*******************************************************************************
* 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.cdt.debug.core.launch;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.internal.core.Messages;
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.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
/**
* Delegate for Generic Launches over the Generic Launch Target. Can be
* overriden to support launch customization for similar targets.
*
* @since 8.3
*/
public class CoreBuildGenericLaunchConfigDelegate extends CoreBuildLaunchConfigDelegate {
public static final String TYPE_ID = "org.eclipse.cdt.debug.core.genericLaunchConfigType"; //$NON-NLS-1$
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
String location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
if (location.isEmpty()) {
launch.addProcess(new NullProcess(launch, Messages.CoreBuildGenericLaunchConfigDelegate_NoAction));
return;
} else {
String substLocation = varManager.performStringSubstitution(location);
if (substLocation.isEmpty()) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
String.format(Messages.CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed, location)));
}
location = substLocation;
}
if (!new File(location).canExecute()) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
String.format(Messages.CoreBuildGenericLaunchConfigDelegate_CommandNotValid, location)));
}
List<String> commands = new ArrayList<>();
commands.add(location);
String arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
if (!arguments.isEmpty()) {
commands.addAll(Arrays.asList(varManager.performStringSubstitution(arguments).split(" "))); //$NON-NLS-1$
}
String workingDirectory = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
""); //$NON-NLS-1$
File workingDir;
if (workingDirectory.isEmpty()) {
workingDir = new File(getProject(configuration).getLocationURI());
} else {
workingDir = new File(varManager.performStringSubstitution(workingDirectory));
if (!workingDir.isDirectory()) {
throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID,
String.format(Messages.CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists, location)));
}
}
String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
Process p = DebugPlugin.exec(commands.toArray(new String[0]), workingDir, envp);
DebugPlugin.newProcess(launch, p, String.join(" ", commands)); //$NON-NLS-1$
}
}

View file

@ -1,150 +1,165 @@
package org.eclipse.cdt.debug.internal.core.launch;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.launch.GenericTargetTypeProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
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.ILaunchConfigurationWorkingCopy;
import org.eclipse.launchbar.core.AbstractLaunchConfigProvider;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider {
private static final String TYPE_ID = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$
private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$
private static final String NO_OS = ""; //$NON-NLS-1$
private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>();
@Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID);
}
@Override
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
return DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(TYPE_ID);
}
@Override
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
ILaunchConfiguration config = null;
IProject project = descriptor.getAdapter(IProject.class);
if (project != null) {
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null) {
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}
String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS);
config = projectConfigs.get(os);
if (config == null) {
config = createLaunchConfiguration(descriptor, target);
}
}
return config;
}
@Override
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
super.populateLaunchConfiguration(descriptor, target, workingCopy);
// Set the project
IProject project = descriptor.getAdapter(IProject.class);
workingCopy.setMappedResources(new IResource[] { project });
// set the OS
String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS);
workingCopy.setAttribute(ATTR_OS, os);
}
@Override
public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
if (ownsLaunchConfiguration(configuration)) {
IProject project = configuration.getMappedResources()[0].getProject();
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null) {
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}
String os = configuration.getAttribute(ATTR_OS, NO_OS);
projectConfigs.put(os, configuration);
return true;
}
return false;
}
@Override
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) {
if (configuration.equals(entry.getValue())) {
projectConfigs.remove(entry.getKey());
if (projectConfigs.isEmpty()) {
configs.remove(projectEntry.getKey());
}
return true;
}
}
}
return false;
}
@Override
public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
// nothing to do
return false;
}
@Override
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
IProject project = descriptor.getAdapter(IProject.class);
if (project != null) {
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs != null) {
for (ILaunchConfiguration config : projectConfigs.values()) {
config.delete();
}
}
}
}
@Override
public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
// Any other targets have the same OS?
String os = target.getAttribute(ILaunchTarget.ATTR_OS, NO_OS);
ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class);
for (ILaunchTarget t : targetManager.getLaunchTargets()) {
if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, NO_OS))) {
// Yup, nothing to do then
return;
}
}
for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
ILaunchConfiguration config = projectConfigs.get(os);
if (config != null) {
config.delete();
}
}
}
}
package org.eclipse.cdt.debug.core.launch;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
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.ILaunchConfigurationWorkingCopy;
import org.eclipse.launchbar.core.AbstractLaunchConfigProvider;
import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
/**
* Core launch configuration provider used by generic target types.
*
* @since 8.3
*/
public class CoreBuildGenericLaunchConfigProvider extends AbstractLaunchConfigProvider {
private static final String ATTR_OS = CDebugCorePlugin.PLUGIN_ID + ".target_os"; //$NON-NLS-1$
private static final String ATTR_ARCH = CDebugCorePlugin.PLUGIN_ID + ".target_arch"; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
private Map<IProject, Map<String, ILaunchConfiguration>> configs = new HashMap<>();
@Override
public boolean supports(ILaunchDescriptor descriptor, ILaunchTarget target) throws CoreException {
return target.getTypeId().equals(GenericTargetTypeProvider.TYPE_ID);
}
@Override
public ILaunchConfigurationType getLaunchConfigurationType(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
return DebugPlugin.getDefault().getLaunchManager()
.getLaunchConfigurationType(CoreBuildGenericLaunchConfigDelegate.TYPE_ID);
}
@Override
public ILaunchConfiguration getLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
ILaunchConfiguration config = null;
IProject project = descriptor.getAdapter(IProject.class);
if (project != null) {
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null) {
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}
String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
String targetConfig = os + '.' + arch;
config = projectConfigs.get(targetConfig);
if (config == null) {
config = createLaunchConfiguration(descriptor, target);
}
}
return config;
}
@Override
protected void populateLaunchConfiguration(ILaunchDescriptor descriptor, ILaunchTarget target,
ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
super.populateLaunchConfiguration(descriptor, target, workingCopy);
// Set the project
IProject project = descriptor.getAdapter(IProject.class);
workingCopy.setMappedResources(new IResource[] { project });
// set the OS and ARCH
String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
workingCopy.setAttribute(ATTR_OS, os);
String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
workingCopy.setAttribute(ATTR_ARCH, arch);
}
@Override
public boolean launchConfigurationAdded(ILaunchConfiguration configuration) throws CoreException {
// TODO make sure it's the correct type
if (ownsLaunchConfiguration(configuration)) {
IProject project = configuration.getMappedResources()[0].getProject();
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs == null) {
projectConfigs = new HashMap<>();
configs.put(project, projectConfigs);
}
String os = configuration.getAttribute(ATTR_OS, EMPTY);
String arch = configuration.getAttribute(ATTR_ARCH, EMPTY);
String targetConfig = os + '.' + arch;
projectConfigs.put(targetConfig, configuration);
return true;
}
return false;
}
@Override
public boolean launchConfigurationRemoved(ILaunchConfiguration configuration) throws CoreException {
for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
for (Entry<String, ILaunchConfiguration> entry : projectConfigs.entrySet()) {
if (configuration.equals(entry.getValue())) {
projectConfigs.remove(entry.getKey());
if (projectConfigs.isEmpty()) {
configs.remove(projectEntry.getKey());
}
return true;
}
}
}
return false;
}
@Override
public boolean launchConfigurationChanged(ILaunchConfiguration configuration) throws CoreException {
// nothing to do
return false;
}
@Override
public void launchDescriptorRemoved(ILaunchDescriptor descriptor) throws CoreException {
IProject project = descriptor.getAdapter(IProject.class);
if (project != null) {
Map<String, ILaunchConfiguration> projectConfigs = configs.get(project);
if (projectConfigs != null) {
for (ILaunchConfiguration config : projectConfigs.values()) {
config.delete();
}
}
}
}
@Override
public void launchTargetRemoved(ILaunchTarget target) throws CoreException {
// Any other targets have the same OS and ARCH?
String os = target.getAttribute(ILaunchTarget.ATTR_OS, EMPTY);
String arch = target.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY);
ILaunchTargetManager targetManager = CDebugCorePlugin.getService(ILaunchTargetManager.class);
for (ILaunchTarget t : targetManager.getLaunchTargets()) {
if (!target.equals(t) && os.equals(t.getAttribute(ILaunchTarget.ATTR_OS, EMPTY))
&& arch.equals(t.getAttribute(ILaunchTarget.ATTR_ARCH, EMPTY))) {
// Yup, nothing to do then
return;
}
}
for (Entry<IProject, Map<String, ILaunchConfiguration>> projectEntry : configs.entrySet()) {
Map<String, ILaunchConfiguration> projectConfigs = projectEntry.getValue();
ILaunchConfiguration config = projectConfigs.get(os);
if (config != null) {
config.delete();
}
}
}
}

View file

@ -0,0 +1,107 @@
/*******************************************************************************
* 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.cdt.debug.core.launch;
import java.io.IOException;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
/**
* A simple process that only spits out a message then terminates.
*
* @since 8.3
*/
public class NullProcess extends PlatformObject implements IProcess {
private final String message;
private final ILaunch launch;
public NullProcess(ILaunch launch, String message) {
this.launch = launch;
this.message = message;
}
@Override
public boolean canTerminate() {
return true;
}
@Override
public boolean isTerminated() {
return true;
}
@Override
public void terminate() throws DebugException {
}
@Override
public String getLabel() {
return launch.getLaunchConfiguration().getName();
}
@Override
public ILaunch getLaunch() {
return launch;
}
@Override
public IStreamsProxy getStreamsProxy() {
return new IStreamsProxy() {
@Override
public void write(String input) throws IOException {
// TODO Auto-generated method stub
}
@Override
public IStreamMonitor getOutputStreamMonitor() {
return new IStreamMonitor() {
@Override
public void removeListener(IStreamListener listener) {
}
@Override
public String getContents() {
return message;
}
@Override
public void addListener(IStreamListener listener) {
}
};
}
@Override
public IStreamMonitor getErrorStreamMonitor() {
return null;
}
};
}
@Override
public void setAttribute(String key, String value) {
}
@Override
public String getAttribute(String key) {
return null;
}
@Override
public int getExitValue() throws DebugException {
return 0;
}
}

View file

@ -0,0 +1,25 @@
/*******************************************************************************
* 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.cdt.debug.internal.core;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.core.messages"; //$NON-NLS-1$
public static String CoreBuildGenericLaunchConfigDelegate_CommandNotValid;
public static String CoreBuildGenericLaunchConfigDelegate_NoAction;
public static String CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed;
public static String CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,11 @@
###############################################################################
# Copyright (c) 2003, 2010 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
###############################################################################
CoreBuildGenericLaunchConfigDelegate_CommandNotValid=Not a valid command "%s"
CoreBuildGenericLaunchConfigDelegate_NoAction=No action specified. Skipping.
CoreBuildGenericLaunchConfigDelegate_SubstitutionFailed=Variable substitution failed "%s"
CoreBuildGenericLaunchConfigDelegate_WorkingDirNotExists=Working directory %s does not exist

View file

@ -121,6 +121,9 @@ public class GDBProcesses_7_12 extends GDBProcesses_7_11 {
}
}
/**
* @since 5.4
*/
@Override
protected boolean targetAttachRequiresTrailingNewline() {
return true;

View file

@ -66,8 +66,11 @@ public class MITargetAttach extends MICommand<MIInfo> {
}
/**
* Add an extra newline to force GDB 7.11 to flush error response to the MI channel.
* Add an extra newline to force GDB 7.11 to flush error response to the MI
* channel.
*
* @see GDBProcesses_7_2#targetAttachRequiresTrailingNewline
* @since 5.4
*/
@Override
public String constructCommand(String groupId, String threadId, int frameId) {

View file

@ -154,11 +154,16 @@
id="org.eclipse.cdt.launch.launchConfigurationTabGroup.local"
type="org.eclipse.cdt.debug.core.localCoreBuildLaunchConfigType">
</launchConfigurationTabGroup>
<launchConfigurationTabGroup
class="org.eclipse.cdt.launch.internal.corebuild.GenericLaunchConfigTabGroup"
id="org.eclipse.cdt.launch.genericLaunchConfigTabGroup"
type="org.eclipse.cdt.debug.core.genericLaunchConfigType">
</launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.launchbar.ui.launchBarUIContributions">
<buildTabGroup
launchConfigType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"
launchConfigType="org.eclipse.cdt.debug.core.genericLaunchConfigType"
launchDescriptorType="org.eclipse.cdt.debug.core.coreBuildDescriptorType"
tabGroup="org.eclipse.cdt.launch.internal.corebuild.CoreBuildTabGroup">
</buildTabGroup>

View file

@ -0,0 +1,28 @@
/*******************************************************************************
* 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.cdt.launch.internal.corebuild;
import org.eclipse.cdt.launch.ui.corebuild.GenericMainTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.EnvironmentTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
public class GenericLaunchConfigTabGroup extends AbstractLaunchConfigurationTabGroup {
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
setTabs(new ILaunchConfigurationTab[] {
new GenericMainTab(),
new EnvironmentTab(),
new CommonTab()
});
}
}

View file

@ -0,0 +1,36 @@
/*******************************************************************************
* 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.cdt.launch.internal.ui;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.launch.internal.ui.messages"; //$NON-NLS-1$
public static String GenericMainTab_Arguments;
public static String GenericMainTab_BrowseFileSystem;
public static String GenericMainTab_BrowseWorkspace;
public static String GenericMainTab_Location;
public static String GenericMainTab_LocationNotAFile;
public static String GenericMainTab_LocationNotExists;
public static String GenericMainTab_Main;
public static String GenericMainTab_Quotes;
public static String GenericMainTab_SelectResource;
public static String GenericMainTab_SelectWorkingDir;
public static String GenericMainTab_SpecifyLocation;
public static String GenericMainTab_Variables;
public static String GenericMainTab_WorkingDirectory;
public static String GenericMainTab_WorkingDirNotADir;
public static String GenericMainTab_WorkingDirNotExists;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
private Messages() {
}
}

View file

@ -0,0 +1,22 @@
###############################################################################
# Copyright (c) 2002, 2015 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
###############################################################################
GenericMainTab_Arguments=Arguments:
GenericMainTab_BrowseFileSystem=Browse File System...
GenericMainTab_BrowseWorkspace=Browse Workspace...
GenericMainTab_Location=Location
GenericMainTab_LocationNotAFile=External tool location specified is not a file
GenericMainTab_LocationNotExists=External tool location does not exist
GenericMainTab_Main=Main
GenericMainTab_Quotes=Note: Enclose an argument containing spaces using double-quotes (\\").
GenericMainTab_SelectResource=Select a resource:
GenericMainTab_SelectWorkingDir=Select a working directory:
GenericMainTab_SpecifyLocation=Please specify the location of the external tool you would like to configure.
GenericMainTab_Variables=Variables...
GenericMainTab_WorkingDirectory=Working Directory:
GenericMainTab_WorkingDirNotADir=The specified location is not a directory
GenericMainTab_WorkingDirNotExists=External tool working directory does not exist or is invalid

View file

@ -0,0 +1,715 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation 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
*
* copied from:
* org.eclipse.ui.externaltools.internal.launchConfigurations.GenericMainTab
*******************************************************************************/
package org.eclipse.cdt.launch.ui.corebuild;
import java.io.File;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.internal.ui.LaunchImages;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.launch.internal.ui.Messages;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
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.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
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.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.dialogs.ResourceSelectionDialog;
/**
* @since 9.2
*/
public class GenericMainTab extends AbstractLaunchConfigurationTab {
public final static String FIRST_EDIT = "editedByExternalToolsMainTab"; //$NON-NLS-1$
protected Text locationField;
protected Text workDirectoryField;
protected Button fileLocationButton;
protected Button workspaceLocationButton;
protected Button variablesLocationButton;
protected Button fileWorkingDirectoryButton;
protected Button workspaceWorkingDirectoryButton;
protected Button variablesWorkingDirectoryButton;
protected Text argumentField;
protected Button argumentVariablesButton;
protected SelectionAdapter selectionAdapter;
protected boolean fInitializing = false;
private boolean userEdited = false;
protected WidgetListener fListener = new WidgetListener();
/**
* A listener to update for text modification and widget selection.
*/
protected class WidgetListener extends SelectionAdapter implements ModifyListener {
@Override
public void modifyText(ModifyEvent e) {
if (!fInitializing) {
setDirty(true);
userEdited = true;
updateLaunchConfigurationDialog();
}
}
@Override
public void widgetSelected(SelectionEvent e) {
setDirty(true);
Object source = e.getSource();
if (source == workspaceLocationButton) {
handleWorkspaceLocationButtonSelected();
} else if (source == fileLocationButton) {
handleFileLocationButtonSelected();
} else if (source == workspaceWorkingDirectoryButton) {
handleWorkspaceWorkingDirectoryButtonSelected();
} else if (source == fileWorkingDirectoryButton) {
handleFileWorkingDirectoryButtonSelected();
} else if (source == argumentVariablesButton) {
handleVariablesButtonSelected(argumentField);
} else if (source == variablesLocationButton) {
handleVariablesButtonSelected(locationField);
} else if (source == variablesWorkingDirectoryButton) {
handleVariablesButtonSelected(workDirectoryField);
}
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.
* widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
Composite mainComposite = new Composite(parent, SWT.NONE);
setControl(mainComposite);
mainComposite.setFont(parent.getFont());
GridLayout layout = new GridLayout();
layout.numColumns = 1;
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
mainComposite.setLayout(layout);
mainComposite.setLayoutData(gridData);
createLocationComponent(mainComposite);
createWorkDirectoryComponent(mainComposite);
createArgumentComponent(mainComposite);
createVerticalSpacer(mainComposite, 1);
Dialog.applyDialogFont(parent);
}
/**
* Creates the controls needed to edit the location attribute of an external
* tool
*
* @param parent
* the composite to create the controls in
*/
protected void createLocationComponent(Composite parent) {
Group group = new Group(parent, SWT.NONE);
String locationLabel = getLocationLabel();
group.setText(locationLabel);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
group.setLayout(layout);
group.setLayoutData(gridData);
locationField = new Text(group, SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
locationField.setLayoutData(gridData);
locationField.addModifyListener(fListener);
addControlAccessibleListener(locationField, group.getText());
Composite buttonComposite = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 3;
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(gridData);
buttonComposite.setFont(parent.getFont());
workspaceLocationButton = createPushButton(buttonComposite, Messages.GenericMainTab_BrowseWorkspace, null);
workspaceLocationButton.addSelectionListener(fListener);
addControlAccessibleListener(workspaceLocationButton,
group.getText() + " " + workspaceLocationButton.getText()); //$NON-NLS-1$
fileLocationButton = createPushButton(buttonComposite, Messages.GenericMainTab_BrowseFileSystem, null);
fileLocationButton.addSelectionListener(fListener);
addControlAccessibleListener(fileLocationButton, group.getText() + " " + fileLocationButton.getText()); //$NON-NLS-1$
variablesLocationButton = createPushButton(buttonComposite, Messages.GenericMainTab_Variables, null);
variablesLocationButton.addSelectionListener(fListener);
addControlAccessibleListener(variablesLocationButton,
group.getText() + " " + variablesLocationButton.getText()); //$NON-NLS-1$
}
/**
* Returns the label used for the location widgets. Subclasses may wish to
* override.
*/
protected String getLocationLabel() {
return Messages.GenericMainTab_Location;
}
/**
* Creates the controls needed to edit the working directory attribute of an
* external tool
*
* @param parent
* the composite to create the controls in
*/
protected void createWorkDirectoryComponent(Composite parent) {
Group group = new Group(parent, SWT.NONE);
String groupName = getWorkingDirectoryLabel();
group.setText(groupName);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
group.setLayout(layout);
group.setLayoutData(gridData);
workDirectoryField = new Text(group, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
workDirectoryField.setLayoutData(data);
workDirectoryField.addModifyListener(fListener);
addControlAccessibleListener(workDirectoryField, group.getText());
Composite buttonComposite = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 3;
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(gridData);
buttonComposite.setFont(parent.getFont());
workspaceWorkingDirectoryButton = createPushButton(buttonComposite, Messages.GenericMainTab_BrowseWorkspace, null);
workspaceWorkingDirectoryButton.addSelectionListener(fListener);
addControlAccessibleListener(workspaceWorkingDirectoryButton,
group.getText() + " " + workspaceWorkingDirectoryButton.getText()); //$NON-NLS-1$
fileWorkingDirectoryButton = createPushButton(buttonComposite, Messages.GenericMainTab_BrowseFileSystem, null);
fileWorkingDirectoryButton.addSelectionListener(fListener);
addControlAccessibleListener(fileWorkingDirectoryButton, group.getText() + " " + fileLocationButton.getText()); //$NON-NLS-1$
variablesWorkingDirectoryButton = createPushButton(buttonComposite, Messages.GenericMainTab_Variables, null);
variablesWorkingDirectoryButton.addSelectionListener(fListener);
addControlAccessibleListener(variablesWorkingDirectoryButton,
group.getText() + " " + variablesWorkingDirectoryButton.getText()); //$NON-NLS-1$
}
/**
* Return the String to use as the label for the working directory field.
* Subclasses may wish to override.
*/
protected String getWorkingDirectoryLabel() {
return Messages.GenericMainTab_WorkingDirectory;
}
/**
* Creates the controls needed to edit the argument and prompt for argument
* attributes of an external tool
*
* @param parent
* the composite to create the controls in
*/
protected void createArgumentComponent(Composite parent) {
Group group = new Group(parent, SWT.NONE);
String groupName = Messages.GenericMainTab_Arguments;
group.setText(groupName);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
GridData gridData = new GridData(GridData.FILL_BOTH);
group.setLayout(layout);
group.setLayoutData(gridData);
group.setFont(parent.getFont());
argumentField = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
argumentField.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent event) {
if (event.detail == SWT.TRAVERSE_RETURN && (event.stateMask & SWT.MODIFIER_MASK) != 0) {
event.doit = true;
}
}
});
gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
gridData.heightHint = 30;
argumentField.setLayoutData(gridData);
argumentField.addModifyListener(fListener);
addControlAccessibleListener(argumentField, group.getText());
Composite composite = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 0;
layout.marginWidth = 0;
gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
composite.setLayout(layout);
composite.setLayoutData(gridData);
composite.setFont(parent.getFont());
argumentVariablesButton = createPushButton(composite, Messages.GenericMainTab_Variables, null);
argumentVariablesButton.addSelectionListener(fListener);
addControlAccessibleListener(argumentVariablesButton, argumentVariablesButton.getText()); // need to strip the
// mnemonic from
// buttons
Label instruction = new Label(group, SWT.NONE);
instruction.setText(Messages.GenericMainTab_Quotes);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 2;
instruction.setLayoutData(gridData);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.
* core.ILaunchConfigurationWorkingCopy)
*/
@Override
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(FIRST_EDIT, true);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug
* .core.ILaunchConfiguration)
*/
@Override
public void initializeFrom(ILaunchConfiguration configuration) {
fInitializing = true;
updateLocation(configuration);
updateWorkingDirectory(configuration);
updateArgument(configuration);
fInitializing = false;
setDirty(false);
}
/**
* Updates the working directory widgets to match the state of the given launch
* configuration.
*/
protected void updateWorkingDirectory(ILaunchConfiguration configuration) {
String workingDir = ""; //$NON-NLS-1$
try {
workingDir = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, ""); //$NON-NLS-1$
} catch (CoreException ce) {
LaunchUIPlugin.log(ce.getStatus());
}
workDirectoryField.setText(workingDir);
}
/**
* Updates the location widgets to match the state of the given launch
* configuration.
*/
protected void updateLocation(ILaunchConfiguration configuration) {
String location = ""; //$NON-NLS-1$
try {
location = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, ""); //$NON-NLS-1$
} catch (CoreException ce) {
LaunchUIPlugin.log(ce.getStatus());
}
locationField.setText(location);
}
/**
* Updates the argument widgets to match the state of the given launch
* configuration.
*/
protected void updateArgument(ILaunchConfiguration configuration) {
String arguments = ""; //$NON-NLS-1$
try {
arguments = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
} catch (CoreException ce) {
LaunchUIPlugin.log(ce.getStatus());
}
argumentField.setText(arguments);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.
* core.ILaunchConfigurationWorkingCopy)
*/
@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
String location = locationField.getText().trim();
if (location.length() == 0) {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, (String) null);
} else {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_LOCATION, location);
}
String workingDirectory = workDirectoryField.getText().trim();
if (workingDirectory.length() == 0) {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
} else {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDirectory);
}
String arguments = argumentField.getText().trim();
if (arguments.length() == 0) {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, (String) null);
} else {
configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_TOOL_ARGUMENTS, arguments);
}
if (userEdited) {
configuration.setAttribute(FIRST_EDIT, (String) null);
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
@Override
public String getName() {
return Messages.GenericMainTab_Main;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.
* ILaunchConfiguration)
*/
@Override
public boolean isValid(ILaunchConfiguration launchConfig) {
setErrorMessage(null);
setMessage(null);
boolean newConfig = false;
try {
newConfig = launchConfig.getAttribute(FIRST_EDIT, false);
} catch (CoreException e) {
// assume false is correct
}
return validateLocation(newConfig) && validateWorkDirectory();
}
/**
* Validates the content of the location field.
*/
protected boolean validateLocation(boolean newConfig) {
String location = locationField.getText().trim();
if (location.length() < 1) {
setErrorMessage(null);
setMessage(Messages.GenericMainTab_SpecifyLocation);
return true;
}
String expandedLocation = null;
try {
expandedLocation = resolveValue(location);
if (expandedLocation == null) { // a variable that needs to be resolved at runtime
return true;
}
} catch (CoreException e) {
setErrorMessage(e.getStatus().getMessage());
return false;
}
File file = new File(expandedLocation);
if (!file.exists()) { // The file does not exist.
if (!newConfig) {
setErrorMessage(Messages.GenericMainTab_LocationNotExists);
}
return false;
}
if (!file.isFile()) {
if (!newConfig) {
setErrorMessage(Messages.GenericMainTab_LocationNotAFile);
}
return false;
}
return true;
}
/**
* Validates the variables of the given string to determine if all variables are
* valid
*
* @param expression
* expression with variables
* @exception CoreException
* if a variable is specified that does not exist
*/
private void validateVaribles(String expression) throws CoreException {
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
manager.validateStringVariables(expression);
}
private String resolveValue(String expression) throws CoreException {
String expanded = null;
try {
expanded = getValue(expression);
} catch (CoreException e) { // possibly just a variable that needs to be resolved at runtime
validateVaribles(expression);
return null;
}
return expanded;
}
/**
* Validates the value of the given string to determine if any/all variables are
* valid
*
* @param expression
* expression with variables
* @return whether the expression contained any variable values
* @exception CoreException
* if variable resolution fails
*/
private String getValue(String expression) throws CoreException {
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
return manager.performStringSubstitution(expression);
}
/**
* Validates the content of the working directory field.
*/
protected boolean validateWorkDirectory() {
String dir = workDirectoryField.getText().trim();
if (dir.length() <= 0) {
return true;
}
String expandedDir = null;
try {
expandedDir = resolveValue(dir);
if (expandedDir == null) { // a variable that needs to be resolved at runtime
return true;
}
} catch (CoreException e) {
setErrorMessage(e.getStatus().getMessage());
return false;
}
File file = new File(expandedDir);
if (!file.exists()) { // The directory does not exist.
setErrorMessage(Messages.GenericMainTab_WorkingDirNotExists);
return false;
}
if (!file.isDirectory()) {
setErrorMessage(Messages.GenericMainTab_WorkingDirNotADir);
return false;
}
return true;
}
/**
* Prompts the user to choose a location from the filesystem and sets the
* location as the full path of the selected file.
*/
protected void handleFileLocationButtonSelected() {
FileDialog fileDialog = new FileDialog(getShell(), SWT.NONE);
fileDialog.setFileName(locationField.getText());
String text = fileDialog.open();
if (text != null) {
locationField.setText(text);
}
}
/**
* Prompts the user for a workspace location within the workspace and sets the
* location as a String containing the workspace_loc variable or
* <code>null</code> if no location was obtained from the user.
*/
protected void handleWorkspaceLocationButtonSelected() {
ResourceSelectionDialog dialog;
dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(),
Messages.GenericMainTab_SelectResource);
dialog.open();
Object[] results = dialog.getResult();
if (results == null || results.length < 1) {
return;
}
IResource resource = (IResource) results[0];
locationField.setText(newVariableExpression("workspace_loc", resource.getFullPath().toString())); //$NON-NLS-1$
}
/**
* Prompts the user for a working directory location within the workspace and
* sets the working directory as a String containing the workspace_loc variable
* or <code>null</code> if no location was obtained from the user.
*/
protected void handleWorkspaceWorkingDirectoryButtonSelected() {
ContainerSelectionDialog containerDialog;
containerDialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
Messages.GenericMainTab_SelectWorkingDir);
containerDialog.open();
Object[] resource = containerDialog.getResult();
String text = null;
if (resource != null && resource.length > 0) {
text = newVariableExpression("workspace_loc", ((IPath) resource[0]).toString()); //$NON-NLS-1$
}
if (text != null) {
workDirectoryField.setText(text);
}
}
/**
* Returns a new variable expression with the given variable and the given
* argument.
*
* @see IStringVariableManager#generateVariableExpression(String, String)
*/
protected String newVariableExpression(String varName, String arg) {
return VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression(varName, arg);
}
/**
* Prompts the user to choose a working directory from the filesystem.
*/
protected void handleFileWorkingDirectoryButtonSelected() {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SAVE);
dialog.setMessage(Messages.GenericMainTab_SelectWorkingDir);
dialog.setFilterPath(workDirectoryField.getText());
String text = dialog.open();
if (text != null) {
workDirectoryField.setText(text);
}
}
/**
* A variable entry button has been pressed for the given text field. Prompt the
* user for a variable and enter the result in the given field.
*/
private void handleVariablesButtonSelected(Text textField) {
String variable = getVariable();
if (variable != null) {
textField.insert(variable);
}
}
/**
* Prompts the user to choose and configure a variable and returns the resulting
* string, suitable to be used as an attribute.
*/
private String getVariable() {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
return dialog.getVariableExpression();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
@Override
public Image getImage() {
return LaunchImages.get(LaunchImages.IMG_VIEW_MAIN_TAB);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.
* core.ILaunchConfigurationWorkingCopy)
*/
@Override
public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core
* .ILaunchConfigurationWorkingCopy)
*/
@Override
public void activated(ILaunchConfigurationWorkingCopy workingCopy) {
}
/*
* Fix for Bug 60163 Accessibility: New Builder Dialog missing object info for
* textInput controls
*/
public void addControlAccessibleListener(Control control, String controlName) {
// strip mnemonic (&)
String[] strs = controlName.split("&"); //$NON-NLS-1$
StringBuffer stripped = new StringBuffer();
for (int i = 0; i < strs.length; i++) {
stripped.append(strs[i]);
}
control.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString()));
}
private class ControlAccessibleListener extends AccessibleAdapter {
private String controlName;
ControlAccessibleListener(String name) {
controlName = name;
}
@Override
public void getName(AccessibleEvent e) {
e.result = controlName;
}
}
}

View file

@ -308,7 +308,7 @@ public class SerialPort {
return outputStream;
}
public void open() throws IOException {
public synchronized void open() throws IOException {
handle = open0(portName, baudRate.getRate(), byteSize.getSize(), parity.ordinal(), stopBits.ordinal());
isOpen = true;
@ -356,18 +356,26 @@ public class SerialPort {
}
public void pause() throws IOException {
isPaused = true;
close0(handle);
try {
// Sleep for a second since some serial ports take a while to actually close
Thread.sleep(500);
} catch (InterruptedException e) {
// nothing to do
if (!isOpen) {
return;
}
synchronized (pauseMutex) {
isPaused = true;
close0(handle);
try {
// Sleep for a second since some serial ports take a while to actually close
Thread.sleep(500);
} catch (InterruptedException e) {
// nothing to do
}
}
}
public void resume() throws IOException {
synchronized (pauseMutex) {
if (!isPaused) {
return;
}
isPaused = false;
handle = open0(portName, baudRate.getRate(), byteSize.getSize(), parity.ordinal(), stopBits.ordinal());
isOpen = true;

View file

@ -102,7 +102,10 @@
<module>cross/org.eclipse.cdt.build.crossgcc-feature</module>
<module>cross/org.eclipse.cdt.launch.remote</module>
<module>cross/org.eclipse.cdt.launch.remote-feature</module>
<module>cross/org.eclipse.cdt.launch.serial.core</module>
<module>cross/org.eclipse.cdt.launch.serial.ui</module>
<module>cross/org.eclipse.cdt.launch.serial-feature</module>
<module>debug/org.eclipse.cdt.debug.core</module>
<module>debug/org.eclipse.cdt.debug.ui</module>