View | Details | Raw Unified | Return to bug 317125 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java (-24 / +25 lines)
Lines 443-472 Link Here
443
	public static String WorkbenchPreference_RunInBackgroundToolTip;
443
	public static String WorkbenchPreference_RunInBackgroundToolTip;
444
444
445
	// --- Appearance ---
445
	// --- Appearance ---
446
	public static String ViewsPreference_currentPresentation;
446
	public static String ViewsPreferencePage_Theme;
447
	public static String ViewsPreference_currentPresentationFormat;
447
	// public static String ViewsPreference_currentPresentation;
448
	public static String ViewsPreference_presentationConfirm_title;
448
	// public static String ViewsPreference_currentPresentationFormat;
449
	public static String ViewsPreference_presentationConfirm_message;
449
	// public static String ViewsPreference_presentationConfirm_title;
450
	public static String ViewsPreference_presentationConfirm_yes;
450
	// public static String ViewsPreference_presentationConfirm_message;
451
	public static String ViewsPreference_presentationConfirm_no;
451
	// public static String ViewsPreference_presentationConfirm_yes;
452
	public static String ViewsPreference_editors;
452
	// public static String ViewsPreference_presentationConfirm_no;
453
	public static String ViewsPreference_editors_top;
453
	// public static String ViewsPreference_editors;
454
	public static String ViewsPreference_editors_bottom;
454
	// public static String ViewsPreference_editors_top;
455
	public static String ViewsPreference_views;
455
	// public static String ViewsPreference_editors_bottom;
456
	public static String ViewsPreference_views_top;
456
	// public static String ViewsPreference_views;
457
	public static String ViewsPreference_views_bottom;
457
	// public static String ViewsPreference_views_top;
458
	public static String ViewsPreference_perspectiveBar;
458
	// public static String ViewsPreference_views_bottom;
459
	public static String ViewsPreference_perspectiveBar_topRight;
459
	// public static String ViewsPreference_perspectiveBar;
460
	public static String ViewsPreference_perspectiveBar_topLeft;
460
	// public static String ViewsPreference_perspectiveBar_topRight;
461
	public static String ViewsPreference_perspectiveBar_left;
461
	// public static String ViewsPreference_perspectiveBar_topLeft;
462
	public static String ViewsPreference_traditionalTabs;
462
	// public static String ViewsPreference_perspectiveBar_left;
463
	public static String ViewsPreference_currentTheme;
463
	// public static String ViewsPreference_traditionalTabs;
464
	public static String ViewsPreference_currentThemeDescription;
464
	// public static String ViewsPreference_currentTheme;
465
	public static String ViewsPreference_currentThemeFormat;
465
	// public static String ViewsPreference_currentThemeDescription;
466
	public static String ViewsPreference_enableAnimations;
466
	// public static String ViewsPreference_currentThemeFormat;
467
	public static String ViewsPreference_useColoredLabels;
467
	// public static String ViewsPreference_enableAnimations;
468
	public static String ViewsPreference_override;
468
	// public static String ViewsPreference_useColoredLabels;
469
	public static String ViewsPreference_restartRequestJobName;
469
	// public static String ViewsPreference_override;
470
	// public static String ViewsPreference_restartRequestJobName;
470
	
471
	
471
	// --- File Editors ---
472
	// --- File Editors ---
472
	public static String FileEditorPreference_fileTypes;
473
	public static String FileEditorPreference_fileTypes;
(-)Eclipse UI/org/eclipse/ui/internal/messages.properties (-25 / +26 lines)
Lines 395-425 Link Here
395
      
395
      
