尝试FilteredTree

时间:2015-08-22 09:36:49

标签: java swt jface viewer

我试图在我的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());

1 个答案:

答案 0 :(得分:1)

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

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