mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Updated to sort nodes by numeric id instead of name
This commit is contained in:
parent
77014a8d90
commit
20ea27c468
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: CollectServer.java,v 1.11 2010/09/06 22:42:29 nifi Exp $
|
* $Id: CollectServer.java,v 1.12 2010/09/08 12:39:40 nifi Exp $
|
||||||
*
|
*
|
||||||
* -----------------------------------------------------------------
|
* -----------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -34,8 +34,8 @@
|
|||||||
*
|
*
|
||||||
* Authors : Joakim Eriksson, Niclas Finne
|
* Authors : Joakim Eriksson, Niclas Finne
|
||||||
* Created : 3 jul 2008
|
* Created : 3 jul 2008
|
||||||
* Updated : $Date: 2010/09/06 22:42:29 $
|
* Updated : $Date: 2010/09/08 12:39:40 $
|
||||||
* $Revision: 1.11 $
|
* $Revision: 1.12 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.contiki.collect;
|
package se.sics.contiki.collect;
|
||||||
@ -731,11 +731,18 @@ public class CollectServer {
|
|||||||
final Node newNode = node;
|
final Node newNode = node;
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// Insert the node sorted by name
|
// Insert the node sorted by id
|
||||||
String nodeName = newNode.getName();
|
String nodeID = newNode.getID();
|
||||||
boolean added = false;
|
boolean added = false;
|
||||||
for (int i = 0, n = nodeModel.size(); i < n; i++) {
|
for (int i = 0, n = nodeModel.size(); i < n; i++) {
|
||||||
int cmp = nodeName.compareTo(((Node) nodeModel.get(i)).getName());
|
String id = ((Node) nodeModel.get(i)).getID();
|
||||||
|
int cmp;
|
||||||
|
// Shorter id first (4.0 before 10.0)
|
||||||
|
if (nodeID.length() == id.length()) {
|
||||||
|
cmp = nodeID.compareTo(id);
|
||||||
|
} else {
|
||||||
|
cmp = nodeID.length() - id.length();
|
||||||
|
}
|
||||||
if (cmp < 0) {
|
if (cmp < 0) {
|
||||||
nodeModel.insertElementAt(newNode, i);
|
nodeModel.insertElementAt(newNode, i);
|
||||||
added = true;
|
added = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user