396
396
397
# --- Appearance ---
397
# --- Appearance ---
398
ViewsPreference_currentPresentation = Current &presentation:
398
ViewsPreferencePage_Theme=Theme
399
ViewsPreference_currentPresentationFormat = {0} (current)
399
#ViewsPreference_currentPresentation = Current &presentation:
400
ViewsPreference_presentationConfirm_title = Confirm Presentation Change
400
#ViewsPreference_currentPresentationFormat = {0} (current)
401
ViewsPreference_presentationConfirm_message =\
401
#ViewsPreference_presentationConfirm_title = Confirm Presentation Change
402
Changing the presentation settings will require restarting the workbench to complete the change.  Restart now?
402
#ViewsPreference_presentationConfirm_message =\
403
ViewsPreference_presentationConfirm_yes = Yes
403
#Changing the presentation settings will require restarting the workbench to complete the change.  Restart now?
404
ViewsPreference_presentationConfirm_no = No
404
#ViewsPreference_presentationConfirm_yes = Yes
405
ViewsPreference_editors = Editor tab positions
405
#ViewsPreference_presentationConfirm_no = No
406
ViewsPreference_editors_top = &Top
406
#ViewsPreference_editors = Editor tab positions
407
ViewsPreference_editors_bottom = &Bottom
407
#ViewsPreference_editors_top = &Top
408
ViewsPreference_views = View tab positions
408
#ViewsPreference_editors_bottom = &Bottom
409
ViewsPreference_views_top = T&op
409
#ViewsPreference_views = View tab positions
410
ViewsPreference_views_bottom = Botto&m
410
#ViewsPreference_views_top = T&op
411
ViewsPreference_perspectiveBar = Perspective switcher positions
411
#ViewsPreference_views_bottom = Botto&m
412
ViewsPreference_perspectiveBar_topRight = Top &Right
412
#ViewsPreference_perspectiveBar = Perspective switcher positions
413
ViewsPreference_perspectiveBar_topLeft = Top L&eft
413
#ViewsPreference_perspectiveBar_topRight = Top &Right
414
ViewsPreference_perspectiveBar_left = &Left
414
#ViewsPreference_perspectiveBar_topLeft = Top L&eft
415
ViewsPreference_traditionalTabs = &Show traditional style tabs
415
#ViewsPreference_perspectiveBar_left = &Left
416
ViewsPreference_currentTheme = &Current theme:
416
#ViewsPreference_traditionalTabs = &Show traditional style tabs
417
ViewsPreference_currentThemeDescription = Descr&iption:
417
#ViewsPreference_currentTheme = &Current theme:
418
ViewsPreference_override=O&verride presentation settings
418
#ViewsPreference_currentThemeDescription = Descr&iption:
419
ViewsPreference_currentThemeFormat = {0} (current)
419
#ViewsPreference_override=O&verride presentation settings
420
ViewsPreference_enableAnimations = Enable a&nimations
420
#ViewsPreference_currentThemeFormat = {0} (current)
421
ViewsPreference_useColoredLabels = Use mixe&d fonts and colors for labels
421
#ViewsPreference_enableAnimations = Enable a&nimations
422
ViewsPreference_restartRequestJobName = Restart Request
422
#ViewsPreference_useColoredLabels = Use mixe&d fonts and colors for labels
423
#ViewsPreference_restartRequestJobName = Restart Request
423
424
424
# --- File Editors ---
425
# --- File Editors ---
425
FileEditorPreference_fileTypes = File &types:
426
FileEditorPreference_fileTypes = File &types:
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java (-1100 / +57 lines)
Lines 11-71 Link Here
11
11
12
package org.eclipse.ui.internal.dialogs;
12
package org.eclipse.ui.internal.dialogs;
13
13
14
import java.util.Arrays;
14
import org.eclipse.e4.core.contexts.IEclipseContext;
15
import java.util.Comparator;
15
import org.eclipse.e4.ui.css.swt.theme.ITheme;
16
import java.util.Locale;
16
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
17
17
import org.eclipse.e4.ui.internal.workbench.swt.E4Application;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.core.runtime.Status;
23
import org.eclipse.jface.dialogs.Dialog;
24
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.jface.preference.IPreferenceStore;
27
import org.eclipse.jface.preference.PreferencePage;
18
import org.eclipse.jface.preference.PreferencePage;
28
import org.eclipse.jface.util.IPropertyChangeListener;
19
import org.eclipse.jface.viewers.ArrayContentProvider;
29
import org.eclipse.jface.util.PropertyChangeEvent;
20
import org.eclipse.jface.viewers.ComboViewer;
30
import org.eclipse.jface.window.Window;
21
import org.eclipse.jface.viewers.ISelectionChangedListener;
31
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.LabelProvider;
24
import org.eclipse.jface.viewers.SelectionChangedEvent;
25
import org.eclipse.jface.viewers.StructuredSelection;
32
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.accessibility.AccessibleAdapter;
34
import org.eclipse.swt.accessibility.AccessibleEvent;
35
import org.eclipse.swt.events.SelectionAdapter;
36
import org.eclipse.swt.events.SelectionEvent;
37
import org.eclipse.swt.events.SelectionListener;
38
import org.eclipse.swt.graphics.GC;
39
import org.eclipse.swt.layout.FormAttachment;
40
import org.eclipse.swt.layout.FormData;
41
import org.eclipse.swt.layout.FormLayout;
42
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridData;
43
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.layout.GridLayout;
44
import org.eclipse.swt.widgets.Button;
45
import org.eclipse.swt.widgets.Combo;
46
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Control;
48
import org.eclipse.swt.widgets.Group;
49
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Label;
50
import org.eclipse.swt.widgets.Text;
51
import org.eclipse.ui.IWorkbench;
32
import org.eclipse.ui.IWorkbench;
52
import org.eclipse.ui.IWorkbenchPreferenceConstants;
53
import org.eclipse.ui.IWorkbenchPreferencePage;
33
import org.eclipse.ui.IWorkbenchPreferencePage;
54
import org.eclipse.ui.PlatformUI;
55
import org.eclipse.ui.internal.IPreferenceConstants;
56
import org.eclipse.ui.internal.IWorkbenchConstants;
57
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
58
import org.eclipse.ui.internal.WorkbenchMessages;
34
import org.eclipse.ui.internal.WorkbenchMessages;
59
import org.eclipse.ui.internal.WorkbenchPlugin;
60
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
61
import org.eclipse.ui.internal.themes.IThemeDescriptor;
62
import org.eclipse.ui.internal.util.PrefUtil;
63
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
64
import org.eclipse.ui.progress.UIJob;
65
import org.eclipse.ui.themes.ITheme;
66
import org.eclipse.ui.themes.IThemeManager;
67
68
import com.ibm.icu.text.Collator;
69
35
70
/**
36
/**
71
 * The ViewsPreferencePage is the page used to set preferences for the
37
 * The ViewsPreferencePage is the page used to set preferences for the
Lines 74-1157 Link Here
74
 */
40
 */
75
public class ViewsPreferencePage extends PreferencePage implements
41
public class ViewsPreferencePage extends PreferencePage implements
76
		IWorkbenchPreferencePage {
42
		IWorkbenchPreferencePage {
43
	private IThemeEngine engine;
44
	private ComboViewer themeIdCombo;
45
	private ITheme currentTheme;
46
	private String defaultTheme;
77
47
78
	private Button showTextOnPerspectiveBar;
48
	@Override
79
80
	/*
81
	 * change the tab style of the workbench
82
	 */
83
	private Button showTraditionalStyleTabs;
84
85
	private Button enableAnimations;
86
87
	private Button useColoredLabels;
88
89
	private Button editorTopButton;
90
91
	private Button editorBottomButton;
92
93
	private Button viewTopButton;
94
95
	private Button viewBottomButton;
96
97
	private Button perspLeftButton;
98
99
	private Button perspTopLeftButton;
100
101
	private Button perspTopRightButton;
102
103
	static final String EDITORS_TITLE = WorkbenchMessages.ViewsPreference_editors;
104
105
	private static final String EDITORS_TOP_TITLE = WorkbenchMessages.ViewsPreference_editors_top;
106
107
	private static final String EDITORS_BOTTOM_TITLE = WorkbenchMessages.ViewsPreference_editors_bottom;
108
109
	private static final String VIEWS_TITLE = WorkbenchMessages.ViewsPreference_views;
110
111
	private static final String VIEWS_TOP_TITLE = WorkbenchMessages.ViewsPreference_views_top;
112
113
	private static final String VIEWS_BOTTOM_TITLE = WorkbenchMessages.ViewsPreference_views_bottom;
114
115
	private static final String PERSP_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar;
116
117
	private static final String PERSP_LEFT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_left;
118
119
	private static final String PERSP_TOP_LEFT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_topLeft;
120
121
	private static final String PERSP_TOP_RIGHT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_topRight;
122
123
	// These constants aren't my favourite idea, but to get this preference done
124
	// for M9... A better solution might be to have the presentation factory set
125
	// its dependant preference defaults on startup. I've filed bug 63346 to do
126
	// something about this area.
127
	private static final String R21PRESENTATION_ID = "org.eclipse.ui.internal.r21presentationFactory"; //$NON-NLS-1$
128
	private static final String DEFAULT_PRESENTATION_ID = IWorkbenchConstants.DEFAULT_PRESENTATION_ID;
129
	private static final String R30_PRESENTATION_ID = "org.eclipse.ui.presentations.r30"; //$NON-NLS-1$
130
131
	private static final String INITIAL_VAL = new String();
132
133
	private static final int INITIAL_LOC_INT = -1;
134
135
	// remembers whether the hidden fastview bar pref needs to be changed on
136
	// OK/Apply
137
	private String fastViewLoc = INITIAL_VAL;
138
139
	private String showTextOnPerspBar = INITIAL_VAL;
140
141
	private int editorAlignment;
142
143
	private boolean editorAlignmentChanged = false;
144
145
	private int viewAlignment;
146
147
	private boolean viewAlignmentChanged = false;
148
149
	private String perspBarLocation;
150
151
	private Combo themeCombo;
152
153
	private Combo presentationCombo;
154
155
	private IConfigurationElement[] presentationFactories;
156
157
	private String currentPresentationFactoryId;
158
159
	private Button overridePresButton;
160
161
	private IPropertyChangeListener overrideListener;
162
163
	private boolean restartPosted = false;
164
165
	private Group editorTabGroup;
166
167
	private Group viewTabGroup;
168
169
	private Group perspBarTabGroup;
170
171
	private Text themeDescriptionText;
172
173
	/**
174
	 * Create a composite that for creating the tab toggle buttons.
175
	 * 
176
	 * @param composite
177
	 *            Composite
178
	 * @param title
179
	 *            String
180
	 */
181
	private Group createButtonGroup(Composite composite, String title) {
182
		Group buttonComposite = new Group(composite, SWT.NONE);
183
		buttonComposite.setText(title);
184
		FormLayout layout = new FormLayout();
185
		layout.marginWidth = 5; // same as GridData default
186
		layout.marginHeight = 5; // same as GridData default
187
		buttonComposite.setLayout(layout);
188
		buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
189
				false));
190
		return buttonComposite;
191
	}
