Skip to content

Commit 80f689f

Browse files
author
jan
committed
Sorting and updating improvement #1727
1 parent ffefdc8 commit 80f689f

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

io.sloeber.core/src/io/sloeber/arduinoFramework/api/IArduinoLibrary.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ public abstract class IArduinoLibrary extends Node implements Comparable<IArdu
5050

5151
public abstract IPath getInstallPath();
5252

53+
public abstract boolean canUpdate();
54+
5355
}

io.sloeber.core/src/io/sloeber/arduinoFramework/internal/ArduinoLibrary.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ public boolean isInstalled() {
139139

140140
@Override
141141
public int compareTo(IArduinoLibrary other) {
142+
if(other==null) {
143+
return 1;
144+
}
142145
return getID().compareTo(other.getID());
146+
143147
}
144148

145149
//Below are the Node overrides
@@ -173,4 +177,12 @@ public ArduinoLibraryVersion getVersion(VersionNumber versionNumber) {
173177
return versions.get(versionNumber);
174178
}
175179

180+
@Override
181+
public boolean canUpdate() {
182+
if(!isInstalled()) {
183+
return false;
184+
}
185+
return !getInstalledVersion().equals(getNewestVersion());
186+
}
187+
176188
}

io.sloeber.core/src/io/sloeber/core/internal/ArduinoHardwareLibrary.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static io.sloeber.core.api.Const.*;
44

5+
import java.util.ArrayList;
56
import java.util.List;
67

78
import org.eclipse.core.runtime.IPath;
@@ -84,8 +85,16 @@ public boolean equals(IArduinoLibraryVersion other) {
8485
}
8586

8687
@Override
87-
public int compareTo(IArduinoLibraryVersion o) {
88-
return 0;
88+
public boolean equals(Object other) {
89+
if(other instanceof IArduinoLibraryVersion) {
90+
return equals((IArduinoLibraryVersion) other);
91+
}
92+
return false;
93+
}
94+
95+
@Override
96+
public int compareTo(IArduinoLibraryVersion other) {
97+
return myFQN.toPortableString().compareTo(other.getFQN().toPortableString());
8998
}
9099

91100
@Override
@@ -105,7 +114,7 @@ public boolean isInstalled() {
105114

106115
@Override
107116
public List<String> getArchitectures() {
108-
return null;
117+
return new ArrayList<>();
109118
}
110119

111120
@Override
@@ -125,7 +134,6 @@ public String getMaintainer() {
125134

126135
@Override
127136
public String getAuthor() {
128-
// TODO Auto-generated method stub
129137
return "Author is board provider"; //$NON-NLS-1$
130138
}
131139

0 commit comments

Comments
 (0)