Procurando Objetos GEF

O Functional Tester reconhece o GEF EditParts e Palettes. É possível que algumas Figuras não tenham nenhuma associação com uma EditPart. Você pode usar as APIs do Functional Tester para localizar tais Figuras como mostrados nos exemplos abaixo.
Exemplo 1: O exemplo a seguir ilustra como usar a API getFigure() para recuperar uma Figura que tenha o texto "etiqueta" e não esteja associado à EditPart
//Obter a figura de
uma EditPart
		GuiTestObject figureTO = EntityEditPart().getFigure();		
		
//Localizar uma figura que contenha texto.
		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)
				{
					//Para procurar uma propriedade específica na figura
					Object figWidth = foundTO[index].getProperty("width");
					if(figWidth != null)
						((GuiTestObject)foundTO[index]).click();
				}				
			}
		}
Exemplo 2: O exemplo a seguir mostra como usar a API getConnectors() para executar a operação clicar no conector que tenha a etiqueta "Associação"
//Listar os conectores
do pai do nó
		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();
						//Localizar uma figura que contenha algum texto.
						TestObject foundConn[] = figConnector.find(atDescendant("text", "association"));
						if(foundConn != null && foundConn.length > 0)						
						{
							//Se há apenas uma etiqueta com o texto "Associação"
							if(foundConn[0] != null && foundConn[0] instanceof GuiTestObject)
							{
								((GuiTestObject)foundConn[0]).click();
							}
						}

					}

				}
			}
		}

Exemplo 3: O exemplo a seguir ocupa uma lista com conectores descendentes à EditPart selecionada usando a API isConnector ()

//Presumindo a existência do "RootEditPart" no 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);
				}
			}
		}	
	}
	

Feedback