コード例 #1
0
 @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());
     }
   }
 }
コード例 #2
0
  /**
   * Notify the ExternalSettingManager that there's been a change in the configuration which may
   * require referencing configs to update their cache of the external settings
   */
  public void handleEvent(CProjectDescriptionEvent event) {
    switch (event.getEventType()) {
      case CProjectDescriptionEvent.LOADED:
        {
          // Bug 312575 on Project load, event.getProjectDelta() == null => report all configs as
          // potentially changed
          // Referencing projects should be reconciled and potentially updated.
          String projName = event.getProject().getName();
          ICConfigurationDescription[] descs =
              event.getNewCProjectDescription().getConfigurations();
          CExternalSettingsContainerChangeInfo[] changeInfos =
              new CExternalSettingsContainerChangeInfo[descs.length + 1];
          int i = 0;
          for (ICConfigurationDescription desc :
              event.getNewCProjectDescription().getConfigurations())
            changeInfos[i++] =
                new CExternalSettingsContainerChangeInfo(
                    CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS,
                    new CContainerRef(FACTORY_ID, createId(projName, desc.getId())),
                    null);
          // Active configuration too
          changeInfos[i] =
              new CExternalSettingsContainerChangeInfo(
                  CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS,
                  new CContainerRef(FACTORY_ID, createId(projName, ACTIVE_CONFIG_ID)),
                  null);
          notifySettingsChange(null, null, changeInfos);
          break;
        }
      case CProjectDescriptionEvent.APPLIED:
        String[] ids = getContainerIds(event.getProjectDelta());
        if (ids.length != 0) {
          CExternalSettingsContainerChangeInfo[] changeInfos =
              new CExternalSettingsContainerChangeInfo[ids.length];

          for (int i = 0; i < changeInfos.length; i++) {
            changeInfos[i] =
                new CExternalSettingsContainerChangeInfo(
                    CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS,
                    new CContainerRef(FACTORY_ID, ids[i]),
                    null);
          }
          notifySettingsChange(null, null, changeInfos);
        }
    }
  }