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 04:41 Go to next message
Michal Borek is currently offline Michal Borek
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 05:09 Go to previous message
Martin Klinke is currently offline Martin Klinke
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: Mon Sep 01 14:38:27 EDT 2014

Powered by FUDForum. Page generated in 0.01746 seconds