Exemplo n.º 1
0
 /**
  * @param key the name of the preference (optionally including its path)
  * @param defaultValue the value to use if the preference is not defined
  * @param project optional project object to honor project scoped preferences
  * @return the value of the preference or the given default value
  */
 private String getStringPreferencesValue(String key, String defaultValue, IProject project) {
   IPreferencesService service = Platform.getPreferencesService();
   String qualifier = getSymbolicName();
   if (project != null) {
     IScopeContext[] contexts = new IScopeContext[] {new ProjectScope(project)};
     return service.getString(qualifier, key, defaultValue, contexts);
   } else {
     return service.getString(qualifier, key, defaultValue, null);
   }
 }
 public Map<String, ? extends Object> getInitServerProperties() {
   final Map<String, Object> map = new HashMap<String, Object>();
   final IPreferencesService preferences = Platform.getPreferencesService();
   final AtomicReference<double[]> dpi = new AtomicReference<double[]>();
   dpi.set(
       RGraphicsPreferencePage.parseDPI(
           preferences.getString(
               RGraphics.PREF_DISPLAY_QUALIFIER,
               RGraphics.PREF_DISPLAY_CUSTOM_DPI_KEY,
               null,
               null)));
   if (dpi.get() == null) {
     Display.getDefault()
         .syncExec(
             new Runnable() {
               public void run() {
                 final Point point = Display.getCurrent().getDPI();
                 dpi.set(new double[] {point.x, point.y});
               }
             });
     if (dpi.get() == null) {
       dpi.set(new double[] {96.0, 96.0});
     }
   }
   map.put("display.ppi", dpi.get()); // $NON-NLS-1$
   return map;
 }
Exemplo n.º 3
0
  /**
   * look up a preference value.
   *
   * <p>will return user settings if available or default settings if not. If a system property with
   * the given key is defined it will overrule any existing setting in the preference store. if the
   * key is not defined, this method returns the given default..
   *
   * @param key
   * @return the value or specified default if no such key exists..
   */
  public String getPreferenceValue(String key, String defaultValue) {

    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = getBundle().getSymbolicName();
    String value = service.getString(qualifier, key, defaultValue, null);
    return System.getProperty(key, value);
  }
 public void testBadContext() {
   IScopeContext context = new BadTestScope();
   IPreferencesService service = Platform.getPreferencesService();
   try {
     context.getNode("qualifier");
     fail("0.5"); // should throw an exception
   } catch (RuntimeException e) {
     // expected
   }
   assertNull("1.0", service.getString("qualifier", "foo", null, new IScopeContext[] {context}));
 }
Exemplo n.º 5
0
  private void loadSaved() {
    // Preferences preferences = Activator.getDefault().getPluginPreferences();
    final IPreferencesService service = Platform.getPreferencesService();

    if (toolGroups != null) {
      for (final BinDirPanel toolGroup : toolGroups) {
        toolGroup.binDir.setText(
            service.getString(
                Activator.PLUGIN_ID,
                IToolLaunchConfigurationConstants.TOOL_BIN_ID + "." + toolGroup.group,
                "",
                null)); // ITAULaunchConfigurationConstants.TAU_BIN_PATH)); //$NON-NLS-1$
      }
    }
  }
Exemplo n.º 6
0
 public HeaderSubstitutor(InclusionContext context) {
   fContext = context;
   fIncludeMaps = new IncludeMap[] {new IncludeMap(true), new IncludeMap(false)};
   IPreferencesService preferences = Platform.getPreferencesService();
   IScopeContext[] scopes = PreferenceConstants.getPreferenceScopes(context.getProject());
   String str =
       preferences.getString(
           CUIPlugin.PLUGIN_ID, PreferenceConstants.INCLUDES_HEADER_SUBSTITUTION, null, scopes);
   if (str != null) {
     List<HeaderSubstitutionMap> maps = HeaderSubstitutionMap.deserializeMaps(str);
     for (HeaderSubstitutionMap map : maps) {
       if (!map.isCppOnly() || fContext.isCXXLanguage()) {
         fIncludeMaps[0].addAllMappings(map.getUnconditionalSubstitutionMap());
         fIncludeMaps[1].addAllMappings(map.getOptionalSubstitutionMap());
       }
     }
   }
 }
