Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » getImageRegistry() does not work
getImageRegistry() does not work [message #294150] Fri, 04 November 2005 08:57 Go to next message
Eclipse UserFriend
Originally posted by: fekmfg.web.de

Hi

I have 2 methods in the class that extends AbstractUiPlugin:

public static Image getImage(String name) {
ImageRegistry imageRegistry = getDefault().getImageRegistry();
return imageRegistry.get(name);
}
and
protected void initializeImageRegistry(ImageRegistry imageRegistry) {
iconBaseUrl = getBundle().getEntry("icons/");
imageRegistry.put("element", getImageDescriptor("element.gif"));
imageRegistry.put("attribute",
getImageDescriptor("attribute.gif"));
}

I've set a breakpoint in the getImage(String) method. When the
breakpoint is arrived and I press the "resume" button, then I become am
error message dialog in the runtime-workspace:

"An error has occured. See error log for more details".
The log files looks like this:
!ENTRY org.eclipse.jface 4 2 2005-11-04 14:40:00.945
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.jface".
!STACK 0
java.lang.NullPointerException
at
com.xtramind.tools.infoxtract.InfoxtractPlugin.getImage(Info xtractPlugin.java:34)
at
com.xtramind.tools.infoxtract.views.XmlLabelProvider.getImag e(XmlLabelProvider.java:42)
at
org.eclipse.jface.viewers.StructuredViewer.buildLabel(Struct uredViewer.java:1878)
at org.eclipse.jface.viewers.TreeViewer.doUpdateItem(TreeViewer .java:231)
at
org.eclipse.jface.viewers.AbstractTreeViewer$UpdateItemSafeR unnable.run(AbstractTreeViewer.java:85)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:14 8)
at
org.eclipse.jface.viewers.AbstractTreeViewer.doUpdateItem(Ab stractTreeViewer.java:621)
at
org.eclipse.jface.viewers.StructuredViewer$UpdateItemSafeRun nable.run(StructuredViewer.java:434)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:14 8)
at
org.eclipse.jface.viewers.StructuredViewer.updateItem(Struct uredViewer.java:1763)
at
org.eclipse.jface.viewers.AbstractTreeViewer.createTreeItem( AbstractTreeViewer.java:535)
at
org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractT reeViewer.java:514)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
at
org.eclipse.jface.viewers.AbstractTreeViewer.createChildren( AbstractTreeViewer.java:494)
at
org.eclipse.jface.viewers.AbstractTreeViewer$5.run(AbstractT reeViewer.java:983)
at
org.eclipse.jface.viewers.StructuredViewer.preservingSelecti on(StructuredViewer.java:1201)
at
org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(Ab stractTreeViewer.java:973)
at org.eclipse.jface.viewers.ContentViewer.setInput(ContentView er.java:248)
at
org.eclipse.jface.viewers.StructuredViewer.setInput(Structur edViewer.java:1417)
at
com.xtramind.tools.infoxtract.views.XmlContentOutlinePage.se tInput(XmlContentOutlinePage.java:77)
at
com.xtramind.tools.infoxtract.views.XmlContentOutlinePage.cr eateControl(XmlContentOutlinePage.java:65)
at
org.eclipse.ui.views.contentoutline.ContentOutline.doCreateP age(ContentOutline.java:133)
at org.eclipse.ui.part.PageBookView.createPage(PageBookView.jav a:315)
at org.eclipse.ui.part.PageBookView.partActivated(PageBookView. java:613)
at
org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookV iew.java:756)
at
org.eclipse.ui.part.PageBookView.createPartControl(PageBookV iew.java:397)
at
org.eclipse.ui.views.contentoutline.ContentOutline.createPar tControl(ContentOutline.java:118)
at
org.eclipse.ui.internal.ViewReference.createPartHelper(ViewR eference.java:305)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReferen ce.java:180)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:552)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:28 3)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:51 2)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:126)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:268)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:391)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1102)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.ja va:591)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.ja va:528)
at
org.eclipse.ui.internal.PartSashContainer.createControl(Part SashContainer.java:485)
at
org.eclipse.ui.internal.PerspectiveHelper.activate(Perspecti veHelper.java:230)
at org.eclipse.ui.internal.Perspective.onActivate(Perspective.j ava:813)
at
org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPa ge.java:2165)
at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindo w.java:2356)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
at
org.eclipse.ui.internal.WorkbenchWindow.setActivePage(Workbe nchWindow.java:2338)
at
org.eclipse.ui.internal.WorkbenchWindow.restoreState(Workben chWindow.java:1861)
at org.eclipse.ui.internal.Workbench.doRestoreState(Workbench.j ava:2566)
at org.eclipse.ui.internal.Workbench.access$14(Workbench.java:2 515)
at org.eclipse.ui.internal.Workbench$19.run(Workbench.java:1514 )
at org.eclipse.ui.internal.Workbench$16.run(Workbench.java:1263 )
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:447)
at
org.eclipse.ui.internal.Workbench.runStartupWithProgress(Wor kbench.java:1258)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1512)
at org.eclipse.ui.internal.Workbench.access$12(Workbench.java:1 491)
at org.eclipse.ui.internal.Workbench$17.run(Workbench.java:1374 )
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:1044)
at org.eclipse.core.runtime.Platform.run(Platform.java:783)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1318)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigurer.java:183)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:700)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:1034)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1636)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
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.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)

