Search in sources :

Example 16 with BoardDescription

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

the class BoardSelectionPage method updateScreen.

@Override
protected void updateScreen() {
    disableListeners = true;
    BoardDescription boardDesc = (BoardDescription) getDescription(getConfdesc());
    myControlBoardsTxtFile.setText(tidyUpLength(boardDesc.getReferencingBoardsFile().toString()));
    mycontrolBoardName.setItems(boardDesc.getCompatibleBoards());
    mycontrolBoardName.setText(boardDesc.getBoardName());
    String CurrentUploadProtocol = myControlUploadProtocol.getText();
    myControlUploadProtocol.setItems(boardDesc.getUploadProtocols());
    myControlUploadProtocol.setText(CurrentUploadProtocol);
    if (myControlUploadProtocol.getText().trim().isEmpty()) {
        myControlUploadProtocol.setText(boardDesc.getProgrammer());
    }
    myControlUploadPort.setText(boardDesc.getUploadPort());
    setTheLabelCombos(boardDesc);
    disableListeners = false;
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription)

Example 17 with BoardDescription

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

the class NewSketchWizard method performFinish.

@Override
public boolean performFinish() {
    if (this.mProject != null) {
        return true;
    }
    BoardDescription boardDescription = this.mArduinoPage.getBoardDescriptor();
    CodeDescription codeDescription = this.mNewArduinoSketchWizardCodeSelectionPage.getCodeDescription();
    CompileDescription compileDescription = new CompileDescription();
    URI locationURI = (!this.mWizardPage.useDefaults()) ? this.mWizardPage.getLocationURI() : null;
    compileDescription.setEnableParallelBuild(MyPreferences.getEnableParallelBuildForNewProjects());
    boardDescription.saveUserSelection();
    this.mProject = SloeberProject.createArduinoProject(this.mWizardPage.getProjectName(), locationURI, boardDescription, codeDescription, compileDescription, new NullProgressMonitor());
    if (this.mProject == null) {
        log(new Status(IStatus.ERROR, PLUGIN_ID, Messages.ui_new_sketch_error_failed_to_create_project));
        return false;
    }
    // so now we set Eclipse to the right perspective and switch to our just
    // created project
    BasicNewProjectResourceWizard.updatePerspective(this.mConfig);
    IWorkbenchWindow TheWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    BasicNewResourceWizard.selectAndReveal(this.mProject, TheWindow);
    return true;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) BoardDescription(io.sloeber.core.api.BoardDescription) CodeDescription(io.sloeber.core.api.CodeDescription) CompileDescription(io.sloeber.core.api.CompileDescription) URI(java.net.URI)

Example 18 with BoardDescription

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

the class NewSketchWizardCodeSelectionPage method validatePage.

/**
 * @name validatePage() Check if the user has provided all the info to create
 *       the project. If so enable the finish button.
 */
