From 5244daa5d17bfdd7edd86f04ac813e92d456721e Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 7 Nov 2016 12:13:30 +0100 Subject: [PATCH] Use the same Comparator to sort EditorTab and SketchFile --- app/src/processing/app/Editor.java | 13 +------------ arduino-core/src/processing/app/Sketch.java | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index f2fe40b7e..814a3286b 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1691,22 +1691,11 @@ public class Editor extends JFrame implements RunnerListener { selectTab(0); } - private static final Comparator CODE_DOCS_COMPARATOR = new Comparator() { - @Override - public int compare(EditorTab x, EditorTab y) { - if (x.getSketchFile().isPrimary() && !y.getSketchFile().isPrimary()) - return -1; - if (y.getSketchFile().isPrimary() && !x.getSketchFile().isPrimary()) - return 1; - return x.getSketchFile().getFileName().compareTo(y.getSketchFile().getFileName()); - } - }; - /** * Reorders tabs as per current sketch's files order */ public void reorderTabs() { - Collections.sort(tabs, CODE_DOCS_COMPARATOR); + Collections.sort(tabs, (x, y) -> Sketch.CODE_DOCS_COMPARATOR.compare(x.getSketchFile(), y.getSketchFile())); } /** diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java index 11b57ab3b..fa6a38bf0 100644 --- a/arduino-core/src/processing/app/Sketch.java +++ b/arduino-core/src/processing/app/Sketch.java @@ -31,7 +31,7 @@ public class Sketch { private File buildPath; - private static final Comparator CODE_DOCS_COMPARATOR = new Comparator() { + public static final Comparator CODE_DOCS_COMPARATOR = new Comparator() { @Override public int compare(SketchFile x, SketchFile y) { if (x.isPrimary() && !y.isPrimary())