1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.preference.IPreferenceStore; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.events.SelectionAdapter; 17 import org.eclipse.swt.events.SelectionEvent; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Menu; 20 import org.eclipse.swt.widgets.MenuItem; 21 import org.eclipse.ui.IEditorReference; 22 import org.eclipse.ui.IWorkbenchPart; 23 import org.eclipse.ui.internal.tweaklets.TabBehaviour; 24 import org.eclipse.ui.internal.tweaklets.Tweaklets; 25 import org.eclipse.ui.presentations.StackPresentation; 26 27 31 public class EditorPane extends PartPane { 32 private EditorStack workbook; 33 34 35 41 public EditorPane(IEditorReference ref, WorkbenchPage page, 42 EditorStack workbook) { 43 super(ref, page); 44 this.workbook = workbook; 45 } 46 47 53 protected void createTitleBar() { 54 } 56 57 60 public void doHide() { 61 getPage().closeEditor(getEditorReference(), true); 62 } 63 64 68 public IEditorReference getEditorReference() { 69 return (IEditorReference) getPartReference(); 70 } 71 72 75 int getStyle() { 76 return SWT.NONE; 77 } 78 79 83 public EditorStack getWorkbook() { 84 return workbook; 85 } 86 87 91 public void requestActivation() { 92 if (!workbook.isActiveWorkbook()) { 95 workbook.getEditorArea().setActiveWorkbook(null, false); 96 } 97 98 super.requestActivation(); 99 } 100 101 105 public void setWorkbook(EditorStack editorWorkbook) { 106 workbook = editorWorkbook; 107 } 108 109 112 void shellActivated() { 113 } 115 116 119 void shellDeactivated() { 120 } 122 123 126 public void setFocus() { 127 super.setFocus(); 128 129 workbook.becomeActiveWorkbook(true); 130 } 131 132 135 public void showFocus(boolean inFocus) { 136 if (inFocus) { 137 this.workbook.becomeActiveWorkbook(true); 138 } else { 139 this.workbook 140 .setActive(this.workbook.isActiveWorkbook() ? StackPresentation.AS_ACTIVE_NOFOCUS 141 : StackPresentation.AS_INACTIVE); 142 } 143 } 144 145 149 protected void addPinEditorItem(Menu parent) { 150 IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); 151 boolean reuseEditor = store 152 .getBoolean(IPreferenceConstants.REUSE_EDITORS_BOOLEAN) 153 || ((TabBehaviour)Tweaklets.get(TabBehaviour.KEY)).alwaysShowPinAction(); 154 if (!reuseEditor) { 155 return; 156 } 157 158 final WorkbenchPartReference ref = (WorkbenchPartReference)getPartReference(); 159 160 final MenuItem item = new MenuItem(parent, SWT.CHECK); 161 item.setText(WorkbenchMessages.EditorPane_pinEditor); 162 item.addSelectionListener(new SelectionAdapter() { 163 public void widgetSelected(SelectionEvent e) { 164 IWorkbenchPart part = getPartReference().getPart(true); 165 if (part == null) { 166 item.setSelection(false); 168 item.setEnabled(false); 169 } else { 170 ref.setPinned(item.getSelection()); 171 } 172 } 173 }); 174 item.setEnabled(true); 175 item.setSelection(ref.isPinned()); 176 } 177 178 181 public void updateTitles() { 182 } 184 185 188 public void testInvariants() { 189 super.testInvariants(); 190 191 if (getContainer() != null) { 192 Assert.isTrue(getContainer() == workbook); 193 } 194 } 195 196 197 201 public String getName() { 202 return null; 203 } 204 205 208 public Control getToolBar() { 209 return null; 210 } 211 212 215 public boolean isCloseable() { 216 return true; 217 } 218 219 } 220 | Popular Tags |