3m9 compatible;
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / JavaSelectMarkerRulerAction2.java
index 29a2fb4..1abf58d 100644 (file)
@@ -12,17 +12,20 @@ package net.sourceforge.phpeclipse.phpeditor;
 
 import java.util.ResourceBundle;
 
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.text.ITextOperationTarget;
 import org.eclipse.jface.text.Position;
 import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationEvent;
 import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.VerticalRulerEvent;
 import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.help.WorkbenchHelp;
 import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.SelectMarkerRulerAction2;
+import org.eclipse.ui.texteditor.SelectAnnotationRulerAction;
 
 //import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
 //import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor;
@@ -32,53 +35,68 @@ import org.eclipse.ui.texteditor.SelectMarkerRulerAction2;
 /**
  * A special select marker ruler action which activates quick fix if clicked on a quick fixable problem.
  */
-public class JavaSelectMarkerRulerAction2 extends SelectMarkerRulerAction2 {
+public class JavaSelectMarkerRulerAction2 extends SelectAnnotationRulerAction {
 
        public JavaSelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) {
                super(bundle, prefix, editor);
-//             WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
+               WorkbenchHelp.setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION);
        }
        
        /*
-        * @see org.eclipse.ui.texteditor.IAnnotationListener#annotationDefaultSelected(org.eclipse.ui.texteditor.AnnotationEvent)
+        * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
         */
-       public void annotationDefaultSelected(AnnotationEvent event) {
-               Annotation a= event.getAnnotation();
+       public void annotationDefaultSelected(VerticalRulerEvent event) {
+               Annotation annotation= event.getSelectedAnnotation();
                IAnnotationModel model= getAnnotationModel();
-               Position position= model.getPosition(a);
                
-               if (isBreakpoint(a))
+//             if (isOverrideIndicator(annotation)) {
+//                     ((OverrideIndicatorManager.OverrideIndicator)annotation).open();
+//                     return;
+//             }
+               
+               if (isBreakpoint(annotation))
                        triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
                
+               Position position= model.getPosition(annotation);
                if (position == null)
                        return;
                
-               if (isQuickFixTarget(a)) {
-                       ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
+//             if (isQuickFixTarget(annotation)) {
+//                     ITextOperationTarget operation= (ITextOperationTarget) getTextEditor().getAdapter(ITextOperationTarget.class);
 //                     final int opCode= PHPUnitEditor.CORRECTIONASSIST_PROPOSALS;
 //                     if (operation != null && operation.canDoOperation(opCode)) {
 //                             getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
 //                             operation.doOperation(opCode);
 //                             return;
 //                     }
-               }
+//             }
                
                // default:
                super.annotationDefaultSelected(event);
        }
 
        /**
-        * @param ma
+        * Tells whether the given annotation is an override annotation.
+        *
+        * @param annotation the annotation
+        * @return <code>true</code> iff the annotation is an override annotation
+        */
+       private boolean isOverrideIndicator(Annotation annotation) {
+               return false; //annotation instanceof OverrideIndicatorManager.OverrideIndicator;
+       }
+
+       /**
+        * @param annotation
         * @return
         */
-       private boolean isBreakpoint(Annotation a) {
-               return a.getType().equals("org.eclipse.debug.core.breakpoint");
-               //|| a.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
+       private boolean isBreakpoint(Annotation annotation) {
+               return annotation.getType().equals("org.eclipse.debug.core.breakpoint"); 
+               //|| annotation.getType().equals(JavaExpandHover.NO_BREAKPOINT_ANNOTATION); //$NON-NLS-1$
+               
        }
 
        private boolean isQuickFixTarget(Annotation a) {
-       //      return a instanceof IJavaAnnotation && JavaCorrectionProcessor.hasCorrections((IJavaAnnotation) a) || a instanceof AssistAnnotation;    
-         return false;
+               return false; //JavaCorrectionProcessor.hasCorrections(a) || a instanceof AssistAnnotation;
        }
 
        private void triggerAction(String actionID) {
@@ -96,4 +114,3 @@ public class JavaSelectMarkerRulerAction2 extends SelectMarkerRulerAction2 {
        }
 
 }
-