1 package net.sourceforge.phpeclipse.phpeditor;
3 /**********************************************************************
4 Copyright (c) 2000, 2002 IBM Corp. and others.
5 All rights reserved. This program and the accompanying materials
6 are made available under the terms of the Common Public License v1.0
7 which accompanies this distribution, and is available at
8 http://www.eclipse.org/legal/cpl-v10.html
11 IBM Corporation - Initial implementation
12 Klaus Hartlage - www.eclipseproject.de
13 **********************************************************************/
14 import java.util.ArrayList;
15 import java.util.HashMap;
16 import java.util.Iterator;
17 import java.util.List;
19 import java.util.ResourceBundle;
20 import java.util.StringTokenizer;
22 import net.sourceforge.phpdt.core.ICompilationUnit;
23 import net.sourceforge.phpdt.core.IJavaElement;
24 import net.sourceforge.phpdt.core.IMember;
25 import net.sourceforge.phpdt.core.ISourceRange;
26 import net.sourceforge.phpdt.core.ISourceReference;
27 import net.sourceforge.phpdt.core.JavaCore;
28 import net.sourceforge.phpdt.core.JavaModelException;
29 import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
30 import net.sourceforge.phpdt.internal.ui.actions.FoldingActionGroup;
31 import net.sourceforge.phpdt.internal.ui.text.CustomSourceInformationControl;
32 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
33 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
34 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
35 import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
36 import net.sourceforge.phpdt.ui.IContextMenuConstants;
37 import net.sourceforge.phpdt.ui.JavaUI;
38 import net.sourceforge.phpdt.ui.PreferenceConstants;
39 import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
40 import net.sourceforge.phpdt.ui.text.JavaTextTools;
41 import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
42 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
44 import org.eclipse.core.resources.IMarker;
45 import org.eclipse.core.resources.IResource;
46 import org.eclipse.core.runtime.CoreException;
47 import org.eclipse.core.runtime.IProgressMonitor;
48 import org.eclipse.core.runtime.IStatus;
49 import org.eclipse.core.runtime.Preferences;
50 import org.eclipse.core.runtime.Status;
51 import org.eclipse.core.runtime.jobs.Job;
52 import org.eclipse.jface.action.Action;
53 import org.eclipse.jface.action.GroupMarker;
54 import org.eclipse.jface.action.IAction;
55 import org.eclipse.jface.action.MenuManager;
56 import org.eclipse.jface.action.Separator;
57 import org.eclipse.jface.preference.IPreferenceStore;
58 import org.eclipse.jface.preference.PreferenceConverter;
59 import org.eclipse.jface.text.BadLocationException;
60 import org.eclipse.jface.text.DefaultInformationControl;
61 import org.eclipse.jface.text.DocumentEvent;
62 import org.eclipse.jface.text.IDocument;
63 import org.eclipse.jface.text.IDocumentListener;
64 import org.eclipse.jface.text.IInformationControl;
65 import org.eclipse.jface.text.IInformationControlCreator;
66 import org.eclipse.jface.text.IRegion;
67 import org.eclipse.jface.text.ITextHover;
68 import org.eclipse.jface.text.ITextInputListener;
69 import org.eclipse.jface.text.ITextSelection;
70 import org.eclipse.jface.text.ITextViewer;
71 import org.eclipse.jface.text.ITextViewerExtension2;
72 import org.eclipse.jface.text.ITextViewerExtension3;
73 import org.eclipse.jface.text.ITypedRegion;
74 import org.eclipse.jface.text.Position;
75 import org.eclipse.jface.text.Region;
76 import org.eclipse.jface.text.TextSelection;
77 import org.eclipse.jface.text.information.IInformationProvider;
78 import org.eclipse.jface.text.information.InformationPresenter;
79 import org.eclipse.jface.text.source.Annotation;
80 import org.eclipse.jface.text.source.IAnnotationModel;
81 import org.eclipse.jface.text.source.IAnnotationModelExtension;
82 import org.eclipse.jface.text.source.IOverviewRuler;
83 import org.eclipse.jface.text.source.ISourceViewer;
84 import org.eclipse.jface.text.source.IVerticalRuler;
85 import org.eclipse.jface.text.source.OverviewRuler;
86 import org.eclipse.jface.text.source.SourceViewerConfiguration;
87 import org.eclipse.jface.text.source.projection.ProjectionSupport;
88 import org.eclipse.jface.text.source.projection.ProjectionViewer;
89 import org.eclipse.jface.util.IPropertyChangeListener;
90 import org.eclipse.jface.util.PropertyChangeEvent;
91 import org.eclipse.jface.viewers.ISelection;
92 import org.eclipse.jface.viewers.ISelectionChangedListener;
93 import org.eclipse.jface.viewers.ISelectionProvider;
94 import org.eclipse.jface.viewers.IStructuredSelection;
95 import org.eclipse.jface.viewers.SelectionChangedEvent;
96 import org.eclipse.jface.viewers.StructuredSelection;
97 import org.eclipse.swt.SWT;
98 import org.eclipse.swt.custom.BidiSegmentEvent;
99 import org.eclipse.swt.custom.BidiSegmentListener;
100 import org.eclipse.swt.custom.StyleRange;
101 import org.eclipse.swt.custom.StyledText;
102 import org.eclipse.swt.events.FocusEvent;
103 import org.eclipse.swt.events.FocusListener;
104 import org.eclipse.swt.events.KeyEvent;
105 import org.eclipse.swt.events.KeyListener;
106 import org.eclipse.swt.events.MouseEvent;
107 import org.eclipse.swt.events.MouseListener;
108 import org.eclipse.swt.events.MouseMoveListener;
109 import org.eclipse.swt.events.PaintEvent;
110 import org.eclipse.swt.events.PaintListener;
111 import org.eclipse.swt.graphics.Color;
112 import org.eclipse.swt.graphics.Cursor;
113 import org.eclipse.swt.graphics.GC;
114 import org.eclipse.swt.graphics.Image;
115 import org.eclipse.swt.graphics.Point;
116 import org.eclipse.swt.graphics.RGB;
117 import org.eclipse.swt.widgets.Composite;
118 import org.eclipse.swt.widgets.Control;
119 import org.eclipse.swt.widgets.Display;
120 import org.eclipse.swt.widgets.Shell;
121 import org.eclipse.ui.IEditorInput;
122 import org.eclipse.ui.IPageLayout;
123 import org.eclipse.ui.IPartService;
124 import org.eclipse.ui.IViewPart;
125 import org.eclipse.ui.IWorkbenchPage;
126 import org.eclipse.ui.IWorkbenchPart;
127 import org.eclipse.ui.IWorkbenchWindow;
128 import org.eclipse.ui.actions.ActionContext;
129 import org.eclipse.ui.actions.ActionGroup;
130 import org.eclipse.ui.editors.text.DefaultEncodingSupport;
131 import org.eclipse.ui.editors.text.IEncodingSupport;
132 import org.eclipse.ui.part.IShowInTargetList;
133 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
134 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
135 import org.eclipse.ui.texteditor.IDocumentProvider;
136 import org.eclipse.ui.texteditor.IEditorStatusLine;
137 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
138 import org.eclipse.ui.texteditor.MarkerAnnotation;
139 import org.eclipse.ui.texteditor.ResourceAction;
140 import org.eclipse.ui.texteditor.TextEditorAction;
141 import org.eclipse.ui.texteditor.TextOperationAction;
142 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
143 import org.eclipse.ui.views.tasklist.TaskList;
146 * PHP specific text editor.
148 public abstract class PHPEditor extends AbstractDecoratedTextEditor implements IViewPartInputProvider {
149 //extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor {
151 * "Smart" runnable for updating the outline page's selection.
153 class OutlinePageSelectionUpdater implements Runnable {
155 /** Has the runnable already been posted? */
156 private boolean fPosted = false;
158 public OutlinePageSelectionUpdater() {
162 * @see Runnable#run()
165 synchronizeOutlinePageSelection();
170 * Posts this runnable into the event queue.
176 Shell shell = getSite().getShell();
177 if (shell != null & !shell.isDisposed()) {
179 shell.getDisplay().asyncExec(this);
183 class SelectionChangedListener implements ISelectionChangedListener {
184 public void selectionChanged(SelectionChangedEvent event) {
185 doSelectionChanged(event);
192 class MouseClickListener
193 implements KeyListener, MouseListener, MouseMoveListener, FocusListener, PaintListener, IPropertyChangeListener, IDocumentListener, ITextInputListener {
195 /** The session is active. */
196 private boolean fActive;
198 /** The currently active style range. */
199 private IRegion fActiveRegion;
200 /** The currently active style range as position. */
201 private Position fRememberedPosition;
202 /** The hand cursor. */
203 private Cursor fCursor;
205 /** The link color. */
206 private Color fColor;
207 /** The key modifier mask. */
208 private int fKeyModifierMask;
210 public void deactivate() {
214 public void deactivate(boolean redrawAll) {
218 repairRepresentation(redrawAll);
222 public void install() {
224 ISourceViewer sourceViewer = getSourceViewer();
225 if (sourceViewer == null)
228 StyledText text = sourceViewer.getTextWidget();
229 if (text == null || text.isDisposed())
232 updateColor(sourceViewer);
234 sourceViewer.addTextInputListener(this);
236 IDocument document = sourceViewer.getDocument();
237 if (document != null)
238 document.addDocumentListener(this);
240 text.addKeyListener(this);
241 text.addMouseListener(this);
242 text.addMouseMoveListener(this);
243 text.addFocusListener(this);
244 text.addPaintListener(this);
246 updateKeyModifierMask();
248 IPreferenceStore preferenceStore = getPreferenceStore();
249 preferenceStore.addPropertyChangeListener(this);
252 private void updateKeyModifierMask() {
253 String modifiers = getPreferenceStore().getString(BROWSER_LIKE_LINKS_KEY_MODIFIER);
254 fKeyModifierMask = computeStateMask(modifiers);
255 if (fKeyModifierMask == -1) {
256 // Fallback to stored state mask
257 fKeyModifierMask = getPreferenceStore().getInt(BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
261 private int computeStateMask(String modifiers) {
262 if (modifiers == null)
265 if (modifiers.length() == 0)
269 StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
270 while (modifierTokenizer.hasMoreTokens()) {
271 int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
272 if (modifier == 0 || (stateMask & modifier) == modifier)
274 stateMask = stateMask | modifier;
279 public void uninstall() {
281 if (fColor != null) {
286 if (fCursor != null) {
291 ISourceViewer sourceViewer = getSourceViewer();
292 if (sourceViewer == null)
295 sourceViewer.removeTextInputListener(this);
297 IDocument document = sourceViewer.getDocument();
298 if (document != null)
299 document.removeDocumentListener(this);
301 IPreferenceStore preferenceStore = getPreferenceStore();
302 if (preferenceStore != null)
303 preferenceStore.removePropertyChangeListener(this);
305 StyledText text = sourceViewer.getTextWidget();
306 if (text == null || text.isDisposed())
309 text.removeKeyListener(this);
310 text.removeMouseListener(this);
311 text.removeMouseMoveListener(this);
312 text.removeFocusListener(this);
313 text.removePaintListener(this);
317 * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
319 public void propertyChange(PropertyChangeEvent event) {
320 if (event.getProperty().equals(PHPEditor.LINK_COLOR)) {
321 ISourceViewer viewer = getSourceViewer();
324 } else if (event.getProperty().equals(BROWSER_LIKE_LINKS_KEY_MODIFIER)) {
325 updateKeyModifierMask();
329 private void updateColor(ISourceViewer viewer) {
333 StyledText text = viewer.getTextWidget();
334 if (text == null || text.isDisposed())
337 Display display = text.getDisplay();
338 fColor = createColor(getPreferenceStore(), PHPEditor.LINK_COLOR, display);
342 * Creates a color from the information stored in the given preference store.
343 * Returns <code>null</code> if there is no such information available.
345 private Color createColor(IPreferenceStore store, String key, Display display) {
349 if (store.contains(key)) {
351 if (store.isDefault(key))
352 rgb = PreferenceConverter.getDefaultColor(store, key);
354 rgb = PreferenceConverter.getColor(store, key);
357 return new Color(display, rgb);
363 private void repairRepresentation() {
364 repairRepresentation(false);
367 private void repairRepresentation(boolean redrawAll) {
369 if (fActiveRegion == null)
372 ISourceViewer viewer = getSourceViewer();
373 if (viewer != null) {
376 int offset = fActiveRegion.getOffset();
377 int length = fActiveRegion.getLength();
380 if (!redrawAll && viewer instanceof ITextViewerExtension2)
381 ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length);
383 viewer.invalidateTextPresentation();
386 if (viewer instanceof ITextViewerExtension3) {
387 ITextViewerExtension3 extension = (ITextViewerExtension3) viewer;
388 offset = extension.modelOffset2WidgetOffset(offset);
390 offset -= viewer.getVisibleRegion().getOffset();
393 StyledText text = viewer.getTextWidget();
395 text.redrawRange(offset, length, true);
396 } catch (IllegalArgumentException x) {
397 PHPeclipsePlugin.log(x);
401 fActiveRegion = null;
404 // will eventually be replaced by a method provided by jdt.core
405 private IRegion selectWord(IDocument document, int anchor) {
411 while (offset >= 0) {
412 c = document.getChar(offset);
413 if (!Character.isJavaIdentifierPart(c))
421 int length = document.getLength();
423 while (offset < length) {
424 c = document.getChar(offset);
425 if (!Character.isJavaIdentifierPart(c))
433 return new Region(start, 0);
435 return new Region(start + 1, end - start - 1);
437 } catch (BadLocationException x) {
442 IRegion getCurrentTextRegion(ISourceViewer viewer) {
444 int offset = getCurrentTextOffset(viewer);
449 // IJavaElement input= SelectionConverter.getInput(PHPEditor.this);
450 // if (input == null)
455 // IJavaElement[] elements= null;
456 // synchronized (input) {
457 // elements= ((ICodeAssist) input).codeSelect(offset, 0);
460 // if (elements == null || elements.length == 0)
463 // return selectWord(viewer.getDocument(), offset);
465 // } catch (JavaModelException e) {
470 private int getCurrentTextOffset(ISourceViewer viewer) {
473 StyledText text = viewer.getTextWidget();
474 if (text == null || text.isDisposed())
477 Display display = text.getDisplay();
478 Point absolutePosition = display.getCursorLocation();
479 Point relativePosition = text.toControl(absolutePosition);
481 int widgetOffset = text.getOffsetAtLocation(relativePosition);
482 if (viewer instanceof ITextViewerExtension3) {
483 ITextViewerExtension3 extension = (ITextViewerExtension3) viewer;
484 return extension.widgetOffset2ModelOffset(widgetOffset);
486 return widgetOffset + viewer.getVisibleRegion().getOffset();
489 } catch (IllegalArgumentException e) {
494 private void highlightRegion(ISourceViewer viewer, IRegion region) {
496 if (region.equals(fActiveRegion))
499 repairRepresentation();
501 StyledText text = viewer.getTextWidget();
502 if (text == null || text.isDisposed())
509 if (viewer instanceof ITextViewerExtension3) {
510 ITextViewerExtension3 extension = (ITextViewerExtension3) viewer;
511 IRegion widgetRange = extension.modelRange2WidgetRange(region);
512 if (widgetRange == null)
515 offset = widgetRange.getOffset();
516 length = widgetRange.getLength();
519 offset = region.getOffset() - viewer.getVisibleRegion().getOffset();
520 length = region.getLength();
523 StyleRange oldStyleRange = text.getStyleRangeAtOffset(offset);
524 Color foregroundColor = fColor;
525 Color backgroundColor = oldStyleRange == null ? text.getBackground() : oldStyleRange.background;
526 StyleRange styleRange = new StyleRange(offset, length, foregroundColor, backgroundColor);
527 text.setStyleRange(styleRange);
530 text.redrawRange(offset, length, true);
532 fActiveRegion = region;
535 private void activateCursor(ISourceViewer viewer) {
536 StyledText text = viewer.getTextWidget();
537 if (text == null || text.isDisposed())
539 Display display = text.getDisplay();
541 fCursor = new Cursor(display, SWT.CURSOR_HAND);
542 text.setCursor(fCursor);
545 private void resetCursor(ISourceViewer viewer) {
546 StyledText text = viewer.getTextWidget();
547 if (text != null && !text.isDisposed())
548 text.setCursor(null);
550 if (fCursor != null) {
557 * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
559 public void keyPressed(KeyEvent event) {
566 if (event.keyCode != fKeyModifierMask) {
573 // removed for #25871
575 // ISourceViewer viewer= getSourceViewer();
576 // if (viewer == null)
579 // IRegion region= getCurrentTextRegion(viewer);
580 // if (region == null)
583 // highlightRegion(viewer, region);
584 // activateCursor(viewer);
588 * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
590 public void keyReleased(KeyEvent event) {
599 * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
601 public void mouseDoubleClick(MouseEvent e) {
604 * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
606 public void mouseDown(MouseEvent event) {
611 if (event.stateMask != fKeyModifierMask) {
616 if (event.button != 1) {
623 * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
625 public void mouseUp(MouseEvent e) {
635 boolean wasActive = fCursor != null;
640 IAction action = getAction("OpenEditor"); //$NON-NLS-1$
647 * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
649 public void mouseMove(MouseEvent event) {
651 if (event.widget instanceof Control && !((Control) event.widget).isFocusControl()) {
657 if (event.stateMask != fKeyModifierMask)
659 // modifier was already pressed
663 ISourceViewer viewer = getSourceViewer();
664 if (viewer == null) {
669 StyledText text = viewer.getTextWidget();
670 if (text == null || text.isDisposed()) {
675 if ((event.stateMask & SWT.BUTTON1) != 0 && text.getSelectionCount() != 0) {
680 IRegion region = getCurrentTextRegion(viewer);
681 if (region == null || region.getLength() == 0) {
682 repairRepresentation();
686 highlightRegion(viewer, region);
687 activateCursor(viewer);
691 * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
693 public void focusGained(FocusEvent e) {
697 * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
699 public void focusLost(FocusEvent event) {
704 * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
706 public void documentAboutToBeChanged(DocumentEvent event) {
707 if (fActive && fActiveRegion != null) {
708 fRememberedPosition = new Position(fActiveRegion.getOffset(), fActiveRegion.getLength());
710 event.getDocument().addPosition(fRememberedPosition);
711 } catch (BadLocationException x) {
712 fRememberedPosition = null;
718 * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
720 public void documentChanged(DocumentEvent event) {
721 if (fRememberedPosition != null && !fRememberedPosition.isDeleted()) {
722 event.getDocument().removePosition(fRememberedPosition);
723 fActiveRegion = new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
725 fRememberedPosition = null;
727 ISourceViewer viewer = getSourceViewer();
728 if (viewer != null) {
729 StyledText widget = viewer.getTextWidget();
730 if (widget != null && !widget.isDisposed()) {
731 widget.getDisplay().asyncExec(new Runnable() {
741 * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
743 public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
744 if (oldInput == null)
747 oldInput.removeDocumentListener(this);
751 * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
753 public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
754 if (newInput == null)
756 newInput.addDocumentListener(this);
760 * @see PaintListener#paintControl(PaintEvent)
762 public void paintControl(PaintEvent event) {
763 if (fActiveRegion == null)
766 ISourceViewer viewer = getSourceViewer();
770 StyledText text = viewer.getTextWidget();
771 if (text == null || text.isDisposed())
777 if (viewer instanceof ITextViewerExtension3) {
779 ITextViewerExtension3 extension = (ITextViewerExtension3) viewer;
780 IRegion widgetRange = extension.modelRange2WidgetRange(new Region(offset, length));
781 if (widgetRange == null)
784 offset = widgetRange.getOffset();
785 length = widgetRange.getLength();
789 IRegion region = viewer.getVisibleRegion();
790 if (!includes(region, fActiveRegion))
793 offset = fActiveRegion.getOffset() - region.getOffset();
794 length = fActiveRegion.getLength();
798 Point minLocation = getMinimumLocation(text, offset, length);
799 Point maxLocation = getMaximumLocation(text, offset, length);
801 int x1 = minLocation.x;
802 int x2 = minLocation.x + maxLocation.x - minLocation.x - 1;
803 int y = minLocation.y + text.getLineHeight() - 1;
806 if (fColor != null && !fColor.isDisposed())
807 gc.setForeground(fColor);
808 gc.drawLine(x1, y, x2, y);
811 private boolean includes(IRegion region, IRegion position) {
812 return position.getOffset() >= region.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength();
815 private Point getMinimumLocation(StyledText text, int offset, int length) {
816 Point minLocation = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
818 for (int i = 0; i <= length; i++) {
819 Point location = text.getLocationAtOffset(offset + i);
821 if (location.x < minLocation.x)
822 minLocation.x = location.x;
823 if (location.y < minLocation.y)
824 minLocation.y = location.y;
830 private Point getMaximumLocation(StyledText text, int offset, int length) {
831 Point maxLocation = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
833 for (int i = 0; i <= length; i++) {
834 Point location = text.getLocationAtOffset(offset + i);
836 if (location.x > maxLocation.x)
837 maxLocation.x = location.x;
838 if (location.y > maxLocation.y)
839 maxLocation.y = location.y;
847 * This action dispatches into two behaviours: If there is no current text
848 * hover, the javadoc is displayed using information presenter. If there is
849 * a current text hover, it is converted into a information presenter in
850 * order to make it sticky.
852 class InformationDispatchAction extends TextEditorAction {
854 /** The wrapped text operation action. */
855 private final TextOperationAction fTextOperationAction;
858 * Creates a dispatch action.
860 public InformationDispatchAction(ResourceBundle resourceBundle, String prefix, final TextOperationAction textOperationAction) {
861 super(resourceBundle, prefix, PHPEditor.this);
862 if (textOperationAction == null)
863 throw new IllegalArgumentException();
864 fTextOperationAction = textOperationAction;
868 * @see org.eclipse.jface.action.IAction#run()
872 ISourceViewer sourceViewer = getSourceViewer();
873 if (sourceViewer == null) {
874 fTextOperationAction.run();
878 if (!(sourceViewer instanceof ITextViewerExtension2)) {
879 fTextOperationAction.run();
883 ITextViewerExtension2 textViewerExtension2 = (ITextViewerExtension2) sourceViewer;
885 // does a text hover exist?
886 ITextHover textHover = textViewerExtension2.getCurrentTextHover();
887 if (textHover == null) {
888 fTextOperationAction.run();
892 Point hoverEventLocation = textViewerExtension2.getHoverEventLocation();
893 int offset = computeOffsetAtLocation(sourceViewer, hoverEventLocation.x, hoverEventLocation.y);
895 fTextOperationAction.run();
900 // get the text hover content
901 IDocument document = sourceViewer.getDocument();
902 String contentType = document.getContentType(offset);
904 final IRegion hoverRegion = textHover.getHoverRegion(sourceViewer, offset);
905 if (hoverRegion == null)
908 final String hoverInfo = textHover.getHoverInfo(sourceViewer, hoverRegion);
910 // with information provider
911 IInformationProvider informationProvider = new IInformationProvider() {
913 * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int)
915 public IRegion getSubject(ITextViewer textViewer, int offset) {
919 * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
921 public String getInformation(ITextViewer textViewer, IRegion subject) {
926 fInformationPresenter.setOffset(offset);
927 fInformationPresenter.setInformationProvider(informationProvider, contentType);
928 fInformationPresenter.showInformation();
930 } catch (BadLocationException e) {
934 // modified version from TextViewer
935 private int computeOffsetAtLocation(ITextViewer textViewer, int x, int y) {
937 StyledText styledText = textViewer.getTextWidget();
938 IDocument document = textViewer.getDocument();
940 if (document == null)
944 int widgetLocation = styledText.getOffsetAtLocation(new Point(x, y));
945 if (textViewer instanceof ITextViewerExtension3) {
946 ITextViewerExtension3 extension = (ITextViewerExtension3) textViewer;
947 return extension.widgetOffset2ModelOffset(widgetLocation);
949 IRegion visibleRegion = textViewer.getVisibleRegion();
950 return widgetLocation + visibleRegion.getOffset();
952 } catch (IllegalArgumentException e) {
959 // static protected class AnnotationAccess implements IAnnotationAccess {
961 // * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation)
963 // public Object getType(Annotation annotation) {
964 // if (annotation instanceof IJavaAnnotation) {
965 // IJavaAnnotation javaAnnotation = (IJavaAnnotation) annotation;
966 // // if (javaAnnotation.isRelevant())
967 // // return javaAnnotation.getAnnotationType();
973 // * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation)
975 // public boolean isMultiLine(Annotation annotation) {
980 // * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation)
982 // public boolean isTemporary(Annotation annotation) {
983 // if (annotation instanceof IJavaAnnotation) {
984 // IJavaAnnotation javaAnnotation = (IJavaAnnotation) annotation;
985 // if (javaAnnotation.isRelevant())
986 // return javaAnnotation.isTemporary();
992 private class PropertyChangeListener implements org.eclipse.core.runtime.Preferences.IPropertyChangeListener {
994 * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
996 public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
997 handlePreferencePropertyChanged(event);
1002 * Finds and marks occurrence annotations.
1006 class OccurrencesFinderJob extends Job implements IDocumentListener {
1008 private IDocument fDocument;
1009 private boolean fCancelled= false;
1010 private IProgressMonitor fProgressMonitor;
1011 private Position[] fPositions;
1013 public OccurrencesFinderJob(IDocument document, Position[] positions) {
1014 super("Occurrences Marker"); //$NON-NLS-1$
1015 fDocument= document;
1016 fPositions= positions;
1017 fDocument.addDocumentListener(this);
1020 private boolean isCancelled() {
1021 return fCancelled || fProgressMonitor.isCanceled();
1025 * @see Job#run(org.eclipse.core.runtime.IProgressMonitor)
1027 public IStatus run(IProgressMonitor progressMonitor) {
1029 fProgressMonitor= progressMonitor;
1034 return Status.CANCEL_STATUS;
1036 ITextViewer textViewer= getViewer();
1037 if (textViewer == null)
1038 return Status.CANCEL_STATUS;
1040 IDocument document= textViewer.getDocument();
1041 if (document == null)
1042 return Status.CANCEL_STATUS;
1044 IDocumentProvider documentProvider= getDocumentProvider();
1045 if (documentProvider == null)
1046 return Status.CANCEL_STATUS;
1048 IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
1049 if (annotationModel == null)
1050 return Status.CANCEL_STATUS;
1052 // Add occurrence annotations
1053 int length= fPositions.length;
1054 Map annotationMap= new HashMap(length);
1055 for (int i= 0; i < length; i++) {
1058 return Status.CANCEL_STATUS;
1061 Position position= fPositions[i];
1063 // Create & add annotation
1065 message= document.get(position.offset, position.length);
1066 } catch (BadLocationException ex) {
1071 new Annotation("net.sourceforge.phpdt.ui.occurrences", false, message), //$NON-NLS-1$
1076 return Status.CANCEL_STATUS;
1078 synchronized (annotationModel) {
1079 if (annotationModel instanceof IAnnotationModelExtension) {
1080 ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
1082 removeOccurrenceAnnotations();
1083 Iterator iter= annotationMap.entrySet().iterator();
1084 while (iter.hasNext()) {
1085 Map.Entry mapEntry= (Map.Entry)iter.next();
1086 annotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue());
1089 fOccurrenceAnnotations= (Annotation[])annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
1092 fDocument.removeDocumentListener(this);
1094 return Status.OK_STATUS;
1098 * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
1100 public void documentAboutToBeChanged(DocumentEvent event) {
1105 * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
1107 public void documentChanged(DocumentEvent event) {
1113 * Holds the current occurrence annotations.
1116 private Annotation[] fOccurrenceAnnotations= null;
1118 private Job fOccurrencesFinderJob;
1120 /** Preference key for showing the line number ruler */
1121 // private final static String LINE_NUMBER_RULER = PreferenceConstants.EDITOR_LINE_NUMBER_RULER;
1122 /** Preference key for the foreground color of the line numbers */
1123 // private final static String LINE_NUMBER_COLOR = PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
1124 /** Preference key for the link color */
1125 private final static String LINK_COLOR = PreferenceConstants.EDITOR_LINK_COLOR;
1126 /** Preference key for compiler task tags */
1127 private final static String COMPILER_TASK_TAGS = JavaCore.COMPILER_TASK_TAGS;
1129 // protected PHPActionGroup fActionGroups;
1130 // /** The outline page */
1131 // private AbstractContentOutlinePage fOutlinePage;
1132 /** The outline page */
1133 protected JavaOutlinePage fOutlinePage;
1134 /** Outliner context menu Id */
1135 protected String fOutlinerContextMenuId;
1137 * The editor selection changed listener.
1141 // private EditorSelectionChangedListener fEditorSelectionChangedListener;
1142 /** Indicates whether this editor should react on outline page selection changes */
1143 private int fIgnoreOutlinePageSelection;
1145 /** The outline page selection updater */
1146 private OutlinePageSelectionUpdater fUpdater;
1147 // protected PHPSyntaxParserThread fValidationThread = null;
1149 // private IPreferenceStore fPHPPrefStore;
1150 /** The selection changed listener */
1151 protected ISelectionChangedListener fSelectionChangedListener = new SelectionChangedListener();
1153 /** The editor's bracket matcher */
1154 private PHPPairMatcher fBracketMatcher = new PHPPairMatcher(BRACKETS);
1157 /** The line number ruler column */
1158 // private LineNumberRulerColumn fLineNumberRulerColumn;
1159 /** This editor's encoding support */
1160 private DefaultEncodingSupport fEncodingSupport;
1161 /** The mouse listener */
1162 private MouseClickListener fMouseListener;
1164 protected CompositeActionGroup fActionGroups;
1165 protected CompositeActionGroup fContextMenuGroup;
1168 * This editor's projection support
1171 private ProjectionSupport fProjectionSupport;
1173 * This editor's projection model updater
1176 private IJavaFoldingStructureProvider fProjectionModelUpdater;
1178 * The action group for folding.
1182 private FoldingActionGroup fFoldingGroup;
1184 /** The information presenter. */
1185 private InformationPresenter fInformationPresenter;
1186 /** The annotation access */
1187 // protected IAnnotationAccess fAnnotationAccess = new AnnotationAccess();
1188 /** The overview ruler */
1189 protected OverviewRuler isOverviewRulerVisible;
1190 /** The source viewer decoration support */
1191 //protected SourceViewerDecorationSupport fSourceViewerDecorationSupport;
1192 /** The overview ruler */
1193 //protected OverviewRuler fOverviewRuler;
1195 /** The preference property change listener for java core. */
1196 private org.eclipse.core.runtime.Preferences.IPropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
1198 * Returns the most narrow java element including the given offset
1200 * @param offset the offset inside of the requested element
1202 abstract protected IJavaElement getElementAt(int offset);
1205 * Returns the java element of this editor's input corresponding to the given IJavaElement
1207 abstract protected IJavaElement getCorrespondingElement(IJavaElement element);
1209 * Sets the input of the editor's outline page.
1211 abstract protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input);
1214 * Default constructor.
1216 public PHPEditor() {
1218 JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
1219 setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
1220 setRangeIndicator(new DefaultRangeIndicator());
1221 IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
1222 setPreferenceStore(store);
1223 setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" }); //$NON-NLS-1$
1224 // fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
1225 // fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
1227 // TODO changed in 3.x ?
1228 if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
1229 fUpdater= new OutlinePageSelectionUpdater();
1233 * @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
1235 protected void updatePropertyDependentActions() {
1236 super.updatePropertyDependentActions();
1237 if (fEncodingSupport != null)
1238 fEncodingSupport.reset();
1242 * Update the hovering behavior depending on the preferences.
1244 private void updateHoverBehavior() {
1245 SourceViewerConfiguration configuration = getSourceViewerConfiguration();
1246 String[] types = configuration.getConfiguredContentTypes(getSourceViewer());
1248 for (int i = 0; i < types.length; i++) {
1250 String t = types[i];
1252 int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
1254 ISourceViewer sourceViewer = getSourceViewer();
1255 if (sourceViewer instanceof ITextViewerExtension2) {
1256 if (stateMasks != null) {
1257 for (int j = 0; j < stateMasks.length; j++) {
1258 int stateMask = stateMasks[j];
1259 ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
1260 ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
1263 ITextHover textHover = configuration.getTextHover(sourceViewer, t);
1264 ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
1267 sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
1271 public void updatedTitleImage(Image image) {
1272 setTitleImage(image);
1275 * @see net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
1277 public Object getViewPartInput() {
1278 return getEditorInput().getAdapter(IResource.class);
1281 * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetSelection(ISelection)
1283 protected void doSetSelection(ISelection selection) {
1284 super.doSetSelection(selection);
1285 synchronizeOutlinePageSelection();
1287 boolean isFoldingEnabled() {
1288 return PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
1291 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.
1292 * widgets.Composite)
1294 public void createPartControl(Composite parent) {
1295 super.createPartControl(parent);
1297 //fSourceViewerDecorationSupport.install(getPreferenceStore());
1299 ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
1301 fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
1302 fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
1303 fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
1304 fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
1305 public IInformationControl createInformationControl(Shell shell) {
1306 return new CustomSourceInformationControl(shell, IDocument.DEFAULT_CONTENT_TYPE);
1309 fProjectionSupport.install();
1311 fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
1312 if (fProjectionModelUpdater != null)
1313 fProjectionModelUpdater.install(this, projectionViewer);
1315 if (isFoldingEnabled())
1316 projectionViewer.doOperation(ProjectionViewer.TOGGLE);
1317 Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
1318 preferences.addPropertyChangeListener(fPropertyChangeListener);
1320 IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
1321 public IInformationControl createInformationControl(Shell parent) {
1322 boolean cutDown = false;
1323 int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
1324 return new DefaultInformationControl(parent, SWT.RESIZE, style, new HTMLTextPresenter(cutDown));
1328 fInformationPresenter = new InformationPresenter(informationControlCreator);
1329 fInformationPresenter.setSizeConstraints(60, 10, true, true);
1330 fInformationPresenter.install(getSourceViewer());
1335 * Returns this document's complete text.
1337 * @return the document's complete text
1339 public String get() {
1340 IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
1345 * Sets the outliner's context menu ID.
1347 protected void setOutlinerContextMenuId(String menuId) {
1348 fOutlinerContextMenuId = menuId;
1352 * Returns the standard action group of this editor.
1354 protected ActionGroup getActionGroup() {
1355 return fActionGroups;
1358 // public JavaOutlinePage getfOutlinePage() {
1359 // return fOutlinePage;
1362 /** The <code>PHPEditor</code> implementation of this
1363 * <code>AbstractTextEditor</code> method extend the
1364 * actions to add those specific to the receiver
1366 protected void createActions() {
1367 super.createActions();
1369 fFoldingGroup= new FoldingActionGroup(this, getViewer());
1371 ResourceAction resAction= new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
1372 resAction= new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
1373 resAction.setActionDefinitionId(net.sourceforge.phpdt.ui.actions.PHPEditorActionDefinitionIds.SHOW_JAVADOC);
1374 setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
1375 // WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
1377 Action action= new GotoMatchingBracketAction(this);
1378 action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
1379 setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
1381 // action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"ShowOutline.", this, JavaSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
1382 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE);
1383 // setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE, action);
1384 //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.SHOW_OUTLINE_ACTION);
1386 // action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenStructure.", this, JavaSourceViewer.OPEN_STRUCTURE, true); //$NON-NLS-1$
1387 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE);
1388 // setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE, action);
1389 //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_STRUCTURE_ACTION);
1391 // action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenHierarchy.", this, JavaSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
1392 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY);
1393 // setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY, action);
1394 //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_HIERARCHY_ACTION);
1396 fEncodingSupport= new DefaultEncodingSupport();
1397 fEncodingSupport.initialize(this);
1399 // fSelectionHistory= new SelectionHistory(this);
1401 // action= new StructureSelectEnclosingAction(this, fSelectionHistory);
1402 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_ENCLOSING);
1403 // setAction(StructureSelectionAction.ENCLOSING, action);
1405 // action= new StructureSelectNextAction(this, fSelectionHistory);
1406 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_NEXT);
1407 // setAction(StructureSelectionAction.NEXT, action);
1409 // action= new StructureSelectPreviousAction(this, fSelectionHistory);
1410 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_PREVIOUS);
1411 // setAction(StructureSelectionAction.PREVIOUS, action);
1413 // StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory);
1414 // historyAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_LAST);
1415 // setAction(StructureSelectionAction.HISTORY, historyAction);
1416 // fSelectionHistory.setHistoryAction(historyAction);
1418 // action= GoToNextPreviousMemberAction.newGoToNextMemberAction(this);
1419 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
1420 // setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
1422 // action= GoToNextPreviousMemberAction.newGoToPreviousMemberAction(this);
1423 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
1424 // setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
1426 // action= new QuickFormatAction();
1427 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.QUICK_FORMAT);
1428 // setAction(IJavaEditorActionDefinitionIds.QUICK_FORMAT, action);
1430 // action= new RemoveOccurrenceAnnotations(this);
1431 // action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
1432 // setAction("RemoveOccurrenceAnnotations", action); //$NON-NLS-1$
1434 // add annotation actions
1435 action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
1436 setAction("AnnotationAction", action); //$NON-NLS-1$
1439 private void internalDoSetInput(IEditorInput input) throws CoreException {
1440 super.doSetInput(input);
1442 if (fEncodingSupport != null)
1443 fEncodingSupport.reset();
1445 setOutlinePageInput(fOutlinePage, input);
1447 if (fProjectionModelUpdater != null)
1448 fProjectionModelUpdater.initialize();
1450 // if (isShowingOverrideIndicators())
1451 // installOverrideIndicator(true);
1455 * @see org.eclipse.ui.texteditor.AbstractTextEditor#setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)
1458 protected void setPreferenceStore(IPreferenceStore store) {
1459 super.setPreferenceStore(store);
1460 if (getSourceViewerConfiguration() instanceof PHPSourceViewerConfiguration) {
1461 JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
1462 setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING));
1464 if (getSourceViewer() instanceof JavaSourceViewer)
1465 ((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);
1467 /** The <code>PHPEditor</code> implementation of this
1468 * <code>AbstractTextEditor</code> method performs any extra
1469 * disposal actions required by the php editor.
1471 public void dispose() {
1472 if (fProjectionModelUpdater != null) {
1473 fProjectionModelUpdater.uninstall();
1474 fProjectionModelUpdater= null;
1477 if (fProjectionSupport != null) {
1478 fProjectionSupport.dispose();
1479 fProjectionSupport= null;
1481 // PHPEditorEnvironment.disconnect(this);
1482 if (fOutlinePage != null)
1483 fOutlinePage.setInput(null);
1485 if (fActionGroups != null)
1486 fActionGroups.dispose();
1488 if (isBrowserLikeLinks())
1489 disableBrowserLikeLinks();
1491 if (fEncodingSupport != null) {
1492 fEncodingSupport.dispose();
1493 fEncodingSupport = null;
1496 if (fPropertyChangeListener != null) {
1497 Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
1498 preferences.removePropertyChangeListener(fPropertyChangeListener);
1499 fPropertyChangeListener = null;
1502 // if (fSourceViewerDecorationSupport != null) {
1503 // fSourceViewerDecorationSupport.dispose();
1504 // fSourceViewerDecorationSupport = null;
1507 if (fBracketMatcher != null) {
1508 fBracketMatcher.dispose();
1509 fBracketMatcher = null;
1514 /** The <code>PHPEditor</code> implementation of this
1515 * <code>AbstractTextEditor</code> method performs any extra
1516 * revert behavior required by the php editor.
1518 // public void doRevertToSaved() {
1519 // super.doRevertToSaved();
1520 // if (fOutlinePage != null)
1521 // fOutlinePage.update();
1524 /** The <code>PHPEditor</code> implementation of this
1525 * <code>AbstractTextEditor</code> method performs any extra
1526 * save behavior required by the php editor.
1528 // public void doSave(IProgressMonitor monitor) {
1529 // super.doSave(monitor);
1530 // compile or not, according to the user preferences
1531 // IPreferenceStore store = getPreferenceStore();
1533 // the parse on save was changed to the eclipse "builders" concept
1534 // if (store.getBoolean(PHPeclipsePlugin.PHP_PARSE_ON_SAVE)) {
1535 // IAction a = PHPParserAction.getInstance();
1540 // if (SWT.getPlatform().equals("win32")) {
1541 // IAction a = ShowExternalPreviewAction.getInstance();
1545 // if (fOutlinePage != null)
1546 // fOutlinePage.update();
1549 /** The <code>PHPEditor</code> implementation of this
1550 * <code>AbstractTextEditor</code> method performs any extra
1551 * save as behavior required by the php editor.
1553 // public void doSaveAs() {
1554 // super.doSaveAs();
1555 // if (fOutlinePage != null)
1556 // fOutlinePage.update();
1559 * @see StatusTextEditor#getStatusHeader(IStatus)
1561 protected String getStatusHeader(IStatus status) {
1562 if (fEncodingSupport != null) {
1563 String message = fEncodingSupport.getStatusHeader(status);
1564 if (message != null)
1567 return super.getStatusHeader(status);
1571 * @see StatusTextEditor#getStatusBanner(IStatus)
1573 protected String getStatusBanner(IStatus status) {
1574 if (fEncodingSupport != null) {
1575 String message = fEncodingSupport.getStatusBanner(status);
1576 if (message != null)
1579 return super.getStatusBanner(status);
1583 * @see StatusTextEditor#getStatusMessage(IStatus)
1585 protected String getStatusMessage(IStatus status) {
1586 if (fEncodingSupport != null) {
1587 String message = fEncodingSupport.getStatusMessage(status);
1588 if (message != null)
1591 return super.getStatusMessage(status);
1593 /** The <code>PHPEditor</code> implementation of this
1594 * <code>AbstractTextEditor</code> method performs sets the
1595 * input of the outline page after AbstractTextEditor has set input.
1597 // protected void doSetInput(IEditorInput input) throws CoreException {
1598 // super.doSetInput(input);
1600 // if (fEncodingSupport != null)
1601 // fEncodingSupport.reset();
1602 // if (fOutlinePage != null)
1603 // fOutlinePage.setInput(input);
1604 // // setOutlinePageInput(fOutlinePage, input);
1606 protected void doSetInput(IEditorInput input) throws CoreException {
1607 super.doSetInput(input);
1608 if (fEncodingSupport != null)
1609 fEncodingSupport.reset();
1610 setOutlinePageInput(fOutlinePage, input);
1613 * @see org.phpeclipse.phpdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
1615 // public Object getViewPartInput() {
1616 // return getEditorInput().getAdapter(IFile.class);
1619 /** The <code>PHPEditor</code> implementation of this
1620 * <code>AbstractTextEditor</code> method adds any
1621 * PHPEditor specific entries.
1623 public void editorContextMenuAboutToShow(MenuManager menu) {
1624 super.editorContextMenuAboutToShow(menu);
1625 menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, new Separator(IContextMenuConstants.GROUP_OPEN));
1626 menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
1628 ActionContext context = new ActionContext(getSelectionProvider().getSelection());
1629 fContextMenuGroup.setContext(context);
1630 fContextMenuGroup.fillContextMenu(menu);
1631 fContextMenuGroup.setContext(null);
1632 // addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "Format"); //$NON-NLS-1$
1634 // ActionContext context =
1635 // new ActionContext(getSelectionProvider().getSelection());
1636 // fContextMenuGroup.setContext(context);
1637 // fContextMenuGroup.fillContextMenu(menu);
1638 // fContextMenuGroup.setContext(null);
1642 * Creates the outline page used with this editor.
1644 protected JavaOutlinePage createOutlinePage() {
1646 // AbstractContentOutlinePage page = new PHPContentOutlinePage(getDocumentProvider(), this);
1648 // page.addSelectionChangedListener(fSelectionChangedListener);
1649 // // setOutlinePageInput(page, getEditorInput());
1650 // if (getEditorInput() != null)
1651 // fOutlinePage.setInput(getEditorInput());
1654 JavaOutlinePage page = new JavaOutlinePage(fOutlinerContextMenuId, this);
1656 page.addSelectionChangedListener(fSelectionChangedListener);
1657 setOutlinePageInput(page, getEditorInput());
1663 * Informs the editor that its outliner has been closed.
1665 public void outlinePageClosed() {
1666 if (fOutlinePage != null) {
1667 fOutlinePage.removeSelectionChangedListener(fSelectionChangedListener);
1668 fOutlinePage = null;
1669 resetHighlightRange();
1673 * Synchronizes the outliner selection with the actual cursor
1674 * position in the editor.
1676 public void synchronizeOutlinePageSelection() {
1678 // if (isEditingScriptRunning())
1681 ISourceViewer sourceViewer = getSourceViewer();
1682 if (sourceViewer == null || fOutlinePage == null)
1685 StyledText styledText = sourceViewer.getTextWidget();
1686 if (styledText == null)
1690 if (sourceViewer instanceof ITextViewerExtension3) {
1691 ITextViewerExtension3 extension = (ITextViewerExtension3) sourceViewer;
1692 caret = extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
1694 int offset = sourceViewer.getVisibleRegion().getOffset();
1695 caret = offset + styledText.getCaretOffset();
1698 IJavaElement element = getElementAt(caret);
1699 if (element instanceof ISourceReference) {
1700 fOutlinePage.removeSelectionChangedListener(fSelectionChangedListener);
1701 fOutlinePage.select((ISourceReference) element);
1702 fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
1706 protected void setSelection(ISourceReference reference, boolean moveCursor) {
1708 ISelection selection = getSelectionProvider().getSelection();
1709 if (selection instanceof TextSelection) {
1710 TextSelection textSelection = (TextSelection) selection;
1711 if (textSelection.getOffset() != 0 || textSelection.getLength() != 0)
1712 markInNavigationHistory();
1715 if (reference != null) {
1717 StyledText textWidget = null;
1719 ISourceViewer sourceViewer = getSourceViewer();
1720 if (sourceViewer != null)
1721 textWidget = sourceViewer.getTextWidget();
1723 if (textWidget == null)
1728 ISourceRange range = reference.getSourceRange();
1732 int offset = range.getOffset();
1733 int length = range.getLength();
1735 if (offset < 0 || length < 0)
1738 textWidget.setRedraw(false);
1740 setHighlightRange(offset, length, moveCursor);
1748 if (reference instanceof IMember) {
1749 range = ((IMember) reference).getNameRange();
1750 if (range != null) {
1751 offset = range.getOffset();
1752 length = range.getLength();
1755 // else if (reference instanceof IImportDeclaration) {
1756 // String name= ((IImportDeclaration) reference).getElementName();
1757 // if (name != null && name.length() > 0) {
1758 // String content= reference.getSource();
1759 // if (content != null) {
1760 // offset= range.getOffset() + content.indexOf(name);
1761 // length= name.length();
1764 // } else if (reference instanceof IPackageDeclaration) {
1765 // String name= ((IPackageDeclaration) reference).getElementName();
1766 // if (name != null && name.length() > 0) {
1767 // String content= reference.getSource();
1768 // if (content != null) {
1769 // offset= range.getOffset() + content.indexOf(name);
1770 // length= name.length();
1775 if (offset > -1 && length > 0) {
1776 sourceViewer.revealRange(offset, length);
1777 sourceViewer.setSelectedRange(offset, length);
1780 } catch (JavaModelException x) {
1781 } catch (IllegalArgumentException x) {
1783 if (textWidget != null)
1784 textWidget.setRedraw(true);
1787 } else if (moveCursor) {
1788 resetHighlightRange();
1791 markInNavigationHistory();
1794 public void setSelection(IJavaElement element) {
1796 if (element == null || element instanceof ICompilationUnit) { // || element instanceof IClassFile) {
1798 * If the element is an ICompilationUnit this unit is either the input
1799 * of this editor or not being displayed. In both cases, nothing should
1800 * happened. (http://dev.eclipse.org/bugs/show_bug.cgi?id=5128)
1805 IJavaElement corresponding = getCorrespondingElement(element);
1806 if (corresponding instanceof ISourceReference) {
1807 ISourceReference reference = (ISourceReference) corresponding;
1808 // set hightlight range
1809 setSelection(reference, true);
1810 // set outliner selection
1811 if (fOutlinePage != null) {
1812 fOutlinePage.removeSelectionChangedListener(fSelectionChangedListener);
1813 fOutlinePage.select(reference);
1814 fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
1819 public synchronized void editingScriptStarted() {
1820 ++ fIgnoreOutlinePageSelection;
1823 public synchronized void editingScriptEnded() {
1824 -- fIgnoreOutlinePageSelection;
1827 public synchronized boolean isEditingScriptRunning() {
1828 return (fIgnoreOutlinePageSelection > 0);
1831 /** The <code>PHPEditor</code> implementation of this
1832 * <code>AbstractTextEditor</code> method performs gets
1833 * the java content outline page if request is for a an
1836 public Object getAdapter(Class required) {
1838 if (IContentOutlinePage.class.equals(required)) {
1839 if (fOutlinePage == null)
1840 fOutlinePage = createOutlinePage();
1841 return fOutlinePage;
1844 if (IEncodingSupport.class.equals(required))
1845 return fEncodingSupport;
1847 if (required == IShowInTargetList.class) {
1848 return new IShowInTargetList() {
1849 public String[] getShowInTargetIds() {
1850 return new String[] { JavaUI.ID_PACKAGES, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
1855 if (fProjectionSupport != null) {
1856 Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), required);
1857 if (adapter != null)
1861 return super.getAdapter(required);
1863 // public Object getAdapter(Class required) {
1864 // if (IContentOutlinePage.class.equals(required)) {
1865 // if (fOutlinePage == null) {
1866 // fOutlinePage = new PHPContentOutlinePage(getDocumentProvider(), this);
1867 // if (getEditorInput() != null)
1868 // fOutlinePage.setInput(getEditorInput());
1870 // return fOutlinePage;
1873 // if (IEncodingSupport.class.equals(required))
1874 // return fEncodingSupport;
1876 // return super.getAdapter(required);
1879 protected void doSelectionChanged(SelectionChangedEvent event) {
1880 ISourceReference reference = null;
1882 ISelection selection = event.getSelection();
1883 Iterator iter = ((IStructuredSelection) selection).iterator();
1884 while (iter.hasNext()) {
1885 Object o = iter.next();
1886 if (o instanceof ISourceReference) {
1887 reference = (ISourceReference) o;
1892 if (!isActivePart() && PHPeclipsePlugin.getActivePage() != null)
1893 PHPeclipsePlugin.getActivePage().bringToTop(this);
1896 editingScriptStarted();
1897 setSelection(reference, !isActivePart());
1899 editingScriptEnded();
1903 * @see AbstractTextEditor#adjustHighlightRange(int, int)
1905 protected void adjustHighlightRange(int offset, int length) {
1909 IJavaElement element = getElementAt(offset);
1910 while (element instanceof ISourceReference) {
1911 ISourceRange range = ((ISourceReference) element).getSourceRange();
1912 if (offset < range.getOffset() + range.getLength() && range.getOffset() < offset + length) {
1913 setHighlightRange(range.getOffset(), range.getLength(), true);
1914 if (fOutlinePage != null) {
1915 fOutlinePage.removeSelectionChangedListener(fSelectionChangedListener);
1916 fOutlinePage.select((ISourceReference) element);
1917 fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
1921 element = element.getParent();
1924 } catch (JavaModelException x) {
1925 PHPeclipsePlugin.log(x.getStatus());
1928 resetHighlightRange();
1930 protected boolean isActivePart() {
1931 IWorkbenchWindow window = getSite().getWorkbenchWindow();
1932 IPartService service = window.getPartService();
1933 IWorkbenchPart part = service.getActivePart();
1934 return part != null && part.equals(this);
1938 // public void openContextHelp() {
1939 // IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
1940 // ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection();
1941 // int pos = selection.getOffset();
1942 // String word = getFunctionName(doc, pos);
1943 // openContextHelp(word);
1946 // private void openContextHelp(String word) {
1950 // public static void open(String word) {
1951 // IHelp help = WorkbenchHelp.getHelpSupport();
1952 // if (help != null) {
1953 // IHelpResource helpResource = new PHPFunctionHelpResource(word);
1954 // WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
1956 // // showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
1960 // private String getFunctionName(IDocument doc, int pos) {
1961 // Point word = PHPWordExtractor.findWord(doc, pos);
1962 // if (word != null) {
1964 // return doc.get(word.x, word.y).replace('_', '-');
1965 // } catch (BadLocationException e) {
1972 * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
1974 protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
1978 ISourceViewer sourceViewer = getSourceViewer();
1979 if (sourceViewer == null)
1982 String property = event.getProperty();
1984 if (PreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
1985 Object value = event.getNewValue();
1986 if (value instanceof Integer) {
1987 sourceViewer.getTextWidget().setTabs(((Integer) value).intValue());
1988 } else if (value instanceof String) {
1989 sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value));
1994 // if (OVERVIEW_RULER.equals(property)) {
1995 // if (isOverviewRulerVisible())
1996 // showOverviewRuler();
1998 // hideOverviewRuler();
2002 // if (LINE_NUMBER_RULER.equals(property)) {
2003 // if (isLineNumberRulerVisible())
2004 // showLineNumberRuler();
2006 // hideLineNumberRuler();
2010 // if (fLineNumberRulerColumn != null
2011 // && (LINE_NUMBER_COLOR.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_BACKGROUND.equals(property))) {
2013 // initializeLineNumberRulerColumn(fLineNumberRulerColumn);
2016 if (isJavaEditorHoverProperty(property))
2017 updateHoverBehavior();
2019 if (BROWSER_LIKE_LINKS.equals(property)) {
2020 if (isBrowserLikeLinks())
2021 enableBrowserLikeLinks();
2023 disableBrowserLikeLinks();
2027 // if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
2028 // if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue())
2029 // fEditorSelectionChangedListener.selectionChanged();
2033 if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
2034 if (event.getNewValue() instanceof Boolean) {
2035 Boolean disable= (Boolean) event.getNewValue();
2036 enableOverwriteMode(!disable.booleanValue());
2041 // if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
2042 // if (event.getNewValue() instanceof Boolean) {
2043 // boolean markOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
2044 // if (markOccurrenceAnnotations != fMarkOccurrenceAnnotations) {
2045 // fMarkOccurrenceAnnotations= markOccurrenceAnnotations;
2046 // if (!fMarkOccurrenceAnnotations)
2047 // uninstallOccurrencesFinder();
2049 // installOccurrencesFinder();
2053 // if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
2054 // if (event.getNewValue() instanceof Boolean) {
2055 // boolean stickyOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
2056 // if (stickyOccurrenceAnnotations != fStickyOccurrenceAnnotations) {
2057 // fStickyOccurrenceAnnotations= stickyOccurrenceAnnotations;
2058 //// if (!fMarkOccurrenceAnnotations)
2059 //// uninstallOccurrencesFinder();
2061 //// installOccurrencesFinder();
2065 if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
2066 if (sourceViewer instanceof ProjectionViewer) {
2067 ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
2068 if (fProjectionModelUpdater != null)
2069 fProjectionModelUpdater.uninstall();
2070 // either freshly enabled or provider changed
2071 fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
2072 if (fProjectionModelUpdater != null) {
2073 fProjectionModelUpdater.install(this, projectionViewer);
2079 super.handlePreferenceStoreChanged(event);
2084 // * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
2086 // protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
2090 // ISourceViewer sourceViewer = getSourceViewer();
2091 // if (sourceViewer == null)
2094 // String property = event.getProperty();
2096 // // if (JavaSourceViewerConfiguration.PREFERENCE_TAB_WIDTH.equals(property)) {
2097 // // Object value= event.getNewValue();
2098 // // if (value instanceof Integer) {
2099 // // sourceViewer.getTextWidget().setTabs(((Integer) value).intValue());
2100 // // } else if (value instanceof String) {
2101 // // sourceViewer.getTextWidget().setTabs(Integer.parseInt((String) value));
2106 // if (IPreferenceConstants.LINE_NUMBER_RULER.equals(property)) {
2107 // if (isLineNumberRulerVisible())
2108 // showLineNumberRuler();
2110 // hideLineNumberRuler();
2114 // if (fLineNumberRulerColumn != null
2115 // && (IPreferenceConstants.LINE_NUMBER_COLOR.equals(property)
2116 // || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
2117 // || PREFERENCE_COLOR_BACKGROUND.equals(property))) {
2119 // initializeLineNumberRulerColumn(fLineNumberRulerColumn);
2123 // super.handlePreferenceStoreChanged(event);
2127 // private boolean isJavaEditorHoverProperty(String property) {
2128 // return PreferenceConstants.EDITOR_DEFAULT_HOVER.equals(property)
2129 // || PreferenceConstants.EDITOR_NONE_HOVER.equals(property)
2130 // || PreferenceConstants.EDITOR_CTRL_HOVER.equals(property)
2131 // || PreferenceConstants.EDITOR_SHIFT_HOVER.equals(property)
2132 // || PreferenceConstants.EDITOR_CTRL_ALT_HOVER.equals(property)
2133 // || PreferenceConstants.EDITOR_CTRL_SHIFT_HOVER.equals(property)
2134 // || PreferenceConstants.EDITOR_CTRL_ALT_SHIFT_HOVER.equals(property)
2135 // || PreferenceConstants.EDITOR_ALT_SHIFT_HOVER.equals(property);
2139 * Shows the line number ruler column.
2141 // private void showLineNumberRuler() {
2142 // IVerticalRuler v = getVerticalRuler();
2143 // if (v instanceof CompositeRuler) {
2144 // CompositeRuler c = (CompositeRuler) v;
2145 // c.addDecorator(1, createLineNumberRulerColumn());
2148 private boolean isJavaEditorHoverProperty(String property) {
2149 return PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property);
2153 * Return whether the browser like links should be enabled
2154 * according to the preference store settings.
2155 * @return <code>true</code> if the browser like links should be enabled
2157 private boolean isBrowserLikeLinks() {
2158 IPreferenceStore store = getPreferenceStore();
2159 return store.getBoolean(BROWSER_LIKE_LINKS);
2163 * Enables browser like links.
2165 private void enableBrowserLikeLinks() {
2166 if (fMouseListener == null) {
2167 fMouseListener = new MouseClickListener();
2168 fMouseListener.install();
2173 * Disables browser like links.
2175 private void disableBrowserLikeLinks() {
2176 if (fMouseListener != null) {
2177 fMouseListener.uninstall();
2178 fMouseListener = null;
2182 * Handles a property change event describing a change
2183 * of the java core's preferences and updates the preference
2184 * related editor properties.
2186 * @param event the property change event
2188 protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
2189 if (COMPILER_TASK_TAGS.equals(event.getProperty())) {
2190 ISourceViewer sourceViewer = getSourceViewer();
2191 if (sourceViewer != null
2192 && affectsTextPresentation(new PropertyChangeEvent(event.getSource(), event.getProperty(), event.getOldValue(), event.getNewValue())))
2193 sourceViewer.invalidateTextPresentation();
2198 * Return whether the line number ruler column should be
2199 * visible according to the preference store settings.
2200 * @return <code>true</code> if the line numbers should be visible
2202 // protected boolean isLineNumberRulerVisible() {
2203 // IPreferenceStore store = getPreferenceStore();
2204 // return store.getBoolean(LINE_NUMBER_RULER);
2207 * Hides the line number ruler column.
2209 // private void hideLineNumberRuler() {
2210 // IVerticalRuler v = getVerticalRuler();
2211 // if (v instanceof CompositeRuler) {
2212 // CompositeRuler c = (CompositeRuler) v;
2214 // c.removeDecorator(1);
2215 // } catch (Throwable e) {
2221 * @see AbstractTextEditor#handleCursorPositionChanged()
2223 protected void handleCursorPositionChanged() {
2224 super.handleCursorPositionChanged();
2225 if (!isEditingScriptRunning() && fUpdater != null)
2229 * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleElementContentReplaced()
2231 protected void handleElementContentReplaced() {
2232 super.handleElementContentReplaced();
2233 if (fProjectionModelUpdater != null)
2234 fProjectionModelUpdater.initialize();
2237 * Initializes the given line number ruler column from the preference store.
2238 * @param rulerColumn the ruler column to be initialized
2240 // protected void initializeLineNumberRulerColumn(LineNumberRulerColumn rulerColumn) {
2241 // JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
2242 // IColorManager manager = textTools.getColorManager();
2244 // IPreferenceStore store = getPreferenceStore();
2245 // if (store != null) {
2248 // // foreground color
2249 // if (store.contains(LINE_NUMBER_COLOR)) {
2250 // if (store.isDefault(LINE_NUMBER_COLOR))
2251 // rgb = PreferenceConverter.getDefaultColor(store, LINE_NUMBER_COLOR);
2253 // rgb = PreferenceConverter.getColor(store, LINE_NUMBER_COLOR);
2255 // rulerColumn.setForeground(manager.getColor(rgb));
2258 // // background color
2259 // if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
2260 // if (store.contains(PREFERENCE_COLOR_BACKGROUND)) {
2261 // if (store.isDefault(PREFERENCE_COLOR_BACKGROUND))
2262 // rgb = PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND);
2264 // rgb = PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
2267 // rulerColumn.setBackground(manager.getColor(rgb));
2272 * Creates a new line number ruler column that is appropriately initialized.
2274 // protected IVerticalRulerColumn createLineNumberRulerColumn() {
2275 // fLineNumberRulerColumn = new LineNumberRulerColumn();
2276 // initializeLineNumberRulerColumn(fLineNumberRulerColumn);
2277 // return fLineNumberRulerColumn;
2281 * @see AbstractTextEditor#createVerticalRuler()
2283 // protected IVerticalRuler createVerticalRuler() {
2284 // CompositeRuler ruler = new CompositeRuler();
2285 // ruler.addDecorator(0, new AnnotationRulerColumn(VERTICAL_RULER_WIDTH));
2286 // if (isLineNumberRulerVisible())
2287 // ruler.addDecorator(1, createLineNumberRulerColumn());
2291 private static IRegion getSignedSelection(ITextViewer viewer) {
2293 StyledText text = viewer.getTextWidget();
2294 int caretOffset = text.getCaretOffset();
2295 Point selection = text.getSelection();
2299 if (caretOffset == selection.x) {
2300 offset = selection.y;
2301 length = selection.x - selection.y;
2305 offset = selection.x;
2306 length = selection.y - selection.x;
2309 return new Region(offset, length);
2312 /** Preference key for matching brackets */
2313 protected final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
2314 /** Preference key for matching brackets color */
2315 protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
2316 /** Preference key for highlighting current line */
2317 protected final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
2318 /** Preference key for highlight color of current line */
2319 protected final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
2320 /** Preference key for showing print marging ruler */
2321 protected final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
2322 /** Preference key for print margin ruler color */
2323 protected final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
2324 /** Preference key for print margin ruler column */
2325 protected final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
2326 /** Preference key for error indication */
2327 // protected final static String ERROR_INDICATION = PreferenceConstants.EDITOR_PROBLEM_INDICATION;
2328 /** Preference key for error color */
2329 // protected final static String ERROR_INDICATION_COLOR = PreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR;
2330 /** Preference key for warning indication */
2331 // protected final static String WARNING_INDICATION = PreferenceConstants.EDITOR_WARNING_INDICATION;
2332 /** Preference key for warning color */
2333 // protected final static String WARNING_INDICATION_COLOR = PreferenceConstants.EDITOR_WARNING_INDICATION_COLOR;
2334 /** Preference key for task indication */
2335 protected final static String TASK_INDICATION = PreferenceConstants.EDITOR_TASK_INDICATION;
2336 /** Preference key for task color */
2337 protected final static String TASK_INDICATION_COLOR = PreferenceConstants.EDITOR_TASK_INDICATION_COLOR;
2338 /** Preference key for bookmark indication */
2339 protected final static String BOOKMARK_INDICATION = PreferenceConstants.EDITOR_BOOKMARK_INDICATION;
2340 /** Preference key for bookmark color */
2341 protected final static String BOOKMARK_INDICATION_COLOR = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR;
2342 /** Preference key for search result indication */
2343 protected final static String SEARCH_RESULT_INDICATION = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION;
2344 /** Preference key for search result color */
2345 protected final static String SEARCH_RESULT_INDICATION_COLOR = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR;
2346 /** Preference key for unknown annotation indication */
2347 protected final static String UNKNOWN_INDICATION = PreferenceConstants.EDITOR_UNKNOWN_INDICATION;
2348 /** Preference key for unknown annotation color */
2349 protected final static String UNKNOWN_INDICATION_COLOR = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR;
2350 /** Preference key for shwoing the overview ruler */
2351 protected final static String OVERVIEW_RULER = PreferenceConstants.EDITOR_OVERVIEW_RULER;
2352 /** Preference key for error indication in overview ruler */
2353 protected final static String ERROR_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER;
2354 /** Preference key for warning indication in overview ruler */
2355 protected final static String WARNING_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER;
2356 /** Preference key for task indication in overview ruler */
2357 protected final static String TASK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER;
2358 /** Preference key for bookmark indication in overview ruler */
2359 protected final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
2360 /** Preference key for search result indication in overview ruler */
2361 protected final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
2362 /** Preference key for unknown annotation indication in overview ruler */
2363 protected final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = PreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
2364 // /** Preference key for compiler task tags */
2365 // private final static String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS;
2366 /** Preference key for browser like links */
2367 private final static String BROWSER_LIKE_LINKS = PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS;
2368 /** Preference key for key modifier of browser like links */
2369 private final static String BROWSER_LIKE_LINKS_KEY_MODIFIER = PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER;
2371 * Preference key for key modifier mask of browser like links.
2372 * The value is only used if the value of <code>EDITOR_BROWSER_LIKE_LINKS</code>
2373 * cannot be resolved to valid SWT modifier bits.
2377 private final static String BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK = PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK;
2379 private final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']' };
2381 private static boolean isBracket(char character) {
2382 for (int i = 0; i != BRACKETS.length; ++i)
2383 if (character == BRACKETS[i])
2388 private static boolean isSurroundedByBrackets(IDocument document, int offset) {
2389 if (offset == 0 || offset == document.getLength())
2393 return isBracket(document.getChar(offset - 1)) && isBracket(document.getChar(offset));
2395 } catch (BadLocationException e) {
2400 // protected void configureSourceViewerDecorationSupport() {
2402 // fSourceViewerDecorationSupport.setCharacterPairMatcher(fBracketMatcher);
2404 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2405 // AnnotationType.UNKNOWN,
2406 // UNKNOWN_INDICATION_COLOR,
2407 // UNKNOWN_INDICATION,
2408 // UNKNOWN_INDICATION_IN_OVERVIEW_RULER,
2410 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2411 // AnnotationType.BOOKMARK,
2412 // BOOKMARK_INDICATION_COLOR,
2413 // BOOKMARK_INDICATION,
2414 // BOOKMARK_INDICATION_IN_OVERVIEW_RULER,
2416 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2417 // AnnotationType.TASK,
2418 // TASK_INDICATION_COLOR,
2420 // TASK_INDICATION_IN_OVERVIEW_RULER,
2422 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2423 // AnnotationType.SEARCH,
2424 // SEARCH_RESULT_INDICATION_COLOR,
2425 // SEARCH_RESULT_INDICATION,
2426 // SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER,
2428 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2429 // AnnotationType.WARNING,
2430 // WARNING_INDICATION_COLOR,
2431 // WARNING_INDICATION,
2432 // WARNING_INDICATION_IN_OVERVIEW_RULER,
2434 // fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(
2435 // AnnotationType.ERROR,
2436 // ERROR_INDICATION_COLOR,
2437 // ERROR_INDICATION,
2438 // ERROR_INDICATION_IN_OVERVIEW_RULER,
2441 // fSourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR);
2442 // fSourceViewerDecorationSupport.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN);
2443 // fSourceViewerDecorationSupport.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
2445 // fSourceViewerDecorationSupport.setSymbolicFontName(getFontPropertyPreferenceKey());
2449 * Jumps to the matching bracket.
2451 public void gotoMatchingBracket() {
2453 ISourceViewer sourceViewer = getSourceViewer();
2454 IDocument document = sourceViewer.getDocument();
2455 if (document == null)
2458 IRegion selection = getSignedSelection(sourceViewer);
2460 int selectionLength = Math.abs(selection.getLength());
2461 if (selectionLength > 1) {
2462 setStatusLineErrorMessage(PHPEditorMessages.getString("GotoMatchingBracket.error.invalidSelection")); //$NON-NLS-1$
2463 sourceViewer.getTextWidget().getDisplay().beep();
2468 int sourceCaretOffset = selection.getOffset() + selection.getLength();
2469 if (isSurroundedByBrackets(document, sourceCaretOffset))
2470 sourceCaretOffset -= selection.getLength();
2472 IRegion region = fBracketMatcher.match(document, sourceCaretOffset);
2473 if (region == null) {
2474 setStatusLineErrorMessage(PHPEditorMessages.getString("GotoMatchingBracket.error.noMatchingBracket")); //$NON-NLS-1$
2475 sourceViewer.getTextWidget().getDisplay().beep();
2479 int offset = region.getOffset();
2480 int length = region.getLength();
2485 int anchor = fBracketMatcher.getAnchor();
2486 int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;
2488 boolean visible = false;
2489 if (sourceViewer instanceof ITextViewerExtension3) {
2490 ITextViewerExtension3 extension = (ITextViewerExtension3) sourceViewer;
2491 visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
2493 IRegion visibleRegion = sourceViewer.getVisibleRegion();
2494 visible = (targetOffset >= visibleRegion.getOffset() && targetOffset < visibleRegion.getOffset() + visibleRegion.getLength());
2498 setStatusLineErrorMessage(PHPEditorMessages.getString("GotoMatchingBracket.error.bracketOutsideSelectedElement")); //$NON-NLS-1$
2499 sourceViewer.getTextWidget().getDisplay().beep();
2503 if (selection.getLength() < 0)
2504 targetOffset -= selection.getLength();
2506 sourceViewer.setSelectedRange(targetOffset, selection.getLength());
2507 sourceViewer.revealRange(targetOffset, selection.getLength());
2510 * Ses the given message as error message to this editor's status line.
2511 * @param msg message to be set
2513 protected void setStatusLineErrorMessage(String msg) {
2514 IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
2515 if (statusLine != null)
2516 statusLine.setMessage(true, msg, null);
2520 * Returns a segmentation of the line of the given document appropriate for bidi rendering.
2521 * The default implementation returns only the string literals of a php code line as segments.
2523 * @param document the document
2524 * @param lineOffset the offset of the line
2525 * @return the line's bidi segmentation
2526 * @throws BadLocationException in case lineOffset is not valid in document
2528 public static int[] getBidiLineSegments(IDocument document, int lineOffset) throws BadLocationException {
2530 IRegion line = document.getLineInformationOfOffset(lineOffset);
2531 ITypedRegion[] linePartitioning = document.computePartitioning(lineOffset, line.getLength());
2533 List segmentation = new ArrayList();
2534 for (int i = 0; i < linePartitioning.length; i++) {
2535 if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType()))
2536 segmentation.add(linePartitioning[i]);
2539 if (segmentation.size() == 0)
2542 int size = segmentation.size();
2543 int[] segments = new int[size * 2 + 1];
2546 for (int i = 0; i < size; i++) {
2547 ITypedRegion segment = (ITypedRegion) segmentation.get(i);
2552 int offset = segment.getOffset() - lineOffset;
2553 if (offset > segments[j - 1])
2554 segments[j++] = offset;
2556 if (offset + segment.getLength() >= line.getLength())
2559 segments[j++] = offset + segment.getLength();
2562 if (j < segments.length) {
2563 int[] result = new int[j];
2564 System.arraycopy(segments, 0, result, 0, j);
2571 * Returns a segmentation of the given line appropriate for bidi rendering. The default
2572 * implementation returns only the string literals of a php code line as segments.
2574 * @param lineOffset the offset of the line
2575 * @param line the content of the line
2576 * @return the line's bidi segmentation
2578 protected int[] getBidiLineSegments(int lineOffset, String line) {
2579 IDocumentProvider provider = getDocumentProvider();
2580 if (provider != null && line != null && line.length() > 0) {
2581 IDocument document = provider.getDocument(getEditorInput());
2582 if (document != null)
2584 return getBidiLineSegments(document, lineOffset);
2585 } catch (BadLocationException x) {
2593 * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
2595 // protected final ISourceViewer createSourceViewer(
2596 // Composite parent,
2597 // IVerticalRuler ruler,
2599 // ISourceViewer viewer = createJavaSourceViewer(parent, ruler, styles);
2600 // StyledText text = viewer.getTextWidget();
2601 // text.addBidiSegmentListener(new BidiSegmentListener() {
2602 // public void lineGetSegments(BidiSegmentEvent event) {
2603 // event.segments = getBidiLineSegments(event.lineOffset, event.lineText);
2606 // // JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
2610 public final ISourceViewer getViewer() {
2611 return getSourceViewer();
2615 // protected void showOverviewRuler() {
2616 // if (fOverviewRuler != null) {
2617 // if (getSourceViewer() instanceof ISourceViewerExtension) {
2618 // ((ISourceViewerExtension) getSourceViewer()).showAnnotationsOverview(true);
2619 // fSourceViewerDecorationSupport.updateOverviewDecorations();
2624 // protected void hideOverviewRuler() {
2625 // if (getSourceViewer() instanceof ISourceViewerExtension) {
2626 // fSourceViewerDecorationSupport.hideAnnotationOverview();
2627 // ((ISourceViewerExtension) getSourceViewer()).showAnnotationsOverview(false);
2631 // protected boolean isOverviewRulerVisible() {
2632 // IPreferenceStore store = getPreferenceStore();
2633 // return store.getBoolean(OVERVIEW_RULER);
2636 * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
2638 // protected ISourceViewer createJavaSourceViewer(
2639 // Composite parent,
2640 // IVerticalRuler ruler,
2641 // IOverviewRuler overviewRuler,
2642 // boolean isOverviewRulerVisible,
2644 // return new SourceViewer(parent, ruler, overviewRuler, isOverviewRulerVisible(), styles);
2647 * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
2649 protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
2650 return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
2653 * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
2655 protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
2657 ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, getPreferenceStore());
2659 StyledText text= viewer.getTextWidget();
2660 text.addBidiSegmentListener(new BidiSegmentListener() {
2661 public void lineGetSegments(BidiSegmentEvent event) {
2662 event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
2666 // JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
2668 // ensure source viewer decoration support has been created and configured
2669 getSourceViewerDecorationSupport(viewer);
2674 * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
2676 // protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
2677 // return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
2680 * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
2682 protected boolean affectsTextPresentation(PropertyChangeEvent event) {
2683 JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
2684 return textTools.affectsBehavior(event);
2688 * Jumps to the error next according to the given direction.
2690 public void gotoError(boolean forward) {
2692 ISelectionProvider provider = getSelectionProvider();
2694 ITextSelection s = (ITextSelection) provider.getSelection();
2695 Position errorPosition = new Position(0, 0);
2696 IJavaAnnotation nextError = getNextError(s.getOffset(), forward, errorPosition);
2698 if (nextError != null) {
2700 IMarker marker = null;
2701 if (nextError instanceof MarkerAnnotation)
2702 marker = ((MarkerAnnotation) nextError).getMarker();
2704 Iterator e = nextError.getOverlaidIterator();
2706 while (e.hasNext()) {
2707 Object o = e.next();
2708 if (o instanceof MarkerAnnotation) {
2709 marker = ((MarkerAnnotation) o).getMarker();
2716 if (marker != null) {
2717 IWorkbenchPage page = getSite().getPage();
2718 IViewPart view = view = page.findView("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
2719 if (view instanceof TaskList) {
2720 StructuredSelection ss = new StructuredSelection(marker);
2721 ((TaskList) view).setSelection(ss, true);
2725 selectAndReveal(errorPosition.getOffset(), errorPosition.getLength());
2726 // setStatusLineErrorMessage(nextError.getMessage());
2730 setStatusLineErrorMessage(null);
2735 private IJavaAnnotation getNextError(int offset, boolean forward, Position errorPosition) {
2737 IJavaAnnotation nextError = null;
2738 Position nextErrorPosition = null;
2740 IDocument document = getDocumentProvider().getDocument(getEditorInput());
2741 int endOfDocument = document.getLength();
2744 IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
2745 Iterator e = new JavaAnnotationIterator(model, false);
2746 while (e.hasNext()) {
2748 IJavaAnnotation a = (IJavaAnnotation) e.next();
2749 if (a.hasOverlay() || !a.isProblem())
2752 Position p = model.getPosition((Annotation) a);
2753 if (!p.includes(offset)) {
2755 int currentDistance = 0;
2758 currentDistance = p.getOffset() - offset;
2759 if (currentDistance < 0)
2760 currentDistance = endOfDocument - offset + p.getOffset();
2762 currentDistance = offset - p.getOffset();
2763 if (currentDistance < 0)
2764 currentDistance = offset + endOfDocument - p.getOffset();
2767 if (nextError == null || currentDistance < distance) {
2768 distance = currentDistance;
2770 nextErrorPosition = p;
2775 if (nextErrorPosition != null) {
2776 errorPosition.setOffset(nextErrorPosition.getOffset());
2777 errorPosition.setLength(nextErrorPosition.getLength());
2782 void removeOccurrenceAnnotations() {
2783 IDocumentProvider documentProvider= getDocumentProvider();
2784 if (documentProvider == null)
2787 IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
2788 if (annotationModel == null || fOccurrenceAnnotations == null)
2791 synchronized (annotationModel) {
2792 if (annotationModel instanceof IAnnotationModelExtension) {
2793 ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
2795 for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
2796 annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
2798 fOccurrenceAnnotations= null;
2801 // protected void uninstallOverrideIndicator() {
2802 // if (fOverrideIndicatorManager != null) {
2803 // fOverrideIndicatorManager.removeAnnotations();
2804 // fOverrideIndicatorManager= null;
2808 protected void installOverrideIndicator(boolean waitForReconcilation) {
2809 // uninstallOverrideIndicator();
2810 IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
2811 // IJavaElement inputElement= getInputJavaElement();
2813 // if (model == null || inputElement == null)
2816 // CompilationUnit ast= PHPeclipsePlugin.getDefault().getASTProvider().getAST(inputElement, true, null);
2817 // fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, ast);
2821 * Tells whether override indicators are shown.
2823 * @return <code>true</code> if the override indicators are shown
2826 //protected boolean isShowingOverrideIndicators() {
2827 // AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
2828 // IPreferenceStore store= getPreferenceStore();
2829 // return getBoolean(store, preference.getHighlightPreferenceKey())
2830 // || getBoolean(store, preference.getVerticalRulerPreferenceKey())
2831 // || getBoolean(store, preference.getOverviewRulerPreferenceKey())
2832 // || getBoolean(store, preference.getTextPreferenceKey());
2836 * Returns the boolean preference for the given key.
2838 * @param store the preference store
2839 * @param key the preference key
2840 * @return <code>true</code> if the key exists in the store and its value is <code>true</code>
2843 private boolean getBoolean(IPreferenceStore store, String key) {
2844 return key != null && store.getBoolean(key);
2848 * Returns the folding action group, or <code>null</code> if there is none.
2850 * @return the folding action group, or <code>null</code> if there is none
2853 protected FoldingActionGroup getFoldingActionGroup() {
2854 return fFoldingGroup;