/**
   * Map public URLs to Alt URLs. Replaces {@link URLHyperlink}s computed by default by instances
   * with the alternative URL.
   *
   * @param hyperlinks
   */
  private IHyperlink[] removeURLHyperlinksOfManagedResources(IHyperlink[] hyperlinks) {
    if (hyperlinks == null) return hyperlinks;

    List<IHyperlink> result = new ArrayList<>(hyperlinks.length);
    for (int i = 0; i < hyperlinks.length; i++) {
      IHyperlink hyperlink = hyperlinks[i];
      if (hyperlink instanceof URLHyperlink) {
        URLHyperlink urlHyperlink = (URLHyperlink) hyperlink;
        String publicUri = urlHyperlink.getURLString();
        IConfigurationManagerForIDE cmgr = null;
        try {
          // get the configuration manager for the edited resource
          IResource editedResource =
              (IResource) getEditor().getEditorInput().getAdapter(IResource.class);
          SadlModelManager visitor =
              sadlModelManagerProvider.get(URI.createURI(editedResource.getLocation().toString()));
          cmgr = visitor.getConfigurationMgr(editedResource.getLocation().toString());

          // map the public URL to the mapped URL
          String altUrl = cmgr.getAltUrlFromPublicUri(publicUri);
          result.add(new URLHyperlinkExt(hyperlink.getHyperlinkRegion(), altUrl));
          // TODO: Actually this hyperlink should not be added
          // but if left out, also no Xtext hyperlink appears. Have to check out why
          // at least this one is mapped
        } catch (ConfigurationException | URISyntaxException | IOException e) {
        }
      } else {
        result.add(hyperlink);
      }
    }
    return result.toArray(hyperlinks);
  }
 private void updateConfigurationOptions(ConfigurationItem configItem) {
   if (configItem == null) {
     return;
   }
   try {
     configurationManager.updateConfiguration(configItem);
     configurationManager.saveConfiguration();
   } catch (ConfigurationException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 protected TranslatorConfigurationDialog(
     Shell parentShell,
     // String translatorCategory,
     // Map<String, ConfigurationOption> config,
     ITranslator _translator,
     IConfigurationManagerForIDE configurationManager2) {
   super(parentShell);
   this.translator = _translator;
   this.translatorCategory = this.translator.getConfigurationCategory();
   this.config = this.translator.getTranslatorConfigurationOptions();
   //		this.translatorCategory = translatorCategory;
   //		this.config = config;
   configurationManager = configurationManager2;
   processConfigurationOptions();
   currentConfig = new HashMap<String, Object>();
   String[] catHier = new String[1];
   catHier[0] = this.translatorCategory;
   try {
     List<ConfigurationItem> cis = configurationManager.getConfiguration(catHier, true);
     if (cis != null && cis.size() > 0) {
       ConfigurationItem ci = cis.get(0);
       List<ConfigurationItem.NameValuePair> nvPairs = ci.getNameValuePairs();
       for (ConfigurationItem.NameValuePair nv : nvPairs) {
         currentConfig.put(nv.getName(), nv.getValue());
       }
     }
   } catch (ConfigurationException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
  private ConfigurationItem constructConfigurationOptions() {
    String[] categoryHierarchy = new String[1];
    categoryHierarchy[0] = this.translatorCategory;
    List<ConfigurationItem> configItems = null;
    try {
      configItems = configurationManager.getConfiguration(categoryHierarchy, true);
    } catch (ConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    logger.debug("Size of configItem = " + (configItems != null ? configItems.size() : 0));
    if (config == null) {
      return null;
    }

    ConfigurationItem configItem;
    if (configItems != null) {
      configItem = configItems.get(0);
    } else {
      configItem = new ConfigurationItem(categoryHierarchy);
    }
    configItem.clearNameValuePairs();
    for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
      String key = entry.getKey();
      ConfigurationOption option = entry.getValue();
      if (key.equalsIgnoreCase("builtin")) {
        continue;
      }
      String optionName = option.getName();
      Object optionValue = option.getValue();
      if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
        optionValue = this.rcps.getString(key);
      } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
        optionValue = this.rcps.getDouble(key);
      } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
        optionValue = this.rcps.getInt(key);
      } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
        optionValue = this.rcps.getBoolean(key);
      } else {
        logger.debug(
            "Error saving configuration option, "
                + optionName
                + ", of type "
                + optionValue.getClass().getName());
      }
      logger.debug("Setting " + optionName + " to " + optionValue.toString());
      ConfigurationItem.NameValuePair nv = configItem.new NameValuePair(optionName, optionValue);
      nv.setConfigType(ConfigurationItem.ConfigurationType.SingleValue);
      configItem.addNameValuePair(nv);
    }
    return configItem;
  }