@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());
     }
   }
 }
  private Preferences getProjectNode(ICProjectDescription projDes) {
    if (projDes == null) return null;
    IProject project = projDes.getProject();
    if (!project.exists()) return null;

    Preferences prefNode = new ProjectScope(project).getNode(CCorePlugin.PLUGIN_ID);
    if (prefNode == null) return null;

    return prefNode.node(NODENAME);
  }
Пример #3
0
  @Override
  public void activate() {
    ICConfigurationDescription config = resolveSelectedConfiguration();

    if (config != null) {
      ICProjectDescription desc = config.getProjectDescription();

      if (desc.getActiveConfiguration() != config) {
        try {
          IProject project = desc.getProject();
          desc.setActiveConfiguration(config);
          CoreModel.getDefault().setProjectDescription(project, desc);
        } catch (CoreException e) {
          CUIPlugin.log(e);
        }
      }
    }
  }