AsyncExec Debugging problem [message #207194] |
Sun, 07 March 2004 23:56 |
Eclipse User |
|
|
|
Hi all,
After such a long time trying to get setEditable() method work I got to
know that I can't call a UI thread from a NON UI thread.To solve this
problem I read that I am suppose to use asyncExec() method.
I am trying to call the following method from the messageDialog
class,after the creation of the editor that is from the javaeditor
example.The only thing is that I can't get any result from it and I ma not
sure why there is no result.Following is the code being called from
messageDialog class.
public void EditorState() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
IEditorPart part = page.getActiveEditor();
System.out.println(part+"part");
javaeditor = (JavaEditor)part;
System.out.println(javaeditor+"javaeditor");
viewer = (SourceViewer)javaeditor.getMySourceViewer();
System.out.println(viewer + "viewer");
control = viewer.getControl();
System.out.println(control +"control");
display = control.getDisplay();
System.out.println(display +"display");
if (viewer != null) {
display.asyncExec(new Runnable() {
public void run() {
try {
System.out.println(viewer + "viewer from run method");
viewer.getTextWidget().setEditable(false);
System.out.println("after seteditable call");
}
catch (Exception e) {
e.printStackTrace();
}
}
});
}
//else
}
public ISourceViewer getMySourceViewer() {
System.out.println("from getMySourceViewer");
return super.getSourceViewer();
}
The output from all the system.out.println are as follows:
com.example.NewEditor.editors.JavaEditor@7b5617part
com.example.NewEditor.editors.JavaEditor@7b5617javaeditor
from getMySourceViewer
org.eclipse.jface.text.source.SourceViewer@1286b10viewer
Canvas {}control
org.eclipse.swt.widgets.Display@945b95display
org.eclipse.jface.text.source.SourceViewer@1286b10viewer
the State of the editor doesn't change,the reason of my using seteditable
is because if the editor becomes readonly then i can enter whatever i need
to enter into it.
I would really apprecaite any help as this is the only error that is
delaying my project.
Thanks
Syed
|
|
|
Powered by
FUDForum. Page generated in 0.10435 seconds