如何使JXTreeTable排序其顶级元素 [英] How to make a JXTreeTable sort its top elements

查看:161
本文介绍了如何使JXTreeTable排序其顶级元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道(我看过这些来源;))已经禁用了JXTreeTable上的排序。

I'm aware (I've looked at the sources ;) ) that sorting on JXTreeTable has been disabled.

但是,我想允许排序所有列都只基于根节点的直接子节点的值。

However, I would like to allow sorting on all columns based only on the values of the direct children of the root node.

假设我有这样的结构:

Name       / Date       / File UID
(Root)
|- Mr. X   / 1996/10/22 / AE123F6D
|--- File1 / 2012/01/10 / DFC2345Q
|--- File2 / 2012/01/11 / D321FEC6
|- Mrs. Y  / 1975/03/03 / G2GF35EZ
|--- File3 / 2012/02/29 / 35GERR32
|--- File4 / 2012/01/22 / LKJY2342
.
.
.

我想要实现的是仅在第一级节点上对3列进行排序。假设我想按升序日期对其进行排序,它最终会像这样:

What I want to achieve is sorting on the 3 columns only on first level nodes. Say I want to sort it by ascending date, it would end up like that:

Name       / Date       / File UID
(Root)
|- Mrs. Y  / 1975/03/03 / G2GF35EZ
|--- File3 / 2012/02/29 / 35GERR32
|--- File4 / 2012/01/22 / LKJY2342
|- Mr. X   / 1996/10/22 / AE123F6D
|--- File1 / 2012/01/10 / DFC2345Q
|--- File2 / 2012/01/11 / D321FEC6
.
.
.

正如我所看到的,它重新组合到简单的表排序(因此调用了用于禁用排序的层次结构限制被解除了。

As I see it, it ressembles to simple table sorting (so the hierarchical limitation invoked for disabling sorting is lifted).

我看到有两种可能性:


  1. Re - 启用JXTable中可用的排序机制,以便从已经实现的所有内容中获益(排序器,通过单击标题排序,...),并且只对第一级的节点进行排序(因为他们的子节点仍然具有相同的父节点)。

  2. 实现我需要的基本内容(主要通过点击标题进行排序),在JXSortableTreeModel中有一个模型行ID的列表,我排序并覆盖convertRowIndexToModel,这将允许(我认为) )按我想要的方式显示我的项目。

我最喜欢的当然是第一个,但我不知道如何实现它。第一个限制是我不知道如何重新启用排序,因为JXTreeTable重写了setSortable()(和所有相关的方法),我不知道如何直接访问JXTable中的方法实现(这是一个Java问题)。我可以简单地复制JXTreeTable的代码并删除覆盖,但在我看来这不是一个选项。

My favourite is of course the first one but I don't know how to achieve it. The first limitation is that I don't know how to re-enable sorting as JXTreeTable overrides setSortable() (and all related methods) and I don't know how to directly access the implementation of the method in JXTable (that's a Java problem). I could simply copy the code of JXTreeTable and remove the overrides but that's not an option in my opinion.

说我解决了这个问题,我怎么能将排序限制在第一个级节点?即使在查看源代码之后,我仍然对如何做到这一点毫无头绪。

Say I solve this, how would I limit the sorting to the first-level nodes? Even after looking at the source, I'm rather clueless about how to do that.

使用第二个,我放弃了现有代码的所有好处,但我看到了实现我想要的实用方法(现在,至少。谁知道是否不想过滤所有行上的数据?)。

With the second one, I loose all the benefits of existing code but I see a practical way to achieve what I want (for now, at least. Who knows if won't want to filter the data on all rows?).

还有其他方法去?如果没有,我应该选择哪一种解决方案?任何有见地的评论?

Is there another way to go? If not, which one of my solutions should I choose? Any insightful comments?

非常感谢提前!

推荐答案

< a href =http://aephyr.googlecode.com/svn/trunk/ =nofollow noreferrer>可能按照方式排序TreeTable ,通过aephyr,顺便说一下这个Swing Guru玩Nimbus Look包括有趣的Nimbus代码

maybe sorting TreeTable following way(s), by aephyr, btw this Swing Guru played with Nimbus Look and Feel too, code for funny Nimbus included






这篇关于如何使JXTreeTable排序其顶级元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