Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » RCP Testing Tool » Need help on ECL script(Have some difficulties to implement algorithm (loop, let variables etc...))
Need help on ECL script [message #1692420] Wed, 15 April 2015 14:41 Go to next message
Christophe Contreras is currently offline Christophe ContrerasFriend
Messages: 7
Registered: March 2015
Junior Member
Hi,

I try to make a generic script for testing org.eclipse.draw2d Figures.

My case is that I have to loop on Viewport children (Figures objects) and click on them to perform some actions.

My idea is to make a procedure givin the name of the Figure to find and the procedure will find this Figure and perform the action.

The algorithm must do those actions :


    1. Give the Figure name in parameter
    2. List the Figures children of a Viewport
    3. For each found children, test its name (or another property)
    4. If the property matches with the given parameter, make a click on the Figure


To realize this script, I wanted to use the following ECL commands :

proc --> To make a parametrable procedure

loop or foreach or each --> To make a loop on children object

let --> To save the number of children into a variable for further use in loop

I tried some code but I don't have any results...

For having the number of children :

let [val nbChildren | get-canvas | get-property "MyViewPort.getChildren().size()" -raw]


Another try using each :

get-canvas | get-property "MyViewPort.getChildren()" | each [val element] {
	log [format "%d" $element]
}


It doesn't works... And then even if it works I don't knwo how to recover the current child to apply some actions on it...

So my question is how can I list children of an object and get this object to make some comparison or actions like click ?

If someone could help me doing this kind of actions...

Thank you in advance,
Christophe
Re: Need help on ECL script [message #1692832 is a reply to message #1692420] Mon, 20 April 2015 06:12 Go to previous messageGo to next message
Olga Yurchuk is currently offline Olga YurchukFriend
Messages: 245
Registered: September 2014
Senior Member

Hello,

Am I right, that "Figure name"="MyViewPort" in your example?
Could you please attach the whole ECL-script and execution details of the test.
Could you please also record verification of the one name (which you want to verify) and attach generated ECL-code.
It would be helpful if you attach screenshot with Assertion&Verification dialog, where needed properties are visible.

Thanks in advance!


Yours sincerely,
Olga.
Re: Need help on ECL script [message #1692878 is a reply to message #1692832] Mon, 20 April 2015 11:45 Go to previous messageGo to next message
Olga Yurchuk is currently offline Olga YurchukFriend
Messages: 245
Registered: September 2014
Senior Member

It seems that there is a syntax error.
Take a look at the following ECL snippet:
proc "FindAllChildren" [val name] {
	get-view "Package Explorer" | get-tree | get-item $name | expand-all | get-items | foreach [val item] {
		if [$item | get-property caption -raw | eq "B.txt"] {
			log "Found!"
		}
	}
}

This snippet has the same algorithm as you have described.


Yours sincerely,
Olga.
Re: Need help on ECL script [message #1692920 is a reply to message #1692878] Mon, 20 April 2015 15:12 Go to previous messageGo to next message
Christophe Contreras is currently offline Christophe ContrerasFriend
Messages: 7
Registered: March 2015
Junior Member
Hi,

My issue is on looping on draw2d Figures, it seems different than looping on tree elements.

I have a Figure container (ViewPort : http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.draw2d.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fdraw2d%2FViewport.html) containing some Figures (http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.draw2d.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fdraw2d%2FFigure.html)

Now (with your help on another topic) I can get the number of Children of my ViewPort and iterate over them BUT I cannot retrieve the object to click on it :

proc "find-my-figure" [val myPropToFind] {
	
	// Get the number of Children into nbChildren
	let [val nbChildren [get-canvas | get-property "getViewport().getChildren().FreeformLayeredPane[0].getChildren().ScalableFreeformLayeredPane[0].getChildren().FreeformLayeredPane[1].getChildren().FreeformLayer[0].getChildren().Viewport[0].getChildren().size()" -raw]] { 
		
		// For each Children of type Figures
		loop [val curChild 0] {
		
			// While we are not at the end of the list of getChildren()
		    if [$curChild | eq $nbChildren] {
		        // Nothing
		    } -else {
		    	
		    	// If the current Figure corresponds to the searched parameter myPropToFind
		    	if [get-canvas | get-property [format "getViewport().getChildren().FreeformLayeredPane[0].getChildren().ScalableFreeformLayeredPane[0].getChildren().FreeformLayeredPane[1].getChildren().FreeformLayer[0].getChildren().Viewport[0].getChildren().Figure[%d].getMyProp()" $curChild] -raw | eq $myPropToFind] {
					show-alert "Figure found !!"
			    
					// Now how to get this Figure and click on it ???
			    }
			    
			    // Loop on next Figure
		    	recur [$curChild | plus 1]
		    }
		}
	}
}


This procedure is correctly working now but I have put in comment where I am blocked (Now how to get this Figure and click on it ???)

The goal for me now is to retrieve the Figure object found and apply any UI action (click for example).

Is it more clear ? (sorry for the huge path in my Figure architecture)

Christophe
Re: Need help on ECL script [message #1692922 is a reply to message #1692920] Mon, 20 April 2015 15:16 Go to previous messageGo to next message
Christophe Contreras is currently offline Christophe ContrerasFriend
Messages: 7
Registered: March 2015
Junior Member
I'm not sure I can use Foreach method to list the getChildren().Figure[x] of my ViewPort... But if I'm wrong it can be better solution than recovering number of children and make a loop like in my posted script...
Re: Need help on ECL script [message #1693507 is a reply to message #1692420] Fri, 24 April 2015 15:30 Go to previous message
Jean-Patrice Laude is currently offline Jean-Patrice LaudeFriend
Messages: 1
Registered: April 2015
Junior Member
Hello,

Any idea on how to retrieve a 'clickable' object knowing the full path: "getViewport().getChildren().FreeformLayeredPane[0].getChildren().ScalableFreeformLayeredPane[0].getChildren().FreeformLayeredPane[1].getChildren().FreeformLayer[0].getChildren().Viewport[0].getChildren().Figure[%d]" ?

I'm wondering if we can use something like
get-canvas | get-control -kind Figure -path "" -index [format "%d" $curChild"]


But here I'm not sure what should I have in path parameter


thanks
Previous Topic:How to restart aut while recording?
Next Topic:RCPTT Maven packaging error
Goto Forum:
  


Current Time: Thu Apr 25 14:36:42 GMT 2024

Powered by FUDForum. Page generated in 0.03574 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top