1 11 package org.eclipse.debug.internal.ui.preferences; 12 13 import org.eclipse.debug.internal.ui.DebugUIPlugin; 14 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 15 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 16 import org.eclipse.debug.internal.ui.SWTFactory; 17 import org.eclipse.debug.ui.IDebugUIConstants; 18 import org.eclipse.jface.dialogs.MessageDialogWithToggle; 19 import org.eclipse.jface.preference.BooleanFieldEditor; 20 import org.eclipse.jface.preference.FieldEditor; 21 import org.eclipse.jface.preference.FieldEditorPreferencePage; 22 import org.eclipse.jface.preference.IntegerFieldEditor; 23 import org.eclipse.jface.preference.RadioGroupFieldEditor; 24 import org.eclipse.jface.preference.StringFieldEditor; 25 import org.eclipse.swt.SWT; 26 import org.eclipse.swt.events.SelectionEvent; 27 import org.eclipse.swt.events.SelectionListener; 28 import org.eclipse.swt.layout.GridData; 29 import org.eclipse.swt.layout.GridLayout; 30 import org.eclipse.swt.widgets.Button; 31 import org.eclipse.swt.widgets.Composite; 32 import org.eclipse.swt.widgets.Control; 33 import org.eclipse.swt.widgets.Group; 34 import org.eclipse.ui.IWorkbench; 35 import org.eclipse.ui.IWorkbenchPreferencePage; 36 import org.eclipse.ui.PlatformUI; 37 38 import com.ibm.icu.text.MessageFormat; 39 40 45 public class LaunchingPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { 46 47 private Button fUseContextLaunching; 48 private Button fUseOldLaunching; 49 private Button fLaunchLastIfNotLaunchable; 50 private Button fCheckParent; 51 52 55 public LaunchingPreferencePage() { 56 super(); 57 setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore()); 58 } 59 60 63 public void createControl(Composite parent) { 64 super.createControl(parent); 65 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCHING_PREFERENCE_PAGE); 66 } 67 68 71 protected Control createContents(Composite parent) { 72 Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_HORIZONTAL); 73 FieldEditor edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_2, 3, 75 new String [][] {{DebugPreferencesMessages.LaunchingPreferencePage_3, MessageDialogWithToggle.ALWAYS}, 76 {DebugPreferencesMessages.LaunchingPreferencePage_4, MessageDialogWithToggle.NEVER}, 77 {DebugPreferencesMessages.LaunchingPreferencePage_5, MessageDialogWithToggle.PROMPT}}, 78 comp, 79 true); 80 addField(edit); 81 82 edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_WAIT_FOR_BUILD, 84 DebugPreferencesMessages.LaunchingPreferencePage_6, 3, 85 new String [][] {{DebugPreferencesMessages.LaunchingPreferencePage_7, MessageDialogWithToggle.ALWAYS}, 86 {DebugPreferencesMessages.LaunchingPreferencePage_8, MessageDialogWithToggle.NEVER}, 87 {DebugPreferencesMessages.LaunchingPreferencePage_9, MessageDialogWithToggle.PROMPT}}, 88 comp, 89 true); 90 addField(edit); 91 92 edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_RELAUNCH_IN_DEBUG_MODE, 94 DebugPreferencesMessages.LaunchingPreferencePage_15, 3, 95 new String [][] {{DebugPreferencesMessages.LaunchingPreferencePage_16, MessageDialogWithToggle.ALWAYS}, 96 {DebugPreferencesMessages.LaunchingPreferencePage_17, MessageDialogWithToggle.NEVER}, 97 {DebugPreferencesMessages.LaunchingPreferencePage_18, MessageDialogWithToggle.PROMPT}}, 98 comp, 99 true); 100 addField(edit); 101 102 edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR, 104 DebugPreferencesMessages.LaunchingPreferencePage_21, 2, 105 new String [][] {{DebugPreferencesMessages.LaunchingPreferencePage_22, MessageDialogWithToggle.ALWAYS}, 106 {DebugPreferencesMessages.LaunchingPreferencePage_23, MessageDialogWithToggle.PROMPT}}, 107 comp, 108 true); 109 addField(edit); 110 111 Group group = SWTFactory.createGroup(comp, DebugPreferencesMessages.LaunchingPreferencePage_36, 1, 1, GridData.FILL_HORIZONTAL); 113 Composite spacer = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL); 114 edit = new BooleanFieldEditor(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, DebugPreferencesMessages.LaunchingPreferencePage_1, SWT.NONE, spacer); 115 edit.fillIntoGrid(spacer, 2); 116 addField(edit); 117 edit = new BooleanFieldEditor(IDebugUIConstants.PREF_AUTO_REMOVE_OLD_LAUNCHES, DebugPreferencesMessages.LaunchingPreferencePage_10, SWT.NONE, spacer); 118 edit.fillIntoGrid(spacer, 2); 119 addField(edit); 120 121 IntegerFieldEditor editor = new IntegerFieldEditor(IDebugUIConstants.PREF_MAX_HISTORY_SIZE, DebugPreferencesMessages.DebugPreferencePage_10, spacer); 123 editor.fillIntoGrid(spacer, 2); 124 addField(editor); 125 int historyMax = IDebugPreferenceConstants.MAX_LAUNCH_HISTORY_SIZE; 126 editor.setTextLimit(Integer.toString(historyMax).length()); 127 editor.setErrorMessage(MessageFormat.format(DebugPreferencesMessages.DebugPreferencePage_11, new Object [] { new Integer (1), new Integer (historyMax)})); 128 editor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); 129 editor.setValidRange(1, historyMax); 130 editor.setEmptyStringAllowed(false); 131 132 createContextLaunchingControls(comp); 134 initialize(); 135 checkState(); 136 return comp; 137 } 138 139 147 private void createContextLaunchingControls(Composite parent) { 148 Group group = SWTFactory.createGroup(parent, DebugPreferencesMessages.LaunchingPreferencePage_40, 1, 1, GridData.FILL_HORIZONTAL); 149 fUseOldLaunching = SWTFactory.createRadioButton(group, DebugPreferencesMessages.LaunchingPreferencePage_37); 150 fUseContextLaunching = SWTFactory.createRadioButton(group, DebugPreferencesMessages.LaunchingPreferencePage_38); 151 fUseContextLaunching.addSelectionListener(new SelectionListener() { 152 public void widgetDefaultSelected(SelectionEvent e) {} 153 public void widgetSelected(SelectionEvent e) { 154 boolean enabled = ((Button)e.widget).getSelection(); 155 fCheckParent.setEnabled(enabled); 156 fLaunchLastIfNotLaunchable.setEnabled(enabled); 157 } 158 }); 159 Composite space = SWTFactory.createComposite(group, 1, 1, GridData.FILL_HORIZONTAL); 160 GridData gd = (GridData) space.getLayoutData(); 161 gd.horizontalIndent = 10; 162 GridLayout layout = (GridLayout) space.getLayout(); 163 layout.marginHeight = 0; 164 fCheckParent = SWTFactory.createRadioButton(space, DebugPreferencesMessages.LaunchingPreferencePage_39); 165 fLaunchLastIfNotLaunchable = SWTFactory.createRadioButton(space, DebugPreferencesMessages.LaunchingPreferencePage_41); 166 167 boolean value = getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH); 169 fUseOldLaunching.setSelection(!value); 170 fUseContextLaunching.setSelection(value); 171 boolean enable = getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT); 172 fCheckParent.setSelection(enable); 173 fCheckParent.setEnabled(value); 174 fLaunchLastIfNotLaunchable.setSelection(!enable); 175 fLaunchLastIfNotLaunchable.setEnabled(value); 176 } 177 178 181 public void init(IWorkbench workbench) {} 182 183 186 protected void performDefaults() { 187 boolean value = getPreferenceStore().getDefaultBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH); 188 fUseOldLaunching.setSelection(!value); 189 fUseContextLaunching.setSelection(value); 190 boolean parent = getPreferenceStore().getDefaultBoolean(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT); 191 fCheckParent.setSelection(parent); 192 fCheckParent.setEnabled(value); 193 fLaunchLastIfNotLaunchable.setSelection(!parent); 194 fLaunchLastIfNotLaunchable.setEnabled(value); 195 super.performDefaults(); 196 } 197 198 201 public boolean performOk() { 202 getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, fUseContextLaunching.getSelection()); 203 getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_LAUNCH_PARENT_PROJECT, fCheckParent.getSelection()); 204 getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE, fLaunchLastIfNotLaunchable.getSelection()); 205 return super.performOk(); 206 } 207 208 211 protected void createFieldEditors() { 212 } 214 } 215 | Popular Tags |