1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Updated UI components for launch config.

This commit is contained in:
Doug Schaefer 2007-04-17 01:53:01 +00:00
parent e6dbc5b189
commit 526c6cd618
3 changed files with 165 additions and 62 deletions

View file

@ -19,6 +19,23 @@ public class GDBJtagConstants {
public static final String DEBUGGER_ID = "org.eclipse.cdt.debug.mi.core.CDebuggerNew"; //$NON-NLS-1$
public static final String LAUNCH_ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$
public static final String LAUNCH_ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$
// Debugger
public static final String ATTR_USE_REMOTE_TARGET = Activator.PLUGIN_ID + ".useRemoteTarget"; //$NON-NLS-1$
public static final String ATTR_IP_ADDRESS = Activator.PLUGIN_ID + ".ipAddress"; //$NON-NLS-1$
public static final String ATTR_PORT_NUMBER = Activator.PLUGIN_ID + ".portNumber"; //$NON-NLS-1$
public static final boolean DEFAULT_USE_REMOTE_TARGET = true;
public static final String DEFAULT_IP_ADDRESS = "localhost"; //$NON-NLS-1$
public static final int DEFAULT_PORT_NUMBER = 10000;
// Startup
public static final String ATTR_INIT_COMMANDS = Activator.PLUGIN_ID + ".initCommands"; //$NON-NLS-1$
public static final String ATTR_LOAD_IMAGE = Activator.PLUGIN_ID + ".loadImage"; //$NON-NLS-1$
public static final String ATTR_IMAGE_FILE_NAME = Activator.PLUGIN_ID + ".imageFileName"; //$NON-NLS-1$
public static final String ATTR_USE_DEFAULT_RUN = Activator.PLUGIN_ID + ".useDefaultRun"; //$NON-NLS-1$
public static final String ATTR_RUN_COMMANDS = Activator.PLUGIN_ID + ".runCommands"; //$NON-NLS-1$
public static final boolean DEFAULT_LOAD_IMAGE = false;
public static final boolean DEFAULT_USE_DEFAULT_RUN = true;
}

View file

