Source Code Cross Referenced for ViewsPreferencePage.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » dialogs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.internal.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.ui.internal.dialogs;
0011:
0012:        import java.util.Arrays;
0013:        import java.util.Comparator;
0014:        import java.util.Locale;
0015:
0016:        import org.eclipse.core.runtime.IConfigurationElement;
0017:        import org.eclipse.core.runtime.IProgressMonitor;
0018:        import org.eclipse.core.runtime.IStatus;
0019:        import org.eclipse.core.runtime.Platform;
0020:        import org.eclipse.core.runtime.Status;
0021:        import org.eclipse.jface.dialogs.IDialogConstants;
0022:        import org.eclipse.jface.dialogs.MessageDialog;
0023:        import org.eclipse.jface.preference.IPreferenceStore;
0024:        import org.eclipse.jface.preference.PreferencePage;
0025:        import org.eclipse.jface.util.IPropertyChangeListener;
0026:        import org.eclipse.jface.util.PropertyChangeEvent;
0027:        import org.eclipse.jface.window.Window;
0028:        import org.eclipse.osgi.util.NLS;
0029:        import org.eclipse.swt.SWT;
0030:        import org.eclipse.swt.accessibility.AccessibleAdapter;
0031:        import org.eclipse.swt.accessibility.AccessibleEvent;
0032:        import org.eclipse.swt.events.SelectionAdapter;
0033:        import org.eclipse.swt.events.SelectionEvent;
0034:        import org.eclipse.swt.events.SelectionListener;
0035:        import org.eclipse.swt.layout.FormAttachment;
0036:        import org.eclipse.swt.layout.FormData;
0037:        import org.eclipse.swt.layout.FormLayout;
0038:        import org.eclipse.swt.layout.GridData;
0039:        import org.eclipse.swt.layout.GridLayout;
0040:        import org.eclipse.swt.widgets.Button;
0041:        import org.eclipse.swt.widgets.Combo;
0042:        import org.eclipse.swt.widgets.Composite;
0043:        import org.eclipse.swt.widgets.Control;
0044:        import org.eclipse.swt.widgets.Group;
0045:        import org.eclipse.swt.widgets.Label;
0046:        import org.eclipse.swt.widgets.Text;
0047:        import org.eclipse.ui.IWorkbench;
0048:        import org.eclipse.ui.IWorkbenchPreferenceConstants;
0049:        import org.eclipse.ui.IWorkbenchPreferencePage;
0050:        import org.eclipse.ui.PlatformUI;
0051:        import org.eclipse.ui.internal.IPreferenceConstants;
0052:        import org.eclipse.ui.internal.IWorkbenchConstants;
0053:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
0054:        import org.eclipse.ui.internal.Workbench;
0055:        import org.eclipse.ui.internal.WorkbenchMessages;
0056:        import org.eclipse.ui.internal.WorkbenchPlugin;
0057:        import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
0058:        import org.eclipse.ui.internal.themes.IThemeDescriptor;
0059:        import org.eclipse.ui.internal.util.PrefUtil;
0060:        import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
0061:        import org.eclipse.ui.progress.UIJob;
0062:        import org.eclipse.ui.themes.ITheme;
0063:        import org.eclipse.ui.themes.IThemeManager;
0064:
0065:        import com.ibm.icu.text.Collator;
0066:
0067:        /**
0068:         * The ViewsPreferencePage is the page used to set preferences for the 
0069:         * appearance of the workbench.  Originally this applied only to views but now 
0070:         * applies to the overall appearance, hence the name.
0071:         */
0072:        public class ViewsPreferencePage extends PreferencePage implements 
0073:                IWorkbenchPreferencePage {
0074:
0075:            private Button showTextOnPerspectiveBar;
0076:
0077:            /*
0078:             * change the tab style of the workbench
0079:             */
0080:            private Button showTraditionalStyleTabs;
0081:
0082:            private Button enableAnimations;
0083:
0084:            private Button editorTopButton;
0085:
0086:            private Button editorBottomButton;
0087:
0088:            private Button viewTopButton;
0089:
0090:            private Button viewBottomButton;
0091:
0092:            private Button perspLeftButton;
0093:
0094:            private Button perspTopLeftButton;
0095:
0096:            private Button perspTopRightButton;
0097:
0098:            static final String EDITORS_TITLE = WorkbenchMessages.ViewsPreference_editors;
0099:
0100:            private static final String EDITORS_TOP_TITLE = WorkbenchMessages.ViewsPreference_editors_top;
0101:
0102:            private static final String EDITORS_BOTTOM_TITLE = WorkbenchMessages.ViewsPreference_editors_bottom;
0103:
0104:            private static final String VIEWS_TITLE = WorkbenchMessages.ViewsPreference_views;
0105:
0106:            private static final String VIEWS_TOP_TITLE = WorkbenchMessages.ViewsPreference_views_top;
0107:
0108:            private static final String VIEWS_BOTTOM_TITLE = WorkbenchMessages.ViewsPreference_views_bottom;
0109:
0110:            private static final String PERSP_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar;
0111:
0112:            private static final String PERSP_LEFT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_left;
0113:
0114:            private static final String PERSP_TOP_LEFT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_topLeft;
0115:
0116:            private static final String PERSP_TOP_RIGHT_TITLE = WorkbenchMessages.ViewsPreference_perspectiveBar_topRight;
0117:
0118:            // These constants aren't my favourite idea, but to get this preference done
0119:            // for M9... A better solution might be to have the presentation factory set
0120:            // its dependant preference defaults on startup. I've filed bug 63346 to do
0121:            // something about this area.
0122:            private static final String R21PRESENTATION_ID = "org.eclipse.ui.internal.r21presentationFactory"; //$NON-NLS-1$
0123:            private static final String DEFAULT_PRESENTATION_ID = IWorkbenchConstants.DEFAULT_PRESENTATION_ID;
0124:            private static final String R30_PRESENTATION_ID = "org.eclipse.ui.presentations.r30"; //$NON-NLS-1$
0125:
0126:            private static final String INITIAL_VAL = new String();
0127:
0128:            private static final int INITIAL_LOC_INT = -1;
0129:
0130:            // remembers whether the hidden fastview bar pref needs to be changed on
0131:            // OK/Apply
0132:            private String fastViewLoc = INITIAL_VAL;
0133:
0134:            private String showTextOnPerspBar = INITIAL_VAL;
0135:
0136:            private int editorAlignment;
0137:
0138:            private boolean editorAlignmentChanged = false;
0139:
0140:            private int viewAlignment;
0141:
0142:            private boolean viewAlignmentChanged = false;
0143:
0144:            private String perspBarLocation;
0145:
0146:            private Combo themeCombo;
0147:
0148:            private Combo presentationCombo;
0149:
0150:            private IConfigurationElement[] presentationFactories;
0151:
0152:            private String currentPresentationFactoryId;
0153:
0154:            private Button overridePresButton;
0155:
0156:            private IPropertyChangeListener overrideListener;
0157:
0158:            private boolean restartPosted = false;
0159:
0160:            private Group editorTabGroup;
0161:
0162:            private Group viewTabGroup;
0163:
0164:            private Group perspBarTabGroup;
0165:
0166:            private Text themeDescriptionText;
0167:
0168:            /**
0169:             * Create a composite that for creating the tab toggle buttons.
0170:             * 
0171:             * @param composite  Composite
0172:             * @param title  String
0173:             */
0174:            private Group createButtonGroup(Composite composite, String title) {
0175:                Group buttonComposite = new Group(composite, SWT.NONE);
0176:                buttonComposite.setText(title);
0177:                FormLayout layout = new FormLayout();
0178:                layout.marginWidth = 5; // same as GridData default
0179:                layout.marginHeight = 5; // same as GridData default
0180:                buttonComposite.setLayout(layout);
0181:                buttonComposite.setLayoutData(new GridData(SWT.FILL,
0182:                        SWT.CENTER, true, false));
0183:                return buttonComposite;
0184:            }
0185:
0186:            /**
0187:             * Creates and returns the SWT control for the customized body of this
0188:             * preference page under the given parent composite.
0189:             * <p>
0190:             * This framework method must be implemented by concrete subclasses.
0191:             * </p>
0192:             * 
0193:             * @param parent  the parent composite
0194:             * @return Control the new control
0195:             */
0196:            protected Control createContents(Composite parent) {
0197:                initializeDialogUnits(parent);
0198:
0199:                PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
0200:                        IWorkbenchHelpContextIds.VIEWS_PREFERENCE_PAGE);
0201:
0202:                IPreferenceStore internalStore = PrefUtil
0203:                        .getInternalPreferenceStore();
0204:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0205:
0206:                editorAlignment = internalStore
0207:                        .getInt(IPreferenceConstants.EDITOR_TAB_POSITION);
0208:                viewAlignment = internalStore
0209:                        .getInt(IPreferenceConstants.VIEW_TAB_POSITION);
0210:                perspBarLocation = apiStore
0211:                        .getString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
0212:
0213:                Composite composite = new Composite(parent, SWT.NONE);
0214:                composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
0215:                        true));
0216:
0217:                GridLayout layout = new GridLayout();
0218:                layout.marginWidth = 0;
0219:                layout.marginHeight = 0;
0220:                layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
0221:                composite.setLayout(layout);
0222:
0223:                createPresentationCombo(composite);
0224:                createPresentationOverride(composite);
0225:                createEditorTabButtonGroup(composite);
0226:                createViewTabButtonGroup(composite);
0227:                createPerspBarTabButtonGroup(composite);
0228:                createShowTextOnPerspectiveBarPref(composite);
0229:                createThemeCombo(composite);
0230:                createThemeDescriptionText(composite);
0231:                createShowTraditionalStyleTabsPref(composite);
0232:                createEnableAnimationsPref(composite);
0233:
0234:                updateOverride();
0235:                hookOverrideListener();
0236:
0237:                applyDialogFont(composite);
0238:
0239:                return composite;
0240:            }
0241:
0242:            private void createThemeCombo(Composite composite) {
0243:                new Label(composite, SWT.NONE)
0244:                        .setText(WorkbenchMessages.ViewsPreference_currentTheme);
0245:                themeCombo = new Combo(composite, SWT.READ_ONLY);
0246:                themeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
0247:                        true, false));
0248:                themeCombo.addSelectionListener(new SelectionAdapter() {
0249:                    public void widgetSelected(SelectionEvent e) {
0250:                        refreshThemeDescriptionText();
0251:                    }
0252:                });
0253:                refreshThemeCombo(PlatformUI.getWorkbench().getThemeManager()
0254:                        .getCurrentTheme().getId());
0255:            }
0256:
0257:            /**
0258:             * Create the text box that will contain the current theme description
0259:             * text (if any).
0260:             * 
0261:             * @param parent
0262:             *            the parent <code>Composite</code>.
0263:             */
0264:            private void createThemeDescriptionText(Composite parent) {
0265:                new Label(parent, SWT.NONE)
0266:                        .setText(WorkbenchMessages.ViewsPreference_currentThemeDescription);
0267:
0268:                themeDescriptionText = new Text(parent, SWT.H_SCROLL
0269:                        | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER | SWT.WRAP);
0270:                themeDescriptionText.setLayoutData(new GridData(SWT.FILL,
0271:                        SWT.FILL, true, true));
0272:
0273:                refreshThemeDescriptionText();
0274:            }
0275:
0276:            private void refreshThemeDescriptionText() {
0277:                String description = null;
0278:                int idx = themeCombo.getSelectionIndex();
0279:                // idx == 0 is "Default" which has no description
0280:                if (idx > 0) {
0281:                    IThemeDescriptor theme = WorkbenchPlugin.getDefault()
0282:                            .getThemeRegistry().getThemes()[idx - 1];
0283:                    description = theme.getDescription();
0284:                }
0285:                if (description == null) {
0286:                    description = ""; //$NON-NLS-1$
0287:                }
0288:                themeDescriptionText.setText(description);
0289:            }
0290:
0291:            private Button createCheckButton(Composite composite, String text,
0292:                    boolean selection) {
0293:                Button button = new Button(composite, SWT.CHECK);
0294:                button.setText(text);
0295:                button.setSelection(selection);
0296:                return button;
0297:            }
0298:
0299:            private void createPresentationOverride(Composite parent) {
0300:                IPreferenceStore store = getPreferenceStore();
0301:                boolean override = store
0302:                        .getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
0303:
0304:                // workaround to catch the case where the show text value was changed outside of this page
0305:                // turn off text on persp bar
0306:                boolean showText = PrefUtil
0307:                        .getAPIPreferenceStore()
0308:                        .getBoolean(
0309:                                IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR);
0310:                if (showText && isR21(currentPresentationFactoryId)
0311:                        || !showText && isR30(currentPresentationFactoryId)) {
0312:                    if (!override) {
0313:                        store.setValue(
0314:                                IPreferenceConstants.OVERRIDE_PRESENTATION,
0315:                                true);
0316:                        override = true;
0317:                    }
0318:                }
0319:                // workaround to catch the case where the perspective switcher location was changed outside of this page
0320:                // turn off text on persp bar
0321:                String barLocation = PrefUtil
0322:                        .getAPIPreferenceStore()
0323:                        .getString(
0324:                                IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
0325:                if (!barLocation.equals(IWorkbenchPreferenceConstants.LEFT)
0326:                        && isR21(currentPresentationFactoryId)
0327:                        || !barLocation
0328:                                .equals(IWorkbenchPreferenceConstants.TOP_RIGHT)
0329:                        && isR30(currentPresentationFactoryId)) {
0330:                    if (!override) {
0331:                        store.setValue(
0332:                                IPreferenceConstants.OVERRIDE_PRESENTATION,
0333:                                true);
0334:                        override = true;
0335:                    }
0336:                }
0337:
0338:                overridePresButton = createCheckButton(parent,
0339:                        WorkbenchMessages.ViewsPreference_override, override);
0340:                overridePresButton
0341:                        .addSelectionListener(new SelectionListener() {
0342:                            public void widgetSelected(SelectionEvent e) {
0343:                                updateOverrideState(overridePresButton
0344:                                        .getSelection());
0345:                            }
0346:
0347:                            public void widgetDefaultSelected(SelectionEvent e) {
0348:                                updateOverrideState(overridePresButton
0349:                                        .getSelection());
0350:                            }
0351:                        });
0352:            }
0353:
0354:            private void updateOverrideState(boolean override) {
0355:                IPreferenceStore store = getPreferenceStore();
0356:                if (store
0357:                        .getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION) != override) {
0358:                    store.setValue(IPreferenceConstants.OVERRIDE_PRESENTATION,
0359:                            override);
0360:                }
0361:                // as we are no longer overriding the prefs should match the selected
0362:                // presentation
0363:                if (!override)
0364:                    setPresentationPrefs(getSelectedPresentationID());
0365:            }
0366:
0367:            private void createPresentationCombo(Composite parent) {
0368:                new Label(parent, SWT.NONE)
0369:                        .setText(WorkbenchMessages.ViewsPreference_currentPresentation);
0370:
0371:                presentationCombo = new Combo(parent, SWT.READ_ONLY);
0372:                presentationCombo.setLayoutData(new GridData(SWT.FILL,
0373:                        SWT.CENTER, true, false));
0374:                presentationCombo.addSelectionListener(new SelectionListener() {
0375:
0376:                    public void widgetSelected(SelectionEvent e) {
0377:                        updateSettings();
0378:                    }
0379:
0380:                    public void widgetDefaultSelected(SelectionEvent e) {
0381:                        updateSettings();
0382:                    }
0383:
0384:                    private void updateSettings() {
0385:                        if (!overridePresButton.getSelection()) {
0386:                            setPresentationPrefs(getSelectedPresentationID());
0387:                        }
0388:                    }
0389:                });
0390:
0391:                refreshPresentationCombo();
0392:                setPresentationSelection();
0393:            }
0394:
0395:            /**
0396:             * Set the two supplied controls to be beside each other.
0397:             */
0398:            private void attachControls(Control leftControl,
0399:                    Control rightControl) {
0400:                FormData leftData = new FormData();
0401:                leftData.left = new FormAttachment(0, 0);
0402:
0403:                FormData rightData = new FormData();
0404:                rightData.left = new FormAttachment(
0405:                        leftControl,
0406:                        convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING));
0407:
0408:                leftControl.setLayoutData(leftData);
0409:                rightControl.setLayoutData(rightData);
0410:            }
0411:
0412:            /**
0413:             * Create a composite that contains buttons for selecting tab position for
0414:             * the edit selection.
0415:             * 
0416:             * @param composite  Composite
0417:             */
0418:            private void createEditorTabButtonGroup(Composite composite) {
0419:                editorTabGroup = createButtonGroup(composite, EDITORS_TITLE);
0420:
0421:                editorTopButton = new Button(editorTabGroup, SWT.RADIO);
0422:                editorTopButton.setText(EDITORS_TOP_TITLE);
0423:                editorTopButton.setSelection(editorAlignment == SWT.TOP);
0424:                editorTopButton.getAccessible().addAccessibleListener(
0425:                        new AccessibleAdapter() {
0426:                            public void getName(AccessibleEvent e) {
0427:                                e.result = EDITORS_TITLE;
0428:                            }
0429:                        });
0430:
0431:                editorBottomButton = new Button(editorTabGroup, SWT.RADIO);
0432:                editorBottomButton.setText(EDITORS_BOTTOM_TITLE);
0433:                editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
0434:
0435:                SelectionListener sel = new SelectionAdapter() {
0436:                    public void widgetSelected(SelectionEvent e) {
0437:                        if (e.widget.equals(editorTopButton)) {
0438:                            if (editorAlignment != SWT.TOP) {
0439:                                editorAlignment = SWT.TOP;
0440:                                editorAlignmentChanged = true;
0441:                            }
0442:                        } else if (e.widget.equals(editorBottomButton)) {
0443:                            if (editorAlignment != SWT.BOTTOM) {
0444:                                editorAlignment = SWT.BOTTOM;
0445:                                editorAlignmentChanged = true;
0446:                            }
0447:                        }
0448:                    }
0449:                };
0450:
0451:                editorTopButton.addSelectionListener(sel);
0452:                editorBottomButton.addSelectionListener(sel);
0453:
0454:                attachControls(editorTopButton, editorBottomButton);
0455:            }
0456:
0457:            /**
0458:             * Create a composite that contains buttons for selecting tab position for
0459:             * the view selection.
0460:             * 
0461:             * @param composite  Composite
0462:             */
0463:            private void createViewTabButtonGroup(Composite composite) {
0464:                viewTabGroup = createButtonGroup(composite, VIEWS_TITLE);
0465:
0466:                viewTopButton = new Button(viewTabGroup, SWT.RADIO);
0467:                viewTopButton.setText(VIEWS_TOP_TITLE);
0468:                viewTopButton.setSelection(this .viewAlignment == SWT.TOP);
0469:
0470:                viewBottomButton = new Button(viewTabGroup, SWT.RADIO);
0471:                viewBottomButton.setText(VIEWS_BOTTOM_TITLE);
0472:                viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
0473:
0474:                SelectionListener sel = new SelectionAdapter() {
0475:                    public void widgetSelected(SelectionEvent e) {
0476:                        if (e.widget.equals(viewTopButton)) {
0477:                            if (viewAlignment != SWT.TOP) {
0478:                                viewAlignment = SWT.TOP;
0479:                                viewAlignmentChanged = true;
0480:                            }
0481:                        } else if (e.widget.equals(viewBottomButton)) {
0482:                            if (viewAlignment != SWT.BOTTOM) {
0483:                                viewAlignment = SWT.BOTTOM;
0484:                                viewAlignmentChanged = true;
0485:                            }
0486:                        }
0487:                    }
0488:                };
0489:
0490:                viewTopButton.addSelectionListener(sel);
0491:                viewBottomButton.addSelectionListener(sel);
0492:
0493:                attachControls(viewTopButton, viewBottomButton);
0494:            }
0495:
0496:            /**
0497:             * Create a composite that contains buttons for selecting perspective
0498:             * switcher position.
0499:             * 
0500:             * @param composite Composite
0501:             */
0502:            private void createPerspBarTabButtonGroup(Composite composite) {
0503:                perspBarTabGroup = createButtonGroup(composite, PERSP_TITLE);
0504:
0505:                perspLeftButton = new Button(perspBarTabGroup, SWT.RADIO);
0506:                perspLeftButton.setText(PERSP_LEFT_TITLE);
0507:                perspLeftButton.setSelection(IWorkbenchPreferenceConstants.LEFT
0508:                        .equals(perspBarLocation));
0509:                perspLeftButton.addSelectionListener(new SelectionAdapter() {
0510:                    public void widgetSelected(SelectionEvent e) {
0511:                        perspBarLocation = IWorkbenchPreferenceConstants.LEFT;
0512:                    }
0513:                });
0514:
0515:                perspTopLeftButton = new Button(perspBarTabGroup, SWT.RADIO);
0516:                perspTopLeftButton.setText(PERSP_TOP_LEFT_TITLE);
0517:                perspTopLeftButton
0518:                        .setSelection(IWorkbenchPreferenceConstants.TOP_LEFT
0519:                                .equals(perspBarLocation));
0520:                perspTopLeftButton.addSelectionListener(new SelectionAdapter() {
0521:                    public void widgetSelected(SelectionEvent e) {
0522:                        perspBarLocation = IWorkbenchPreferenceConstants.TOP_LEFT;
0523:                    }
0524:                });
0525:
0526:                perspTopRightButton = new Button(perspBarTabGroup, SWT.RADIO);
0527:                perspTopRightButton.setText(PERSP_TOP_RIGHT_TITLE);
0528:                perspTopRightButton
0529:                        .setSelection(IWorkbenchPreferenceConstants.TOP_RIGHT
0530:                                .equals(perspBarLocation));
0531:                perspTopRightButton
0532:                        .addSelectionListener(new SelectionAdapter() {
0533:                            public void widgetSelected(SelectionEvent e) {
0534:                                perspBarLocation = IWorkbenchPreferenceConstants.TOP_RIGHT;
0535:                            }
0536:                        });
0537:
0538:                int spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
0539:
0540:                FormData leftData = new FormData();
0541:                leftData.left = new FormAttachment(0, 0);
0542:
0543:                FormData topLeftData = new FormData();
0544:                topLeftData.left = new FormAttachment(perspLeftButton, spacing);
0545:
0546:                FormData topRightData = new FormData();
0547:                topRightData.left = new FormAttachment(perspTopLeftButton,
0548:                        spacing);
0549:
0550:                perspLeftButton.setLayoutData(leftData);
0551:                perspTopLeftButton.setLayoutData(topLeftData);
0552:                perspTopRightButton.setLayoutData(topRightData);
0553:            }
0554:
0555:            /**
0556:             * Hook a listener to update the buttons based on an override preference. If
0557:             * the preference is false then do not allow editing of these options.
0558:             * 
0559:             */
0560:            private void hookOverrideListener() {
0561:                if (overrideListener != null) {
0562:                    return;
0563:                }
0564:                IPreferenceStore store = getPreferenceStore();
0565:                overrideListener = new IPropertyChangeListener() {
0566:                    public void propertyChange(PropertyChangeEvent event) {
0567:                        if (event.getProperty().equals(
0568:                                IPreferenceConstants.OVERRIDE_PRESENTATION)) {
0569:                            updateOverride();
0570:                        }
0571:                    }
0572:                };
0573:                store.addPropertyChangeListener(overrideListener);
0574:            }
0575:
0576:            /**
0577:             * Dispose resources created by the receiver.
0578:             */
0579:            public void dispose() {
0580:                super .dispose();
0581:                if (overrideListener != null) {
0582:                    getPreferenceStore().removePropertyChangeListener(
0583:                            overrideListener);
0584:                    overrideListener = null;
0585:                }
0586:            }
0587:
0588:            private void updateOverride() {
0589:                boolean override = getPreferenceStore().getBoolean(
0590:                        IPreferenceConstants.OVERRIDE_PRESENTATION);
0591:                editorTabGroup.setEnabled(override);
0592:                editorTopButton.setEnabled(override);
0593:                editorBottomButton.setEnabled(override);
0594:                viewTabGroup.setEnabled(override);
0595:                viewTopButton.setEnabled(override);
0596:                viewBottomButton.setEnabled(override);
0597:                perspBarTabGroup.setEnabled(override);
0598:                perspTopLeftButton.setEnabled(override);
0599:                perspLeftButton.setEnabled(override);
0600:                perspTopRightButton.setEnabled(override);
0601:                showTextOnPerspectiveBar.setEnabled(override);
0602:            }
0603:
0604:            private void refreshPresentationCombo() {
0605:                // get the active presentation
0606:                presentationCombo.removeAll();
0607:                refreshPresentationFactories();
0608:
0609:                for (int i = 0; i < presentationFactories.length; ++i) {
0610:                    IConfigurationElement el = presentationFactories[i];
0611:                    String name = el.getAttribute(IWorkbenchConstants.TAG_NAME);
0612:                    if (!currentPresentationFactoryId.equals(el
0613:                            .getAttribute(IWorkbenchConstants.TAG_ID))) {
0614:                        presentationCombo.add(name);
0615:                    } else {
0616:                        presentationCombo
0617:                                .add(NLS
0618:                                        .bind(
0619:                                                WorkbenchMessages.ViewsPreference_currentPresentationFormat,
0620:                                                name));
0621:                    }
0622:                }
0623:            }
0624:
0625:            private void setPresentationSelection() {
0626:                for (int i = 0; i < presentationFactories.length; ++i) {
0627:                    if (currentPresentationFactoryId
0628:                            .equals(presentationFactories[i]
0629:                                    .getAttribute(IWorkbenchConstants.TAG_ID))) {
0630:                        presentationCombo.select(i);
0631:                        return;
0632:                    }
0633:                }
0634:                //presentationCombo.select(0);
0635:            }
0636:
0637:            /**
0638:             * Update this page's list of presentation factories. This should only be
0639:             * used when the presentation combo is refreshed, as this array will be used
0640:             * to set the selection from the combo.
0641:             */
0642:            private void refreshPresentationFactories() {
0643:                // update the current selection (used to look for changes on apply)
0644:                currentPresentationFactoryId = PrefUtil
0645:                        .getAPIPreferenceStore()
0646:                        .getString(
0647:                                IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
0648:                // Workbench.getInstance().getPresentationId();
0649:
0650:                // update the sorted list of factories
0651:                presentationFactories = Platform
0652:                        .getExtensionRegistry()
0653:                        .getConfigurationElementsFor(
0654:                                PlatformUI.PLUGIN_ID,
0655:                                IWorkbenchRegistryConstants.PL_PRESENTATION_FACTORIES);
0656:
0657:                // sort the array by name
0658:                Arrays.sort(presentationFactories, new Comparator() {
0659:                    Collator collator = Collator.getInstance(Locale
0660:                            .getDefault());
0661:
0662:                    public int compare(Object a, Object b) {
0663:                        IConfigurationElement el1 = (IConfigurationElement) a;
0664:                        IConfigurationElement el2 = (IConfigurationElement) b;
0665:                        return collator.compare(el1
0666:                                .getAttribute(IWorkbenchConstants.TAG_NAME),
0667:                                el2.getAttribute(IWorkbenchConstants.TAG_NAME));
0668:                    }
0669:                });
0670:            }
0671:
0672:            /**
0673:             * Update the preferences associated with the argument presentation factory.
0674:             * 
0675:             * @return boolean
0676:             *         <code>true<\code> of the presentation has changed and <code>false<\code> otherwise
0677:             */
0678:            private boolean updatePresentationPreferences() {
0679:                // There are some preference values associated with the R2.1
0680:                // presentation that cannot be captured in the presentation
0681:                // factory. Perhaps the extension point should contain these
0682:                // (a list of attributes?), but for now it is done manually.
0683:
0684:                if (presentationCombo == null) {
0685:                    return false;
0686:                }
0687:
0688:                String id = getSelectedPresentationID();
0689:
0690:                // if it hasn't changed then there's nothing to do
0691:                if (id.equals(currentPresentationFactoryId)) {
0692:                    return false;
0693:                }
0694:
0695:                currentPresentationFactoryId = id;
0696:                // apply 2.1 prefs if needed
0697:                setPresentationPrefs(id);
0698:                // set the new presentation factory id
0699:                PrefUtil.getAPIPreferenceStore().putValue(
0700:                        IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID,
0701:                        id);
0702:                // a restart is required to update the presentation
0703:                return true;
0704:            }
0705:
0706:            private void setPresentationPrefs(String id) {
0707:                if (isR21(id)) {
0708:                    setR21Preferences();
0709:                } else if (isR30(id)) {
0710:                    setR30Preferences();
0711:                } else if (isR33(id)) {
0712:                    setR33Preferences();
0713:                }
0714:            }
0715:
0716:            private boolean isR33(String id) {
0717:                return DEFAULT_PRESENTATION_ID.equals(id);
0718:            }
0719:
0720:            private boolean isR30(String id) {
0721:                return R30_PRESENTATION_ID.equals(id);
0722:            }
0723:
0724:            private boolean isR21(String id) {
0725:                return R21PRESENTATION_ID.equals(id);
0726:            }
0727:
0728:            private String getSelectedPresentationID() {
0729:                int selection = presentationCombo.getSelectionIndex();
0730:                IConfigurationElement element = presentationFactories[selection];
0731:                String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
0732:                return id;
0733:            }
0734:
0735:            private void setR33Preferences() {
0736:                setR30Preferences();
0737:
0738:                // Turn -on- the new Min/Max behaviour
0739:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0740:                apiStore.setValue(
0741:                        IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX, true);
0742:            }
0743:
0744:            private void setR30Preferences() {
0745:                IPreferenceStore internalStore = PrefUtil
0746:                        .getInternalPreferenceStore();
0747:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0748:
0749:                // Turn -off- the new min/max behaviour
0750:                apiStore
0751:                        .setValue(
0752:                                IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX,
0753:                                false);
0754:
0755:                setEditorAlignDefault(internalStore);
0756:                setViewAlignDefault(internalStore);
0757:
0758:                // perspective switcher on the left
0759:                perspBarLocation = apiStore
0760:                        .getDefaultString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
0761:                perspLeftButton.setSelection(perspBarLocation
0762:                        .equals(IWorkbenchPreferenceConstants.LEFT));
0763:                perspTopLeftButton.setSelection(perspBarLocation
0764:                        .equals(IWorkbenchPreferenceConstants.TOP_LEFT));
0765:                perspTopRightButton.setSelection(perspBarLocation
0766:                        .equals(IWorkbenchPreferenceConstants.TOP_RIGHT));
0767:
0768:                // perspective bar should be set to default on OK or Apply
0769:                perspBarLocation = INITIAL_VAL;
0770:
0771:                // turn off text on persp bar
0772:                showTextOnPerspectiveBar
0773:                        .setSelection(apiStore
0774:                                .getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
0775:                // text on perspective bar should be set to default on OK or Apply
0776:                showTextOnPerspBar = INITIAL_VAL;
0777:
0778:                // fast view bar should be set to default on OK or Apply
0779:                fastViewLoc = INITIAL_VAL;
0780:            }
0781:
0782:            private void setViewAlignDefault(IPreferenceStore internalStore) {
0783:                int oldVal;
0784:                // reset the preferences for 3.0 presentation
0785:                oldVal = viewAlignment;
0786:                viewAlignment = internalStore
0787:                        .getDefaultInt(IPreferenceConstants.VIEW_TAB_POSITION);
0788:                viewTopButton.setSelection(viewAlignment == SWT.TOP);
0789:                viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
0790:
0791:                // view tabs should be set to default on OK or Apply
0792:                if (oldVal != viewAlignment) {
0793:                    viewAlignmentChanged = true;
0794:                }
0795:                viewAlignment = INITIAL_LOC_INT;
0796:            }
0797:
0798:            private void setEditorAlignDefault(IPreferenceStore internalStore) {
0799:                // editor tabs on the bottom, really should associate this with the
0800:                // presentation
0801:                int oldVal = editorAlignment;
0802:                editorAlignment = internalStore
0803:                        .getDefaultInt(IPreferenceConstants.EDITOR_TAB_POSITION);
0804:                editorTopButton.setSelection(editorAlignment == SWT.TOP);
0805:                editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
0806:
0807:                // editor tabs should be set to default on OK or Apply
0808:                if (oldVal != editorAlignment) {
0809:                    editorAlignmentChanged = true;
0810:                }
0811:                editorAlignment = INITIAL_LOC_INT;
0812:            }
0813:
0814:            private void setR21Preferences() {
0815:                // editor tabs on the bottom, really should associate this with the
0816:                // presentation
0817:                int oldVal = editorAlignment;
0818:                editorAlignment = SWT.TOP;
0819:                editorTopButton.setSelection(editorAlignment == SWT.TOP);
0820:                editorBottomButton.setSelection(editorAlignment == SWT.BOTTOM);
0821:                if (oldVal != editorAlignment) {
0822:                    editorAlignmentChanged = true;
0823:                }
0824:
0825:                // view tabs on the bottom, really should associate this with the
0826:                // presentation
0827:                oldVal = viewAlignment;
0828:                viewAlignment = SWT.BOTTOM;
0829:                viewTopButton.setSelection(viewAlignment == SWT.TOP);
0830:                viewBottomButton.setSelection(viewAlignment == SWT.BOTTOM);
0831:                if (oldVal != viewAlignment) {
0832:                    viewAlignmentChanged = true;
0833:                }
0834:
0835:                // perspective switcher on the left, really should associate this with
0836:                // the presentation
0837:                perspBarLocation = IWorkbenchPreferenceConstants.LEFT;
0838:                perspLeftButton.setSelection(perspBarLocation
0839:                        .equals(IWorkbenchPreferenceConstants.LEFT));
0840:                perspTopLeftButton.setSelection(perspBarLocation
0841:                        .equals(IWorkbenchPreferenceConstants.TOP_LEFT));
0842:                perspTopRightButton.setSelection(perspBarLocation
0843:                        .equals(IWorkbenchPreferenceConstants.TOP_RIGHT));
0844:
0845:                // turn off text on persp bar, really should associate this with the
0846:                // presentation
0847:                showTextOnPerspectiveBar.setSelection(false);
0848:                showTextOnPerspBar = String.valueOf(false);
0849:
0850:                // fast view bar on the left (hidden pref, set it directly)
0851:                fastViewLoc = IWorkbenchPreferenceConstants.LEFT;
0852:
0853:                // Turn -off- the new min/max behaviour
0854:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0855:                apiStore
0856:                        .setValue(
0857:                                IWorkbenchPreferenceConstants.ENABLE_NEW_MIN_MAX,
0858:                                false);
0859:            }
0860:
0861:            /**
0862:             * @param themeToSelect the id of the theme to be selected
0863:             */
0864:            private void refreshThemeCombo(String themeToSelect) {
0865:                themeCombo.removeAll();
0866:                ITheme currentTheme = PlatformUI.getWorkbench()
0867:                        .getThemeManager().getCurrentTheme();
0868:
0869:                IThemeDescriptor[] descs = WorkbenchPlugin.getDefault()
0870:                        .getThemeRegistry().getThemes();
0871:                String defaultThemeString = PlatformUI.getWorkbench()
0872:                        .getThemeManager()
0873:                        .getTheme(IThemeManager.DEFAULT_THEME).getLabel();
0874:                if (currentTheme.getId().equals(IThemeManager.DEFAULT_THEME)) {
0875:                    defaultThemeString = NLS
0876:                            .bind(
0877:                                    WorkbenchMessages.ViewsPreference_currentThemeFormat,
0878:                                    new Object[] { defaultThemeString });
0879:                }
0880:                themeCombo.add(defaultThemeString);
0881:
0882:                String themeString;
0883:                int selection = 0;
0884:                for (int i = 0; i < descs.length; i++) {
0885:                    themeString = descs[i].getName();
0886:                    if (descs[i].getId().equals(currentTheme.getId())) {
0887:                        themeString = NLS
0888:                                .bind(
0889:                                        WorkbenchMessages.ViewsPreference_currentThemeFormat,
0890:                                        new Object[] { themeString });
0891:                    }
0892:                    if (themeToSelect.equals(descs[i].getId())) {
0893:                        selection = i + 1;
0894:                    }
0895:                    themeCombo.add(themeString);
0896:                }
0897:                themeCombo.select(selection);
0898:            }
0899:
0900:            /**
0901:             * Create the button and text that support setting the preference for
0902:             * showing text labels on the perspective switching bar.
0903:             */
0904:            protected void createShowTextOnPerspectiveBarPref(
0905:                    Composite composite) {
0906:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0907:
0908:                showTextOnPerspectiveBar = createCheckButton(
0909:                        composite,
0910:                        WorkbenchMessages.WorkbenchPreference_showTextOnPerspectiveBar,
0911:                        apiStore
0912:                                .getBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
0913:            }
0914:
0915:            /**
0916:             * Create the button and text that support setting the preference for
0917:             * showing text labels on the perspective switching bar
0918:             */
0919:            protected void createShowTraditionalStyleTabsPref(
0920:                    Composite composite) {
0921:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0922:
0923:                showTraditionalStyleTabs = createCheckButton(
0924:                        composite,
0925:                        WorkbenchMessages.ViewsPreference_traditionalTabs,
0926:                        apiStore
0927:                                .getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
0928:            }
0929:
0930:            protected void createEnableAnimationsPref(Composite composite) {
0931:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0932:
0933:                enableAnimations = createCheckButton(
0934:                        composite,
0935:                        WorkbenchMessages.ViewsPreference_enableAnimations,
0936:                        apiStore
0937:                                .getBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS));
0938:            }
0939:
0940:            /**
0941:             * Returns preference store that belongs to the our plugin.
0942:             * 
0943:             * @return IPreferenceStore the preference store for this plugin
0944:             */
0945:            protected IPreferenceStore doGetPreferenceStore() {
0946:                return WorkbenchPlugin.getDefault().getPreferenceStore();
0947:            }
0948:
0949:            /**
0950:             * Initializes this preference page for the given workbench.
0951:             * <p>
0952:             * This method is called automatically as the preference page is being
0953:             * created and initialized. Clients must not call this method.
0954:             * </p>
0955:             * 
0956:             * @param workbench  the workbench
0957:             */
0958:            public void init(IWorkbench workbench) {
0959:                currentPresentationFactoryId = PrefUtil
0960:                        .getAPIPreferenceStore()
0961:                        .getString(
0962:                                IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
0963:            }
0964:
0965:            /**
0966:             * The default button has been pressed.
0967:             */
0968:            protected void performDefaults() {
0969:                IPreferenceStore store = getPreferenceStore();
0970:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
0971:
0972:                showTextOnPerspectiveBar
0973:                        .setSelection(apiStore
0974:                                .getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR));
0975:                showTraditionalStyleTabs
0976:                        .setSelection(apiStore
0977:                                .getDefaultBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
0978:                enableAnimations
0979:                        .setSelection(apiStore
0980:                                .getDefaultBoolean(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS));
0981:
0982:                String presID = apiStore
0983:                        .getDefaultString(IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID);
0984:                currentPresentationFactoryId = presID;
0985:                setPresentationSelection();
0986:
0987:                boolean overridePrefs = store
0988:                        .getDefaultBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
0989:                overridePresButton.setSelection(overridePrefs);
0990:
0991:                updateOverrideState(overridePrefs);
0992:
0993:                setEditorAlignDefault(store);
0994:                setViewAlignDefault(store);
0995:
0996:                perspBarLocation = apiStore
0997:                        .getDefaultString(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
0998:                perspLeftButton.setSelection(IWorkbenchPreferenceConstants.LEFT
0999:                        .equals(perspBarLocation));
1000:                perspTopLeftButton
1001:                        .setSelection(IWorkbenchPreferenceConstants.TOP_LEFT
1002:                                .equals(perspBarLocation));
1003:                perspTopRightButton
1004:                        .setSelection(IWorkbenchPreferenceConstants.TOP_RIGHT
1005:                                .equals(perspBarLocation));
1006:
1007:                refreshThemeCombo(PlatformUI.getWorkbench().getThemeManager()
1008:                        .getTheme(IThemeManager.DEFAULT_THEME).getId());
1009:                refreshThemeDescriptionText();
1010:
1011:                WorkbenchPlugin.getDefault().savePluginPreferences();
1012:
1013:                super .performDefaults();
1014:            }
1015:
1016:            /**
1017:             * The user has pressed Ok. Store/apply this page's values appropriately.
1018:             */
1019:            public boolean performOk() {
1020:                IPreferenceStore store = getPreferenceStore();
1021:                IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
1022:                boolean override = store
1023:                        .getBoolean(IPreferenceConstants.OVERRIDE_PRESENTATION);
1024:
1025:                // apply the presentation selection first since it might change some of
1026:                // the other values
1027:                boolean restart = updatePresentationPreferences();
1028:
1029:                if (showTextOnPerspBar.equals(INITIAL_VAL) && !override) {
1030:                    apiStore
1031:                            .setToDefault(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR);
1032:                } else {
1033:                    apiStore
1034:                            .setValue(
1035:                                    IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR,
1036:                                    showTextOnPerspectiveBar.getSelection());
1037:                }
1038:
1039:                if (editorAlignmentChanged) {
1040:                    if (editorAlignment == INITIAL_LOC_INT) {
1041:                        store
1042:                                .setToDefault(IPreferenceConstants.EDITOR_TAB_POSITION);
1043:                    } else if (!override) {
1044:                        // store the editor tab value to setting
1045:                        store.setValue(
1046:                                IPreferenceConstants.EDITOR_TAB_POSITION,
1047:                                editorAlignment);
1048:                    } else {
1049:                        // store the editor tab value to setting
1050:                        store.setValue(
1051:                                IPreferenceConstants.EDITOR_TAB_POSITION,
1052:                                editorAlignment);
1053:                    }
1054:                    restart = true;
1055:                }
1056:
1057:                if (viewAlignmentChanged) {
1058:                    if (viewAlignment == INITIAL_LOC_INT) {
1059:                        store
1060:                                .setToDefault(IPreferenceConstants.VIEW_TAB_POSITION);
1061:                    } else if (!override) {
1062:                        // store the view tab value to setting
1063:                        store.setValue(IPreferenceConstants.VIEW_TAB_POSITION,
1064:                                viewAlignment);
1065:                    } else {
1066:                        // store the view tab value to setting
1067:                        store.setValue(IPreferenceConstants.VIEW_TAB_POSITION,
1068:                                viewAlignment);
1069:                    }
1070:                    restart = true;
1071:                }
1072:
1073:                if (perspBarLocation.equals(INITIAL_VAL)) {
1074:                    apiStore
1075:                            .setToDefault(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR);
1076:                } else if (!override) {
1077:                    // store the perspective bar text enabled setting
1078:                    apiStore.setValue(
1079:                            IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
1080:                            perspBarLocation);
1081:                } else {
1082:                    // store the perspective bar text enabled setting
1083:                    apiStore.setValue(
1084:                            IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
1085:                            perspBarLocation);
1086:                }
1087:
1088:                if (fastViewLoc.equals(INITIAL_VAL)) {
1089:                    apiStore
1090:                            .setToDefault(IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION);
1091:                } else {
1092:                    apiStore
1093:                            .setValue(
1094:                                    IWorkbenchPreferenceConstants.INITIAL_FAST_VIEW_BAR_LOCATION,
1095:                                    fastViewLoc);
1096:                }
1097:
1098:                int idx = themeCombo.getSelectionIndex();
1099:                if (idx <= 0) {
1100:                    Workbench.getInstance().getThemeManager().setCurrentTheme(
1101:                            IThemeManager.DEFAULT_THEME);
1102:                    refreshThemeCombo(IThemeManager.DEFAULT_THEME);
1103:                } else {
1104:                    IThemeDescriptor applyTheme = WorkbenchPlugin.getDefault()
1105:                            .getThemeRegistry().getThemes()[idx - 1];
1106:                    Workbench.getInstance().getThemeManager().setCurrentTheme(
1107:                            applyTheme.getId());
1108:                    refreshThemeCombo(applyTheme.getId());
1109:                }
1110:                refreshThemeDescriptionText();
1111:
1112:                apiStore
1113:                        .setValue(
1114:                                IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS,
1115:                                showTraditionalStyleTabs.getSelection());
1116:                apiStore.setValue(
1117:                        IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS,
1118:                        enableAnimations.getSelection());
1119:
1120:                PrefUtil.savePrefs();
1121:
1122:                // we can get here through performApply, in that case only post one
1123:                // restart
1124:                if (restart && !restartPosted) {
1125:                    if (getContainer() instanceof  IWorkbenchPreferenceContainer) {
1126:                        IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
1127:                        UIJob job = new UIJob(
1128:                                WorkbenchMessages.ViewsPreference_restartRequestJobName) {
1129:                            public IStatus runInUIThread(
1130:                                    IProgressMonitor monitor) {
1131:                                // make sure they really want to do this
1132:                                int really = new MessageDialog(
1133:                                        null,
1134:                                        WorkbenchMessages.ViewsPreference_presentationConfirm_title,
1135:                                        null,
1136:                                        WorkbenchMessages.ViewsPreference_presentationConfirm_message,
1137:                                        MessageDialog.QUESTION,
1138:                                        new String[] {
1139:                                                WorkbenchMessages.ViewsPreference_presentationConfirm_yes,
1140:                                                WorkbenchMessages.ViewsPreference_presentationConfirm_no },
1141:                                        1).open();
1142:                                if (really == Window.OK) {
1143:                                    PlatformUI.getWorkbench().restart();
1144:                                }
1145:                                return Status.OK_STATUS;
1146:                            }
1147:                        };
1148:                        job.setSystem(true);
1149:                        container.registerUpdateJob(job);
1150:                        restartPosted = true;
1151:                    }
1152:                }
1153:                return true;
1154:            }
1155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.