Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to create a FileLink for an external library resource
icon5.gif  How to create a FileLink for an external library resource [message #1153988] Fri, 25 October 2013 00:38
Kivanc Muslu is currently offline Kivanc MusluFriend
Messages: 153
Registered: November 2010
Senior Member
Hi everyone,

I am trying to create a FileLink (similar to what Eclipse Console does for exception traces) for exception traces programmatically.

So far, through my Console IPatternMatchListener, I was able to retrieve the filename:linenumber pattern correctly, and using this pattern I was able to get the absolute path for the corresponding type (java file or class) using SearchEngine.searchAllTypeNames(..).

Everything works perfectly for files that already exist in my Eclipse workspace, the hyperlinks I create correctly open them. However for file that are referenced by the dependent projects, I keep getting an internal Eclipse exception.

Example:
Assert.java:86 (or just Assert for SearchEngine)
resolves to absolute path
<home directory>\Eclipses\eclipse_4.3_dev\plugins\org.junit_4.11.0.v201303080030\junit.jar|org/junit/Assert.class

I create an IFile from this by
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);

which creates the following IFile (when printed):
L/Users/kivan_000/Eclipses/eclipse_4.3_dev/plugins/org.junit_4.11.0.v201303080030/junit.jar|org/junit/Assert.class

However, if I click on the hyperlink that I generate, I get the following error:
!ENTRY org.eclipse.ui 4 0 2013-10-24 17:32:43.192
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException
	at org.eclipse.ui.part.FileEditorInput.getPath(FileEditorInput.java:208)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3056)
	at org.eclipse.ui.internal.WorkbenchPage.access$21(WorkbenchPage.java:3042)
	at org.eclipse.ui.internal.WorkbenchPage$8.run(WorkbenchPage.java:3024)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3020)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2984)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2975)
	at org.eclipse.debug.ui.console.FileLink.linkActivated(FileLink.java:81)
	at org.eclipse.ui.console.TextConsoleViewer$2.handleEvent(TextConsoleViewer.java:103)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	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:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)


I suspect that the absolute path I am giving to IFile is incorrect (since it has the path for the .jar file and then the fully qualified path for the class), but I do not know the correct format.

Can someone know how to resolve the problem and make hyperlinks for external resources work? Alternative transform the path I get from SearchEngine to an IFile that can be used with FileLink?

Thanks in advance, best regards,
Previous Topic:Adding hyperlink capabilities for text displayed on Text
Next Topic:How to set Network Connections programatically
Goto Forum:
  


Current Time: Sun Nov 23 16:21:40 GMT 2014

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

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