Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsProblem with Thread Understanding
https://www.eclipse.org/forums/index.php/mv/msg/284545/790029/#msg_790029
I got a problem with the understanding why some of my code doesnt work. I wrote some code to search a label in a shell :
private void init(){
labels=new ArrayList<Label>();
PlatformUI.createDisplay().syncExec(new Runnable() {
@Override
public void run(){
Control[] children = parentShell.getChildren();
for(Control control : children){
if (control instanceof Composite)
findLabels((Composite)control);
else if (control instanceof Label)
labels.add((Label)control);
}
boolean found = false;
for (Label label : labels){
if (label.getToolTipText()!= null && label.getToolTipText().equals(buttonTooltip)){
transButton = label;
found =true;
}
if ( !found )
throw new WidgetNotFoundException("Widget with Tooltip\" "+buttonTooltip+" \" not found! ");
}
}
});
}
My problem is, that I need the Shell, in which the label is to be searched. So that I can do:
Control[] children = parentShell.getChildren(); ( line 6 in the method)
So how do I get this Shell? I tried parentShell = botShell.widget() ( botShell is a SWTBotShell), but that doenst work. If I debug it and look what I get, the parenShell has the text "Wrong Thread". I must admit that I don´t know much about the Thread concept, so can someone plz explain to me why it doens´t work, and how it should be done.