Java 类org.eclipse.core.runtime.preferences.IPreferencesService 实例源码

项目:openhab-hdl    文件:ConfigurationFolderProvider.java   
private static File getFolderFromPreferences() {
    IPreferencesService service = Platform.getPreferencesService();
    Preferences node = service.getRootNode().node(ConfigurationScope.SCOPE).node(CoreActivator.PLUGIN_ID);
    if(node!=null) {
        String folderPath = node.get(DesignerCoreConstants.CONFIG_FOLDER_PREFERENCE, null);
        if(folderPath!=null) {
            File file = new File(folderPath);
            if(file!=null && file.isDirectory()) {
                return file;
            } else {
                logger.warn("'{}' is no valid directory.", folderPath);
            }
        }
    }
    return null;
}
项目:eclox    文件:Doxygen.java   
/**
 * Retrieves the default doxygen instance to use.
 */
public static Doxygen getDefault() {
    Doxygen doxygen = null;
    // get the actual default preference store
    //final String identifier  = Plugin.getDefault().getPluginPreferences().getString( IPreferences.DEFAULT_DOXYGEN );
    IPreferencesService service = Platform.getPreferencesService();
    final String PLUGIN_ID = Plugin.getDefault().getBundle().getSymbolicName();
    IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences[] nodes = new IEclipsePreferences[] { instanceNode, defaultNode };
    final String identifier = service.get(IPreferences.DEFAULT_DOXYGEN, "", nodes);

    List<Class<? extends Doxygen>> doxygenClassList = new ArrayList<Class<? extends Doxygen>>();
    doxygenClassList.add(DefaultDoxygen.class);
    doxygenClassList.add(CustomDoxygen.class);
    doxygenClassList.add(BundledDoxygen.class);
    for (Class<? extends Doxygen> doxygenClass : doxygenClassList) {
        doxygen = getFromClassAndIdentifier(doxygenClass, identifier);
        if (doxygen != null)
            break;
    }
    return doxygen;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static Set<String> getHiddenWidgets()
{
    final Set<String> deprecated = new HashSet<>();
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
    {
        final String list = prefs.getString(Plugin.ID, "hidden_widget_types", "", null);
        for (String item : list.split(" *, *"))
        {
            final String type = item.trim();
            if (! type.isEmpty())
                deprecated.add(type);
        }
    }
    return deprecated;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Global macros set in preferences, or <code>null</code> */
public static Macros getMacros()
{
    // Fall-back value used in MacroHierarchyUnitTest
    String macro_def = "<EXAMPLE_MACRO>Value from Preferences</EXAMPLE_MACRO><TEST>true</TEST>";
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        macro_def = prefs.getString(ModelPlugin.ID, MACROS, macro_def, null);
    if (macro_def.isEmpty())
        return null;
    try
    {
        return MacroXMLUtil.readMacros(macro_def);
    }
    catch (Exception ex)
    {
        return null;
    }
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static TraceType getTraceType()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
    {
        final String type_name = prefs.getString(Activator.PLUGIN_ID, TRACE_TYPE, TraceType.AREA.name(), null);
        try
        {
            return TraceType.valueOf(type_name);
        }
        catch (Exception ex)
        {
            Activator.getLogger().log(Level.WARNING, "Undefined trace type option '" + type_name + "'", ex);
        }
    }
    return TraceType.AREA;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static ArchiveServerURL[] getArchiveServerURLs()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    final String urls = prefs.getString(Activator.PLUGIN_ID, URLS, "", null).trim();
    if (urls.length() <= 0)
        return new ArchiveServerURL[0];

    ArrayList<ArchiveServerURL> list = new ArrayList<ArchiveServerURL>();
    for (String fragment : urls.split("\\*"))
    {
        String[] strs = fragment.split("\\|");
        if (strs.length == 1)
            list.add(new ArchiveServerURL(strs[0], null));
        else if (strs.length >= 2)
            list.add(new ArchiveServerURL(strs[0], strs[1]));
    }
    return list.toArray(new ArchiveServerURL[list.size()]);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Archive rescale setting */
static public ArchiveRescale getArchiveRescale()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null)
        return ArchiveRescale.STAGGER;
    try
    {
        return ArchiveRescale.valueOf(
                prefs.getString(Activator.PLUGIN_ID, ARCHIVE_RESCALE,
                        ArchiveRescale.STAGGER.name(), null));
    }
    catch (Throwable ex)
    {
        Activator.getLogger().log(Level.WARNING, "Undefined rescale option", ex);
    }
    return ArchiveRescale.STAGGER;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Array where [N][0] is display text and [N][1] is the 'start' time */
static public String[][] getTimespanShortcuts()
{
    String shortcuts = "1 Day,-1 days|7 Days,-7 days";
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        shortcuts = prefs.getString(Activator.PLUGIN_ID, TIME_SPAN_SHORTCUTS, shortcuts, null);
    final List<List<String>> items = new ArrayList<>();
    for (String item : shortcuts.split("\\|"))
    {
        final String[] display_start = item.split(", *");
        if (display_start.length != 2)
        {
            Activator.getLogger().log(Level.WARNING, "Invalid " + TIME_SPAN_SHORTCUTS + " value " + item);
            continue;
        }
        items.add(Arrays.asList(display_start));
    }
    final String[][] result = new String[items.size()][2];
    for (int i=0; i<items.size(); ++i)
    {
        result[i][0] = items.get(i).get(0);
        result[i][1] = items.get(i).get(1);
    }
    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaModelManager.java   
public String getOption(String optionName) {

        if (JavaCore.CORE_ENCODING.equals(optionName)){
            return JavaCore.getEncoding();
        }
        // backward compatibility
        if (isDeprecatedOption(optionName)) {
            return JavaCore.ERROR;
        }
        int optionLevel = getOptionLevel(optionName);
        if (optionLevel != UNKNOWN_OPTION){
            IPreferencesService service = Platform.getPreferencesService();
            String value = service.get(optionName, null, this.preferencesLookup);
            if (value == null && optionLevel == DEPRECATED_OPTION) {
                // May be a deprecated option, retrieve the new value in compatible options
                String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName);
                value = service.get(compatibleOptions[0], null, this.preferencesLookup);
            }
            return value==null ? null : value.trim();
        }
        return null;
    }
项目:parichayana    文件:ParichayanaActivator.java   
public static String getPreference(String name, String defaultValue, IProject project) {
    IEclipsePreferences[] preferencesLookup;
    if (project != null) {
        preferencesLookup = new IEclipsePreferences[] {
                new ProjectScope(project).getNode(PLUGIN_ID),
                InstanceScope.INSTANCE.getNode(PLUGIN_ID),
                DefaultScope.INSTANCE.getNode(PLUGIN_ID)
        };
    } else {
        preferencesLookup = new IEclipsePreferences[] {
                InstanceScope.INSTANCE.getNode(PLUGIN_ID),
                DefaultScope.INSTANCE.getNode(PLUGIN_ID)
        };
    }
    IPreferencesService service = Platform.getPreferencesService();
    String value = service.get(name, defaultValue, preferencesLookup);
    return value;
}
项目:sadlos2    文件:ResourceManager.java   
/**
 * Method to determine, from preferences, the OWL file format to use
 * @return -- the file extension specified by the format selected in preferences
 */
public static String getOwlFileExtension() {
    if (!Platform.isRunning()) {
        return "owl";
    }
    IPreferencesService service = Platform.getPreferencesService();
    String format = service.getString("com.ge.research.sadl.Sadl", "OWL_Format", IConfigurationManager.RDF_XML_ABBREV_FORMAT, null);
    if (format.equals(IConfigurationManager.RDF_XML_ABBREV_FORMAT) || format.equals(IConfigurationManager.RDF_XML_FORMAT)) {
        return "owl";
    }
    else if (format.equals(IConfigurationManager.N3_FORMAT))    {
        return "n3";
    }
    else if (format.equals(IConfigurationManager.N_TRIPLE_FORMAT)) {
        return "nt";
    }
    else {
        return "owl";   // reasonable default?
    }
}
项目:sadlos2    文件:SadlProposalProvider.java   
public String generateBaseUri(URI modelURI) throws MalformedURLException {
    String prefix = "http://sadl.org/" + ResourceManager.getProjectUri(modelURI).lastSegment() + "/";

    IPreferencesService service = Platform.getPreferencesService();
    String value = service.getString("com.ge.research.sadl.Sadl", "baseUri", prefix, null);

       if (value != null && !value.isEmpty()) {
           prefix = value;
           if (!prefix.endsWith("/")) {
            prefix += "/";
           }
       }

    String baseUri = prefix + modelURI.trimFileExtension().lastSegment();
    return baseUri;
}
项目:sadlos2    文件:TestSuiteProposalProvider.java   
public void completeTest_Name(Test test, Assignment assignment, 
        ContentAssistContext context, ICompletionProposalAcceptor acceptor) throws URISyntaxException, IOException {
    IPreferencesService service = Platform.getPreferencesService();
    String value = service.getString("com.ge.research.sadl.Sadl", "importBy", "fn", null);
    boolean useSadlFN = value.equals("fn");

//  super.completeTest_Name(test, assignment, context, acceptor); 
    URI prjUri = ResourceManager.getProjectUri(context.getResource().getURI());
    List<String> possibleFiles = getPossibleFileList(test.eContainer(), useSadlFN, prjUri);
    if (possibleFiles != null) {
        for (int i = 0; i < possibleFiles.size(); i++) {
            String file = possibleFiles.get(i);
            String proposalText = getValueConverter().toString(file, "STRING");
            String displayText = proposalText + " - Uri of Model to test";
            Image image = getImage(test.eContainer());
            ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, image, context);
            acceptor.accept(proposal);          
        }
    }
}
项目:sadlos2    文件:TestSuiteProposalProvider.java   
public void completeModel_Tests(Model model, Assignment assignment, 
        ContentAssistContext context, ICompletionProposalAcceptor acceptor) throws URISyntaxException, IOException {
    IPreferencesService service = Platform.getPreferencesService();
    String value = service.getString("com.ge.research.sadl.Sadl", "importBy", "fn", null);
    boolean useSadlFN = value.equals("fn");

//  super.completeTest_Name(test, assignment, context, acceptor); 
    URI prjUri = ResourceManager.getProjectUri(context.getResource().getURI());
    List<String> possibleFiles = getPossibleFileList(model, useSadlFN, prjUri);
    if (possibleFiles != null && possibleFiles.size() > 0) {
        for (int i = 0; i < possibleFiles.size(); i++) {
            String file = possibleFiles.get(i);
            String proposalText = "Test: " + getValueConverter().toString(file, "STRING") + ".\n";
            String displayText = proposalText + " - Test this Model";
            Image image = getImage(model.eContainer());
            ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, image, context);
            acceptor.accept(proposal);          
        }
    }
}
项目:idecore    文件:ApexAutoIndentStrategy.java   
/**
 * Returns the String to use for indenting based on the General/Editors/Text Editors preferences
 * that are respected by the underlying platform editing code.
 * 
 * @return the String to use for indenting
 */