192
193
	/**
194
	 * Creates and returns the SWT control for the customized body of this
195
	 * preference page under the given parent composite.
196
	 * <p>
197
	 * This framework method must be implemented by concrete subclasses.
198
	 * </p>
199
	 * 
200
	 * @param parent
201
	 *            the parent composite
202
	 * @return Control the new control
203
	 */
204
	protected Control createContents(Composite parent) {
49
	protected Control createContents(Composite parent) {
205
		initializeDialogUnits(parent);
50
		Composite comp = new Composite(parent, SWT.NONE);
206
51
		comp.setLayout(new GridLayout(2, false));
207
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
52
		new Label(comp, SWT.NONE).setText(WorkbenchMessages.ViewsPreferencePage_Theme);
208
				IWorkbenchHelpContextIds.VIEWS_PREFERENCE_PAGE);
209
210
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
211
212
		editorAlignment = apiStore
213
				.getInt(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
214
		viewAlignment = apiStore
215
				.getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
216
		perspBarLocation = apiStore
217
				.getString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
218
219
		Composite composite = new Composite(parent, SWT.NONE);
220
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
221
53
222
		GridLayout layout = new GridLayout();
54
		themeIdCombo = new ComboViewer(comp, SWT.READ_ONLY);
223
		layout.marginWidth = 0;
55
		themeIdCombo.setLabelProvider(new LabelProvider() {
224
		layout.marginHeight = 0;
56
			@Override
225
		layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
57
			public String getText(Object element) {
226
		composite.setLayout(layout);
58
				return ((ITheme) element).getLabel();
227
228
		createPresentationCombo(composite);
229
		createPresentationOverride(composite);
230
		createEditorTabButtonGroup(composite);
231
		createViewTabButtonGroup(composite);
232
		createPerspBarTabButtonGroup(composite);
233
		createShowTextOnPerspectiveBarPref(composite);
234
		createThemeCombo(composite);
235
		createThemeDescriptionText(composite);
236
		createShowTraditionalStyleTabsPref(composite);
237
		createEnableAnimationsPref(composite);
238
		createColoredLabelsPref(composite);
239
240
		updateOverride();
241
		hookOverrideListener();
242
243
		applyDialogFont(composite);
244
245
		return composite;
246
	}
247
248
	private void createColoredLabelsPref(Composite composite) {
249
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
250
251
		useColoredLabels = createCheckButton(
252
				composite,
253
				WorkbenchMessages.ViewsPreference_useColoredLabels,
254
				apiStore
255
						.getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
256
	}
257
258
	private void createThemeCombo(Composite composite) {
259
		new Label(composite, SWT.NONE)
260
				.setText(WorkbenchMessages.ViewsPreference_currentTheme);
261
		themeCombo = new Combo(composite, SWT.READ_ONLY);
262
		themeCombo
263
				.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
264
		themeCombo.addSelectionListener(new SelectionAdapter() {
265
			public void widgetSelected(SelectionEvent e) {
266
				refreshThemeDescriptionText();
267
			}
59
			}
268
		});
60
		});
269
		refreshThemeCombo(PlatformUI.getWorkbench().getThemeManager()
61
		themeIdCombo.setContentProvider(new ArrayContentProvider());
270
				.getCurrentTheme().getId());
62
		themeIdCombo.setInput(engine.getThemes());
271
	}
63
		themeIdCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
272
64
		this.currentTheme = engine.getActiveTheme();
273
	/**
65
		themeIdCombo.setSelection(new StructuredSelection(currentTheme));
274
	 * Create the text box that will contain the current theme description text
66
		themeIdCombo.addSelectionChangedListener(new ISelectionChangedListener() {
275
	 * (if any).
276
	 * 
277
	 * @param parent
278
	 *            the parent <code>Composite</code>.
279
	 */
280
	private void createThemeDescriptionText(Composite parent) {
281
		new Label(parent, SWT.NONE)
282
				.setText(WorkbenchMessages.ViewsPreference_currentThemeDescription);
283
284
		themeDescriptionText = new Text(parent, SWT.H_SCROLL | SWT.V_SCROLL
285
				| SWT.READ_ONLY | SWT.BORDER | SWT.WRAP);
286
		GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
287
		// give a height hint that'll show at least two lines (and let the
288
		// scroll bars draw nicely if necessary)
289
		GC gc = new GC(parent);
290
		layoutData.heightHint = Dialog.convertHeightInCharsToPixels(gc
291
				.getFontMetrics(), 2);
292
		gc.dispose();
293
		themeDescriptionText.setLayoutData(layoutData);
294
295
		refreshThemeDescriptionText();
296
	}
297
298
	private void refreshThemeDescriptionText() {
299
		String description = null;
300
		int idx = themeCombo.getSelectionIndex();
301
		// idx == 0 is "Default" which has no description
302
		if (idx > 0) {
303
			IThemeDescriptor theme = WorkbenchPlugin.getDefault()
304
					.getThemeRegistry().getThemes()[idx - 1];
305
			description = theme.getDescription();
306
		}
307
		if (description == null) {
308
			description = ""; //$NON-NLS-1$
309
		}
310
		themeDescriptionText.setText(description);
311
	}
312
313
	private Button createCheckButton(Composite composite, String text,
314
			boolean selection) {
315
		Button button = new Button(composite, SWT.CHECK);
316
		button.setText(text);
317
		button.setSelection(selection);
318
		return button;
319
	}
320
321
	private void createPresentationOverride(Composite parent) {
322
		IPreferenceStore store = getPreferenceStore();
323
		boolean override = store
324
				.getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
325
326
		// workaround to catch the case where the show text value was changed
327
		// outside of this page
328
		// turn off text on persp bar
329
		boolean showText = PrefUtil.getAPIPreferenceStore().getBoolean(
330
				IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR);
331
		if (showText && isR21(currentPresentationFactoryId) || !showText
332
				&& isR30(currentPresentationFactoryId)) {
333
			if (!override) {
334
				store
335
						.setValue(IPreferenceConstants.OVERRIDE_PRESENTATION,
336
								true);
337
				override = true;
338
			}
339
		}
340
		// workaround to catch the case where the perspective switcher location
341
		// was changed outside of this page
342
		// turn off text on persp bar
343
		String barLocation = PrefUtil.getAPIPreferenceStore().getString(
344
				IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
345
		if (!barLocation.equals(IWorkbenchPreferenceConstants.LEFT)
346
				&& isR21(currentPresentationFactoryId)
347
				|| !barLocation.equals(IWorkbenchPreferenceConstants.TOP_RIGHT)
348
				&& isR30(currentPresentationFactoryId)) {
349
			if (!override) {
350
				store
351
						.setValue(IPreferenceConstants.OVERRIDE_PRESENTATION,
352
								true);
353
				override = true;
354
			}
355
		}
356
67
357
		overridePresButton = createCheckButton(parent,
68
			public void selectionChanged(SelectionChangedEvent event) {
358
				WorkbenchMessages.ViewsPreference_override, override);
69
				engine.setTheme(getSelection(), false);
359
		overridePresButton.addSelectionListener(new SelectionListener() {
360
			public void widgetSelected(SelectionEvent e) {
361
				updateOverrideState(overridePresButton.getSelection());
362
			}
363
364
			public void widgetDefaultSelected(SelectionEvent e) {
365
				updateOverrideState(overridePresButton.getSelection());
366
			}
70
			}
367
		});
71
		});
368
	}
369
72
370
	private void updateOverrideState(boolean override) {
73
		return comp;
371
		IPreferenceStore store = getPreferenceStore();
372
		if (store.getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION) != override) {
373
			store
374
					.setValue(IPreferenceConstants.OVERRIDE_PRESENTATION,
375
							override);
376
		}
377
		// as we are no longer overriding the prefs should match the selected
378
		// presentation
379
		if (!override)
380
			setPresentationPrefs(getSelectedPresentationID());
381
	}
