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 org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.text.ITextOperationTarget;
17 import org.eclipse.jface.text.Position;
18 import org.eclipse.jface.text.source.Annotation;
19 import org.eclipse.jface.text.source.AnnotationEvent;
20 import org.eclipse.jface.text.source.IAnnotationModel;
21 import org.eclipse.ui.ISelectionListener;
22 import org.eclipse.ui.texteditor.ITextEditor;
23 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
24 import org.eclipse.ui.texteditor.IUpdate;
25 import org.eclipse.ui.texteditor.SelectMarkerRulerAction2;
27 //import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
28 //import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor;
29 //import org.eclipse.jdt.internal.ui.text.correction.QuickAssistLightBulbUpdater.AssistAnnotation;
30 //import org.eclipse.jdt.internal.ui.text.java.hover.JavaExpandHover;
33 * A special select marker ruler action which activates quick fix if clicked on a quick fixable problem.
35 public class JavaSelectMarkerRulerAction2 extends SelectMarkerRulerAction2 {
37 public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
38 super(bundle, prefix, editor);
39 // WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
43 * @see org.eclipse.ui.texteditor.IAnnotationListener#annotationDefaultSelected(org.eclipse.ui.texteditor.AnnotationEvent)
45 public void annotationDefaultSelected(AnnotationEvent event) {
46 Annotation a= event.getAnnotation();
47 IAnnotationModel model= getAnnotationModel();
48 Position position= model.getPosition(a);
51 triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
56 if (isQuickFixTarget(a)) {
57 ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
58 // final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
59 // if (operation != null && operation.canDoOperation(opCode)) {
60 // getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
61 // operation.doOperation(opCode);
67 super.annotationDefaultSelected(event);
74 private boolean isBreakpoint(Annotation a) {
75 return a.getType().equals("org.eclipse.debug.core.breakpoint");
76 //|| a.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
79 private boolean isQuickFixTarget(Annotation a) {
80 // return a instanceof IJavaAnnotation && JavaCorrectionProcessor.hasCorrections((IJavaAnnotation) a) || a instanceof AssistAnnotation;
84 private void triggerAction(String actionID) {
85 IAction action= getTextEditor().getAction(actionID);
87 if (action instanceof IUpdate)
88 ((IUpdate) action).update();
89 // hack to propagate line change
90 if (action instanceof ISelectionListener) {
91 ((ISelectionListener)action).selectionChanged(null, null);
93 if (action.isEnabled())