| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2007, 2008 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | |
| 12 | package org.eclipse.ui.internal.presentations.classic; |
| 13 | |
| 14 | import org.eclipse.jface.preference.IPreferenceStore; |
| 15 | import org.eclipse.swt.SWT; |
| 16 | import org.eclipse.swt.widgets.Composite; |
| 17 | import org.eclipse.ui.IWorkbenchPreferenceConstants; |
| 18 | import org.eclipse.ui.PlatformUI; |
| 19 | import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultSimpleTabListener; |
| 20 | import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder; |
| 21 | import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener; |
| 22 | import org.eclipse.ui.internal.presentations.util.PresentablePartFolder; |
| 23 | import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu; |
| 24 | import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; |
| 25 | import org.eclipse.ui.presentations.IStackPresentationSite; |
| 26 | import org.eclipse.ui.presentations.StackPresentation; |
| 27 | import org.eclipse.ui.presentations.WorkbenchPresentationFactory; |
| 28 | |
| 29 | /** |
| 30 | * The classic presentation factory for the Workbench (the 3.0 look). |
| 31 | * |
| 32 | * @since 3.4 |
| 33 | * |
| 34 | */ |
| 35 | public class WorkbenchPresentationFactoryClassic extends |
| 36 | WorkbenchPresentationFactory { |
| 37 | |
| 38 | private static int viewTabPosition = PlatformUI.getPreferenceStore() |
| 39 | .getInt(IWorkbenchPreferenceConstants.VIEW_TAB_POSITION); |
| 40 | |
| 41 | /* |
| 42 | * (non-Javadoc) |
| 43 | * |
| 44 | * @see org.eclipse.ui.presentations.WorkbenchPresentationFactory#createViewPresentation(org.eclipse.swt.widgets.Composite, |
| 45 | * org.eclipse.ui.presentations.IStackPresentationSite) |
| 46 | */ |
| 47 | public StackPresentation createViewPresentation(Composite parent, |
| 48 | IStackPresentationSite site) { |
| 49 | |
| 50 | DefaultTabFolder folder = new DefaultTabFolder(parent, viewTabPosition |
| 51 | | SWT.BORDER, site |
| 52 | .supportsState(IStackPresentationSite.STATE_MINIMIZED), site |
| 53 | .supportsState(IStackPresentationSite.STATE_MAXIMIZED)); |
| 54 | |
| 55 | final IPreferenceStore store = PlatformUI.getPreferenceStore(); |
| 56 | final int minimumCharacters = store |
| 57 | .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS); |
| 58 | if (minimumCharacters >= 0) { |
| 59 | folder.setMinimumCharacters(minimumCharacters); |
| 60 | } |
| 61 | |
| 62 | PresentablePartFolder partFolder = new PresentablePartFolder(folder); |
| 63 | |
| 64 | folder.setUnselectedCloseVisible(false); |
| 65 | folder.setUnselectedImageVisible(false); |
| 66 | |
| 67 | TabbedStackPresentation result = new TabbedStackPresentation(site, |
| 68 | partFolder, new StandardViewSystemMenu(site)); |
| 69 | |
| 70 | DefaultThemeListener themeListener = new DefaultThemeListener(folder, |
| 71 | result.getTheme()); |
| 72 | result.getTheme().addListener(themeListener); |
| 73 | |
| 74 | new DefaultSimpleTabListener(result.getApiPreferences(), |
| 75 | IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, |
| 76 | folder); |
| 77 | |
| 78 | return result; |
| 79 | } |
| 80 | } |