74
	}
382
75
383
	private void createPresentationCombo(Composite parent) {
76
	private ITheme getSelection() {
384
		new Label(parent, SWT.NONE)
77
		return (ITheme) ((IStructuredSelection) themeIdCombo.getSelection()).getFirstElement();
385
				.setText(WorkbenchMessages.ViewsPreference_currentPresentation);
386
387
		presentationCombo = new Combo(parent, SWT.READ_ONLY);
388
		presentationCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
389
				true, false));
390
		presentationCombo.addSelectionListener(new SelectionListener() {
391
392
			public void widgetSelected(SelectionEvent e) {
393
				updateSettings();
394
			}
395
396
			public void widgetDefaultSelected(SelectionEvent e) {
397
				updateSettings();
398
			}
399
400
			private void updateSettings() {
401
				if (!overridePresButton.getSelection()) {
402
					setPresentationPrefs(getSelectedPresentationID());
403
				}
404
			}
405
		});
406
407
		refreshPresentationCombo();
408
		setPresentationSelection();
409
	}
78
	}
410
79
411
	/**
80
	public void init(IWorkbench workbench) {
412
	 * Set the two supplied controls to be beside each other.
81
		IEclipseContext context = (IEclipseContext) workbench.getService(IEclipseContext.class);
413
	 */
82
		defaultTheme = (String) context.get(E4Application.THEME_ID);
414
	private void attachControls(Control leftControl, Control rightControl) {
83
		engine = context.get(IThemeEngine.class);
415
		FormData leftData = new FormData();
416
		leftData.left = new FormAttachment(0, 0);
417
418
		FormData rightData = new FormData();
419
		rightData.left = new FormAttachment(
420
				leftControl,
421
				convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING));
422
423
		leftControl.setLayoutData(leftData);
424
		rightControl.setLayoutData(rightData);
425
	}
426
427
	/**
428
	 * Create a composite that contains buttons for selecting tab position for
429
	 * the edit selection.
430
	 * 
431
	 * @param composite
432
	 *            Composite
433
	 */
434
	private void createEditorTabButtonGroup(Composite composite) {
435
		editorTabGroup = createButtonGroup(composite, EDITORS_TITLE);
436
437
		editorTopButton = new Button(editorTabGroup, SWT.RADIO);
438
		editorTopButton.setText(EDITORS_TOP_TITLE);
439
		editorTopButton.setSelection(editorAlignment == SWT.TOP);
440
		editorTopButton.getAccessible().addAccessibleListener(
441
				new AccessibleAdapter() {
442
					public void getName(AccessibleEvent e) {
443
						e.result = EDITORS_TITLE;
444
					}
445
				});
446
447
		editorBottomButton = new Button(editorTabGroup, SWT.RADIO);
448
		editorBottomButton.setText(EDITORS_BOTTOM_TITLE);
449
		editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
450
451
		SelectionListener sel = new SelectionAdapter() {
452
			public void widgetSelected(SelectionEvent e) {
453
				if (e.widget.equals(editorTopButton)) {
454
					if (editorAlignment != SWT.TOP) {
455
						editorAlignment = SWT.TOP;
456
						editorAlignmentChanged = true;
457
					}
458
				} else if (e.widget.equals(editorBottomButton)) {
459
					if (editorAlignment != SWT.BOTTOM) {
460
						editorAlignment = SWT.BOTTOM;
461
						editorAlignmentChanged = true;
462
					}
463
				}
464
			}
465
		};
466
467
		editorTopButton.addSelectionListener(sel);
468
		editorBottomButton.addSelectionListener(sel);
469
470
		attachControls(editorTopButton, editorBottomButton);
471
	}
472
473
	/**
474
	 * Create a composite that contains buttons for selecting tab position for
475
	 * the view selection.
476
	 * 
477
	 * @param composite
478
	 *            Composite
479
	 */
