1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Use the same Comparator to sort EditorTab and SketchFile

This commit is contained in:
Cristian Maglie 2016-11-07 12:13:30 +01:00
parent c35469ea81
commit 5244daa5d1
2 changed files with 2 additions and 13 deletions

View File

@ -1691,22 +1691,11 @@ public class Editor extends JFrame implements RunnerListener {
selectTab(0);
}
private static final Comparator<EditorTab> CODE_DOCS_COMPARATOR = new Comparator<EditorTab>() {
@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()));
}
/**

View File

@ -31,7 +31,7 @@ public class Sketch {
private File buildPath;
private static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
public static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
@Override
public int compare(SketchFile x, SketchFile y) {
if (x.isPrimary() && !y.isPrimary())