protected void validatePage() {
    switch(getCodeType()) {
        case None:
        case defaultIno:
        case defaultCPP:
            // default and no file always works
            setPageComplete(true);
            break;
        case CustomTemplate:
            IPath templateFolder = new Path(myTemplateFolderEditor.getStringValue());
            File cppFile = templateFolder.append(CodeDescription.DEFAULT_SKETCH_CPP).toFile();
            File headerFile = templateFolder.append(CodeDescription.DEFAULT_SKETCH_H).toFile();
            File inoFile = templateFolder.append(CodeDescription.DEFAULT_SKETCH_INO).toFile();
            boolean existFile = inoFile.isFile() || (cppFile.isFile() && headerFile.isFile());
            setPageComplete(existFile);
            break;
        case sample:
            BoardDescription mySelectedBoardDesc = myArduinoPage.getBoardDescriptor();
            if (!mySelectedBoardDesc.equals(myCurrentBoardDesc)) {
                myCurrentBoardDesc = new BoardDescription(mySelectedBoardDesc);
                myExampleEditor.AddAllExamples(myCurrentBoardDesc, myCodedescriptor.getExamples());
            }
            setPageComplete(myExampleEditor.isSampleSelected());
            break;
        default:
            setPageComplete(false);
            break;
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) File(java.io.File)

Example 19 with BoardDescription

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

the class SloeberBuildRunner method invokeBuild.

@Override
public boolean invokeBuild(int kind, IProject project, IConfiguration configuration, IBuilder builder, IConsole console, IMarkerGenerator markerGenerator, IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor) throws CoreException {
    String theBuildTarget = builder.getFullBuildTarget();
    String actualUploadPort = Const.EMPTY;
    List<String> stopSerialOnBuildTargets = List.of(Preferences.getDisconnectSerialTargetsList());
    if (stopSerialOnBuildTargets.contains(theBuildTarget)) {
        SloeberProject sloeberProject = SloeberProject.getSloeberProject(project);
        if (sloeberProject != null) {
            BoardDescription myBoardDescriptor = sloeberProject.getBoardDescription(configuration.getName(), true);
            if (myBoardDescriptor != null) {
                actualUploadPort = myBoardDescriptor.getActualUploadPort();
                if (actualUploadPort == null) {
                    actualUploadPort = Const.EMPTY;
                }
            }
        }
    }
    boolean theComPortIsPaused = false;
    if (!actualUploadPort.isBlank()) {
        try {
            theComPortIsPaused = SerialManager.pauseSerialMonitor(actualUploadPort);
        } catch (Exception e) {
            Status ret = new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, Messages.Upload_Error_com_port, e);
            Common.log(ret);
        }
    }
    Job job = new // $NON-NLS-1$
    Job(// $NON-NLS-1$
    "Start build Activator") {

        @Override
        protected IStatus run(IProgressMonitor _monitor) {
            try {
                // $NON-NLS-1$
                String buildflag = "FbStatus";
                char[] uri = { 'h', 't', 't', 'p', ':', '/', '/', 'b', 'a', 'e', 'y', 'e', 'n', 's', '.', 'i', 't', '/', 'e', 'c', 'l', 'i', 'p', 's', 'e', '/', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '/', 'b', 'u', 'i', 'l', 'd', 'S', 't', 'a', 'r', 't', '.', 'h', 't', 'm', 'l', '?', 'b', '=' };
                IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode(NODE_ARDUINO);
                int curFsiStatus = myScope.getInt(buildflag, 0) + 1;
                myScope.putInt(buildflag, curFsiStatus);
                try {
                    myScope.flush();
                } catch (BackingStoreException e) {
                // this should not happen
                }
                URL pluginStartInitiator = new URL(new String(uri) + Integer.toString(curFsiStatus));
                pluginStartInitiator.getContent();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.DECORATE);
    job.schedule();
    boolean ret = super.invokeBuild(kind, project, configuration, builder, console, markerGenerator, projectBuilder, monitor);
    if (theComPortIsPaused) {
        try {
            SerialManager.resumeSerialMonitor(actualUploadPort);
        } catch (Exception e) {
            Status ret2 = new Status(IStatus.WARNING, Const.CORE_PLUGIN_ID, Messages.Upload_Error_serial_monitor_restart, e);
            Common.log(ret2);
        }
    }
    return ret;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) SloeberProject(io.sloeber.core.api.SloeberProject) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) BackingStoreException(org.osgi.service.prefs.BackingStoreException) CoreException(org.eclipse.core.runtime.CoreException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) URL(java.net.URL) BoardDescription(io.sloeber.core.api.BoardDescription) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job)

Example 20 with BoardDescription

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

the class NightlyBoardPatronTest method testExamples.

@Test
public void testExamples() {
    myBuildCounter++;
    Assume.assumeTrue("Skipping first " + mySkipAtStart + " tests", myBuildCounter >= mySkipAtStart);
    Assume.assumeTrue("To many fails. Stopping test", myTotalFails < maxFails);
    ArrayList<IPath> paths = new ArrayList<>();
    paths.add(myExample.getPath());
    CodeDescription codeDescriptor = CodeDescription.createExample(false, paths);
    Map<String, String> boardOptions = myBoardID.getBoardOptions(myExample);
    BoardDescription boardDescriptor = myBoardID.getBoardDescriptor();
    boardDescriptor.setOptions(boardOptions);
    if (!Shared.BuildAndVerify(myBoardID.getBoardDescriptor(), codeDescriptor, myCompileOptions, myBuildCounter)) {
        myTotalFails++;
        fail(Shared.getLastFailMessage());
    }
}
Also used : BoardDescription(io.sloeber.core.api.BoardDescription) IPath(org.eclipse.core.runtime.IPath) CodeDescription(io.sloeber.core.api.CodeDescription) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

BoardDescription (io.sloeber.core.api.BoardDescription)30 CodeDescription (io.sloeber.core.api.CodeDescription)16 Test (org.junit.Test)15 CompileDescription (io.sloeber.core.api.CompileDescription)13 IProject (org.eclipse.core.resources.IProject)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)12 IPath (org.eclipse.core.runtime.IPath)10 CoreException (org.eclipse.core.runtime.CoreException)7 SloeberProject (io.sloeber.core.api.SloeberProject)6 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)4 ICConfigurationDescription (org.eclipse.cdt.core.settings.model.ICConfigurationDescription)4 ICProjectDescription (org.eclipse.cdt.core.settings.model.ICProjectDescription)4 File (java.io.File)3 Parameters (org.junit.runners.Parameterized.Parameters)3 ArduinoPackage (io.sloeber.core.api.Json.ArduinoPackage)2 ArduinoPlatform (io.sloeber.core.api.Json.ArduinoPlatform)2 ArduinoPlatformVersion (io.sloeber.core.api.Json.ArduinoPlatformVersion)2 MCUBoard (io.sloeber.providers.MCUBoard)2 URL (java.net.URL)2