480
	private void createViewTabButtonGroup(Composite composite) {
481
		viewTabGroup = createButtonGroup(composite, VIEWS_TITLE);
482
483
		viewTopButton = new Button(viewTabGroup, SWT.RADIO);
484
		viewTopButton.setText(VIEWS_TOP_TITLE);
485
		viewTopButton.setSelection(this.viewAlignment == SWT.TOP);
486
487
		viewBottomButton = new Button(viewTabGroup, SWT.RADIO);
488
		viewBottomButton.setText(VIEWS_BOTTOM_TITLE);
489
		viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
490
491
		SelectionListener sel = new SelectionAdapter() {
492
			public void widgetSelected(SelectionEvent e) {
493
				if (e.widget.equals(viewTopButton)) {
494
					if (viewAlignment != SWT.TOP) {
495
						viewAlignment = SWT.TOP;
496
						viewAlignmentChanged = true;
497
					}
498
				} else if (e.widget.equals(viewBottomButton)) {
499
					if (viewAlignment != SWT.BOTTOM) {
500
						viewAlignment = SWT.BOTTOM;
501
						viewAlignmentChanged = true;
502
					}
503
				}
504
			}
505
		};
506
507
		viewTopButton.addSelectionListener(sel);
508
		viewBottomButton.addSelectionListener(sel);
509
510
		attachControls(viewTopButton, viewBottomButton);
511
	}
512
513
	/**
514
	 * Create a composite that contains buttons for selecting perspective
515
	 * switcher position.
516
	 * 
517
	 * @param composite
518
	 *            Composite
519
	 */
520
	private void createPerspBarTabButtonGroup(Composite composite) {
521
		perspBarTabGroup = createButtonGroup(composite, PERSP_TITLE);
522
523
		perspLeftButton = new Button(perspBarTabGroup, SWT.RADIO);
524
		perspLeftButton.setText(PERSP_LEFT_TITLE);
525
		perspLeftButton.setSelection(IWorkbenchPreferenceConstants.LEFT
526
				.equals(perspBarLocation));
527
		perspLeftButton.addSelectionListener(new SelectionAdapter() {
528
			public void widgetSelected(SelectionEvent e) {
529
				perspBarLocation = IWorkbenchPreferenceConstants.LEFT;
530
			}
531
		});
532
533
		perspTopLeftButton = new Button(perspBarTabGroup, SWT.RADIO);
534
		perspTopLeftButton.setText(PERSP_TOP_LEFT_TITLE);
535
		perspTopLeftButton.setSelection(IWorkbenchPreferenceConstants.TOP_LEFT
536
				.equals(perspBarLocation));
537
		perspTopLeftButton.addSelectionListener(new SelectionAdapter() {
538
			public void widgetSelected(SelectionEvent e) {
539
				perspBarLocation = IWorkbenchPreferenceConstants.TOP_LEFT;
540
			}
541
		});
542
543
		perspTopRightButton = new Button(perspBarTabGroup, SWT.RADIO);
544
		perspTopRightButton.setText(PERSP_TOP_RIGHT_TITLE);
545
		perspTopRightButton
546
				.setSelection(IWorkbenchPreferenceConstants.TOP_RIGHT
547
						.equals(perspBarLocation));
548
		perspTopRightButton.addSelectionListener(new SelectionAdapter() {
549
			public void widgetSelected(SelectionEvent e) {
550
				perspBarLocation = IWorkbenchPreferenceConstants.TOP_RIGHT;
551
			}
552
		});
553
554
		int spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
555
556
		FormData leftData = new FormData();
557
		leftData.left = new FormAttachment(0, 0);
558
559
		FormData topLeftData = new FormData();
560
		topLeftData.left = new FormAttachment(perspLeftButton, spacing);
561
562
		FormData topRightData = new FormData();
563
		topRightData.left = new FormAttachment(perspTopLeftButton, spacing);
564
565
		perspLeftButton.setLayoutData(leftData);
566
		perspTopLeftButton.setLayoutData(topLeftData);
567
		perspTopRightButton.setLayoutData(topRightData);
568
	}
569
570
	/**
571
	 * Hook a listener to update the buttons based on an override preference. If
572
	 * the preference is false then do not allow editing of these options.
573
	 * 
574
	 */
575
	private void hookOverrideListener() {
576
		if (overrideListener != null) {
577
			return;
578
		}
579
		IPreferenceStore store = getPreferenceStore();
580
		overrideListener = new IPropertyChangeListener() {
581
			public void propertyChange(PropertyChangeEvent event) {
582
				if (event.getProperty().equals(
583
						IPreferenceConstants.OVERRIDE_PRESENTATION)) {
584
					updateOverride();
585
				}
586
			}
587
		};
588
		store.addPropertyChangeListener(overrideListener);
589
	}
590
591
	/**
592
	 * Dispose resources created by the receiver.
593
	 */
594
	public void dispose() {
595
		super.dispose();
596
		if (overrideListener != null) {
597
			getPreferenceStore().removePropertyChangeListener(overrideListener);
598
			overrideListener = null;
599
		}
600
	}
601
602
	private void updateOverride() {
603
		boolean override = getPreferenceStore().getBoolean(
604
				IPreferenceConstants.OVERRIDE_PRESENTATION);
605
		editorTabGroup.setEnabled(override);
606
		editorTopButton.setEnabled(override);
607
		editorBottomButton.setEnabled(override);
608
		viewTabGroup.setEnabled(override);
609
		viewTopButton.setEnabled(override);
610
		viewBottomButton.setEnabled(override);
611
		perspBarTabGroup.setEnabled(override);
612
		perspTopLeftButton.setEnabled(override);
613
		perspLeftButton.setEnabled(override);
614
		perspTopRightButton.setEnabled(override);
615
		showTextOnPerspectiveBar.setEnabled(override);
616
	}
617
618
	private void refreshPresentationCombo() {
619
		// get the active presentation
620
		presentationCombo.removeAll();
621
		refreshPresentationFactories();
622
623
		for (int i = 0; i < presentationFactories.length; ++i) {
624
			IConfigurationElement el = presentationFactories[i];
625
			String name = el.getAttribute(IWorkbenchConstants.TAG_NAME);
626
			if (!currentPresentationFactoryId.equals(el
627
					.getAttribute(IWorkbenchConstants.TAG_ID))) {
628
				presentationCombo.add(name);
629
			} else {
630
				presentationCombo
631
						.add(NLS
632
								.bind(
633
										WorkbenchMessages.ViewsPreference_currentPresentationFormat,
634
										name));
635
			}
636
		}
637
	}
638
639
	private void setPresentationSelection() {
640
		for (int i = 0; i < presentationFactories.length; ++i) {
641
			if (currentPresentationFactoryId.equals(presentationFactories[i]
642
					.getAttribute(IWorkbenchConstants.TAG_ID))) {
643
				presentationCombo.select(i);
644
				return;
645
			}
646
		}
647
		// presentationCombo.select(0);
648
	}
