|
Lines 13-37
Link Here
|
| 13 |
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences; |
13 |
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences; |
| 14 |
|
14 |
|
| 15 |
import java.io.File; |
15 |
import java.io.File; |
|
|
16 |
import java.util.LinkedList; |
| 17 |
import java.util.List; |
| 18 |
import java.util.Map; |
| 19 |
import java.util.Set; |
| 16 |
|
20 |
|
|
|
21 |
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.IntegerWithBooleanFieldEditor; |
| 17 |
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor; |
22 |
import org.eclipse.cdt.dsf.debug.internal.ui.preferences.StringWithBooleanFieldEditor; |
| 18 |
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; |
23 |
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; |
| 19 |
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; |
24 |
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; |
| 20 |
import org.eclipse.cdt.dsf.gdb.internal.ui.launching.LaunchUIMessages; |
25 |
import org.eclipse.cdt.dsf.gdb.internal.ui.IGdbUIConstants; |
|
|
26 |
import org.eclipse.cdt.dsf.gdb.service.command.CustomTimeoutsMap; |
| 27 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 28 |
import org.eclipse.jface.dialogs.TitleAreaDialog; |
| 21 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
29 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
| 22 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
30 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
| 23 |
import org.eclipse.jface.preference.IPreferenceStore; |
31 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 24 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
32 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
| 25 |
import org.eclipse.jface.preference.StringFieldEditor; |
33 |
import org.eclipse.jface.preference.StringFieldEditor; |
|
|
34 |
import org.eclipse.jface.resource.JFaceResources; |
| 35 |
import org.eclipse.jface.util.PropertyChangeEvent; |
| 36 |
import org.eclipse.jface.viewers.CellEditor; |
| 37 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
| 38 |
import org.eclipse.jface.viewers.ColumnViewer; |
| 39 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
| 40 |
import org.eclipse.jface.viewers.EditingSupport; |
| 41 |
import org.eclipse.jface.viewers.ICellEditorListener; |
| 42 |
import org.eclipse.jface.viewers.ICellEditorValidator; |
| 43 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
| 44 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 45 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
| 46 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 47 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 48 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 49 |
import org.eclipse.jface.viewers.TableViewer; |
| 50 |
import org.eclipse.jface.viewers.TableViewerColumn; |
| 51 |
import org.eclipse.jface.viewers.TextCellEditor; |
| 52 |
import org.eclipse.jface.viewers.Viewer; |
| 53 |
import org.eclipse.jface.window.Window; |
| 26 |
import org.eclipse.swt.SWT; |
54 |
import org.eclipse.swt.SWT; |
|
|
55 |
import org.eclipse.swt.events.ControlAdapter; |
| 56 |
import org.eclipse.swt.events.ControlEvent; |
| 27 |
import org.eclipse.swt.events.SelectionAdapter; |
57 |
import org.eclipse.swt.events.SelectionAdapter; |
| 28 |
import org.eclipse.swt.events.SelectionEvent; |
58 |
import org.eclipse.swt.events.SelectionEvent; |
|
|
59 |
import org.eclipse.swt.graphics.Rectangle; |
| 29 |
import org.eclipse.swt.layout.GridData; |
60 |
import org.eclipse.swt.layout.GridData; |
| 30 |
import org.eclipse.swt.layout.GridLayout; |
61 |
import org.eclipse.swt.layout.GridLayout; |
| 31 |
import org.eclipse.swt.widgets.Button; |
62 |
import org.eclipse.swt.widgets.Button; |
| 32 |
import org.eclipse.swt.widgets.Composite; |
63 |
import org.eclipse.swt.widgets.Composite; |
|
|
64 |
import org.eclipse.swt.widgets.Control; |
| 33 |
import org.eclipse.swt.widgets.FileDialog; |
65 |
import org.eclipse.swt.widgets.FileDialog; |
| 34 |
import org.eclipse.swt.widgets.Group; |
66 |
import org.eclipse.swt.widgets.Group; |
|
|
67 |
import org.eclipse.swt.widgets.Shell; |
| 68 |
import org.eclipse.swt.widgets.Table; |
| 69 |
import org.eclipse.swt.widgets.TableColumn; |
| 35 |
import org.eclipse.ui.IWorkbench; |
70 |
import org.eclipse.ui.IWorkbench; |
| 36 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
71 |
import org.eclipse.ui.IWorkbenchPreferencePage; |
| 37 |
import org.eclipse.ui.PlatformUI; |
72 |
import org.eclipse.ui.PlatformUI; |
|
Lines 41-46
Link Here
|
| 41 |
*/ |
76 |
*/ |
| 42 |
@SuppressWarnings("restriction") |
77 |
@SuppressWarnings("restriction") |
| 43 |
public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
78 |
public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
|
|
79 |
|
| 44 |
/** |
80 |
/** |
| 45 |
* A vehicle in order to be able to register a selection listener with |
81 |
* A vehicle in order to be able to register a selection listener with |
| 46 |
* a {@link BooleanFieldEditor}. |
82 |
* a {@link BooleanFieldEditor}. |
|
Lines 58-68
Link Here
|
| 58 |
} |
94 |
} |
| 59 |
} |
95 |
} |
| 60 |
|
96 |
|
|
|
97 |
class AdvancedTimeoutSettingsDialog extends TitleAreaDialog { |
| 98 |
|
| 99 |
class CommandTimeoutEntry { |
| 100 |
|
| 101 |
String fCommand; |
| 102 |
Integer fTimeout; |
| 103 |
|
| 104 |
CommandTimeoutEntry( String command, Integer timeout ) { |
| 105 |
fCommand = command; |
| 106 |
fTimeout = timeout; |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
class CellEditorListener implements ICellEditorListener { |
| 111 |
|
| 112 |
CellEditor fEditor; |
| 113 |
|
| 114 |
public CellEditorListener( CellEditor editor ) { |
| 115 |
super(); |
| 116 |
fEditor = editor; |
| 117 |
} |
| 118 |
|
| 119 |
@Override |
| 120 |
public void editorValueChanged( boolean oldValidState, boolean newValidState ) { |
| 121 |
if ( newValidState ) { |
| 122 |
setErrorMessage( null ); |
| 123 |
} |
| 124 |
else { |
| 125 |
setErrorMessage( fEditor.getErrorMessage() ); |
| 126 |
} |
| 127 |
updateDialogButtons(); |
| 128 |
} |
| 129 |
|
| 130 |
@Override |
| 131 |
public void cancelEditor() { |
| 132 |
} |
| 133 |
|
| 134 |
@Override |
| 135 |
public void applyEditorValue() { |
| 136 |
validate(); |
| 137 |
updateDialogButtons(); |
| 138 |
} |
| 139 |
}; |
| 140 |
|
| 141 |
abstract class AbstractEditingSupport extends EditingSupport { |
| 142 |
|
| 143 |
public AbstractEditingSupport( ColumnViewer viewer ) { |
| 144 |
super( viewer ); |
| 145 |
} |
| 146 |
|
| 147 |
@Override |
| 148 |
protected void setValue( Object element, Object value ) { |
| 149 |
if ( element instanceof CommandTimeoutEntry && value instanceof String ) { |
| 150 |
if ( processValue( (CommandTimeoutEntry)element, (String)value ) ) { |
| 151 |
fViewer.refresh( element ); |
| 152 |
validate(); |
| 153 |
updateDialogButtons(); |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
@Override |
| 159 |
protected Object getValue( Object element ) { |
| 160 |
if ( element instanceof CommandTimeoutEntry ) { |
| 161 |
return doGetValue( (CommandTimeoutEntry)element ); |
| 162 |
} |
| 163 |
return null; |
| 164 |
} |
| 165 |
|
| 166 |
@Override |
| 167 |
protected CellEditor getCellEditor( Object element ) { |
| 168 |
final CellEditor editor = new TextCellEditor( (Composite)getViewer().getControl() ); |
| 169 |
editor.setValidator( getValidator() ); |
| 170 |
editor.addListener( new CellEditorListener( editor ) ); |
| 171 |
return editor; |
| 172 |
} |
| 173 |
|
| 174 |
@Override |
| 175 |
protected boolean canEdit( Object element ) { |
| 176 |
return ( element instanceof CommandTimeoutEntry ); |
| 177 |
} |
| 178 |
|
| 179 |
abstract boolean processValue( CommandTimeoutEntry entry, String value ); |
| 180 |
|
| 181 |
abstract Object doGetValue( CommandTimeoutEntry entry ); |
| 182 |
|
| 183 |
abstract ICellEditorValidator getValidator(); |
| 184 |
}; |
| 185 |
|
| 186 |
private TableViewer fViewer; |
| 187 |
private Button fAddButton; |
| 188 |
private Button fDeleteButton; |
| 189 |
|
| 190 |
private List<CommandTimeoutEntry> fEntries; |
| 191 |
|
| 192 |
final private ICellEditorValidator fCommandValidator = new ICellEditorValidator() { |
| 193 |
|
| 194 |
@Override |
| 195 |
public String isValid( Object value ) { |
| 196 |
if ( value instanceof String && ((String)value).trim().length() == 0 ) { |
| 197 |
return MessagesForPreferences.GdbDebugPreferencePage_Command_field_can_not_be_empty; |
| 198 |
} |
| 199 |
return null; |
| 200 |
} |
| 201 |
}; |
| 202 |
|
| 203 |
final private ICellEditorValidator fTimeoutValidator = new ICellEditorValidator() { |
| 204 |
|
| 205 |
@Override |
| 206 |
public String isValid( Object value ) { |
| 207 |
if ( value instanceof String ) { |
| 208 |
try { |
| 209 |
int intValue = Integer.decode( (String)value ).intValue(); |
| 210 |
if ( intValue < 0 ) |
| 211 |
return MessagesForPreferences.GdbDebugPreferencePage_Timeout_value_can_not_be_negative; |
| 212 |
} |
| 213 |
catch( NumberFormatException e ) { |
| 214 |
return MessagesForPreferences.GdbDebugPreferencePage_Invalid_timeout_value; |
| 215 |
} |
| 216 |
} |
| 217 |
return null; |
| 218 |
} |
| 219 |
}; |
| 220 |
|
| 221 |
AdvancedTimeoutSettingsDialog( Shell parentShell, Set<Map.Entry<String, Integer>> entries ) { |
| 222 |
super( parentShell ); |
| 223 |
setShellStyle(getShellStyle() | SWT.RESIZE); |
| 224 |
fEntries = new LinkedList<CommandTimeoutEntry>(); |
| 225 |
for ( Map.Entry<String, Integer> entry : entries ) { |
| 226 |
fEntries.add( new CommandTimeoutEntry( entry.getKey(), entry.getValue() ) ); |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
/* (non-Javadoc) |
| 231 |
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
| 232 |
*/ |
| 233 |
@Override |
| 234 |
protected Control createDialogArea( Composite parent ) { |
| 235 |
getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Anvanced_Timeout_Settings ); |
| 236 |
setTitle( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_title ); |
| 237 |
setTitleImage( GdbUIPlugin.getImage( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS ) ); |
| 238 |
setMessage( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_message ); |
| 239 |
|
| 240 |
Composite control = (Composite)super.createDialogArea( parent ); |
| 241 |
Composite comp = new Composite( control, SWT.NONE ); |
| 242 |
GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); |
| 243 |
comp.setLayout( new GridLayout( 2, false ) ); |
| 244 |
comp.setLayoutData( gd ); |
| 245 |
|
| 246 |
fViewer = new TableViewer( comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER ); |
| 247 |
final Table table = fViewer.getTable(); |
| 248 |
gd = new GridData( SWT.FILL, SWT.FILL, true, true ); |
| 249 |
table.setLayoutData( gd ); |
| 250 |
|
| 251 |
fViewer.addDoubleClickListener( new IDoubleClickListener() { |
| 252 |
@Override |
| 253 |
public void doubleClick( DoubleClickEvent event ) { |
| 254 |
okPressed(); |
| 255 |
} |
| 256 |
} ); |
| 257 |
|
| 258 |
fViewer.addSelectionChangedListener( new ISelectionChangedListener() { |
| 259 |
|
| 260 |
@Override |
| 261 |
public void selectionChanged( SelectionChangedEvent event ) { |
| 262 |
updateDialogButtons(); |
| 263 |
} |
| 264 |
} ); |
| 265 |
|
| 266 |
Composite btnComp = new Composite( comp, SWT.NONE ); |
| 267 |
btnComp.setLayout( new GridLayout() ); |
| 268 |
btnComp.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) ); |
| 269 |
|
| 270 |
fAddButton = new Button( btnComp, SWT.PUSH ); |
| 271 |
fAddButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Add_button ); |
| 272 |
fAddButton.setFont( JFaceResources.getDialogFont() ); |
| 273 |
setButtonLayoutData( fAddButton ); |
| 274 |
fAddButton.addSelectionListener( new SelectionAdapter() { |
| 275 |
|
| 276 |
@Override |
| 277 |
public void widgetSelected( SelectionEvent e ) { |
| 278 |
addNewEntry(); |
| 279 |
} |
| 280 |
} ); |
| 281 |
|
| 282 |
fDeleteButton = new Button( btnComp, SWT.PUSH ); |
| 283 |
fDeleteButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Delete_button ); |
| 284 |
fDeleteButton.setFont( JFaceResources.getDialogFont() ); |
| 285 |
setButtonLayoutData( fDeleteButton ); |
| 286 |
fDeleteButton.addSelectionListener( new SelectionAdapter() { |
| 287 |
|
| 288 |
@Override |
| 289 |
public void widgetSelected( SelectionEvent e ) { |
| 290 |
deleteEntries(); |
| 291 |
} |
| 292 |
} ); |
| 293 |
|
| 294 |
table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); |
| 295 |
table.setHeaderVisible( true ); |
| 296 |
table.setLinesVisible( true ); |
| 297 |
|
| 298 |
TableViewerColumn commandColumn = new TableViewerColumn( fViewer, SWT.LEFT ); |
| 299 |
commandColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Command_column_name ); |
| 300 |
commandColumn.setLabelProvider( createCommandLabelProvider() ); |
| 301 |
commandColumn.setEditingSupport( createCommandEditingSupport( fViewer ) ); |
| 302 |
|
| 303 |
TableViewerColumn timeoutColumn = new TableViewerColumn( fViewer, SWT.LEFT ); |
| 304 |
timeoutColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Timeout_column_name ); |
| 305 |
timeoutColumn.setLabelProvider( createTimeoutLabelProvider() ); |
| 306 |
timeoutColumn.setEditingSupport( createTimeoutEditingSupport( fViewer ) ); |
| 307 |
|
| 308 |
fViewer.setContentProvider( createCustomTimeoutsContentProvider() ); |
| 309 |
|
| 310 |
table.addControlListener( new ControlAdapter() { |
| 311 |
|
| 312 |
@Override |
| 313 |
public void controlResized( ControlEvent e ) { |
| 314 |
Rectangle area = table.getClientArea(); |
| 315 |
if ( area.width > 0 ) { |
| 316 |
TableColumn[] cols = table.getColumns(); |
| 317 |
cols[0].setWidth( area.width * 50 / 100 ); |
| 318 |
cols[1].setWidth( area.width * 50 / 100 ); |
| 319 |
table.removeControlListener( this ); |
| 320 |
} |
| 321 |
} |
| 322 |
} ); |
| 323 |
|
| 324 |
fViewer.setInput( fEntries ); |
| 325 |
|
| 326 |
updateDialogButtons(); |
| 327 |
|
| 328 |
return control; |
| 329 |
} |
| 330 |
|
| 331 |
void updateDialogButtons() { |
| 332 |
if ( fViewer != null && fDeleteButton != null ) { |
| 333 |
fDeleteButton.setEnabled( !fViewer.getSelection().isEmpty() ); |
| 334 |
} |
| 335 |
Button okButton = getButton( IDialogConstants.OK_ID ); |
| 336 |
if ( okButton != null ) |
| 337 |
okButton.setEnabled( getErrorMessage() == null ); |
| 338 |
} |
| 339 |
|
| 340 |
void addNewEntry() { |
| 341 |
CommandTimeoutEntry newEntry = new CommandTimeoutEntry( "", Integer.valueOf( 0 ) ); //$NON-NLS-1$ |
| 342 |
fEntries.add( newEntry ); |
| 343 |
fViewer.refresh(); |
| 344 |
fViewer.setSelection( new StructuredSelection( newEntry ) ); |
| 345 |
validateEntry( newEntry ); |
| 346 |
updateDialogButtons(); |
| 347 |
fViewer.editElement( newEntry, 0 ); |
| 348 |
} |
| 349 |
|
| 350 |
void deleteEntries() { |
| 351 |
IStructuredSelection sel = (IStructuredSelection)fViewer.getSelection(); |
| 352 |
if ( !sel.isEmpty() ) |
| 353 |
fEntries.removeAll( sel.toList() ); |
| 354 |
fViewer.refresh(); |
| 355 |
validate(); |
| 356 |
updateDialogButtons(); |
| 357 |
} |
| 358 |
|
| 359 |
CustomTimeoutsMap getResult() { |
| 360 |
CustomTimeoutsMap map = new CustomTimeoutsMap(); |
| 361 |
for ( CommandTimeoutEntry entry : fEntries ) { |
| 362 |
map.put( entry.fCommand, entry.fTimeout ); |
| 363 |
} |
| 364 |
return map; |
| 365 |
} |
| 366 |
|
| 367 |
void validate() { |
| 368 |
for ( CommandTimeoutEntry entry : fEntries ) { |
| 369 |
validateEntry( entry ); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
void validateEntry( CommandTimeoutEntry entry ) { |
| 374 |
String errorMessage = fCommandValidator.isValid( entry.fCommand ); |
| 375 |
setErrorMessage( ( errorMessage != null ) ? |
| 376 |
errorMessage : fTimeoutValidator.isValid( entry.fTimeout.toString() ) ); |
| 377 |
} |
| 378 |
|
| 379 |
IStructuredContentProvider createCustomTimeoutsContentProvider() { |
| 380 |
return new IStructuredContentProvider() { |
| 381 |
|
| 382 |
@Override |
| 383 |
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { |
| 384 |
} |
| 385 |
|
| 386 |
@Override |
| 387 |
public void dispose() { |
| 388 |
} |
| 389 |
|
| 390 |
@Override |
| 391 |
public Object[] getElements( Object inputElement ) { |
| 392 |
if ( inputElement instanceof List<?> ) { |
| 393 |
@SuppressWarnings( "unchecked" ) |
| 394 |
List<CommandTimeoutEntry> list = (List<CommandTimeoutEntry>)inputElement; |
| 395 |
return list.toArray( new Object[list.size()] ); |
| 396 |
} |
| 397 |
return null; |
| 398 |
} |
| 399 |
}; |
| 400 |
} |
| 401 |
|
| 402 |
ColumnLabelProvider createCommandLabelProvider() { |
| 403 |
return new ColumnLabelProvider() { |
| 404 |
|
| 405 |
/* (non-Javadoc) |
| 406 |
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) |
| 407 |
*/ |
| 408 |
@Override |
| 409 |
public String getText( Object element ) { |
| 410 |
if ( element instanceof CommandTimeoutEntry ) { |
| 411 |
return ((CommandTimeoutEntry)element).fCommand; |
| 412 |
} |
| 413 |
return super.getText( element ); |
| 414 |
} |
| 415 |
}; |
| 416 |
} |
| 417 |
|
| 418 |
ColumnLabelProvider createTimeoutLabelProvider() { |
| 419 |
return new ColumnLabelProvider() { |
| 420 |
|
| 421 |
/* (non-Javadoc) |
| 422 |
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) |
| 423 |
*/ |
| 424 |
@Override |
| 425 |
public String getText( Object element ) { |
| 426 |
if ( element instanceof CommandTimeoutEntry ) { |
| 427 |
return ((CommandTimeoutEntry)element).fTimeout.toString(); |
| 428 |
} |
| 429 |
return super.getText( element ); |
| 430 |
} |
| 431 |
}; |
| 432 |
} |
| 433 |
|
| 434 |
EditingSupport createCommandEditingSupport( ColumnViewer viewer ) { |
| 435 |
return new AbstractEditingSupport( viewer ) { |
| 436 |
|
| 437 |
@Override |
| 438 |
boolean processValue( CommandTimeoutEntry entry, String value ) { |
| 439 |
entry.fCommand = value; |
| 440 |
return true; |
| 441 |
} |
| 442 |
|
| 443 |
@Override |
| 444 |
Object doGetValue( CommandTimeoutEntry entry ) { |
| 445 |
return entry.fCommand; |
| 446 |
} |
| 447 |
|
| 448 |
@Override |
| 449 |
ICellEditorValidator getValidator() { |
| 450 |
return fCommandValidator; |
| 451 |
} |
| 452 |
}; |
| 453 |
} |
| 454 |
|
| 455 |
EditingSupport createTimeoutEditingSupport( ColumnViewer viewer ) { |
| 456 |
return new AbstractEditingSupport( viewer ) { |
| 457 |
|
| 458 |
@Override |
| 459 |
boolean processValue( CommandTimeoutEntry entry, String value ) { |
| 460 |
try { |
| 461 |
entry.fTimeout = Integer.decode( value ); |
| 462 |
return true; |
| 463 |
} |
| 464 |
catch( NumberFormatException e ) { |
| 465 |
// Shouldn't happen, validator takes care of this case. |
| 466 |
} |
| 467 |
return false; |
| 468 |
} |
| 469 |
|
| 470 |
@Override |
| 471 |
Object doGetValue( CommandTimeoutEntry entry ) { |
| 472 |
return entry.fTimeout.toString(); |
| 473 |
} |
| 474 |
|
| 475 |
@Override |
| 476 |
ICellEditorValidator getValidator() { |
| 477 |
return fTimeoutValidator; |
| 478 |
} |
| 479 |
}; |
| 480 |
} |
| 481 |
} |
| 482 |
|
| 483 |
private IntegerWithBooleanFieldEditor fCommandTimeoutField; |
| 484 |
private Button fTimeoutAdvancedButton; |
| 485 |
|
| 486 |
private CustomTimeoutsMap fCustomTimeouts; |
| 487 |
|
| 61 |
public GdbDebugPreferencePage() { |
488 |
public GdbDebugPreferencePage() { |
| 62 |
super(FLAT); |
489 |
super(FLAT); |
| 63 |
IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore(); |
490 |
IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore(); |
| 64 |
setPreferenceStore(store); |
491 |
setPreferenceStore(store); |
| 65 |
setDescription(MessagesForPreferences.GdbDebugPreferencePage_description); |
492 |
setDescription(MessagesForPreferences.GdbDebugPreferencePage_description); |
|
|
493 |
fCustomTimeouts = new CustomTimeoutsMap(); |
| 66 |
} |
494 |
} |
| 67 |
|
495 |
|
| 68 |
@Override |
496 |
@Override |
|
Lines 70-77
Link Here
|
| 70 |
} |
498 |
} |
| 71 |
|
499 |
|
| 72 |
@Override |
500 |
@Override |
|
|
501 |
protected void initialize() { |
| 502 |
super.initialize(); |
| 503 |
initializeCustomTimeouts(); |
| 504 |
} |
| 505 |
|
| 506 |
@Override |
| 73 |
public void createControl(Composite parent) { |
507 |
public void createControl(Composite parent) { |
| 74 |
super.createControl(parent); |
508 |
super.createControl(parent); |
|
|
509 |
updateTimeoutButtons(); |
| 75 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), |
510 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), |
| 76 |
GdbUIPlugin.PLUGIN_ID + ".dsfgdb_preference_page"); //$NON-NLS-1$ |
511 |
GdbUIPlugin.PLUGIN_ID + ".dsfgdb_preference_page"); //$NON-NLS-1$ |
| 77 |
} |
512 |
} |
|
Lines 91-134
Link Here
|
| 91 |
|
526 |
|
| 92 |
final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor( |
527 |
final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor( |
| 93 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, |
528 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, |
| 94 |
LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger"), //$NON-NLS-1$ |
529 |
"GDB debugger:", //$NON-NLS-1$ |
| 95 |
group1); |
530 |
group1); |
| 96 |
|
531 |
|
| 97 |
stringFieldEditorCommand.fillIntoGrid(group1, 2); |
532 |
stringFieldEditorCommand.fillIntoGrid(group1, 2); |
| 98 |
addField(stringFieldEditorCommand); |
533 |
addField(stringFieldEditorCommand); |
| 99 |
Button browsebutton = new Button(group1, SWT.PUSH); |
534 |
Button browsebutton = new Button(group1, SWT.PUSH); |
| 100 |
browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$ |
535 |
browsebutton.setText("&Browse..."); //$NON-NLS-1$ |
| 101 |
browsebutton.addSelectionListener(new SelectionAdapter() { |
536 |
browsebutton.addSelectionListener(new SelectionAdapter() { |
| 102 |
@Override |
537 |
@Override |
| 103 |
public void widgetSelected(SelectionEvent e) { |
538 |
public void widgetSelected(SelectionEvent e) { |
| 104 |
handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse_dlg_title"), //$NON-NLS-1$ |
539 |
handleBrowseButtonSelected("GDB Debugger", //$NON-NLS-1$ |
| 105 |
stringFieldEditorCommand); |
540 |
stringFieldEditorCommand); |
| 106 |
} |
541 |
} |
| 107 |
}); |
542 |
}); |
|
|
543 |
setButtonLayoutData( browsebutton ); |
| 108 |
|
544 |
|
| 109 |
final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor( |
545 |
final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor( |
| 110 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT, |
546 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT, |
| 111 |
LaunchUIMessages.getString("GDBDebuggerPage.gdb_command_file"), //$NON-NLS-1$ |
547 |
"GDB command file:", //$NON-NLS-1$ |
| 112 |
group1); |
548 |
group1); |
| 113 |
|
549 |
|
| 114 |
stringFieldEditorGdbInit.fillIntoGrid(group1, 2); |
550 |
stringFieldEditorGdbInit.fillIntoGrid(group1, 2); |
| 115 |
addField(stringFieldEditorGdbInit); |
551 |
addField(stringFieldEditorGdbInit); |
| 116 |
browsebutton = new Button(group1, SWT.PUSH); |
552 |
browsebutton = new Button(group1, SWT.PUSH); |
| 117 |
browsebutton.setText(LaunchUIMessages.getString("GDBDebuggerPage.gdb_browse")); //$NON-NLS-1$ |
553 |
browsebutton.setText("&Browse..."); //$NON-NLS-1$ |
| 118 |
browsebutton.addSelectionListener(new SelectionAdapter() { |
554 |
browsebutton.addSelectionListener(new SelectionAdapter() { |
| 119 |
@Override |
555 |
@Override |
| 120 |
public void widgetSelected(SelectionEvent e) { |
556 |
public void widgetSelected(SelectionEvent e) { |
| 121 |
handleBrowseButtonSelected(LaunchUIMessages.getString("GDBDebuggerPage.gdb_cmdfile_dlg_title"), //$NON-NLS-1$ |
557 |
handleBrowseButtonSelected("GDB Command File", //$NON-NLS-1$ |
| 122 |
stringFieldEditorGdbInit); |
558 |
stringFieldEditorGdbInit); |
| 123 |
} |
559 |
} |
| 124 |
}); |
560 |
}); |
|
|
561 |
setButtonLayoutData( browsebutton ); |
| 125 |
|
562 |
|
| 126 |
final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor( |
563 |
final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor( |
| 127 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, |
564 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, |
| 128 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, |
565 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, |
| 129 |
LaunchUIMessages.getString("CDebuggerTab.Stop_at_main_on_startup"), //$NON-NLS-1$ |
566 |
"Stop on startup at:", //$NON-NLS-1$ |
| 130 |
group1); |
567 |
group1); |
| 131 |
enableStopAtMain.fillIntoGrid(group1, 2); |
568 |
enableStopAtMain.fillIntoGrid(group1, 3); |
| 132 |
addField(enableStopAtMain); |
569 |
addField(enableStopAtMain); |
| 133 |
|
570 |
|
| 134 |
// final StringFieldEditor stopAtMainSymbol = new StringFieldEditor( |
571 |
// final StringFieldEditor stopAtMainSymbol = new StringFieldEditor( |
|
Lines 145-153
Link Here
|
| 145 |
// } |
582 |
// } |
| 146 |
// }); |
583 |
// }); |
| 147 |
|
584 |
|
|
|
585 |
fCommandTimeoutField = new IntegerWithBooleanFieldEditor( |
| 586 |
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, |
| 587 |
IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, |
| 588 |
MessagesForPreferences.GdbDebugPreferencePage_Command_timeout, |
| 589 |
group1); |
| 590 |
fCommandTimeoutField.setValidRange(1, Integer.MAX_VALUE); |
| 591 |
fCommandTimeoutField.fillIntoGrid(group1, 2); |
| 592 |
addField(fCommandTimeoutField); |
| 593 |
|
| 594 |
fTimeoutAdvancedButton = new Button(group1, SWT.PUSH); |
| 595 |
fTimeoutAdvancedButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Advanced_button); |
| 596 |
fTimeoutAdvancedButton.addSelectionListener(new SelectionAdapter() { |
| 597 |
@Override |
| 598 |
public void widgetSelected(SelectionEvent e) { |
| 599 |
handleAdvancedButtonSelected( |
| 600 |
"GDB Debugger"); //$NON-NLS-1$ |
| 601 |
} |
| 602 |
}); |
| 603 |
setButtonLayoutData( fTimeoutAdvancedButton ); |
| 604 |
|
| 148 |
final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor( |
605 |
final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor( |
| 149 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, |
606 |
IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, |
| 150 |
LaunchUIMessages.getString("GDBDebuggerPage.nonstop_mode"), //$NON-NLS-1$ |
607 |
"Non-stop mode (Note: Requires non-stop GDB)", //$NON-NLS-1$ |
| 151 |
SWT.NONE, group1); |
608 |
SWT.NONE, group1); |
| 152 |
enableNonStop.fillIntoGrid(group1, 3); |
609 |
enableNonStop.fillIntoGrid(group1, 3); |
| 153 |
addField(enableNonStop); |
610 |
addField(enableNonStop); |
|
Lines 286-293
Link Here
|
| 286 |
stringFieldEditor.setStringValue(res); |
743 |
stringFieldEditor.setStringValue(res); |
| 287 |
} |
744 |
} |
| 288 |
|
745 |
|
|
|
746 |
private void handleAdvancedButtonSelected(String dialogTitle) { |
| 747 |
AdvancedTimeoutSettingsDialog dialog = |
| 748 |
new AdvancedTimeoutSettingsDialog( getShell(), fCustomTimeouts.entrySet() ); |
| 749 |
if ( dialog.open() == Window.OK ) { |
| 750 |
fCustomTimeouts = dialog.getResult(); |
| 751 |
} |
| 752 |
} |
| 753 |
|
| 289 |
@Override |
754 |
@Override |
| 290 |
protected void adjustGridLayout() { |
755 |
protected void adjustGridLayout() { |
| 291 |
// do nothing |
756 |
// do nothing |
| 292 |
} |
757 |
} |
|
|
758 |
|
| 759 |
@Override |
| 760 |
public void propertyChange( PropertyChangeEvent event ) { |
| 761 |
if ( event.getSource().equals( fCommandTimeoutField ) && event.getNewValue() instanceof Boolean ) { |
| 762 |
fTimeoutAdvancedButton.setEnabled( ((Boolean)event.getNewValue()).booleanValue() ); |
| 763 |
} |
| 764 |
super.propertyChange( event ); |
| 765 |
} |
| 766 |
|
| 767 |
@Override |
| 768 |
protected void performDefaults() { |
| 769 |
IPreferenceStore store = getPreferenceStore(); |
| 770 |
if ( store != null ) { |
| 771 |
String memento = store.getDefaultString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS ); |
| 772 |
fCustomTimeouts.initializeFromMemento( memento ); |
| 773 |
} |
| 774 |
super.performDefaults(); |
| 775 |
updateTimeoutButtons(); |
| 776 |
} |
| 777 |
|
| 778 |
/* (non-Javadoc) |
| 779 |
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() |
| 780 |
*/ |
| 781 |
@Override |
| 782 |
public boolean performOk() { |
| 783 |
getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() ); |
| 784 |
return super.performOk(); |
| 785 |
} |
| 786 |
|
| 787 |
private void updateTimeoutButtons() { |
| 788 |
fTimeoutAdvancedButton.setEnabled( fCommandTimeoutField.getBooleanValue() ); |
| 789 |
} |
| 790 |
|
| 791 |
private void initializeCustomTimeouts() { |
| 792 |
IPreferenceStore store = getPreferenceStore(); |
| 793 |
if ( store != null ) { |
| 794 |
String memento = store.getString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS ); |
| 795 |
fCustomTimeouts.initializeFromMemento( memento ); |
| 796 |
} |
| 797 |
} |
| 293 |
} |
798 |
} |