Skip to content

Commit 636e89a

Browse files
authored
Merge pull request #1417 from Sloeber/#1339_Add_deserialisation_clases
#1339 add deserialisation clases
2 parents 533582d + 94063a9 commit 636e89a

File tree

88 files changed

+5985
-5796
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+5985
-5796
lines changed

io.sloeber.core/META-INF/MANIFEST.MF

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Export-Package: cc.arduino.packages;x-internal:=true,
3232
cc.arduino.packages.ssh;x-internal:=true,
3333
io.sloeber.core;x-friends:="io.sloeber.tests",
3434
io.sloeber.core.api,
35+
io.sloeber.core.api.Json,
3536
io.sloeber.core.builder;x-internal:=true,
3637
io.sloeber.core.common;x-friends:="io.sloeber.tests",
3738
io.sloeber.core.communication;x-internal:=true,

io.sloeber.core/config/pre_processing_platform_default.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ recipe.objcopy.hex.pattern=${recipe.objcopy.bin.pattern}
44
archive_file=arduino.ar
55
archive_file_path=${build.path}/${archive_file}
66
runtime.ide.version=10812
7-
build.system.path=${referenced.core.path}${DirectoryDelimiter}system
87
serial.port=${com_port}
98
build.project_name=${ProjName}
109

io.sloeber.core/src/io/sloeber/core/Activator.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.sloeber.core;
22

33
import static io.sloeber.core.common.Const.*;
4-
import static io.sloeber.core.managers.InternalPackageManager.*;
54
import static org.eclipse.core.resources.IResource.*;
65

76
import java.io.File;
@@ -42,13 +41,14 @@
4241
import org.osgi.service.prefs.Preferences;
4342

4443
import cc.arduino.packages.discoverers.SloeberNetworkDiscovery;
45-
import io.sloeber.core.api.PackageManager;
44+
import io.sloeber.core.api.BoardsManager;
4645
import io.sloeber.core.common.Common;
4746
import io.sloeber.core.common.ConfigurationPreferences;
4847
import io.sloeber.core.common.InstancePreferences;
4948
import io.sloeber.core.listeners.ConfigurationChangeListener;
5049
import io.sloeber.core.listeners.IndexerListener;
5150
import io.sloeber.core.listeners.resourceChangeListener;
51+
import io.sloeber.core.tools.PackageManager;
5252

5353
/**
5454
* generated code
@@ -207,14 +207,13 @@ private static void initializeImportantVariables() {
207207
try {
208208
workspace.setDescription(workspaceDesc);
209209
} catch (CoreException e) {
210-
// TODO Auto-generated catch block
211-
e.printStackTrace();
210+
Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e));
212211
}
213212
// Make sure some important variables are being initialized
214213
InstancePreferences.setPrivateLibraryPaths(InstancePreferences.getPrivateLibraryPaths());
215214
InstancePreferences.setPrivateHardwarePaths(InstancePreferences.getPrivateHardwarePaths());
216215
InstancePreferences.setAutomaticallyImportLibraries(InstancePreferences.getAutomaticallyImportLibraries());
217-
PackageManager.setJsonURLs(PackageManager.getJsonURLs());
216+
BoardsManager.setJsonURLs(BoardsManager.getJsonURLs());
218217
}
219218

220219
private void runPluginCoreStartInstantiatorJob() {
@@ -252,7 +251,7 @@ protected IStatus run(IProgressMonitor monitor) {
252251

253252
installOtherStuff();
254253

255-
startup_Pluging(monitor);
254+
BoardsManager.startup_Pluging(monitor);
256255

257256
monitor.setTaskName("Done!");
258257
if (InstancePreferences.useBonjour()) {
@@ -418,14 +417,14 @@ private static void installOtherStuff() {
418417
}
419418
if (!localMakePath.append(MAKE_EXE).toFile().exists()) {
420419
IProgressMonitor monitor = new NullProgressMonitor();
421-
Common.log(downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
420+
Common.log(PackageManager.downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
422421
}
423422

424423
// Install awk if needed
425424
IPath localAwkPath = ConfigurationPreferences.getAwkPath();
426425
if (!localAwkPath.append(AWK_EXE).toFile().exists()) {
427426
IProgressMonitor monitor = new NullProgressMonitor();
428-
Common.log(downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
427+
Common.log(PackageManager.downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
429428
}
430429
}
431430
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.sloeber.core.Gson;
2+
3+
import com.google.gson.JsonElement;
4+
import com.google.gson.JsonObject;
5+
6+
import io.sloeber.core.api.VersionNumber;
7+
8+
public class GsonConverter {
9+
public static String getSafeString(JsonObject jsonObject, String fieldName) {
10+
JsonElement field = jsonObject.get(fieldName);
11+
if (field == null) {
12+
return "no info found in file"; //$NON-NLS-1$
13+
}
14+
return field.getAsString();
15+
16+
}
17+
18+
public static VersionNumber getSafeVersion(JsonObject jsonObject, String fieldName) {
19+
JsonElement field = jsonObject.get(fieldName);
20+
if (field == null) {
21+
return new VersionNumber("no version number provided"); //$NON-NLS-1$
22+
}
23+
return new VersionNumber(field.getAsString());
24+
25+
}
26+
27+
public static String getSafeString(JsonObject jsonObject, String fieldName1, String fieldName2) {
28+
JsonElement field = jsonObject.get(fieldName1);
29+
if (field != null) {
30+
field = field.getAsJsonObject().get(fieldName2);
31+
if (field != null) {
32+
return field.getAsString();
33+
}
34+
}
35+
36+
return "no info found in file"; //$NON-NLS-1$
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)