예제 #1
0
 private static void loadSetupLibraries(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements,
     final RSetup setup)
     throws Exception {
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.getName().equals(LIBRARY_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String path = getLocation(element, filter);
       if (path == null) {
         continue;
       }
       final String groupId = element.getAttribute(GROUP_ATTRIBUTE_NAME);
       if (groupId == null || groupId.length() == 0 || groupId.equals("R_LIBS")) { // $NON-NLS-1$
         setup.getRLibs().add(path);
       } else if (groupId.equals("R_LIBS_SITE")) { // $NON-NLS-1$
         setup.getRLibsSite().add(path);
       } else if (groupId.equals("R_LIBS_USER")) { // $NON-NLS-1$
         setup.getRLibsUser().add(path);
       } else {
         log(
             IStatus.WARNING,
             "Invalid R setup element: "
                 + "Unknown library group '"
                 + groupId
                 + "', the library is ignored",
             element);
       }
     }
   }
 }
예제 #2
0
 private static RSetup loadSetup(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements) {
   try {
     for (int i = 0; i < configurationElements.length; i++) {
       final IConfigurationElement element = configurationElements[i];
       if (element.getName().equals(SETUP_ELEMENT_NAME)
           && id.equals(element.getAttribute(ID_ATTRIBUTE_NAME))) {
         final RSetup setup = new RSetup(id);
         if (filter != null && filter.containsKey("$os$")) { // $NON-NLS-1$
           setup.setOS(filter.get("$os$"), filter.get("$arch$")); // $NON-NLS-1$ //$NON-NLS-2$
         } else {
           setup.setOS(Platform.getOS(), Platform.getOSArch());
         }
         setup.setName(element.getAttribute(NAME_ATTRIBUTE_NAME));
         loadSetupBase(id, filter, configurationElements, setup);
         if (setup.getRHome() == null) {
           log(
               IStatus.WARNING,
               "Incomplete R setup: Missing R home for setup '" + id + "', the setup is ignored.",
               element);
           return null;
         }
         loadSetupLibraries(id, filter, configurationElements, setup);
         return setup;
       }
     }
   } catch (final Exception e) {
     LOGGER.log(
         new Status(IStatus.ERROR, PLUGIN_ID, "Error in R setup: Failed to load setup.", e));
   }
   return null;
 }
예제 #3
0
 private static void loadSetupBase(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements,
     final RSetup setup)
     throws Exception {
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.getName().equals(BASE_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String path = getLocation(element, filter);
       setup.setRHome(path);
       return;
     }
   }
   for (int i = 0; i < configurationElements.length; i++) {
     final IConfigurationElement element = configurationElements[i];
     if (element.equals(SETUP_ELEMENT_NAME)
         && id.equals(element.getAttribute(SETUP_ID_ATTRIBUTE_NAME))) {
       final String inheritId = element.getAttribute(INHERIT_BASE_ATTRIBUTE_NAME);
       if (inheritId != null) {
         loadSetupBase(inheritId, filter, configurationElements, setup);
       }
       return;
     }
   }
 }