Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » WorkbenchLabelProvider
WorkbenchLabelProvider [message #634076] Wed, 20 October 2010 13:11 Go to next message
Jens Piegsa is currently offline Jens PiegsaFriend
Messages: 16
Registered: July 2009
Location: Germany
Junior Member

Hi folks,

I'm currently doing my first steps in e4 application developement.
I associated the model part with my POJO class and everything
works quit well until now.
I want to use a JFace TreeViewer combined with a WorkbenchLabelProvider
that provides labels for adaptable objects.
The problem is that instanciating this LabelProvider fails with an
Exception:
....
Caused by: java.lang.IllegalStateException: Workbench has not been
created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
at
org.eclipse.ui.model.WorkbenchLabelProvider.<init>(WorkbenchLabelProvider.java:76)

My code:

@PostConstruct
public void buildUI() {
....
viewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
Platform.getAdapterManager().registerAdapters(adapterFactory ,MyNode.class);
viewer.setLabelProvider(new WorkbenchLabelProvider()); // fails
viewer.setContentProvider(new BaseWorkbenchContentProvider());
viewer.setInput(rootNode);
....
}


I will be happy about any suggestions, how to solve this issue the
e4-ish way. :-)


TIA,
Jens
Re: WorkbenchLabelProvider [message #634084 is a reply to message #634076] Wed, 20 October 2010 13:34 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
You can only use this stuff if you are running inside compat mode and
not in a native e4 application.

Tom

Am 20.10.10 15:11, schrieb Jens Piegsa:
> Hi folks,
>
> I'm currently doing my first steps in e4 application developement.
> I associated the model part with my POJO class and everything
> works quit well until now.
> I want to use a JFace TreeViewer combined with a WorkbenchLabelProvider
> that provides labels for adaptable objects.
> The problem is that instanciating this LabelProvider fails with an
> Exception:
> ...
> Caused by: java.lang.IllegalStateException: Workbench has not been
> created yet.
> at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:92)
> at
> org.eclipse.ui.model.WorkbenchLabelProvider.<init>(WorkbenchLabelProvider.java:76)
>
>
> My code:
>
> @PostConstruct
> public void buildUI() {
> ...
> viewer = new TreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
> Platform.getAdapterManager().registerAdapters(adapterFactory ,MyNode.class);
> viewer.setLabelProvider(new WorkbenchLabelProvider()); // fails
> viewer.setContentProvider(new BaseWorkbenchContentProvider());
> viewer.setInput(rootNode);
> ...
> }
>
>
> I will be happy about any suggestions, how to solve this issue the
> e4-ish way. :-)
>
>
> TIA,
> Jens
Re: WorkbenchLabelProvider [message #634107 is a reply to message #634084] Wed, 20 October 2010 14:18 Go to previous messageGo to next message
Jens Piegsa is currently offline Jens PiegsaFriend
Messages: 16
Registered: July 2009
Location: Germany
Junior Member

Hi Tom,

Thank you very much for your fast reply. Since I'm starting a new
project I would prefer to write a native e4 application rather than
using downward compatibility stuff.
Are there some rules of thumb which parts of the old RCP API should
be avoided?

To get the TreeViewer running do I have to use some kind of
adapter service? Is there a new LabelProvider that handles different
types of input objects?

Jens
Re: WorkbenchLabelProvider [message #634117 is a reply to message #634107] Wed, 20 October 2010 14:26 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 20.10.10 16:18, schrieb Jens Piegsa:
> Hi Tom,
>
> Thank you very much for your fast reply. Since I'm starting a new
> project I would prefer to write a native e4 application rather than
> using downward compatibility stuff.
> Are there some rules of thumb which parts of the old RCP API should
> be avoided?

All - no dependencies on org.eclipse.ui and friends should be avoided.
You can safely use org.eclipse.core stuff though.

>
> To get the TreeViewer running do I have to use some kind of
> adapter service? Is there a new LabelProvider that handles different
> types of input objects?


Not yet. You'd have to write your own until such features are extracted
from org.eclipse.ui and made available on their own

Tom
Re: WorkbenchLabelProvider [message #634122 is a reply to message #634117] Wed, 20 October 2010 14:57 Go to previous message
Jens Piegsa is currently offline Jens PiegsaFriend
Messages: 16
Registered: July 2009
Location: Germany
Junior Member

Tom,

I stumbled upon your tutorial with the MailDemo application.
I will study this now and come back with more questions later :-)

Jens
Previous Topic:e4 and JFace Wizards
Next Topic:XWT Section css
Goto Forum:
  


Current Time: Fri Apr 26 22:49:47 GMT 2024

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

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

Back to the top