However sometimes when i want to step over the breakpoint instead to
resume I become an timeout error in the debug-workspace:

Error 2005-11-04 14:07:39.336 org.eclipse.jdi.TimeoutException: Timeout
occurred while waiting for packet 20805. occurred stepping in thread.
org.eclipse.jdi.TimeoutException: Timeout occurred while waiting for
packet 20805.
at
org.eclipse.jdi.internal.connect.PacketReceiveManager.getRep ly(PacketReceiveManager.java:174)
at
org.eclipse.jdi.internal.connect.PacketReceiveManager.getRep ly(PacketReceiveManager.java:184)
at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.jav a:174)
at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.jav a:192)
at org.eclipse.jdi.internal.MirrorImpl.requestVM(MirrorImpl.jav a:207)
at
org.eclipse.jdi.internal.ThreadReferenceImpl.resume(ThreadRe ferenceImpl.java:326)
at
org.eclipse.jdt.internal.debug.core.model.JDIThread$StepHand ler.invokeThread(JDIThread.java:1727)
at
org.eclipse.jdt.internal.debug.core.model.JDIThread$StepHand ler.step(JDIThread.java:1710)
at
org.eclipse.jdt.internal.debug.core.model.JDIThread.stepOver (JDIThread.java:1234)
at
org.eclipse.jdt.internal.debug.core.model.JDIStackFrame.step Over(JDIStackFrame.java:406)
at
org.eclipse.debug.internal.ui.actions.StepOverActionDelegate .stepAction(StepOverActionDelegate.java:30)
at
org.eclipse.debug.internal.ui.actions.StepActionDelegate.doA ction(StepActionDelegate.java:25)
at
org.eclipse.debug.internal.ui.actions.AbstractDebugActionDel egate$DebugRequestJob.run(AbstractDebugActionDelegate.java:1 50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)

Can someone help me? I dont know what to do.

Greetings Mark
Re: getImageRegistry() does not work [message #294161 is a reply to message #294150] Fri, 04 November 2005 10:31 Go to previous messageGo to next message
Eclipse UserFriend
Fek wrote:
> Hi
>
> I have 2 methods in the class that extends AbstractUiPlugin:
>
> public static Image getImage(String name) {
> ImageRegistry imageRegistry = getDefault().getImageRegistry();
> return imageRegistry.get(name);
> }

You have an NPE at:

> !STACK 0
> java.lang.NullPointerException
> at
> com.xtramind.tools.infoxtract.InfoxtractPlugin.getImage(Info xtractPlugin.java:34)
>
> at
> com.xtramind.tools.infoxtract.views.XmlLabelProvider.getImag e(XmlLabelProvider.java:42)

That's either because getDefault() returned null (did you initialize
your static in your constructor), or imageRegistry is still null on the
next line.

