Home » Eclipse Projects » Remote Application Platform (RAP) » Closing a Dialog automatically
Closing a Dialog automatically [message #51839] |
Tue, 16 October 2007 12:24 |
Magnus Konze Messages: 35 Registered: July 2009 |
Member |
|
|
Hi!
I have a Dialog, which shows the progress of an action. Now i'm trying
to close the Dialog automatically, when the action has finished.
Here is a sketch of my code:
final ProgressDialog progressDialog = new ProgressDialog(...);
ExecutionEndedListener eel= new ExecutionEndedListener() {
public void executionEnded(ExecutionEndedEvent eee) {
progressDialog.close();
}
};
ExecuterThread et = new ExecuterThread(..., eel);
progressDialog.setExecuterThread(et);
progressDialog.open;
The ExecuterThread starts, after opening the Dialog. But when the
ExecutionEndedListener calls progressDialog.close(), i get the following
Exception:
Exception in thread "Thread-6" java.lang.IllegalStateException: No
context available outside of the request service lifecycle.
at org.eclipse.rwt.internal.service.ContextProvider.getContext( Unknown
Source)
at
org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(Unknown
Source)
at org.eclipse.rwt.SessionSingletonBase.getInstance(Unknown Source)
at
org.eclipse.jface.resource.JFaceResources$FontRegistryStore. getInstance(Unknown
Source)
at org.eclipse.jface.resource.JFaceResources.getFontRegistry(Un known
Source)
at org.eclipse.jface.window.Window.close(Unknown Source)
at org.eclipse.jface.dialogs.Dialog.close(Unknown Source)
at
de.tolina.common.action.rap.gui.ActionDetailComposite$3.exec utionEnded(ActionDetailComposite.java:126)
at de.tolina.common.progress.ExecuterThread.run(ExecuterThread. java:101)
I guessed, that the current Thread isn't allowed to close the
ProgressDialog (i'm not sure, if this is correct), so i tried this in
the executionEnded method:
progressDialog.getShell().getDisplay().syncExec(new Runnable() {
public void run() {
progressDialog.close();
}
});
In this case i get the following error in my browser:
Could not evaluate javascript response:
TypeError: t has no properties
followed by a _very_ long line of javascript.
Any hints, what could be the problem?
Regards Magnus
|
|
|
Re: Closing a Dialog automatically [message #51917 is a reply to message #51839] |
Tue, 16 October 2007 14:42 |
Stefan Messages: 316 Registered: July 2009 |
Senior Member |
|
|
Hi Magnus,
to trigger ui updates from a non-ui-thread you can use the UICallback class.
Call UICallBack#activate(String) with a unique identifier to enable this
feature.
There have been previous posts on this topic which you can be found by
searching for "UICallBack".
Hope this helps,
Stefan.
Btw.: However, the second JS-Error should never ocurr in my opinion so you
can file a bug, if this is reproducable.
"Magnus Konze" <bodomchild@web.de> schrieb im Newsbeitrag
news:ff2ahd$7ne$1@build.eclipse.org...
> Hi!
> I have a Dialog, which shows the progress of an action. Now i'm trying
> to close the Dialog automatically, when the action has finished.
> Here is a sketch of my code:
>
> final ProgressDialog progressDialog = new ProgressDialog(...);
> ExecutionEndedListener eel= new ExecutionEndedListener() {
> public void executionEnded(ExecutionEndedEvent eee) {
> progressDialog.close();
> }
> };
> ExecuterThread et = new ExecuterThread(..., eel);
> progressDialog.setExecuterThread(et);
> progressDialog.open;
>
>
> The ExecuterThread starts, after opening the Dialog. But when the
> ExecutionEndedListener calls progressDialog.close(), i get the following
> Exception:
>
> Exception in thread "Thread-6" java.lang.IllegalStateException: No context
> available outside of the request service lifecycle.
> at org.eclipse.rwt.internal.service.ContextProvider.getContext( Unknown
> Source)
> at org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(Unknown
> Source)
> at org.eclipse.rwt.SessionSingletonBase.getInstance(Unknown Source)
> at
> org.eclipse.jface.resource.JFaceResources$FontRegistryStore. getInstance(Unknown
> Source)
> at org.eclipse.jface.resource.JFaceResources.getFontRegistry(Un known
> Source)
> at org.eclipse.jface.window.Window.close(Unknown Source)
> at org.eclipse.jface.dialogs.Dialog.close(Unknown Source)
> at
> de.tolina.common.action.rap.gui.ActionDetailComposite$3.exec utionEnded(ActionDetailComposite.java:126)
> at de.tolina.common.progress.ExecuterThread.run(ExecuterThread. java:101)
>
>
>
> I guessed, that the current Thread isn't allowed to close the
> ProgressDialog (i'm not sure, if this is correct), so i tried this in the
> executionEnded method:
>
> progressDialog.getShell().getDisplay().syncExec(new Runnable() {
> public void run() {
> progressDialog.close();
> }
> });
>
> In this case i get the following error in my browser:
>
> Could not evaluate javascript response:
>
> TypeError: t has no properties
> followed by a _very_ long line of javascript.
>
> Any hints, what could be the problem?
> Regards Magnus
|
|
| |
Re: Closing a Dialog automatically [message #52573 is a reply to message #51839] |
Wed, 17 October 2007 13:25 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
wouldn't it be easier to use the Job API of equinox? The workbench demo
shows how to use it in the class
org.eclipse.rap.demo.actions.JobActionWithDialog.
But anyway I thing Stefan is right the javascript should not be corrupted
which means that this is probably a bug.
Where do you get the ProgressDialog from? Is this an own one that extends a
jface dialog with blockOnOpen? If so there may be some problems with the
open/close implementation that blocks the execution of the code that opens
the dialog. In fact this is a very ugly mechanism behind the scenes. Even if
the javascript line is very long, it may contain some additional
information, so don't hesitate to post it...
Ciao
Frank
"Magnus Konze" <bodomchild@web.de> schrieb im Newsbeitrag
news:ff2ahd$7ne$1@build.eclipse.org...
> Hi!
> I have a Dialog, which shows the progress of an action. Now i'm trying
> to close the Dialog automatically, when the action has finished.
> Here is a sketch of my code:
>
> final ProgressDialog progressDialog = new ProgressDialog(...);
> ExecutionEndedListener eel= new ExecutionEndedListener() {
> public void executionEnded(ExecutionEndedEvent eee) {
> progressDialog.close();
> }
> };
> ExecuterThread et = new ExecuterThread(..., eel);
> progressDialog.setExecuterThread(et);
> progressDialog.open;
>
>
> The ExecuterThread starts, after opening the Dialog. But when the
> ExecutionEndedListener calls progressDialog.close(), i get the following
> Exception:
>
> Exception in thread "Thread-6" java.lang.IllegalStateException: No context
> available outside of the request service lifecycle.
> at org.eclipse.rwt.internal.service.ContextProvider.getContext( Unknown
> Source)
> at org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(Unknown
> Source)
> at org.eclipse.rwt.SessionSingletonBase.getInstance(Unknown Source)
> at
> org.eclipse.jface.resource.JFaceResources$FontRegistryStore. getInstance(Unknown
> Source)
> at org.eclipse.jface.resource.JFaceResources.getFontRegistry(Un known
> Source)
> at org.eclipse.jface.window.Window.close(Unknown Source)
> at org.eclipse.jface.dialogs.Dialog.close(Unknown Source)
> at
> de.tolina.common.action.rap.gui.ActionDetailComposite$3.exec utionEnded(ActionDetailComposite.java:126)
> at de.tolina.common.progress.ExecuterThread.run(ExecuterThread. java:101)
>
>
>
> I guessed, that the current Thread isn't allowed to close the
> ProgressDialog (i'm not sure, if this is correct), so i tried this in the
> executionEnded method:
>
> progressDialog.getShell().getDisplay().syncExec(new Runnable() {
> public void run() {
> progressDialog.close();
> }
> });
>
> In this case i get the following error in my browser:
>
> Could not evaluate javascript response:
>
> TypeError: t has no properties
> followed by a _very_ long line of javascript.
>
> Any hints, what could be the problem?
> Regards Magnus
|
|
|
Re: Closing a Dialog automatically [message #53353 is a reply to message #52573] |
Thu, 18 October 2007 11:48 |
Magnus Konze Messages: 35 Registered: July 2009 |
Member |
|
|
Hi again!
I didn't know about the Job API, thanks for the advice. I'm porting an
old Swing application and this could be a great alternative for our old
ProgressDialog.
So yes, the ProgressDialog is selfmade. It extends
org.eclipse.jface.dialogs.Dialog and so far only contains a ProgressBar
and a Label for Messages.
Here is a bigger excerpt of my code:
public class ProgressDialog extends org.eclipse.jface.dialogs.Dialog {
public void setExecuterThread(ExecuterThread executerThread) {
_executerThread = executerThread;
}
protected Control createDialogArea(final Composite parent) {
...
_executerThread.start();
}
}
Here is the code, which uses the ProgressDialog:
UICallBack.activate(id);
final ProgressDialog progressDialog = new ProgressDialog(...);
ExecutionEndedListener eel= new ExecutionEndedListener() {
public void executionEnded(ExecutionEndedEvent eee) {
progressDialog.getShell().getDisplay().syncExec(new Runnable() {
public void run() {
progressDialog.close();
}
});
}
};
ExecuterThread executerThread = new ExecuterThread(..., eel);
progressDialog.setExecuterThread(executerThread);
progressDialog.open();
UICallBack.deactivate(id);
The idea is, when the ExecutionThread finishes the ExecutionListener is
called, which should close the Dialog.
Here is the complete error, which appears in the Browser:
Could not evaluate javascript response:
TypeError: t has no properties
org.eclipse.swt.EventUtil.suspendEventHandling();var wm =
org.eclipse.swt.WidgetManager.getInstance();var t = wm.findWidgetById(
"w195" );t.setDefaultButton( null );wm.dispose( "w204"
);wm.registerResetHandler( -2112204799, function( w )
{w.removeEventListener( "focusin", org.eclipse.swt.EventUtil.focusGained
);w.removeEventListener( "focusout", org.eclipse.swt.EventUtil.focusLost
);w.resetContextMenu();w.removeEventListener( "contextmenu",
org.eclipse.swt.MenuUtil.contextMenu );wm.setToolTip( w
);w.resetFont();w.resetBackgroundColor();w.resetTextColor(); w.removeEventListener(
"appear", org.eclipse.swt.WidgetManager._onAppearSetForeground
);w.setEnabled( true );w.setVisibility( true
);w.resetTabIndex();w.resetZIndex();w.resetClipWidth();w.res etClipHeight();w.setSpace(
0, 0, 0, 0 );w.removeState( "rwt_BORDER" );w.removeState( "rwt_FLAT" );}
);wm.dispose( "w203" );wm.registerResetHandler( -143793474, function( w
)
{w.resetHorizontalChildrenAlign();w.getLabelObject().resetTe xtAlign();org.eclipse.swt.LabelUtil.setText(
w, null );org.eclipse.swt.LabelUtil.setImage( w, null
);w.removeEventListener( "focusin",
org.eclipse.swt.EventUtil.focusGained );w.removeEventListener(
"focusout", org.eclipse.swt.EventUtil.focusLost
);w.resetContextMenu();w.removeEventListener( "contextmenu",
org.eclipse.swt.MenuUtil.contextMenu );wm.setToolTip( w
);w.resetFont();w.resetBackgroundColor();w.resetTextColor(); w.removeEventListener(
"appear", org.eclipse.swt.WidgetManager._onAppearSetForeground
);w.setEnabled( true );w.setVisibility( true
);w.resetTabIndex();w.resetZIndex();w.resetClipWidth();w.res etClipHeight();w.setSpace(
0, 0, 0, 0 );w.removeState( "rwt_BORDER" );w.removeState( "rwt_FLAT" );}
);wm.dispose( "w202" );wm.dispose( "w201" );wm.dispose( "w200"
);wm.dispose( "w199" );wm.dispose( "w198" );wm.dispose( "w197"
);wm.dispose( "w196" );var w = wm.findWidgetById( "w195"
);w.setVisibility( false );wm.dispose( "w195" );var w =
wm.findWidgetById( "w3" );w.setActive( true );var w = wm.findWidgetById(
"w4" );w.setSpace( 2, 953, 21, 20
);org.eclipse.swt.WidgetManager.getInstance().focus( "w17"
);qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();org.eclipse.swt.EventUtil.suspen dEventHandling();var
t = wm.findWidgetById( "w195" );t.setDefaultButton( null );wm.dispose(
"w204" );wm.dispose( "w203" );wm.dispose( "w202" );wm.dispose( "w201"
);wm.dispose( "w200" );wm.dispose( "w199" );wm.dispose( "w198"
);wm.dispose( "w197" );wm.dispose( "w196" );var w = wm.findWidgetById(
"w195" );w.setVisibility( false );wm.dispose( "w195" );var w =
wm.findWidgetById( "w3" );w.setActive( true
);org.eclipse.swt.TreeItemUtil.createTreeItem( "w207",
wm.findWidgetById( "w58" ), wm.findWidgetById( "w58" ) );var w =
wm.findWidgetById( "w207" );w.setImages( [
" /de/tolina/common/action/gui/32x22_action_ok_user_disabled.g if " ]
);w.setTexts( [ "Aktion 2" ] );w.setBackground( "#ffffff"
);w.setSelection( true, true
);org.eclipse.swt.TreeItemUtil.createTreeItem( "w208",
wm.findWidgetById( "w58" ), wm.findWidgetById( "w58" ) );var w =
wm.findWidgetById( "w208" );w.setImages( [
"/de/tolina/common/action/gui/32x22_actionFolder.gif" ] );w.setTexts( [
"Container" ] );w.setBackground( "#ffffff"
);org.eclipse.swt.TreeItemUtil.createTreeItem( "w209", w,
wm.findWidgetById( "w58" ) );var w = wm.findWidgetById( "w209"
);w.setImages( [null ] );w.setTexts( [ "" ] );w.setBackground( "#ffffff"
);org.eclipse.swt.WidgetManager.getInstance().focus( "w17"
);qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();
Regards
Magnus
Frank Appel schrieb:
> Hi,
>
> wouldn't it be easier to use the Job API of equinox? The workbench demo
> shows how to use it in the class
> org.eclipse.rap.demo.actions.JobActionWithDialog.
>
> But anyway I thing Stefan is right the javascript should not be corrupted
> which means that this is probably a bug.
>
> Where do you get the ProgressDialog from? Is this an own one that extends a
> jface dialog with blockOnOpen? If so there may be some problems with the
> open/close implementation that blocks the execution of the code that opens
> the dialog. In fact this is a very ugly mechanism behind the scenes. Even if
> the javascript line is very long, it may contain some additional
> information, so don't hesitate to post it...
>
>
> Ciao
> Frank
|
|
|
Re: Closing a Dialog automatically [message #53404 is a reply to message #53353] |
Thu, 18 October 2007 13:40 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I just fixed (hopefully) a problem with multiple dialogs #206322. This bug
had the same symptoms that you are describing. Maybe the fix solves your
problem too.
Ciao
Frank
"Magnus Konze" <bodomchild@web.de> schrieb im Newsbeitrag
news:ff7h5s$q6n$1@build.eclipse.org...
> Hi again!
> I didn't know about the Job API, thanks for the advice. I'm porting an old
> Swing application and this could be a great alternative for our old
> ProgressDialog.
> So yes, the ProgressDialog is selfmade. It extends
> org.eclipse.jface.dialogs.Dialog and so far only contains a ProgressBar
> and a Label for Messages.
>
> Here is a bigger excerpt of my code:
>
> public class ProgressDialog extends org.eclipse.jface.dialogs.Dialog {
>
> public void setExecuterThread(ExecuterThread executerThread) {
> _executerThread = executerThread;
> }
>
> protected Control createDialogArea(final Composite parent) {
> ...
> _executerThread.start();
> }
> }
>
> Here is the code, which uses the ProgressDialog:
>
> UICallBack.activate(id);
> final ProgressDialog progressDialog = new ProgressDialog(...);
> ExecutionEndedListener eel= new ExecutionEndedListener() {
> public void executionEnded(ExecutionEndedEvent eee) {
> progressDialog.getShell().getDisplay().syncExec(new Runnable() {
> public void run() {
> progressDialog.close();
> }
> });
> }
> };
> ExecuterThread executerThread = new ExecuterThread(..., eel);
> progressDialog.setExecuterThread(executerThread);
> progressDialog.open();
> UICallBack.deactivate(id);
>
> The idea is, when the ExecutionThread finishes the ExecutionListener is
> called, which should close the Dialog.
>
> Here is the complete error, which appears in the Browser:
>
> Could not evaluate javascript response:
>
> TypeError: t has no properties
>
> org.eclipse.swt.EventUtil.suspendEventHandling();var wm =
> org.eclipse.swt.WidgetManager.getInstance();var t = wm.findWidgetById(
> "w195" );t.setDefaultButton( null );wm.dispose(
> "w204" );wm.registerResetHandler( -2112204799, function( w )
> {w.removeEventListener( "focusin",
> org.eclipse.swt.EventUtil.focusGained );w.removeEventListener( "focusout",
> org.eclipse.swt.EventUtil.focusLost );w.resetContextMenu();w.removeEventListener(
> "contextmenu", org.eclipse.swt.MenuUtil.contextMenu );wm.setToolTip(
> w );w.resetFont();w.resetBackgroundColor();w.resetTextColor(); w.removeEventListener(
> "appear",
> org.eclipse.swt.WidgetManager._onAppearSetForeground );w.setEnabled(
> true );w.setVisibility(
> true );w.resetTabIndex();w.resetZIndex();w.resetClipWidth();w.res etClipHeight();w.setSpace(
> 0, 0, 0, 0 );w.removeState( "rwt_BORDER" );w.removeState(
> "rwt_FLAT" );} );wm.dispose( "w203" );wm.registerResetHandler( -143793474,
> function( w )
> {w.resetHorizontalChildrenAlign();w.getLabelObject().resetTe xtAlign();org.eclipse.swt.LabelUtil.setText(
> w, null );org.eclipse.swt.LabelUtil.setImage( w,
> null );w.removeEventListener( "focusin",
> org.eclipse.swt.EventUtil.focusGained );w.removeEventListener( "focusout",
> org.eclipse.swt.EventUtil.focusLost );w.resetContextMenu();w.removeEventListener(
> "contextmenu", org.eclipse.swt.MenuUtil.contextMenu );wm.setToolTip(
> w );w.resetFont();w.resetBackgroundColor();w.resetTextColor(); w.removeEventListener(
> "appear",
> org.eclipse.swt.WidgetManager._onAppearSetForeground );w.setEnabled(
> true );w.setVisibility(
> true );w.resetTabIndex();w.resetZIndex();w.resetClipWidth();w.res etClipHeight();w.setSpace(
> 0, 0, 0, 0 );w.removeState( "rwt_BORDER" );w.removeState(
> "rwt_FLAT" );} );wm.dispose( "w202" );wm.dispose( "w201" );wm.dispose(
> "w200" );wm.dispose( "w199" );wm.dispose( "w198" );wm.dispose(
> "w197" );wm.dispose( "w196" );var w = wm.findWidgetById(
> "w195" );w.setVisibility( false );wm.dispose( "w195" );var w =
> wm.findWidgetById( "w3" );w.setActive( true );var w = wm.findWidgetById(
> "w4" );w.setSpace( 2, 953, 21,
> 20 );org.eclipse.swt.WidgetManager.getInstance().focus(
> "w17" );qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();org.eclipse.swt.EventUtil.suspen dEventHandling();var
> t = wm.findWidgetById( "w195" );t.setDefaultButton( null );wm.dispose(
> "w204" );wm.dispose( "w203" );wm.dispose( "w202" );wm.dispose(
> "w201" );wm.dispose( "w200" );wm.dispose( "w199" );wm.dispose(
> "w198" );wm.dispose( "w197" );wm.dispose( "w196" );var w =
> wm.findWidgetById( "w195" );w.setVisibility( false );wm.dispose(
> "w195" );var w = wm.findWidgetById( "w3" );w.setActive(
> true );org.eclipse.swt.TreeItemUtil.createTreeItem( "w207",
> wm.findWidgetById( "w58" ), wm.findWidgetById( "w58" ) );var w =
> wm.findWidgetById( "w207" );w.setImages( [
> " /de/tolina/common/action/gui/32x22_action_ok_user_disabled.g if " ] );w.setTexts(
> [ "Aktion 2" ] );w.setBackground( "#ffffff" );w.setSelection( true,
> true );org.eclipse.swt.TreeItemUtil.createTreeItem( "w208",
> wm.findWidgetById( "w58" ), wm.findWidgetById( "w58" ) );var w =
> wm.findWidgetById( "w208" );w.setImages( [
> "/de/tolina/common/action/gui/32x22_actionFolder.gif" ] );w.setTexts( [
> "Container" ] );w.setBackground(
> "#ffffff" );org.eclipse.swt.TreeItemUtil.createTreeItem( "w209", w,
> wm.findWidgetById( "w58" ) );var w = wm.findWidgetById(
> "w209" );w.setImages( [null ] );w.setTexts( [ "" ] );w.setBackground(
> "#ffffff" );org.eclipse.swt.WidgetManager.getInstance().focus(
> "w17" );qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();
>
> Regards
> Magnus
>
>
> Frank Appel schrieb:
>> Hi,
>>
>> wouldn't it be easier to use the Job API of equinox? The workbench demo
>> shows how to use it in the class
>> org.eclipse.rap.demo.actions.JobActionWithDialog.
>>
>> But anyway I thing Stefan is right the javascript should not be corrupted
>> which means that this is probably a bug.
>>
>> Where do you get the ProgressDialog from? Is this an own one that extends
>> a jface dialog with blockOnOpen? If so there may be some problems with
>> the open/close implementation that blocks the execution of the code that
>> opens the dialog. In fact this is a very ugly mechanism behind the
>> scenes. Even if the javascript line is very long, it may contain some
>> additional information, so don't hesitate to post it...
>>
>>
>> Ciao
>> Frank
|
|
| |
Re: Closing a Dialog automatically [message #55082 is a reply to message #55054] |
Wed, 24 October 2007 11:29 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
bugfixes can't be applied to existing targets, without patching the target.
But this is done only in rare cases. As you have done, we verify against CVS
that problems are solved. We will soon start to provide service releases
that contain such bugfixes. So you will simply have to switch your target
installation to the latest version.
Ciao
Frank
"Magnus Konze" <bodomchild@web.de> schrieb im Newsbeitrag
news:ffn9p1$hr3$1@build.eclipse.org...
> Hi!
> Sorry, but i how can i apply the bugfix to the target platform? So far i
> only worked with the milestones or the 1.0 release.
>
> But i already created a simple version of my application (only one Button,
> which opens a Dialog; Dialog closes automatically after some seconds) in a
> new workspace with the current target platform from the CVS and it worked
> fine. So it seems, that your bugfix solved my problem.
>
> It would be nice, if someone could explain how to apply bugfixes!
>
> Thank you very much!
> Magnus
>
>
> Frank Appel schrieb:
>> Hi,
>>
>> I just fixed (hopefully) a problem with multiple dialogs #206322. This
>> bug had the same symptoms that you are describing. Maybe the fix solves
>> your problem too.
>>
>> Ciao
>> Frank
|
|
|
Goto Forum:
Current Time: Tue Sep 17 16:56:06 GMT 2024
Powered by FUDForum. Page generated in 0.04407 seconds
|