649
650
	/**
651
	 * Update this page's list of presentation factories. This should only be
652
	 * used when the presentation combo is refreshed, as this array will be used
653
	 * to set the selection from the combo.
654
	 */
655
	private void refreshPresentationFactories() {
656
		// update the current selection (used to look for changes on apply)
657
		currentPresentationFactoryId = PrefUtil.getAPIPreferenceStore()
658
				.getString(
659
						IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
660
		// Workbench.getInstance().getPresentationId();
661
662
		// update the sorted list of factories
663
		presentationFactories = Platform.getExtensionRegistry()
664
				.getConfigurationElementsFor(PlatformUI.PLUGIN_ID,
665
						IWorkbenchRegistryConstants.PL_PRESENTATION_FACTORIES);
666
667
		// sort the array by name
668
		Arrays.sort(presentationFactories, new Comparator() {
669
			Collator collator = Collator.getInstance(Locale.getDefault());
670
671
			public int compare(Object a, Object b) {
672
				IConfigurationElement el1 = (IConfigurationElement) a;
673
				IConfigurationElement el2 = (IConfigurationElement) b;
674
				return collator.compare(el1
675
						.getAttribute(IWorkbenchConstants.TAG_NAME), el2
676
						.getAttribute(IWorkbenchConstants.TAG_NAME));
677
			}
678
		});
679
	}
680
681
	/**
682
	 * Update the preferences associated with the argument presentation factory.
683
	 * 
684
	 * @return boolean
685
	 *         <code>true<\code> of the presentation has changed and <code>false<\code> otherwise
686
	 */
687
	private boolean updatePresentationPreferences() {
688
		// There are some preference values associated with the R2.1
689
		// presentation that cannot be captured in the presentation
690
		// factory. Perhaps the extension point should contain these
691
		// (a list of attributes?), but for now it is done manually.
692
693
		if (presentationCombo == null) {
694
			return false;
695
		}
696
697
		String id = getSelectedPresentationID();
698
699
		// if it hasn't changed then there's nothing to do
700
		if (id.equals(currentPresentationFactoryId)) {
701
			return false;
702
		}
703
704
		currentPresentationFactoryId = id;
705
		// apply 2.1 prefs if needed
706
		setPresentationPrefs(id);
707
		// set the new presentation factory id
708
		PrefUtil.getAPIPreferenceStore().putValue(
709
				IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID, id);
710
		// a restart is required to update the presentation
711
		return true;
712
	}
713
714
	private void setPresentationPrefs(String id) {
715
		if (isR21(id)) {
716
			setR21Preferences();
717
		} else if (isR30(id)) {
718
			setR30Preferences();
719
		} else if (isR33(id)) {
720
			setR33Preferences();
721
		}
722
	}
723
724
	private boolean isR33(String id) {
725
		return DEFAULT_PRESENTATION_ID.equals(id);
726
	}
727
728
	private boolean isR30(String id) {
729
		return R30_PRESENTATION_ID.equals(id);
730
	}
731
732
	private boolean isR21(String id) {
733
		return R21PRESENTATION_ID.equals(id);
734
	}
735
736
	private String getSelectedPresentationID() {
737
		int selection = presentationCombo.getSelectionIndex();
738
		IConfigurationElement element = presentationFactories[selection];
739
		String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
740
		return id;
741
	}
742
743
	private void setR33Preferences() {
744
		setR30Preferences();
745
746
		// Turn -on- the new Min/Max behaviour
747
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
748
		apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX,
749
				true);
750
	}
751
752
	private void setR30Preferences() {
753
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
754
755
		// Turn -off- the new min/max behaviour
756
		apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX,
757
				false);
758
759
		setEditorAlignDefault(apiStore);
760
		setViewAlignDefault(apiStore);
761
762
		// perspective switcher on the left
763
		perspBarLocation = apiStore
764
				.getDefaultString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
765
		perspLeftButton.setSelection(perspBarLocation
766
				.equals(IWorkbenchPreferenceConstants.LEFT));
767
		perspTopLeftButton.setSelection(perspBarLocation
768
				.equals(IWorkbenchPreferenceConstants.TOP_LEFT));
769
		perspTopRightButton.setSelection(perspBarLocation
770
				.equals(IWorkbenchPreferenceConstants.TOP_RIGHT));
771
772
		// perspective bar should be set to default on OK or Apply
773
		perspBarLocation = INITIAL_VAL;
774
775
		// turn off text on persp bar
776
		showTextOnPerspectiveBar
777
				.setSelection(apiStore
778
						.getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
779
		// text on perspective bar should be set to default on OK or Apply
780
		showTextOnPerspBar = INITIAL_VAL;
781
782
		// fast view bar should be set to default on OK or Apply
783
		fastViewLoc = INITIAL_VAL;
784
	}
785
786
	/**
787
	 * Set the view alignment based on apiStore.
788
	 * @param apiStore
789
	 */
790
	private void setViewAlignDefault(IPreferenceStore apiStore) {
791
		int oldVal;
792
		// reset the preferences for 3.0 presentation
793
		oldVal = viewAlignment;
794
		viewAlignment = apiStore
795
				.getDefaultInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
796
		viewTopButton.setSelection(viewAlignment == SWT.TOP);
797
		viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
798
799
		// view tabs should be set to default on OK or Apply
800
		if (oldVal != viewAlignment) {
801
			viewAlignmentChanged = true;
802
		}
803
		viewAlignment = INITIAL_LOC_INT;
804
	}
