Skip to content

Commit b522af4

Browse files
author
jantje
committed
refactor rename boarddescriptor description
1 parent 046dcb2 commit b522af4

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

io.sloeber.core/src/io/sloeber/core/api/PackageManager.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sloeber.core.api;
22

3+
import static io.sloeber.core.Messages.*;
34
import static java.nio.file.StandardCopyOption.*;
45

56
import java.io.File;
@@ -35,7 +36,6 @@
3536
import com.google.gson.Gson;
3637

3738
import io.sloeber.core.Activator;
38-
import io.sloeber.core.Messages;
3939
import io.sloeber.core.api.PackageManager.PlatformTree.IndexFile;
4040
import io.sloeber.core.api.PackageManager.PlatformTree.InstallableVersion;
4141
import io.sloeber.core.api.PackageManager.PlatformTree.Platform;
@@ -59,16 +59,15 @@
5959
*/
6060
public class PackageManager {
6161

62-
private static final String FILE = Messages.FILE;
63-
private static final String FOLDER = Messages.FOLDER;
62+
public static final String LOCAL = "local"; //$NON-NLS-1$
6463
protected static List<PackageIndex> packageIndices;
6564
private static boolean myHasbeenLogged = false;
6665
private static boolean platformsDirty = true;// reset global variables at startup
6766
private final static int MAX_HTTP_REDIRECTIONS = 5;
6867
private static HashMap<String, String> myWorkbenchEnvironmentVariables = new HashMap<>();
6968

7069
/**
71-
* Gets the board descriptor based on the information provided. If
70+
* Gets the board description based on the information provided. If
7271
* jsonFileName="local" the board is assumed not to be installed by the boards
7372
* manager. Otherwise the boardsmanager is queried to find the board descriptor.
7473
* In this case the latest installed board will be returned
@@ -91,9 +90,9 @@ public class PackageManager {
9190
* file) or null for defaults
9291
* @return The class BoardDescriptor or null
9392
*/
94-
static public BoardDescription getBoardDescriptor(String jsonFileName, String packageName, String architectureName,
93+
static public BoardDescription getBoardDescription(String jsonFileName, String packageName, String architectureName,
9594
String boardID, Map<String, String> options) {
96-
if (jsonFileName.equals("local")) { //$NON-NLS-1$
95+
if (LOCAL.equals(jsonFileName)) {
9796
return new BoardDescription(new File(packageName), boardID, options);
9897
}
9998
return getNewestBoardIDFromBoardsManager(jsonFileName, packageName, architectureName, boardID, options);
@@ -129,7 +128,7 @@ public static void addPackageURLs(HashSet<String> packageUrlsToAdd, boolean forc
129128

130129
public static void setPackageURLs(HashSet<String> packageUrls, boolean forceDownload) {
131130
if (!isReady()) {
132-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
131+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
133132
return;
134133
}
135134
ConfigurationPreferences.setJsonURLs(packageUrls);
@@ -138,7 +137,7 @@ public static void setPackageURLs(HashSet<String> packageUrls, boolean forceDown
138137

139138
public static void removePackageURLs(Set<String> packageUrlsToRemove) {
140139
if (!isReady()) {
141-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
140+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
142141
return;
143142
}
144143
InternalPackageManager.removePackageURLs(packageUrlsToRemove);
@@ -157,7 +156,7 @@ public static void removePackageURLs(Set<String> packageUrlsToRemove) {
157156
*/
158157
public static void installsubsetOfLatestPlatforms(int fromIndex, int toIndex) {
159158
if (!isReady()) {
160-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
159+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
161160
return;
162161
}
163162
platformsDirty = true;
@@ -185,7 +184,7 @@ public static void installAllLatestPlatforms() {
185184

186185
public static void installLatestPlatform(String JasonName, String packageName, String architectureName) {
187186
if (!isReady()) {
188-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
187+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
189188
return;
190189
}
191190
platformsDirty = true;
@@ -243,7 +242,7 @@ public static File[] getAllBoardsFiles() {
243242
}
244243
if (boardFiles.size() == 0) {
245244
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
246-
Messages.Helpers_No_boards_txt_found.replace(FILE, String.join("\n", hardwareFolders)), null)); //$NON-NLS-1$
245+
Helpers_No_boards_txt_found.replace(FILE, String.join("\n", hardwareFolders)), null)); //$NON-NLS-1$
247246
return null;
248247
}
249248
return boardFiles.toArray(new File[boardFiles.size()]);
@@ -255,7 +254,7 @@ private static void searchFiles(File folder, TreeSet<File> Hardwarelists, String
255254
if (a == null) {
256255
if (!myHasbeenLogged) {
257256
Common.log(new Status(IStatus.INFO, Const.CORE_PLUGIN_ID,
258-
Messages.Helpers_Error_The_folder_is_empty.replace(FOLDER, folder.toString()), null));
257+
Helpers_Error_The_folder_is_empty.replace(FOLDER, folder.toString()), null));
259258
myHasbeenLogged = true;
260259
}
261260
return;
@@ -569,7 +568,7 @@ public Platform getPlatform(Package curPackage, ArduinoPlatform curInternalPlatf
569568

570569
public static IStatus setPlatformTree(PlatformTree platformTree, IProgressMonitor monitor, MultiStatus status) {
571570
if (!isReady()) {
572-
status.add(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, null));
571+
status.add(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, null));
573572
return status;
574573
}
575574
if (!ConfigurationPreferences.getUpdateJasonFilesFlag()) {
@@ -617,7 +616,7 @@ public static TreeMap<String, String> getAllmenus() {
617616
*/
618617
public static void onlyKeepLatestPlatforms() {
619618
if (!isReady()) {
620-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
619+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
621620
return;
622621
}
623622
InternalPackageManager.onlyKeepLatestPlatforms();
@@ -626,7 +625,7 @@ public static void onlyKeepLatestPlatforms() {
626625

627626
public static void setPrivateHardwarePaths(String[] hardWarePaths) {
628627
if (!isReady()) {
629-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
628+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
630629
return;
631630
}
632631
InstancePreferences.setPrivateHardwarePaths(hardWarePaths);
@@ -690,7 +689,7 @@ static private void loadPackage(File jsonFile) {
690689
packageIndices.add(index);
691690
} catch (Exception e) {
692691
Common.log(new Status(IStatus.ERROR, Activator.getId(),
693-
Messages.Manager_Failed_to_parse.replace(FILE, jsonFile.getAbsolutePath()), e));
692+
Manager_Failed_to_parse.replace(FILE, jsonFile.getAbsolutePath()), e));
694693
jsonFile.delete();// Delete the file so it stops damaging
695694
}
696695
}
@@ -822,7 +821,7 @@ public static String[] getJsonURLList() {
822821
*/
823822
public static void setJsonURLs(String[] newJsonUrls) {
824823
if (!isReady()) {
825-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
824+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
826825
return;
827826
}
828827

@@ -858,7 +857,7 @@ public static String getDefaultURLs() {
858857

859858
public static void removeAllInstalledPlatforms() {
860859
if (!isReady()) {
861-
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, Messages.BoardsManagerIsBussy, new Exception()));
860+
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
862861
return;
863862
}
864863
try {

io.sloeber.tests/src/io/sloeber/core/RegressionTestFailingOnTravis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void redirectedJson() {
5252
PackageManager.installLatestPlatform("package_talk2.wisen.com_index.json", "Talk2", "avr");
5353
Map<String, String> options = new HashMap<>();
5454
options.put("mhz", "16MHz");
55-
BoardDescription boardid = PackageManager.getBoardDescriptor("package_talk2.wisen.com_index.json", "Talk2",
55+
BoardDescription boardid = PackageManager.getBoardDescription("package_talk2.wisen.com_index.json", "Talk2",
5656
"avr", "whispernode", options);
5757
if (boardid == null) {
5858
fail("redirect Json ");

io.sloeber.tests/src/io/sloeber/providers/Adafruit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Adafruit extends MCUBoard {
1818

1919
public Adafruit( String architectureName, String boardName) {
2020

21-
this.myBoardDescriptor = PackageManager.getBoardDescriptor( "package_adafruit_index.json","adafruit",architectureName ,
21+
this.myBoardDescriptor = PackageManager.getBoardDescription( "package_adafruit_index.json","adafruit",architectureName ,
2222
boardName, null);
2323
if (this.myBoardDescriptor == null) {
2424
fail(boardName + " Board not found");

io.sloeber.tests/src/io/sloeber/providers/Arduino.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static MCUBoard arduino_101(String uploadPort) {
166166

167167

168168
private Arduino(String providerName, String architectureName, String boardName) {
169-
this.myBoardDescriptor = PackageManager.getBoardDescriptor(jsonFileName, providerName, architectureName,
169+
this.myBoardDescriptor = PackageManager.getBoardDescription(jsonFileName, providerName, architectureName,
170170
boardName, null);
171171
if (this.myBoardDescriptor == null) {
172172
fail(boardName + " Board not found");

io.sloeber.tests/src/io/sloeber/providers/ESP32.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static MCUBoard esp32() {
2929

3030

3131
public ESP32(String boardName, Map<String, String> options) {
32-
this.myBoardDescriptor = PackageManager.getBoardDescriptor(jsonFileName, provider, architectureName,
32+
this.myBoardDescriptor = PackageManager.getBoardDescription(jsonFileName, provider, architectureName,
3333
boardName, options);
3434
if (this.myBoardDescriptor == null) {
3535
fail(boardName + " Board not found");

io.sloeber.tests/src/io/sloeber/providers/ESP8266.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static MCUBoard ESPressoLite() {
4949

5050

5151
public ESP8266(String boardName, Map<String, String> options) {
52-
this.myBoardDescriptor = PackageManager.getBoardDescriptor(jsonFileName, provider, architectureName,
52+
this.myBoardDescriptor = PackageManager.getBoardDescription(jsonFileName, provider, architectureName,
5353
boardName, options);
5454
if (this.myBoardDescriptor == null) {
5555
fail(boardName + " Board not found");

io.sloeber.tests/src/io/sloeber/providers/Jantje.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class Jantje extends MCUBoard {
2424
public Jantje(String boardName) {
2525
Map<String, String> options = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
2626
options.put("type", "debug");
27-
this.myBoardDescriptor = PackageManager.getBoardDescriptor(jsonFileName,packageName,localDebugArchitectureName ,
27+
this.myBoardDescriptor = PackageManager.getBoardDescription(jsonFileName,packageName,localDebugArchitectureName ,
2828
boardName, options);
2929
if (this.myBoardDescriptor == null) {
3030
fail(boardName + " Board not found");

io.sloeber.tests/src/io/sloeber/providers/Teensy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.sloeber.providers;
22

3-
import static org.junit.Assert.fail;
3+
import static org.junit.Assert.*;
44

55
import java.util.Map;
66
import java.util.TreeMap;
@@ -81,7 +81,8 @@ private Teensy(String boardName) {
8181
break;
8282
}
8383

84-
this.myBoardDescriptor = PackageManager.getBoardDescriptor("local", MySystem.getTeensyBoard_txt(), "ignored",
84+
this.myBoardDescriptor = PackageManager.getBoardDescription(PackageManager.LOCAL, MySystem.getTeensyBoard_txt(),
85+
"ignored",
8586
boardName, options);
8687
if (this.myBoardDescriptor == null) {
8788
fail(boardName + " Board not found");
@@ -137,7 +138,7 @@ public Map<String, String> getBoardOptions(Examples example) {
137138
}
138139

139140
public static MCUBoard[] getAllBoards() {
140-
// hardcode this stuff now because I want to release 4.3.1
141+
// TOFIX hardcode this stuff now because I want to release 4.3.1
141142
// shoulds be something like
142143
// return
143144
// PackageManager.getAllBoardDescriptors(getJsonFileName(),getPackageName(),getPlatformName()

0 commit comments

Comments
 (0)