[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform] Re: Paths in Plugin

The best way I've found for use in a plug-in (or any Jar, for that matter), if the images are inside, is to use something like this:

ImageIcon folderIcon = new ImageIcon(getClass().getResource("/images/icons/folder.png"));

Adjust as needed to get an Image object rather than an ImageIcon.

Alwin Schmitz wrote:
Hello,
I´m new to the plugin development.
Now I have the following problem.

I want to call from an action a CheckedTreeSelectionDialog.
For this I use the following code:


public void run(IAction action) { Shell shell = new Shell(); CheckedTreeSelectionDialog treeDialog = new CheckedTreeSelectionDialog(shell, new TreeLabelProvider(), new TreeContentProvider()); treeDialog.setInput(ContentProvider.getInitalInput()); int returnV =treeDialog.open(); }

The TreeLabelProvider has the following constructor:

 // Images for tree nodes
	  private Image file;

	  private Image dir;



	  /**
	   * Constructs a FileTreeLabelProvider
	   */
	  public TreeLabelProvider() {
	    // Create the list to hold the listeners
	    listeners = new ArrayList();

	    // Create the images
	    try {
	    	

	    	
	      file = new Image(null, new FileInputStream("icons/full/obj16/file_obj.gif"));
	      dir = new Image(null, new FileInputStream("icons/full/obj16/fldr_obj.gif"));
	    } catch (FileNotFoundException e) {
	      e.printStackTrace();
	    }
	  }

In this constructor I use relative paths. But with these paths I get a file not found Exception
How can I get the absolute Path at this point in my program code?