805
806
	private void setEditorAlignDefault(IPreferenceStore apiStore) {
807
		// editor tabs on the bottom, really should associate this with the
808
		// presentation
809
		int oldVal = editorAlignment;
810
		editorAlignment = apiStore
811
				.getDefaultInt(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
812
		editorTopButton.setSelection(editorAlignment == SWT.TOP);
813
		editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
814
815
		// editor tabs should be set to default on OK or Apply
816
		if (oldVal != editorAlignment) {
817
			editorAlignmentChanged = true;
818
		}
819
		editorAlignment = INITIAL_LOC_INT;
820
	}
821
822
	private void setR21Preferences() {
823
		// editor tabs on the bottom, really should associate this with the
824
		// presentation
825
		int oldVal = editorAlignment;
826
		editorAlignment = SWT.TOP;
827
		editorTopButton.setSelection(editorAlignment == SWT.TOP);
828
		editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
829
		if (oldVal != editorAlignment) {
830
			editorAlignmentChanged = true;
831
		}
832
833
		// view tabs on the bottom, really should associate this with the
834
		// presentation
835
		oldVal = viewAlignment;
836
		viewAlignment = SWT.BOTTOM;
837
		viewTopButton.setSelection(viewAlignment == SWT.TOP);
838
		viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
839
		if (oldVal != viewAlignment) {
840
			viewAlignmentChanged = true;
841
		}
842
843
		// perspective switcher on the left, really should associate this with
844
		// the presentation
845
		perspBarLocation = IWorkbenchPreferenceConstants.LEFT;
846
		perspLeftButton.setSelection(perspBarLocation
847
				.equals(IWorkbenchPreferenceConstants.LEFT));
848
		perspTopLeftButton.setSelection(perspBarLocation
849
				.equals(IWorkbenchPreferenceConstants.TOP_LEFT));
850
		perspTopRightButton.setSelection(perspBarLocation
851
				.equals(IWorkbenchPreferenceConstants.TOP_RIGHT));
852
853
		// turn off text on persp bar, really should associate this with the
854
		// presentation
855
		showTextOnPerspectiveBar.setSelection(false);
856
		showTextOnPerspBar = String.valueOf(false);
857
858
		// fast view bar on the left (hidden pref, set it directly)
859
		fastViewLoc = IWorkbenchPreferenceConstants.LEFT;
860
861
		// Turn -off- the new min/max behaviour
862
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
863
		apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX,
864
				false);
865
	}
866
867
	/**
868
	 * @param themeToSelect
869
	 *            the id of the theme to be selected
870
	 */
871
	private void refreshThemeCombo(String themeToSelect) {
872
		themeCombo.removeAll();
873
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager()
874
				.getCurrentTheme();
875
876
		IThemeDescriptor[] descs = WorkbenchPlugin.getDefault()
877
				.getThemeRegistry().getThemes();
878
		String defaultThemeString = PlatformUI.getWorkbench().getThemeManager()
879
				.getTheme(IThemeManager.DEFAULT_THEME).getLabel();
880
		if (currentTheme.getId().equals(IThemeManager.DEFAULT_THEME)) {
881
			defaultThemeString = NLS.bind(
882
					WorkbenchMessages.ViewsPreference_currentThemeFormat,
883
					new Object[] { defaultThemeString });
884
		}
885
		themeCombo.add(defaultThemeString);
886
887
		String themeString;
888
		int selection = 0;
889
		for (int i = 0; i < descs.length; i++) {
890
			themeString = descs[i].getName();
891
			if (descs[i].getId().equals(currentTheme.getId())) {
892
				themeString = NLS.bind(
893
						WorkbenchMessages.ViewsPreference_currentThemeFormat,
894
						new Object[] { themeString });
895
			}
896
			if (themeToSelect.equals(descs[i].getId())) {
897
				selection = i + 1;
898
			}
899
			themeCombo.add(themeString);
900
		}
901
		themeCombo.select(selection);
902
	}
903
904
	/**
905
	 * Create the button and text that support setting the preference for
906
	 * showing text labels on the perspective switching bar.
907
	 */
908
	protected void createShowTextOnPerspectiveBarPref(Composite composite) {
909
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
910
911
		showTextOnPerspectiveBar = createCheckButton(
912
				composite,
913
				WorkbenchMessages.WorkbenchPreference_showTextOnPerspectiveBar,
914
				apiStore
915
						.getBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
916
	}
917
918
	/**
919
	 * Create the button and text that support setting the preference for
920
	 * showing text labels on the perspective switching bar
921
	 */
922
	protected void createShowTraditionalStyleTabsPref(Composite composite) {
923
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
924
925
		showTraditionalStyleTabs = createCheckButton(
926
				composite,
927
				WorkbenchMessages.ViewsPreference_traditionalTabs,
928
				apiStore
929
						.getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
930
	}
931
932
	protected void createEnableAnimationsPref(Composite composite) {
933
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
934
935
		enableAnimations = createCheckButton(
936
				composite,
937
				WorkbenchMessages.ViewsPreference_enableAnimations,
938
				apiStore
939
						.getBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS));
940
	}
941
942
	/**
943
	 * Returns preference store that belongs to the our plugin.
944
	 * 
945
	 * @return IPreferenceStore the preference store for this plugin
946
	 */
947
	protected IPreferenceStore doGetPreferenceStore() {
948
		return WorkbenchPlugin.getDefault().getPreferenceStore();
949
	}
84
	}
950
85
951
	/**
86
	/*
952
	 * Initializes this preference page for the given workbench.
87
	 * (non-Javadoc)
953
	 * <p>
954
	 * This method is called automatically as the preference page is being
955
	 * created and initialized. Clients must not call this method.
956
	 * </p>
957
	 * 
88
	 * 
958
	 * @param workbench
89
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
959
	 *            the workbench
960
	 */
90
	 */
