1 11 package org.eclipse.ui.internal.ide.application.dialogs; 12 13 import org.eclipse.jface.preference.IPreferenceStore; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.layout.GridData; 16 import org.eclipse.swt.widgets.Button; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Label; 20 import org.eclipse.ui.IWorkbenchPreferencePage; 21 import org.eclipse.ui.PlatformUI; 22 import org.eclipse.ui.internal.IWorkbenchHelpContextIds; 23 import org.eclipse.ui.internal.dialogs.StartupPreferencePage; 24 import org.eclipse.ui.internal.ide.ChooseWorkspaceData; 25 import org.eclipse.ui.internal.ide.IDEInternalPreferences; 26 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 27 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 28 29 36 public class IDEStartupPreferencePage extends StartupPreferencePage implements 37 IWorkbenchPreferencePage { 38 39 private Button refreshButton; 40 41 private Button launchPromptButton; 42 43 private Button exitPromptButton; 44 45 50 protected Control createContents(Composite parent) { 51 52 PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, 53 IWorkbenchHelpContextIds.STARTUP_PREFERENCE_PAGE); 54 55 Composite composite = createComposite(parent); 56 57 createLaunchPromptPref(composite); 58 createRefreshWorkspaceOnStartupPref(composite); 59 createExitPromptPref(composite); 60 61 Label space = new Label(composite,SWT.NONE); 62 space.setLayoutData(new GridData()); 63 64 createEarlyStartupSelection(composite); 65 66 return composite; 67 } 68 69 72 protected void performDefaults() { 73 IPreferenceStore store = getIDEPreferenceStore(); 74 75 launchPromptButton.setSelection(true); 76 77 refreshButton 78 .setSelection(store 79 .getDefaultBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP)); 80 exitPromptButton 81 .setSelection(store 82 .getDefaultBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW)); 83 84 super.performDefaults(); 85 } 86 87 90 public boolean performOk() { 91 IPreferenceStore store = getIDEPreferenceStore(); 92 93 store.setValue(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP, 95 refreshButton.getSelection()); 96 97 ChooseWorkspaceData.setShowDialogValue(launchPromptButton 103 .getSelection()); 104 105 store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, 107 exitPromptButton.getSelection()); 108 109 IDEWorkbenchPlugin.getDefault().savePluginPreferences(); 110 111 return super.performOk(); 112 } 113 114 protected void createRefreshWorkspaceOnStartupPref(Composite composite) { 115 refreshButton = new Button(composite, SWT.CHECK); 116 refreshButton.setText(IDEWorkbenchMessages.StartupPreferencePage_refreshButton); 117 refreshButton.setFont(composite.getFont()); 118 refreshButton.setSelection(getIDEPreferenceStore().getBoolean( 119 IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP)); 120 } 121 122 protected void createLaunchPromptPref(Composite composite) { 123 launchPromptButton = new Button(composite, SWT.CHECK); 124 launchPromptButton.setText(IDEWorkbenchMessages.StartupPreferencePage_launchPromptButton); 125 launchPromptButton.setFont(composite.getFont()); 126 127 launchPromptButton.setSelection(ChooseWorkspaceData 133 .getShowDialogValue()); 134 } 135 136 protected void createExitPromptPref(Composite composite) { 137 exitPromptButton = new Button(composite, SWT.CHECK); 138 exitPromptButton.setText(IDEWorkbenchMessages.StartupPreferencePage_exitPromptButton); 139 exitPromptButton.setFont(composite.getFont()); 140 exitPromptButton.setSelection(getIDEPreferenceStore().getBoolean( 141 IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW)); 142 } 143 144 147 protected IPreferenceStore getIDEPreferenceStore() { 148 return IDEWorkbenchPlugin.getDefault().getPreferenceStore(); 149 } 150 } 151 | Popular Tags |