Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Label provider and icons from workspace
Label provider and icons from workspace [message #557851] Thu, 09 September 2010 08:41 Go to next message
Michal Borek is currently offline Michal BorekFriend
Messages: 25
Registered: August 2010
Junior Member
Hello,
I've got a problem creating LabelProvider that returs Image chosen by user (from his project workspace).

I've got element Icon with attribute "path".

I need project relative path, so I need to get project. I don't know how, because LabelProvider doesn't have IProject element. When I use

IEditorPart editorPart = WidgetsActivator.getDefault().getWorkbench().getActiveWorkbenchWindow()
		.getActivePage().getActiveEditor();
	IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput();
	IProject activeProject = input.getFile().getProject();


I've got null pointer exception when loading eclipse and there is active tab which using this label provider (but if tab is closed after eclipse start I open this editor, everything's fine).

Could you please tell me how to get project which is parent of file for which this editor is opened ?
Re: Label provider and icons from workspace [message #558121 is a reply to message #557851] Fri, 10 September 2010 09:09 Go to previous message
Martin Klinke is currently offline Martin KlinkeFriend
Messages: 80
Registered: July 2009
Member
Hi,

first of all you should check the resources you get from the API for
"null values". For example, if there is no active editor, than
editorPart is null and the access to editorPart.getEditorInput() will
throw the NPE. You need to take these situations into account in your
code. Think about what may happen and read the method documentation for
information about possible null return values.

HTH,
Martin Klinke
Previous Topic:Creating Excel sheet using RCP
Next Topic:JFace/SWT Show Multiple Cell Editors in a Table Column
Goto Forum:
  


Current Time: Wed Nov 06 11:48:19 GMT 2024

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

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

Back to the top