自#199391实施以来,尝试从EDT获取<文件对象>的数据对象/无效</fileobject>

时间:2012-05-06 23:47:58

标签: java netbeans netbeans-7 netbeans-platform

“尝试从EDT获取DataObject”的含义在此netbeans平台应用程序堆栈跟踪中表示:

[INFO] INFO [org.netbeans.ui.metrics.projects]: USG_PROJECT_OPEN
[INFO] WARNING [org.netbeans.TopSecurityManager]: use of system property netbeans.user has been obsoleted in favor of InstalledFileLocator at org.netbeans.modules.masterfs.providers.Attributes.getRootForAttributes(Attributes.java:104)
[INFO] WARNING [org.openide.loaders.FolderChildren..tmp.lol.Wonderland.scenes]: Attempt to obtain DataObject for /tmp/lol/Wonderland/scenes/Alice.inc@d30e0395:b749a5 from EDT
[INFO] INFO [org.openide.loaders.FolderChildren..tmp.lol.Wonderland.scenes]: Ineffective since #199391 was implemented
[INFO] java.lang.Exception: Find for /tmp/lol/Wonderland/scenes/Alice.inc@d30e0395:b749a5
[INFO]  at org.openide.loaders.FolderChildren$DelayedNode.convert(FolderChildren.java:451)
[INFO]  at org.openide.loaders.FolderChildren$DelayedNode.convert(FolderChildren.java:399)
[INFO]  at org.openide.util.lookup.InstanceContent$ConvertingItem.getInstance(InstanceContent.java:316)
[INFO]  at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:421)
[INFO]  at org.openide.nodes.FilterNode$FilterLookup.lookup(FilterNode.java:2114)
[INFO]  at org.openide.nodes.FilterNode$FilterLookup.lookup(FilterNode.java:2114)
[INFO]  at povray.projects.PovRayProxyChildren.createNodes(PovRayProxyChildren.java:30)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterNodeEntry.nodes(FilterNode.java:1895)
[INFO]  at org.openide.nodes.EntrySupport$Lazy$EntryInfo.getNode(EntrySupport.java:1645)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterLazySnapshot.get(FilterNode.java:1741)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterNodeEntry.nodes(FilterNode.java:1886)
[INFO]  at org.openide.nodes.EntrySupport$Lazy$EntryInfo.getNode(EntrySupport.java:1645)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterLazySnapshot.get(FilterNode.java:1741)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterNodeEntry.nodes(FilterNode.java:1886)
[INFO]  at org.openide.nodes.EntrySupport$Lazy$EntryInfo.getNode(EntrySupport.java:1645)
[INFO]  at org.openide.nodes.FilterNode$Children$LazySupport$FilterLazySnapshot.get(FilterNode.java:1741)
[INFO]  at org.openide.nodes.EntrySupport$Lazy$LazySnapshot.get(EntrySupport.java:1871)
[INFO]  at org.openide.nodes.EntrySupport$Lazy$LazySnapshot.get(EntrySupport.java:1858)
[INFO]  at org.openide.explorer.view.VisualizerChildren.getChildAt(VisualizerChildren.java:127)
[INFO]  at org.openide.explorer.view.VisualizerNode.getChildAt(VisualizerNode.java:321)
[INFO]  at javax.swing.tree.DefaultTreeModel.getChild(DefaultTreeModel.java:156)
[INFO]  at javax.swing.tree.FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration.nextElement(FixedHeightLayoutCache.java:1506)
[INFO]  at javax.swing.tree.FixedHeightLayoutCache$VisibleFHTreeStateNodeEnumeration.nextElement(FixedHeightLayoutCache.java:1461)
[INFO]  at javax.swing.tree.AbstractLayoutCache.getPreferredWidth(AbstractLayoutCache.java:228)
[INFO]  at javax.swing.plaf.basic.BasicTreeUI.updateCachedPreferredSize(BasicTreeUI.java:1820)
[INFO]  at javax.swing.plaf.basic.BasicTreeUI.getPreferredSize(BasicTreeUI.java:1921)
[INFO]  at javax.swing.plaf.basic.BasicTreeUI.getPreferredSize(BasicTreeUI.java:1909)
[INFO]  at javax.swing.JComponent.getPreferredSize(JComponent.java:1634)
[INFO]  at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
[INFO]  at org.openide.explorer.view.TreeView$ExplorerScrollPaneLayout.layoutContainer(TreeView.java:1823)
[INFO]  at java.awt.Container.layout(Container.java:1421)
[INFO]  at java.awt.Container.doLayout(Container.java:1410)
[INFO]  at java.awt.Container.validateTree(Container.java:1507)
[INFO]  at java.awt.Container.validate(Container.java:1480)
[INFO]  at org.openide.explorer.view.TreeView.access$101(TreeView.java:151)
[INFO]  at org.openide.explorer.view.TreeView$3.run(TreeView.java:683)
[INFO]  at org.openide.util.Mutex.readAccess(Mutex.java:365)
[INFO]  at org.openide.util.Mutex$1R.run(Mutex.java:1307)
[INFO]  at org.openide.nodes.Children$ProjectManagerDeadlockDetector.execute(Children.java:1920)
[INFO]  at org.openide.util.Mutex.doWrapperAccess(Mutex.java:1326)
[INFO]  at org.openide.util.Mutex.readAccess(Mutex.java:354)
[INFO]  at org.openide.explorer.view.TreeView.validate(TreeView.java:681)
[INFO]  at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:670)
[INFO]  at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1635)
[INFO]  at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
[INFO]  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
[INFO]  at java.awt.EventQueue.access$000(EventQueue.java:84)
[INFO]  at java.awt.EventQueue$1.run(EventQueue.java:602)
[INFO]  at java.awt.EventQueue$1.run(EventQueue.java:600)
[INFO]  at java.security.AccessController.doPrivileged(Native Method)
[INFO]  at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
[INFO]  at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
[INFO]  at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:162)
[INFO]  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
[INFO]  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
[INFO]  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
[INFO]  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
[INFO]  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
[INFO]  at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

? 怎么解决? 当我打开我的应用程序打开特殊项目类型(.pov)时会发生这种情况。它不会伤害任何东西,但会为每个.pov项目文件以相同的消息充斥终端输出。

EDIT1

Aha,经过一些研究后我发现EDT的意思是“Event Dispatcher Thread”,禁止出于某种原因访问DataObjects。这种禁止的原因是什么?如何正确测试节点是否代表FS上的隐藏文件?如何正确创建单独的线程?

2 个答案:

答案 0 :(得分:1)

禁止的原因是这可能导致IO到磁盘,因此应该在EDT上避免。否则UI可能会冻结。

有关线程及其正确用法的信息,请参阅:http://docs.oracle.com/javase/tutorial/uiswing/concurrency/worker.html

要知道文件是否隐藏,您需要访问java.io.File。

要访问该文件,您需要执行以下操作:

FileObject fo = DATAOBJECT.getPrimaryFile();
File = FileUtil.toFile(fo)

您需要添加错误代码。

答案 1 :(得分:0)

正如Jesse Glick在关于这个错误的帖子中所解释的那样:https://netbeans.org/bugzilla/show_bug.cgi?id=199391

尽可能尝试查找FileObject而不是DataObject,以避免因使用DataObject而导致IO到磁盘。

从节点对象获取FileObject的示例:

FileObject fileObject = (FileObject) node.getLookup().lookup(FileObject.class);

FileObject实例可以为您提供大量信息,因为它支持java.io.File类上可用的许多方法