961
	public void init(IWorkbench workbench) {
91
	@Override
962
		currentPresentationFactoryId = PrefUtil.getAPIPreferenceStore()
92
	public boolean performOk() {
963
				.getString(
93
		engine.setTheme(getSelection(), true);
964
						IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
94
		return super.performOk();
965
	}
95
	}
966
96
967
	/**
97
	@Override
968
	 * The default button has been pressed.
969
	 */
970
	protected void performDefaults() {
98
	protected void performDefaults() {
971
		IPreferenceStore store = getPreferenceStore();
99
		engine.setTheme(defaultTheme, true);
972
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
100
		themeIdCombo.setSelection(new StructuredSelection(engine.getActiveTheme()));
973
974
		showTextOnPerspectiveBar
975
				.setSelection(apiStore
976
						.getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
977
		showTraditionalStyleTabs
978
				.setSelection(apiStore
979
						.getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
980
		enableAnimations
981
				.setSelection(apiStore
982
						.getDefaultBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS));
983
		useColoredLabels
984
				.setSelection(apiStore
985
						.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
986
987
		String presID = apiStore
988
				.getDefaultString(IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
989
		currentPresentationFactoryId = presID;
990
		setPresentationSelection();
991
992
		boolean overridePrefs = store
993
				.getDefaultBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
994
		overridePresButton.setSelection(overridePrefs);
995
996
		updateOverrideState(overridePrefs);
997
998
		setEditorAlignDefault(apiStore);
999
		setViewAlignDefault(apiStore);
1000
1001
		perspBarLocation = apiStore
1002
				.getDefaultString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
1003
		perspLeftButton.setSelection(IWorkbenchPreferenceConstants.LEFT
1004
				.equals(perspBarLocation));
1005
		perspTopLeftButton.setSelection(IWorkbenchPreferenceConstants.TOP_LEFT
1006
				.equals(perspBarLocation));
1007
		perspTopRightButton
1008
				.setSelection(IWorkbenchPreferenceConstants.TOP_RIGHT
1009
						.equals(perspBarLocation));
1010
1011
		refreshThemeCombo(PlatformUI.getWorkbench().getThemeManager().getTheme(
1012
				IThemeManager.DEFAULT_THEME).getId());
1013
		refreshThemeDescriptionText();
1014
1015
		WorkbenchPlugin.getDefault().savePluginPreferences();
1016
1017
		super.performDefaults();
101
		super.performDefaults();
1018
	}
102
	}
1019
103
1020
	/**
104
	/*
1021
	 * The user has pressed Ok. Store/apply this page's values appropriately.
105
	 * (non-Javadoc)
106
	 * 
107
	 * @see org.eclipse.jface.preference.PreferencePage#performCancel()
1022
	 */
108
	 */
1023
	public boolean performOk() {
109
	@Override
1024
		IPreferenceStore store = getPreferenceStore();
110
	public boolean performCancel() {
1025
		IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
111
		engine.setTheme(currentTheme, false);
1026
		boolean override = store
112
		return super.performCancel();
1027
				.getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
1028
1029
		// apply the presentation selection first since it might change some of
1030
		// the other values
1031
		boolean restart = updatePresentationPreferences();
1032
1033
		if (showTextOnPerspBar.equals(INITIAL_VAL) && !override) {
1034
			apiStore
1035
					.setToDefault(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR);
1036
		} else {
1037
			apiStore.setValue(
1038
					IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR,
1039
					showTextOnPerspectiveBar.getSelection());
1040
		}
1041
1042
		if (editorAlignmentChanged) {
1043
			if (editorAlignment == INITIAL_LOC_INT) {
1044
				apiStore
1045
						.setToDefault(IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION);
1046
			} else if (!override) {
1047
				// store the editor tab value to setting
1048
				apiStore.setValue(
1049
						IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION,
1050
						editorAlignment);
1051
			} else {
1052
				// store the editor tab value to setting
1053
				apiStore.setValue(
1054
						IWorkbenchPreferenceConstants.EDITOR_TAB_POSITION,
1055
						editorAlignment);
1056
			}
1057
			restart = true;
1058
		}
1059
1060
		if (viewAlignmentChanged) {
1061
			if (viewAlignment == INITIAL_LOC_INT) {
1062
				apiStore
1063
						.setToDefault(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION);
1064
			} else if (!override) {
1065
				// store the view tab value to setting
1066
				apiStore.setValue(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION,
1067
						viewAlignment);
1068
			} else {
1069
				// store the view tab value to setting
1070
				apiStore.setValue(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION,
1071
						viewAlignment);
1072
			}
1073
			restart = true;
1074
		}
1075
1076
		if (perspBarLocation.equals(INITIAL_VAL)) {
1077
			apiStore
1078
					.setToDefault(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
1079
		} else if (!override) {
1080
			// store the perspective bar text enabled setting
1081
			apiStore.setValue(
1082
					IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
1083
					perspBarLocation);
1084
		} else {
1085
			// store the perspective bar text enabled setting
1086
			apiStore.setValue(
1087
					IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
1088
					perspBarLocation);
1089
		}
1090
1091
		if (fastViewLoc.equals(INITIAL_VAL)) {
1092
			apiStore
1093
					.setToDefault(IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION);
1094
		} else {
1095
			apiStore
1096
					.setValue(
1097
							IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION,
1098
							fastViewLoc);
1099
		}
1100
1101
		int idx = themeCombo.getSelectionIndex();
1102
		if (idx <= 0) {
1103
			PlatformUI.getWorkbench().getThemeManager().setCurrentTheme(
1104
					IThemeManager.DEFAULT_THEME);
1105
			refreshThemeCombo(IThemeManager.DEFAULT_THEME);
1106
		} else {
1107
			IThemeDescriptor applyTheme = WorkbenchPlugin.getDefault()
1108
					.getThemeRegistry().getThemes()[idx - 1];
1109
			PlatformUI.getWorkbench().getThemeManager().setCurrentTheme(
1110
					applyTheme.getId());
1111
			refreshThemeCombo(applyTheme.getId());
1112
		}
1113
		refreshThemeDescriptionText();
1114
1115
		apiStore.setValue(
1116
				IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
1117
				showTraditionalStyleTabs.getSelection());
1118
		apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS,
1119
				enableAnimations.getSelection());
1120
		apiStore.setValue(IWorkbenchPreferenceConstants.USE_COLORED_LABELS,
1121
				useColoredLabels.getSelection());
1122
1123
		PrefUtil.savePrefs();
1124
1125
		// we can get here through performApply, in that case only post one
1126
		// restart
1127
		if (restart && !restartPosted) {
1128
			if (getContainer() instanceof IWorkbenchPreferenceContainer) {
1129
				IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
1130
				UIJob job = new UIJob(
1131
						WorkbenchMessages.ViewsPreference_restartRequestJobName) {
1132
					public IStatus runInUIThread(IProgressMonitor monitor) {
1133
						// make sure they really want to do this
1134
						int really = new MessageDialog(
1135
								null,
1136
								WorkbenchMessages.ViewsPreference_presentationConfirm_title,
1137
								null,
1138
								WorkbenchMessages.ViewsPreference_presentationConfirm_message,
1139
								MessageDialog.QUESTION,
1140
								new String[] {
1141
										WorkbenchMessages.ViewsPreference_presentationConfirm_yes,
1142
										WorkbenchMessages.ViewsPreference_presentationConfirm_no },
1143
								1).open();
1144
						if (really == Window.OK) {
1145
							PlatformUI.getWorkbench().restart();
1146
						}
1147
						return Status.OK_STATUS;
1148
					}
1149
				};
1150
				job.setSystem(true);
1151
				container.registerUpdateJob(job);
1152
				restartPosted = true;
1153
			}
1154
		}
1155
		return true;
1156
	}
113
	}
1157
}
114
}
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 100-106 Link Here
100
 org.eclipse.e4.core.di,
100
 org.eclipse.e4.core.di,
101
 org.eclipse.e4.ui.workbench.swt;bundle-version="0.9.1",
101
 org.eclipse.e4.ui.workbench.swt;bundle-version="0.9.1",
102
 org.eclipse.e4.ui.di;bundle-version="0.9.0",
102
 org.eclipse.e4.ui.di;bundle-version="0.9.0",
103
 org.eclipse.e4.ui.model.workbench;bundle-version="0.9.1"
103
 org.eclipse.e4.ui.model.workbench;bundle-version="0.9.1",
104
 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.9.0"
104
Import-Package: com.ibm.icu.text,
105
Import-Package: com.ibm.icu.text,
105
 com.ibm.icu.util,
106
 com.ibm.icu.util,
106
 javax.annotation;version="1.0.0",
107
 javax.annotation;version="1.0.0",

Return to bug 317125