3737import org .eclipse .swt .events .SelectionAdapter ;
3838import org .eclipse .swt .events .SelectionEvent ;
3939import org .eclipse .swt .layout .GridData ;
40+ import org .eclipse .swt .layout .GridLayout ;
4041import org .eclipse .swt .widgets .Button ;
4142import org .eclipse .swt .widgets .Combo ;
4243import org .eclipse .swt .widgets .Composite ;
44+ import org .eclipse .swt .widgets .Group ;
4345import org .eclipse .swt .widgets .Label ;
4446import org .eclipse .swt .widgets .Link ;
4547import org .eclipse .swt .widgets .Shell ;
@@ -93,7 +95,6 @@ protected void clearErrorMessage() {
9395 private ConsoleIntegerFieldEditor fBufferSizeEditor ;
9496
9597 private BooleanFieldEditor2 fLimitLines ;
96- private BooleanFieldEditor2 fLimitLineWrap ;
9798 private ConsoleIntegerFieldEditor fLimitLineLength ;
9899
99100 private ConsoleIntegerFieldEditor fTabSizeEditor ;
@@ -108,6 +109,10 @@ protected void clearErrorMessage() {
108109
109110 private Label fElapsedFormatPreviewLabel ;
110111
112+ private Group lineLimitGroup ;
113+ private Button cutConsoleLineButton ;
114+ private Button wrapConsoleLineButton ;
115+
111116 @ SuppressWarnings ("nls" )
112117 private static final String [] ELAPSED_FORMATS = new String [] { "H:MM:SS" , "HH:MM:SS" , "HH:MM:SS.mmm" , "MM:SS.mmm" ,
113118 "HHh MMm SSs" , DebugPreferencesMessages .ConsoleDisableElapsedTime .toString () };
@@ -169,24 +174,44 @@ public void widgetSelected(SelectionEvent e) {
169174 }
170175 );
171176
172- fLimitLines = new BooleanFieldEditor2 (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES , DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines , SWT .NONE , getFieldEditorParent ());
173- addField (fLimitLines );
174- fLimitLines .getChangeControl (getFieldEditorParent ()).addSelectionListener (
175- new SelectionAdapter () {
176- @ Override
177- public void widgetSelected (SelectionEvent e ) {
178- updateLineLimitControls ();
179- }
180- }
181- );
182-
183- fLimitLineWrap = new BooleanFieldEditor2 (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_WRAP , DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines_wrap , SWT .NONE , getFieldEditorParent ());
184- addField (fLimitLineWrap );
177+ lineLimitGroup = new Group (getFieldEditorParent (), SWT .LEFT );
178+ GridLayout layout = new GridLayout ();
179+ lineLimitGroup .setLayout (layout );
180+ GridData data = new GridData (GridData .FILL_HORIZONTAL | GridData .GRAB_HORIZONTAL );
181+ data .horizontalSpan = 2 ;
182+ lineLimitGroup .setLayoutData (data );
183+ lineLimitGroup .setText (DebugPreferencesMessages .ConsolePreferencePage_Limit_console_group );
185184
186- fLimitLineLength = new ConsoleIntegerFieldEditor (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_LENGTH , DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines_length , getFieldEditorParent ());
185+ fLimitLines = new BooleanFieldEditor2 (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES ,
186+ DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines , SWT .NONE , lineLimitGroup );
187+ addField (fLimitLines );
188+ fLimitLines .getChangeControl (lineLimitGroup ).addSelectionListener (new SelectionAdapter () {
189+ @ Override
190+ public void widgetSelected (SelectionEvent e ) {
191+ updateLineLimitControls ();
192+ }
193+ });
194+ fLimitLineLength = new ConsoleIntegerFieldEditor (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_LENGTH ,
195+ DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines_length , lineLimitGroup );
187196 fLimitLineLength .setValidRange (1 , Integer .MAX_VALUE - 100000 );
188197 addField (fLimitLineLength );
189198
199+ boolean hardWrapLines = getPreferenceStore ().getBoolean (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_WRAP );
200+ String label ;
201+
202+ label = DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines_cut ;
203+ cutConsoleLineButton = createRadioButton (lineLimitGroup , label );
204+ cutConsoleLineButton .setSelection (!hardWrapLines );
205+
206+ label = DebugPreferencesMessages .ConsolePreferencePage_Limit_console_lines_wrap ;
207+ wrapConsoleLineButton = createRadioButton (lineLimitGroup , label );
208+ wrapConsoleLineButton .setSelection (hardWrapLines );
209+
210+ // Restore margins after field editor constructors overwrote them with 0
211+ GridLayout groupLayout = (GridLayout ) lineLimitGroup .getLayout ();
212+ groupLayout .marginWidth = 5 ;
213+ groupLayout .marginHeight = 5 ;
214+
190215 fTabSizeEditor = new ConsoleIntegerFieldEditor (IDebugPreferenceConstants .CONSOLE_TAB_WIDTH , DebugPreferencesMessages .ConsolePreferencePage_12 , getFieldEditorParent ());
191216 addField (fTabSizeEditor );
192217 fTabSizeEditor .setValidRange (1 ,100 );
@@ -277,8 +302,10 @@ public void init(IWorkbench workbench) {
277302 @ Override
278303 public boolean performOk () {
279304 boolean ok = super .performOk ();
280- // update high water mark to be (about) 100 lines (100 * 80 chars) greater than low water mark
281305 IPreferenceStore store = DebugUIPlugin .getDefault ().getPreferenceStore ();
306+ store .setValue (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_WRAP , wrapConsoleLineButton .getSelection ());
307+
308+ // update high water mark to be (about) 100 lines (100 * 80 chars) greater than low water mark
282309 int low = store .getInt (IDebugPreferenceConstants .CONSOLE_LOW_WATER_MARK );
283310 int high = low + 8000 ;
284311 store .setValue (IDebugPreferenceConstants .CONSOLE_HIGH_WATER_MARK , high );
@@ -336,10 +363,11 @@ protected void updateBufferSizeEditor() {
336363 * console lines' editor.
337364 */
338365 protected void updateLineLimitControls () {
339- Button b = fLimitLines .getChangeControl (getFieldEditorParent ());
340- fLimitLineWrap .setEnabled (b .getSelection (), getFieldEditorParent ());
341- fLimitLineLength .getTextControl (getFieldEditorParent ()).setEnabled (b .getSelection ());
342- fLimitLineLength .getLabelControl (getFieldEditorParent ()).setEnabled (b .getSelection ());
366+ boolean enableLimit = fLimitLines .getBooleanValue ();
367+ wrapConsoleLineButton .setEnabled (enableLimit );
368+ cutConsoleLineButton .setEnabled (enableLimit );
369+ fLimitLineLength .getTextControl (lineLimitGroup ).setEnabled (enableLimit );
370+ fLimitLineLength .getLabelControl (lineLimitGroup ).setEnabled (enableLimit );
343371 }
344372
345373 /**
@@ -365,6 +393,12 @@ protected void updateWordWrapEditorFromConsolePreferences() {
365393 @ Override
366394 protected void performDefaults () {
367395 super .performDefaults ();
396+
397+ boolean hardWrapLines = getPreferenceStore ()
398+ .getDefaultBoolean (IDebugPreferenceConstants .CONSOLE_LIMIT_LINES_WRAP );
399+ wrapConsoleLineButton .setSelection (hardWrapLines );
400+ cutConsoleLineButton .setSelection (!hardWrapLines );
401+
368402 updateWidthEditor ();
369403 updateBufferSizeEditor ();
370404 updateLineLimitControls ();
@@ -473,4 +507,18 @@ public void widgetSelected(SelectionEvent e) {
473507 link .setLayoutData (gridData );
474508 SWTFactory .createVerticalSpacer (getFieldEditorParent (), 2 );
475509 }
510+
511+ /**
512+ * Utility method that creates a radio button instance and sets the default
513+ * layout data.
514+ *
515+ * @param parent the parent for the new button
516+ * @param label the label for the new button
517+ * @return the newly-created button
518+ */
519+ protected static Button createRadioButton (Composite parent , String label ) {
520+ Button button = new Button (parent , SWT .RADIO | SWT .LEFT );
521+ button .setText (label );
522+ return button ;
523+ }
476524}
0 commit comments