Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Get a SHELL
Get a SHELL [message #480274] Fri, 14 August 2009 16:41 Go to next message
encom79  is currently offline encom79 Friend
Messages: 12
Registered: July 2009
Junior Member
Hi

How to get a shell in a plugin code. The following code is a earlyStartup
Plugin.
It crashes when it attempts to display an error.

public EarlyStartup()
{
if (...)
{

}
else
{
ErrorDialog.openError(Display.getDefault().getActiveShell(),
"", "", null);
}
}
Re: Get a SHELL [message #480353 is a reply to message #480274] Sat, 15 August 2009 20:11 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Encom79,

A stacktrace would be nice but before you post that, try to execute this code
in the user interface thread:

Display.getDefault().asyncExec(new Runnable(){run(){

ErrorDialog.openError(Display.getDefault().getActiveShell(), "", "", null)
}});

If this works then read the user interface thread information in the
workbench offline help to understand why this works:

Platform Plug-in Developer Guide > Programmer's Guide > Standard Widget
Toolkit > Threading issues

Best regards,

Wim Jongman

> Hi
>
> How to get a shell in a plugin code. The following code is a earlyStartup
> Plugin.
> It crashes when it attempts to display an error.
>
> public EarlyStartup()
> {
> if (...)
> {
>
> }
> else
> {
> ErrorDialog.openError(Display.getDefault().getActiveShell(),
> "", "", null);
> }
> }
Re: Get a SHELL [message #480538 is a reply to message #480353] Mon, 17 August 2009 14:53 Go to previous messageGo to next message
encom79  is currently offline encom79 Friend
Messages: 12
Registered: July 2009
Junior Member
No it does not :(

NullPointerException.

All that i need is to dislay Error/Warning popup in my plugin code. It
seems to be HELL to do that !
Re: Get a SHELL [message #480590 is a reply to message #480538] Mon, 17 August 2009 18:35 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Early startup plugins are executed in worker threads after the workbench window/workbench has been initialized.

You do have to post an asyncExec(*) ... as for getting a shell, what about PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShel l()

But I'll point out that ErrorDialog will take "null" as the parent shell argument. You could use that.

PW


Re: Get a SHELL [message #480763 is a reply to message #480590] Tue, 18 August 2009 12:41 Go to previous messageGo to next message
encom79  is currently offline encom79 Friend
Messages: 12
Registered: July 2009
Junior Member
No

PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null.

and passing null to ErrorDialog.openError(null, ...) throws an exception :/

It's a shame
Re: Get a SHELL [message #480798 is a reply to message #480763] Tue, 18 August 2009 14:12 Go to previous messageGo to next message
Fred is currently offline FredFriend
Messages: 11
Registered: July 2009
Junior Member
encom79 a écrit :
> No
>
> PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null.
>
> and passing null to ErrorDialog.openError(null, ...) throws an exception :/
>
> It's a shame
>
>
>
>

Are you allowed to display this error dialog once the main window has
been opened?

If yes, you could add a IWindowListener to the workbench like this

PlatformUI.getWorkbench().addWindowListener(new IWindowListener() {

public void windowActivated(IWorkbenchWindow window) {
}

public void windowClosed(IWorkbenchWindow window) {
}

public void windowDeactivated(IWorkbenchWindow window) {
}

public void windowOpened(IWorkbenchWindow window) {
// put ErrorDialog opening here ...
}

});

my 2 cts ...
Re: Get a SHELL [message #480828 is a reply to message #480763] Tue, 18 August 2009 15:41 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

encom79 wrote on Tue, 18 August 2009 08:41
No

PlatformUI.getWorkbench().getActiveWorkbenchWindow() returns null.

and passing null to ErrorDialog.openError(null, ...) throws an exception :/



It shouldn't (unless this is related to early startup as well). Please open a bug at https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=UI since the API for ErrorDialog.openError(*) specifically allows "null"

You can post the open bug number here.

PW


Re: Get a SHELL [message #480967 is a reply to message #480828] Wed, 19 August 2009 08:25 Go to previous messageGo to next message
encom79  is currently offline encom79 Friend
Messages: 12
Registered: July 2009
Junior Member
Bug#: 287028

Is there a Workaroud ? Could i use Swing JOptionPane instead ?
Re: Get a SHELL [message #481038 is a reply to message #480967] Wed, 19 August 2009 12:10 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

A reminder for all forum readers on how to write effective bug reports: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

For example, if we have an NPE include the stack trace in the bug report (then committers don't have to guess at what code path would cause that NPE).

If it's too long to read effectively when included in the body of the report (and we shouldn't generally include more than one), attach it as a plain text file.

PW


Previous Topic:com.ibm.icu.text.MessageFormat initialization maxing out CPU
Next Topic:Disabling Team Menus in CVS
Goto Forum:
  


Current Time: Mon Jan 20 00:35:42 GMT 2025

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

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

Back to the top