diff options
author | Mikhail Khodjaiants | 2003-12-05 20:46:29 +0000 |
---|---|---|
committer | Mikhail Khodjaiants | 2003-12-05 20:46:29 +0000 |
commit | 8a0a4cb7100a63323faab9f3204cd0747864dfa6 (patch) | |
tree | efa16d028cb7c50e402bd20d8d1b7448f48c6d43 /debug | |
parent | 565184adfaeb06017fa4df036e6c7d6b49fa9518 (diff) | |
download | org.eclipse.cdt-8a0a4cb7100a63323faab9f3204cd0747864dfa6.tar.gz org.eclipse.cdt-8a0a4cb7100a63323faab9f3204cd0747864dfa6.tar.xz org.eclipse.cdt-8a0a4cb7100a63323faab9f3204cd0747864dfa6.zip |
Fix for PR 47230: Need a shared library search path editing capability for GDBServerDebugger.
Implemented 'GDBServerDebuggerPage' as an extension of 'GDBDebuggerPage'.
Added two new control blocks - "TCP Connection" and "Serial Connection".
Diffstat (limited to 'debug')
5 files changed, 724 insertions, 298 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog index 7edc0b31b26..c5599722f38 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog @@ -1,3 +1,12 @@ +2003-12-01 Mikhail Khodjaiants + Fix for PR 47230: Need a shared library search path editing capability for GDBServerDebugger. + Implemented 'GDBServerDebuggerPage' as an extension of 'GDBDebuggerPage'. + Added two new control blocks - "TCP Connection" and "Serial Connection". + * src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java + * src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java + * src/org/eclipse/cdt/debug/mi/internal/ui/SerialPortSettingsBlock.java: new + * src/org/eclipse/cdt/debug/mi/internal/ui/TCPSettingsBlock.java: new + 2003-11-26 Mikhail Khodjaiants Cleanup. * GDBServerDebuggerPage.java diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java index 8a3a17f15c2..5bda33a621f 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java @@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Text; public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements Observer { - private TabFolder fTabFolder; + protected TabFolder fTabFolder; protected Text fGDBCommandText; protected Text fGDBInitText; private GDBSolibBlock fSolibBlock; @@ -160,12 +160,12 @@ public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements O ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; tabItem.setControl( comp ); - Composite subComp = ControlFactory.createCompositeEx( comp, 2, GridData.FILL_HORIZONTAL ); + Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; Label label = ControlFactory.createLabel( subComp, "GDB debugger:" ); GridData gd = new GridData(); - gd.horizontalSpan = 2; +// gd.horizontalSpan = 2; label.setLayoutData( gd ); fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); @@ -191,7 +191,7 @@ public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements O private void handleGDBButtonSelected() { FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( "GDB Command" ); + dialog.setText( "GDB Command File" ); String gdbCommand = fGDBCommandText.getText().trim(); int lastSeparatorIndex = gdbCommand.lastIndexOf( File.separator ); if ( lastSeparatorIndex != -1 ) @@ -209,7 +209,7 @@ public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements O label = ControlFactory.createLabel( subComp, "GDB command file:" ); gd = new GridData(); - gd.horizontalSpan = 2; +// gd.horizontalSpan = 2; label.setLayoutData( gd ); fGDBInitText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java index c01c9a70f45..8d5ad8630d7 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java @@ -1,23 +1,24 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. * - * Contributors: - * Monta Vista - initial API and implementation - *******************************************************************************/ + */ package org.eclipse.cdt.debug.mi.internal.ui; +import java.io.File; + import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ComboDialogField; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; @@ -25,323 +26,262 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -public class GDBServerDebuggerPage extends AbstractLaunchConfigurationTab { - - protected Text fDebuggerCommandText; - protected Button fTCPButton; - protected Button fAsyncButton; - protected Text fHostText; - protected Text fHostPort; - protected Text fAsyncDev; - protected Combo fAsyncDevSpeedCombo; - private Button fAutoSoLibButton; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; - public void createControl(Composite parent) { - Composite comp = new Composite(parent, SWT.NONE); - GridLayout topLayout = new GridLayout(); - topLayout.numColumns = 2; - comp.setLayout(topLayout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - comp.setLayoutData(gd); - setControl(comp); - - createVerticalSpacer(comp, 2); - - Label debugCommandLabel= new Label(comp, SWT.NONE); - debugCommandLabel.setText("GDBServer gdb executable:"); - - fDebuggerCommandText= new Text(comp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - fDebuggerCommandText.setLayoutData(gd); - fDebuggerCommandText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); +/** + * Enter type comment. + * + * @since Nov 20, 2003 + */ +public class GDBServerDebuggerPage extends GDBDebuggerPage +{ + private final static String CONNECTION_TCP = "TCP"; + private final static String CONNECTION_SERIAL = "Serial"; - Composite radioComp = new Composite(comp, SWT.NONE); - GridLayout radioLayout = new GridLayout(2, true); - radioLayout.marginHeight = 0; - radioLayout.marginWidth = 0; - radioComp.setLayout(radioLayout); - gd = new GridData(); - gd.horizontalSpan = 2; - radioComp.setLayoutData(gd); - fTCPButton = createRadioButton(radioComp, "Connect using TCP"); - fTCPButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean isTcp = fTCPButton.getSelection(); - fHostPort.setEnabled(isTcp); - fHostText.setEnabled(isTcp); - updateLaunchConfigurationDialog(); - } - }); - fAsyncButton = createRadioButton(radioComp, "Connect using a serial port"); - fAsyncButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fAsyncDev.setEnabled(fAsyncButton.getSelection()); - fAsyncDevSpeedCombo.setEnabled(fAsyncButton.getSelection()); - updateLaunchConfigurationDialog(); - } - }); + private ComboDialogField fConnectionField; + private String[] fConnections = new String[] { CONNECTION_TCP, CONNECTION_SERIAL }; + private TCPSettingsBlock fTCPBlock; + private SerialPortSettingsBlock fSerialBlock; + private Composite fConnectionStack; - Label hostTextLabel= new Label(comp, SWT.NONE); - hostTextLabel.setText("GDBServer TCP host:"); - - fHostText= new Text(comp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - fHostText.setLayoutData(gd); - fHostText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); + public GDBServerDebuggerPage() + { + super(); + fConnectionField = createConnectionField(); + fTCPBlock = new TCPSettingsBlock(); + fSerialBlock = new SerialPortSettingsBlock(); + fTCPBlock.addObserver( this ); + fSerialBlock.addObserver( this ); + } - Label hostPortLabel= new Label(comp, SWT.NONE); - hostPortLabel.setText("GDBServer TCP port:"); - - fHostPort= new Text(comp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - fHostPort.setLayoutData(gd); - fHostPort.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); + public void createMainTab( TabFolder tabFolder ) + { + TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); + tabItem.setText( "Main" ); - + Composite comp = ControlFactory.createCompositeEx( fTabFolder, 1, GridData.FILL_BOTH ); + ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; + tabItem.setControl( comp ); - Label asyncDevLabel= new Label(comp, SWT.NONE); - asyncDevLabel.setText("Serial device:"); - - fAsyncDev= new Text(comp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - fAsyncDev.setLayoutData(gd); - fAsyncDev.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); + Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); + ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - Label asyncDevSpeedLabel= new Label(comp, SWT.NONE); - asyncDevSpeedLabel.setText("Serial speed:"); - - - fAsyncDevSpeedCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY); - String choices [] = {"9600", "19200","38400", "57600", "115200"}; - fAsyncDevSpeedCombo.setItems(choices); - fAsyncDevSpeedCombo.select(choices.length-1); - - gd = new GridData(GridData.FILL_HORIZONTAL); - fAsyncDevSpeedCombo.setLayoutData(gd); - fAsyncDevSpeedCombo.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent arg0) { - - updateLaunchConfigurationDialog(); - - } - }); + Label label = ControlFactory.createLabel( subComp, "GDB debugger:" ); + GridData gd = new GridData(); +// gd.horizontalSpan = 2; + label.setLayoutData( gd ); - fTCPButton.setSelection(true); - fAsyncButton.setSelection(false); - fHostText.setEnabled(true); - fHostPort.setEnabled(true); - fAsyncDev.setEnabled(false); - fHostPort.setEnabled(true); - fHostText.setEnabled(true); - fAsyncDevSpeedCombo.setEnabled(false); + fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); + fGDBCommandText.addModifyListener( + new ModifyListener() + { + public void modifyText( ModifyEvent evt ) + { + updateLaunchConfigurationDialog(); + } + } ); - createVerticalSpacer(comp, 2); + Button button = createPushButton( subComp, "&Browse...", null ); + button.addSelectionListener( + new SelectionAdapter() + { + public void widgetSelected( SelectionEvent evt ) + { + handleGDBButtonSelected(); + updateLaunchConfigurationDialog(); + } + + private void handleGDBButtonSelected() + { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( "GDB Command File" ); + String gdbCommand = fGDBCommandText.getText().trim(); + int lastSeparatorIndex = gdbCommand.lastIndexOf( File.separator ); + if ( lastSeparatorIndex != -1 ) + { + dialog.setFilterPath( gdbCommand.substring( 0, lastSeparatorIndex ) ); + } + String res = dialog.open(); + if ( res == null ) + { + return; + } + fGDBCommandText.setText( res ); + } + } ); - fAutoSoLibButton = new Button(comp, SWT.CHECK ) ; - fAutoSoLibButton.setText("Load shared library symbols automatically"); + label = ControlFactory.createLabel( subComp, "GDB command file:" ); gd = new GridData(); - gd.horizontalSpan = 2; - fAutoSoLibButton.setLayoutData(gd); -/* - ListEditor listEditor = new ListEditor("1", "Shared library search paths:", comp) { - protected String createList(String[] items) { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < items.length; i++) { - buf.append(items[i]); - buf.append(';'); - } - return buf.toString(); - } - protected String getNewInputObject() { -// StringInputDialog dialog= new StringInputDialog(comp.getShell(), "Library Path", null, "Enter a library path", "", null); -// if (dialog.open() == dialog.OK) { -// return dialog.getValue(); -// } else { -// return null; -// } - return null; - } +// gd.horizontalSpan = 2; + label.setLayoutData( gd ); - protected String[] parseString(String list) { - StringTokenizer st = new StringTokenizer(list, ";"); - ArrayList v = new ArrayList(); - while (st.hasMoreElements()) { - v.add(st.nextElement()); - } - return (String[]) v.toArray(new String[v.size()]); - } + fGDBInitText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); + gd = new GridData( GridData.FILL_HORIZONTAL ); + fGDBInitText.setLayoutData( gd ); + fGDBInitText.addModifyListener( new ModifyListener() + { + public void modifyText( ModifyEvent evt ) + { + updateLaunchConfigurationDialog(); + } + } ); + button = createPushButton( subComp, "&Browse...", null ); + button.addSelectionListener( + new SelectionAdapter() + { + public void widgetSelected( SelectionEvent evt ) + { + handleGDBInitButtonSelected(); + updateLaunchConfigurationDialog(); + } + + private void handleGDBInitButtonSelected() + { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( "GDB command file" ); + String gdbCommand = fGDBInitText.getText().trim(); + int lastSeparatorIndex = gdbCommand.lastIndexOf( File.separator ); + if ( lastSeparatorIndex != -1 ) + { + dialog.setFilterPath( gdbCommand.substring( 0, lastSeparatorIndex ) ); + } + String res = dialog.open(); + if ( res == null ) + { + return; + } + fGDBInitText.setText( res ); + } + } ); - }; -*/ - + extendMainTab( comp ); } - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - String attr; - - attr = null; - try { - attr = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, (String) null); - } catch (CoreException e) { - } - if (attr == null) { - configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); - } + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.GDBDebuggerPage#extendMainTab(org.eclipse.swt.widgets.Composite) + */ + protected void extendMainTab( Composite parent ) + { + Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); + ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - /* The booleans should already be correct. */ - attr = null; - try { - attr = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, (String) null); - } catch (CoreException e) { - } - if (attr == null) { - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, ""); - } - attr = null; - try { - attr = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, (String) null); - } catch (CoreException e) { - } - if (attr == null) { - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, ""); - } - attr = null; - try { - attr = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, (String) null); - } catch (CoreException e) { - } - if (attr == null) { - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "/dev/ttyS0"); - } - attr = null; - try { - attr = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, (String) null); - } catch (CoreException e) { - } - if (attr == null) { - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "115200"); - } + fConnectionField.doFillIntoGrid( comp, 2 ); + ((GridData)fConnectionField.getComboControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + PixelConverter converter = new PixelConverter( comp ); + LayoutUtil.setWidthHint( fConnectionField.getComboControl( null ), converter.convertWidthInCharsToPixels( 15 ) ); + fConnectionStack = ControlFactory.createCompositeEx( comp, 1, GridData.FILL_BOTH ); + StackLayout stackLayout = new StackLayout(); + fConnectionStack.setLayout( stackLayout ); + ((GridData)fConnectionStack.getLayoutData()).horizontalSpan = 2; + fTCPBlock.createBlock( fConnectionStack ); + fSerialBlock.createBlock( fConnectionStack ); + connectionTypeChanged(); } - /** - * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration) - */ - public boolean isValid(ILaunchConfiguration launchConfig) { - boolean valid; - - valid= fDebuggerCommandText.getText().length() != 0; - setErrorMessage(null); - setMessage(null); - if (!valid) { - setErrorMessage("Debugger executable must be specified"); - setMessage(null); + private ComboDialogField createConnectionField() + { + ComboDialogField field = new ComboDialogField( SWT.DROP_DOWN | SWT.READ_ONLY ); + field.setLabelText( "Connection: " ); + field.setItems( fConnections ); + field.setDialogFieldListener( + new IDialogFieldListener() + { + public void dialogFieldChanged( DialogField field ) + { + connectionTypeChanged(); + } + } ); + return field; + } + + protected void connectionTypeChanged() + { + ((StackLayout)fConnectionStack.getLayout()).topControl = null; + int index = fConnectionField.getSelectionIndex(); + if ( index >= 0 && index < fConnections.length ) + { + String[] connTypes = fConnectionField.getItems(); + if ( CONNECTION_TCP.equals( connTypes[index] ) ) + ((StackLayout)fConnectionStack.getLayout()).topControl = fTCPBlock.getControl(); + else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) + ((StackLayout)fConnectionStack.getLayout()).topControl = fSerialBlock.getControl(); } - if (valid) { - if (fTCPButton.getSelection()) { - valid = ((fHostText.getText().length() != 0) - && (fHostPort.getText().length() != 0)); - if (!valid) { - setErrorMessage("If TCP is selected, host and port must be specified"); - setMessage(null); + fConnectionStack.layout(); + updateLaunchConfigurationDialog(); + } + + public boolean isValid( ILaunchConfiguration launchConfig ) + { + if ( super.isValid( launchConfig ) ) + { + setErrorMessage( null ); + setMessage( null ); + + int index = fConnectionField.getSelectionIndex(); + if ( index >= 0 && index < fConnections.length ) + { + String[] connTypes = fConnectionField.getItems(); + if ( CONNECTION_TCP.equals( connTypes[index] ) ) + { + if ( !fTCPBlock.isValid( launchConfig ) ) + { + setErrorMessage( fTCPBlock.getErrorMessage() ); + return false; + } } - } else { - valid = ((fAsyncDev.getText().length() != 0) && (fAsyncDevSpeedCombo.getSelectionIndex()!=-1)) ; - if (!valid) { - setErrorMessage("If Async is selected, device and speed must be specified"); - setMessage(null); + else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) + { + if ( !fSerialBlock.isValid( launchConfig ) ) + { + setErrorMessage( fSerialBlock.getErrorMessage() ); + return false; + } } + return true; } } - - return valid; + return false; } - public void initializeFrom(ILaunchConfiguration configuration) { - String debuggerCommand = "gdb"; + public void initializeFrom( ILaunchConfiguration configuration ) + { + super.initializeFrom( configuration ); + boolean isTcp = false; - String hostText = ""; - String hostPort = ""; - String asyncDev = "/dev/ttyS0"; - String asyncDevSpeed = "115200"; - boolean autosolib = false; - try { - debuggerCommand = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb"); - autosolib = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, false); - } catch (CoreException e) { - } - try { - isTcp = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false); - hostText = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, ""); - hostPort = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, ""); - asyncDev = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, ""); - asyncDevSpeed = configuration.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, ""); - } catch (CoreException e) { + try + { + isTcp = configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); + } + catch( CoreException e ) + { } - fDebuggerCommandText.setText(debuggerCommand); - fTCPButton.setSelection(isTcp); - fAsyncButton.setSelection(!isTcp); - fHostText.setText(hostText); - fHostPort.setText(hostPort); - fAsyncDev.setText(asyncDev); - fAsyncDevSpeedCombo.select(fAsyncDevSpeedCombo.indexOf(asyncDevSpeed)); - fHostText.setEnabled(isTcp); - fHostPort.setEnabled(isTcp); - fAsyncDev.setEnabled(!isTcp); - fAsyncDevSpeedCombo.setEnabled(!isTcp); - fAutoSoLibButton.setSelection(autosolib); - } - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - String debuggerCommand = fDebuggerCommandText.getText(); - String hostText = fHostText.getText(); - String hostPort = fHostPort.getText(); - String asyncDev = fAsyncDev.getText(); - String asyncDevSpeed = fAsyncDevSpeedCombo.getItem(fAsyncDevSpeedCombo.getSelectionIndex()); - debuggerCommand.trim(); - hostText.trim(); - hostPort.trim(); - asyncDev.trim(); - configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, debuggerCommand); - configuration.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, fAutoSoLibButton.getSelection()); - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, fTCPButton.getSelection()); - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_HOST, hostText); - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_PORT, hostPort); - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, asyncDev); - configuration.setAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, asyncDevSpeed); + fTCPBlock.initializeFrom( configuration ); + fSerialBlock.initializeFrom( configuration ); + + fConnectionField.selectItem( ( isTcp ) ? 0 : 1 ); } - public String getName() { - return "GDBServer Debugger Options"; + public void performApply( ILaunchConfigurationWorkingCopy configuration ) + { + super.performApply( configuration ); + if ( fConnectionField != null ) + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, fConnectionField.getSelectionIndex() == 0 ); + fTCPBlock.performApply( configuration ); + fSerialBlock.performApply( configuration ); } - /** - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() - */ - protected void updateLaunchConfigurationDialog() { - super.updateLaunchConfigurationDialog(); + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) + { + super.setDefaults( configuration ); + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); + fTCPBlock.setDefaults( configuration ); + fSerialBlock.setDefaults( configuration ); } } diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SerialPortSettingsBlock.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SerialPortSettingsBlock.java new file mode 100644 index 00000000000..6e2a3bce8b5 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SerialPortSettingsBlock.java @@ -0,0 +1,241 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.internal.ui; + +import java.util.Observable; + +import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ComboDialogField; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.StringDialogField; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * Enter type comment. + * + * @since Nov 20, 2003 + */ +public class SerialPortSettingsBlock extends Observable +{ + private final static String DEFAULT_ASYNC_DEVICE = "/dev/ttyS0"; + private final static String DEFAULT_ASYNC_DEVICE_SPEED = "115200"; + + private Shell fShell; + + private StringDialogField fDeviceField; + private ComboDialogField fSpeedField; + + private String fSpeedChoices[] = { "9600", "19200", "38400", "57600", "115200" }; + + private Control fControl; + + private String fErrorMessage = null; + + public SerialPortSettingsBlock() + { + super(); + fDeviceField = createDeviceField(); + fSpeedField = createSpeedField(); + } + + public void createBlock( Composite parent ) + { + fShell = parent.getShell(); + Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); + ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout)comp.getLayout()).marginHeight = 0; + ((GridLayout)comp.getLayout()).marginWidth = 0; + comp.setFont( JFaceResources.getDialogFont() ); + + PixelConverter converter = new PixelConverter( comp ); + + fDeviceField.doFillIntoGrid( comp, 2 ); + LayoutUtil.setWidthHint( fDeviceField.getTextControl( null ), converter.convertWidthInCharsToPixels( 20 ) ); + fSpeedField.doFillIntoGrid( comp, 2 ); + ((GridData)fSpeedField.getComboControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + + setControl( comp ); + } + + protected Shell getShell() + { + return fShell; + } + + public void dispose() + { + deleteObservers(); + } + + public void initializeFrom( ILaunchConfiguration configuration ) + { + initializeDevice( configuration ); + initializeSpeed( configuration ); + } + + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) + { + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE ); + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ); + } + + public void performApply( ILaunchConfigurationWorkingCopy configuration ) + { + if ( fDeviceField != null ) + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, fDeviceField.getText().trim() ); + if ( fSpeedField != null ) + { + int index = fSpeedField.getSelectionIndex(); + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, getSpeedItem( index ) ); + } + } + + private StringDialogField createDeviceField() + { + StringDialogField field = new StringDialogField(); + field.setLabelText( "Device: " ); + field.setDialogFieldListener( + new IDialogFieldListener() + { + public void dialogFieldChanged( DialogField field ) + { + deviceFieldChanged(); + } + } ); + return field; + } + + private ComboDialogField createSpeedField() + { + ComboDialogField field = new ComboDialogField( SWT.DROP_DOWN | SWT.READ_ONLY ); + field.setLabelText( "Speed: " ); + field.setItems( fSpeedChoices ); + field.setDialogFieldListener( + new IDialogFieldListener() + { + public void dialogFieldChanged( DialogField field ) + { + speedFieldChanged(); + } + } ); + return field; + } + + protected void deviceFieldChanged() + { + updateErrorMessage(); + setChanged(); + notifyObservers(); + } + + protected void speedFieldChanged() + { + updateErrorMessage(); + setChanged(); + notifyObservers(); + } + + private void initializeDevice( ILaunchConfiguration configuration ) + { + if ( fDeviceField != null ) + { + try + { + fDeviceField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE ) ); + } + catch( CoreException e ) + { + } + } + } + + private void initializeSpeed( ILaunchConfiguration configuration ) + { + if ( fSpeedField != null ) + { + int index = 0; + try + { + index = getSpeedItemIndex( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ) ); + } + catch( CoreException e ) + { + } + fSpeedField.selectItem( index ); + } + } + + private String getSpeedItem( int index ) + { + return ( index >= 0 && index < fSpeedChoices.length ) ? fSpeedChoices[index] : null; + } + + private int getSpeedItemIndex( String item ) + { + for ( int i = 0; i < fSpeedChoices.length; ++i ) + if ( fSpeedChoices[i].equals( item ) ) + return i; + return 0; + } + + public Control getControl() + { + return fControl; + } + + protected void setControl( Control control ) + { + fControl = control; + } + + public boolean isValid( ILaunchConfiguration configuration ) + { + updateErrorMessage(); + return ( getErrorMessage() == null ); + } + + private void updateErrorMessage() + { + setErrorMessage( null ); + if ( fDeviceField != null && fSpeedField != null ) + { + if ( fDeviceField.getText().trim().length() == 0 ) + setErrorMessage( "Device must be specified." ); + else if ( !deviceIsValid( fDeviceField.getText().trim() ) ) + setErrorMessage( "Invalid device." ); + else if ( fSpeedField.getSelectionIndex() < 0 ) + setErrorMessage( "Speed must be specified." ); + } + } + + public String getErrorMessage() + { + return fErrorMessage; + } + + private void setErrorMessage( String string ) + { + fErrorMessage = string; + } + + private boolean deviceIsValid( String hostName ) + { + return true; + } +} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/TCPSettingsBlock.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/TCPSettingsBlock.java new file mode 100644 index 00000000000..34146efb8bb --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/TCPSettingsBlock.java @@ -0,0 +1,236 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ + +package org.eclipse.cdt.debug.mi.internal.ui; + +import java.util.Observable; + +import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; +import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.StringDialogField; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; + +/** + * Enter type comment. + * + * @since Nov 20, 2003 + */ +public class TCPSettingsBlock extends Observable +{ + private final static String DEFAULT_HOST_NAME = "localhost"; + private final static String DEFAULT_PORT_NUMBER = "10000"; + + private Shell fShell; + + private StringDialogField fHostNameField; + private StringDialogField fPortNumberField; + + private Control fControl; + + private String fErrorMessage = null; + + public TCPSettingsBlock() + { + super(); + fHostNameField = createHostNameField(); + fPortNumberField = createPortNumberField(); + } + + public void createBlock( Composite parent ) + { + fShell = parent.getShell(); + Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); + ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout)comp.getLayout()).marginHeight = 0; + ((GridLayout)comp.getLayout()).marginWidth = 0; + comp.setFont( JFaceResources.getDialogFont() ); + + PixelConverter converter = new PixelConverter( comp ); + + fHostNameField.doFillIntoGrid( comp, 2 ); + LayoutUtil.setWidthHint( fHostNameField.getTextControl( null ), converter.convertWidthInCharsToPixels( 20 ) ); + fPortNumberField.doFillIntoGrid( comp, 2 ); + ((GridData)fPortNumberField.getTextControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + LayoutUtil.setWidthHint( fPortNumberField.getTextControl( null ), converter.convertWidthInCharsToPixels( 10 ) ); + + setControl( comp ); + } + + protected Shell getShell() + { + return fShell; + } + + public void dispose() + { + deleteObservers(); + } + + public void initializeFrom( ILaunchConfiguration configuration ) + { + initializeHostName( configuration ); + initializePortNumber( configuration ); + } + + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) + { + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME ); + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER ); + } + + public void performApply( ILaunchConfigurationWorkingCopy configuration ) + { + if ( fHostNameField != null ) + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, fHostNameField.getText().trim() ); + if ( fPortNumberField != null ) + configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, fPortNumberField.getText().trim() ); + } + + private StringDialogField createHostNameField() + { + StringDialogField field = new StringDialogField(); + field.setLabelText( "Host name or IP address: " ); + field.setDialogFieldListener( + new IDialogFieldListener() + { + public void dialogFieldChanged( DialogField field ) + { + hostNameFieldChanged(); + } + } ); + return field; + } + + private StringDialogField createPortNumberField() + { + StringDialogField field = new StringDialogField(); + field.setLabelText( "Port number: " ); + field.setDialogFieldListener( + new IDialogFieldListener() + { + public void dialogFieldChanged( DialogField field ) + { + portNumberFieldChanged(); + } + } ); + return field; + } + + protected void hostNameFieldChanged() + { + updateErrorMessage(); + setChanged(); + notifyObservers(); + } + + protected void portNumberFieldChanged() + { + updateErrorMessage(); + setChanged(); + notifyObservers(); + } + + private void initializeHostName( ILaunchConfiguration configuration ) + { + if ( fHostNameField != null ) + { + try + { + fHostNameField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME ) ); + } + catch( CoreException e ) + { + } + } + } + + private void initializePortNumber( ILaunchConfiguration configuration ) + { + if ( fPortNumberField != null ) + { + try + { + fPortNumberField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER ) ); + } + catch( CoreException e ) + { + } + } + } + + public Control getControl() + { + return fControl; + } + + protected void setControl( Control control ) + { + fControl = control; + } + + public boolean isValid( ILaunchConfiguration configuration ) + { + updateErrorMessage(); + return ( getErrorMessage() == null ); + } + + private void updateErrorMessage() + { + setErrorMessage( null ); + if ( fHostNameField != null && fPortNumberField != null ) + { + if ( fHostNameField.getText().trim().length() == 0 ) + setErrorMessage( "Host name or IP address must be specified." ); + else if ( !hostNameIsValid( fHostNameField.getText().trim() ) ) + setErrorMessage( "Invalid host name or IP address." ); + else if ( fPortNumberField.getText().trim().length() == 0 ) + setErrorMessage( "Port number must be specified." ); + else if ( !portNumberIsValid( fPortNumberField.getText().trim() ) ) + setErrorMessage( "Invalid port number." ); + } + } + + public String getErrorMessage() + { + return fErrorMessage; + } + + private void setErrorMessage( String string ) + { + fErrorMessage = string; + } + + private boolean hostNameIsValid( String hostName ) + { + return true; + } + + private boolean portNumberIsValid( String portNumber ) + { + try + { + int port = Short.parseShort( portNumber ); + if ( port < 0 ) + return false; + } + catch( NumberFormatException e ) + { + return false; + } + return true; + } +} |