Exemplo n.º 7
0
 /**
  * Helper method to get a single preference setting, e.g., APT_GENSRCDIR. This is a different
  * level of abstraction than the processor -A settings! The -A settings are all contained under
  * one single preference node, APT_PROCESSOROPTIONS. Use @see #getProcessorOptions(IJavaProject)
  * to get the -A settings; use @see #getOptions(IJavaProject) to get all the preference settings
  * as a map; and use this helper method to get a single preference setting.
  *
  * @param jproj the project, or null for workspace.
  * @param optionName a preference constant from @see AptPreferenceConstants.
  * @return the string value of the setting.
  */
 public static String getString(IJavaProject jproj, String optionName) {
   IPreferencesService service = Platform.getPreferencesService();
   IScopeContext[] contexts;
   if (jproj != null) {
     contexts =
         new IScopeContext[] {
           new ProjectScope(jproj.getProject()), InstanceScope.INSTANCE, DefaultScope.INSTANCE
         };
   } else {
     contexts = new IScopeContext[] {InstanceScope.INSTANCE, DefaultScope.INSTANCE};
   }
   String pluginId = null;
   if (AptPreferenceConstants.APT_PROCESSANNOTATIONS.equals(optionName)) {
     pluginId = JavaCore.PLUGIN_ID;
   } else {
     pluginId = AptPlugin.PLUGIN_ID;
   }
   return service.getString(
       pluginId, optionName, AptPreferenceConstants.DEFAULT_OPTIONS_MAP.get(optionName), contexts);
 }
  /**
   * Generates connection string using user preferences
   *
   * @param dbPath Path to the database files
   * @return
   */
  private String getConnectionString(IPath dbPath) {

    IPreferencesService preferencesService = Platform.getPreferencesService();

    StringBuilder buf = new StringBuilder("jdbc:h2:").append(dbPath.append(DB_NAME).toOSString());

    buf.append(";UNDO_LOG=0");
    buf.append(";LOCK_MODE=")
        .append(
            preferencesService.getInt(
                SymfonyIndex.PLUGIN_ID, SymfonyIndexPreferences.DB_LOCK_MODE, 0, null));

    buf.append(";CACHE_TYPE=")
        .append(
            preferencesService.getString(
                SymfonyIndex.PLUGIN_ID, SymfonyIndexPreferences.DB_CACHE_TYPE, null, null));

    buf.append(";CACHE_SIZE=")
        .append(
            preferencesService.getInt(
                SymfonyIndex.PLUGIN_ID, SymfonyIndexPreferences.DB_CACHE_SIZE, 0, null));

    return buf.toString();
  }
 /**
  * This method should not intended to be used anywhere outside this class. This will be made
  * private once the deprecated J2EEPreferences class is deleted
  */
 static String getString(String name) {
   IPreferencesService preferencesService = Platform.getPreferencesService();
   IScopeContext[] lookupOrder = new IScopeContext[] {new InstanceScope(), new DefaultScope()};
   return preferencesService.getString(
       J2EEPlugin.PLUGIN_ID, name, Defaults.STRING_DEFAULT_DEFAULT, lookupOrder);
 }
Exemplo n.º 10
0
 /**
  * @param setting Preference identifier
  * @param default_value Default value when preferences unavailable
  * @return String from preference system, or <code>null</code>
  */
 private static String getString(final String setting, final String default_value) {
   final IPreferencesService service = Platform.getPreferencesService();
   if (service == null) return default_value;
   return service.getString(Activator.PLUGIN_ID, setting, default_value, null);
 }