diff options
Diffstat (limited to 'debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse')
50 files changed, 0 insertions, 7227 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/ActionFilterAdapterFactory.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/ActionFilterAdapterFactory.java deleted file mode 100644 index 15d8fe5b4ca..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/ActionFilterAdapterFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.cdt.debug.core.model.ICDebugTarget; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.ui.IActionFilter; - -/** - * The UI adapter factory for GDB/MI Debug extensions - */ -public class ActionFilterAdapterFactory implements IAdapterFactory { - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - @Override - public Object getAdapter( Object adaptableObject, Class adapterType ) { - if ( adapterType.isInstance( adaptableObject ) ) { - return adaptableObject; - } - if ( adapterType == IActionFilter.class ) { - if ( adaptableObject instanceof ICDebugTarget ) { - return new GDBTargetActionFilter(); - } - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - @Override - public Class[] getAdapterList() { - return new Class[] { - IActionFilter.class - }; - } -} 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 deleted file mode 100644 index b39328b21f2..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/CygwinDebuggerPage.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.swt.widgets.TabFolder; - -/** - * CygWin-specific extension of <code>GDBDebuggerPage</code>. - */ -public class CygwinDebuggerPage extends GDBDebuggerPage { - - @Override - public String getName() { - return MIUIMessages.getString( "CygwinDebuggerPage.0" ); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.GDBDebuggerPage#createTabs(org.eclipse.swt.widgets.TabFolder) - */ - @Override - public void createTabs( TabFolder tabFolder ) { - createMainTab( tabFolder ); - } -} 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 deleted file mode 100644 index 7a73c898dbe..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBDebuggerPage.java +++ /dev/null @@ -1,384 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -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.core.MIPlugin; -import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent; -import org.eclipse.cdt.debug.mi.ui.MIUIUtils; -import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.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.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; - -/** - * The dynamic tab for gdb-based debugger implementations. - */ -public class GDBDebuggerPage extends AbstractCDebuggerPage implements Observer { - - final private static String DEFAULT_MI_PROTOCOL = MIUIMessages.getString( "GDBDebuggerPage.12" ); //$NON-NLS-1$ - final protected String[] protocolItems = new String[] { DEFAULT_MI_PROTOCOL, "mi1", "mi2", "mi3" }; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - - protected TabFolder fTabFolder; - - protected Text fGDBCommandText; - - protected Text fGDBInitText; - - protected Combo fProtocolCombo; - - private IMILaunchConfigurationComponent fSolibBlock; - - private boolean fIsInitializing = false; - - private Button fBreakpointsFullPath; - - @Override - 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 ); - setControl( parent ); - } - - @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$ - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi" ); //$NON-NLS-1$ - if ( fSolibBlock != null ) - fSolibBlock.setDefaults( configuration ); - } - - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - boolean valid = fGDBCommandText.getText().length() != 0; - if ( valid ) { - setErrorMessage( null ); - setMessage( null ); - } - else { - setErrorMessage( MIUIMessages.getString( "GDBDebuggerPage.0" ) ); //$NON-NLS-1$ - setMessage( null ); - } - return valid; - } - - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - setInitializing( true ); - String gdbCommand = "gdb"; //$NON-NLS-1$ - String gdbInit = IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT; - try { - gdbCommand = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb" ); //$NON-NLS-1$ - } - catch( CoreException e ) { - } - try { - gdbInit = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT ); - } - catch( CoreException e ) { - } - String miVersion = MIPlugin.getMIVersion( configuration ); - if ( miVersion.compareTo( "mi" ) == 0 ) { //$NON-NLS-1$ - miVersion = DEFAULT_MI_PROTOCOL; - } - if ( fSolibBlock != null ) - fSolibBlock.initializeFrom( configuration ); - fGDBCommandText.setText( gdbCommand ); - fGDBInitText.setText( gdbInit ); - int index = 0; - if ( miVersion.length() > 0 ) { - for( int i = 0; i < protocolItems.length; ++i ) { - if ( protocolItems[i].equals( miVersion ) ) { - index = i; - break; - } - } - } - fProtocolCombo.select( index ); - - boolean useFullPath = IMILaunchConfigurationConstants.DEBUGGER_FULLPATH_BREAKPOINTS_DEFAULT; - try { - useFullPath = configuration.getAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_FULLPATH_BREAKPOINTS, useFullPath); - } - catch (CoreException e) {} - fBreakpointsFullPath.setSelection(useFullPath); - - setInitializing( false ); - } - - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - String str = fGDBCommandText.getText(); - str.trim(); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, str ); - str = fGDBInitText.getText(); - str.trim(); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, str ); - str = fProtocolCombo.getText(); - if ( str.compareTo( DEFAULT_MI_PROTOCOL ) == 0 ) { - str = "mi"; //$NON-NLS-1$ - } - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, str ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_FULLPATH_BREAKPOINTS, fBreakpointsFullPath.getSelection() ); - if ( fSolibBlock != null ) - fSolibBlock.performApply( configuration ); - } - - @Override - public String getName() { - return MIUIMessages.getString( "GDBDebuggerPage.1" ); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getShell() - */ - @Override - protected Shell getShell() { - return super.getShell(); - } - - /** - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() - */ - @Override - protected void updateLaunchConfigurationDialog() { - super.updateLaunchConfigurationDialog(); - } - - /* - * (non-Javadoc) - * - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) - */ - @Override - public void update( Observable o, Object arg ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - public IMILaunchConfigurationComponent createSolibBlock( Composite parent ) { - IMILaunchConfigurationComponent block = MIUIUtils.createGDBSolibBlock( true, true ); - block.createControl( parent ); - return block; - } - - public void createTabs( TabFolder tabFolder ) { - createMainTab( tabFolder ); - createSolibTab( 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( tabFolder, 1, GridData.FILL_BOTH ); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - comp.setFont( tabFolder.getFont() ); - tabItem.setControl( comp ); - Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - subComp.setFont( tabFolder.getFont() ); - Label label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "GDBDebuggerPage.3" ) ); //$NON-NLS-1$ - GridData gd = new GridData(); - // gd.horizontalSpan = 2; - label.setLayoutData( gd ); - fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); - fGDBCommandText.addModifyListener( new ModifyListener() { - - @Override - public void modifyText( ModifyEvent evt ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - Button button = createPushButton( subComp, MIUIMessages.getString( "GDBDebuggerPage.4" ), null ); //$NON-NLS-1$ - button.addSelectionListener( new SelectionAdapter() { - - @Override - 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; - label.setLayoutData( gd ); - fGDBInitText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); - gd = new GridData( GridData.FILL_HORIZONTAL ); - fGDBInitText.setLayoutData( gd ); - fGDBInitText.addModifyListener( new ModifyListener() { - - @Override - public void modifyText( ModifyEvent evt ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - button = createPushButton( subComp, MIUIMessages.getString( "GDBDebuggerPage.7" ), null ); //$NON-NLS-1$ - button.addSelectionListener( new SelectionAdapter() { - - @Override - 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( subComp, MIUIMessages.getString( "GDBDebuggerPage.9" ), //$NON-NLS-1$ - 200, SWT.DEFAULT, SWT.WRAP ); - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 3; - gd.widthHint = 200; - label.setLayoutData( gd ); - - createProtocolCombo( subComp ); - - createBreakpointFullPathName(subComp); - GridData gd2 = new GridData(); - gd2.horizontalSpan = 3; - fBreakpointsFullPath.setLayoutData(gd2); - } - - 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 ); - comp.setFont( tabFolder.getFont() ); - tabItem.setControl( comp ); - fSolibBlock = createSolibBlock( comp ); - if ( fSolibBlock instanceof Observable ) - ((Observable)fSolibBlock).addObserver( this ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() - */ - @Override - 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) - */ - @Override - public void activated( ILaunchConfigurationWorkingCopy workingCopy ) { - // Override the default behavior - } - - protected boolean isInitializing() { - return fIsInitializing; - } - - private void setInitializing( boolean isInitializing ) { - fIsInitializing = isInitializing; - } - - protected void createProtocolCombo( Composite parent ) { - Label label = new Label( parent, SWT.NONE ); - label.setText( MIUIMessages.getString( "GDBDebuggerPage.11" ) ); //$NON-NLS-1$ - fProtocolCombo = new Combo( parent, SWT.READ_ONLY | SWT.DROP_DOWN ); - fProtocolCombo.setItems( protocolItems ); - fProtocolCombo.addSelectionListener( new SelectionListener() { - - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } - - protected void createBreakpointFullPathName( Composite parent ) { - fBreakpointsFullPath = createCheckButton( parent, MIUIMessages.getString( "StandardGDBDebuggerPage.14" ) ); //$NON-NLS-1$ - fBreakpointsFullPath.addSelectionListener( new SelectionListener() { - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } -} 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 deleted file mode 100644 index 74257032824..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBServerDebuggerPage.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - * IBM Corporation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ComboDialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; - -/** - * The dynamic debugger tab for remote launches using gdb server. - */ -public class GDBServerDebuggerPage extends StandardGDBDebuggerPage { - - 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 TCPSettingsBlock fTCPBlock; - - private SerialPortSettingsBlock fSerialBlock; - - private Composite fConnectionStack; - - private boolean fIsInitializing = false; - - public GDBServerDebuggerPage() { - super(); - fConnectionField = createConnectionField(); - fTCPBlock = new TCPSettingsBlock(); - fSerialBlock = new SerialPortSettingsBlock(); - fTCPBlock.addObserver( this ); - fSerialBlock.addObserver( this ); - } - - protected void createConnectionTab( TabFolder tabFolder ) { - TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); - tabItem.setText( MIUIMessages.getString( "GDBServerDebuggerPage.10" ) ); //$NON-NLS-1$ - Composite comp1 = ControlFactory.createCompositeEx( tabFolder, 1, GridData.FILL_BOTH ); - ((GridLayout)comp1.getLayout()).makeColumnsEqualWidth = false; - comp1.setFont( tabFolder.getFont() ); - tabItem.setControl( comp1 ); - Composite comp = ControlFactory.createCompositeEx( comp1, 2, GridData.FILL_BOTH ); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - comp.setFont( comp1.getFont() ); - - createConnectionWidgets(comp); - } - - protected void createConnectionWidgets(Composite comp) { - fConnectionField.doFillIntoGrid( comp, 2 ); - ((GridData)fConnectionField.getComboControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; - fConnectionStack = ControlFactory.createCompositeEx( comp, 1, GridData.FILL_BOTH ); - StackLayout stackLayout = new StackLayout(); - fConnectionStack.setLayout( stackLayout ); - ((GridData)fConnectionStack.getLayoutData()).horizontalSpan = 2; - fTCPBlock.createBlock( fConnectionStack ); - fSerialBlock.createBlock( fConnectionStack ); - } - - 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() { - - @Override - public void dialogFieldChanged( DialogField f ) { - if ( !isInitializing() ) - connectionTypeChanged(); - } - } ); - return field; - } - - protected void connectionTypeChanged() { - connectionTypeChanged0(); - updateLaunchConfigurationDialog(); - } - - private void connectionTypeChanged0() { - ((StackLayout)fConnectionStack.getLayout()).topControl = null; - int index = fConnectionField.getSelectionIndex(); - if ( index >= 0 && index < fConnections.length ) { - String[] connTypes = fConnectionField.getItems(); - if ( CONNECTION_TCP.equals( connTypes[index] ) ) - ((StackLayout)fConnectionStack.getLayout()).topControl = fTCPBlock.getControl(); - else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) - ((StackLayout)fConnectionStack.getLayout()).topControl = fSerialBlock.getControl(); - } - fConnectionStack.layout(); - } - - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - if ( super.isValid( launchConfig ) ) { - setErrorMessage( null ); - setMessage( null ); - int index = fConnectionField.getSelectionIndex(); - if ( index >= 0 && index < fConnections.length ) { - String[] connTypes = fConnectionField.getItems(); - if ( CONNECTION_TCP.equals( connTypes[index] ) ) { - if ( !fTCPBlock.isValid( launchConfig ) ) { - setErrorMessage( fTCPBlock.getErrorMessage() ); - return false; - } - } - else if ( CONNECTION_SERIAL.equals( connTypes[index] ) ) { - if ( !fSerialBlock.isValid( launchConfig ) ) { - setErrorMessage( fSerialBlock.getErrorMessage() ); - return false; - } - } - return true; - } - } - return false; - } - - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - setInitializing( true ); - super.initializeFrom( configuration ); - boolean isTcp = false; - try { - isTcp = configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); - } - catch( CoreException e ) { - } - fTCPBlock.initializeFrom( configuration ); - fSerialBlock.initializeFrom( configuration ); - fConnectionField.selectItem( (isTcp) ? 0 : 1 ); - connectionTypeChanged0(); - setInitializing( false ); - } - - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - super.performApply( configuration ); - if ( fConnectionField != null ) - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, fConnectionField.getSelectionIndex() == 0 ); - fTCPBlock.performApply( configuration ); - fSerialBlock.performApply( configuration ); - } - - @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - super.setDefaults( configuration ); - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_REMOTE_TCP, false ); - fTCPBlock.setDefaults( configuration ); - fSerialBlock.setDefaults( configuration ); - } - - @Override - protected boolean isInitializing() { - return fIsInitializing; - } - - private void setInitializing( boolean isInitializing ) { - fIsInitializing = isInitializing; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.GDBDebuggerPage#createTabs(org.eclipse.swt.widgets.TabFolder) - */ - @Override - public void createTabs( TabFolder tabFolder ) { - super.createTabs( tabFolder ); - createConnectionTab( tabFolder ); - } - - public void dispose() { - fTCPBlock.dispose(); - fSerialBlock.dispose(); - fConnectionStack.dispose(); - fConnectionField.dispose(); - super.dispose(); - } -} 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 deleted file mode 100644 index 92286fe32f8..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBSolibBlock.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.util.Map; -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; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -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; - -/** - * The content of the <code>Shared Libraries</code> tab of the <code>GDBDebuggerPage</code>. - */ -public class GDBSolibBlock extends Observable implements IMILaunchConfigurationComponent, Observer { - - private IMILaunchConfigurationComponent fSolibSearchPathBlock; - - private Button fAutoSoLibButton; - - private Button fStopOnSolibEventsButton; - - private Composite fControl; - - private boolean fAutoSolib = false; - - private boolean fStopOnSolibEvents = false; - - public GDBSolibBlock( IMILaunchConfigurationComponent solibSearchBlock, boolean autoSolib, boolean stopOnSolibEvents ) { - super(); - fSolibSearchPathBlock = solibSearchBlock; - fAutoSolib = autoSolib; - fStopOnSolibEvents = stopOnSolibEvents; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - 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 ( fSolibSearchPathBlock != null ) { - fSolibSearchPathBlock.createControl( subComp ); - if ( fSolibSearchPathBlock instanceof Observable ) - ((Observable)fSolibSearchPathBlock).addObserver( this ); - } - if ( fAutoSolib ) { - fAutoSoLibButton = ControlFactory.createCheckBox( subComp, MIUIMessages.getString( "GDBSolibBlock.0" ) ); //$NON-NLS-1$ - fAutoSoLibButton.addSelectionListener( new SelectionAdapter() { - - @Override - public void widgetSelected( SelectionEvent e ) { - updateButtons(); - changed(); - } - } ); - } - if ( fStopOnSolibEvents ) { - fStopOnSolibEventsButton = ControlFactory.createCheckBox( subComp, MIUIMessages.getString( "GDBSolibBlock.1" ) ); //$NON-NLS-1$ - fStopOnSolibEventsButton.addSelectionListener( new SelectionAdapter() { - - @Override - public void widgetSelected( SelectionEvent e ) { - updateButtons(); - changed(); - } - } ); - } - fControl = subComp; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.initializeFrom( configuration ); - try { - if ( fAutoSoLibButton != null ) - fAutoSoLibButton.setSelection( configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IMILaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ) ); - if ( fStopOnSolibEventsButton != null ) - fStopOnSolibEventsButton.setSelection( configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, IMILaunchConfigurationConstants.DEBUGGER_STOP_ON_SOLIB_EVENTS_DEFAULT ) ); - initializeButtons( configuration ); - updateButtons(); - } - catch( CoreException e ) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.performApply( configuration ); - try { - Map attrs = configuration.getAttributes(); - if ( fAutoSoLibButton != null ) - attrs.put( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, Boolean.valueOf( fAutoSoLibButton.getSelection() ) ); - if ( fStopOnSolibEventsButton != null ) - attrs.put( IMILaunchConfigurationConstants.ATTR_DEBUGGER_STOP_ON_SOLIB_EVENTS, Boolean.valueOf( fStopOnSolibEventsButton.getSelection() ) ); - configuration.setAttributes( attrs ); - } - catch( CoreException e ) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - @Override - 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 ); - } - - protected void updateButtons() { - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() - */ - @Override - public void dispose() { - deleteObservers(); - if ( fSolibSearchPathBlock != null ) { - if ( fSolibSearchPathBlock instanceof Observable ) - ((Observable)fSolibSearchPathBlock).deleteObserver( this ); - fSolibSearchPathBlock.dispose(); - } - } - - /* - * (non-Javadoc) - * - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) - */ - @Override - public void update( Observable o, Object arg ) { - changed(); - } - - protected void changed() { - setChanged(); - notifyObservers(); - } - - 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 ) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() - */ - @Override - public Control getControl() { - return fControl; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - // TODO Auto-generated method stub - return false; - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBTargetActionFilter.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBTargetActionFilter.java deleted file mode 100644 index 7b9d152bc89..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/GDBTargetActionFilter.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.model.ICDebugTarget; -import org.eclipse.cdt.debug.mi.core.cdi.Session; -import org.eclipse.ui.IActionFilter; - -/** - * Comment for . - */ -public class GDBTargetActionFilter implements IActionFilter { - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String) - */ - @Override - public boolean testAttribute( Object target, String name, String value ) { - if ( target instanceof ICDebugTarget ) { - if ( name.equals( "GDBTargetActionFilter" ) && value.equals( "isGDBTarget" ) ) { //$NON-NLS-1$//$NON-NLS-2$ - return ( ((ICDebugTarget)target).getAdapter( ICDISession.class ) instanceof Session ); - } - } - return false; - } -} 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 deleted file mode 100644 index 60f8ed427b8..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIHelpContextIds.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -/** - * Help context ids for the C/C++ debug ui. - * <p> - * This interface contains constants only; it is not intended to be implemented or extended. - * </p> - */ -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$ -} 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 deleted file mode 100644 index fc8d73d242d..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/IMIUIConstants.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -/** - * Constant definitions for MI UI plug-in. - */ -public interface IMIUIConstants { - - /** - * Plug-in identifier (value <code>"org.eclipse.cdt.debug.mi.ui"</code>). - */ - public static final String PLUGIN_ID = MIUIPlugin.getUniqueIdentifier(); -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.java deleted file mode 100644 index 9fa393dcd06..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class MIUIMessages { - - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.mi.internal.ui.MIUIMessages";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private MIUIMessages() { - } - - public static String getString( String key ) { - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } - } -} 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 deleted file mode 100644 index 5e7d8234a3c..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIMessages.properties +++ /dev/null @@ -1,75 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2008 QNX Software Systems and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# QNX Software Systems - initial API and implementation -############################################################################### - -CygwinDebuggerPage.0=Cygwin GDB Debugger Options -GDBDebuggerPage.0=Debugger executable must be specified. -GDBDebuggerPage.1=GDB Debugger Options -GDBDebuggerPage.2=Main -GDBDebuggerPage.3=GDB debugger: -GDBDebuggerPage.4=&Browse... -GDBDebuggerPage.5=GDB Debugger -GDBDebuggerPage.6=GDB command file: -GDBDebuggerPage.7=B&rowse... -GDBDebuggerPage.8=GDB Command File -GDBDebuggerPage.9=(Warning: Some commands in this file may interfere with the startup operation of the debugger, for example "run".) -GDBDebuggerPage.10=Shared Libraries -GDBDebuggerPage.11=Protocol: -GDBDebuggerPage.12=Default -StandardGDBDebuggerPage.0=Debugger executable must be specified. -StandardGDBDebuggerPage.1=GDB Debugger Options -StandardGDBDebuggerPage.2=Main -StandardGDBDebuggerPage.3=GDB debugger: -StandardGDBDebuggerPage.4=&Browse... -StandardGDBDebuggerPage.5=GDB Debugger -StandardGDBDebuggerPage.6=GDB command file: -StandardGDBDebuggerPage.7=B&rowse... -StandardGDBDebuggerPage.8=GDB Command File -StandardGDBDebuggerPage.9=(Warning: Some commands in this file may interfere with the startup operation of the debugger, for example "run".) -StandardGDBDebuggerPage.10=Shared Libraries -StandardGDBDebuggerPage.11=Protocol: -StandardGDBDebuggerPage.12=GDB command set: -StandardGDBDebuggerPage.13=Verbose console mode -StandardGDBDebuggerPage.14=Use full file path to set breakpoints -GDBServerDebuggerPage.0=TCP -GDBServerDebuggerPage.1=Serial -GDBServerDebuggerPage.10=Connection -GDBServerDebuggerPage.2=Main -GDBServerDebuggerPage.3=GDB debugger -GDBServerDebuggerPage.4=&Browse... -GDBServerDebuggerPage.5=GDB Debugger -GDBServerDebuggerPage.6=GDB command file: -GDBServerDebuggerPage.7=B&rowse... -GDBServerDebuggerPage.8=GDB Command File -GDBServerDebuggerPage.9=Type: -GDBSolibBlock.0=Load shared library symbols automatically -GDBSolibBlock.1=Stop on shared library events -SerialPortSettingsBlock.0=Device: -SerialPortSettingsBlock.1=Speed: -SerialPortSettingsBlock.2=Device must be specified. -SerialPortSettingsBlock.3=Invalid device. -SerialPortSettingsBlock.4=Speed must be specified. -SolibSearchPathBlock.0=Add... -SolibSearchPathBlock.1=Up -SolibSearchPathBlock.2=Down -SolibSearchPathBlock.3=Remove -SolibSearchPathBlock.4=Directories: -SolibSearchPathBlock.5=Select directory that contains shared library. -SolibSearchPathBlock.6=Select From List -SolibSearchPathBlock.7=Select Libraries -SolibSearchPathBlock.8=Select libraries to load symbols automatically. -SolibSearchPathBlock.9=No libraries found. -SolibSearchPathBlock.Add_Directory=Add Directory -TCPSettingsBlock.0=Host name or IP address: -TCPSettingsBlock.1=Port number: -TCPSettingsBlock.2=Host name or IP address must be specified. -TCPSettingsBlock.3=Invalid host name or IP address. -TCPSettingsBlock.4=Port number must be specified. -TCPSettingsBlock.5=Invalid port number. diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIPlugin.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIPlugin.java deleted file mode 100644 index b5de4edd239..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MIUIPlugin.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -/** - * The main plugin class to be used in the desktop. - */ -public class MIUIPlugin extends AbstractUIPlugin { - - /** - * The plug-in identifier (value <code>"org.eclipse.cdt.debug.mi.ui"</code>). - */ - public static final String PLUGIN_ID = "org.eclipse.cdt.debug.mi.ui" ; //$NON-NLS-1$ - - //The shared instance. - private static MIUIPlugin plugin; - - /** - * The constructor. - */ - public MIUIPlugin() { - super(); - plugin = this; - } - - /** - * Returns the shared instance. - */ - public static MIUIPlugin getDefault() { - return plugin; - } - - /** - * Returns the workspace instance. - */ - public static IWorkspace getWorkspace() { - return ResourcesPlugin.getWorkspace(); - } - - /** - * Convenience method which returns the unique identifier of this plugin. - * - * @return the unique identifier of this plugin - */ - public static String getUniqueIdentifier() { - return PLUGIN_ID; - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MinGWDebuggerPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MinGWDebuggerPage.java deleted file mode 100644 index 6a05e687a99..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/MinGWDebuggerPage.java +++ /dev/null @@ -1,67 +0,0 @@ -/********************************************************************** - * Copyright (c) 2007, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - **********************************************************************/ - -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.io.File; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.envvar.IEnvironmentVariable; -import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.ILaunchConfiguration; - - - -/** - * @author Doug Schaefer - * - */ -public class MinGWDebuggerPage extends StandardGDBDebuggerPage { - - @Override - protected String defaultGdbCommand(ILaunchConfiguration configuration) { - // Lets look it up in the project - try { - String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ - if (projectName.length() > 0) { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project); - ICConfigurationDescription configDesc = projDesc.getActiveConfiguration(); - IEnvironmentVariableManager envVarMgr = CCorePlugin.getDefault().getBuildEnvironmentManager(); - IEnvironmentVariable pathvar = envVarMgr.getVariable("PATH", configDesc, true); //$NON-NLS-1$ - if(pathvar != null) - { - String path = pathvar.getValue(); - String[] dirs = path.split(pathvar.getDelimiter()); - for (int i = 0; i < dirs.length; ++i) { - IPath gdbPath = new Path(dirs[i]).append("gdb.exe"); //$NON-NLS-1$ - File gdbFile = gdbPath.toFile(); - if (gdbFile.exists()) - return gdbPath.toOSString(); - } - } - } - } catch (CoreException e) { - } - - return super.defaultGdbCommand(configuration); - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SWTUtil.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SWTUtil.java deleted file mode 100644 index 2f9e0c7e837..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SWTUtil.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.core.runtime.Assert; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DragSource; -import org.eclipse.swt.dnd.DropTarget; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Caret; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.ScrollBar; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; - -/** - * Utility class to simplify access to some SWT resources. - */ -public class SWTUtil { - - /** - * Returns the standard display to be used. The method first checks, if the - * thread calling this method has an associated disaply. If so, this - * display is returned. Otherwise the method returns the default display. - */ - public static Display getStandardDisplay() { - Display display; - display = Display.getCurrent(); - if ( display == null ) - display = Display.getDefault(); - return display; - } - - /** - * Returns the shell for the given widget. If the widget doesn't represent - * a SWT object that manage a shell, <code>null</code> is returned. - * - * @return the shell for the given widget - */ - public static Shell getShell(Widget widget) { - if ( widget instanceof Control ) - return ((Control)widget).getShell(); - if ( widget instanceof Caret ) - return ((Caret)widget).getParent().getShell(); - if ( widget instanceof DragSource ) - return ((DragSource)widget).getControl().getShell(); - if ( widget instanceof DropTarget ) - return ((DropTarget)widget).getControl().getShell(); - if ( widget instanceof Menu ) - return ((Menu)widget).getParent().getShell(); - if ( widget instanceof ScrollBar ) - return ((ScrollBar)widget).getParent().getShell(); - return null; - } - - /** - * Returns a width hint for a button control. - */ - public static int getButtonWidthHint( Button button ) { - PixelConverter converter = new PixelConverter( button ); - int widthHint = converter.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); - return Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); - } - - /** - * Returns a height hint for a button control. - */ -// public static int getButtonHeigthHint( Button button ) { -// PixelConverter converter = new PixelConverter( button ); -// return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT ); -// } - - /** - * Sets width and height hint for the button control. <b>Note:</b> This - * is a NOP if the button's layout data is not an instance of <code>GridData</code>. - * - * @param the button for which to set the dimension hint - */ - public static void setButtonDimensionHint( Button button ) { - Assert.isNotNull( button ); - Object gd = button.getLayoutData(); - if ( gd instanceof GridData ) { - ((GridData)gd).widthHint = getButtonWidthHint( button ); - ((GridData)gd).horizontalAlignment = GridData.FILL; - } - } -} 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 deleted file mode 100644 index 6c2b32fc5ca..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SerialPortSettingsBlock.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.util.Observable; - -import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ComboDialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.StringDialogField; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -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() { - super(); - fDeviceField = createDeviceField(); - fSpeedField = createSpeedField(); - } - - public void createBlock( Composite parent ) { - fShell = parent.getShell(); - Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)comp.getLayout()).marginHeight = 0; - ((GridLayout)comp.getLayout()).marginWidth = 0; - comp.setFont( parent.getFont() ); - PixelConverter converter = new PixelConverter( comp ); - fDeviceField.doFillIntoGrid( comp, 2 ); - LayoutUtil.setWidthHint( fDeviceField.getTextControl( null ), converter.convertWidthInCharsToPixels( 20 ) ); - fSpeedField.doFillIntoGrid( comp, 2 ); - ((GridData)fSpeedField.getComboControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; - setControl( comp ); - } - - protected Shell getShell() { - return fShell; - } - - public void dispose() { - deleteObservers(); - } - - public void initializeFrom( ILaunchConfiguration configuration ) { - initializeDevice( configuration ); - initializeSpeed( configuration ); - } - - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE ); - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ); - } - - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - if ( fDeviceField != null ) - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, fDeviceField.getText().trim() ); - if ( fSpeedField != null ) { - int index = fSpeedField.getSelectionIndex(); - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, getSpeedItem( index ) ); - } - } - - private StringDialogField createDeviceField() { - StringDialogField field = new StringDialogField(); - field.setLabelText( MIUIMessages.getString( "SerialPortSettingsBlock.0" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( new IDialogFieldListener() { - - @Override - public void dialogFieldChanged( DialogField f ) { - deviceFieldChanged(); - } - } ); - return field; - } - - 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() { - - @Override - public void dialogFieldChanged( DialogField f ) { - speedFieldChanged(); - } - } ); - return field; - } - - protected void deviceFieldChanged() { - updateErrorMessage(); - setChanged(); - notifyObservers(); - } - - protected void speedFieldChanged() { - updateErrorMessage(); - setChanged(); - notifyObservers(); - } - - private void initializeDevice( ILaunchConfiguration configuration ) { - if ( fDeviceField != null ) { - try { - fDeviceField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE ) ); - } - catch( CoreException e ) { - } - } - } - - private void initializeSpeed( ILaunchConfiguration configuration ) { - if ( fSpeedField != null ) { - int index = 0; - try { - index = getSpeedItemIndex( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED ) ); - } - catch( CoreException e ) { - } - fSpeedField.selectItem( index ); - } - } - - private String getSpeedItem( int index ) { - return (index >= 0 && index < fSpeedChoices.length) ? fSpeedChoices[index] : null; - } - - private int getSpeedItemIndex( String item ) { - for( int i = 0; i < fSpeedChoices.length; ++i ) - if ( fSpeedChoices[i].equals( item ) ) - return i; - return 0; - } - - public Control getControl() { - return fControl; - } - - protected void setControl( Control control ) { - fControl = control; - } - - public boolean isValid( ILaunchConfiguration configuration ) { - updateErrorMessage(); - return (getErrorMessage() == null); - } - - private void updateErrorMessage() { - setErrorMessage( null ); - if ( fDeviceField != null && fSpeedField != null ) { - if ( fDeviceField.getText().trim().length() == 0 ) - setErrorMessage( MIUIMessages.getString( "SerialPortSettingsBlock.2" ) ); //$NON-NLS-1$ - else if ( !deviceIsValid( fDeviceField.getText().trim() ) ) - setErrorMessage( MIUIMessages.getString( "SerialPortSettingsBlock.3" ) ); //$NON-NLS-1$ - else if ( fSpeedField.getSelectionIndex() < 0 ) - setErrorMessage( MIUIMessages.getString( "SerialPortSettingsBlock.4" ) ); //$NON-NLS-1$ - } - } - - public String getErrorMessage() { - return fErrorMessage; - } - - private void setErrorMessage( String string ) { - fErrorMessage = string; - } - - private boolean deviceIsValid( String hostName ) { - return true; - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java deleted file mode 100644 index 82adc381f1a..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/SolibSearchPathBlock.java +++ /dev/null @@ -1,622 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - * IBM Corporation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Observable; -import java.util.Set; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.IBinaryParser; -import org.eclipse.cdt.core.IBinaryParser.IBinaryFile; -import org.eclipse.cdt.core.IBinaryParser.IBinaryShared; -import org.eclipse.cdt.core.model.CoreModelUtil; -import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference; -import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.core.MICoreUtils; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.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.utils.ui.controls.ControlFactory; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -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.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jface.window.Window; -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; -import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog; - -/** - * The UI component to access the shared libraries search path. - */ -public class SolibSearchPathBlock extends Observable implements IMILaunchConfigurationComponent, IDialogFieldListener { - - class AddDirectoryDialog extends Dialog { - - protected Text fText; - - private Button fBrowseButton; - - private IPath fValue; - - /** - * Constructor for AddDirectoryDialog. - */ - public AddDirectoryDialog( Shell parentShell ) { - super( parentShell ); - } - - @Override - 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() { - - @Override - public void modifyText( ModifyEvent e ) { - updateOKButton(); - } - } ); - - fBrowseButton = ControlFactory.createPushButton( subComp, MIUIMessages.getString( "GDBServerDebuggerPage.7" ) ); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - fBrowseButton.setLayoutData( data ); - fBrowseButton.addSelectionListener( new SelectionAdapter() { - - @Override - public void widgetSelected( SelectionEvent evt ) { - DirectoryDialog dialog = new DirectoryDialog( AddDirectoryDialog.this.getShell() ); - dialog.setMessage( MIUIMessages.getString( "SolibSearchPathBlock.5" ) ); //$NON-NLS-1$ - String res = dialog.open(); - if ( res != null ) { - fText.setText( res ); - } - } - } ); - - applyDialogFont( composite ); - return composite; - } - - @Override - protected void configureShell( Shell newShell ) { - super.configureShell( newShell ); - newShell.setText( MIUIMessages.getString( "SolibSearchPathBlock.Add_Directory" ) ); //$NON-NLS-1$ - } - - public IPath getValue() { - return fValue; - } - - private void setValue( String value ) { - fValue = ( value != null ) ? new Path( value ) : null; - } - - @Override - 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 ); - } - - @Override - 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) - */ - @Override - protected boolean managedButtonPressed( int index ) { - boolean result = super.managedButtonPressed( index ); - if ( result ) - buttonPressed( index ); - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ListDialogField#getManagedButtonState(org.eclipse.jface.viewers.ISelection, int) - */ - @Override - protected boolean getManagedButtonState( ISelection sel, int index ) { - if ( index > 3 ) - return getButtonState( sel, index ); - return super.getManagedButtonState( sel, index ); - } - } - - private static String[] fgStaticButtonLabels = new String[] { - MIUIMessages.getString( "SolibSearchPathBlock.0" ), //$NON-NLS-1$ - MIUIMessages.getString( "SolibSearchPathBlock.1" ), //$NON-NLS-1$ - MIUIMessages.getString( "SolibSearchPathBlock.2" ), //$NON-NLS-1$ - MIUIMessages.getString( "SolibSearchPathBlock.3" ), //$NON-NLS-1$ - MIUIMessages.getString( "SolibSearchPathBlock.6" ), //$NON-NLS-1$ - null, // separator - }; - - private IProject fProject; - - private Shell fShell; - - private SolibSearchPathListDialogField fDirList; - - private IListAdapter fCustomListAdapter; - - private File[] fAutoSolibs = new File[0]; - - public SolibSearchPathBlock() { - this( new String[0], null ); - } - - public SolibSearchPathBlock( String[] customButtonLabels, IListAdapter customListAdapter ) { - super(); - fCustomListAdapter = customListAdapter; - int length = fgStaticButtonLabels.length; - if ( customButtonLabels.length > 0 ) - length += customButtonLabels.length; - String[] buttonLabels = new String[length]; - System.arraycopy( fgStaticButtonLabels, 0, buttonLabels, 0, fgStaticButtonLabels.length ); - if ( length > fgStaticButtonLabels.length ) { - for ( int i = fgStaticButtonLabels.length; i < length; ++i ) - buttonLabels[i] = customButtonLabels[i - fgStaticButtonLabels.length]; - } - IListAdapter listAdapter = new IListAdapter() { - @Override - public void customButtonPressed( DialogField field, int index ) { - buttonPressed( index ); - } - @Override - public void selectionChanged( DialogField field ) { - } - }; - ILabelProvider lp = new LabelProvider() { - @Override - public String getText( Object element ) { - if ( element instanceof IPath ) - return ((IPath)element).toOSString(); - return super.getText( element ); - } - }; - fDirList = new SolibSearchPathListDialogField( listAdapter, buttonLabels, lp ); - fDirList.setLabelText( MIUIMessages.getString( "SolibSearchPathBlock.4" ) ); //$NON-NLS-1$ - fDirList.setUpButtonIndex( 1 ); - fDirList.setDownButtonIndex( 2 ); - fDirList.setRemoveButtonIndex( 3 ); - - fDirList.setDialogFieldListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) - */ - @Override - 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; - comp.setFont( parent.getFont() ); - 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; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - IProject project = null; - try { - String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null ); - if ( projectName != null ) { - projectName = projectName.trim(); - if ( projectName.length() > 0 ) { - project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); - } - } - } - catch( CoreException e ) { - } - setProject( project ); - - if ( fDirList != null ) { - try { - List values = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST ); - ArrayList paths = new ArrayList( values.size() ); - Iterator it = values.iterator(); - while( it.hasNext() ) { - paths.add( new Path( (String)it.next() ) ); - } - fDirList.addElements( paths ); - } - catch( CoreException e ) { - } - } - - try { - fAutoSolibs = MICoreUtils.getAutoSolibs( configuration ); - } - catch( CoreException e ) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST ); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - if ( fDirList != null ) { - List elements = fDirList.getElements(); - ArrayList values = new ArrayList( elements.size() ); - Iterator it = elements.iterator(); - while( it.hasNext() ) { - values.add( ((IPath)it.next()).toOSString() ); - } - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, values ); - } - ArrayList autoLibs = new ArrayList( fAutoSolibs.length ); - for ( int i = 0; i < fAutoSolibs.length; ++i ) - autoLibs.add( fAutoSolibs[i].getPath() ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, autoLibs ); - } - - protected void buttonPressed( int index ) { - boolean changed = false; - if ( index == 0 ) { // Add button - changed = addDirectory(); - } - else if ( index == 4 ) { //Select from list - changed = selectFromList(); - } - else if ( index >= fgStaticButtonLabels.length && fCustomListAdapter != null ) { - fCustomListAdapter.customButtonPressed( fDirList, index ); - changed = true; - } - if ( changed ) { - setChanged(); - notifyObservers(); - } - } - - protected boolean getButtonState( ISelection sel, int index ) { - if ( index == 4 ) { // select from list - return ( !sel.isEmpty() ); - } - return true; - } - - protected Shell getShell() { - return fShell; - } - - protected DialogField getDirList(){ - return fDirList; - } - protected boolean addDirectory() { - boolean changed = false; - AddDirectoryDialog dialog = new AddDirectoryDialog( getShell() ); - dialog.open(); - IPath result = dialog.getValue(); - if ( result != null && !contains( result ) ) { - fDirList.addElement( result ); - changed = true; - } - return changed; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() - */ - @Override - public void dispose() { - deleteObservers(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() - */ - @Override - public Control getControl() { - return fControl; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - // TODO Auto-generated method stub - return false; - } - - protected boolean contains( IPath path ) { - List list = fDirList.getElements(); - Iterator it = list.iterator(); - while( it.hasNext() ) { - IPath p = (IPath)it.next(); - if ( p.toFile().equals( path.toFile() ) ) - return true; - } - return false; - } - - protected IProject getProject() { - return fProject; - } - - private void setProject( IProject project ) { - fProject = project; - } - - protected boolean selectFromList() { - boolean changed = false; - List dirList = fDirList.getSelectedElements(); - final HashSet libs = new HashSet( 10 ); - if ( generateLibraryList( (IPath[])dirList.toArray( new IPath[dirList.size()] ), libs ) ) { - ITreeContentProvider cp = new ITreeContentProvider() { - - @Override - public Object[] getChildren( Object parentElement ) { - return getElements( parentElement ); - } - - @Override - public Object getParent( Object element ) { - if ( libs.contains( element ) ) - return libs; - return null; - } - - @Override - public boolean hasChildren( Object element ) { - return false; - } - - @Override - public Object[] getElements( Object inputElement ) { - if ( inputElement instanceof Set ) { - return ((Set)inputElement).toArray(); - } - return new Object[0]; - } - - @Override - public void dispose() { - } - - @Override - public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { - } - }; - - LabelProvider lp = new LabelProvider() { - - @Override - public String getText( Object element ) { - if ( element instanceof File ) - return ((File)element).getName(); - return super.getText( element ); - } - }; - CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog( getShell(), lp, cp ); - dialog.setTitle( MIUIMessages.getString( "SolibSearchPathBlock.7" ) ); //$NON-NLS-1$ - dialog.setMessage( MIUIMessages.getString( "SolibSearchPathBlock.8" ) ); //$NON-NLS-1$ - dialog.setEmptyListMessage( MIUIMessages.getString( "SolibSearchPathBlock.9" ) ); //$NON-NLS-1$ - dialog.setSorter( new ViewerSorter() ); - dialog.setInput( libs ); - dialog.setInitialElementSelections( Arrays.asList( fAutoSolibs ) ); - if ( dialog.open() == Window.OK ) { - Object[] result = dialog.getResult(); - fAutoSolibs = Arrays.asList( result ).toArray( new File[result.length] ); - changed = true; - } - } - return changed; - } - - private boolean generateLibraryList( final IPath[] paths, final Set libs ) { - boolean result = true; - - IRunnableWithProgress runnable = new IRunnableWithProgress() { - @Override - public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { - - for ( int i = 0; i < paths.length; ++i ) { - File dir = paths[i].toFile(); - if ( dir.exists() && dir.isDirectory() ) { - File[] all = dir.listFiles(); - for ( int j = 0; j < all.length; ++j ) { - if ( monitor.isCanceled() ) { - throw new InterruptedException(); - } - monitor.subTask( all[j].getPath() ); - String libName = getSharedLibraryName( all[j] ); - if ( libName != null ) { - libs.add( new File( libName ) ); - } - } - } - } - } - }; - try { - IRunnableContext context = new ProgressMonitorDialog( getShell() ); - context.run( true, true, runnable ); - } - catch( InvocationTargetException e ) { - } - catch( InterruptedException e ) { - result = false; - } - return result; - } - - protected String getSharedLibraryName( File file ) { - if ( !file.isFile() ) - return null; - IProject project = getProject(); - if ( project != null ) { - IPath fullPath = new Path( file.getPath() ); - try { - ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getDefaultBinaryParserExtensions( project ); - for( int i = 0; i < binaryParsersExt.length; i++ ) { - IBinaryParser parser = CoreModelUtil.getBinaryParser(binaryParsersExt[i]); - try { - IBinaryFile bin = parser.getBinary( fullPath ); - if ( bin instanceof IBinaryShared ) { - String soname = ((IBinaryShared)bin).getSoName(); - return ( soname.length() != 0 ) ? soname : file.getName(); - } - } - catch( IOException e ) { - } - } - } - catch( CoreException e ) { - } - return null; - } - // no project: for now - IPath path = new Path( file.getPath() ); - String name = path.lastSegment(); - String extension = path.getFileExtension(); - if ( extension != null && (extension.compareTo( "so" ) == 0 || extension.compareToIgnoreCase( "dll" ) == 0) ) //$NON-NLS-1$ //$NON-NLS-2$ - return name; - return ( name.indexOf( ".so." ) >= 0 ) ? name : null; //$NON-NLS-1$ - } - - protected boolean isSharedLibrary( File file ) { - if ( !file.isFile() ) - return false; - IProject project = getProject(); - if ( project != null ) { - IPath fullPath = new Path( file.getPath() ); - try { - ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getDefaultBinaryParserExtensions( project ); - for( int i = 0; i < binaryParsersExt.length; i++ ) { - IBinaryParser parser = CoreModelUtil.getBinaryParser(binaryParsersExt[i]); - try { - IBinaryFile bin = parser.getBinary( fullPath ); - return ( bin instanceof IBinaryShared ); - } - catch( IOException e ) { - } - } - } - catch( CoreException e ) { - } - return false; - } - // no project: for now - IPath path = new Path( file.getPath() ); - String extension = path.getFileExtension(); - if ( extension != null && (extension.compareTo( "so" ) == 0 || extension.compareToIgnoreCase( "dll" ) == 0) ) //$NON-NLS-1$ //$NON-NLS-2$ - return true; - String name = path.lastSegment(); - return ( name.indexOf( ".so." ) >= 0 ); //$NON-NLS-1$ - } - - @Override - public void dialogFieldChanged(DialogField field) { - setChanged(); - notifyObservers(); - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/StandardGDBDebuggerPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/StandardGDBDebuggerPage.java deleted file mode 100644 index 9d8c36387e4..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/StandardGDBDebuggerPage.java +++ /dev/null @@ -1,558 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - * Vladimir Prus (vladimir@codesourcery.com) - bug 156114: GDB options layout - * problem - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Observable; -import java.util.Observer; -import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.core.MIPlugin; -import org.eclipse.cdt.debug.mi.core.command.factories.CommandFactoryDescriptor; -import org.eclipse.cdt.debug.mi.ui.IMILaunchConfigurationComponent; -import org.eclipse.cdt.debug.mi.ui.MIUIUtils; -import org.eclipse.cdt.debug.ui.AbstractCDebuggerPage; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.cdt.utils.Platform; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -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.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; - -/** - * The dynamic tab for gdb-based debugger implementations. - */ -public class StandardGDBDebuggerPage extends AbstractCDebuggerPage implements Observer { - - private final static String DEFAULT_MI_VERSION = "mi"; //$NON-NLS-1$ - - protected TabFolder fTabFolder; - - protected Text fGDBCommandText; - - protected Text fGDBInitText; - - protected Combo fCommandFactoryCombo; - - protected Combo fProtocolCombo; - - protected Button fVerboseModeButton; - protected Button fBreakpointsFullPath; - - private IMILaunchConfigurationComponent fSolibBlock; - - private CommandFactoryDescriptor[] fCommandFactoryDescriptors; - - private boolean fIsInitializing = false; - - private static boolean gdb64ExistsIsCached = false; - - private static boolean cachedGdb64Exists; - - @Override - 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 ); - setControl( parent ); - } - - @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand(configuration)); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, MIPlugin.getDefault().getCommandFactoryManager().getDefaultDescriptor( getDebuggerIdentifier() ).getIdentifier() ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT ); - if ( fSolibBlock != null ) - fSolibBlock.setDefaults( configuration ); - } - - protected String defaultGdbCommand(ILaunchConfiguration configuration) { - String gdbCommand = null; - - if (Platform.getOS().equals(Platform.OS_LINUX) && - Platform.getOSArch().equals("ppc64")) { //$NON-NLS-1$ - // On SLES 9 and 10 for ppc64 arch, there is a separate - // 64-bit capable gdb called gdb64. It can - // also debug 32-bit executables, so let's see if it exists. - if (!gdb64ExistsIsCached) { - Process unameProcess; - int interruptedRetryCount = 5; - - String cmd[] = {"gdb64", "--version"}; //$NON-NLS-1$ //$NON-NLS-2$ - - gdb64ExistsIsCached = true; - - while (interruptedRetryCount >= 0) { - try { - unameProcess = Runtime.getRuntime().exec(cmd); - int exitStatus = unameProcess.waitFor(); - - cachedGdb64Exists = (exitStatus == 0); - break; - } catch (IOException e) { - cachedGdb64Exists = false; - break; - } catch (InterruptedException e) { - // Never should get here, really. The chances of the command being interrupted - // are very small - cachedGdb64Exists = false; - interruptedRetryCount--; - } - } - } - if (cachedGdb64Exists) { - gdbCommand = "gdb64"; //$NON-NLS-1$ - } else { - gdbCommand = IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT; - } - } else { - gdbCommand = IMILaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT; - } - return gdbCommand; - } - - - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { - boolean valid = fGDBCommandText.getText().length() != 0; - if ( valid ) { - setErrorMessage( null ); - setMessage( null ); - } - else { - setErrorMessage( MIUIMessages.getString( "StandardGDBDebuggerPage.0" ) ); //$NON-NLS-1$ - setMessage( null ); - } - return valid; - } - - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - setInitializing( true ); - String gdbCommand = defaultGdbCommand(configuration); - String gdbInit = IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT; - try { - gdbCommand = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand(configuration)); - } - catch( CoreException e ) { - } - try { - gdbInit = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, IMILaunchConfigurationConstants.DEBUGGER_GDB_INIT_DEFAULT ); - } - catch( CoreException e ) { - } - if ( fSolibBlock != null ) - fSolibBlock.initializeFrom( configuration ); - fGDBCommandText.setText( gdbCommand ); - fGDBInitText.setText( gdbInit ); - - String debuggerID = getDebuggerIdentifier(); - fCommandFactoryDescriptors = MIPlugin.getDefault().getCommandFactoryManager().getDescriptors( debuggerID ); - Arrays.sort( fCommandFactoryDescriptors, - new Comparator() { - @Override - public int compare( Object arg0, Object arg1 ) { - return ((CommandFactoryDescriptor)arg0).getName().compareTo( ((CommandFactoryDescriptor)arg1).getName() ); - } - } ); - String[] descLabels = new String[fCommandFactoryDescriptors.length]; - String commandFactoryId = MIPlugin.getCommandFactory( configuration ); - int index = -1; - for( int i = 0; i < fCommandFactoryDescriptors.length; ++i ) { - descLabels[i] = fCommandFactoryDescriptors[i].getName(); - if ( fCommandFactoryDescriptors[i].getIdentifier().equals( commandFactoryId ) ) - index = i; - } - fCommandFactoryCombo.setItems( descLabels ); - if ( index < 0 ) { - index = 0; - } - - //It may be the case that we can't match up any identifier with any installed debuggers associated - //with this debuggerID (ie fCommandFactoryDescriptors.length == 0) for example when importing a - //launch from different environments that use CDT debugging. In this case we try and soldier on - //using the defaults as much as is realistic. - String[] miVersions = new String[0]; - if(index < fCommandFactoryDescriptors.length) { - fCommandFactoryCombo.select( index ); - miVersions = fCommandFactoryDescriptors[index].getMIVersions(); - } - fProtocolCombo.setItems( miVersions ); - if ( miVersions.length == 0 ) { - miVersions = new String[] { DEFAULT_MI_VERSION }; - } - String mi = DEFAULT_MI_VERSION; - try { - mi = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, DEFAULT_MI_VERSION ); - } - catch( CoreException e ) { - // use default - } - int miIndex = 0; - for ( int i = 0; i < miVersions.length; ++i ) { - if ( miVersions[i].equals( mi ) ) { - miIndex = i; - break; - } - } - fProtocolCombo.select( miIndex ); - boolean verboseMode = IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT; - try { - verboseMode = configuration.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, IMILaunchConfigurationConstants.DEBUGGER_VERBOSE_MODE_DEFAULT ); - } - catch( CoreException e ) { - // use default - } - fVerboseModeButton.setSelection( verboseMode ); - fBreakpointsFullPath.setSelection(getBreakpointsWithFullNameAttribute(configuration)); - // We've populated combos, which affects their preferred size, and so must relayout things. - Control changed[] = { fCommandFactoryCombo, fProtocolCombo }; - ((Composite) getControl()).layout( changed ); - - setInitializing( false ); - } - protected boolean getBreakpointsWithFullNameAttribute( ILaunchConfiguration config ) { - boolean result = IMILaunchConfigurationConstants.DEBUGGER_FULLPATH_BREAKPOINTS_DEFAULT; - try { - return config.getAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_FULLPATH_BREAKPOINTS, result ); - } - catch( CoreException e ) { - // use default - } - return result; - } - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - String str = fGDBCommandText.getText(); - str.trim(); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, str ); - str = fGDBInitText.getText(); - str.trim(); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_GDB_INIT, str ); - str = fCommandFactoryCombo.getText(); - int index = fCommandFactoryCombo.indexOf( str ); - str = ( index < 0 ) ? "" : fCommandFactoryDescriptors[index].getIdentifier(); //$NON-NLS-1$ - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_COMMAND_FACTORY, str ); - str = fProtocolCombo.getText(); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, str ); - if ( fSolibBlock != null ) - fSolibBlock.performApply( configuration ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_VERBOSE_MODE, fVerboseModeButton.getSelection() ); - configuration.setAttribute( IMILaunchConfigurationConstants.ATTR_DEBUGGER_FULLPATH_BREAKPOINTS, fBreakpointsFullPath.getSelection() ); - } - - @Override - public String getName() { - return MIUIMessages.getString( "StandardGDBDebuggerPage.1" ); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getShell() - */ - @Override - protected Shell getShell() { - return super.getShell(); - } - - /** - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() - */ - @Override - protected void updateLaunchConfigurationDialog() { - super.updateLaunchConfigurationDialog(); - } - - /* - * (non-Javadoc) - * - * @see java.util.Observer#update(java.util.Observable, java.lang.Object) - */ - @Override - public void update( Observable o, Object arg ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - public IMILaunchConfigurationComponent createSolibBlock( Composite parent ) { - IMILaunchConfigurationComponent block = MIUIUtils.createGDBSolibBlock( true, true ); - block.createControl( parent ); - return block; - } - - public void createTabs( TabFolder tabFolder ) { - createMainTab( tabFolder ); - createSolibTab( tabFolder ); - } - - public void createMainTab( TabFolder tabFolder ) { - TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); - tabItem.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.2" ) ); //$NON-NLS-1$ - Composite comp = ControlFactory.createCompositeEx( tabFolder, 1, GridData.FILL_BOTH ); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - comp.setFont( tabFolder.getFont() ); - tabItem.setControl( comp ); - Composite subComp = ControlFactory.createCompositeEx( comp, 3, GridData.FILL_HORIZONTAL ); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - subComp.setFont( tabFolder.getFont() ); - Label label = ControlFactory.createLabel( subComp, MIUIMessages.getString( "StandardGDBDebuggerPage.3" ) ); //$NON-NLS-1$ - GridData gd = new GridData(); -// gd.horizontalSpan = 2; - label.setLayoutData( gd ); - fGDBCommandText = ControlFactory.createTextField( subComp, SWT.SINGLE | SWT.BORDER ); - fGDBCommandText.addModifyListener( new ModifyListener() { - - @Override - public void modifyText( ModifyEvent evt ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - Button button = createPushButton( subComp, MIUIMessages.getString( "StandardGDBDebuggerPage.4" ), null ); //$NON-NLS-1$ - button.addSelectionListener( new SelectionAdapter() { - - @Override - public void widgetSelected( SelectionEvent evt ) { - handleGDBButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBButtonSelected() { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.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( "StandardGDBDebuggerPage.6" ) ); //$NON-NLS-1$ - gd = new GridData(); -// 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() { - - @Override - public void modifyText( ModifyEvent evt ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - button = createPushButton( subComp, MIUIMessages.getString( "StandardGDBDebuggerPage.7" ), null ); //$NON-NLS-1$ - button.addSelectionListener( new SelectionAdapter() { - - @Override - public void widgetSelected( SelectionEvent evt ) { - handleGDBInitButtonSelected(); - updateLaunchConfigurationDialog(); - } - - private void handleGDBInitButtonSelected() { - FileDialog dialog = new FileDialog( getShell(), SWT.NONE ); - dialog.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.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( subComp, MIUIMessages.getString( "StandardGDBDebuggerPage.9" ), //$NON-NLS-1$ - 200, SWT.DEFAULT, SWT.WRAP ); - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 3; - gd.widthHint = 200; - label.setLayoutData( gd ); - - Composite options = ControlFactory.createCompositeEx( subComp, 2, GridData.FILL_HORIZONTAL ); - gd = new GridData( GridData.FILL_HORIZONTAL ); - gd.horizontalSpan = 3; - options.setLayoutData( gd ); - createCommandFactoryCombo( options ); - createProtocolCombo( options ); - createVerboseModeButton( subComp ); - createBreakpointFullPathName(subComp); - // fit options into 3-grid one per line - GridData gd1 = new GridData(); - gd1.horizontalSpan = 3; - fVerboseModeButton.setLayoutData(gd1); - GridData gd2 = new GridData(); - gd2.horizontalSpan = 3; - fBreakpointsFullPath.setLayoutData(gd2); - } - - public void createSolibTab( TabFolder tabFolder ) { - TabItem tabItem = new TabItem( tabFolder, SWT.NONE ); - tabItem.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.10" ) ); //$NON-NLS-1$ - Composite comp = ControlFactory.createCompositeEx( fTabFolder, 1, GridData.FILL_BOTH ); - comp.setFont( tabFolder.getFont() ); - tabItem.setControl( comp ); - fSolibBlock = createSolibBlock( comp ); - if ( fSolibBlock instanceof Observable ) - ((Observable)fSolibBlock).addObserver( this ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() - */ - @Override - 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) - */ - @Override - public void activated( ILaunchConfigurationWorkingCopy workingCopy ) { - // Override the default behavior - } - - protected boolean isInitializing() { - return fIsInitializing; - } - - private void setInitializing( boolean isInitializing ) { - fIsInitializing = isInitializing; - } - - protected void createCommandFactoryCombo( Composite parent ) { - Label label = new Label( parent, SWT.NONE ); - label.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.12" ) ); //$NON-NLS-1$ - fCommandFactoryCombo = new Combo( parent, SWT.READ_ONLY | SWT.DROP_DOWN ); - fCommandFactoryCombo.addSelectionListener( new SelectionListener() { - - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } - - protected void createProtocolCombo( Composite parent ) { - Label label = new Label( parent, SWT.NONE ); - label.setText( MIUIMessages.getString( "StandardGDBDebuggerPage.11" ) ); //$NON-NLS-1$ - fProtocolCombo = new Combo( parent, SWT.READ_ONLY | SWT.DROP_DOWN ); - fProtocolCombo.addSelectionListener( new SelectionListener() { - - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } - - protected String getCurrentCommandFactoryID() { - String name = fCommandFactoryCombo.getText(); - for ( int i = 0; i < fCommandFactoryDescriptors.length; ++i ) { - if ( fCommandFactoryDescriptors[i].getName().equals( name ) ) { - return fCommandFactoryDescriptors[i].getIdentifier(); - } - } - return ""; //$NON-NLS-1$ - } - - protected void createVerboseModeButton( Composite parent ) { - fVerboseModeButton = createCheckButton( parent, MIUIMessages.getString( "StandardGDBDebuggerPage.13" ) ); //$NON-NLS-1$ - fVerboseModeButton.addSelectionListener( new SelectionListener() { - - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } - protected void createBreakpointFullPathName( Composite parent ) { - fBreakpointsFullPath = createCheckButton( parent, MIUIMessages.getString( "StandardGDBDebuggerPage.14" ) ); //$NON-NLS-1$ - - fBreakpointsFullPath.addSelectionListener( new SelectionListener() { - - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - - @Override - public void widgetSelected( SelectionEvent e ) { - if ( !isInitializing() ) - updateLaunchConfigurationDialog(); - } - } ); - } -} 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 deleted file mode 100644 index 8f664a1fa5d..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/TCPSettingsBlock.java +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.debug.mi.internal.ui; - -import java.util.Observable; - -import org.eclipse.cdt.debug.mi.core.IGDBServerMILaunchConfigurationConstants; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IDialogFieldListener; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.LayoutUtil; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.StringDialogField; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -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() { - super(); - fHostNameField = createHostNameField(); - fPortNumberField = createPortNumberField(); - } - - public void createBlock( Composite parent ) { - fShell = parent.getShell(); - Composite comp = ControlFactory.createCompositeEx( parent, 2, GridData.FILL_BOTH ); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)comp.getLayout()).marginHeight = 0; - ((GridLayout)comp.getLayout()).marginWidth = 0; - comp.setFont( parent.getFont() ); - PixelConverter converter = new PixelConverter( comp ); - fHostNameField.doFillIntoGrid( comp, 2 ); - LayoutUtil.setWidthHint( fHostNameField.getTextControl( null ), converter.convertWidthInCharsToPixels( 20 ) ); - fPortNumberField.doFillIntoGrid( comp, 2 ); - ((GridData)fPortNumberField.getTextControl( null ).getLayoutData()).horizontalAlignment = GridData.BEGINNING; - LayoutUtil.setWidthHint( fPortNumberField.getTextControl( null ), converter.convertWidthInCharsToPixels( 10 ) ); - setControl( comp ); - } - - protected Shell getShell() { - return fShell; - } - - public void dispose() { - deleteObservers(); - } - - public void initializeFrom( ILaunchConfiguration configuration ) { - initializeHostName( configuration ); - initializePortNumber( configuration ); - } - - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME ); - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER ); - } - - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - if ( fHostNameField != null ) - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, fHostNameField.getText().trim() ); - if ( fPortNumberField != null ) - configuration.setAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, fPortNumberField.getText().trim() ); - } - - private StringDialogField createHostNameField() { - StringDialogField field = new StringDialogField(); - field.setLabelText( MIUIMessages.getString( "TCPSettingsBlock.0" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( new IDialogFieldListener() { - - @Override - public void dialogFieldChanged( DialogField f ) { - hostNameFieldChanged(); - } - } ); - return field; - } - - private StringDialogField createPortNumberField() { - StringDialogField field = new StringDialogField(); - field.setLabelText( MIUIMessages.getString( "TCPSettingsBlock.1" ) ); //$NON-NLS-1$ - field.setDialogFieldListener( new IDialogFieldListener() { - - @Override - public void dialogFieldChanged( DialogField f ) { - portNumberFieldChanged(); - } - } ); - return field; - } - - protected void hostNameFieldChanged() { - updateErrorMessage(); - setChanged(); - notifyObservers(); - } - - protected void portNumberFieldChanged() { - updateErrorMessage(); - setChanged(); - notifyObservers(); - } - - private void initializeHostName( ILaunchConfiguration configuration ) { - if ( fHostNameField != null ) { - try { - fHostNameField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME ) ); - } - catch( CoreException e ) { - } - } - } - - private void initializePortNumber( ILaunchConfiguration configuration ) { - if ( fPortNumberField != null ) { - try { - fPortNumberField.setText( configuration.getAttribute( IGDBServerMILaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER ) ); - } - catch( CoreException e ) { - } - } - } - - public Control getControl() { - return fControl; - } - - protected void setControl( Control control ) { - fControl = control; - } - - public boolean isValid( ILaunchConfiguration configuration ) { - updateErrorMessage(); - return (getErrorMessage() == null); - } - - private void updateErrorMessage() { - setErrorMessage( null ); - if ( fHostNameField != null && fPortNumberField != null ) { - if ( fHostNameField.getText().trim().length() == 0 ) - setErrorMessage( MIUIMessages.getString( "TCPSettingsBlock.2" ) ); //$NON-NLS-1$ - else if ( !hostNameIsValid( fHostNameField.getText().trim() ) ) - setErrorMessage( MIUIMessages.getString( "TCPSettingsBlock.3" ) ); //$NON-NLS-1$ - else if ( fPortNumberField.getText().trim().length() == 0 ) - setErrorMessage( MIUIMessages.getString( "TCPSettingsBlock.4" ) ); //$NON-NLS-1$ - else if ( !portNumberIsValid( fPortNumberField.getText().trim() ) ) - setErrorMessage( MIUIMessages.getString( "TCPSettingsBlock.5" ) ); //$NON-NLS-1$ - } - } - - public String getErrorMessage() { - return fErrorMessage; - } - - private void setErrorMessage( String string ) { - fErrorMessage = string; - } - - private boolean hostNameIsValid( String hostName ) { - return true; - } - - private boolean portNumberIsValid( String portNumber ) { - try { - int port = Integer.parseInt( portNumber ); - return ( port > 0 && port <= 0xFFFF ); - } - catch( NumberFormatException e ) { - return false; - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.java deleted file mode 100644 index 88b4e5ba22b..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.actions; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class ActionMessages { - - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.mi.internal.ui.actions.ActionMessages";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private ActionMessages() { - } - - public static String getString( String key ) { - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.properties deleted file mode 100644 index 5dd0f84d4fe..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/ActionMessages.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2006 QNX Software Systems and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# QNX Software Systems - initial API and implementation -############################################################################### - -SetAutoSolibActionDelegate.0=Exceptions occurred attempting to set 'Automatically Load Symbols' mode. -SetAutoSolibActionDelegate.1=Set 'Automatically Load Symbols' mode failed. 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 deleted file mode 100644 index edb3e38cbdd..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/SetAutoSolibActionDelegate.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.actions; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.MIPlugin; -import org.eclipse.cdt.debug.mi.core.cdi.Session; -import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; -import org.eclipse.cdt.debug.mi.core.cdi.model.Target; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * The delegate for the "Automatically Load Symbols" action. - */ -public class SetAutoSolibActionDelegate implements IViewActionDelegate, ISelectionListener, IPartListener { - - private IViewPart fView = null; - - private IAction fAction; - - private IStatus fStatus = null; - - /** - * Constructor for SetAutoSolibActionDelegate. - */ - public SetAutoSolibActionDelegate() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) - */ - @Override - public void init( IViewPart view ) { - fView = view; - view.getSite().getPage().addPartListener( this ); - view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) - */ - @Override - public void selectionChanged( IWorkbenchPart part, ISelection selection ) { - if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) { - update( getAction() ); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(IAction) - */ - @Override - public void run( IAction action ) { - BusyIndicator.showWhile( Display.getCurrent(), new Runnable() { - - @Override - 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 { - CDebugUIPlugin.log( getStatus() ); - } - } - update( action ); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) - */ - @Override - public void selectionChanged( IAction action, ISelection selection ) { - setAction( action ); - if ( getView() != null ) { - update( action ); - } - } - - protected void update( IAction action ) { - if ( action != null ) { - IAdaptable element = DebugUITools.getDebugContext(); - action.setEnabled( getEnableStateForSelection( element ) ); - action.setChecked( getCheckStateForSelection( element ) ); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) - */ - @Override - public void partActivated( IWorkbenchPart part ) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) - */ - @Override - public void partBroughtToTop( IWorkbenchPart part ) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) - */ - @Override - public void partClosed( IWorkbenchPart part ) { - if ( part.equals( getView() ) ) { - dispose(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) - */ - @Override - public void partDeactivated( IWorkbenchPart part ) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) - */ - @Override - public void partOpened( IWorkbenchPart part ) { - } - - protected IViewPart getView() { - return fView; - } - - protected void setView( IViewPart viewPart ) { - fView = viewPart; - } - - protected void setAction( IAction action ) { - fAction = action; - } - - protected IAction getAction() { - return fAction; - } - - 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 ) { - SharedLibraryManager slm = getSharedLibraryManager( element ); - Target target = getTarget(element); - if ( slm != null && target != null) { - try { - return slm.isAutoLoadSymbols(target); - } catch( CDIException e ) { - } - } - return false; - } - - protected boolean getEnableStateForSelection( IAdaptable element ) { - return (element instanceof IDebugElement && ((IDebugElement)element).getDebugTarget().isSuspended() && getSharedLibraryManager( element ) != null); - } - - protected String getStatusMessage() { - return ActionMessages.getString( "SetAutoSolibActionDelegate.0" ); //$NON-NLS-1$ - } - - protected String getErrorDialogMessage() { - return ActionMessages.getString( "SetAutoSolibActionDelegate.1" ); //$NON-NLS-1$ - } - - protected void setStatus( IStatus status ) { - fStatus = status; - } - - protected IStatus getStatus() { - return fStatus; - } - - protected void doAction( IAdaptable element ) throws DebugException { - if ( getView() == null ) - return; - SharedLibraryManager slm = getSharedLibraryManager( element ); - Target target = getTarget(element); - if ( slm != null && target != null && getAction() != null ) { - try { - slm.setAutoLoadSymbols( target, getAction().isChecked() ); - } - catch( CDIException e ) { - getAction().setChecked( !getAction().isChecked() ); - throw new DebugException( new Status( IStatus.ERROR, MIPlugin.getUniqueIdentifier(), DebugException.TARGET_REQUEST_FAILED, e.getMessage(), null ) ); - } - } - } - - private SharedLibraryManager getSharedLibraryManager( IAdaptable element ) { - if ( element != null ) { - ICDISession session = element.getAdapter( ICDISession.class ); - if ( session instanceof Session ) - return ((Session)session).getSharedLibraryManager(); - } - return null; - } - - private Target getTarget( IAdaptable element ) { - if (element != null) { - ICDITarget target = element.getAdapter( ICDITarget.class ); - if (target instanceof Target) { - return (Target)target; - } - } - return null; - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/VerboseModeActionDelegate.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/VerboseModeActionDelegate.java deleted file mode 100644 index c625d6157e8..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/actions/VerboseModeActionDelegate.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.actions; - -import org.eclipse.cdt.debug.mi.core.GDBProcess; -import org.eclipse.cdt.debug.mi.ui.console.VerboseModeChangedEvent; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.actions.ActionDelegate; - -public class VerboseModeActionDelegate extends ActionDelegate implements IObjectActionDelegate { - - private GDBProcess fProcess; - - /* (non-Javadoc) - * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) - */ - @Override - public void setActivePart( IAction action, IWorkbenchPart targetPart ) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction) - */ - @Override - public void run( IAction action ) { - if ( fProcess != null ) { - boolean enabled = fProcess.getTarget().isVerboseModeEnabled(); - fProcess.getTarget().enableVerboseMode( !enabled ); - fProcess.getTarget().getMISession().notifyObservers(new VerboseModeChangedEvent(fProcess.getTarget().getMISession(),0)); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged( IAction action, ISelection selection ) { - IStructuredSelection s = (IStructuredSelection)selection; - fProcess = ( !s.isEmpty() ) ? (GDBProcess)s.getFirstElement() : null; - action.setEnabled( fProcess != null && !fProcess.isTerminated()); - action.setChecked( fProcess != null && fProcess.getTarget().isVerboseModeEnabled() ); - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/CheckedListDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/CheckedListDialogField.java deleted file mode 100644 index a618c15d9dc..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/CheckedListDialogField.java +++ /dev/null @@ -1,228 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Table; - -/** - * A list with checkboxes and a button bar. Typical buttons are 'Check All' and 'Uncheck All'. - * List model is independend of widget creation. - * DialogFields controls are: Label, List and Composite containing buttons. - */ -public class CheckedListDialogField extends ListDialogField { - - private int fCheckAllButtonIndex; - private int fUncheckAllButtonIndex; - - private List fCheckElements; - - public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, ILabelProvider lprovider) { - super(adapter, customButtonLabels, lprovider); - fCheckElements= new ArrayList(); - - fCheckAllButtonIndex= -1; - fUncheckAllButtonIndex= -1; - } - - /** - * Sets the index of the 'check' button in the button label array passed in the constructor. - * The behaviour of the button marked as the check button will then be handled internally. - * (enable state, button invocation behaviour) - */ - public void setCheckAllButtonIndex(int checkButtonIndex) { - Assert.isTrue(checkButtonIndex < fButtonLabels.length); - fCheckAllButtonIndex= checkButtonIndex; - } - - /** - * Sets the index of the 'uncheck' button in the button label array passed in the constructor. - * The behaviour of the button marked as the uncheck button will then be handled internally. - * (enable state, button invocation behaviour) - */ - public void setUncheckAllButtonIndex(int uncheckButtonIndex) { - Assert.isTrue(uncheckButtonIndex < fButtonLabels.length); - fUncheckAllButtonIndex= uncheckButtonIndex; - } - - - /* - * @see ListDialogField#createTableViewer - */ - @Override - protected TableViewer createTableViewer(Composite parent) { - Table table= new Table(parent, SWT.CHECK + getListStyle()); - CheckboxTableViewer tableViewer= new CheckboxTableViewer(table); - tableViewer.addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent e) { - doCheckStateChanged(e); - } - }); - return tableViewer; - } - - - /* - * @see ListDialogField#getListControl - */ - @Override - public Control getListControl(Composite parent) { - Control control= super.getListControl(parent); - if (parent != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray()); - } - return control; - } - - /* - * @see DialogField#dialogFieldChanged - * Hooks in to get element changes to update check model. - */ - @Override - public void dialogFieldChanged() { - for (int i= fCheckElements.size() -1; i >= 0; i--) { - if (!fElements.contains(fCheckElements.get(i))) { - fCheckElements.remove(i); - } - } - super.dialogFieldChanged(); - } - - private void checkStateChanged() { - //call super and do not update check model - super.dialogFieldChanged(); - } - - /** - * Gets the checked elements. - */ - public List getCheckedElements() { - return new ArrayList(fCheckElements); - } - - /** - * Returns true if the element is checked. - */ - public boolean isChecked(Object obj) { - return fCheckElements.contains(obj); - } - - /** - * Sets the checked elements. - */ - public void setCheckedElements(List list) { - fCheckElements= new ArrayList(list); - if (fTable != null) { - ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray()); - } - checkStateChanged(); - } - - /** - * Sets the checked state of an element. - */ - public void setChecked(Object object, boolean state) { - setCheckedWithoutUpdate(object, state); - checkStateChanged(); - } - - /** - * Sets the checked state of an element. no dialog changed listener informed - */ - public void setCheckedWithoutUpdate(Object object, boolean state) { - if (state) { - if (!fCheckElements.contains(object)) { - fCheckElements.add(object); - } - } - else { - if (fCheckElements.contains(object)) { - fCheckElements.remove(object); - } - } - if (fTable != null) { - ((CheckboxTableViewer)fTable).setChecked(object, state); - } - } - - /** - * Sets the check state of all elements - */ - public void checkAll(boolean state) { - if (state) { - fCheckElements= getElements(); - } else { - fCheckElements.clear(); - } - if (fTable != null) { - ((CheckboxTableViewer)fTable).setAllChecked(state); - } - checkStateChanged(); - } - - - protected void doCheckStateChanged(CheckStateChangedEvent e) { - if (e.getChecked()) { - fCheckElements.add(e.getElement()); - } else { - fCheckElements.remove(e.getElement()); - } - checkStateChanged(); - } - - // ------ enable / disable management - - /* - * @see ListDialogField#getManagedButtonState - */ - @Override - protected boolean getManagedButtonState(ISelection sel, int index) { - if (index == fCheckAllButtonIndex) { - return !fElements.isEmpty(); - } else if (index == fUncheckAllButtonIndex) { - return !fElements.isEmpty(); - } - return super.getManagedButtonState(sel, index); - } - - /* - * @see ListDialogField#extraButtonPressed - */ - @Override - protected boolean managedButtonPressed(int index) { - if (index == fCheckAllButtonIndex) { - checkAll(true); - } else if (index == fUncheckAllButtonIndex) { - checkAll(false); - } else { - return super.managedButtonPressed(index); - } - 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/dialogfields/ComboDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/ComboDialogField.java deleted file mode 100644 index 3fe817d9405..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/ComboDialogField.java +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; - -/** - * Dialog field containing a label and a combo control. - */ -public class ComboDialogField extends DialogField { - - private String fText; - private int fSelectionIndex; - private String[] fItems; - private Combo fComboControl; - private ModifyListener fModifyListener; - private int fFlags; - - public ComboDialogField(int flags) { - super(); - fText= ""; //$NON-NLS-1$ - fItems= new String[0]; - fFlags= flags; - fSelectionIndex= -1; - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(1)); - Combo combo= getComboControl(parent); - combo.setLayoutData(gridDataForCombo(nColumns - 1)); - - return new Control[] { label, combo }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 2; - } - - protected static GridData gridDataForCombo(int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; - return gd; - } - - // ------- focus methods - - /* - * @see DialogField#setFocus - */ - @Override - public boolean setFocus() { - if (isOkToUse(fComboControl)) { - fComboControl.setFocus(); - } - return true; - } - - // ------- ui creation - - /** - * Creates or returns the created combo control. - * @param parent The parent composite or <code>null</code> when the widget has - * already been created. - */ - public Combo getComboControl(Composite parent) { - if (fComboControl == null) { - assertCompositeNotNull(parent); - fModifyListener= new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - doModifyText(e); - } - }; - SelectionListener selectionListener= new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - doSelectionChanged(e); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }; - - fComboControl= new Combo(parent, fFlags); - // moved up due to 1GEUNW2 - fComboControl.setItems(fItems); - if (fSelectionIndex != -1) { - fComboControl.select(fSelectionIndex); - } else { - fComboControl.setText(fText); - } - fComboControl.setFont(parent.getFont()); - fComboControl.addModifyListener(fModifyListener); - fComboControl.addSelectionListener(selectionListener); - fComboControl.setEnabled(isEnabled()); - } - return fComboControl; - } - - protected void doModifyText(ModifyEvent e) { - if (isOkToUse(fComboControl)) { - fText= fComboControl.getText(); - fSelectionIndex= fComboControl.getSelectionIndex(); - } - dialogFieldChanged(); - } - - protected void doSelectionChanged(SelectionEvent e) { - if (isOkToUse(fComboControl)) { - fItems= fComboControl.getItems(); - fText= fComboControl.getText(); - fSelectionIndex= fComboControl.getSelectionIndex(); - } - dialogFieldChanged(); - } - - // ------ enable / disable management - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (isOkToUse(fComboControl)) { - fComboControl.setEnabled(isEnabled()); - } - } - - // ------ text access - - /** - * Gets the combo items. - */ - public String[] getItems() { - return fItems; - } - - /** - * Sets the combo items. Triggers a dialog-changed event. - */ - public void setItems(String[] items) { - fItems= items; - if (isOkToUse(fComboControl)) { - fComboControl.setItems(items); - } - dialogFieldChanged(); - } - - /** - * Gets the text. - */ - public String getText() { - return fText; - } - - /** - * Sets the text. Triggers a dialog-changed event. - */ - public void setText(String text) { - fText= text; - if (isOkToUse(fComboControl)) { - fComboControl.setText(text); - } else { - dialogFieldChanged(); - } - } - - /** - * Selects an item. - */ - public void selectItem(int index) { - if (isOkToUse(fComboControl)) { - fComboControl.select(index); - fSelectionIndex= index; - } else { - if (index >= 0 && index < fItems.length) { - fText= fItems[index]; - fSelectionIndex= index; - } - } - dialogFieldChanged(); - } - - public int getSelectionIndex() { - return fSelectionIndex; - } - - - /** - * Sets the text without triggering a dialog-changed event. - */ - public void setTextWithoutUpdate(String text) { - fText= text; - if (isOkToUse(fComboControl)) { - fComboControl.removeModifyListener(fModifyListener); - fComboControl.setText(text); - fComboControl.addModifyListener(fModifyListener); - } - } - - public void dispose() { - if (fComboControl != null) fComboControl.dispose(); - if (fItems != null) fItems = null; - if (fModifyListener != null) fModifyListener = null; - super.dispose(); - } - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/DialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/DialogField.java deleted file mode 100644 index 9d5f4ca51ad..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/DialogField.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2014 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; - -/** - * Base class of all dialog fields. - * Dialog fields manage controls together with the model, independed - * from the creation time of the widgets. - * - support for automated layouting. - * - enable / disable, set focus a concept of the base class. - * - * DialogField have a label. - */ -public class DialogField { - - private Label fLabel; - protected String fLabelText; - - private IDialogFieldListener fDialogFieldListener; - - private boolean fEnabled; - - public DialogField() { - fEnabled= true; - fLabel= null; - fLabelText= ""; //$NON-NLS-1$ - } - - /** - * Sets the label of the dialog field. - */ - public void setLabelText(String labeltext) { - fLabelText= labeltext; - } - - // ------ change listener - - /** - * Defines the listener for this dialog field. - */ - public final void setDialogFieldListener(IDialogFieldListener listener) { - fDialogFieldListener= listener; - } - - /** - * Programatical invocation of a dialog field change. - */ - public void dialogFieldChanged() { - if (fDialogFieldListener != null) { - fDialogFieldListener.dialogFieldChanged(this); - } - } - - // ------- focus management - - /** - * Tries to set the focus to the dialog field. - * Returns <code>true</code> if the dialog field can take focus. - * To be reimplemented by dialog field implementors. - */ - public boolean setFocus() { - return false; - } - - /** - * Posts <code>setFocus</code> to the display event queue. - */ - public void postSetFocusOnDialogField(Display display) { - if (display != null) { - display.asyncExec( - new Runnable() { - @Override - public void run() { - setFocus(); - } - } - ); - } - } - - // ------- layout helpers - - /** - * Creates all controls of the dialog field and fills it to a composite. - * The composite is assumed to have <code>MGridLayout</code> as - * layout. - * The dialog field will adjust its controls' spans to the number of columns given. - * To be reimplemented by dialog field implementors. - */ - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(nColumns)); - - return new Control[] { label }; - } - - /** - * Returns the number of columns of the dialog field. - * To be reimplemented by dialog field implementors. - */ - public int getNumberOfControls() { - return 1; - } - - protected static GridData gridDataForLabel(int span) { - GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.horizontalSpan= span; - return gd; - } - - // ------- ui creation - - /** - * Creates or returns the created label widget. - * @param parent The parent composite or <code>null</code> if the widget has - * already been created. - */ - public Label getLabelControl(Composite parent) { - if (fLabel == null) { - assertCompositeNotNull(parent); - - fLabel= new Label(parent, SWT.LEFT | SWT.WRAP); - fLabel.setFont(parent.getFont()); - fLabel.setEnabled(fEnabled); - if (fLabelText != null && !"".equals(fLabelText)) { //$NON-NLS-1$ - fLabel.setText(fLabelText); - } else { - // XXX: to avoid a 16 pixel wide empty label - revisit - fLabel.setText("."); //$NON-NLS-1$ - fLabel.setVisible(false); - } - } - return fLabel; - } - - /** - * Creates a spacer control. - * - * @param parent The parent composite - */ - public static Control createEmptySpace(Composite parent) { - return createEmptySpace(parent, 1); - } - - /** - * Creates a spacer control with the given span. - * The composite is assumed to have {@link GridLayout} as layout. - * - * @param parent The parent composite - */ - public static Control createEmptySpace(Composite parent, int span) { - Label label= new Label(parent, SWT.LEFT); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; - gd.horizontalIndent= 0; - gd.widthHint= 0; - gd.heightHint= 0; - label.setLayoutData(gd); - return label; - } - - /** - * Tests is the control is not <code>null</code> and not disposed. - */ - protected final boolean isOkToUse(Control control) { - return (control != null) && !(control.isDisposed()); - } - - // --------- enable / disable management - - /** - * Sets the enable state of the dialog field. - */ - public final void setEnabled(boolean enabled) { - if (enabled != fEnabled) { - fEnabled= enabled; - updateEnableState(); - } - } - - /** - * Called when the enable state changed. - * To be extended by dialog field implementors. - */ - protected void updateEnableState() { - if (fLabel != null) { - fLabel.setEnabled(fEnabled); - } - } - - /** - * Gets the enable state of the dialog field. - */ - public final boolean isEnabled() { - return fEnabled; - } - - protected final void assertCompositeNotNull(Composite comp) { - Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$ - } - - protected final void assertEnoughColumns(int nColumns) { - Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$ - } - - public void dispose() { - if (fLabel != null) fLabel.dispose(); - if (fDialogFieldListener != null) fDialogFieldListener = 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/dialogfields/IDialogFieldListener.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IDialogFieldListener.java deleted file mode 100644 index f170d4ca469..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IDialogFieldListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -/** - * Change listener used by <code>DialogField</code> - */ -public interface IDialogFieldListener { - - /** - * The dialog field has changed. - */ - void dialogFieldChanged(DialogField field); - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IListAdapter.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IListAdapter.java deleted file mode 100644 index 7f7a841a6fc..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IListAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -/** - * Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code> - */ -public interface IListAdapter { - - /** - * A button from the button bar has been pressed. - */ - void customButtonPressed(DialogField field, int index); - - /** - * The selection of the list has changed. - */ - void selectionChanged(DialogField field); - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IStringButtonAdapter.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IStringButtonAdapter.java deleted file mode 100644 index b65936e45d9..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/IStringButtonAdapter.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -/** - * Change listener used by <code>StringButtonDialogField</code> - */ -public interface IStringButtonAdapter { - - void changeControlPressed(DialogField field); - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/LayoutUtil.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/LayoutUtil.java deleted file mode 100644 index 155b57d79b2..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/LayoutUtil.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -public class LayoutUtil { - - /** - * Calculates the number of columns needed by field editors - */ - public static int getNumberOfColumns(DialogField[] editors) { - int nCulumns= 0; - for (int i= 0; i < editors.length; i++) { - nCulumns= Math.max(editors[i].getNumberOfControls(), nCulumns); - } - return nCulumns; - } - - /** - * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) { - doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0); - } - - /** - * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - * @param minWidth The minimal width of the composite - * @param minHeight The minimal height of the composite - */ - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight) { - doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0); - } - - /** - * Creates a composite and fills in the given editors. - * @param labelOnTop Defines if the label of all fields should be on top of the fields - * @param minWidth The minimal width of the composite - * @param minHeight The minimal height of the composite - * @param marginWidth The margin width to be used by the composite - * @param marginHeight The margin height to be used by the composite - * @deprecated - */ - @Deprecated - public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop, int minWidth, int minHeight, int marginWidth, int marginHeight) { - int nCulumns= getNumberOfColumns(editors); - Control[][] controls= new Control[editors.length][]; - for (int i= 0; i < editors.length; i++) { - controls[i]= editors[i].doFillIntoGrid(parent, nCulumns); - } - if (labelOnTop) { - nCulumns--; - modifyLabelSpans(controls, nCulumns); - } - GridLayout layout= new GridLayout(); - if (marginWidth != SWT.DEFAULT) { - layout.marginWidth= marginWidth; - } - if (marginHeight != SWT.DEFAULT) { - layout.marginHeight= marginHeight; - } - layout.numColumns= nCulumns; - parent.setLayout(layout); - } - - private static void modifyLabelSpans(Control[][] controls, int nCulumns) { - for (int i= 0; i < controls.length; i++) { - setHorizontalSpan(controls[i][0], nCulumns); - } - } - - /** - * Sets the span of a control. Assumes that GridData is used. - */ - public static void setHorizontalSpan(Control control, int span) { - Object ld= control.getLayoutData(); - if (ld instanceof GridData) { - ((GridData)ld).horizontalSpan= span; - } else if (span != 1) { - GridData gd= new GridData(); - gd.horizontalSpan= span; - control.setLayoutData(gd); - } - } - - /** - * Sets the width hint of a control. Assumes that GridData is used. - */ - public static void setWidthHint(Control control, int widthHint) { - Object ld= control.getLayoutData(); - if (ld instanceof GridData) { - ((GridData)ld).widthHint= widthHint; - } - } - - /** - * Sets the heigthHint hint of a control. Assumes that GridData is used. - */ - public static void setHeigthHint(Control control, int heigthHint) { - Object ld= control.getLayoutData(); - if (ld instanceof GridData) { - ((GridData)ld).heightHint= heigthHint; - } - } - - /** - * Sets the horizontal indent of a control. Assumes that GridData is used. - */ - public static void setHorizontalIndent(Control control, int horizontalIndent) { - Object ld= control.getLayoutData(); - if (ld instanceof GridData) { - ((GridData)ld).horizontalIndent= horizontalIndent; - } - } - - /** - * Sets the horizontal indent of a control. Assumes that GridData is used. - */ - public static void setHorizontalGrabbing(Control control) { - Object ld= control.getLayoutData(); - if (ld instanceof GridData) { - ((GridData)ld).grabExcessHorizontalSpace= 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/dialogfields/ListDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/ListDialogField.java deleted file mode 100644 index e1d8dc168b9..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/ListDialogField.java +++ /dev/null @@ -1,783 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.cdt.debug.mi.internal.ui.SWTUtil; -import org.eclipse.jface.layout.PixelConverter; -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; - -/** - * A list with a button bar. - * Typical buttons are 'Add', 'Remove', 'Up' and 'Down'. - * List model is independend of widget creation. - * DialogFields controls are: Label, List and Composite containing buttons. - */ -public class ListDialogField extends DialogField { - - protected TableViewer fTable; - protected ILabelProvider fLabelProvider; - protected ListViewerAdapter fListViewerAdapter; - protected List fElements; - protected ViewerSorter fViewerSorter; - - protected String[] fButtonLabels; - private Button[] fButtonControls; - - private boolean[] fButtonsEnabled; - - private int fRemoveButtonIndex; - private int fUpButtonIndex; - private int fDownButtonIndex; - - private Label fLastSeparator; - - protected Table fTableControl; - private Composite fButtonsControl; - private ISelection fSelectionWhenEnabled; - - private IListAdapter fListAdapter; - - private Object fParentElement; - - /** - * Creates the <code>ListDialogField</code>. - * @param adapter A listener for button invocation, selection changes. - * @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and - * marks a separator. - * @param lprovider The label provider to render the table entries - */ - public ListDialogField(IListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider) { - super(); - fListAdapter= adapter; - - fLabelProvider= lprovider; - fListViewerAdapter= new ListViewerAdapter(); - fParentElement= this; - - fElements= new ArrayList(10); - - fButtonLabels= buttonLabels; - if (fButtonLabels != null) { - int nButtons= fButtonLabels.length; - fButtonsEnabled= new boolean[nButtons]; - for (int i= 0; i < nButtons; i++) { - fButtonsEnabled[i]= true; - } - } - - fTable= null; - fTableControl= null; - fButtonsControl= null; - - fRemoveButtonIndex= -1; - fUpButtonIndex= -1; - fDownButtonIndex= -1; - } - - /** - * Sets the index of the 'remove' button in the button label array passed in the constructor. - * The behaviour of the button marked as the 'remove' button will then be handled internally. - * (enable state, button invocation behaviour) - */ - public void setRemoveButtonIndex(int removeButtonIndex) { - Assert.isTrue(removeButtonIndex < fButtonLabels.length); - fRemoveButtonIndex= removeButtonIndex; - } - - /** - * Sets the index of the 'up' button in the button label array passed in the constructor. - * The behaviour of the button marked as the 'up' button will then be handled internally. - * (enable state, button invocation behaviour) - */ - public void setUpButtonIndex(int upButtonIndex) { - Assert.isTrue(upButtonIndex < fButtonLabels.length); - fUpButtonIndex= upButtonIndex; - } - - /** - * Sets the index of the 'down' button in the button label array passed in the constructor. - * The behaviour of the button marked as the 'down' button will then be handled internally. - * (enable state, button invocation behaviour) - */ - public void setDownButtonIndex(int downButtonIndex) { - Assert.isTrue(downButtonIndex < fButtonLabels.length); - fDownButtonIndex= downButtonIndex; - } - - /** - * Sets the viewerSorter. - * @param viewerSorter The viewerSorter to set - */ - public void setViewerSorter(ViewerSorter viewerSorter) { - fViewerSorter= viewerSorter; - } - - // ------ adapter communication - - private void buttonPressed(int index) { - if (!managedButtonPressed(index)) { - fListAdapter.customButtonPressed(this, index); - } - } - - /** - * Checks if the button pressed is handled internally - * @return Returns true if button has been handled. - */ - protected boolean managedButtonPressed(int index) { - if (index == fRemoveButtonIndex) { - remove(); - } else if (index == fUpButtonIndex) { - up(); - } else if (index == fDownButtonIndex) { - down(); - } else { - return false; - } - return true; - } - - - // ------ layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - PixelConverter converter= new PixelConverter(parent); - - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - GridData gd= gridDataForLabel(1); - gd.verticalAlignment= GridData.BEGINNING; - label.setLayoutData(gd); - - Control list= getListControl(parent); - gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.verticalAlignment= GridData.FILL; - gd.grabExcessVerticalSpace= true; - gd.horizontalSpan= nColumns - 2; - gd.widthHint= converter.convertWidthInCharsToPixels(50); - gd.heightHint= converter.convertHeightInCharsToPixels(6); - - list.setLayoutData(gd); - - Composite buttons= getButtonBox(parent); - gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.verticalAlignment= GridData.FILL; - gd.grabExcessVerticalSpace= true; - gd.horizontalSpan= 1; - buttons.setLayoutData(gd); - - return new Control[] { label, list, buttons }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 3; - } - - /** - * Sets the minimal width of the buttons. Must be called after widget creation. - */ - public void setButtonsMinWidth(int minWidth) { - if (fLastSeparator != null) { - ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth; - } - } - - - // ------ ui creation - - /** - * Returns the list control. When called the first time, the control will be created. - * @param The parent composite when called the first time, or <code>null</code> - * after. - */ - public Control getListControl(Composite parent) { - if (fTableControl == null) { - assertCompositeNotNull(parent); - - fTable= createTableViewer(parent); - fTable.setContentProvider(fListViewerAdapter); - fTable.setLabelProvider(fLabelProvider); - fTable.addSelectionChangedListener(fListViewerAdapter); - - fTableControl= (Table)fTable.getControl(); - - fTable.setInput(fParentElement); - - if (fViewerSorter != null) { - fTable.setSorter(fViewerSorter); - } - - fTableControl.setEnabled(isEnabled()); - if (fSelectionWhenEnabled != null) { - postSetSelection(fSelectionWhenEnabled); - } - } - return fTableControl; - } - - /** - * Returns the internally used table viewer. - */ - public TableViewer getTableViewer() { - return fTable; - } - - /* - * Subclasses may override to specify a different style. - */ - protected int getListStyle(){ - return SWT.BORDER + SWT.MULTI + SWT.H_SCROLL + SWT.V_SCROLL; - } - - protected TableViewer createTableViewer(Composite parent) { - Table table= new Table(parent, getListStyle()); - return new TableViewer(table); - } - - protected Button createButton(Composite parent, String label, SelectionListener listener) { - Button button= new Button(parent, SWT.PUSH); - button.setText(label); - button.addSelectionListener(listener); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= true; - gd.verticalAlignment= GridData.BEGINNING; - gd.widthHint = SWTUtil.getButtonWidthHint(button); - - button.setLayoutData(gd); - return button; - } - - private Label createSeparator(Composite parent) { - Label separator= new Label(parent, SWT.NONE); - separator.setVisible(false); - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.verticalAlignment= GridData.BEGINNING; - gd.heightHint= 4; - separator.setLayoutData(gd); - return separator; - } - - /** - * Returns the composite containing the buttons. When called the first time, the control - * will be created. - * @param The parent composite when called the first time, or <code>null</code> - * after. - */ - public Composite getButtonBox(Composite parent) { - if (fButtonsControl == null) { - assertCompositeNotNull(parent); - - SelectionListener listener= new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - doButtonSelected(e); - } - @Override - public void widgetSelected(SelectionEvent e) { - doButtonSelected(e); - } - }; - - Composite contents= new Composite(parent, SWT.NULL); - GridLayout layout= new GridLayout(); - layout.marginWidth= 0; - layout.marginHeight= 0; - contents.setLayout(layout); - - if (fButtonLabels != null) { - fButtonControls= new Button[fButtonLabels.length]; - for (int i= 0; i < fButtonLabels.length; i++) { - String currLabel= fButtonLabels[i]; - if (currLabel != null) { - fButtonControls[i]= createButton(contents, currLabel, listener); - fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]); - } else { - fButtonControls[i]= null; - createSeparator(contents); - } - } - } - - fLastSeparator= createSeparator(contents); - - updateButtonState(); - fButtonsControl= contents; - } - - return fButtonsControl; - } - - protected void doButtonSelected(SelectionEvent e) { - if (fButtonControls != null) { - for (int i= 0; i < fButtonControls.length; i++) { - if (e.widget == fButtonControls[i]) { - buttonPressed(i); - return; - } - } - } - } - - // ------ enable / disable management - - /* - * @see DialogField#dialogFieldChanged - */ - @Override - public void dialogFieldChanged() { - super.dialogFieldChanged(); - updateButtonState(); - } - - /* - * Updates the enable state of the all buttons - */ - protected void updateButtonState() { - if (fButtonControls != null) { - ISelection sel= fTable.getSelection(); - for (int i= 0; i < fButtonControls.length; i++) { - Button button= fButtonControls[i]; - if (isOkToUse(button)) { - boolean extraState= getManagedButtonState(sel, i); - button.setEnabled(isEnabled() && extraState && fButtonsEnabled[i]); - } - } - } - } - - protected boolean getManagedButtonState(ISelection sel, int index) { - if (index == fRemoveButtonIndex) { - return !sel.isEmpty(); - } else if (index == fUpButtonIndex) { - return !sel.isEmpty() && canMoveUp(); - } else if (index == fDownButtonIndex) { - return !sel.isEmpty() && canMoveDown(); - } - return true; - } - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - - boolean enabled= isEnabled(); - if (isOkToUse(fTableControl)) { - if (!enabled) { - fSelectionWhenEnabled= fTable.getSelection(); - selectElements(null); - } else { - selectElements(fSelectionWhenEnabled); - fSelectionWhenEnabled= null; - } - fTableControl.setEnabled(enabled); - } - updateButtonState(); - } - - /** - * Sets a button enabled or disabled. - */ - public void enableButton(int index, boolean enable) { - if (fButtonsEnabled != null && index < fButtonsEnabled.length) { - fButtonsEnabled[index]= enable; - updateButtonState(); - } - } - - // ------ model access - - /** - * Sets the elements shown in the list. - */ - public void setElements(List elements) { - fElements= new ArrayList(elements); - if (fTable != null) { - fTable.refresh(); - } - dialogFieldChanged(); - } - - /** - * Gets the elements shown in the list. - * The list returned is a copy, so it can be modified by the user. - */ - public List getElements() { - return new ArrayList(fElements); - } - - /** - * Gets the elements shown at the given index. - */ - public Object getElement(int index) { - return fElements.get(index); - } - - /** - * Replace an element. - */ - public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException { - int idx= fElements.indexOf(oldElement); - if (idx != -1) { - if (oldElement.equals(newElement) || fElements.contains(newElement)) { - return; - } - fElements.set(idx, newElement); - if (fTable != null) { - List selected= getSelectedElements(); - if (selected.remove(oldElement)) { - selected.add(newElement); - } - fTable.refresh(); - selectElements(new StructuredSelection(selected)); - } - dialogFieldChanged(); - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Adds an element at the end of the list. - */ - public void addElement(Object element) { - if (fElements.contains(element)) { - return; - } - fElements.add(element); - if (fTable != null) { - fTable.add(element); - } - dialogFieldChanged(); - } - - /** - * Adds elements at the end of the list. - */ - public void addElements(List elements) { - int nElements= elements.size(); - - if (nElements > 0) { - // filter duplicated - ArrayList elementsToAdd= new ArrayList(nElements); - - for (int i= 0; i < nElements; i++) { - Object elem= elements.get(i); - if (!fElements.contains(elem)) { - elementsToAdd.add(elem); - } - } - fElements.addAll(elementsToAdd); - if (fTable != null) { - fTable.add(elementsToAdd.toArray()); - } - dialogFieldChanged(); - } - } - - /** - * Adds an element at a position. - */ - public void insertElementAt(Object element, int index) { - if (fElements.contains(element)) { - return; - } - fElements.add(index, element); - if (fTable != null) { - fTable.add(element); - } - - dialogFieldChanged(); - } - - - /** - * Adds an element at a position. - */ - public void removeAllElements() { - if (fElements.size() > 0) { - fElements.clear(); - if (fTable != null) { - fTable.refresh(); - } - dialogFieldChanged(); - } - } - - /** - * Removes an element from the list. - */ - public void removeElement(Object element) throws IllegalArgumentException { - if (fElements.remove(element)) { - if (fTable != null) { - fTable.remove(element); - } - dialogFieldChanged(); - } else { - throw new IllegalArgumentException(); - } - } - - /** - * Removes elements from the list. - */ - public void removeElements(List elements) { - if (elements.size() > 0) { - fElements.removeAll(elements); - if (fTable != null) { - fTable.remove(elements.toArray()); - } - dialogFieldChanged(); - } - } - - /** - * Gets the number of elements - */ - public int getSize() { - return fElements.size(); - } - - - public void selectElements(ISelection selection) { - fSelectionWhenEnabled= selection; - if (fTable != null) { - fTable.setSelection(selection, true); - } - } - - public void selectFirstElement() { - Object element= null; - if (fViewerSorter != null) { - Object[] arr= fElements.toArray(); - fViewerSorter.sort(fTable, arr); - if (arr.length > 0) { - element= arr[0]; - } - } else { - if (fElements.size() > 0) { - element= fElements.get(0); - } - } - if (element != null) { - selectElements(new StructuredSelection(element)); - } - } - - - public void postSetSelection(final ISelection selection) { - if (isOkToUse(fTableControl)) { - Display d= fTableControl.getDisplay(); - d.asyncExec(new Runnable() { - @Override - public void run() { - if (isOkToUse(fTableControl)) { - selectElements(selection); - } - } - }); - } - } - - /** - * Refreshes the table. - */ - public void refresh() { - fTable.refresh(); - } - - // ------- list maintenance - - private List moveUp(List elements, List move) { - int nElements= elements.size(); - List res= new ArrayList(nElements); - Object floating= null; - for (int i= 0; i < nElements; i++) { - Object curr= elements.get(i); - if (move.contains(curr)) { - res.add(curr); - } else { - if (floating != null) { - res.add(floating); - } - floating= curr; - } - } - if (floating != null) { - res.add(floating); - } - return res; - } - - private void moveUp(List toMoveUp) { - if (toMoveUp.size() > 0) { - setElements(moveUp(fElements, toMoveUp)); - fTable.reveal(toMoveUp.get(0)); - } - } - - private void moveDown(List toMoveDown) { - if (toMoveDown.size() > 0) { - setElements(reverse(moveUp(reverse(fElements), toMoveDown))); - fTable.reveal(toMoveDown.get(toMoveDown.size() - 1)); - } - } - - private List reverse(List p) { - List reverse= new ArrayList(p.size()); - for (int i= p.size()-1; i >= 0; i--) { - reverse.add(p.get(i)); - } - return reverse; - } - - - private void remove() { - removeElements(getSelectedElements()); - } - - private void up() { - moveUp(getSelectedElements()); - } - - private void down() { - moveDown(getSelectedElements()); - } - - private boolean canMoveUp() { - if (isOkToUse(fTableControl)) { - int[] indc= fTableControl.getSelectionIndices(); - for (int i= 0; i < indc.length; i++) { - if (indc[i] != i) { - return true; - } - } - } - return false; - } - - private boolean canMoveDown() { - if (isOkToUse(fTableControl)) { - int[] indc= fTableControl.getSelectionIndices(); - int k= fElements.size() - 1; - for (int i= indc.length - 1; i >= 0 ; i--, k--) { - if (indc[i] != k) { - return true; - } - } - } - return false; - } - - /** - * Returns the selected elements. - */ - public List getSelectedElements() { - List result= new ArrayList(); - if (fTable != null) { - ISelection selection= fTable.getSelection(); - if (selection instanceof IStructuredSelection) { - Iterator iter= ((IStructuredSelection)selection).iterator(); - while (iter.hasNext()) { - result.add(iter.next()); - } - } - } - return result; - } - - // ------- ListViewerAdapter - - private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener { - - // ------- ITableContentProvider Interface ------------ - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - // will never happen - } - - public boolean isDeleted(Object element) { - return false; - } - - @Override - public void dispose() { - } - - @Override - public Object[] getElements(Object obj) { - return fElements.toArray(); - } - - // ------- ISelectionChangedListener Interface ------------ - - @Override - public void selectionChanged(SelectionChangedEvent event) { - doListSelected(event); - } - - } - - - protected void doListSelected(SelectionChangedEvent event) { - updateButtonState(); - if (fListAdapter != null) { - fListAdapter.selectionChanged(this); - } - } - - - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogField.java deleted file mode 100644 index ccc1841b784..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogField.java +++ /dev/null @@ -1,195 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.cdt.debug.mi.internal.ui.SWTUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * Dialog Field containing a single button: e.g. radio or checkbox button. - */ -public class SelectionButtonDialogField extends DialogField { - - private Button fButton; - private boolean fIsSelected; - private DialogField[] fAttachedDialogFields; - private int fButtonStyle; - - /** - * Creates a selection button. - * Allowed button styles: SWT.RADIO, SWT.CHECK, SWT.TOGGLE, SWT.PUSH - */ - public SelectionButtonDialogField(int buttonStyle) { - super(); - fIsSelected= false; - fAttachedDialogFields= null; - fButtonStyle= buttonStyle; - } - - /** - * Attaches a field to the selection state of the selection button. - * The attached field will be disabled if the selection button is not selected. - */ - public void attachDialogField(DialogField dialogField) { - attachDialogFields(new DialogField[] { dialogField }); - } - - /** - * Attaches fields to the selection state of the selection button. - * The attached fields will be disabled if the selection button is not selected. - */ - public void attachDialogFields(DialogField[] dialogFields) { - fAttachedDialogFields= dialogFields; - for (int i= 0; i < dialogFields.length; i++) { - dialogFields[i].setEnabled(fIsSelected); - } - } - - /** - * Returns <code>true</code> is teh gived field is attached to the selection button. - */ - public boolean isAttached(DialogField editor) { - if (fAttachedDialogFields != null) { - for (int i=0; i < fAttachedDialogFields.length; i++) { - if (fAttachedDialogFields[i] == editor) { - return true; - } - } - } - return false; - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Button button= getSelectionButton(parent); - GridData gd= new GridData(); - gd.horizontalSpan= nColumns; - gd.horizontalAlignment= GridData.FILL; - if (fButtonStyle == SWT.PUSH) { - gd.widthHint = SWTUtil.getButtonWidthHint(button); - } - - button.setLayoutData(gd); - - return new Control[] { button }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 1; - } - - // ------- ui creation - - /** - * Returns the selection button widget. When called the first time, the widget will be created. - * @param The parent composite when called the first time, or <code>null</code> - * after. - */ - public Button getSelectionButton(Composite group) { - if (fButton == null) { - assertCompositeNotNull(group); - - fButton= new Button(group, fButtonStyle); - fButton.setFont(group.getFont()); - fButton.setText(fLabelText); - fButton.setEnabled(isEnabled()); - fButton.setSelection(fIsSelected); - fButton.addSelectionListener(new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - doWidgetSelected(e); - } - @Override - public void widgetSelected(SelectionEvent e) { - doWidgetSelected(e); - } - }); - } - return fButton; - } - - protected void doWidgetSelected(SelectionEvent e) { - if (isOkToUse(fButton)) { - changeValue(fButton.getSelection()); - } - } - - private void changeValue(boolean newState) { - if (fIsSelected != newState) { - fIsSelected= newState; - if (fAttachedDialogFields != null) { - boolean focusSet= false; - for (int i= 0; i < fAttachedDialogFields.length; i++) { - fAttachedDialogFields[i].setEnabled(fIsSelected); - if (fIsSelected && !focusSet) { - focusSet= fAttachedDialogFields[i].setFocus(); - } - } - } - dialogFieldChanged(); - } else if (fButtonStyle == SWT.PUSH) { - dialogFieldChanged(); - } - } - - // ------ model access - - /** - * Returns the selection state of the button. - */ - public boolean isSelected() { - return fIsSelected; - } - - /** - * Sets the selection state of the button. - */ - public void setSelection(boolean selected) { - changeValue(selected); - if (isOkToUse(fButton)) { - fButton.setSelection(selected); - } - } - - // ------ enable / disable management - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (isOkToUse(fButton)) { - fButton.setEnabled(isEnabled()); - } - } - - - - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java deleted file mode 100644 index 75f30fc0ed1..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/SelectionButtonDialogFieldGroup.java +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.jface.util.Assert; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -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.Group; -import org.eclipse.swt.widgets.Label; - -/** - * Dialog field describing a group with buttons (Checkboxes, radio buttons..) - */ -public class SelectionButtonDialogFieldGroup extends DialogField { - - private Composite fButtonComposite; - - private Button[] fButtons; - private String[] fButtonNames; - private boolean[] fButtonsSelected; - private boolean[] fButtonsEnabled; - - private int fGroupBorderStyle; - private int fGroupNumberOfColumns; - private int fButtonsStyle; - - /** - * Creates a group without border. - */ - public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) { - this(buttonsStyle, buttonNames, nColumns, SWT.NONE); - } - - - /** - * Creates a group with border (label in border). - * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE - * For border styles see <code>Group</code> - */ - public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) { - super(); - - Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE); - fButtonNames= buttonNames; - - int nButtons= buttonNames.length; - fButtonsSelected= new boolean[nButtons]; - fButtonsEnabled= new boolean[nButtons]; - for (int i= 0; i < nButtons; i++) { - fButtonsSelected[i]= false; - fButtonsEnabled[i]= true; - } - if (fButtonsStyle == SWT.RADIO) { - fButtonsSelected[0]= true; - } - - fGroupBorderStyle= borderStyle; - fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns; - - fButtonsStyle= buttonsStyle; - - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - if (fGroupBorderStyle == SWT.NONE) { - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(1)); - - Composite buttonsgroup= getSelectionButtonsGroup(parent); - GridData gd= new GridData(); - gd.horizontalSpan= nColumns - 1; - buttonsgroup.setLayoutData(gd); - - return new Control[] { label, buttonsgroup }; - } - Composite buttonsgroup= getSelectionButtonsGroup(parent); - GridData gd= new GridData(); - gd.horizontalSpan= nColumns; - buttonsgroup.setLayoutData(gd); - - return new Control[] { buttonsgroup }; - } - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public int getNumberOfControls() { - return (fGroupBorderStyle == SWT.NONE) ? 2 : 1; - } - - // ------- ui creation - - private Button createSelectionButton(int index, Composite group, SelectionListener listener) { - Button button= new Button(group, fButtonsStyle | SWT.LEFT); - button.setFont(group.getFont()); - button.setText(fButtonNames[index]); - button.setEnabled(isEnabled() && fButtonsEnabled[index]); - button.setSelection(fButtonsSelected[index]); - button.addSelectionListener(listener); - button.setLayoutData(new GridData()); - return button; - } - - /** - * Returns the group widget. When called the first time, the widget will be created. - * @param The parent composite when called the first time, or <code>null</code> - * after. - */ - public Composite getSelectionButtonsGroup(Composite parent) { - if (fButtonComposite == null) { - assertCompositeNotNull(parent); - - GridLayout layout= new GridLayout(); - layout.makeColumnsEqualWidth= true; - layout.numColumns= fGroupNumberOfColumns; - - if (fGroupBorderStyle != SWT.NONE) { - Group group= new Group(parent, fGroupBorderStyle); - if (fLabelText != null && fLabelText.length() > 0) { - group.setText(fLabelText); - } - fButtonComposite= group; - } else { - fButtonComposite= new Composite(parent, SWT.NULL); - layout.marginHeight= 0; - layout.marginWidth= 0; - } - - fButtonComposite.setLayout(layout); - - SelectionListener listener= new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - doWidgetSelected(e); - } - @Override - public void widgetSelected(SelectionEvent e) { - doWidgetSelected(e); - } - }; - int nButtons= fButtonNames.length; - fButtons= new Button[nButtons]; - for (int i= 0; i < nButtons; i++) { - fButtons[i]= createSelectionButton(i, fButtonComposite, listener); - } - int nRows= nButtons / fGroupNumberOfColumns; - int nFillElements= nRows * fGroupNumberOfColumns - nButtons; - for (int i= 0; i < nFillElements; i++) { - createEmptySpace(fButtonComposite); - } - } - return fButtonComposite; - } - - /** - * Returns a button from the group or <code>null</code> if not yet created. - */ - public Button getSelectionButton(int index) { - if (index >= 0 && index < fButtons.length) { - return fButtons[index]; - } - return null; - } - - protected void doWidgetSelected(SelectionEvent e) { - Button button= (Button)e.widget; - for (int i= 0; i < fButtons.length; i++) { - if (fButtons[i] == button) { - fButtonsSelected[i]= button.getSelection(); - dialogFieldChanged(); - return; - } - } - } - - // ------ model access - - /** - * Returns the selection state of a button contained in the group. - * @param The index of the button - */ - public boolean isSelected(int index) { - if (index >= 0 && index < fButtonsSelected.length) { - return fButtonsSelected[index]; - } - return false; - } - - /** - * Sets the selection state of a button contained in the group. - */ - public void setSelection(int index, boolean selected) { - if (index >= 0 && index < fButtonsSelected.length) { - if (fButtonsSelected[index] != selected) { - fButtonsSelected[index]= selected; - if (fButtons != null) { - Button button= fButtons[index]; - if (isOkToUse(button)) { - button.setSelection(selected); - } - } - } - } - } - - // ------ enable / disable management - - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (fButtons != null) { - boolean enabled= isEnabled(); - for (int i= 0; i < fButtons.length; i++) { - Button button= fButtons[i]; - if (isOkToUse(button)) { - button.setEnabled(enabled && fButtonsEnabled[i]); - } - } - } - } - - /** - * Sets the enable state of a button contained in the group. - */ - public void enableSelectionButton(int index, boolean enable) { - if (index >= 0 && index < fButtonsEnabled.length) { - fButtonsEnabled[index]= enable; - if (fButtons != null) { - Button button= fButtons[index]; - if (isOkToUse(button)) { - button.setEnabled(isEnabled() && enable); - } - } - } - } -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/Separator.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/Separator.java deleted file mode 100644 index 83c2ff67e03..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/Separator.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; - -/** - * Dialog field describing a separator. - */ -public class Separator extends DialogField { - - private Label fSeparator; - private int fStyle; - - public Separator() { - this(SWT.NONE); - } - - /** - * @param style of the separator. See <code>Label</code> for possible - * styles. - */ - public Separator(int style) { - super(); - fStyle= style; - } - - // ------- layout helpers - - /** - * Creates the separator and fills it in a MGridLayout. - * @param height The heigth of the separator - */ - public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) { - assertEnoughColumns(nColumns); - - Control separator= getSeparator(parent); - separator.setLayoutData(gridDataForSeperator(nColumns, height)); - - return new Control[] { separator }; - } - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - return doFillIntoGrid(parent, nColumns, 4); - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 1; - } - - protected static GridData gridDataForSeperator(int span, int height) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.verticalAlignment= GridData.BEGINNING; - gd.heightHint= height; - gd.horizontalSpan= span; - return gd; - } - - // ------- ui creation - - /** - * Creates or returns the created separator. - * @param parent The parent composite or <code>null</code> if the widget has - * already been created. - */ - public Control getSeparator(Composite parent) { - if (fSeparator == null) { - assertCompositeNotNull(parent); - fSeparator= new Label(parent, fStyle); - } - return fSeparator; - } - -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonDialogField.java deleted file mode 100644 index 000c76c4d88..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonDialogField.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.cdt.debug.mi.internal.ui.SWTUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog field containing a label, text control and a button control. - */ -public class StringButtonDialogField extends StringDialogField { - - private Button fBrowseButton; - private String fBrowseButtonLabel; - private IStringButtonAdapter fStringButtonAdapter; - - private boolean fButtonEnabled; - - public StringButtonDialogField(IStringButtonAdapter adapter) { - super(); - fStringButtonAdapter= adapter; - fBrowseButtonLabel= "!Browse...!"; //$NON-NLS-1$ - fButtonEnabled= true; - } - - /** - * Sets the label of the button. - */ - public void setButtonLabel(String label) { - fBrowseButtonLabel= label; - } - - // ------ adapter communication - - /** - * Programmatical pressing of the button - */ - public void changeControlPressed() { - fStringButtonAdapter.changeControlPressed(this); - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); - text.setLayoutData(gridDataForText(nColumns - 2)); - Button button= getChangeControl(parent); - button.setLayoutData(gridDataForButton(button, 1)); - - return new Control[] { label, text, button }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 3; - } - - protected static GridData gridDataForButton(Button button, int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; - gd.widthHint = SWTUtil.getButtonWidthHint(button); - return gd; - } - - // ------- ui creation - - /** - * Creates or returns the created buttom widget. - * @param parent The parent composite or <code>null</code> if the widget has - * already been created. - */ - public Button getChangeControl(Composite parent) { - if (fBrowseButton == null) { - assertCompositeNotNull(parent); - - fBrowseButton= new Button(parent, SWT.PUSH); - fBrowseButton.setText(fBrowseButtonLabel); - fBrowseButton.setEnabled(isEnabled() && fButtonEnabled); - fBrowseButton.addSelectionListener(new SelectionListener() { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - changeControlPressed(); - } - @Override - public void widgetSelected(SelectionEvent e) { - changeControlPressed(); - } - }); - - } - return fBrowseButton; - } - - // ------ enable / disable management - - /** - * Sets the enable state of the button. - */ - public void enableButton(boolean enable) { - if (isOkToUse(fBrowseButton)) { - fBrowseButton.setEnabled(isEnabled() && enable); - } - fButtonEnabled= enable; - } - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (isOkToUse(fBrowseButton)) { - fBrowseButton.setEnabled(isEnabled() && fButtonEnabled); - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonStatusDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonStatusDialogField.java deleted file mode 100644 index 1513758478d..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringButtonStatusDialogField.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog field containing a label, text control, status label and a button control. - * The status label can be either a image or text label, and can be usd to give - * additional information about the current element chosen. - */ -public class StringButtonStatusDialogField extends StringButtonDialogField { - - private Label fStatusLabelControl; - private Object fStatus; // String or ImageDescriptor - - private String fWidthHintString; - private int fWidthHint; - - public StringButtonStatusDialogField(IStringButtonAdapter adapter) { - super(adapter); - fStatus= null; - fWidthHintString= null; - fWidthHint= -1; - } - - // ------ set status - - /** - * Sets the status string. - */ - public void setStatus(String status) { - if (isOkToUse(fStatusLabelControl)) { - fStatusLabelControl.setText(status); - } - fStatus= status; - } - - /** - * Sets the status image. - * Caller is responsible to dispose image - */ - public void setStatus(Image image) { - if (isOkToUse(fStatusLabelControl)) { - if (image == null) { - fStatusLabelControl.setImage(null); - } else { - fStatusLabelControl.setImage(image); - } - } - fStatus= image; - } - - /** - * Sets the staus string hint of the status label. - * The string is used to calculate the size of the status label. - */ - public void setStatusWidthHint(String widthHintString) { - fWidthHintString= widthHintString; - fWidthHint= -1; - } - - /** - * Sets the width hint of the status label. - */ - public void setStatusWidthHint(int widthHint) { - fWidthHint= widthHint; - fWidthHintString= null; - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); - text.setLayoutData(gridDataForText(nColumns - 3)); - Label status= getStatusLabelControl(parent); - status.setLayoutData(gridDataForStatusLabel(parent, 1)); - Button button= getChangeControl(parent); - button.setLayoutData(gridDataForButton(button, 1)); - - return new Control[] { label, text, status, button }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 4; - } - - protected GridData gridDataForStatusLabel(Control aControl, int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.BEGINNING; - gd.grabExcessHorizontalSpace= false; - gd.horizontalIndent= 0; - if (fWidthHintString != null) { - GC gc= new GC(aControl); - gd.widthHint= gc.textExtent(fWidthHintString).x; - gc.dispose(); - } else if (fWidthHint != -1) { - gd.widthHint= fWidthHint; - } else { - gd.widthHint= SWT.DEFAULT; - } - return gd; - } - - // ------- ui creation - - /** - * Creates or returns the created status label widget. - * @param parent The parent composite or <code>null</code> when the widget has - * already been created. - */ - public Label getStatusLabelControl(Composite parent) { - if (fStatusLabelControl == null) { - assertCompositeNotNull(parent); - fStatusLabelControl= new Label(parent, SWT.LEFT); - fStatusLabelControl.setFont(parent.getFont()); - fStatusLabelControl.setEnabled(isEnabled()); - if (fStatus instanceof Image) { - fStatusLabelControl.setImage((Image)fStatus); - } else if (fStatus instanceof String) { - fStatusLabelControl.setText((String)fStatus); - } else { - // must be null - } - } - return fStatusLabelControl; - } - - // ------ enable / disable management - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (isOkToUse(fStatusLabelControl)) { - fStatusLabelControl.setEnabled(isEnabled()); - } - } -}
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringDialogField.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringDialogField.java deleted file mode 100644 index ff320aa36c6..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/dialogfields/StringDialogField.java +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.dialogfields; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog field containing a label and a text control. - */ -public class StringDialogField extends DialogField { - - private String fText; - private Text fTextControl; - private ModifyListener fModifyListener; - - public StringDialogField() { - super(); - fText= ""; //$NON-NLS-1$ - } - - // ------- layout helpers - - /* - * @see DialogField#doFillIntoGrid - */ - @Override - public Control[] doFillIntoGrid(Composite parent, int nColumns) { - assertEnoughColumns(nColumns); - - Label label= getLabelControl(parent); - label.setLayoutData(gridDataForLabel(1)); - Text text= getTextControl(parent); - text.setLayoutData(gridDataForText(nColumns - 1)); - - return new Control[] { label, text }; - } - - /* - * @see DialogField#getNumberOfControls - */ - @Override - public int getNumberOfControls() { - return 2; - } - - protected static GridData gridDataForText(int span) { - GridData gd= new GridData(); - gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; - gd.horizontalSpan= span; - return gd; - } - - // ------- focus methods - - /* - * @see DialogField#setFocus - */ - @Override - public boolean setFocus() { - if (isOkToUse(fTextControl)) { - fTextControl.setFocus(); - fTextControl.setSelection(0, fTextControl.getText().length()); - } - return true; - } - - // ------- ui creation - - /** - * Creates or returns the created text control. - * @param parent The parent composite or <code>null</code> when the widget has - * already been created. - */ - public Text getTextControl(Composite parent) { - if (fTextControl == null) { - assertCompositeNotNull(parent); - fModifyListener= new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - doModifyText(e); - } - }; - - fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER); - // moved up due to 1GEUNW2 - fTextControl.setText(fText); - fTextControl.setFont(parent.getFont()); - fTextControl.addModifyListener(fModifyListener); - - fTextControl.setEnabled(isEnabled()); - } - return fTextControl; - } - - protected void doModifyText(ModifyEvent e) { - if (isOkToUse(fTextControl)) { - fText= fTextControl.getText(); - } - dialogFieldChanged(); - } - - // ------ enable / disable management - - /* - * @see DialogField#updateEnableState - */ - @Override - protected void updateEnableState() { - super.updateEnableState(); - if (isOkToUse(fTextControl)) { - fTextControl.setEnabled(isEnabled()); - } - } - - // ------ text access - - /** - * Gets the text. Can not be <code>null</code> - */ - public String getText() { - return fText; - } - - /** - * Sets the text. Triggers a dialog-changed event. - */ - public void setText(String text) { - fText= text; - if (isOkToUse(fTextControl)) { - fTextControl.setText(text); - } else { - dialogFieldChanged(); - } - } - - /** - * Sets the text without triggering a dialog-changed event. - */ - public void setTextWithoutUpdate(String text) { - fText= text; - if (isOkToUse(fTextControl)) { - fTextControl.removeModifyListener(fModifyListener); - fTextControl.setText(text); - fTextControl.addModifyListener(fModifyListener); - } - } - -}
\ 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 deleted file mode 100644 index ba805ebc8e4..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/MIPreferencePage.java +++ /dev/null @@ -1,574 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2012 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.preferences; - -import com.ibm.icu.text.MessageFormat; -import java.util.HashMap; -import java.util.Iterator; -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; -import org.eclipse.cdt.debug.mi.internal.ui.MIUIPlugin; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * Page for preferences that apply specifically to GDB MI. - */ -public class MIPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IPropertyChangeListener { - - /** - * This class exists to provide visibility to the - * <code>refreshValidState</code> method and to perform more intelligent - * clearing of the error message. - */ - protected class MIIntegerFieldEditor extends IntegerFieldEditor { - - public MIIntegerFieldEditor(String name, String labelText, Composite parent) { - super(name, labelText, parent); - } - - /** - * @see org.eclipse.jface.preference.FieldEditor#refreshValidState() - */ - @Override - protected void refreshValidState() { - super.refreshValidState(); - } - - /** - * Clears the error message from the message line if the error - * message is the error message from this field editor. - */ - @Override - protected void clearErrorMessage() { - if (canClearErrorMessage()) { - super.clearErrorMessage(); - } - } - } - public class MIPreferenceStore implements IPreferenceStore { - - private Preferences fPreferences; - - private HashMap fListeners = new HashMap(); - - public MIPreferenceStore( Preferences pref ) { - fPreferences = pref; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - @Override - public void addPropertyChangeListener( final IPropertyChangeListener listener ) { - Preferences.IPropertyChangeListener l = new Preferences.IPropertyChangeListener() { - - @Override - public void propertyChange( org.eclipse.core.runtime.Preferences.PropertyChangeEvent event ) { - listener.propertyChange( new PropertyChangeEvent( MIPreferenceStore.this, event.getProperty(), event.getNewValue(), event.getOldValue() ) ); - } - }; - fListeners.put( listener, l ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) - */ - @Override - public boolean contains( String name ) { - return getPreferences().contains( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object) - */ - @Override - public void firePropertyChangeEvent( String name, Object oldValue, Object newValue ) { - Iterator it = fListeners.keySet().iterator(); - while( it.hasNext() ) { - ((IPropertyChangeListener)it.next()).propertyChange( new PropertyChangeEvent( this, name, oldValue, newValue ) ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) - */ - @Override - public boolean getBoolean( String name ) { - return fPreferences.getBoolean( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String) - */ - @Override - public boolean getDefaultBoolean( String name ) { - return fPreferences.getDefaultBoolean( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String) - */ - @Override - public double getDefaultDouble( String name ) { - return fPreferences.getDefaultDouble( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String) - */ - @Override - public float getDefaultFloat( String name ) { - return fPreferences.getDefaultFloat( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String) - */ - @Override - public int getDefaultInt( String name ) { - return fPreferences.getDefaultInt( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String) - */ - @Override - public long getDefaultLong( String name ) { - return fPreferences.getDefaultLong( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String) - */ - @Override - public String getDefaultString( String name ) { - return fPreferences.getDefaultString( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) - */ - @Override - public double getDouble( String name ) { - return fPreferences.getDouble( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) - */ - @Override - public float getFloat( String name ) { - return fPreferences.getFloat( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) - */ - @Override - public int getInt( String name ) { - return fPreferences.getInt( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) - */ - @Override - public long getLong( String name ) { - return fPreferences.getLong( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) - */ - @Override - public String getString( String name ) { - return fPreferences.getString( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) - */ - @Override - public boolean isDefault( String name ) { - return fPreferences.isDefault( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() - */ - @Override - public boolean needsSaving() { - return getPreferences().needsSaving(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String) - */ - @Override - public void putValue( String name, String value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - @Override - public void removePropertyChangeListener( IPropertyChangeListener listener ) { - fListeners.remove( listener ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double) - */ - @Override - public void setDefault( String name, double value ) { - getPreferences().setDefault( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, float) - */ - @Override - public void setDefault( String name, float value ) { - getPreferences().setDefault( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, int) - */ - @Override - public void setDefault( String name, int value ) { - getPreferences().setDefault( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, long) - */ - @Override - public void setDefault( String name, long value ) { - getPreferences().setDefault( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, java.lang.String) - */ - @Override - public void setDefault( String name, String defaultObject ) { - getPreferences().setDefault( name, defaultObject ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, boolean) - */ - @Override - public void setDefault( String name, boolean value ) { - getPreferences().setDefault( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String) - */ - @Override - public void setToDefault( String name ) { - getPreferences().setToDefault( name ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, double) - */ - @Override - public void setValue( String name, double value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, float) - */ - @Override - public void setValue( String name, float value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, int) - */ - @Override - public void setValue( String name, int value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, long) - */ - @Override - public void setValue( String name, long value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, java.lang.String) - */ - @Override - public void setValue( String name, String value ) { - getPreferences().setValue( name, value ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, boolean) - */ - @Override - public void setValue( String name, boolean value ) { - getPreferences().setValue( name, value ); - } - - protected Preferences getPreferences() { - return fPreferences; - } - } - - private IWorkbench fWorkbench; - - // Debugger timeout preference widgets - private MIIntegerFieldEditor fDebugTimeoutText; - - // Launch timeout preference widgets - private MIIntegerFieldEditor fLaunchTimeoutText; - - private BooleanFieldEditor fRefreshSolibsButton; - - private MIPreferenceStore fMICorePreferenceStore = new MIPreferenceStore( MIPlugin.getDefault().getPluginPreferences() ); - - /** - * Constructor for MIPreferencePage. - */ - public MIPreferencePage() { - super(); - setPreferenceStore( MIUIPlugin.getDefault().getPreferenceStore() ); - setDescription( PreferenceMessages.getString( "MIPreferencePage.0" ) ); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) - */ - @Override - protected Control createContents( Composite parent ) { - getWorkbench().getHelpSystem().setHelp( getControl(), IMIHelpContextIds.MI_PREFERENCE_PAGE ); - //The main composite - Composite composite = new Composite( parent, SWT.NULL ); - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout( layout ); - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - composite.setLayoutData( data ); - createSpacer( composite, 1 ); - createCommunicationPreferences( composite ); - 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 - * @return the newly-created composite - */ - private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) { - return ControlFactory.createGroup( parent, labelText, numColumns ); - } - - /** - * @see IPreferencePage#performOk() - */ - @Override - public boolean performOk() { - boolean result = super.performOk(); - storeValues(); - MIUIPlugin.getDefault().savePluginPreferences(); - MIPlugin.getDefault().savePluginPreferences(); - return result; - } - - /** - * Sets the default preferences. - * - * @see PreferencePage#performDefaults() - */ - @Override - protected void performDefaults() { - setDefaultValues(); - super.performDefaults(); - } - - private void setDefaultValues() { - fDebugTimeoutText.loadDefault(); - fLaunchTimeoutText.loadDefault(); - fRefreshSolibsButton.loadDefault(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench) - */ - @Override - public void init( IWorkbench workbench ) { - fWorkbench = workbench; - } - - 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 ) { - 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 ); - GridLayout layout = new GridLayout(); - spacingComposite.setLayout( layout ); - 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( this ); - fLaunchTimeoutText = createTimeoutField( IMIConstants.PREF_REQUEST_LAUNCH_TIMEOUT, PreferenceMessages.getString( "MIPreferencePage.3" ), spacingComposite ); //$NON-NLS-1$ - fLaunchTimeoutText.setPropertyChangeListener( this ); - fRefreshSolibsButton = createCheckbox( IMIConstants.PREF_SHARED_LIBRARIES_AUTO_REFRESH, PreferenceMessages.getString( "MIPreferencePage.6" ), spacingComposite ); //$NON-NLS-1$ - } - - /** - * Store the preference values based on the state of the component widgets - */ - private void storeValues() { - fDebugTimeoutText.store(); - fLaunchTimeoutText.store(); - fRefreshSolibsButton.store(); - } - - private MIIntegerFieldEditor createTimeoutField( String preference, String label, Composite parent ) { - MIIntegerFieldEditor toText = new MIIntegerFieldEditor( preference, label, parent ); - GridData data = new GridData(); - data.widthHint = convertWidthInCharsToPixels( 10 ); - toText.getTextControl( parent ).setLayoutData( data ); - toText.setPreferenceStore( getMICorePreferenceStore() ); - toText.setPage( this ); - toText.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE ); - toText.setValidRange( IMIConstants.MIN_REQUEST_TIMEOUT, IMIConstants.MAX_REQUEST_TIMEOUT ); - String minValue = Integer.toString( IMIConstants.MIN_REQUEST_TIMEOUT ); - String maxValue = Integer.toString( IMIConstants.MAX_REQUEST_TIMEOUT ); - toText.setErrorMessage( MessageFormat.format( PreferenceMessages.getString( "MIPreferencePage.4" ), new String[]{ minValue, maxValue } ) ); //$NON-NLS-1$ - toText.load(); - return toText; - } - - private BooleanFieldEditor createCheckbox( String preference, String label, Composite parent ) { - BooleanFieldEditor field = new BooleanFieldEditor( preference, label, parent ); - field.setPage( this ); - field.setPreferenceStore( new MIPreferenceStore( MIPlugin.getDefault().getPluginPreferences() ) ); - field.load(); - return field; - } - - protected MIPreferenceStore getMICorePreferenceStore() { - return fMICorePreferenceStore; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#dispose() - */ - @Override - public void dispose() { - fDebugTimeoutText.dispose(); - fLaunchTimeoutText.dispose(); - fRefreshSolibsButton.dispose(); - super.dispose(); - } - - protected MIIntegerFieldEditor getLaunchTimeoutText() { - return fLaunchTimeoutText; - } - - protected MIIntegerFieldEditor getDebugTimeoutText() { - return fDebugTimeoutText; - } - - /** - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - @Override - public void propertyChange(PropertyChangeEvent event) { - - if (event.getProperty().equals(FieldEditor.IS_VALID)) { - boolean newValue = ((Boolean) event.getNewValue()).booleanValue(); - // If the new value is true then we must check all field editors. - // If it is false, then the page is invalid in any case. - MIIntegerFieldEditor launchTimeout = getLaunchTimeoutText(); - MIIntegerFieldEditor debugTimeout = getDebugTimeoutText(); - if (newValue) { - if (launchTimeout != null && event.getSource() != launchTimeout) { - launchTimeout.refreshValidState(); - } - if (debugTimeout != null && event.getSource() != debugTimeout) { - debugTimeout.refreshValidState(); - } - } - setValid(launchTimeout.isValid() && debugTimeout.isValid()); - getContainer().updateButtons(); - updateApplyButton(); - } - } - - protected boolean canClearErrorMessage() { - MIIntegerFieldEditor launchTimeout = getLaunchTimeoutText(); - MIIntegerFieldEditor debugTimeout = getDebugTimeoutText(); - boolean validLaunch = false; - boolean validDebug = false; - if (launchTimeout != null) { - validLaunch = launchTimeout.isValid(); - } - if (debugTimeout != null) { - validDebug = debugTimeout.isValid(); - } - return validLaunch && validDebug; - } - - private IWorkbench getWorkbench() { - return fWorkbench; - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.java deleted file mode 100644 index 2ae2b0266b4..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.preferences; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class PreferenceMessages { - - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.mi.internal.ui.preferences.PreferenceMessages";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private PreferenceMessages() { - } - - public static String getString( String key ) { - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.properties b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.properties deleted file mode 100644 index 52edd439374..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/preferences/PreferenceMessages.properties +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2010 QNX Software Systems and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# QNX Software Systems - initial API and implementation -# IBM Corporation -############################################################################### - -MIPreferencePage.0=General settings for GDB MI. -MIPreferencePage.1=Communication -MIPreferencePage.2=&Debugger timeout (ms): -MIPreferencePage.3=&Launch timeout (ms): -MIPreferencePage.4=Value must be an integer between {0} and {1}. -MIPreferencePage.6=Automatically refresh modules - diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/OptionsPropertyPage.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/OptionsPropertyPage.java deleted file mode 100644 index 1eba323ba53..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/OptionsPropertyPage.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2015 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.propertypages; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDISession; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.mi.core.cdi.Session; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.dialogs.PropertyPage; - -/** - * The property page for the gdb/mi-based debugger options. - */ -public class OptionsPropertyPage extends PropertyPage { - - private Button fRefreshSolibsButton; - - /** - * Constructor for OptionsPropertyPage. - */ - public OptionsPropertyPage() { - noDefaultAndApplyButton(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createContents( Composite parent ) { - Composite comp = ControlFactory.createComposite( parent, 1 ); - fRefreshSolibsButton = createCheckButton( comp, PropertyMessages.getString( "OptionsPropertyPage.1" ) ); //$NON-NLS-1$ - initialize(); - return comp; - } - - private Button createCheckButton( Composite parent, String label ) { - Button button = new Button( parent, SWT.CHECK | SWT.LEFT ); - button.setText( label ); - // FieldEditor GridData - GridData data = new GridData(); - button.setLayoutData( data ); - return button; - } - - private void initialize() { - boolean solibUpdate = true; - ICDISession session = getElement().getAdapter( ICDISession.class ); - if ( session instanceof Session ) { - solibUpdate = ((Session)session).getSharedLibraryManager().isAutoUpdate(); - } - fRefreshSolibsButton.setSelection( solibUpdate ); - - } - - @Override - protected void performApply() { - storeValues(); - super.performApply(); - } - - @Override - public boolean performOk() { - storeValues(); - return super.performOk(); - } - - private void storeValues() { - ICDISession session = getElement().getAdapter( ICDISession.class ); - final ICDITarget target = getElement().getAdapter( ICDITarget.class ); - if ( session instanceof Session ) { - final boolean solibUpdate = fRefreshSolibsButton.getSelection(); - final Session miSession = ((Session)session); - miSession.getSharedLibraryManager().setAutoUpdate( solibUpdate ); - if ( target.isSuspended() && solibUpdate ) { - DebugPlugin.getDefault().asyncExec( new Runnable() { - - @Override - public void run() { - if ( target.isSuspended() ) { - if ( solibUpdate ) { - try { - miSession.getSharedLibraryManager().update(); - } - catch( CDIException e ) { - } - } - } - } - } ); - } - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.java deleted file mode 100644 index eabe4d9dce6..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.internal.ui.propertypages; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Comment for . - */ -public class PropertyMessages { - - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.mi.internal.ui.propertypages.PropertyMessages";//$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); - - private PropertyMessages() { - } - - public static String getString( String key ) { - // TODO Auto-generated method stub - try { - return RESOURCE_BUNDLE.getString( key ); - } - catch( MissingResourceException e ) { - return '!' + key + '!'; - } - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.properties b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.properties deleted file mode 100644 index d47a940b7d7..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/internal/ui/propertypages/PropertyMessages.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2005 QNX Software Systems and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# QNX Software Systems - initial API and implementation -############################################################################### -OptionsPropertyPage.1=Automatically refresh modules 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 deleted file mode 100644 index c363b9eeaf0..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/IMILaunchConfigurationComponent.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * 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. - * <p> - * Implementors are responsible for ensuring that the created control can be accessed via <code>getControl</code> - * </p> - * - * @param parent the parent composite - */ - public void createControl( Composite parent ); - - /** - * Returns the top level control for this component. - * <p> - * May return <code>null</code> if the control has not been created yet. - * </p> - * - * @return the top level control or <code>null</code> - */ - 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 <code>null</code>. - * - * @return whether this component is in a valid state - */ - public boolean isValid(ILaunchConfiguration launchConfig); -} 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 deleted file mode 100644 index b0277bba31d..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/MIUIUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * 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; -import org.eclipse.cdt.debug.mi.internal.ui.dialogfields.IListAdapter; - -/** - * 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 createGDBSolibBlock( boolean autoSolib, boolean stopOnSolibEvents ) { - return new GDBSolibBlock( new SolibSearchPathBlock(), autoSolib, stopOnSolibEvents ); - } - - public static IMILaunchConfigurationComponent createSolibSearchPathBlock( String[] customButtonLabels, IListAdapter listAdapter ) { - return new SolibSearchPathBlock( customButtonLabels, listAdapter ); - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java deleted file mode 100644 index 98a30180bb5..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java +++ /dev/null @@ -1,130 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2012 STMicroelectronics and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - * Alena Laskavaia (QNX) - Fix for 186172 - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.ui.console; - -import java.util.Observable; -import java.util.Observer; - -import org.eclipse.cdt.debug.mi.core.GDBProcess; -import org.eclipse.cdt.debug.mi.core.cdi.model.Target; -import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleSaveAction; -import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleVerboseModeAction; -import org.eclipse.debug.core.DebugEvent; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IDebugEventSetListener; -import org.eclipse.jface.action.Separator; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.console.IConsoleConstants; -import org.eclipse.ui.console.IConsolePageParticipant; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.console.IConsole; - -/** - * Enhances ProcessConsole when the process attached is a GDBProcess - * @since 6.1 - * - */ -public class MiConsolePageParticipant implements IConsolePageParticipant, IDebugEventSetListener, Observer { - - private MiConsoleSaveAction fSaveConsole = null; - private MiConsoleVerboseModeAction fVerboseMode = null; - private org.eclipse.debug.ui.console.IConsole fConsole = null; - private org.eclipse.cdt.debug.mi.core.GDBProcess GDBProcess = null; - - @Override - public void activated() { - } - - @Override - public void deactivated() { - } - - @Override - public void dispose() { - if (GDBProcess != null) { - DebugPlugin.getDefault().removeDebugEventListener(this); - } - fSaveConsole = null; - fVerboseMode = null; - GDBProcess = null; - fConsole = null; - } - - @Override - public void init(IPageBookViewPage page, IConsole console) { - - if(console instanceof org.eclipse.debug.ui.console.IConsole) - { - fConsole = (org.eclipse.debug.ui.console.IConsole) console; - if(fConsole.getProcess() instanceof GDBProcess) { - - GDBProcess = (GDBProcess) fConsole.getProcess(); - - // add two new actions: save console content and verbose console mode switcher - IActionBars bars = page.getSite().getActionBars(); - bars.getToolBarManager().appendToGroup(IConsoleConstants.OUTPUT_GROUP, new Separator()); - fSaveConsole = new MiConsoleSaveAction(fConsole); - bars.getToolBarManager().appendToGroup(IConsoleConstants.OUTPUT_GROUP, fSaveConsole); - fVerboseMode = new MiConsoleVerboseModeAction(fConsole); - bars.getToolBarManager().appendToGroup(IConsoleConstants.OUTPUT_GROUP, fVerboseMode); - bars.getToolBarManager().appendToGroup(IConsoleConstants.OUTPUT_GROUP, new Separator()); - - // add a debug event listener - DebugPlugin.getDefault().addDebugEventListener(this); - // if we miss change event update enablement manually - fVerboseMode.updateStateAndEnablement(); - Target target = GDBProcess.getTarget(); - if (target != null) { - // register this object as MISession observer - target.getMISession().addObserver(this); - } - } - } - } - - @Override - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) { - return null; - } - - @Override - public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event = events[i]; - if (event.getSource().equals(GDBProcess)) { - if (fVerboseMode != null) { - fVerboseMode.updateStateAndEnablement(); - Target target = GDBProcess.getTarget(); - if (target != null) { - // register this object as MISession observer - target.getMISession().addObserver(this); - } - } - } - } - } - - /** - * Handle MISession notification - */ - @Override - public void update(Observable arg0, Object arg1) { - if((arg1!=null) && (arg1 instanceof VerboseModeChangedEvent) && (fVerboseMode != null)) { - try { - fVerboseMode.updateStateAndEnablement(); - } catch (Exception e) { - } - } - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/VerboseModeChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/VerboseModeChangedEvent.java deleted file mode 100644 index 3db6cb4c84a..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/VerboseModeChangedEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 STMicroelectronics. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.ui.console; - -import org.eclipse.cdt.debug.mi.core.MISession; -import org.eclipse.cdt.debug.mi.core.event.MIEvent; - -/** - * MISession event, verbose console mode changed - * @since 6.1 - * - */ -public class VerboseModeChangedEvent extends MIEvent { - - private static final long serialVersionUID = 1L; - - public VerboseModeChangedEvent(MISession session, int token) { - super(session, token); - setPropagate(false); - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/IMiConsoleImagesConst.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/IMiConsoleImagesConst.java deleted file mode 100644 index 5459ce6312d..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/IMiConsoleImagesConst.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2014 STMicroelectronics. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.ui.console.actions; - -/** @since 6.2 */ -public interface IMiConsoleImagesConst { - - public static final String IMG_SAVE_CONSOLE = "icons/obj16/save_console.gif"; //$NON-NLS-1$ - public static final String IMG_VERBOSE_CONSOLE = "icons/obj16/verbose_mode_co.gif"; //$NON-NLS-1$ -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.java deleted file mode 100644 index 37f1157cd4b..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2014 STMicroelectronics. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.ui.console.actions; - -import org.eclipse.osgi.util.NLS; - -/** @since 6.2 */ -public class MiConsoleMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleMessages"; //$NON-NLS-1$ - - public static String saveActionTooltip; - public static String verboseActionTooltip; - - public static String confirmOverWrite; - public static String infoIOError; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, MiConsoleMessages.class); - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.properties b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.properties deleted file mode 100644 index 4ac24931069..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleMessages.properties +++ /dev/null @@ -1,14 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 2006 STMicroelectronics -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# STMicroelectronics - initial API and implementation -############################################################################### -saveActionTooltip=Save console content -verboseActionTooltip=Verbose console mode -confirmOverWrite=File exists, do you want overwrite it? -infoIOError=Error during save console content. Task failed. diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleSaveAction.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleSaveAction.java deleted file mode 100644 index 1a226d9516e..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleSaveAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2014 STMicroelectronics. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - *******************************************************************************/ - -package org.eclipse.cdt.debug.mi.ui.console.actions; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import org.eclipse.cdt.debug.mi.internal.ui.MIUIPlugin; -import org.eclipse.debug.ui.console.IConsole; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; - -/** - * Save console content - * @since 6.2 - */ -public class MiConsoleSaveAction extends Action{ - - private IConsole fConsole; - private String fileName; - - public MiConsoleSaveAction(IConsole console) { - super(); - setToolTipText(MiConsoleMessages.saveActionTooltip); - setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID,IMiConsoleImagesConst.IMG_SAVE_CONSOLE)); - fConsole = console; - } - - @Override - public void run() { - - FileDialog fileDialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); - fileName = fileDialog.open(); - if(fileName==null) { - return; - } - - Runnable saveJob = new Runnable() { - @Override - public void run() { - saveContent(); - } - }; - BusyIndicator.showWhile(Display.getCurrent(), saveJob); - - } - - protected void saveContent() { - boolean confirmed = true; - - try { - File f = new File(fileName); - if(f.exists()) { - confirmed = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), "Confirm overwrite", MiConsoleMessages.confirmOverWrite); - } - if(confirmed) { - BufferedWriter out = new BufferedWriter(new FileWriter(fileName)); - out.write(fConsole.getDocument().get()); - out.close(); - } - } catch (IOException e) { - MessageDialog.openError(Display.getCurrent().getActiveShell(),"Error",MiConsoleMessages.infoIOError); - } - - } - -} diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java deleted file mode 100644 index 43861f18aa4..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2014 STMicroelectronics and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * STMicroelectronics - Process console enhancements - * Alena Laskavaia (QNX) - Fix for 186172 - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.ui.console.actions; - -import org.eclipse.cdt.debug.mi.core.GDBProcess; -import org.eclipse.cdt.debug.mi.core.cdi.model.Target; -import org.eclipse.cdt.debug.mi.internal.ui.MIUIPlugin; -import org.eclipse.debug.ui.console.IConsole; -import org.eclipse.jface.action.Action; - -/** - * Verbose console mode switcher - * @since 6.2 - */ -public class MiConsoleVerboseModeAction extends Action { - private IConsole fConsole; - - public MiConsoleVerboseModeAction(IConsole console) { - super(); - setToolTipText(MiConsoleMessages.verboseActionTooltip); - setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID, IMiConsoleImagesConst.IMG_VERBOSE_CONSOLE)); - fConsole = console; - } - - public void updateStateAndEnablement() { - // initialize button - GDBProcess gdbProcess = (GDBProcess) fConsole.getProcess(); - setEnabled(!gdbProcess.isTerminated()); - Target target = gdbProcess.getTarget(); - if (target != null) { - setChecked(target.isVerboseModeEnabled()); - } else { - setChecked(false); - } - } - - @Override - public void run() { - GDBProcess fProcess = (GDBProcess) fConsole.getProcess(); - fProcess.getTarget().enableVerboseMode(isChecked()); - } - -} |