Paths in Plugin [message #329761] |
Thu, 03 July 2008 03:30  |
Eclipse User |
|
|
|
Originally posted by: automatic.javalobby.org
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?
|
|
|
|
|
|
Re: Paths in Plugin [message #329787 is a reply to message #329761] |
Thu, 03 July 2008 14:28  |
Eclipse User |
|
|
|
Originally posted by: Jim.Cooper.sas.com
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?
|
|
|
Powered by
FUDForum. Page generated in 0.04484 seconds