@ -12,9 +12,11 @@
package org.eclipse.cdt.debug.gdbjtag.ui;
import org.eclipse.cdt.debug.gdbjtag.core.GDBJtagConstants;
import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
import org.eclipse.cdt.debug.mi.core.MIPlugin;
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryDescriptor;
import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryManager;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@ -22,6 +24,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -39,10 +43,15 @@ import org.eclipse.swt.widgets.Text;
public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
private CommandFactoryDescriptor[] cfDescs;
private int cfSelected = -1;
private Text gdbCommand;
private Text gdbinitFile;
private Combo commandFactory;
private Combo miProtocol;
private Button verboseMode;
private Button useRemote;
private Composite remoteConnection;
private Composite remoteTarget;
private Text ipAddress;
private Text portNumber;
@ -96,10 +105,9 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
gd.horizontalSpan = 3;
label.setLayoutData(gd);
Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
text.setText("gdb");
gdbCommand = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(gd);
gdbCommand.setLayoutData(gd);
Button button = new Button(comp, SWT.NONE);
button.setText("Browse...");
@ -122,9 +130,9 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
gd.horizontalSpan = 3;
label.setLayoutData(gd);
Text text = new Text(comp, SWT.SINGLE | SWT.BORDER);
gdbinitFile = new Text(comp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
text.setLayoutData(gd);
gdbinitFile.setLayoutData(gd);
Button button = new Button(comp, SWT.NONE);
button.setText("Browse...");
@ -139,21 +147,14 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
Label label = new Label(comp, SWT.NONE);
label.setText("Command Set:");
Combo combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
commandFactory = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
// Get the command sets
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
cfDescs = cfManager.getDescriptors(
GDBJtagConstants.DEBUGGER_ID);
cfDescs = cfManager.getDescriptors(GDBJtagConstants.DEBUGGER_ID);
for (int i = 0; i < cfDescs.length; ++i) {
combo.add(cfDescs[i].getName());
if (defDesc == cfDescs[i])
cfSelected = i;
commandFactory.add(cfDescs[i].getName());
}
if (cfSelected > -1)
combo.select(cfSelected);
}
public void createProtocolControl(Composite parent) {
@ -163,24 +164,27 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
Label label = new Label(comp, SWT.NONE);
label.setText("Protocol Version:");
Combo combo = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
if (cfSelected > -1) {
String[] vers = cfDescs[cfSelected].getMIVersions();
for (int i = 0; i < vers.length; ++i) {
combo.add(vers[i]);
miProtocol = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN);
}
private void commandSetChanged() {
int currsel = miProtocol.getSelectionIndex();
String currProt = miProtocol.getItem(currsel);
miProtocol.removeAll();
int cfsel = commandFactory.getSelectionIndex();
if (cfsel >= 0) {
String[] protocols = cfDescs[cfsel].getMIVersions();
for (int i = 0; i < protocols.length; ++i) {
miProtocol.add(protocols[i]);
if (protocols[i].equals(currProt))
miProtocol.select(i);
}
}
combo.select(0);
}
public void createVerboseModeControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
comp.setLayout(layout);
Button button = new Button(comp, SWT.CHECK);
Label label = new Label(comp, SWT.NONE);
label.setText("Verbose console mode");
verboseMode = new Button(parent, SWT.CHECK);
verboseMode.setText("Verbose console mode");
}
private void createRemoteControl(Composite parent) {
@ -189,28 +193,39 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
group.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
group.setLayoutData(gd);
group.setText("Remote Connection");
group.setText("Remote Target");
useRemote = new Button(group, SWT.CHECK);
useRemote.setText("Use remote connection");
useRemote.setText("Use remote target");
useRemote.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
useRemoteChanged();
}
});
remoteConnection = new Composite(group, SWT.NONE);
remoteTarget = new Composite(group, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
remoteConnection.setLayout(layout);
remoteTarget.setLayout(layout);
Label label = new Label(remoteConnection, SWT.NONE);
Label label = new Label(remoteTarget, SWT.NONE);
label.setText("Host name or IP address:");
ipAddress = new Text(remoteConnection, SWT.BORDER);
ipAddress = new Text(remoteTarget, SWT.BORDER);
gd = new GridData();
gd.widthHint = 100;
ipAddress.setLayoutData(gd);
label = new Label(remoteConnection, SWT.NONE);
label = new Label(remoteTarget, SWT.NONE);
label.setText("Port number:");
portNumber = new Text(remoteConnection, SWT.BORDER);
portNumber = new Text(remoteTarget, SWT.BORDER);
portNumber.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
e.doit = Character.isDigit(e.character) || Character.isISOControl(e.character);
}
});
gd = new GridData();
gd.widthHint = 100;
portNumber.setLayoutData(gd);
}
private void useRemoteChanged() {
@ -220,16 +235,58 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
}
public void initializeFrom(ILaunchConfiguration configuration) {
useRemote.setSelection(true);
useRemoteChanged();
try {
gdbCommand.setText(configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT));
gdbinitFile.setText(configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT));
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
String cfname = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, defDesc.getName());
int cfid = 0;
for (int i = 0; i < cfDescs.length; ++i)
if (cfDescs[i].getName().equals(cfname)) {
cfid = i;
break;
}
commandFactory.select(cfid);
String protname = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]);
miProtocol.removeAll();
String[] protocols = cfDescs[cfid].getMIVersions();
for (int i = 0; i < protocols.length; ++i) {
miProtocol.add(protocols[i]);
if (protocols[i].equals(protname))
miProtocol.select(i);
}
verboseMode.setSelection(configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT));
useRemote.setSelection(configuration.getAttribute(GDBJtagConstants.ATTR_USE_REMOTE_TARGET, GDBJtagConstants.DEFAULT_USE_REMOTE_TARGET));
ipAddress.setText(configuration.getAttribute(GDBJtagConstants.ATTR_IP_ADDRESS, GDBJtagConstants.DEFAULT_IP_ADDRESS));
portNumber.setText(String.valueOf(configuration.getAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, GDBJtagConstants.DEFAULT_PORT_NUMBER)));
useRemoteChanged();
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
// TODO Auto-generated method stub
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
// TODO Auto-generated method stub
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT);
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT);
CommandFactoryManager cfManager = MIPlugin.getDefault().getCommandFactoryManager();
CommandFactoryDescriptor defDesc = cfManager.getDefaultDescriptor(GDBJtagConstants.DEBUGGER_ID);
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, defDesc.getName());
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, defDesc.getMIVersions()[0]);
configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT);
configuration.setAttribute(GDBJtagConstants.ATTR_USE_REMOTE_TARGET, GDBJtagConstants.DEFAULT_USE_REMOTE_TARGET);
configuration.setAttribute(GDBJtagConstants.ATTR_IP_ADDRESS, GDBJtagConstants.DEFAULT_IP_ADDRESS);
configuration.setAttribute(GDBJtagConstants.ATTR_PORT_NUMBER, GDBJtagConstants.DEFAULT_PORT_NUMBER);
}
}

