Search in sources :

Example 1 with ArduinoPlatform

use of io.sloeber.core.api.Json.ArduinoPlatform in project arduino-eclipse-plugin by Sloeber.

the class BoardDescription method getArduinoPlatformPath.

/*
     * get the latest installed arduino platform with the same architecture. This is
     * the platform to use the programmers.txt if no other programmers.txt are
     * found.
     */
public IPath getArduinoPlatformPath() {
    updateWhenDirty();
    ArduinoPlatform platform = BoardsManager.getPlatform(VendorArduino, getArchitecture());
    if (platform == null) {
        return null;
    }
    ArduinoPlatformVersion platformVersion = platform.getNewestInstalled();
    if (platformVersion == null) {
        return null;
    }
    return platformVersion.getInstallPath();
}
Also used : ArduinoPlatformVersion(io.sloeber.core.api.Json.ArduinoPlatformVersion) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform)

Example 2 with ArduinoPlatform

use of io.sloeber.core.api.Json.ArduinoPlatform in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method startup_Pluging.

/**
 * Loads all stuff needed and if this is the first time downloads the avr boards
 * and needed tools
 *
 * @param monitor
 */
public static synchronized void startup_Pluging(IProgressMonitor monitor) {
    loadJsons(ConfigurationPreferences.getUpdateJasonFilesFlag());
    if (!LibraryManager.libsAreInstalled()) {
        LibraryManager.InstallDefaultLibraries(monitor);
    }
    IPath examplesPath = ConfigurationPreferences.getInstallationPathExamples();
    if (!examplesPath.toFile().exists()) {
        // examples are not installed
        // Download arduino IDE example programs
        Common.log(PackageManager.downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE, examplesPath, false, monitor));
    }
    if (!areThereInstalledBoards()) {
        IStatus status = null;
        // if successfully installed the examples: add the boards
        ArduinoPlatform platform = getPlatform(Defaults.DEFAULT_INSTALL_MAINTAINER, Defaults.DEFAULT_INSTALL_ARCHITECTURE);
        // we failed to find arduino avr platform. Take the fiorst one
        if (platform == null) {
            try {
                platform = getPlatforms().get(0);
            } catch (@SuppressWarnings("unused") Exception e) {
            // no need to do anything
            }
        }
        if (platform == null) {
            status = new Status(IStatus.ERROR, Activator.getId(), Messages.No_Platform_available);
        } else {
            status = install(platform.getNewestVersion(), monitor);
        }
        if (!status.isOK()) {
            StatusManager stMan = StatusManager.getManager();
            stMan.handle(status, StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK);
        }
    }
    myIsReady = true;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) StatusManager(org.eclipse.ui.statushandlers.StatusManager) IPath(org.eclipse.core.runtime.IPath) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 3 with ArduinoPlatform

use of io.sloeber.core.api.Json.ArduinoPlatform in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method getNewestBoardIDFromBoardsManager.

private static BoardDescription getNewestBoardIDFromBoardsManager(String jsonFileName, String packageName, String architectureName, String boardID, Map<String, String> options) {
    ArduinoPackage thePackage = getPackage(jsonFileName, packageName);
    if (thePackage == null) {
        // fail("failed to find package:" + this.mPackageName);
        return null;
    }
    ArduinoPlatform platform = thePackage.getPlatform(architectureName);
    if (platform == null) {
        // package:" + this.mPackageName);
        return null;
    }
    ArduinoPlatformVersion platformVersion = platform.getNewestVersion();
    java.io.File boardsFile = platformVersion.getBoardsFile();
    BoardDescription boardid = new BoardDescription(boardsFile, boardID, options);
    return boardid;
}
Also used : ArduinoPlatformVersion(io.sloeber.core.api.Json.ArduinoPlatformVersion) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) File(java.io.File)

Example 4 with ArduinoPlatform

use of io.sloeber.core.api.Json.ArduinoPlatform in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method installLatestPlatform.

public static void installLatestPlatform(String JasonName, String packageName, String architectureName) {
    if (!isReady()) {
        Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
        return;
    }
    envVarsNeedUpdating = true;
    ArduinoPackage curPackage = getPackage(JasonName, packageName);
    if (curPackage != null) {
        ArduinoPlatform curPlatform = curPackage.getPlatform(architectureName);
        if (curPlatform != null) {
            ArduinoPlatformVersion curPlatformVersion = curPlatform.getNewestVersion();
            if (curPlatformVersion != null) {
                NullProgressMonitor monitor = new NullProgressMonitor();
                install(curPlatformVersion, monitor);
                return;
            }
        }
    }
    Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "failed to find " + JasonName + " " + packageName + " " + architectureName));
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ArduinoPlatformVersion(io.sloeber.core.api.Json.ArduinoPlatformVersion) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 5 with ArduinoPlatform

use of io.sloeber.core.api.Json.ArduinoPlatform in project arduino-eclipse-plugin by Sloeber.

the class BoardsManager method installsubsetOfLatestPlatforms.

/**
 * installs a subset of the latest platforms It skips the first <fromIndex>
 * platforms And stops at <toIndex> platforms. To install the 5 first latest
 * platforms installsubsetOfLatestPlatforms(0,5)
 *
 * @param fromIndex
 *            the platforms at the start to skip
 * @param toIndex
 *            the platforms after this platform are skipped
 */
public static void installsubsetOfLatestPlatforms(int fromIndex, int toIndex) {
    if (!isReady()) {
        Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, BoardsManagerIsBussy, new Exception()));
        return;
    }
    envVarsNeedUpdating = true;
    int currPlatformIndex = 1;
    NullProgressMonitor monitor = new NullProgressMonitor();
    List<ArduinoPackage> allPackages = getPackages();
    for (ArduinoPackage curPackage : allPackages) {
        Collection<ArduinoPlatform> latestPlatforms = curPackage.getPlatforms();
        for (ArduinoPlatform curPlatform : latestPlatforms) {
            if (currPlatformIndex > fromIndex) {
                install(curPlatform.getNewestVersion(), monitor);
            }
            if (currPlatformIndex++ > toIndex)
                return;
        }
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus) Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ArduinoPlatform(io.sloeber.core.api.Json.ArduinoPlatform) ArduinoPackage(io.sloeber.core.api.Json.ArduinoPackage) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)8 ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)6 ArduinoPlatformVersion (io.sloeber.core.api.Json.ArduinoPlatformVersion)6 MyMultiStatus (io.sloeber.core.tools.MyMultiStatus)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 IStatus (org.eclipse.core.runtime.IStatus)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)3 Status (org.eclipse.core.runtime.Status)3 BoardDescription (io.sloeber.core.api.BoardDescription)2 LinkedList (java.util.LinkedList)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ArduinoPlatformPackageIndex (io.sloeber.core.api.Json.ArduinoPlatformPackageIndex)1 File (java.io.File)1 IPath (org.eclipse.core.runtime.IPath)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 ICheckStateProvider (org.eclipse.jface.viewers.ICheckStateProvider)1