Flamingo功能区:Java.lang.IllegalArgumentException:找不到java.lang.Float的内插器:java.lang.Float

时间:2014-09-26 07:51:25

标签: java swing netbeans-platform radiance-flamingo

我在NetBeans项目中使用Flamingo Ribbon Bar,我遇到了一个主要问题:有时候(对不起,我不能更具体,因为我真的无法弄清楚如何始终如一复制它)我得到以下异常:

Java.lang.IllegalArgumentException: No interpolator found for java.lang.Float:java.lang.Float
at org.pushingpixels.trident.TimelinePropertyBuilder.getFieldInfo(TimelinePropertyBuilder.java:257)
at org.pushingpixels.trident.Timeline.addPropertyToInterpolate(Timeline.java:353)
at org.pushingpixels.trident.Timeline.addPropertyToInterpolate(Timeline.java:363)
at org.pushingpixels.flamingo.internal.ui.ribbon.BasicRibbonBandUI.installUI(BasicRibbonBandUI.java:168)
at javax.swing.JComponent.setUI(Unknown Source)
at org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand.setUI(AbstractRibbonBand.java:232)
at org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand.updateUI(AbstractRibbonBand.java:245)
at org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand.<init>(AbstractRibbonBand.java:205)
at org.pushingpixels.flamingo.api.ribbon.JRibbonBand.<init>(JRibbonBand.java:169)
at com.pinkmatter.modules.flamingo.RibbonComponentFactory.createRibbonBand(RibbonComponentFactory.java:216)
at com.pinkmatter.modules.flamingo.RibbonComponentFactory.createRibbonBands(RibbonComponentFactory.java:207)
at com.pinkmatter.modules.flamingo.RibbonComponentFactory.createRibbonTask(RibbonComponentFactory.java:195)
at com.pinkmatter.modules.flamingo.LayerRibbonComponentProvider.addTaskPanes(LayerRibbonComponentProvider.java:101)
at com.pinkmatter.modules.flamingo.LayerRibbonComponentProvider.createRibbon(LayerRibbonComponentProvider.java:56)
at com.pinkmatter.modules.flamingo.Installer$2.run(Installer.java:69)
[catch] at org.netbeans.core.windows.WindowManagerImpl$Exclusive$1.run(WindowManagerImpl.java:1563)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

功能区栏未初始化(因此我的软件无法使用)。有时候,如果我关闭它并重新启动它,它会正确启动,有时则不会。我对发生的事情一无所知;在某个地方,我读到了一些关于使用错误的类加载器的内容,但我现在无法真正找到该链接...任何人都可以帮忙吗?当然,如果需要,我可以提供更多细节

由于

2 个答案:

答案 0 :(得分:2)

虽然接受的答案可以完成这项工作,但这不是正确的方法。基本上,上面是一个问题的解决方法,首先不应该/不存在。由于trident库的许多源和二进制文件传输,它已经发生,因此遗留了一个非常重要的文件。因此像病毒一样传播臭虫。

该文件名为 trident-plugin.properties ,并且,实际上存储了可用插值器的位置。

因此,明显的解决方法是将此文件添加到META-INF目录中受影响的包中。

为了快速参考,以下是它的内容:

UIToolkitHandler=org.pushingpixels.trident.swing.SwingToolkitHandler
PropertyInterpolatorSource=org.pushingpixels.trident.swing.AWTPropertyInterpolators

UIToolkitHandler=org.pushingpixels.trident.swt.SWTToolkitHandler
PropertyInterpolatorSource=org.pushingpixels.trident.swt.SWTPropertyInterpolators

UIToolkitHandler=org.pushingpixels.trident.android.AndroidToolkitHandler
PropertyInterpolatorSource=org.pushingpixels.trident.android.AndroidPropertyInterpolators

PropertyInterpolatorSource=org.pushingpixels.trident.interpolator.CorePropertyInterpolators

答案 1 :(得分:1)

正如其他评论中所述,我找到了一个解决方案(对不起,我之前没有提供解决方案)。

基本上,问题是使用错误的类加载器来查找插补器。所以我确保实例化总是使用System类加载器。为此,我修改了两个文件:

com.pinkmatter.modules.flamingo.RibbonComponentFactory.getOrCreateActionItem()

private static ActionItem getOrCreateActionItem(Lookup.Item<Object> item, String name,
        Map<String, ActionItem> actionMap,
        Map<String, FileObject> foMap) {
    ActionItem actionItem = actionMap.get(name);
    if (actionItem == null) {
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            // Some ribbon resources use Trident which looks for resources not 
            // found by the org.netbeans.MainImpl$BootClassLoader. So we
            // switch to the org.netbeans.ModuleManager$SystemClassLoader.
            ClassLoader systemClassLoader = Lookup.getDefault().lookup(ClassLoader.class);
            Thread.currentThread().setContextClassLoader(systemClassLoader);
            if (Action.class.isAssignableFrom(item.getType())) {
            // Create an Action from an instance defined in the file object
            Action instance = (Action) item.getInstance();
                if (instance != null) {
                    actionItem = ActionItem.leaf((Action) instance);
                }
            } else if (JSeparator.class.isAssignableFrom(item.getType())) {
                // Create a Separator
                actionItem = ActionItem.separator();
                actionItem.setText(foMap.get(name).getName());
            } else if (JComponent.class.isAssignableFrom(item.getType())) {
                // Create a Ribbon component from an instance defined in the file object
                JComponent instance = (JComponent) item.getInstance();

                if (instance != null) {
                    actionItem = ActionItem.component((JComponent) instance);
                }
            }
        }
        finally {
            // Restore the original classloader
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        } 
    } else {
        System.out.println(MessageFormat.format("WARNING: Unknown item: {0}", item.getType()));
    }
    if (actionItem != null) {
        addProperties(actionItem, foMap.get(name));
        actionMap.put(name, actionItem);
    }
    return actionItem;
}

方法com.pinkmatter.modules.flamingo.RibbonComponentFactory.createRibbonBand()中的内容相同:

public AbstractRibbonBand createRibbonBand(ActionItem item) {
        //TODO icon
        JRibbonBand band = null;
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        ClassLoader systemClassLoader = Lookup.getDefault().lookup(ClassLoader.class);
        Thread.currentThread().setContextClassLoader(systemClassLoader);
        try {
        String text = item.getValue("displayName") == null ? item.getText() : item.getValue("displayName").toString();
        band = new JRibbonBand(text, ResizableIcons.empty(), getDefaultAction(item));
        for (ActionItem child : item.getChildren()) {
            if (child.isSeparator()) {
                band.startGroup();
            } else if (child.getValue(ActionItem.DEFAULT_ACTION) != Boolean.TRUE) {
                addRibbonBandAction(band, child);
            }
        }
        band.setResizePolicies(Arrays.<RibbonBandResizePolicy>asList(
                new Mid2Mid(band.getControlPanel())));
        } finally {
            Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
        return band;
    }

通过这两项更改,我对插补器不再有任何问题了。希望这会有所帮助。