View file

@ -41,8 +41,11 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
Text initCommands;
Button loadImage;
Text imageFileName;
Button imageFileBrowse;
Button imageFileWorkspace;
Button defaultRun;
Text runCommands;
Button runVarsButton;
public String getName() {
return "Startup";
@ -94,7 +97,7 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
varsButton.setText("Variables...");
varsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleVarsButtonSelected(initCommands);
varsButtonSelected(initCommands);
}
});
}
@ -130,14 +133,18 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
gd = new GridData(GridData.FILL_HORIZONTAL);
imageFileName.setLayoutData(gd);
Button button = new Button(group, SWT.NONE);
button.setText("Browse...");
button = new Button(group, SWT.NONE);
button.setText("Workspace...");
imageFileBrowse = new Button(group, SWT.NONE);
imageFileBrowse.setText("Browse...");
imageFileWorkspace = new Button(group, SWT.NONE);
imageFileWorkspace.setText("Workspace...");
}
private void loadImageChanged() {
imageFileName.setEnabled(loadImage.getSelection());
boolean enabled = loadImage.getSelection();
imageFileName.setEnabled(enabled);
imageFileBrowse.setEnabled(enabled);
imageFileWorkspace.setEnabled(enabled);
}
public void createRunGroup(Composite parent) {
@ -150,6 +157,11 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
defaultRun = new Button(group, SWT.CHECK);
defaultRun.setText("Use default run command");
defaultRun.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
defaultRunChanged();
}
});
runCommands = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
gd = new GridData(GridData.FILL_BOTH);
@ -161,18 +173,24 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
}
});
Button varsButton = new Button(group, SWT.NONE);
runVarsButton = new Button(group, SWT.NONE);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
varsButton.setLayoutData(gd);
varsButton.setText("Variables...");
varsButton.addSelectionListener(new SelectionAdapter() {
runVarsButton.setLayoutData(gd);
runVarsButton.setText("Variables...");
runVarsButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleVarsButtonSelected(runCommands);
varsButtonSelected(runCommands);
}
});
}
private void handleVarsButtonSelected(Text text) {
private void defaultRunChanged() {
boolean enabled = !defaultRun.getSelection();
runCommands.setEnabled(enabled);
runVarsButton.setEnabled(enabled);
}
private void varsButtonSelected(Text text) {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
text.append(dialog.getVariableExpression());
@ -180,21 +198,32 @@ public class GDBJtagStartupTab extends AbstractLaunchConfigurationTab {
public void initializeFrom(ILaunchConfiguration configuration) {
try {
initCommands.setText(configuration.getAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$
runCommands.setText(configuration.getAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$)
initCommands.setText(configuration.getAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, "")); //$NON-NLS-1$
loadImage.setSelection(configuration.getAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, GDBJtagConstants.DEFAULT_LOAD_IMAGE));
loadImageChanged();
imageFileName.setText(configuration.getAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, "")); //$NON-NLS-1$
defaultRun.setSelection(configuration.getAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, GDBJtagConstants.DEFAULT_USE_DEFAULT_RUN));
defaultRunChanged();
runCommands.setText(configuration.getAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, "")); //$NON-NLS-1$)
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
}
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, initCommands.getText());
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, runCommands.getText());
configuration.setAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, initCommands.getText());
configuration.setAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, loadImage.getSelection());
configuration.setAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, imageFileName.getText());
configuration.setAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, defaultRun.getSelection());
configuration.setAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, runCommands.getText());
}
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$
configuration.setAttribute(GDBJtagConstants.LAUNCH_ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$
configuration.setAttribute(GDBJtagConstants.ATTR_INIT_COMMANDS, ""); //$NON-NLS-1$
configuration.setAttribute(GDBJtagConstants.ATTR_LOAD_IMAGE, GDBJtagConstants.DEFAULT_LOAD_IMAGE);
configuration.setAttribute(GDBJtagConstants.ATTR_IMAGE_FILE_NAME, ""); //$NON-NLS-1$
configuration.setAttribute(GDBJtagConstants.ATTR_USE_DEFAULT_RUN, true);
configuration.setAttribute(GDBJtagConstants.ATTR_RUN_COMMANDS, ""); //$NON-NLS-1$
}
}