Skip to content

Commit

Permalink
Merge pull request #1417 from Sloeber/#1339_Add_deserialisation_clases
Browse files Browse the repository at this point in the history
#1339 add deserialisation clases
  • Loading branch information
jantje authored Dec 5, 2021
2 parents 533582d + 94063a9 commit 636e89a
Show file tree
Hide file tree
Showing 88 changed files with 5,985 additions and 5,796 deletions.
1 change: 1 addition & 0 deletions io.sloeber.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Export-Package: cc.arduino.packages;x-internal:=true,
cc.arduino.packages.ssh;x-internal:=true,
io.sloeber.core;x-friends:="io.sloeber.tests",
io.sloeber.core.api,
io.sloeber.core.api.Json,
io.sloeber.core.builder;x-internal:=true,
io.sloeber.core.common;x-friends:="io.sloeber.tests",
io.sloeber.core.communication;x-internal:=true,
Expand Down
1 change: 0 additions & 1 deletion io.sloeber.core/config/pre_processing_platform_default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ recipe.objcopy.hex.pattern=${recipe.objcopy.bin.pattern}
archive_file=arduino.ar
archive_file_path=${build.path}/${archive_file}
runtime.ide.version=10812
build.system.path=${referenced.core.path}${DirectoryDelimiter}system
serial.port=${com_port}
build.project_name=${ProjName}

Expand Down
15 changes: 7 additions & 8 deletions io.sloeber.core/src/io/sloeber/core/Activator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.sloeber.core;

import static io.sloeber.core.common.Const.*;
import static io.sloeber.core.managers.InternalPackageManager.*;
import static org.eclipse.core.resources.IResource.*;

import java.io.File;
Expand Down Expand Up @@ -42,13 +41,14 @@
import org.osgi.service.prefs.Preferences;

import cc.arduino.packages.discoverers.SloeberNetworkDiscovery;
import io.sloeber.core.api.PackageManager;
import io.sloeber.core.api.BoardsManager;
import io.sloeber.core.common.Common;
import io.sloeber.core.common.ConfigurationPreferences;
import io.sloeber.core.common.InstancePreferences;
import io.sloeber.core.listeners.ConfigurationChangeListener;
import io.sloeber.core.listeners.IndexerListener;
import io.sloeber.core.listeners.resourceChangeListener;
import io.sloeber.core.tools.PackageManager;

/**
* generated code
Expand Down Expand Up @@ -207,14 +207,13 @@ private static void initializeImportantVariables() {
try {
workspace.setDescription(workspaceDesc);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Common.log(new Status(IStatus.ERROR, CORE_PLUGIN_ID, e.getMessage(), e));
}
// Make sure some important variables are being initialized
InstancePreferences.setPrivateLibraryPaths(InstancePreferences.getPrivateLibraryPaths());
InstancePreferences.setPrivateHardwarePaths(InstancePreferences.getPrivateHardwarePaths());
InstancePreferences.setAutomaticallyImportLibraries(InstancePreferences.getAutomaticallyImportLibraries());
PackageManager.setJsonURLs(PackageManager.getJsonURLs());
BoardsManager.setJsonURLs(BoardsManager.getJsonURLs());
}

private void runPluginCoreStartInstantiatorJob() {
Expand Down Expand Up @@ -252,7 +251,7 @@ protected IStatus run(IProgressMonitor monitor) {

installOtherStuff();

startup_Pluging(monitor);
BoardsManager.startup_Pluging(monitor);

monitor.setTaskName("Done!");
if (InstancePreferences.useBonjour()) {
Expand Down Expand Up @@ -418,14 +417,14 @@ private static void installOtherStuff() {
}
if (!localMakePath.append(MAKE_EXE).toFile().exists()) {
IProgressMonitor monitor = new NullProgressMonitor();
Common.log(downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
Common.log(PackageManager.downloadAndInstall(MAKE_URL, MAKE_ZIP, localMakePath, false, monitor));
}

// Install awk if needed
IPath localAwkPath = ConfigurationPreferences.getAwkPath();
if (!localAwkPath.append(AWK_EXE).toFile().exists()) {
IProgressMonitor monitor = new NullProgressMonitor();
Common.log(downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
Common.log(PackageManager.downloadAndInstall(AWK_URL, AWK_ZIP, localAwkPath, false, monitor));
}
}
}
Expand Down
40 changes: 40 additions & 0 deletions io.sloeber.core/src/io/sloeber/core/Gson/GsonConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.sloeber.core.Gson;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import io.sloeber.core.api.VersionNumber;

public class GsonConverter {
public static String getSafeString(JsonObject jsonObject, String fieldName) {
JsonElement field = jsonObject.get(fieldName);
if (field == null) {
return "no info found in file"; //$NON-NLS-1$
}
return field.getAsString();

}

public static VersionNumber getSafeVersion(JsonObject jsonObject, String fieldName) {
JsonElement field = jsonObject.get(fieldName);
if (field == null) {
return new VersionNumber("no version number provided"); //$NON-NLS-1$
}
return new VersionNumber(field.getAsString());

}

public static String getSafeString(JsonObject jsonObject, String fieldName1, String fieldName2) {
JsonElement field = jsonObject.get(fieldName1);
if (field != null) {
field = field.getAsJsonObject().get(fieldName2);
if (field != null) {
return field.getAsString();
}
}

return "no info found in file"; //$NON-NLS-1$

}

}
Loading

0 comments on commit 636e89a

Please sign in to comment.