Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Paths in Plugin
Paths in Plugin [message #329761] Thu, 03 July 2008 07:30 Go to next message
Eclipse UserFriend
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 #329763 is a reply to message #329761] Thu, 03 July 2008 08:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi Alwin

You can either use FileLocator.find() from the plugin org.eclipse.equinox.common or for images you can also use AbstractUIPlugin.imageDescriptorFromPlugin().

Cheers, Stephan
Re: Paths in Plugin [message #329771 is a reply to message #329763] Thu, 03 July 2008 12:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hi,

I tried now to create the image with this code:

Image file=AbstractUIPlugin.imageDescriptorFromPlugin(
"de.itm.inkas.svn.popUpMenu", "icons/full/obj16/file_obj.gif").createImage();

But I still get the FileNotFound Exception:


java.io.FileNotFoundException: icons\full\obj16\file_obj.gif (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at de.itm.inkas.svn.filecomponent.FileNode.getImage(FileNode.ja va:25)
at de.itm.inkas.svn.filecomponent.TreeLabelProvider.getImage(Tr eeLabelProvider.java:80)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.getImag e(WrappedViewerLabelProvider.java:117)
at org.eclipse.jface.viewers.WrappedViewerLabelProvider.update( WrappedViewerLabelProvider.java:165)
at org.eclipse.jface.viewers.ViewerColumn.refresh(ViewerColumn. java:135)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(Ab stractTreeViewer.java:911)
at org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeR unnable.run(AbstractTreeViewer.java:97)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:857)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:19 9)
at org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(Ab stractTreeViewer.java:991)
at org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRun nable.run(StructuredViewer.java:466)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:857)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:46)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:19 9)
at org.eclipse.jface.viewers.StructuredViewer.updateItem(Struct uredViewer.java:2026)
at org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem( AbstractTreeViewer.java:806)
at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractT reeViewer.java:781)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren( AbstractTreeViewer.java:755)
at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeView er.java:627)
at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpan d(AbstractTreeViewer.java:1410)
at org.eclipse.jface.viewers.TreeViewer.handleTreeExpand(TreeVi ewer.java:918)
at org.eclipse.jface.viewers.AbstractTreeViewer$4.treeExpanded( AbstractTreeViewer.java:1421)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:125)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:7053)
at org.eclipse.swt.widgets.Control.wmNotify(Control.java:4563)
at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:15 81)
at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:4216)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3724 )
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4351 )
at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:217 9)
at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1541)
at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:5798)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3705 )
at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5370)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4364 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:22 65)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3291)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820 )
at org.eclipse.jface.window.Window.open(Window.java:796)
at org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.open(Check edTreeSelectionDialog.java:241)
at de.itm.inkas.svn.menu.actions.BrowseAction.run(BrowseAction. java:43)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:256)
at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPl uginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:546)
at org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$6.handleEven t(ActionContributionItem.java:443)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 19)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:1173)
at org.eclipse.equinox.launcher.Main.main(Main.java:1148)
Re: Paths in Plugin [message #329784 is a reply to message #329771] Thu, 03 July 2008 16:52 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Alwin Schmitz wrote:
> Hi,
>
> I tried now to create the image with this code:
>
> Image file=AbstractUIPlugin.imageDescriptorFromPlugin(
> "de.itm.inkas.svn.popUpMenu", "icons/full/obj16/file_obj.gif").createImage();
>
> But I still get the FileNotFound Exception:
>
>
> java.io.FileNotFoundException: icons\full\obj16\file_obj.gif (Das System kann den angegebenen Pfad nicht finden)
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(Unknown Source)
> at java.io.FileInputStream.<init>(Unknown Source)
> at de.itm.inkas.svn.filecomponent.FileNode.getImage(FileNode.ja va:25)

It doesn't look like you are using the new code yet (that looks like old
code).

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Paths in Plugin [message #329787 is a reply to message #329761] Thu, 03 July 2008 18:28 Go to previous message
Eclipse UserFriend
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?
Previous Topic:popupMenus objectContribution
Next Topic:Re: Can't add extras p2 update site
Goto Forum:
  


Current Time: Sat Jul 13 21:36:25 GMT 2024

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

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

Back to the top