将OutlineView与ChildFactory一起使用

时间:2018-08-05 14:47:52

标签: java netbeans platform netbeans-platform netbeans-plugins

我想在我的netbeans插件中使用OutlineView。我创建:

public class UserDictionaryResultDataPanel extends TopComponent implements
        ExplorerManager.Provider {
   private final ExplorerManager em = new ExplorerManager();

   public UserDictionaryResultDataPanel() {
     OutlineView ov = (OutlineView) myJscrollPane;
     final UserDictionary currentUserDictionary = getCurrentUserDictionary();

        final List<String> namesAndDisplayNames = new ArrayList<>();
        currentUserDictionary.getColumns().forEach(c -> {
            namesAndDisplayNames.add(c.getColumnName());
            namesAndDisplayNames.add(c.getColumnName());
        });

     em.setRootContext(new AbstractNode(Children.create(new TaskChildFactory(currentUserDictionary ), true)));
   }

   @Override
    public ExplorerManager getExplorerManager() {
        return em;
    }

}

但是要使用此功能,我必须从ChildFactory进行扩展,并将其放入类似这样的类型:

public class TaskChildFactory extends ChildFactory<Task /* Some type */> {
   final UserDictionary currentUserDictionary;

   public TaskChildFactory(UserDictionary currentUserDictionary) {
       this.currentUserDictionary = currentUserDictionary;
   }

   @Override
   protected boolean createKeys(final List<Task> toPopulate) {
        //create rows
   }

   @Override
   protected Node createNodeForKey(final Task key) {
   }

}

但就我而言,我在不同的时间事先不知道这种类型。我有一组不同的表列!我只有一个包含列name = value的Map。

我伤了头!如何在不知道类型的情况下打印行?

0 个答案:

没有答案