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.ITextOperationTarget;
19 import org.eclipse.jface.text.Position;
20 import org.eclipse.jface.text.source.Annotation;
21 import org.eclipse.jface.text.source.IAnnotationModel;
22 import org.eclipse.jface.text.source.VerticalRulerEvent;
23 import org.eclipse.ui.ISelectionListener;
24 import org.eclipse.ui.help.WorkbenchHelp;
25 import org.eclipse.ui.texteditor.ITextEditor;
26 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
27 import org.eclipse.ui.texteditor.IUpdate;
28 import org.eclipse.ui.texteditor.SelectAnnotationRulerAction;
30 //import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
31 //import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor;
32 //import org.eclipse.jdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
33 //import org.eclipse.jdt.internal.ui.text.java.hover.JavaExpandHover;
36 * A special select marker ruler action which activates quick fix if clicked on a quick fixable problem.
38 public class JavaSelectMarkerRulerAction2 extends SelectAnnotationRulerAction {
40 public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
41 super(bundle, prefix, editor);
42 WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
46 * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
48 public void annotationDefaultSelected(VerticalRulerEvent event) {
49 Annotation annotation= event.getSelectedAnnotation();
50 IAnnotationModel model= getAnnotationModel();
52 // if (isOverrideIndicator(annotation)) {
53 // ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
57 if (isBreakpoint(annotation))
58 triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
60 Position position= model.getPosition(annotation);
64 // if (isQuickFixTarget(annotation)) {
65 // ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
66 // final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
67 // if (operation != null && operation.canDoOperation(opCode)) {
68 // getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
69 // operation.doOperation(opCode);
75 super.annotationDefaultSelected(event);
79 * Tells whether the given annotation is an override annotation.
81 * @param annotation the annotation
82 * @return <code>true</code> iff the annotation is an override annotation
84 private boolean isOverrideIndicator(Annotation annotation) {
85 return false; //annotation instanceof OverrideIndicatorManager.OverrideIndicator;
92 private boolean isBreakpoint(Annotation annotation) {
93 return annotation.getType().equals("org.eclipse.debug.core.breakpoint");
94 //|| annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
98 private boolean isQuickFixTarget(Annotation a) {
99 return false; //JavaCorrectionProcessor.hasCorrections(a) || a instanceof AssistAnnotation;
102 private void triggerAction(String actionID) {
103 IAction action= getTextEditor().getAction(actionID);
104 if (action != null) {
105 if (action instanceof IUpdate)
106 ((IUpdate) action).update();
107 // hack to propagate line change
108 if (action instanceof ISelectionListener) {
109 ((ISelectionListener)action).selectionChanged(null, null);
111 if (action.isEnabled())