1 11 package org.eclipse.ui.internal.dialogs; 12 13 import org.eclipse.jface.preference.PreferencePage; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.layout.GridData; 16 import org.eclipse.swt.layout.GridLayout; 17 import org.eclipse.swt.widgets.Button; 18 import org.eclipse.swt.widgets.Composite; 19 import org.eclipse.swt.widgets.Control; 20 import org.eclipse.ui.IWorkbench; 21 import org.eclipse.ui.IWorkbenchPreferencePage; 22 import org.eclipse.ui.internal.IPreferenceConstants; 23 import org.eclipse.ui.internal.WorkbenchPlugin; 24 import org.eclipse.ui.internal.activities.ws.ActivityEnabler; 25 import org.eclipse.ui.internal.activities.ws.ActivityMessages; 26 27 28 33 public class ActivitiesPreferencePage 34 extends PreferencePage 35 implements IWorkbenchPreferencePage { 36 37 38 private Button activityPromptButton; 39 private IWorkbench workbench; 40 private ActivityEnabler enabler; 41 42 47 protected void createActivityPromptPref(Composite composite) { 48 activityPromptButton = new Button(composite, SWT.CHECK); 49 activityPromptButton.setText(ActivityMessages 50 .getString("activityPromptButton")); activityPromptButton.setToolTipText(ActivityMessages 52 .getString("activityPromptToolTip")); 54 activityPromptButton.setFont(composite.getFont()); 55 setActivityButtonState(); 56 } 57 58 59 62 private void setActivityButtonState() { 63 activityPromptButton.setSelection(getPreferenceStore().getBoolean( 64 IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT)); 65 } 66 67 68 71 protected Control createContents(Composite parent) { 72 Composite composite = new Composite(parent, SWT.NONE); 73 GridLayout layout = new GridLayout(); 74 layout.marginHeight = 0; 75 layout.marginWidth = 0; 76 composite.setLayout(layout); 77 composite.setFont(parent.getFont()); 78 79 createActivityPromptPref(composite); 80 GridData data = new GridData(GridData.FILL_HORIZONTAL); 81 activityPromptButton.setLayoutData(data); 82 83 data = new GridData(GridData.FILL_BOTH); 84 enabler = new ActivityEnabler(workbench.getActivitySupport()); 85 enabler.createControl(composite).setLayoutData(data); 86 87 return composite; 88 } 89 90 93 public void init(IWorkbench aWorkbench) { 94 this.workbench = aWorkbench; 95 setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore()); 96 } 97 98 101 public boolean performOk() { 102 enabler.updateActivityStates(); 103 104 getPreferenceStore().setValue(IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT, activityPromptButton 105 .getSelection()); 106 107 return true; 108 } 109 112 protected void performDefaults() { 113 enabler.restoreDefaults(); 114 activityPromptButton.setSelection(getPreferenceStore().getDefaultBoolean(IPreferenceConstants.SHOULD_PROMPT_FOR_ENABLEMENT)); 115 super.performDefaults(); 116 } 117 } 118 | Popular Tags |