private static String indentStringFromEditorsUIPreferences() {

    IPreferencesService ps = Platform.getPreferencesService();
    boolean spacesForTabs = ps.getBoolean(
            EditorsUI.PLUGIN_ID,
            AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS,
            false,
            null
            );
    if (spacesForTabs) {
        int tabWidth = ps.getInt(
                EditorsUI.PLUGIN_ID,
                AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH,
                4,
                null
                );
        StringBuilder sb = new StringBuilder(tabWidth);
        for (int i = 0; i < tabWidth; i++) {
            sb.append(" ");
        }
        return sb.toString();
    } else {
        return "\t";
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaModelManager.java   
public String getOption(String optionName) {

        if (JavaCore.CORE_ENCODING.equals(optionName)){
            return JavaCore.getEncoding();
        }
        // backward compatibility
        if (isDeprecatedOption(optionName)) {
            return JavaCore.ERROR;
        }
        int optionLevel = getOptionLevel(optionName);
        if (optionLevel != UNKNOWN_OPTION){
            IPreferencesService service = Platform.getPreferencesService();
            String value = service.get(optionName, null, this.preferencesLookup);
            if (value == null && optionLevel == DEPRECATED_OPTION) {
                // May be a deprecated option, retrieve the new value in compatible options
                String[] compatibleOptions = (String[]) this.deprecatedOptions.get(optionName);
                value = service.get(compatibleOptions[0], null, this.preferencesLookup);
            }
            return value==null ? null : value.trim();
        }
        return null;
    }
项目:workspacemechanic    文件:LastModifiedPreferencesFileTask.java   
/**
 * Applies preferences from a export file using IPreferenceFilter such that other prefs don't
 * get removed. This allows pref fragment files to do the right thing.
 */
private void transfer() {
  InputStream input = null;
  try {
    input = new BufferedInputStream(taskRef.newInputStream());
  } catch (IOException e) {
    log.logError(e);
  }

  IPreferenceFilter[] filters = new IPreferenceFilter[1];
  // Matches all prefs for both Instance and Config scope.
  filters[0] = new IPreferenceFilter() {
      public String[] getScopes() {
          return new String[] {
              InstanceScope.SCOPE,
              ConfigurationScope.SCOPE
          };
      }

      @SuppressWarnings("rawtypes") // Eclipse doesn't do generics.
      public Map getMapping(String scope) {
          return null;
      }
  };

  IPreferencesService service = Platform.getPreferencesService();
  try {
    IExportedPreferences prefs = service.readPreferences(input);
    // Apply the prefs with the filters so they're only imported and others aren't removed.
    service.applyPreferences(prefs, filters);
  } catch (CoreException ex) {
    log.log(ex.getStatus());
  }

}
项目:hybris-commerce-eclipse-plugin    文件:BuildUtils.java   
protected static boolean isAutoBuildEnabled() {
    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
    String key = "description.autobuilding";
    IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE };
    return service.getBoolean(qualifier, key, false, contexts);
}
项目:hybris-commerce-eclipse-plugin    文件:EclipseRefreshAndBuildHandler.java   
protected boolean isAutoBuildEnabled()
{
    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
    String key = "description.autobuilding";
    IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE };
    return service.getBoolean(qualifier, key, false, contexts);
}
项目:hybris-commerce-eclipse-plugin    文件:SynchronizePlatformWizard.java   
protected boolean isAutoBuildEnabled()
{
    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
    String key = "description.autobuilding";
    IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
    return service.getBoolean( qualifier, key, false, contexts );
}
项目:hybris-commerce-eclipse-plugin    文件:ImportPlatformWizard.java   
protected boolean isAutoBuildEnabled()
{
    IPreferencesService service = Platform.getPreferencesService();
    String qualifier = ResourcesPlugin.getPlugin().getBundle().getSymbolicName();
    String key = "description.autobuilding";
    IScopeContext[] contexts = { InstanceScope.INSTANCE, ConfigurationScope.INSTANCE};
    return service.getBoolean( qualifier, key, false, contexts );
}
项目:openhab-hdl    文件:ConfigurationFolderProvider.java   
public static void saveFolderToPreferences(String folderPath) {
    IPreferencesService service = Platform.getPreferencesService();
    Preferences node = service.getRootNode().node(ConfigurationScope.SCOPE).node(CoreActivator.PLUGIN_ID);
    try {
        if(node!=null) {
            node.put(DesignerCoreConstants.CONFIG_FOLDER_PREFERENCE, folderPath);
            node.flush();
            return;
        }
    } catch (BackingStoreException e) {}
    logger.warn("Could not save folder '{}' to preferences.", folderPath);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
private static String get(final String setting, final String default_value)
{
    String value = default_value;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        value = prefs.getString(RuntimePlugin.ID, setting, value, null);
    return value;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getLogPeriodSeconds()
{
    int secs = 5;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        secs = prefs.getInt(ID, "performance_log_period_secs", secs, null);
    return secs;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getLogThresholdMillisec()
{
    int milli = 20;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        milli = prefs.getInt(ID, "performance_log_threshold_ms", milli, null);
    return milli;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getUpdateAccumulationMillisec()
{
    int milli = 20;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        milli = prefs.getInt(ID, "update_accumulation_time", milli, null);
    return milli;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getUpdateDelayMillisec()
{
    int milli = 100;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        milli = prefs.getInt(ID, "update_delay", milli, null);
    return milli;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getPlotUpdateDelayMillisec()
{
    int milli = 100;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        milli = prefs.getInt(ID, "plot_update_delay", milli, null);
    return milli;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Read timeout [ms] */
public static int getReadTimeout()
{
    int timeout = 10000;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        timeout = prefs.getInt(ModelPlugin.ID, READ_TIMEOUT, timeout, null);
    return timeout;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Cache timeout [sec] */
public static int getCacheTimeout()
{
    int timeout = 60;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        timeout = prefs.getInt(ModelPlugin.ID, CACHE_TIMEOUT, timeout, null);
    return timeout;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Legacy font size calibration */
public static double getLegacyFontCalibration()
{
    double factor = 0.75;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        factor = prefs.getDouble(ModelPlugin.ID, LEGACY_FONT_CALIBRATION, factor, null);
    return factor;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @return Maximum number of re-parse operations */
public static int getMaxReparse()
{
    int max_reparse = 5000;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        max_reparse = prefs.getInt(ModelPlugin.ID, MAX_REPARSE_ITERATIONS, max_reparse, null);
    return max_reparse;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
/** @param key Preference key
 *  @param default_value Default value
 *  @return Preference text or default value
 */
public static String getPreference(final String key, final String default_value)
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
        return prefs.getString(ModelPlugin.ID, key, default_value, null);
    return default_value;
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static boolean isAutomaticHistoryRefresh()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null) // Allow some JUnit tests without prefs
        return Boolean.FALSE;
    return prefs.getBoolean(Activator.PLUGIN_ID, AUTOMATIC_HISTORY_REFRESH, Boolean.FALSE, null);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static Duration getTimeSpan()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null) // Allow some JUnit tests without prefs
        return Duration.ofSeconds(60);
    return TimeDuration.ofSeconds(prefs.getDouble(Activator.PLUGIN_ID, TIME_SPAN, 60.0 * 60.0, null));
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static Duration getScrollStep()
{
    int scroll_step = 5;
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs != null)
    {   // Check related legacy preference, then current one
        scroll_step = prefs.getInt(Activator.PLUGIN_ID, "future_buffer", scroll_step, null);
        scroll_step = prefs.getInt(Activator.PLUGIN_ID, SCROLL_STEP, scroll_step, null);
    }
    return Duration.ofSeconds(scroll_step);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getLiveSampleBufferSize()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null) // Allow some JUnit tests without prefs
        return 5000;
    return prefs.getInt(Activator.PLUGIN_ID, BUFFER_SIZE, 5000, null);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static double getUpdatePeriod()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null) // Allow some JUnit tests without prefs
        return 1.0;
    return prefs.getDouble(Activator.PLUGIN_ID, UPDATE_PERIOD, 1.0, null);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getLineWidth()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null)
        return 2;
    return prefs.getInt(Activator.PLUGIN_ID, LINE_WIDTH, 2, null);
}
项目:org.csstudio.display.builder    文件:Preferences.java   
public static int getOpacity()
{
    final IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs == null)
        return 20;
    return prefs.getInt(Activator.PLUGIN_ID, OPACITY, 20, null);
}