1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.jface.action.ContributionItem; 14 import org.eclipse.jface.action.IContributionItem; 15 import org.eclipse.jface.action.ToolBarManager; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.events.SelectionEvent; 18 import org.eclipse.swt.events.SelectionListener; 19 import org.eclipse.swt.graphics.Image; 20 import org.eclipse.swt.widgets.ToolBar; 21 import org.eclipse.swt.widgets.ToolItem; 22 import org.eclipse.ui.IPageLayout; 23 import org.eclipse.ui.IViewReference; 24 import org.eclipse.ui.internal.layout.TrimToolBarBase; 25 26 public class EditorAreaTrimToolBar extends TrimToolBarBase { 27 private LayoutPart editorArea; 28 private boolean restoreOnUnzoom = false; 29 30 private int paneOrientation; 32 33 public EditorAreaTrimToolBar(WorkbenchWindow wbw, LayoutPart editorArea) { 34 super(IPageLayout.ID_EDITOR_AREA, SWT.TOP, wbw); 35 36 this.editorArea = editorArea; 37 dock(SWT.TOP); 38 } 39 40 43 protected void restoreToPresentation() { 44 EditorSashContainer esc = (EditorSashContainer)editorArea; 45 EditorStack curStack = esc.getUpperRightEditorStack(esc.getChildren()); 46 curStack.setMinimized(false); 47 } 48 49 public void initToolBarManager(final ToolBarManager mgr) { 50 IContributionItem restoreContrib = new ContributionItem() { 52 public void fill(ToolBar parent, int index) { 53 ToolItem restoreItem = new ToolItem(mgr.getControl(), SWT.PUSH, index); 54 Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART); 55 restoreItem.setImage(tbImage); 56 String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore; 57 restoreItem.setToolTipText(menuTip); 58 restoreItem.addSelectionListener(new SelectionListener() { 59 public void widgetDefaultSelected(SelectionEvent e) { 60 restoreToPresentation(); 61 } 62 public void widgetSelected(SelectionEvent e) { 63 restoreToPresentation(); 64 } 65 }); 66 } 67 }; 68 mgr.add(restoreContrib); 69 70 IContributionItem eaContrib = new ContributionItem() { 72 public void fill(ToolBar parent, int index) { 73 ToolItem editorAreaItem = new ToolItem(mgr.getControl(), SWT.PUSH, index); 74 Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART); 75 editorAreaItem.setImage(tbImage); 76 String menuTip = WorkbenchMessages.EditorArea_Tooltip; 77 editorAreaItem.setToolTipText(menuTip); 78 editorAreaItem.addSelectionListener(new SelectionListener() { 79 public void widgetDefaultSelected(SelectionEvent e) { 80 restoreToPresentation(); 81 } 82 public void widgetSelected(SelectionEvent e) { 83 restoreToPresentation(); 84 } 85 }); 86 } 87 }; 88 mgr.add(eaContrib); 89 } 90 91 94 public void hookControl(ToolBarManager mgr) { 95 new FastViewDnDHandler(id, mgr, wbw); 99 } 100 101 107 public void setRestoreOnUnzoom(boolean restoreOnUnzoom) { 108 this.restoreOnUnzoom = restoreOnUnzoom; 109 } 110 111 public boolean restoreOnUnzoom() { 112 return restoreOnUnzoom; 113 } 114 115 119 public void setIconSelection(IViewReference ref, boolean selected) { 120 ToolItem item = ShowFastViewContribution.getItem(tbMgr.getControl(), ref); 121 if (item != null) 122 item.setSelection(selected); 123 } 124 125 128 public int getPaneOrientation() { 129 return paneOrientation; 130 } 131 } 132 | Popular Tags |