1 11 12 package org.eclipse.pde.internal.ui.editor; 13 14 import org.eclipse.jface.text.information.IInformationPresenter; 15 import org.eclipse.jface.text.source.IOverviewRuler; 16 import org.eclipse.jface.text.source.IVerticalRuler; 17 import org.eclipse.jface.text.source.SourceViewerConfiguration; 18 import org.eclipse.jface.text.source.projection.ProjectionViewer; 19 import org.eclipse.pde.internal.ui.editor.text.ChangeAwareSourceViewerConfiguration; 20 import org.eclipse.swt.widgets.Composite; 21 22 26 public class PDEProjectionViewer extends ProjectionViewer { 27 28 31 public static final int QUICK_OUTLINE = 513; 32 33 private IInformationPresenter fOutlinePresenter; 34 35 private boolean fIsQuickOutlineEnabled; 36 37 44 public PDEProjectionViewer(Composite parent, IVerticalRuler ruler, 45 IOverviewRuler overviewRuler, boolean showsAnnotationOverview, 46 int styles, boolean isQuickOutlineEnabled) { 47 super(parent, ruler, overviewRuler, showsAnnotationOverview, styles); 48 49 fIsQuickOutlineEnabled = isQuickOutlineEnabled; 50 } 51 52 55 public void doOperation(int operation) { 56 if ((getTextWidget() == null) || 58 getTextWidget().isDisposed()) { 59 return; 60 } 61 if (operation == QUICK_OUTLINE) { 63 if (fOutlinePresenter != null) { 64 fOutlinePresenter.showInformation(); 65 } 66 return; 67 } 68 super.doOperation(operation); 70 } 71 72 75 public boolean canDoOperation(int operation) { 76 if (operation == QUICK_OUTLINE) { 78 if (fOutlinePresenter == null) { 79 return false; 80 } 81 return true; 82 } 83 return super.canDoOperation(operation); 85 } 86 87 90 public void configure(SourceViewerConfiguration configuration) { 91 if ((getTextWidget() == null) || 93 getTextWidget().isDisposed()) { 94 return; 95 } 96 super.configure(configuration); 98 if (fIsQuickOutlineEnabled && 101 configuration instanceof ChangeAwareSourceViewerConfiguration) { 102 ChangeAwareSourceViewerConfiguration sourceConfiguration = 103 (ChangeAwareSourceViewerConfiguration)configuration; 104 fOutlinePresenter = sourceConfiguration.getOutlinePresenter(this); 105 if (fOutlinePresenter != null) { 106 fOutlinePresenter.install(this); 107 } 108 } 109 } 110 111 114 public void unconfigure() { 115 if (fOutlinePresenter != null) { 117 fOutlinePresenter.uninstall(); 118 fOutlinePresenter = null; 119 } 120 super.unconfigure(); 122 } 123 124 } 125 | Popular Tags |