Progress on do save [message #130895] |
Thu, 30 April 2009 09:53  |
Eclipse User |
|
|
|
Hi,
i created an edit with "save" and "save as..." possible. Now since the
"save" needs some time I actually expected a progress monitor to show up or
see the progress in the status line (status line is activated). There is no
progress shown at all, just a cursor indicating that it is busy.
Is this a bug (did a search, but could not find one related to it), or am I
doing something wrong?
You can implement the following mehtods is FooEditor of the Demo:
@Override
public void doSave( final IProgressMonitor monitor ) {
monitor.beginTask( "Saveing...", IProgressMonitor.UNKNOWN );
try {
Thread.sleep( 10000 );
} catch( InterruptedException exception ) {
// TODO Auto-generated catch block
exception.printStackTrace();
}
editor.setDirty( false );
treeeditor.setDirty( false );
monitor.done();
}
@Override
public void doSaveAs() {
try {
getSite().getWorkbenchWindow().run( false,
false,
new IRunnableWithProgress() {
public void run( IProgressMonitor monitor )
throws InvocationTargetException,
InterruptedException
{
doSave( monitor );
}
} );
} catch( InvocationTargetException exception ) {
// TODO Auto-generated catch block
exception.printStackTrace();
} catch( InterruptedException exception ) {
// TODO Auto-generated catch block
exception.printStackTrace();
}
}
|
|
|
|
Re: Progress on do save [message #131293 is a reply to message #130895] |
Tue, 05 May 2009 02:54   |
Eclipse User |
|
|
|
one would run the actual save operation in a job/background thread.
Think of your code in RCP, the UI would freeze if you run a long
running operation in the UI thread.
Markus Krüger wrote:
> Hi,
>
> i created an edit with "save" and "save as..." possible. Now since the
> "save" needs some time I actually expected a progress monitor to show up or
> see the progress in the status line (status line is activated). There is no
> progress shown at all, just a cursor indicating that it is busy.
>
> Is this a bug (did a search, but could not find one related to it), or am I
> doing something wrong?
>
> You can implement the following mehtods is FooEditor of the Demo:
> @Override
>
> public void doSave( final IProgressMonitor monitor ) {
>
> monitor.beginTask( "Saveing...", IProgressMonitor.UNKNOWN );
>
> try {
>
> Thread.sleep( 10000 );
>
> } catch( InterruptedException exception ) {
>
> // TODO Auto-generated catch block
>
> exception.printStackTrace();
>
> }
>
> editor.setDirty( false );
>
> treeeditor.setDirty( false );
>
> monitor.done();
>
> }
>
>
> @Override
>
> public void doSaveAs() {
>
> try {
>
> getSite().getWorkbenchWindow().run( false,
>
> false,
>
> new IRunnableWithProgress() {
>
>
> public void run( IProgressMonitor monitor )
>
> throws InvocationTargetException,
>
> InterruptedException
>
> {
>
> doSave( monitor );
>
> }
>
> } );
>
> } catch( InvocationTargetException exception ) {
>
> // TODO Auto-generated catch block
>
> exception.printStackTrace();
>
> } catch( InterruptedException exception ) {
>
> // TODO Auto-generated catch block
>
> exception.printStackTrace();
>
> }
>
> }
>
>
|
|
|
Re: Progress on do save [message #131389 is a reply to message #131293] |
Tue, 05 May 2009 05:27  |
Eclipse User |
|
|
|
Well, since the method "save" takes an IProgressMonitor as argument I thinkt
this is already a background thread, isn't it?
I could not find an example for an implementation of the method save.
"R
|
|
|
Powered by
FUDForum. Page generated in 0.03627 seconds