1 11 12 package org.eclipse.ui.presentations; 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.IPreferenceConstants; 20 import org.eclipse.ui.internal.WorkbenchPlugin; 21 import org.eclipse.ui.internal.preferences.IDynamicPropertyMap; 22 import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultMultiTabListener; 23 import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultSimpleTabListener; 24 import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder; 25 import org.eclipse.ui.internal.presentations.defaultpresentation.DefaultThemeListener; 26 import org.eclipse.ui.internal.presentations.defaultpresentation.EmptyTabFolder; 27 import org.eclipse.ui.internal.presentations.util.PresentablePartFolder; 28 import org.eclipse.ui.internal.presentations.util.StandardEditorSystemMenu; 29 import org.eclipse.ui.internal.presentations.util.StandardViewSystemMenu; 30 import org.eclipse.ui.internal.presentations.util.TabbedStackPresentation; 31 32 37 public class WorkbenchPresentationFactory extends AbstractPresentationFactory { 38 39 private static int editorTabPosition = WorkbenchPlugin 44 .getDefault().getPreferenceStore().getInt(IPreferenceConstants.EDITOR_TAB_POSITION); 45 private static int viewTabPosition = WorkbenchPlugin 46 .getDefault().getPreferenceStore().getInt(IPreferenceConstants.VIEW_TAB_POSITION); 47 48 51 public StackPresentation createEditorPresentation(Composite parent, 52 IStackPresentationSite site) { 53 DefaultTabFolder folder = new DefaultTabFolder(parent, editorTabPosition | SWT.BORDER, 54 site.supportsState(IStackPresentationSite.STATE_MINIMIZED), 55 site.supportsState(IStackPresentationSite.STATE_MAXIMIZED)); 56 57 64 final IPreferenceStore store = PlatformUI.getPreferenceStore(); 65 if (store 66 .contains(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS)) { 67 final int minimumCharacters = store 68 .getInt(IWorkbenchPreferenceConstants.EDITOR_MINIMUM_CHARACTERS); 69 if (minimumCharacters >= 0) { 70 folder.setMinimumCharacters(minimumCharacters); 71 } 72 } 73 74 PresentablePartFolder partFolder = new PresentablePartFolder(folder); 75 76 TabbedStackPresentation result = new TabbedStackPresentation(site, partFolder, 77 new StandardEditorSystemMenu(site)); 78 79 DefaultThemeListener themeListener = new DefaultThemeListener(folder, result.getTheme()); 80 result.getTheme().addListener(themeListener); 81 82 IDynamicPropertyMap workbenchPreferences = result.getPluginPreferences(WorkbenchPlugin.getDefault()); 83 84 new DefaultMultiTabListener(workbenchPreferences, 85 IPreferenceConstants.SHOW_MULTIPLE_EDITOR_TABS, folder); 86 87 new DefaultSimpleTabListener(result.getApiPreferences(), 88 IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, 89 folder); 90 91 return result; 92 } 93 94 100 public StackPresentation createViewPresentation(Composite parent, 101 IStackPresentationSite site) { 102 103 DefaultTabFolder folder = new DefaultTabFolder(parent, viewTabPosition | SWT.BORDER, 104 site.supportsState(IStackPresentationSite.STATE_MINIMIZED), 105 site.supportsState(IStackPresentationSite.STATE_MAXIMIZED)); 106 107 final IPreferenceStore store = PlatformUI.getPreferenceStore(); 108 final int minimumCharacters = store 109 .getInt(IWorkbenchPreferenceConstants.VIEW_MINIMUM_CHARACTERS); 110 if (minimumCharacters >= 0) { 111 folder.setMinimumCharacters(minimumCharacters); 112 } 113 114 PresentablePartFolder partFolder = new PresentablePartFolder(folder); 115 116 folder.setUnselectedCloseVisible(false); 117 folder.setUnselectedImageVisible(false); 118 119 TabbedStackPresentation result = new TabbedStackPresentation(site, partFolder, 120 new StandardViewSystemMenu(site)); 121 122 DefaultThemeListener themeListener = new DefaultThemeListener(folder, result.getTheme()); 123 result.getTheme().addListener(themeListener); 124 125 new DefaultSimpleTabListener(result.getApiPreferences(), 126 IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS, 127 folder); 128 129 return result; 130 } 131 132 138 public StackPresentation createStandaloneViewPresentation(Composite parent, 139 IStackPresentationSite site, boolean showTitle) { 140 141 if (showTitle) { 142 return createViewPresentation(parent, site); 143 } 144 EmptyTabFolder folder = new EmptyTabFolder(parent, true); 145 TabbedStackPresentation presentation = new TabbedStackPresentation(site, folder, new StandardViewSystemMenu(site)); 146 147 return presentation; 148 } 149 150 } 151 | Popular Tags |