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.help.WorkbenchHelp;
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 org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
30 //import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor;
31 //import org.eclipse.jdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
32 //import org.eclipse.jdt.internal.ui.text.java.hover.JavaExpandHover;
35 * A special select marker ruler action which activates quick fix if clicked on a quick fixable problem.
37 public class JavaSelectMarkerRulerAction2 extends SelectAnnotationRulerAction {
39 public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
40 super(bundle, prefix, editor);
41 WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
45 * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
47 public void annotationDefaultSelected(VerticalRulerEvent event) {
48 Annotation annotation= event.getSelectedAnnotation();
49 IAnnotationModel model= getAnnotationModel();
51 // if (isOverrideIndicator(annotation)) {
52 // ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
56 if (isBreakpoint(annotation))
57 triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
59 Position position= model.getPosition(annotation);
63 // if (isQuickFixTarget(annotation)) {
64 // ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
65 // final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
66 // if (operation != null && operation.canDoOperation(opCode)) {
67 // getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
68 // operation.doOperation(opCode);
74 super.annotationDefaultSelected(event);
78 * Tells whether the given annotation is an override annotation.
80 * @param annotation the annotation
81 * @return <code>true</code> iff the annotation is an override annotation
83 private boolean isOverrideIndicator(Annotation annotation) {
84 return false; //annotation instanceof OverrideIndicatorManager.OverrideIndicator;
91 private boolean isBreakpoint(Annotation annotation) {
92 return annotation.getType().equals("org.eclipse.debug.core.breakpoint");
93 //|| annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
97 private boolean isQuickFixTarget(Annotation a) {
98 return false; //JavaCorrectionProcessor.hasCorrections(a) || a instanceof AssistAnnotation;
101 private void triggerAction(String actionID) {
102 IAction action= getTextEditor().getAction(actionID);
103 if (action != null) {
104 if (action instanceof IUpdate)
105 ((IUpdate) action).update();
106 // hack to propagate line change
107 if (action instanceof ISelectionListener) {
108 ((ISelectionListener)action).selectionChanged(null, null);
110 if (action.isEnabled())