From 6e702766cb26d10de72227b57c95cec1ef492e8b Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Mon, 23 Aug 2004 20:39:04 +0000 Subject: [PATCH] Added API to allow the access to the internal MI UI components by client plugins. Changed the "Solib search path" component. Reformatting and cleanup. --- debug/org.eclipse.cdt.debug.mi.ui/ChangeLog | 21 ++ .../mi/internal/ui/CygwinDebuggerPage.java | 3 + .../debug/mi/internal/ui/GDBDebuggerPage.java | 286 ++++++++-------- .../mi/internal/ui/GDBServerDebuggerPage.java | 260 +++++++------- .../debug/mi/internal/ui/GDBSolibBlock.java | 199 ++++++----- .../mi/internal/ui/IMIHelpContextIds.java | 12 +- .../debug/mi/internal/ui/IMIUIConstants.java | 9 +- .../mi/internal/ui/MIUIMessages.properties | 2 + .../debug/mi/internal/ui/PixelConverter.java | 23 +- .../internal/ui/SerialPortSettingsBlock.java | 161 ++++----- .../mi/internal/ui/SolibSearchPathBlock.java | 320 ++++++++++++++---- .../mi/internal/ui/TCPSettingsBlock.java | 149 +++----- .../actions/SetAutoSolibActionDelegate.java | 224 ++++++------ .../ui/preferences/MIPreferencePage.java | 112 +++--- .../ui/IMILaunchConfigurationComponent.java | 84 +++++ .../cdt/debug/mi/ui/IPathProvider.java | 20 ++ .../eclipse/cdt/debug/mi/ui/MIUIUtils.java | 30 ++ 17 files changed, 1025 insertions(+), 890 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IMILaunchConfigurationComponent.java create mode 100644 debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IPathProvider.java create mode 100644 debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/MIUIUtils.java diff --git a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog index cf004576330..14fd531f250 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.ui/ChangeLog @@ -1,3 +1,24 @@ +2004-08-23 Mikhail Khodjaiants + Added API to allow the access to the internal MI UI components by client plugins. + Changed the "Solib search path" component. + Reformatting and cleanup. + * MIUIMessages.properties + * CygwinDebuggerPage.java + * GDBDebuggerPage.java + * GDBServerDebuggerPage.java + * GDBSolibBlock.java + * IMIHelpContextIds.java + * IMILaunchConfigurationComponent.java: new + * IMIUIConstants.java + * IPathProvider.java: new + * MIUIUtils.java: new + * PixelConverter.java + * SerialPortSettingsBlock.java + * SolibSearchPathBlock.java + * TCPSettingsBlock.java + * SetAutoSolibActionDelegate.java + * MIPreferencePage.java + 2004-07-14 Mikhail Khodjaiants Wrong fix. Falling back. * GDBSolibBlock.java diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CygwinDebuggerPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CygwinDebuggerPage.java index ab2dc248832..b0ad2f1501c 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CygwinDebuggerPage.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CygwinDebuggerPage.java @@ -12,6 +12,9 @@ package org.eclipse.cdt.debug.mi.internal.ui; import org.eclipse.swt.widgets.TabFolder; +/** + * CygWin-specific extension of GDBDebuggerPage. + */ public class CygwinDebuggerPage extends GDBDebuggerPage { public String getName() { 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 954ba329051..5eddd07dcd8 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 @@ -14,6 +14,8 @@ import java.io.File; import java.util.Observable; import java.util.Observer; import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent; +import org.eclipse.cdt.debug.mi.ui.MIUIUtils; import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; @@ -36,75 +38,73 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; -public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements Observer -{ - protected TabFolder fTabFolder; - protected Text fGDBCommandText; - protected Text fGDBInitText; - private GDBSolibBlock fSolibBlock; +/** + * The dynamic tab for gdb-based debugger implementations. + */ +public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements Observer { - public void createControl( Composite parent ) - { + protected TabFolder fTabFolder; + + protected Text fGDBCommandText; + + protected Text fGDBInitText; + + private IMILaunchConfigurationComponent fSolibBlock; + + private boolean fIsInitializing = false; + + public void createControl( Composite parent ) { Composite comp = new Composite( parent, SWT.NONE ); comp.setLayout( new GridLayout() ); comp.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - fTabFolder = new TabFolder( comp, SWT.NONE ); fTabFolder.setLayoutData( new GridData( GridData.FILL_BOTH | GridData.GRAB_VERTICAL ) ); - createTabs( fTabFolder ); - - fTabFolder.setSelection( 0 ); + fTabFolder.setSelection( 0 ); setControl( parent ); } - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) - { + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$ configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, "" ); //$NON-NLS-1$ if ( fSolibBlock != null ) - fSolibBlock.setDefaults( configuration ); + fSolibBlock.setDefaults( configuration ); } /** * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration) */ - public boolean isValid( ILaunchConfiguration launchConfig ) - { + public boolean isValid( ILaunchConfiguration launchConfig ) { boolean valid = fGDBCommandText.getText().length() != 0; - if ( valid ) - { + if ( valid ) { setErrorMessage( null ); setMessage( null ); - } - else - { + } + else { setErrorMessage( MIUIMessages.getString( "GDBDebuggerPage.0" ) ); //$NON-NLS-1$ setMessage( null ); } return valid; } - public void initializeFrom( ILaunchConfiguration configuration ) - { + public void initializeFrom( ILaunchConfiguration configuration ) { + setInitializing( true ); String gdbCommand = "gdb"; //$NON-NLS-1$ String gdbInit = ""; //$NON-NLS-1$ - try - { + try { gdbCommand = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$ gdbInit = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, "" ); //$NON-NLS-1$ - } - catch( CoreException e ) - { + } + catch( CoreException e ) { } if ( fSolibBlock != null ) - fSolibBlock.initializeFrom( configuration ); + fSolibBlock.initializeFrom( configuration ); fGDBCommandText.setText( gdbCommand ); fGDBInitText.setText( gdbInit ); + setInitializing( false ); } - public void performApply( ILaunchConfigurationWorkingCopy configuration ) - { + public void performApply( ILaunchConfigurationWorkingCopy configuration ) { String gdbStr = fGDBCommandText.getText(); gdbStr.trim(); configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, gdbStr ); @@ -115,181 +115,169 @@ public class GDBDebuggerPage extends AbstractLaunchConfigurationTab implements O fSolibBlock.performApply( configuration ); } - public String getName() - { + public String getName() { return MIUIMessages.getString( "GDBDebuggerPage.1" ); //$NON-NLS-1$ } - + /** * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getShell() */ - protected Shell getShell() - { + protected Shell getShell() { return super.getShell(); } /** * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() */ - protected void updateLaunchConfigurationDialog() - { + protected void updateLaunchConfigurationDialog() { super.updateLaunchConfigurationDialog(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ - public void update( Observable o, Object arg ) - { - updateLaunchConfigurationDialog(); + public void update( Observable o, Object arg ) { + if ( !isInitializing() ) + updateLaunchConfigurationDialog(); } - public GDBSolibBlock createSolibBlock( Composite parent ) - { - GDBSolibBlock block = new GDBSolibBlock(); - block.createBlock( parent, true, true, true ); + public IMILaunchConfigurationComponent createSolibBlock( Composite parent ) { + IMILaunchConfigurationComponent block = MIUIUtils.createGDBSolibBlock( MIUIUtils.createSolibSearchPathBlock( null ), true, true ); + block.createControl( parent ); return block; } - public void createTabs( TabFolder tabFolder ) - { + public void createTabs( TabFolder tabFolder ) { createMainTab( tabFolder ); createSolibTab( tabFolder ); } - public void createMainTab( TabFolder tabFolder ) - { + public void createMainTab( TabFolder tabFolder ) { TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); tabItem.setText( MIUIMessages.getString( "GDBDebuggerPage.2" ) ); //$NON-NLS-1$ - Composite comp = ControlFactory.createCompositeEx( fTabFolder, 1, GridData.FILL_BOTH ); ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - tabItem.setControl( comp ); - + tabItem.setControl( comp ); Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - Label label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "GDBDebuggerPage.3" ) ); //$NON-NLS-1$ GridData gd = new GridData(); -// gd.horizontalSpan = 2; + // gd.horizontalSpan = 2; label.setLayoutData( gd ); - fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); - fGDBCommandText.addModifyListener( - new ModifyListener() - { - public void modifyText( ModifyEvent evt ) - { - updateLaunchConfigurationDialog(); - } - } ); + fGDBCommandText.addModifyListener( new ModifyListener() { + public void modifyText( ModifyEvent evt ) { + if ( !isInitializing() ) + updateLaunchConfigurationDialog(); + } + } ); Button button = createPushButton( subComp, MIUIMessages.getString( "GDBDebuggerPage.4" ), null ); //$NON-NLS-1$ - button.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent evt ) - { - handleGDBButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBButtonSelected() - { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "GDBDebuggerPage.5" ) ); //$NON-NLS-1$ - 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 ); - } - } ); + button.addSelectionListener( new SelectionAdapter() { + public void widgetSelected( SelectionEvent evt ) { + handleGDBButtonSelected(); + updateLaunchConfigurationDialog(); + } + + private void handleGDBButtonSelected() { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( MIUIMessages.getString( "GDBDebuggerPage.5" ) ); //$NON-NLS-1$ + 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 ); + } + } ); label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "GDBDebuggerPage.6" ) ); //$NON-NLS-1$ gd = new GridData(); -// gd.horizontalSpan = 2; + // gd.horizontalSpan = 2; label.setLayoutData( gd ); - 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, MIUIMessages.getString( "GDBDebuggerPage.7" ), null ); //$NON-NLS-1$ - button.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent evt ) - { - handleGDBInitButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBInitButtonSelected() - { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "GDBDebuggerPage.8" ) ); //$NON-NLS-1$ - 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 ); - } - } ); + fGDBInitText.addModifyListener( new ModifyListener() { - label = ControlFactory.createLabel( comp, - MIUIMessages.getString( "GDBDebuggerPage.9" ), //$NON-NLS-1$ - 200, - SWT.DEFAULT, - SWT.WRAP ); + public void modifyText( ModifyEvent evt ) { + if ( !isInitializing() ) + updateLaunchConfigurationDialog(); + } + } ); + button = createPushButton( subComp, MIUIMessages.getString( "GDBDebuggerPage.7" ), null ); //$NON-NLS-1$ + button.addSelectionListener( new SelectionAdapter() { + + public void widgetSelected( SelectionEvent evt ) { + handleGDBInitButtonSelected(); + updateLaunchConfigurationDialog(); + } + + private void handleGDBInitButtonSelected() { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( MIUIMessages.getString( "GDBDebuggerPage.8" ) ); //$NON-NLS-1$ + 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 ); + } + } ); + label = ControlFactory.createLabel( comp, MIUIMessages.getString( "GDBDebuggerPage.9" ), //$NON-NLS-1$ + 200, SWT.DEFAULT, SWT.WRAP ); gd = new GridData( GridData.FILL_HORIZONTAL ); gd.horizontalSpan = 1; gd.widthHint = 200; label.setLayoutData( gd ); } - public void createSolibTab( TabFolder tabFolder ) - { + public void createSolibTab( TabFolder tabFolder ) { TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); tabItem.setText( MIUIMessages.getString( "GDBDebuggerPage.10" ) ); //$NON-NLS-1$ - Composite comp = ControlFactory.createCompositeEx( fTabFolder, 1, GridData.FILL_BOTH ); tabItem.setControl( comp ); - fSolibBlock = createSolibBlock( comp ); - fSolibBlock.addObserver( this ); - } - /* (non-Javadoc) + if ( fSolibBlock instanceof Observable ) + ((Observable)fSolibBlock).addObserver( this ); + } + + /* + * (non-Javadoc) + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() */ - public void dispose() - { - if ( fSolibBlock != null ) - { - fSolibBlock.deleteObserver( this ); - fSolibBlock.dispose(); - } + public void dispose() { + if ( fSolibBlock != null ) { + if ( fSolibBlock instanceof Observable ) + ((Observable)fSolibBlock).deleteObserver( this ); + fSolibBlock.dispose(); + } super.dispose(); } -} + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void activated( ILaunchConfigurationWorkingCopy workingCopy ) { + // Override the default behavior + } + + protected boolean isInitializing() { + return fIsInitializing; + } + + private void setInitializing( boolean isInitializing ) { + fIsInitializing = isInitializing; + } +} \ No newline at end of file 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 5adf7bafe6f..5265124160c 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 @@ -8,7 +8,6 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.debug.mi.internal.ui; import java.io.File; @@ -37,24 +36,27 @@ import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; /** - * Enter type comment. - * - * @since Nov 20, 2003 + * The dynamic debugger tab for remote launches using gdb server. */ -public class GDBServerDebuggerPage extends GDBDebuggerPage -{ +public class GDBServerDebuggerPage extends GDBDebuggerPage { + private final static String CONNECTION_TCP = MIUIMessages.getString( "GDBServerDebuggerPage.0" ); //$NON-NLS-1$ + private final static String CONNECTION_SERIAL = MIUIMessages.getString( "GDBServerDebuggerPage.1" ); //$NON-NLS-1$ private ComboDialogField fConnectionField; - private String[] fConnections = new String[] { CONNECTION_TCP, CONNECTION_SERIAL }; + private String[] fConnections = new String[]{ CONNECTION_TCP, CONNECTION_SERIAL }; + private TCPSettingsBlock fTCPBlock; + private SerialPortSettingsBlock fSerialBlock; + private Composite fConnectionStack; - public GDBServerDebuggerPage() - { + private boolean fIsInitializing = false; + + public GDBServerDebuggerPage() { super(); fConnectionField = createConnectionField(); fTCPBlock = new TCPSettingsBlock(); @@ -63,118 +65,101 @@ public class GDBServerDebuggerPage extends GDBDebuggerPage fSerialBlock.addObserver( this ); } - public void createMainTab( TabFolder tabFolder ) - { + public void createMainTab( TabFolder tabFolder ) { TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); tabItem.setText( MIUIMessages.getString( "GDBServerDebuggerPage.2" ) ); //$NON-NLS-1$ - Composite comp = ControlFactory.createCompositeEx( fTabFolder, 1, GridData.FILL_BOTH ); ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - tabItem.setControl( comp ); - + tabItem.setControl( comp ); Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - Label label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.3" ) ); //$NON-NLS-1$ GridData gd = new GridData(); -// gd.horizontalSpan = 2; + // gd.horizontalSpan = 2; label.setLayoutData( gd ); - fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); - fGDBCommandText.addModifyListener( - new ModifyListener() - { - public void modifyText( ModifyEvent evt ) - { - updateLaunchConfigurationDialog(); - } - } ); + fGDBCommandText.addModifyListener( new ModifyListener() { + public void modifyText( ModifyEvent evt ) { + if ( !isInitializing() ) + updateLaunchConfigurationDialog(); + } + } ); Button button = createPushButton( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.4" ), null ); //$NON-NLS-1$ - button.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent evt ) - { - handleGDBButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBButtonSelected() - { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "GDBServerDebuggerPage.5" ) ); //$NON-NLS-1$ - 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 ); - } - } ); + button.addSelectionListener( new SelectionAdapter() { + public void widgetSelected( SelectionEvent evt ) { + if ( !isInitializing() ) { + handleGDBButtonSelected(); + updateLaunchConfigurationDialog(); + } + } + + private void handleGDBButtonSelected() { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( MIUIMessages.getString( "GDBServerDebuggerPage.5" ) ); //$NON-NLS-1$ + 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 ); + } + } ); label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.6" ) ); //$NON-NLS-1$ gd = new GridData(); -// gd.horizontalSpan = 2; + // gd.horizontalSpan = 2; label.setLayoutData( gd ); - 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, MIUIMessages.getString( "GDBServerDebuggerPage.7" ), null ); //$NON-NLS-1$ - button.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent evt ) - { - handleGDBInitButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBInitButtonSelected() - { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "GDBServerDebuggerPage.8" ) ); //$NON-NLS-1$ - 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 ); - } - } ); + fGDBInitText.addModifyListener( new ModifyListener() { + public void modifyText( ModifyEvent evt ) { + if ( !isInitializing() ) + updateLaunchConfigurationDialog(); + } + } ); + button = createPushButton( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.7" ), null ); //$NON-NLS-1$ + button.addSelectionListener( new SelectionAdapter() { + + public void widgetSelected( SelectionEvent evt ) { + if ( !isInitializing() ) { + handleGDBInitButtonSelected(); + updateLaunchConfigurationDialog(); + } + } + + private void handleGDBInitButtonSelected() { + FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); + dialog.setText( MIUIMessages.getString( "GDBServerDebuggerPage.8" ) ); //$NON-NLS-1$ + 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 ); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.cdt.debug.mi.internal.ui.GDBDebuggerPage#extendMainTab(org.eclipse.swt.widgets.Composite) */ - protected void extendMainTab( Composite parent ) - { + protected void extendMainTab( Composite parent ) { Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - - fConnectionField.doFillIntoGrid( comp, 2 ); ((GridData)fConnectionField.getComboControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; PixelConverter converter = new PixelConverter( comp ); @@ -185,31 +170,31 @@ public class GDBServerDebuggerPage extends GDBDebuggerPage ((GridData)fConnectionStack.getLayoutData()).horizontalSpan = 2; fTCPBlock.createBlock( fConnectionStack ); fSerialBlock.createBlock( fConnectionStack ); - connectionTypeChanged(); } - private ComboDialogField createConnectionField() - { + private ComboDialogField createConnectionField() { ComboDialogField field = new ComboDialogField( SWT.DROP_DOWN | SWT.READ_ONLY ); field.setLabelText( MIUIMessages.getString( "GDBServerDebuggerPage.9" ) ); //$NON-NLS-1$ field.setItems( fConnections ); - field.setDialogFieldListener( - new IDialogFieldListener() - { - public void dialogFieldChanged( DialogField f ) - { - connectionTypeChanged(); - } - } ); + field.setDialogFieldListener( new IDialogFieldListener() { + + public void dialogFieldChanged( DialogField f ) { + if ( !isInitializing() ) + connectionTypeChanged(); + } + } ); return field; } - protected void connectionTypeChanged() - { + protected void connectionTypeChanged() { + connectionTypeChanged0(); + updateLaunchConfigurationDialog(); + } + + private void connectionTypeChanged0() { ((StackLayout)fConnectionStack.getLayout()).topControl = null; int index = fConnectionField.getSelectionIndex(); - if ( index >= 0 && index < fConnections.length ) - { + if ( index >= 0 && index < fConnections.length ) { String[] connTypes = fConnectionField.getItems(); if ( CONNECTION_TCP.equals( connTypes[index] ) ) ((StackLayout)fConnectionStack.getLayout()).topControl = fTCPBlock.getControl(); @@ -217,32 +202,23 @@ public class GDBServerDebuggerPage extends GDBDebuggerPage ((StackLayout)fConnectionStack.getLayout()).topControl = fSerialBlock.getControl(); } fConnectionStack.layout(); - updateLaunchConfigurationDialog(); } - public boolean isValid( ILaunchConfiguration launchConfig ) - { - if ( super.isValid( launchConfig ) ) - { + public boolean isValid( ILaunchConfiguration launchConfig ) { + if ( super.isValid( launchConfig ) ) { setErrorMessage( null ); setMessage( null ); - int index = fConnectionField.getSelectionIndex(); - if ( index >= 0 && index < fConnections.length ) - { + if ( index >= 0 && index < fConnections.length ) { String[] connTypes = fConnectionField.getItems(); - if ( CONNECTION_TCP.equals( connTypes[index] ) ) - { - if ( !fTCPBlock.isValid( launchConfig ) ) - { + if ( CONNECTION_TCP.equals( connTypes[index] ) ) { + if ( !fTCPBlock.isValid( launchConfig ) ) { setErrorMessage( fTCPBlock.getErrorMessage() ); return false; } } - else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) - { - if ( !fSerialBlock.isValid( launchConfig ) ) - { + else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) { + if ( !fSerialBlock.isValid( launchConfig ) ) { setErrorMessage( fSerialBlock.getErrorMessage() ); return false; } @@ -253,27 +229,23 @@ public class GDBServerDebuggerPage extends GDBDebuggerPage return false; } - public void initializeFrom( ILaunchConfiguration configuration ) - { + public void initializeFrom( ILaunchConfiguration configuration ) { + setInitializing( true ); super.initializeFrom( configuration ); - boolean isTcp = false; - try - { + try { isTcp = configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); - } - catch( CoreException e ) - { } - + catch( CoreException e ) { + } fTCPBlock.initializeFrom( configuration ); fSerialBlock.initializeFrom( configuration ); - - fConnectionField.selectItem( ( isTcp ) ? 0 : 1 ); + fConnectionField.selectItem( (isTcp) ? 0 : 1 ); + connectionTypeChanged0(); + setInitializing( false ); } - public void performApply( ILaunchConfigurationWorkingCopy configuration ) - { + public void performApply( ILaunchConfigurationWorkingCopy configuration ) { super.performApply( configuration ); if ( fConnectionField != null ) configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, fConnectionField.getSelectionIndex() == 0 ); @@ -281,12 +253,18 @@ public class GDBServerDebuggerPage extends GDBDebuggerPage fSerialBlock.performApply( configuration ); } - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) - { + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { super.setDefaults( configuration ); configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); fTCPBlock.setDefaults( configuration ); fSerialBlock.setDefaults( configuration ); } -} + protected boolean isInitializing() { + return fIsInitializing; + } + + private void setInitializing( boolean isInitializing ) { + fIsInitializing = isInitializing; + } +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBSolibBlock.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBSolibBlock.java index d217d7da10a..3b04f211b8e 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBSolibBlock.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBSolibBlock.java @@ -8,7 +8,6 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.debug.mi.internal.ui; import java.util.Map; @@ -16,6 +15,7 @@ import java.util.Observable; import java.util.Observer; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; +import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent; import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfiguration; @@ -26,74 +26,75 @@ 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; /** - * Enter type comment. - * - * @since Sep 3, 2003 + * The content of the Shared Libraries tab of the GDBDebuggerPage. */ -public class GDBSolibBlock extends Observable implements Observer -{ - private SolibSearchPathBlock fSolibSearchPathBlock; +public class GDBSolibBlock extends Observable implements IMILaunchConfigurationComponent, Observer { + + private IMILaunchConfigurationComponent fSolibSearchPathBlock; + private Button fAutoSoLibButton; + private Button fStopOnSolibEventsButton; + private Composite fControl; + + private boolean fAutoSolib = false; - public GDBSolibBlock() - { + private boolean fStopOnSolibEvents = false; + + public GDBSolibBlock( IMILaunchConfigurationComponent solibSearchBlock, boolean autoSolib, boolean stopOnSolibEvents ) { super(); + fSolibSearchPathBlock = solibSearchBlock; + fAutoSolib = autoSolib; + fStopOnSolibEvents = stopOnSolibEvents; } - public void createBlock( Composite parent, boolean solibPath, boolean autoSolib, boolean stopOnSolibEvents ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl( Composite parent ) { Composite subComp = ControlFactory.createCompositeEx( parent, 1, GridData.FILL_HORIZONTAL ); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)subComp.getLayout()).marginHeight = 0; - ((GridLayout)subComp.getLayout()).marginWidth = 0; - - if ( solibPath ) - { - fSolibSearchPathBlock = new SolibSearchPathBlock(); - fSolibSearchPathBlock.createBlock( subComp ); - fSolibSearchPathBlock.addObserver( this ); + ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout)subComp.getLayout()).marginHeight = 0; + ((GridLayout)subComp.getLayout()).marginWidth = 0; + if ( fSolibSearchPathBlock != null ) { + fSolibSearchPathBlock.createControl( subComp ); + if ( fSolibSearchPathBlock instanceof Observable ) + ((Observable)fSolibSearchPathBlock).addObserver( this ); } - - if ( autoSolib ) - { + if ( fAutoSolib ) { fAutoSoLibButton = ControlFactory.createCheckBox( subComp, MIUIMessages.getString( "GDBSolibBlock.0" ) ); //$NON-NLS-1$ - fAutoSoLibButton.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent e ) - { - updateButtons(); - changed(); - } - } ); - } + fAutoSoLibButton.addSelectionListener( new SelectionAdapter() { - if ( stopOnSolibEvents ) - { - fStopOnSolibEventsButton = ControlFactory.createCheckBox( subComp, MIUIMessages.getString( "GDBSolibBlock.1" ) ); //$NON-NLS-1$ - fStopOnSolibEventsButton.addSelectionListener( - new SelectionAdapter() - { - public void widgetSelected( SelectionEvent e ) - { - updateButtons(); - changed(); - } - } ); + public void widgetSelected( SelectionEvent e ) { + updateButtons(); + changed(); + } + } ); } - setControl( subComp ); + if ( fStopOnSolibEvents ) { + fStopOnSolibEventsButton = ControlFactory.createCheckBox( subComp, MIUIMessages.getString( "GDBSolibBlock.1" ) ); //$NON-NLS-1$ + fStopOnSolibEventsButton.addSelectionListener( new SelectionAdapter() { + + public void widgetSelected( SelectionEvent e ) { + updateButtons(); + changed(); + } + } ); + } + fControl = subComp; } - public void initializeFrom( ILaunchConfiguration configuration ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + public void initializeFrom( ILaunchConfiguration configuration ) { if ( fSolibSearchPathBlock != null ) fSolibSearchPathBlock.initializeFrom( configuration ); - try - { + try { if ( fAutoSoLibButton != null ) fAutoSoLibButton.setSelection( configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ) ); if ( fStopOnSolibEventsButton != null ) @@ -101,18 +102,17 @@ public class GDBSolibBlock extends Observable implements Observer initializeButtons( configuration ); updateButtons(); } - catch( CoreException e ) - { - return; + catch( CoreException e ) { } } - public void performApply( ILaunchConfigurationWorkingCopy configuration ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply( ILaunchConfigurationWorkingCopy configuration ) { if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.performApply( configuration ); - try - { + fSolibSearchPathBlock.performApply( configuration ); + try { Map attrs = configuration.getAttributes(); if ( fAutoSoLibButton != null ) attrs.put( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, new Boolean( fAutoSoLibButton.getSelection() ) ); @@ -120,80 +120,73 @@ public class GDBSolibBlock extends Observable implements Observer attrs.put( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, new Boolean( fStopOnSolibEventsButton.getSelection() ) ); configuration.setAttributes( attrs ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { if ( fSolibSearchPathBlock != null ) fSolibSearchPathBlock.setDefaults( configuration ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, - IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, - IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT ); + configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ); + configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT ); } - protected void updateButtons() - { + protected void updateButtons() { } - public void dispose() - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() + */ + public void dispose() { deleteObservers(); - if ( fSolibSearchPathBlock != null ) - { - fSolibSearchPathBlock.deleteObserver( this ); + if ( fSolibSearchPathBlock != null ) { + if ( fSolibSearchPathBlock instanceof Observable ) + ((Observable)fSolibSearchPathBlock).deleteObserver( this ); fSolibSearchPathBlock.dispose(); } } - public void disable() - { - if ( fAutoSoLibButton != null ) - fAutoSoLibButton.setEnabled( false ); - if ( fStopOnSolibEventsButton != null ) - fStopOnSolibEventsButton.setEnabled( false ); - } - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ - public void update( Observable o, Object arg ) - { + public void update( Observable o, Object arg ) { changed(); } - protected void changed() - { + protected void changed() { setChanged(); notifyObservers(); } - public Composite getControl() - { - return fControl; - } - - protected void setControl( Composite composite ) - { - fControl = composite; - } - - protected void initializeButtons( ILaunchConfiguration configuration ) - { - try - { + protected void initializeButtons( ILaunchConfiguration configuration ) { + try { boolean enable = !ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, "" ) ); //$NON-NLS-1$ if ( fAutoSoLibButton != null ) fAutoSoLibButton.setEnabled( enable ); if ( fStopOnSolibEventsButton != null ) fStopOnSolibEventsButton.setEnabled( enable ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } -} + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() + */ + public Control getControl() { + return fControl; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + public boolean isValid( ILaunchConfiguration launchConfig ) { + // TODO Auto-generated method stub + return false; + } +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIHelpContextIds.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIHelpContextIds.java index 5752c01d83f..1b9a8a48b08 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIHelpContextIds.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIHelpContextIds.java @@ -11,19 +11,15 @@ package org.eclipse.cdt.debug.mi.internal.ui; /** - * * Help context ids for the C/C++ debug ui. *

- * This interface contains constants only; it is not intended to be implemented - * or extended. + * This interface contains constants only; it is not intended to be implemented or extended. *

- * - * @since Oct 4, 2002 */ -public interface IMIHelpContextIds -{ +public interface IMIHelpContextIds { + public static final String PREFIX = IMIUIConstants.PLUGIN_ID + "."; //$NON-NLS-1$ // Preference pages public static final String MI_PREFERENCE_PAGE = PREFIX + "mi_preference_page_context"; //$NON-NLS-1$ -} +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIUIConstants.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIUIConstants.java index b7b3d5ad84c..261debb6d8d 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIUIConstants.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIUIConstants.java @@ -11,15 +11,12 @@ package org.eclipse.cdt.debug.mi.internal.ui; /** - * * Constant definitions for MI UI plug-in. - * - * @since Oct 4, 2002 */ -public interface IMIUIConstants -{ +public interface IMIUIConstants { + /** * Plug-in identifier (value "org.eclipse.cdt.debug.mi.ui"). */ public static final String PLUGIN_ID = MIUIPlugin.getUniqueIdentifier(); -} +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.properties b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.properties index a5e33dc6a90..b4d35e90a61 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.properties +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.properties @@ -44,6 +44,8 @@ SolibSearchPathBlock.2=Down SolibSearchPathBlock.3=Remove SolibSearchPathBlock.4=Directories: SolibSearchPathBlock.5=Select directory that contains shared library. +SolibSearchPathBlock.Add_Directory=Add Directory +SolibSearchPathBlock.Auto=Auto TCPSettingsBlock.0=Host name or IP address: TCPSettingsBlock.1=Port number: TCPSettingsBlock.2=Host name or IP address must be specified. diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/PixelConverter.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/PixelConverter.java index 8813695cd70..a2f6c88ed7a 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/PixelConverter.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/PixelConverter.java @@ -10,19 +10,16 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.internal.ui; - - import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.widgets.Control; -public class PixelConverter -{ +public class PixelConverter { + private FontMetrics fFontMetrics; - public PixelConverter( Control control ) - { + public PixelConverter( Control control ) { GC gc = new GC( control ); gc.setFont( control.getFont() ); fFontMetrics = gc.getFontMetrics(); @@ -32,32 +29,28 @@ public class PixelConverter /** * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int) */ - public int convertHeightInCharsToPixels( int chars ) - { + public int convertHeightInCharsToPixels( int chars ) { return Dialog.convertHeightInCharsToPixels( fFontMetrics, chars ); } /** * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int) */ - public int convertHorizontalDLUsToPixels( int dlus ) - { + public int convertHorizontalDLUsToPixels( int dlus ) { return Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus ); } /** * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int) */ - public int convertVerticalDLUsToPixels( int dlus ) - { + public int convertVerticalDLUsToPixels( int dlus ) { return Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus ); } /** * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int) */ - public int convertWidthInCharsToPixels( int chars ) - { + public int convertWidthInCharsToPixels( int chars ) { return Dialog.convertWidthInCharsToPixels( fFontMetrics, chars ); } -} +} \ No newline at end of file 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 index 9c6e5fef70a..58f29bcdb19 100644 --- 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 @@ -30,195 +30,158 @@ 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 -{ +public class SerialPortSettingsBlock extends Observable { + private final static String DEFAULT_ASYNC_DEVICE = "/dev/ttyS0"; //$NON-NLS-1$ + private final static String DEFAULT_ASYNC_DEVICE_SPEED = "115200"; //$NON-NLS-1$ private Shell fShell; private StringDialogField fDeviceField; + private ComboDialogField fSpeedField; private String fSpeedChoices[] = { "9600", "19200", "38400", "57600", "115200" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - + private Control fControl; private String fErrorMessage = null; - public SerialPortSettingsBlock() - { + public SerialPortSettingsBlock() { super(); fDeviceField = createDeviceField(); fSpeedField = createSpeedField(); } - public void createBlock( Composite parent ) - { + 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; + ((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() - { + protected Shell getShell() { return fShell; } - public void dispose() - { + public void dispose() { deleteObservers(); } - public void initializeFrom( ILaunchConfiguration configuration ) - { + public void initializeFrom( ILaunchConfiguration configuration ) { initializeDevice( configuration ); initializeSpeed( configuration ); } - public void setDefaults( ILaunchConfigurationWorkingCopy 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 ) - { + public void performApply( ILaunchConfigurationWorkingCopy configuration ) { if ( fDeviceField != null ) configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, fDeviceField.getText().trim() ); - if ( fSpeedField != null ) - { + if ( fSpeedField != null ) { int index = fSpeedField.getSelectionIndex(); configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, getSpeedItem( index ) ); } } - private StringDialogField createDeviceField() - { + private StringDialogField createDeviceField() { StringDialogField field = new StringDialogField(); field.setLabelText( MIUIMessages.getString( "SerialPortSettingsBlock.0" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( - new IDialogFieldListener() - { - public void dialogFieldChanged( DialogField f ) - { - deviceFieldChanged(); - } - } ); - return field; - } + field.setDialogFieldListener( new IDialogFieldListener() { - private ComboDialogField createSpeedField() - { - ComboDialogField field = new ComboDialogField( SWT.DROP_DOWN | SWT.READ_ONLY ); - field.setLabelText( MIUIMessages.getString( "SerialPortSettingsBlock.1" ) ); //$NON-NLS-1$ - field.setItems( fSpeedChoices ); - field.setDialogFieldListener( - new IDialogFieldListener() - { - public void dialogFieldChanged( DialogField f ) - { - speedFieldChanged(); - } - } ); + public void dialogFieldChanged( DialogField f ) { + deviceFieldChanged(); + } + } ); return field; } - protected void deviceFieldChanged() - { + private ComboDialogField createSpeedField() { + ComboDialogField field = new ComboDialogField( SWT.DROP_DOWN | SWT.READ_ONLY ); + field.setLabelText( MIUIMessages.getString( "SerialPortSettingsBlock.1" ) ); //$NON-NLS-1$ + field.setItems( fSpeedChoices ); + field.setDialogFieldListener( new IDialogFieldListener() { + + public void dialogFieldChanged( DialogField f ) { + speedFieldChanged(); + } + } ); + return field; + } + + protected void deviceFieldChanged() { updateErrorMessage(); setChanged(); notifyObservers(); } - protected void speedFieldChanged() - { + protected void speedFieldChanged() { updateErrorMessage(); setChanged(); notifyObservers(); } - private void initializeDevice( ILaunchConfiguration configuration ) - { - if ( fDeviceField != null ) - { - try - { + private void initializeDevice( ILaunchConfiguration configuration ) { + if ( fDeviceField != null ) { + try { fDeviceField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE ) ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } } - private void initializeSpeed( ILaunchConfiguration configuration ) - { - if ( fSpeedField != null ) - { + private void initializeSpeed( ILaunchConfiguration configuration ) { + if ( fSpeedField != null ) { int index = 0; - try - { - index = getSpeedItemIndex( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ) ); + try { + index = getSpeedItemIndex( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ) ); } - catch( CoreException e ) - { + catch( CoreException e ) { } - fSpeedField.selectItem( index ); + fSpeedField.selectItem( index ); } } - private String getSpeedItem( int index ) - { - return ( index >= 0 && index < fSpeedChoices.length ) ? fSpeedChoices[index] : null; + 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 ) + 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() - { + public Control getControl() { return fControl; } - protected void setControl( Control control ) - { + protected void setControl( Control control ) { fControl = control; } - public boolean isValid( ILaunchConfiguration configuration ) - { + public boolean isValid( ILaunchConfiguration configuration ) { updateErrorMessage(); - return ( getErrorMessage() == null ); + return (getErrorMessage() == null); } - private void updateErrorMessage() - { + private void updateErrorMessage() { setErrorMessage( null ); - if ( fDeviceField != null && fSpeedField != null ) - { + if ( fDeviceField != null && fSpeedField != null ) { if ( fDeviceField.getText().trim().length() == 0 ) setErrorMessage( MIUIMessages.getString( "SerialPortSettingsBlock.2" ) ); //$NON-NLS-1$ else if ( !deviceIsValid( fDeviceField.getText().trim() ) ) @@ -228,19 +191,15 @@ public class SerialPortSettingsBlock extends Observable } } - public String getErrorMessage() - { + public String getErrorMessage() { return fErrorMessage; } - private void setErrorMessage( String string ) - { + private void setErrorMessage( String string ) { fErrorMessage = string; } - private boolean deviceIsValid( String hostName ) - { + private boolean deviceIsValid( String hostName ) { return true; } -} - +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java index 86693f59721..2e42e08f094 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java @@ -8,161 +8,331 @@ * Contributors: * QNX Software Systems - Initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.debug.mi.internal.ui; import java.util.Collections; +import java.util.Iterator; +import java.util.List; import java.util.Observable; import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IListAdapter; import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ListDialogField; +import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent; +import org.eclipse.cdt.debug.mi.ui.IPathProvider; import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.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.Shell; +import org.eclipse.swt.widgets.Text; /** - * Enter type comment. - * - * @since Sep 4, 2003 + * The UI component to access the shared libraries search path. */ -public class SolibSearchPathBlock extends Observable -{ - public class SolibSearchPathListDialogField extends ListDialogField - { - public SolibSearchPathListDialogField( IListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider ) - { +public class SolibSearchPathBlock extends Observable implements IMILaunchConfigurationComponent { + + class AddDirectoryDialog extends Dialog { + + protected Text fText; + + private Button fBrowseButton; + + private String fValue; + + /** + * Constructor for AddDirectoryDialog. + */ + public AddDirectoryDialog( Shell parentShell ) { + super( parentShell ); + } + + protected Control createDialogArea( Composite parent ) { + Composite composite = (Composite)super.createDialogArea( parent ); + + Composite subComp = ControlFactory.createCompositeEx( composite, 2, GridData.FILL_HORIZONTAL ); + ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; + GridData data = new GridData( GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER ); + data.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); + subComp.setLayoutData( data ); + subComp.setFont( parent.getFont() ); + + fText = new Text( subComp, SWT.SINGLE | SWT.BORDER ); + fText.setLayoutData( new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL ) ); + fText.addModifyListener( new ModifyListener() { + + public void modifyText( ModifyEvent e ) { + updateOKButton(); + } + } ); + + fBrowseButton = ControlFactory.createPushButton( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.7" ) ); //$NON-NLS-1$ + data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); + fBrowseButton.setLayoutData( data ); + fBrowseButton.addSelectionListener( new SelectionAdapter() { + + public void widgetSelected( SelectionEvent evt ) { + DirectoryDialog dialog = new DirectoryDialog( getShell() ); + dialog.setMessage( MIUIMessages.getString( "SolibSearchPathBlock.5" ) ); //$NON-NLS-1$ + String res = dialog.open(); + if ( res != null ) { + fText.setText( res ); + } + } + } ); + + applyDialogFont( composite ); + return composite; + } + + protected void configureShell( Shell newShell ) { + super.configureShell( newShell ); + newShell.setText( MIUIMessages.getString( "SolibSearchPathBlock.Add_Directory" ) ); //$NON-NLS-1$ + } + + public String getValue() { + return fValue; + } + + private void setValue( String value ) { + fValue = value; + } + + protected void buttonPressed( int buttonId ) { + if ( buttonId == IDialogConstants.OK_ID ) { + setValue( fText.getText() ); + } + else { + setValue( null ); + } + super.buttonPressed( buttonId ); + } + + protected void updateOKButton() { + Button okButton = getButton( IDialogConstants.OK_ID ); + String text = fText.getText(); + okButton.setEnabled( isValid( text ) ); + } + + protected boolean isValid( String text ) { + return ( text.trim().length() > 0 ); + } + + protected Control createButtonBar( Composite parent ) { + Control control = super.createButtonBar( parent ); + updateOKButton(); + return control; + } + } + + private Composite fControl; + + public class SolibSearchPathListDialogField extends ListDialogField { + + public SolibSearchPathListDialogField( IListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider ) { super( adapter, buttonLabels, lprovider ); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField#managedButtonPressed(int) */ - protected boolean managedButtonPressed( int index ) - { + protected boolean managedButtonPressed( int index ) { boolean result = super.managedButtonPressed( index ); if ( result ) buttonPressed( index ); return result; } - } private Shell fShell; + private SolibSearchPathListDialogField fDirList; - public SolibSearchPathBlock() - { + private IPathProvider fPathProvider; + + public SolibSearchPathBlock( IPathProvider pathProvider ) { super(); + setPathProvider( pathProvider ); + int length = ( getPathProvider() != null ) ? 6 : 4; + String[] buttonLabels = new String[length]; + buttonLabels[0] = MIUIMessages.getString( "SolibSearchPathBlock.0" ); //$NON-NLS-1$ + buttonLabels[1] = MIUIMessages.getString( "SolibSearchPathBlock.1" ); //$NON-NLS-1$ + buttonLabels[2] = MIUIMessages.getString( "SolibSearchPathBlock.2" ); //$NON-NLS-1$ + buttonLabels[3] = MIUIMessages.getString( "SolibSearchPathBlock.3" ); //$NON-NLS-1$ + if ( buttonLabels.length == 6 ) { + buttonLabels[4] = null; + buttonLabels[5] = MIUIMessages.getString( "SolibSearchPathBlock.Auto" ); //$NON-NLS-1$ + } + IListAdapter listAdapter = new IListAdapter() { - String[] buttonLabels = new String[] - { - /* 0 */ MIUIMessages.getString( "SolibSearchPathBlock.0" ), //$NON-NLS-1$ - /* 1 */ null, - /* 2 */ MIUIMessages.getString( "SolibSearchPathBlock.1" ), //$NON-NLS-1$ - /* 3 */ MIUIMessages.getString( "SolibSearchPathBlock.2" ), //$NON-NLS-1$ - /* 4 */ null, - /* 5 */ MIUIMessages.getString( "SolibSearchPathBlock.3" ), //$NON-NLS-1$ + public void customButtonPressed( DialogField field, int index ) { + buttonPressed( index ); + } + + public void selectionChanged( DialogField field ) { + } }; - - IListAdapter listAdapter = new IListAdapter() - { - public void customButtonPressed( DialogField field, int index ) - { - buttonPressed( index ); - } - - public void selectionChanged( DialogField field ) - { - } - }; - fDirList = new SolibSearchPathListDialogField( listAdapter, buttonLabels, new LabelProvider() ); fDirList.setLabelText( MIUIMessages.getString( "SolibSearchPathBlock.4" ) ); //$NON-NLS-1$ - fDirList.setUpButtonIndex( 2 ); - fDirList.setDownButtonIndex( 3 ); - fDirList.setRemoveButtonIndex( 5 ); + fDirList.setUpButtonIndex( 1 ); + fDirList.setDownButtonIndex( 2 ); + fDirList.setRemoveButtonIndex( 3 ); } - public void createBlock( Composite parent ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl( 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; + ((GridLayout)comp.getLayout()).marginHeight = 0; + ((GridLayout)comp.getLayout()).marginWidth = 0; comp.setFont( JFaceResources.getDialogFont() ); - PixelConverter converter = new PixelConverter( comp ); - fDirList.doFillIntoGrid( comp, 3 ); LayoutUtil.setHorizontalSpan( fDirList.getLabelControl( null ), 2 ); LayoutUtil.setWidthHint( fDirList.getLabelControl( null ), converter.convertWidthInCharsToPixels( 30 ) ); LayoutUtil.setHorizontalGrabbing( fDirList.getListControl( null ) ); + fControl = comp; } - public void initializeFrom( ILaunchConfiguration configuration ) - { - if ( fDirList != null ) - { - try - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + public void initializeFrom( ILaunchConfiguration configuration ) { + if ( fDirList != null ) { + try { fDirList.addElements( configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST ) ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } } - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST ); } - public void performApply( ILaunchConfigurationWorkingCopy configuration ) - { - if ( fDirList != null ) - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void performApply( ILaunchConfigurationWorkingCopy configuration ) { + if ( fDirList != null ) { configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, fDirList.getElements() ); } } - protected void buttonPressed( int index ) - { - if ( index == 0 ) - addDirectory(); + protected void buttonPressed( int index ) { + switch( index ) { + case 0: + addDirectory(); + break; + case 5: + generatePaths(); + break; + } setChanged(); notifyObservers(); } - protected Shell getShell() - { + protected Shell getShell() { return fShell; } - private void addDirectory() - { - DirectoryDialog dialog = new DirectoryDialog( getShell() ); - dialog.setMessage( MIUIMessages.getString( "SolibSearchPathBlock.5" ) ); //$NON-NLS-1$ - String res = dialog.open(); - if ( res != null ) - fDirList.addElement( res ); + private void addDirectory() { + AddDirectoryDialog dialog = new AddDirectoryDialog( getShell() ); + dialog.open(); + String result = dialog.getValue(); + if ( result != null && !contains( result ) ) { + fDirList.addElement( result.trim() ); + } } - public void dispose() - { + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() + */ + public void dispose() { deleteObservers(); } -} + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() + */ + public Control getControl() { + return fControl; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + public boolean isValid( ILaunchConfiguration launchConfig ) { + // TODO Auto-generated method stub + return false; + } + + private void generatePaths() { + IPathProvider pp = getPathProvider(); + if ( pp != null ) { + IPath[] dirs = pp.getPaths(); + for ( int i = 0; i < dirs.length; ++i ) + if ( !contains( dirs[i] ) ) + fDirList.addElement( dirs[i].toOSString() ); + } + } + + private IPathProvider getPathProvider() { + return fPathProvider; + } + + private void setPathProvider( IPathProvider pathProvider ) { + fPathProvider = pathProvider; + } + + private boolean contains( IPath path ) { + List list = fDirList.getElements(); + Iterator it = list.iterator(); + while( it.hasNext() ) { + IPath p = new Path( (String)it.next() ); + if ( p.toFile().compareTo( path.toFile() ) == 0 ) + return true; + } + return false; + } + + private boolean contains( String dir ) { + IPath path = new Path( dir ); + List list = fDirList.getElements(); + Iterator it = list.iterator(); + while( it.hasNext() ) { + IPath p = new Path( (String)it.next() ); + if ( p.toFile().compareTo( path.toFile() ) == 0 ) + return true; + } + return false; + } +} \ No newline at end of file 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 index bf5a10daa5f..7b3f8299fd9 100644 --- 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 @@ -28,175 +28,141 @@ 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 -{ +public class TCPSettingsBlock extends Observable { + private final static String DEFAULT_HOST_NAME = "localhost"; //$NON-NLS-1$ + private final static String DEFAULT_PORT_NUMBER = "10000"; //$NON-NLS-1$ private Shell fShell; private StringDialogField fHostNameField; + private StringDialogField fPortNumberField; - + private Control fControl; private String fErrorMessage = null; - - public TCPSettingsBlock() - { + + public TCPSettingsBlock() { super(); fHostNameField = createHostNameField(); fPortNumberField = createPortNumberField(); } - public void createBlock( Composite parent ) - { + 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; + ((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() - { + protected Shell getShell() { return fShell; } - public void dispose() - { + public void dispose() { deleteObservers(); } - public void initializeFrom( ILaunchConfiguration configuration ) - { + public void initializeFrom( ILaunchConfiguration configuration ) { initializeHostName( configuration ); initializePortNumber( configuration ); } - public void setDefaults( ILaunchConfigurationWorkingCopy 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 ) - { + 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() - { + private StringDialogField createHostNameField() { StringDialogField field = new StringDialogField(); field.setLabelText( MIUIMessages.getString( "TCPSettingsBlock.0" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( - new IDialogFieldListener() - { - public void dialogFieldChanged( DialogField f ) - { - hostNameFieldChanged(); - } - } ); - return field; + field.setDialogFieldListener( new IDialogFieldListener() { + + public void dialogFieldChanged( DialogField f ) { + hostNameFieldChanged(); + } + } ); + return field; } - private StringDialogField createPortNumberField() - { + private StringDialogField createPortNumberField() { StringDialogField field = new StringDialogField(); field.setLabelText( MIUIMessages.getString( "TCPSettingsBlock.1" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( - new IDialogFieldListener() - { - public void dialogFieldChanged( DialogField f ) - { - portNumberFieldChanged(); - } - } ); - return field; + field.setDialogFieldListener( new IDialogFieldListener() { + + public void dialogFieldChanged( DialogField f ) { + portNumberFieldChanged(); + } + } ); + return field; } - protected void hostNameFieldChanged() - { + protected void hostNameFieldChanged() { updateErrorMessage(); setChanged(); notifyObservers(); } - protected void portNumberFieldChanged() - { + protected void portNumberFieldChanged() { updateErrorMessage(); setChanged(); notifyObservers(); } - private void initializeHostName( ILaunchConfiguration configuration ) - { - if ( fHostNameField != null ) - { - try - { + private void initializeHostName( ILaunchConfiguration configuration ) { + if ( fHostNameField != null ) { + try { fHostNameField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME ) ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } } - private void initializePortNumber( ILaunchConfiguration configuration ) - { - if ( fPortNumberField != null ) - { - try - { + private void initializePortNumber( ILaunchConfiguration configuration ) { + if ( fPortNumberField != null ) { + try { fPortNumberField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER ) ); } - catch( CoreException e ) - { + catch( CoreException e ) { } } } - public Control getControl() - { + public Control getControl() { return fControl; } - protected void setControl( Control control ) - { + protected void setControl( Control control ) { fControl = control; } - public boolean isValid( ILaunchConfiguration configuration ) - { + public boolean isValid( ILaunchConfiguration configuration ) { updateErrorMessage(); - return ( getErrorMessage() == null ); + return (getErrorMessage() == null); } - private void updateErrorMessage() - { + private void updateErrorMessage() { setErrorMessage( null ); - if ( fHostNameField != null && fPortNumberField != null ) - { + if ( fHostNameField != null && fPortNumberField != null ) { if ( fHostNameField.getText().trim().length() == 0 ) setErrorMessage( MIUIMessages.getString( "TCPSettingsBlock.2" ) ); //$NON-NLS-1$ else if ( !hostNameIsValid( fHostNameField.getText().trim() ) ) @@ -208,34 +174,27 @@ public class TCPSettingsBlock extends Observable } } - public String getErrorMessage() - { + public String getErrorMessage() { return fErrorMessage; } - private void setErrorMessage( String string ) - { + private void setErrorMessage( String string ) { fErrorMessage = string; } - private boolean hostNameIsValid( String hostName ) - { + private boolean hostNameIsValid( String hostName ) { return true; } - private boolean portNumberIsValid( String portNumber ) - { - try - { + private boolean portNumberIsValid( String portNumber ) { + try { int port = Short.parseShort( portNumber ); if ( port < 0 ) return false; } - catch( NumberFormatException e ) - { + catch( NumberFormatException e ) { return false; } return true; } -} - +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java index 4d70b257ee8..99a4e460a46 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java @@ -36,251 +36,217 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; /** - * Enter type comment. - * - * @since: Feb 11, 2003 + * The delegate for the "Automatically Load Symbols" action. */ -public class SetAutoSolibActionDelegate implements IViewActionDelegate, - ISelectionListener, - IPartListener -{ +public class SetAutoSolibActionDelegate implements IViewActionDelegate, ISelectionListener, IPartListener { + private IViewPart fView = null; + private IAction fAction; + private IStatus fStatus = null; /** * Constructor for SetAutoSolibActionDelegate. */ - public SetAutoSolibActionDelegate() - { + public SetAutoSolibActionDelegate() { super(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) */ - public void init( IViewPart view ) - { + public void init( IViewPart view ) { fView = view; view.getSite().getPage().addPartListener( this ); view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) */ - public void selectionChanged( IWorkbenchPart part, ISelection selection ) - { - if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) - { + public void selectionChanged( IWorkbenchPart part, ISelection selection ) { + if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) { update( getAction() ); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IActionDelegate#run(IAction) */ - public void run( IAction action ) - { - BusyIndicator.showWhile( Display.getCurrent(), - new Runnable() - { - public void run() - { - try - { - doAction( DebugUITools.getDebugContext() ); - setStatus( null ); - } - catch( DebugException e ) - { - setStatus( e.getStatus() ); - } - } - } ); - if ( getStatus() != null && !getStatus().isOK() ) - { - IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow(); - if ( window != null ) - { + public void run( IAction action ) { + BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { + + public void run() { + try { + doAction( DebugUITools.getDebugContext() ); + setStatus( null ); + } + catch( DebugException e ) { + setStatus( e.getStatus() ); + } + } + } ); + if ( getStatus() != null && !getStatus().isOK() ) { + IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow(); + if ( window != null ) { CDebugUIPlugin.errorDialog( getErrorDialogMessage(), getStatus() ); - } - else - { + } + else { CDebugUIPlugin.log( getStatus() ); } } - update( action ); + update( action ); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) */ - public void selectionChanged( IAction action, ISelection selection ) - { + public void selectionChanged( IAction action, ISelection selection ) { setAction( action ); - if ( getView() != null ) - { + if ( getView() != null ) { update( action ); } } - protected void update( IAction action ) - { - if ( action != null ) - { + protected void update( IAction action ) { + if ( action != null ) { IAdaptable element = DebugUITools.getDebugContext(); action.setEnabled( getEnableStateForSelection( element ) ); action.setChecked( getCheckStateForSelection( element ) ); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) */ - public void partActivated( IWorkbenchPart part ) - { + public void partActivated( IWorkbenchPart part ) { } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) */ - public void partBroughtToTop( IWorkbenchPart part ) - { + public void partBroughtToTop( IWorkbenchPart part ) { } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) */ - public void partClosed( IWorkbenchPart part ) - { - if ( part.equals( getView() ) ) - { + public void partClosed( IWorkbenchPart part ) { + if ( part.equals( getView() ) ) { dispose(); } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) */ - public void partDeactivated( IWorkbenchPart part ) - { + public void partDeactivated( IWorkbenchPart part ) { } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) */ - public void partOpened( IWorkbenchPart part ) - { + public void partOpened( IWorkbenchPart part ) { } - - protected IViewPart getView() - { + + protected IViewPart getView() { return fView; } - protected void setView( IViewPart viewPart ) - { + protected void setView( IViewPart viewPart ) { fView = viewPart; } - - protected void setAction( IAction action ) - { + + protected void setAction( IAction action ) { fAction = action; } - protected IAction getAction() - { + protected IAction getAction() { return fAction; } - protected void dispose() - { - if ( getView() != null ) - { + protected void dispose() { + if ( getView() != null ) { getView().getViewSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); getView().getViewSite().getPage().removePartListener( this ); } } - protected boolean getCheckStateForSelection( IAdaptable element ) - { + protected boolean getCheckStateForSelection( IAdaptable element ) { SharedLibraryManager slm = getSharedLibraryManager( element ); - if ( slm != null ) - { - try - { + if ( slm != null ) { + try { return slm.isAutoLoadSymbols(); } - catch( CDIException e ) - { + catch( CDIException e ) { } } return false; } - protected boolean getEnableStateForSelection( IAdaptable element ) - { - return ( element instanceof IDebugElement && - ((IDebugElement)element).getDebugTarget().isSuspended() && - getSharedLibraryManager( element ) != null ); + protected boolean getEnableStateForSelection( IAdaptable element ) { + return (element instanceof IDebugElement && ((IDebugElement)element).getDebugTarget().isSuspended() && getSharedLibraryManager( element ) != null); } - protected String getStatusMessage() - { + protected String getStatusMessage() { return ActionMessages.getString( "SetAutoSolibActionDelegate.0" ); //$NON-NLS-1$ } /** * @see AbstractDebugActionDelegate#getErrorDialogMessage() */ - protected String getErrorDialogMessage() - { + protected String getErrorDialogMessage() { return ActionMessages.getString( "SetAutoSolibActionDelegate.1" ); //$NON-NLS-1$ } - - protected void setStatus( IStatus status ) - { + + protected void setStatus( IStatus status ) { fStatus = status; } - - protected IStatus getStatus() - { + + protected IStatus getStatus() { return fStatus; } - protected void doAction( IAdaptable element ) throws DebugException - { + protected void doAction( IAdaptable element ) throws DebugException { if ( getView() == null ) return; SharedLibraryManager slm = getSharedLibraryManager( element ); - if ( slm != null && getAction() != null ) - { - try - { + if ( slm != null && getAction() != null ) { + try { slm.setAutoLoadSymbols( getAction().isChecked() ); } - catch( CDIException e ) - { + catch( CDIException e ) { getAction().setChecked( !getAction().isChecked() ); - throw new DebugException( new Status( IStatus.ERROR, - MIPlugin.getUniqueIdentifier(), - DebugException.TARGET_REQUEST_FAILED, - e.getMessage(), - null ) ); + throw new DebugException( new Status( IStatus.ERROR, MIPlugin.getUniqueIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getMessage(), null ) ); } } } - - private SharedLibraryManager getSharedLibraryManager( IAdaptable element ) - { - if ( element != null ) - { + + private SharedLibraryManager getSharedLibraryManager( IAdaptable element ) { + if ( element != null ) { ICDISession session = (ICDISession)element.getAdapter( ICDISession.class ); if ( session instanceof Session && ((Session)session).getSharedLibraryManager() instanceof SharedLibraryManager ) return (SharedLibraryManager)((Session)session).getSharedLibraryManager(); } - return null; + return null; } -} - +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java index 6dc2e03bdbf..7dca00fb891 100644 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.debug.mi.internal.ui.preferences; import java.text.MessageFormat; - import org.eclipse.cdt.debug.mi.core.IMIConstants; import org.eclipse.cdt.debug.mi.core.MIPlugin; import org.eclipse.cdt.debug.mi.internal.ui.IMIHelpContextIds; @@ -34,14 +33,12 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.WorkbenchHelp; /** - * * Page for preferences that apply specifically to GDB MI. - * - * @since Oct 4, 2002 */ -public class MIPreferencePage extends PreferencePage implements IWorkbenchPreferencePage -{ +public class MIPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + private final static String GDB_MI_HELP_CONTEXT = MIUIPlugin.PLUGIN_ID + "mi_preference_page_context"; //$NON-NLS-1$ + // Debugger timeout preference widgets IntegerFieldEditor fDebugTimeoutText; @@ -51,20 +48,19 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer /** * Constructor for MIPreferencePage. */ - public MIPreferencePage() - { + public MIPreferencePage() { super(); setPreferenceStore( MIUIPlugin.getDefault().getPreferenceStore() ); setDescription( PreferenceMessages.getString( "MIPreferencePage.0" ) ); //$NON-NLS-1$ } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) */ - protected Control createContents( Composite parent ) - { + protected Control createContents( Composite parent ) { WorkbenchHelp.setHelp( getControl(), IMIHelpContextIds.MI_PREFERENCE_PAGE ); - //The main composite Composite composite = new Composite( parent, SWT.NULL ); GridLayout layout = new GridLayout(); @@ -76,36 +72,29 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer data.verticalAlignment = GridData.FILL; data.horizontalAlignment = GridData.FILL; composite.setLayoutData( data ); - createSpacer( composite, 1 ); createCommunicationPreferences( composite ); - setValues(); - - WorkbenchHelp.setHelp(composite, GDB_MI_HELP_CONTEXT); - + WorkbenchHelp.setHelp( composite, GDB_MI_HELP_CONTEXT ); return composite; } /** * Creates composite group and sets the default layout data. - * - * @param parent the parent of the new composite - * @param numColumns the number of columns for the new composite - * @param labelText the text label of the new composite + * + * @param parent the parent of the new composite + * @param numColumns the number of columns for the new composite + * @param labelText the text label of the new composite * @return the newly-created composite */ - private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) - { + private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) { return ControlFactory.createGroup( parent, labelText, numColumns ); - } + } /** - * Set the values of the component widgets based on the - * values in the preference store + * Set the values of the component widgets based on the values in the preference store */ - private void setValues() - { + private void setValues() { fDebugTimeoutText.setStringValue( new Integer( MIPlugin.getDefault().getPluginPreferences().getInt( IMIConstants.PREF_REQUEST_TIMEOUT ) ).toString() ); fLaunchTimeoutText.setStringValue( new Integer( MIPlugin.getDefault().getPluginPreferences().getInt( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT ) ).toString() ); } @@ -113,8 +102,7 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer /** * @see IPreferencePage#performOk() */ - public boolean performOk() - { + public boolean performOk() { storeValues(); MIUIPlugin.getDefault().savePluginPreferences(); MIPlugin.getDefault().savePluginPreferences(); @@ -123,37 +111,35 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer /** * Sets the default preferences. + * * @see PreferencePage#performDefaults() */ - protected void performDefaults() - { + protected void performDefaults() { setDefaultValues(); super.performDefaults(); } - private void setDefaultValues() - { + private void setDefaultValues() { fDebugTimeoutText.setStringValue( new Integer( IMIConstants.DEF_REQUEST_TIMEOUT ).toString() ); fLaunchTimeoutText.setStringValue( new Integer( IMIConstants.DEF_REQUEST_LAUNCH_TIMEOUT ).toString() ); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench) */ - public void init( IWorkbench workbench ) - { + public void init( IWorkbench workbench ) { } - protected void createSpacer( Composite composite, int columnSpan ) - { + protected void createSpacer( Composite composite, int columnSpan ) { Label label = new Label( composite, SWT.NONE ); GridData gd = new GridData(); gd.horizontalSpan = columnSpan; label.setLayoutData( gd ); } - private void createCommunicationPreferences( Composite composite ) - { + private void createCommunicationPreferences( Composite composite ) { Composite comp = createGroupComposite( composite, 1, PreferenceMessages.getString( "MIPreferencePage.1" ) ); //$NON-NLS-1$ //Add in an intermediate composite to allow for spacing Composite spacingComposite = new Composite( comp, SWT.NONE ); @@ -162,42 +148,33 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer GridData data = new GridData(); data.horizontalSpan = 2; spacingComposite.setLayoutData( data ); - fDebugTimeoutText = createTimeoutField( IMIConstants.PREF_REQUEST_TIMEOUT, PreferenceMessages.getString( "MIPreferencePage.2" ), spacingComposite ); //$NON-NLS-1$ - fDebugTimeoutText.setPropertyChangeListener( - new IPropertyChangeListener() - { - public void propertyChange( PropertyChangeEvent event ) - { - if ( event.getProperty().equals( FieldEditor.IS_VALID ) ) - setValid( fDebugTimeoutText.isValid() ); - } - } ); + fDebugTimeoutText.setPropertyChangeListener( new IPropertyChangeListener() { + public void propertyChange( PropertyChangeEvent event ) { + if ( event.getProperty().equals( FieldEditor.IS_VALID ) ) + setValid( fDebugTimeoutText.isValid() ); + } + } ); fLaunchTimeoutText = createTimeoutField( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, PreferenceMessages.getString( "MIPreferencePage.3" ), spacingComposite ); //$NON-NLS-1$ - fLaunchTimeoutText.setPropertyChangeListener( - new IPropertyChangeListener() - { - public void propertyChange( PropertyChangeEvent event ) - { - if ( event.getProperty().equals( FieldEditor.IS_VALID ) ) - setValid( fLaunchTimeoutText.isValid() ); - } - } ); + fLaunchTimeoutText.setPropertyChangeListener( new IPropertyChangeListener() { + + public void propertyChange( PropertyChangeEvent event ) { + if ( event.getProperty().equals( FieldEditor.IS_VALID ) ) + setValid( fLaunchTimeoutText.isValid() ); + } + } ); } /** - * Store the preference values based on the state of the - * component widgets + * Store the preference values based on the state of the component widgets */ - private void storeValues() - { + private void storeValues() { MIPlugin.getDefault().getPluginPreferences().setValue( IMIConstants.PREF_REQUEST_TIMEOUT, fDebugTimeoutText.getIntValue() ); MIPlugin.getDefault().getPluginPreferences().setValue( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, fLaunchTimeoutText.getIntValue() ); } - private IntegerFieldEditor createTimeoutField( String preference, String label, Composite parent ) - { + private IntegerFieldEditor createTimeoutField( String preference, String label, Composite parent ) { IntegerFieldEditor toText = new IntegerFieldEditor( preference, label, parent ); GridData data = new GridData(); data.widthHint = convertWidthInCharsToPixels( 10 ); @@ -212,5 +189,4 @@ public class MIPreferencePage extends PreferencePage implements IWorkbenchPrefer toText.load(); return toText; } -} - +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IMILaunchConfigurationComponent.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IMILaunchConfigurationComponent.java new file mode 100644 index 00000000000..404673d49ce --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IMILaunchConfigurationComponent.java @@ -0,0 +1,84 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems 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 + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.mi.ui; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** + * The common interface for UI components of the launch configuration tabs. + */ +public interface IMILaunchConfigurationComponent { + + /** + * Creates the top level control for this component under the given parent composite. + *

+ * Implementors are responsible for ensuring that the created control can be accessed via getControl + *

+ * + * @param parent the parent composite + */ + public void createControl( Composite parent ); + + /** + * Returns the top level control for this component. + *

+ * May return null if the control has not been created yet. + *

+ * + * @return the top level control or null + */ + public Control getControl(); + + /** + * Initializes the given component with default values. + * This method may be called before this tab's control is created. + * + * @param configuration launch configuration + */ + public void setDefaults( ILaunchConfigurationWorkingCopy configuration ); + + /** + * Initializes this component's controls with values from the given + * launch configuration. + * + * @param configuration launch configuration + */ + public void initializeFrom( ILaunchConfiguration configuration ); + + /** + * Notifies this component that it has been disposed. + * Marks the end of this component's lifecycle, allowing + * to perform any cleanup required. + */ + public void dispose(); + + /** + * Copies values from this component into the given launch configuration. + * + * @param configuration launch configuration + */ + public void performApply( ILaunchConfigurationWorkingCopy configuration ); + + /** + * Returns whether this component is in a valid state in the context + * of the specified launch configuration. + * + * @param launchConfig launch configuration which provides context + * for validating this component. + * This value must not be null. + * + * @return whether this component is in a valid state + */ + public boolean isValid(ILaunchConfiguration launchConfig); +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IPathProvider.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IPathProvider.java new file mode 100644 index 00000000000..a373bbf9f8d --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IPathProvider.java @@ -0,0 +1,20 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems 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 + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.mi.ui; + +import org.eclipse.core.runtime.IPath; + +/** + * Comment for . + */ +public interface IPathProvider { + public IPath[] getPaths(); +} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/MIUIUtils.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/MIUIUtils.java new file mode 100644 index 00000000000..24e9aac5071 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/MIUIUtils.java @@ -0,0 +1,30 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems 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 + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.mi.ui; + +import org.eclipse.cdt.debug.mi.internal.ui.GDBSolibBlock; +import org.eclipse.cdt.debug.mi.internal.ui.SolibSearchPathBlock; + +/** + * This class provides utilities for clients of the MI UI. + */ +public class MIUIUtils { + + public static IMILaunchConfigurationComponent createGDBSolibBlock( IMILaunchConfigurationComponent solibSearchBlock, + boolean autoSolib, + boolean stopOnSolibEvents ) { + return new GDBSolibBlock( solibSearchBlock, autoSolib, stopOnSolibEvents ); + } + + public static IMILaunchConfigurationComponent createSolibSearchPathBlock( IPathProvider pp ) { + return new SolibSearchPathBlock( pp ); + } +}