//Get the figure for an EditPart GuiTestObject figureTO = EntityEditPart().getFigure(); //Find for a figure that has the text in it. TestObject foundTO[] = figureTO.find(atDescendant("text", "label")); if(foundTO != null) { int numFound = foundTO.length; for(int index = 0; index < numFound ; index ++) { if(foundTO[index] != null && foundTO[index] instanceof GuiTestObject) { //To check for specific property on the figure Object figWidth = foundTO[index].getProperty("width"); if(figWidth != null) ((GuiTestObject)foundTO[index]).click(); } } }
//List the connectors from the node's parent TestObject parent = EntityEditPart().getParent(); if(parent != null && parent instanceof GefEditPartTestObject) { TestObject connectors[] = ((GefEditPartTestObject)parent).getConnectors(); if(connectors != null) { int numConnector = connectors.length; for(int conIndex = 0; conIndex < numConnector; conIndex ++) { if(connectors[conIndex] != null && connectors[conIndex] instanceof GefEditPartTestObject) { GuiTestObject figConnector = ((GefEditPartTestObject)connectors[conIndex]).getFigure(); //Find for a figure that has some text in it. TestObject foundConn[] = figConnector.find(atDescendant("text", "association")); if(foundConn != null && foundConn.length > 0) { //If there is only one label with the text "Association" if(foundConn[0] != null && foundConn[0] instanceof GuiTestObject) { ((GuiTestObject)foundConn[0]).click(); } } } } } }
Ejemplo 3: en el ejemplo siguiente se llena una lista con los conectores que son descendientes del EditPart seleccionado utilizando la API isConnector ().
//Assuming you have "RootEditPart" in the ObjectMap. ArrayList connList = new ArrayList(); enumerateAllConnectors(RootEditPart(),connList); } private static void enumerateAllConnectors(TestObject editPart,ArrayList connList) { if(editPart != null ) { if(editPart instanceof GefEditPartTestObject) { boolean isConnector = ((GefEditPartTestObject)editPart).isConnector(); if(isConnector) connList.add(editPart); } TestObject []children = editPart.getChildren(); if(children != null) { int numChild = children.length; for(int i=0; i < numChild ; i++) { enumerateAllConnectors(children[i], connList); } } } }