Context click on an editor's vertical ruler

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Context click on an editor's vertical ruler

Postby nortega » Mon Sep 21, 2009 11:59 am

Hi,

I need to use the context menu of and editor's vertical ruler. When I used the recorder to do it the canvas was used to locate the vertical ruler. I have set a name to that canvas to avoid ambiguity. However, when I use the context click API the click takes place at the middle of the control. Since the behavior of the context menu varies depending on where the ruler is clicked, is there a way I can specify the specific location I want to click on?

This is the API call I am using:
Code: Select all
ui.contextClick(new NamedWidgetLocator("editor.vertical_ruler_control"),  "Toggle Brea&kpoint");
nortega
 
Posts: 6
Joined: Wed Sep 09, 2009 11:07 am

Re: Context click on an editor's vertical ruler

Postby Phil Quitslund » Mon Sep 21, 2009 12:47 pm

There is currently not a good way to do this generally. But perhaps we could work up something for your specific case. Is the goal to set a breakpoint at a given line number? Maybe we could cook something up that talks directly to the action that triggers the toggling (e.g., org.eclipse.debug.ui.actions.ToggleBreakpointAction). Would an API that looks like this be headed in the right direction?:

void toggleBreakpointInActiveEditorAtLine(int lineNumber);

Do you need to be able to check if the breakpoint is already set?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Context click on an editor's vertical ruler

Postby nortega » Tue Sep 22, 2009 7:08 am

I need to toggle a breakpoint at a particular line. I also need to verify that breakpoints can be toggled only in lines that support them (E.g. not in comment lines). This involves being able to check if a ruler menu option is enabled or disabled.
nortega
 
Posts: 6
Joined: Wed Sep 09, 2009 11:07 am

Re: Context click on an editor's vertical ruler

Postby Phil Quitslund » Tue Sep 22, 2009 2:53 pm

Starting with setting a breakpoint on a line, here's a top-down sketch of how we might proceed if we took the programmatic angle.

Code: Select all
import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorPart;

import com.windowtester.runtime.swt.UITestCaseSWT;

public class BreakpointSpelunk extends UITestCaseSWT {

   public void testDrive() throws Exception {
      moveCursorToLine();
      toggleBreakpoint();
   }
   private void moveCursorToLine() {
      // TODO Auto-generated method stub
   }
   
   private void toggleBreakpoint() {
      IEditorPart editor = getEditorPart();
      IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) editor.getAdapter(IVerticalRulerInfo.class);
      IDocument document = getEditor(editor);
      new ToggleBreakpointAction(editor, document, rulerInfo).run();
   }

   private IDocument getEditor(IEditorPart editor) {
      // TODO Auto-generated method stub
      return null;
   }

   private IEditorPart getEditorPart() {
      // TODO Auto-generated method stub
      return null;
   }
   
   
}


There are certainly cleaner ways... but this is a start.
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest