Search in sources :

Example 1 with StatusManager

use of org.eclipse.ui.statushandlers.StatusManager in project arduino-eclipse-plugin by Sloeber.

the class Common method log.

/**
 * Logs the status information
 *
 * @param status
 *            the status information to log
 */
public static void log(IStatus status) {
    if (status.getSeverity() == IStatus.ERROR) {
        int style = StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK;
        StatusManager stMan = StatusManager.getManager();
        stMan.handle(status, style);
    } else {
        Activator.getDefault().getLog().log(status);
    }
}
Also used : StatusManager(org.eclipse.ui.statushandlers.StatusManager)

Example 2 with StatusManager

use of org.eclipse.ui.statushandlers.StatusManager in project arduino-eclipse-plugin by Sloeber.

the class InternalPackageManager 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 void startup_Pluging(IProgressMonitor monitor) {
    loadJsons(ConfigurationPreferences.getUpdateJasonFilesFlag());
    List<Board> allBoards = getInstalledBoards();
    if (!LibraryManager.libsAreInstalled()) {
        LibraryManager.InstallDefaultLibraries(monitor);
    }
    if (allBoards.isEmpty()) {
        // If boards are installed do nothing
        // $NON-NLS-1$
        MyMultiStatus mstatus = new MyMultiStatus("Failed to configer Sloeber");
        // Download sample programs
        mstatus.addErrors(downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE, ConfigurationPreferences.getInstallationPathExamples(), false, monitor));
        if (mstatus.isOK()) {
            // if successfully installed the examples: add the boards
            Package pkg = getPackageIndices().get(0).getPackages().get(0);
            if (pkg != null) {
                ArduinoPlatform platform = pkg.getLatestPlatform(Defaults.PLATFORM_NAME, false);
                if (platform == null) {
                    ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
                    pkg.getLatestPlatforms().toArray(platformList);
                    platform = platformList[0];
                }
                if (platform != null) {
                    mstatus.addErrors(downloadAndInstall(platform, false, monitor));
                }
            }
        }
        if (!mstatus.isOK()) {
            StatusManager stMan = StatusManager.getManager();
            stMan.handle(mstatus, StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK);
        }
    }
    myIsReady = true;
}
Also used : StatusManager(org.eclipse.ui.statushandlers.StatusManager) MyMultiStatus(io.sloeber.core.tools.MyMultiStatus)

Example 3 with StatusManager

use of org.eclipse.ui.statushandlers.StatusManager 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 4 with StatusManager

use of org.eclipse.ui.statushandlers.StatusManager in project arduino-eclipse-plugin by Sloeber.

the class Activator method log.

/**
 * Logs the status information
 *
 * @param status
 *            the status information to log
 */
public static void log(IStatus status) {
    int style;
    if (status.getSeverity() == IStatus.ERROR) {
        style = StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK;
        StatusManager stMan = StatusManager.getManager();
        stMan.handle(status, style);
    } else {
        Activator.getDefault().getLog().log(status);
    }
}
Also used : StatusManager(org.eclipse.ui.statushandlers.StatusManager)

Aggregations

StatusManager (org.eclipse.ui.statushandlers.StatusManager)4 MyMultiStatus (io.sloeber.core.tools.MyMultiStatus)2 ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1