Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » IProgressMonitor
IProgressMonitor [message #325859] Fri, 29 February 2008 11:25 Go to next message
Eclipse UserFriend
Originally posted by: invone2000.yahoo.de

And a new question...
In my application (a working plugin) I changed something in an open editor.
I can cast this opened editor to EditorPart and want to use the
doSave(IprogressMonitor monitor) method
I did the following:

IProgressMonitor monitor = null;
try {
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask("Save content...", 1);
((EditorPart) editorPart).doSave(monitor);
monitor.worked(1);
} finally {
monitor.done();
}

But I get the following exception:
Exception in thread "main" org.eclipse.swt.SWTException: Unspecified error

And I found out the following:
org.eclipse.swt.SWTException: Invalid thread access

Now what? Am I using an existing IPgrogressMonitor? If yes - were do I get
it?

Thanx before
R4ID
Re: IProgressMonitor [message #325861 is a reply to message #325859] Fri, 29 February 2008 11:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

R4ID,

You can't do GUI operations on a background thread. Have a look at
Display.asyncExec. You might find ProgressMonitorDialog useful. When
you get exceptions and want to ask questions about them, it's good to
get the stack trace from the Error Log view and include that in your
question.


R4ID wrote:
> And a new question...
> In my application (a working plugin) I changed something in an open
> editor.
> I can cast this opened editor to EditorPart and want to use the
> doSave(IprogressMonitor monitor) method
> I did the following:
>
> IProgressMonitor monitor = null;
> try {
> if (monitor == null)
> monitor = new NullProgressMonitor();
> monitor.beginTask("Save content...", 1);
> ((EditorPart) editorPart).doSave(monitor);
> monitor.worked(1);
> } finally {
> monitor.done();
> }
>
> But I get the following exception:
> Exception in thread "main" org.eclipse.swt.SWTException: Unspecified
> error
>
> And I found out the following:
> org.eclipse.swt.SWTException: Invalid thread access
>
> Now what? Am I using an existing IPgrogressMonitor? If yes - were do I
> get it?
>
> Thanx before
> R4ID
>
Re: IProgressMonitor [message #325864 is a reply to message #325861] Fri, 29 February 2008 12:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: invone2000.yahoo.de

Okay - thanx for fast reply...
I extended my app in the following manner:

1.)
public class SaveEditorJob implements IRunnableWithProgress {...}
2.)
SaveEditorJob job = new SaveEditorJob((EditorPart) editor);
3.)
ProgressMonitorDialog dlg = new ProgressMonitorDialog(activeShell);
dlg.run(false, false, job);

Beng - active Shell???
I tried the following:
IWorkbench workbench = PlatformUI.getWorkbench();
Shell[] shells = workbench.getDisplay().getShells();

=> Invalid Thread access (SWT thingy)

Then I tried:
Shell activeShell = Display.getDefault().getActiveShell();
=> Invalid Thread access (SWT thingy)

Now what?
Re: IProgressMonitor [message #325867 is a reply to message #325864] Fri, 29 February 2008 12:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

R4ID,

I don't think you've read about asycExec yet. It still sounds like you
are running this on a background thread.


R4ID wrote:
> Okay - thanx for fast reply...
> I extended my app in the following manner:
>
> 1.)
> public class SaveEditorJob implements IRunnableWithProgress {...}
> 2.)
> SaveEditorJob job = new SaveEditorJob((EditorPart) editor);
> 3.)
> ProgressMonitorDialog dlg = new ProgressMonitorDialog(activeShell);
> dlg.run(false, false, job);
>
> Beng - active Shell???
> I tried the following:
> IWorkbench workbench = PlatformUI.getWorkbench();
> Shell[] shells = workbench.getDisplay().getShells();
>
> => Invalid Thread access (SWT thingy)
>
> Then I tried:
> Shell activeShell = Display.getDefault().getActiveShell();
> => Invalid Thread access (SWT thingy)
>
> Now what?
>
>
>
Re: IProgressMonitor [message #325871 is a reply to message #325867] Fri, 29 February 2008 13:16 Go to previous message
Eclipse UserFriend
Originally posted by: invone2000.yahoo.de

...
mea maxima culpa...

You said it - I googled and found the other solution. But now I make a new
runnable annonymous class which will force the doSave.
I use the NullProgressMonitor in this one
and then I pass the runnable to the Display.getDefault().asyncExe(job) =>
and it works...
Fine - thanx ;)
R4ID
Previous Topic:Jobs API / Workspace.run() and Display.syncExec()
Next Topic:How to contribute to Eclipse's Properties view?
Goto Forum:
  


Current Time: Sun Jun 30 14:27:48 GMT 2024

Powered by FUDForum. Page generated in 0.03195 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top