Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » API to find if progress dialog is displayed ?
API to find if progress dialog is displayed ? [message #1712218] Thu, 22 October 2015 07:51 Go to next message
Gidi Gal is currently offline Gidi GalFriend
Messages: 42
Registered: July 2009
Member
Hello to the forum members,

I'm looking for an API that will return true\false whether Eclipse is displaying progress dialog. I'll explain why I'm looking for such API:

My plugins are embedding ActiveX code that runs MFC code. The MFC code launches a modal dialog box when progress dialog is displayed in Eclipse. Once the progress dialog box is closed the MFC dialog box is destroyed and Eclipse UI is disabled - any click on Eclipse window will only yield beep sound. After trying unsuccessfully to hack into the Window messages being sent to the MFC dialog and disable the ones that destroy the dialog box, I'm trying a different angle. I have interface from the MFC code to Eclipse. I'm thinking of postponing the launch of the modal MFC dialog to after the progress dialog is closed. Obviously, this is not a perfect solution - another progress dialog may pop-up later, but currently I don't have other solution for this issue. For that behavior I need to know if the progress dialog is displayed.

Many thanks for your help,
Gidi
Re: API to find if progress dialog is displayed ? [message #1712278 is a reply to message #1712218] Thu, 22 October 2015 15:30 Go to previous messageGo to next message
Eclipse UserFriend
There aren't any APIs that will help you. Plus any code could popup a dialog, let alone a progress dialog, and probably have the same effect.

I think the best you can do is to call Display.getShells() and check to see if any have a *MODAL style bit set.

Brian.
Re: API to find if progress dialog is displayed ? [message #1712305 is a reply to message #1712278] Thu, 22 October 2015 18:17 Go to previous messageGo to next message
Gidi Gal is currently offline Gidi GalFriend
Messages: 42
Registered: July 2009
Member
Hi Brian,

Thanks for your reply. I tried running this code while the progress dialog was running:
boolean hasModal = false;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Shell[] shells = window.getShell().getDisplay().getShells();
for (Shell shell: shells) {
out.println(shell.getText());
final int style = shell.getStyle();
final int applicationModal = (style & SWT.APPLICATION_MODAL);
final int primaryModal = (style & SWT.PRIMARY_MODAL);
final int systemModal = (style & SWT.SYSTEM_MODAL);
if ( (applicationModal > 0) || (primaryModal > 0) || (systemModal > 0)) {
hasModal = true;
break;
}
}
if (hasModal) {
out.println("MODAL !!!");
}
else {
out.println("NOT MODAL !!!");
}

The out variable was connected to a console view. I saw the title of the progress dialog, so I'm sure it was tested by this code. However, the result was not modal.
Is this test incorrect ?
I'll be grateful for any thoughts\ideas.

Best regards,
Gidi
Re: API to find if progress dialog is displayed ? [message #1712306 is a reply to message #1712305] Thu, 22 October 2015 18:36 Go to previous messageGo to next message
Gidi Gal is currently offline Gidi GalFriend
Messages: 42
Registered: July 2009
Member
The value of style in the relevant progress dialog is 33557616, maybe it will help.
Re: API to find if progress dialog is displayed ? [message #1712328 is a reply to message #1712305] Fri, 23 October 2015 03:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Gidi,

Keep in mind that shells can form a hierarchy:
org.eclipse.swt.widgets.Shell.getShells(). So one question to consider:
which shell is the parent shell of your PMF dialog? If it's the
progress dialog's shell, it will be destroyed when the progress dialog
is destroyed. Whether a progress dialog ever shows is controlled by
Window -> Preferences -> General -> Always run in background so even if
you wait, it's possible a progress dialog will show up after your dialog
shows up (though in that case your dialog shell can't be a child
shell). Probably you should focus first on determining which shell is
the parent of your dialog, and if you need code like what you show
below, it should be recursive to visit all shells. Keep in mind too
that you can do Window -> New Window so there can be more than one
top-level shell, each containing a workbench window.


On 22/10/2015 8:17 PM, Gidi Gal wrote:
> Hi Brian,
>
> Thanks for your reply. I tried running this code while the progress
> dialog was running:
> boolean hasModal = false;
> IWorkbenchWindow window =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> Shell[] shells = window.getShell().getDisplay().getShells();
> for (Shell shell: shells) {
> out.println(shell.getText());
> final int style = shell.getStyle();
> final int applicationModal = (style & SWT.APPLICATION_MODAL);
> final int primaryModal = (style & SWT.PRIMARY_MODAL);
> final int systemModal = (style & SWT.SYSTEM_MODAL);
> if ( (applicationModal > 0) || (primaryModal > 0) || (systemModal
> > 0)) { hasModal = true;
> break;
> }
> }
> if (hasModal) {
> out.println("MODAL !!!");
> }
> else {
> out.println("NOT MODAL !!!");
> }
>
> The out variable was connected to a console view. I saw the title of
> the progress dialog, so I'm sure it was tested by this code. However,
> the result was not modal.
> Is this test incorrect ?
> I'll be grateful for any thoughts\ideas.
>
> Best regards,
> Gidi
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: API to find if progress dialog is displayed ? [message #1721603 is a reply to message #1712328] Thu, 28 January 2016 15:20 Go to previous message
Gidi Gal is currently offline Gidi GalFriend
Messages: 42
Registered: July 2009
Member
Hi Ed,

Thanks for your help. I decided in the end to pass the request to show the dialog to Eclipse, so the dialog is created in Eclipse and not by MFC code. It solved this issue.

Best regards,
Gidi
Previous Topic:How to configure testng with excel
Next Topic:Platform extension point reference documentation
Goto Forum:
  


Current Time: Sat Apr 20 01:52:30 GMT 2024

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

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

Back to the top