我试图在我的SWT应用程序中使用过滤树。我将所有必需的jar文件添加到了构建路径。当我运行应用程序时遇到以下异常

org.eclipse.core.runtime.AssertionFailedException: null argument:
    at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
    at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
    at org.eclipse.ui.internal.util.PrefUtil.getAPIPreferenceStore(PrefUtil.java:70)
    at org.eclipse.ui.PlatformUI.getPreferenceStore(PlatformUI.java:196)
    at org.eclipse.ui.dialogs.FilteredTree.init(FilteredTree.java:302)
    at org.eclipse.ui.dialogs.FilteredTree.<init>(FilteredTree.java:247)
    at com.sample.TreeView.createContents(TreeView.java:61)
    at com.sample.TreeView.open(TreeView.java:40)
    at com.sample.TreeView.main(TreeView.java:29)


这是我的代码。

PatternFilter patternFilter = new PatternFilter();
        patternFilter.setIncludeLeadingWildcard(true);
        filteredTree = new FilteredTree(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true);

        TreeViewer viewer = filteredTree.getViewer();
        tree = viewer.getTree();
        tree.setHeaderVisible(true);

        TreeColumn modelColumn = new TreeColumn(tree, SWT.LEFT);
        modelColumn.setText("Model");
        modelColumn.setWidth(400);

        TreeViewerColumn treeViewerModelColumn = new TreeViewerColumn(viewer, modelColumn);
        treeViewerModelColumn.setLabelProvider(new ColumnLabelProvider());

最佳答案

您只能在完整的Eclipse RCP中使用FilteredTree,因为它取决于许多其他Eclipse插件以及RCP启动时完成的所有初始化。

您不能在SWT应用程序中使用它。

关于java - 尝试FilteredTree时出现AssertionFailedException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32154565/

10-10 09:14