Later,
PW
Re: getImageRegistry() does not work [message #294165 is a reply to message #294150] Fri, 04 November 2005 11:11 Go to previous messageGo to next message
Eclipse UserFriend
> public static Image getImage(String name) {
> ImageRegistry imageRegistry = getDefault().getImageRegistry();
> return imageRegistry.get(name);
> }

> "An error has occured. See error log for more details".
> The log files looks like this:
> !ENTRY org.eclipse.jface 4 2 2005-11-04 14:40:00.945
> !MESSAGE Problems occurred when invoking code from plug-in:
> "org.eclipse.jface".
> !STACK 0
> java.lang.NullPointerException
> at
> com.xtramind.tools.infoxtract.InfoxtractPlugin.getImage(Info xtractPlugin.java:34)

It would help if you provide the line numbering information. I guess the
name parameter is null as the exception is from within jface and these
classes do not like null as parameter. So line 34 is the return statement.
If line 34 is the assignment statement I would say the plugin is not
started jet or it has not registered itself as singleton. The former could
be solved with Eclipse-Autostart: true in the manifest.mf. The latter
results when you accidently erase the template constructor of your
AbstractUIPlugin implementation and your constructor does not set the
plugin field anymore.

hth,

Ricky
Re: getImageRegistry() does not work [message #294210 is a reply to message #294165] Mon, 07 November 2005 08:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fekmfg.web.de

Ricky wrote:
>> public static Image getImage(String name) {
>> ImageRegistry imageRegistry = getDefault().getImageRegistry();
>> return imageRegistry.get(name);
>> }
>
>
>> "An error has occured. See error log for more details".
>> The log files looks like this:
>> !ENTRY org.eclipse.jface 4 2 2005-11-04 14:40:00.945
>> !MESSAGE Problems occurred when invoking code from plug-in:
>> "org.eclipse.jface".
>> !STACK 0
>> java.lang.NullPointerException
>> at
>> com.xtramind.tools.infoxtract.InfoxtractPlugin.getImage(Info xtractPlugin.java:34)
>>
>
>
> It would help if you provide the line numbering information. I guess
> the name parameter is null as the exception is from within jface and
> these classes do not like null as parameter. So line 34 is the return
> statement. If line 34 is the assignment statement I would say the
> plugin is not started jet or it has not registered itself as singleton.
> The former could be solved with Eclipse-Autostart: true in the
> manifest.mf. The latter results when you accidently erase the template
> constructor of your AbstractUIPlugin implementation and your
> constructor does not set the plugin field anymore.
>
> hth,
>
> Ricky


Hi and thanks for the help.

I've changed the code to see better where the error is thrown:

InfoxtractPlugin pluginx = getDefault();
ImageRegistry imageRegistry = pluginx.getImageRegistry();
return imageRegistry.get(name);

The error is thrown in the second line, so the plugin object seems to be
initialized. But I don't understand the problem because I do not
overwrite the getImageRegistry() method and the original implementation
of this method in AbstractUIPlugin class looks like this:

public ImageRegistry getImageRegistry() {
if (imageRegistry == null) {
imageRegistry = createImageRegistry();
initializeImageRegistry(imageRegistry);
}
return imageRegistry;
}

When I create a breakpoint in the first line of the implementation of
getImageRegistry, I never reach this point. Why?
I implemented the initializeImageRegistry-method in my plugin class
(InfoxtractRegistry) but it never be called.

Greetings Mark
Re: getImageRegistry() does not work [message #294211 is a reply to message #294210] Mon, 07 November 2005 08:14 Go to previous messageGo to next message
Eclipse UserFriend
Fek wrote:
>
> Hi and thanks for the help.
>
> I've changed the code to see better where the error is thrown:
>
> InfoxtractPlugin pluginx = getDefault();
> ImageRegistry imageRegistry = pluginx.getImageRegistry();
> return imageRegistry.get(name);
>
> The error is thrown in the second line, so the plugin object seems to be
> initialized. But I don't understand the problem because I do not
> overwrite the getImageRegistry() method and the original implementation
> of this method in AbstractUIPlugin class looks like this:

If the NPE is thrown in the second line, that means that pluginx ==
null, so the plugin object isn't initialized.

What's wrong with your getDefault()?

Later,
PW
Re: getImageRegistry() does not work [message #294219 is a reply to message #294211] Mon, 07 November 2005 08:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fekmfg.web.de

Paul Webster wrote:
> Fek wrote:
>
>>
>> Hi and thanks for the help.
>>
>> I've changed the code to see better where the error is thrown:
>>
>> InfoxtractPlugin pluginx = getDefault();
>> ImageRegistry imageRegistry = pluginx.getImageRegistry();
>> return imageRegistry.get(name);
>>
>> The error is thrown in the second line, so the plugin object seems to
>> be initialized. But I don't understand the problem because I do not
>> overwrite the getImageRegistry() method and the original
>> implementation of this method in AbstractUIPlugin class looks like this:
>
>
> If the NPE is thrown in the second line, that means that pluginx ==
> null, so the plugin object isn't initialized.
>
> What's wrong with your getDefault()?
>
> Later,
> PW

Oh thanks, you are very right :-)

My consrtuctor
public InfoxtractPlugin() {
super();
plugin = this;
}

seems to never be called.

Why? I have set my plugin-class in the overview window.

Greetings Mark
Re: getImageRegistry() does not work [message #294220 is a reply to message #294219] Mon, 07 November 2005 09:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

Is your plugin configured to be automatically started?

Look at manifest and see if you find an entry
Eclipse-AutoStart: true
if it is not there add it. This should make sure that when ever you call
into your plugin the plugin gets instantiated.

Regards
Stefan

Fek wrote:
> Paul Webster wrote:
>
>> Fek wrote:
>>
>>>
>>> Hi and thanks for the help.
>>>
>>> I've changed the code to see better where the error is thrown:
>>>
>>> InfoxtractPlugin pluginx = getDefault();
>>> ImageRegistry imageRegistry = pluginx.getImageRegistry();
>>> return imageRegistry.get(name);
>>>
>>> The error is thrown in the second line, so the plugin object seems to
>>> be initialized. But I don't understand the problem because I do not
>>> overwrite the getImageRegistry() method and the original
>>> implementation of this method in AbstractUIPlugin class looks like
>>> this:
>>
>>
>>
>> If the NPE is thrown in the second line, that means that pluginx ==
>> null, so the plugin object isn't initialized.
>>
>> What's wrong with your getDefault()?
>>
>> Later,
>> PW
>
>
> Oh thanks, you are very right :-)
>
> My consrtuctor
> public InfoxtractPlugin() {
> super();
> plugin = this;
> }
>
> seems to never be called.
>
> Why? I have set my plugin-class in the overview window.
>
> Greetings Mark
Re: getImageRegistry() does not work [message #294221 is a reply to message #294219] Mon, 07 November 2005 09:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Check that the manifest says

Eclipse-AutoStart: true

If it doesn't say this then the plugin will not be initialized until it
is explicitly started, instead of an implicit start by accessing a class
in the plugin.

Note: This doesn't mean start plugin immediately when Eclipse starts.
That is a different extension point in the plugin.xml.
--
Thanks,
Rich Kulp
Re: getImageRegistry() does not work [message #294227 is a reply to message #294221] Mon, 07 November 2005 09:40 Go to previous message
Eclipse UserFriend
Originally posted by: fekmfg.web.de

Rich Kulp wrote:
> Check that the manifest says
>
> Eclipse-AutoStart: true
>
> If it doesn't say this then the plugin will not be initialized until it
> is explicitly started, instead of an implicit start by accessing a class
> in the plugin.
>
> Note: This doesn't mean start plugin immediately when Eclipse starts.
> That is a different extension point in the plugin.xml.

thx, thx, thx

It works!!!

Greetings Mark
Previous Topic:user job dialog doesnt expand as necessary
Next Topic:Popupmenus and Adapters
Goto Forum:
  


Current Time: Thu May 08 20:56:52 EDT 2025

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

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

Back to the top