- Code: Select all
public String connectends() {
String restate="";
Tree tree = getTree();
if (tree != null)
{
final Element element = getSelectedElement(tree);
if (element != null)
{
try {element.accept(visitor);} catch (Exception e) {e.printStackTrace();}
}
ArrayList<Element> all=new ArrayList<>();
all.addAll(element.getOwnedElement());
for (int i = 0; i < all.size(); i++) {Element current = all.get(i);try{current.accept(visitor);}catch (Exception e){e.printStackTrace();}all.addAll(current.getOwnedElement());}
ArrayList<String> list=new ArrayList<String>();
Element tests=all.get(0);
int flag=0;
for (int index=0;index < all.size(); index++) {
tests=all.get(index);
String teststring=tests.getHumanName();
String tester="";
if (teststring.startsWith("Connector")&&flag==0){
tester=String.valueOf(tests.getOwner().getHumanName());//
list.add(teststring+": "+tester+"\n ");
flag=1;
}
}
for (String strad:list) {
restate=restate.concat(strad+"\n");
}
}
return restate;
}
Currently, just for reasons of making the trial runs more readable, only tries for the first connector (thus, the flag). Ideally, would be an element function on the connector itself, so it would just be swapping out the "tester=String.valueOf(tests.getOwner().getHumanName());" for something else, but not holding my breath on that.