/**
   * Based on the selected board and parameters save all info needed to the build environments
   *
   * @param confdesc
   */
  public void saveAllSelections(ICConfigurationDescription confdesc) {
    String boardFile = this.mControlBoardsTxtFile.getText().trim();
    String boardName = this.mcontrolBoardName.getText().trim();
    String uploadPort = this.mControlUploadPort.getValue();
    IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
    IContributedEnvironment contribEnv = envManager.getContributedEnvironment();

    // Set the path variables
    IPath platformPath =
        new Path(new File(this.mControlBoardsTxtFile.getText().trim()).getParent())
            .append(Const.PLATFORM_FILE_NAME);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARDS_FILE, boardFile);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_PLATFORM_FILE, platformPath.toString());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARD_NAME, boardName);
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_COM_PORT, uploadPort);

    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_PACKAGE_ID, getPackage());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_ARCITECTURE_ID, getArchitecture());
    Common.setBuildEnvironmentVariable(
        contribEnv, confdesc, Const.ENV_KEY_JANTJE_BOARD_ID, getBoardID());

    for (LabelCombo curLabelCombo : this.mBoardOptionCombos) {
      curLabelCombo.StoreValue(confdesc);
    }
    saveAllLastUseds();
  }
        @Override
        public void handleEvent(Event e) {
          IEnvironmentVariableManager envManager =
              CCorePlugin.getDefault().getBuildEnvironmentManager();
          IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
          ICConfigurationDescription confdesc = getConfdesc();

          int selectedBoardFile = BoardSelectionPage.this.mControlBoardsTxtFile.getSelectionIndex();
          String boardFile = BoardSelectionPage.this.mControlBoardsTxtFile.getText().trim();
          if (confdesc != null) {
            IEnvironmentVariable var =
                new EnvironmentVariable(Const.ENV_KEY_JANTJE_BOARDS_FILE, boardFile);
            contribEnv.addVariable(var, confdesc);
            IPath platformPath =
                new Path(new File(boardFile).getParent()).append(Const.PLATFORM_FILE_NAME);
            var =
                new EnvironmentVariable(
                    Const.ENV_KEY_JANTJE_PLATFORM_FILE, platformPath.toString());
            contribEnv.addVariable(var, confdesc);
          }

          /*
           * Change the list of available boards
           */
          String CurrentBoard = BoardSelectionPage.this.mcontrolBoardName.getText();
          BoardSelectionPage.this.mcontrolBoardName.removeAll();
          BoardSelectionPage.this.mcontrolBoardName.setItems(
              BoardSelectionPage.this.mAllBoardsFiles[selectedBoardFile].GetArduinoBoards());
          BoardSelectionPage.this.mcontrolBoardName.setText(CurrentBoard);

          BoardSelectionPage.this.BoardModifyListener.handleEvent(null);
        }
 @Override
 public void handleEvent(CProjectDescriptionEvent event) {
   // we are only interested in about to apply
   if (event.getEventType() != CProjectDescriptionEvent.ABOUT_TO_APPLY) return;
   ICProjectDescription projDesc = event.getNewCProjectDescription();
   IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
   IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
   if (projDesc.getActiveConfiguration() != null) {
     IEnvironmentVariable var =
         contribEnv.getVariable(
             ArduinoConst.ENV_KEY_JANTJE_PLATFORM_FILE, projDesc.getActiveConfiguration());
     if (var != null) {
       IPath platformPath = new Path(var.getValue());
       ArduinoHelpers.setProjectPathVariables(
           projDesc.getProject(), platformPath.removeLastSegments(1));
       ArduinoHelpers.setTheEnvironmentVariables(
           projDesc.getProject(), projDesc.getActiveConfiguration(), false);
       try {
         ArduinoHelpers.addArduinoCodeToProject(
             projDesc.getProject(), projDesc.getActiveConfiguration());
       } catch (CoreException e1) {
         Common.log(
             new Status(
                 IStatus.ERROR, ArduinoConst.CORE_PLUGIN_ID, "Error adding the arduino code", e1));
       }
       ArduinoLibraries.reAttachLibrariesToProject(projDesc.getActiveConfiguration());
     }
   }
 }
Exemplo n.º 4
0
  private static Properties calcEnvironment(IConfiguration cfg) {
    Properties envProps = new Properties();
    ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
    IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
    IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
    for (int i = 0; i < vars.length; i++) {
      envProps.setProperty(vars[i].getName(), vars[i].getValue());
    }

    return envProps;
  }
        @Override
        public void handleEvent(Event e) {

          int selectedBoardFile = BoardSelectionPage.this.mControlBoardsTxtFile.getSelectionIndex();
          String boardName = BoardSelectionPage.this.mcontrolBoardName.getText();

          for (LabelCombo curLabelCombo : BoardSelectionPage.this.mBoardOptionCombos) {
            curLabelCombo.setItems(
                BoardSelectionPage.this.mAllBoardsFiles[selectedBoardFile].getMenuItemNames(
                    curLabelCombo.getMenuName(), boardName));
          }

          IEnvironmentVariableManager envManager =
              CCorePlugin.getDefault().getBuildEnvironmentManager();
          IContributedEnvironment contribEnv = envManager.getContributedEnvironment();
          ICConfigurationDescription confdesc = getConfdesc();
          if (confdesc != null) {
            IEnvironmentVariable var =
                new EnvironmentVariable(Const.ENV_KEY_JANTJE_BOARD_NAME, boardName);
            contribEnv.addVariable(var, confdesc);
          }
          isPageComplete();
          EnableControls();
        }