1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
13 import java.util.ResourceBundle;
15 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.jface.text.Position;
19 import org.eclipse.jface.text.source.Annotation;
20 import org.eclipse.jface.text.source.IAnnotationModel;
21 import org.eclipse.jface.text.source.VerticalRulerEvent;
22 import org.eclipse.ui.ISelectionListener;
23 import org.eclipse.ui.PlatformUI;
24 import org.eclipse.ui.texteditor.ITextEditor;
25 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
26 import org.eclipse.ui.texteditor.IUpdate;
27 import org.eclipse.ui.texteditor.SelectAnnotationRulerAction;
29 // import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
31 // net.sourceforge.phpdt.internal.ui.text.correction.JavaCorrectionProcessor;
33 // net.sourceforge.phpdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
34 // import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaExpandHover;
37 * A special select marker ruler action which activates quick fix if clicked on
38 * a quick fixable problem.
40 public class JavaSelectMarkerRulerAction2 extends SelectAnnotationRulerAction {
42 public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix,
44 super(bundle, prefix, editor);
45 PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
46 IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
50 * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
52 public void annotationDefaultSelected(VerticalRulerEvent event) {
53 Annotation annotation = event.getSelectedAnnotation();
54 IAnnotationModel model = getAnnotationModel();
56 // if (isOverrideIndicator(annotation)) {
57 // ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
61 if (isBreakpoint(annotation))
62 triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
64 Position position = model.getPosition(annotation);
68 // if (isQuickFixTarget(annotation)) {
69 // ITextOperationTarget operation= (ITextOperationTarget)
70 // getTextEditor().getAdapter(ITextOperationTarget.class);
71 // final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
72 // if (operation != null && operation.canDoOperation(opCode)) {
73 // getTextEditor().selectAndReveal(position.getOffset(),
74 // position.getLength());
75 // operation.doOperation(opCode);
81 super.annotationDefaultSelected(event);
85 * Tells whether the given annotation is an override annotation.
89 * @return <code>true</code> iff the annotation is an override annotation
91 private boolean isOverrideIndicator(Annotation annotation) {
92 return false; // annotation instanceof
93 // OverrideIndicatorManager.OverrideIndicator;
100 private boolean isBreakpoint(Annotation annotation) {
101 return annotation.getType().equals("org.eclipse.debug.core.breakpoint");
103 // annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION);
108 private boolean isQuickFixTarget(Annotation a) {
109 return false; // JavaCorrectionProcessor.hasCorrections(a) || a
110 // instanceof AssistAnnotation;
113 private void triggerAction(String actionID) {
114 IAction action = getTextEditor().getAction(actionID);
115 if (action != null) {
116 if (action instanceof IUpdate)
117 ((IUpdate) action).update();
118 // hack to propagate line change
119 if (action instanceof ISelectionListener) {
120 ((ISelectionListener) action).selectionChanged(null, null);
122 if (action.isEnabled())