| Create element out of clipping window [message #663221] |
Mon, 04 April 2011 07:44 |
Arthur Daussy Messages: 1 Registered: April 2011 |
Junior Member |
|
|
Hi,
First I would like to thanks anybody who can help me on this topic. I'm a new user of SWTBot and I'm working specially on the GEF part on SWTBot. I have been through some topics on this forum but none of them seem to answer my question. After discovering some of the great features of SWTBot I have encountered a problem. I want to create a helper which creates an element from a palette tool at a specific location. In order to do it I used the following code. The following method has been implemented in a class which extends SWTBotGefEditor.
/**
* @Create a node in the current diagram
* @param name of the element (if needed can be null if the element has no name)
* @param position Position where the node has to be created (FIXME for now only location inside the current diagram work. Outside the diagram error it do not expand automaticallyà)
* @param tool Name of the tool used to create the diagram (e.g in activity diagram "Activity Partition" @see {@link ActivityDiagramConstants}
* @param dim Dimension of the drag (can be null if it's a simple click)
* @return return {@link SWTBotGefEditor} of the newly element or null if it has failed
*/
private SWTBotGefEditPart createNodeElement(String name, Point position, String tool, Dimension dim, NameEditMode mode) {
this.activateTool(tool);
if(dim != null && (dim.height != 0 || dim.width != 0)) {
this.drag(position.x, position.y, position.x + dim.width, position.y + dim.height);
} else {
this.click(position.x, position.y+ MOVE);
}
bot.waitUntil(new WaitForEditsPartAfterCreation(this),3000);
List<SWTBotGefEditPart> selectedEditPart = this.getSWTBotGefViewer().selectedEditParts();
SWTBotGefEditPart swtBotGefEditPart = null;
if(!selectedEditPart.isEmpty()) {
swtBotGefEditPart = selectedEditPart.get(0);
}
if(name != null) {
switch(mode) {
case BY_DIRECT_EDIT:
swtBotGefEditPart.activateDirectEdit();
this.directEditType(name);
break;
case BY_PROPERTIES:
case DEFAULT:
default:
SWTBotPapyrusHelper.changeCurrentElementName(name,swtBotGefEditPart);
break;
}
}
return swtBotGefEditPart;
}
This method works perfectly fine when I intend to create an element which is contained in the clipping window of the diagram view (see figure ). However when I try to create an element out of the clipping window SWTBot clicks out of the view and nothing is done.
For example :
Position of the new element X = 700 , Y 100
Size of the clipping windows Width = 600 , Height = 400,
Size of the diagram Width = 900 , Height = 600.

First I have thought to use the scrollbar to move the diagram before clicking however using this method seems to be really complicated to compute new coordinates in a new clipping window. If anyone has any suggestions I would be glad to hear them.
Thanks for your time
|
|
|
Powered by
FUDForum. Page generated in 0.01502 seconds