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

项目:CodeCheckerEclipsePlugin    文件:CcConfiguration.java   
public void init() {        
    globalPreferences = ConfigurationScope.INSTANCE.getNode(CodeCheckerNature.NATURE_ID);
    defaults=new HashMap<ConfigTypes,String>();
    defaults.put(ConfigTypes.COMPILERS,"gcc:g++:clang");
    defaults.put(ConfigTypes.ANAL_THREADS,"4");
    defaults.put(ConfigTypes.IS_GLOBAL,"true");

    configKeys=new HashMap<ConfigTypes,String>();
    configKeys.put(ConfigTypes.CHECKER_PATH,"global_server_url");
    configKeys.put(ConfigTypes.PYTHON_PATH,"location_prefix");
    configKeys.put(ConfigTypes.COMPILERS,"compilers");
    configKeys.put(ConfigTypes.ANAL_THREADS,"analthreads");
    configKeys.put(ConfigTypes.CHECKER_LIST,"global_checker_command");
    configKeys.put(ConfigTypes.IS_GLOBAL,"is_global");
    configKeys.put(ConfigTypes.CHECKER_WORKSPACE,"checker_workspace");        
}
项目:bts    文件:RemoteDBConnectionProviderImpl.java   
private void initDBHost()
{
    if (remote_db_url == null || remote_db_url.trim().length() == 0)
    {
        remote_db_url = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app").get(BTSPluginIDs.PREF_REMOTE_DB_URL, null);
    }
    if (remote_db_url != null && remote_db_url.trim().length() > 0)
    {
        try
        {
            URL url = new URL(remote_db_url);
            protocol = url.getProtocol();
            host = url.getHost();
            port = url.getPort();
        } catch (MalformedURLException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    System.out.println("CouchDBDao initDBHost " + remote_db_url);

}
项目:bts    文件:TextAnnotationsPart.java   
@Inject
@Optional
void eventReceivedPreferencesChanged(
        @EventTopic("event_preferences_changed/*") final String preferencePath) {
    if (preferencePath != null && preferencePath.endsWith(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS)) {

        sync.asyncExec(new Runnable() {
            @Override
            public void run() {
                Preferences rootNode = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
                annotationSettings = (EclipsePreferences) rootNode.node(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS);
                AnnotationToolbarItemCreator.processAndUpateToolbarItemsAnnotationShortcut(part, annotationSettings);
                textAnnotatationEditor.reloadCurrentSentence();
            }
        });

    }
}
项目:bts    文件:PreferenceStoreAccessImpl.java   
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
    lazyInitialize();
    if (context instanceof IFileEditorInput) {
        context = ((IFileEditorInput) context).getFile().getProject();
    }
    if (context instanceof IProject) {
        ProjectScope projectScope = new ProjectScope((IProject) context);
        FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
        result.setSearchContexts(new IScopeContext[] {
            projectScope,
            new InstanceScope(),
            new ConfigurationScope()
        });
        return result;
    }
    return getWritablePreferenceStore();
}
项目:bts    文件:CorpusSettingsPage.java   
/**
     * Initialize the preference page.
     */
    public void init(IWorkbench workbench) {
//      BundleContext bundleContext = Platform.getBundle("org.bbaw.bts.ui.main").getBundleContext();
        context = StaticAccessController.getContext();
        corpusController = context.get(CorpusNavigatorController.class);
        prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app");
        IEclipsePreferences defaultpref = DefaultScope.INSTANCE.getNode("org.bbaw.bts.app");

        main_corpus_key = prefs.get(BTSPluginIDs.PREF_MAIN_CORPUS_KEY, defaultpref.get(BTSPluginIDs.PREF_MAIN_CORPUS_KEY, null));
        active_corpora = prefs.get(BTSPluginIDs.PREF_ACTIVE_CORPORA, defaultpref.get(BTSPluginIDs.PREF_ACTIVE_CORPORA, null));
        logger = context.get(Logger.class);

        loadListInput();

        activate = prefs.getBoolean(BTSPluginIDs.PREF_CORPUS_ACTIVATE_MAIN_CORPUS_SELECTION, false);
        initialActivate = new Boolean(activate);
        mainCorpusComboViewer.getCombo().setEnabled(activate);
        activateButton.setSelection(activate);

    }
项目:bts    文件:TextAnnotationSettingsPage.java   
/**
 * @return
 */
private List<EclipsePreferences> loadAnnotationPreferenceNodes() {
    Preferences rootNode = ConfigurationScope.INSTANCE.getNode(Activator.BUNDLE_ID);

    annotationsNode = (EclipsePreferences) rootNode.node(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS);
    List<EclipsePreferences> nodes = new Vector<EclipsePreferences>();
    if (annotationsNode != null)
    {
        try {
            for (String n : annotationsNode.childrenNames())
            {
                if (annotationsNode.nodeExists(n))
                {
                    nodes.add((EclipsePreferences) annotationsNode.node(n));
                }
            }
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }

    return nodes;
}
项目:plan    文件:NWDays.java   
@Override
public boolean performOk() {
    Preferences preferences = ConfigurationScope.INSTANCE.getNode("org.mdpm.lng.plan.preferences");
    preferences.putBoolean("sunday", sunday.getSelection());
    preferences.putBoolean("monday", monday.getSelection());
    preferences.putBoolean("tuesday", tuesday.getSelection());
    preferences.putBoolean("wednesday", wednesday.getSelection());
    preferences.putBoolean("thursday", thursday.getSelection());
    preferences.putBoolean("friday", friday.getSelection());
    preferences.putBoolean("saturday", saturday.getSelection());
    String tmp="";
    if(dates.getItemCount()>0){
    for (int k=0; k<dates.getItemCount();k++){
        tmp = tmp+dates.getItem(k)+",";
    }
    }
    preferences.put("dates",tmp);
    //preferences.put
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
    return super.performOk();
}
项目: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;
}
项目:org.csstudio.display.builder    文件:Activator.java   
/** {@inheritDoc} */
@Override
public void start(BundleContext context) throws Exception
{
    super.start(context);
    if (SingleSourcePlugin.getUIHelper().getUI() == UI.RAP)
    {
        // Is this necessary?
        // RAPCorePlugin adds the "server" scope for all plugins,
        // but starts too late...
        Platform.getPreferencesService().setDefaultLookupOrder(
                PLUGIN_ID, null,
                new String[]
                        {
                                InstanceScope.SCOPE,
                                ConfigurationScope.SCOPE,
                                "server",
                                DefaultScope.SCOPE
                        });
    }
    plugin = this;
}
项目:wsprefs-transferrer    文件:PreferencesImportStartup.java   
private IPreferenceFilter[] getPreferenceImportFilters() {
  IPreferenceFilter filter = new IPreferenceFilter() {

    /** {@inheritDoc} */
    @Override
    public String[] getScopes() {
      return new String[] {ConfigurationScope.SCOPE, InstanceScope.SCOPE};
    }

    /** {@inheritDoc} */
    @Override
    public Map<?, ?> getMapping(String scope) {
      return null;
    }
  };

  return new IPreferenceFilter[] {filter};
}
项目:AgentWorkbench    文件:BundleProperties.java   
/**
 * Returns the eclipse preferences.
 * @return the eclipse preferences
 */
public IEclipsePreferences getEclipsePreferences() {
    if (eclipsePreferences==null) {
        IScopeContext iScopeContext = ConfigurationScope.INSTANCE;
        eclipsePreferences = iScopeContext.getNode(PlugInActivator.PLUGIN_ID);
        eclipsePreferences.addPreferenceChangeListener(this.getChangeListener());
    }
    return eclipsePreferences;
}
项目:neoscada    文件:Activator.java   
public static TimeZone getTimeZone ()
{
    final IScopeContext[] scopeContext = new IScopeContext[] { ConfigurationScope.INSTANCE };
    final String tzId = Platform.getPreferencesService ().getString ( PLUGIN_ID, TIME_ZONE_KEY, TimeZone.getDefault ().getID (), scopeContext );
    if ( Arrays.asList ( TimeZone.getAvailableIDs () ).contains ( tzId ) )
    {
        return TimeZone.getTimeZone ( tzId );
    }
    return TimeZone.getDefault ();
}
项目:eclipse-plugin-commander    文件:EclipsePreferencesSerializer.java   
public EclipsePreferencesSerializer<T> saveSettings(final T settings) {
    IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(prefereneceId);
    Gson gson = new Gson();
    preferences.put(preferenceKey, gson.toJson(settings));
    try {
        preferences.flush();
    } catch (BackingStoreException e) {
        throw new RuntimeException(e);
    }
    return this;
}
项目:eclipse-plugin-commander    文件:EclipsePreferencesSerializer.java   
@SuppressWarnings("unchecked")
public T loadSettings(final Class<?> settingsTypeClass) {
    IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(prefereneceId);
    Gson gson = new Gson();
    String keyValue = preferences.get(preferenceKey, null);
    if (keyValue != null) {
        return (T) gson.fromJson(keyValue, settingsTypeClass );
    }
    return null;
}
项目:com.onpositive.prefeditor    文件:FolderViewerPage.java   
public void folderChoosed(String folderPath) {
    this.folderPath = folderPath;
    doResetProvider();
    IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(PrefEditorPlugin.PLUGIN_ID);
    node.put(CHOOSED_FOLDER_PREF, folderPath);
    try {
        node.flush();
    } catch (BackingStoreException e) {
        PrefEditorPlugin.log(e);
    }
    setViewerTitle(folderPath);
}
项目: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());
  }

}
项目:google-cloud-eclipse    文件:PreferenceResolver.java   
/**
 * Resolve the given scheme to a preference scope.
 * 
 * @param scheme the preference scheme
 * @return the corresponding preference scope
 * @throws IllegalArgumentException if unable to resolve the scheme to a preference scope
 */
private static IScopeContext resolveScopeContext(String scheme) throws IllegalArgumentException {
  switch (scheme) {
    case "instance":
      return InstanceScope.INSTANCE;
    case "configuration":
      return ConfigurationScope.INSTANCE;
    default:
      throw new IllegalArgumentException("Unknown scheme: " + scheme);
  }
}
项目: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 );
}
项目:ForgedUI-Eclipse    文件:ActivationService.java   
public void clearActivation() {

        IEclipsePreferences prefs = new ConfigurationScope()
                .getNode(GUIEditorPlugin.PLUGIN_ID);

        prefs.remove(USER_ID_PROP_NAME);
        prefs.remove(ACTIVATION_V_PROP_NAME);
        try {
            prefs.flush();
        } catch (BackingStoreException e) {
            logError("Error resetting pres", e);
        }

    }
项目:bts    文件:BTSConfigurationServiceImpl.java   
@Override
public BTSConfiguration getActiveConfiguration()
{
    BTSConfiguration activeConfig = (BTSConfiguration) context.get(BTSPluginIDs.ACTIVE_CONFIGURATION);
    if (activeConfig != null)
    {
        return (BTSConfiguration) activeConfig;
    }
    List<BTSConfiguration> list = list(BTSConstants.OBJECT_STATE_ACTIVE, null);
    if (list == null || list.isEmpty())
    {
        return null;
    }

    activeConfig = list.get(0);
    if (active_configuration_name == null)
    {
        active_configuration_name = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app").get(BTSPluginIDs.ACTIVE_CONFIGURATION, null); 
    }
    for (BTSConfiguration c : list) {
        if (active_configuration_name.equals(c.getProvider())) {
            activeConfig = c;
            break;
        }
    }
    context.set(BTSPluginIDs.ACTIVE_CONFIGURATION, activeConfig);
    return activeConfig;
}
项目:bts    文件:TextAnnotationsPart.java   
@PostConstruct
    public void createPartControl(Composite parent) {
        if (parentShell == null)
        {
            parentShell = new Shell();
        }
        try {
            part = partService.findPart(PART_ID);
        } catch (Exception e) {
//          logger.warn("Part Service couldn't find org.fuberlin.bts.ui.corpus.egy.annotations.TextAnnotationsPart ");
            e.printStackTrace();
        }
        parent.setLayout(new GridLayout());
        ((GridLayout) parent.getLayout()).marginHeight = 0;
        ((GridLayout) parent.getLayout()).marginWidth = 0;
//      contextService
//              .activateContext("org.eclipse.ui.contexts.dialogAndWindow");
        IEclipseContext child = context.createChild();
        child.set(Composite.class, parent);
        child.set(IBTSEditor.class, TextAnnotationsPart.this);
        textAnnotatationEditor = ContextInjectionFactory.make(
                TextAnnotationsComposite.class, child);

        // load annotatin styling settings node
        Preferences rootNode = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus");
        annotationSettings = (EclipsePreferences) rootNode.node(BTSCorpusConstants.PREF_ANNOTATION_SETTINGS);
        AnnotationToolbarItemCreator.processAndUpateToolbarItemsAnnotationShortcut(part, annotationSettings);

        Map<String, Boolean> filters = (Map<String, Boolean>) context.get("org.bbaw.bts.corpus.annotationsPart.filter");
        textAnnotatationEditor.setFilters(filters );
        if (text != null)
        {
            loadInput(text);
        }

        parent.layout();
        parent.pack();
        constructed = true;
    }
项目:bts    文件:AbstractPreferencePage.java   
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
    boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
    link.setEnabled(!isUseProjectSettings);
    if (!isUseProjectSettings) {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] { new InstanceScope(),
                new ConfigurationScope() });
    }
    else {
        ((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] {
                new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
    }
    updateFieldEditors(isUseProjectSettings);
}
项目:bts    文件:PreferenceStoreAccessImpl.java   
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore() {
    lazyInitialize();
    FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(new InstanceScope(), getQualifier());
    result.setSearchContexts(new IScopeContext[] {
        new InstanceScope(),
        new ConfigurationScope()
    });
    return result;
}
项目:bts    文件:OpenWebHelpHandler.java   
@Execute
public void execute() {
    IEclipsePreferences preferences = ConfigurationScope.INSTANCE
              .getNode("org.bbaw.bts.app");
    String url = preferences.get("webhelp_url", "http://aaew64.bbaw.de/bts/help");
    if (url != null)
    {
        OpenExternalBrowser.openURL(url);
    }
}
项目:bts    文件:ProjectSettingsPage.java   
/**
     * Initialize the preference page.
     */
    public void init(IWorkbench workbench) {
//      BundleContext bundleContext = Platform.getBundle("org.bbaw.bts.ui.main").getBundleContext();
        context = StaticAccessController.getContext();
        projectController = context.get(BTSProjectController.class);
        prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app");
        main_project = prefs.get(BTSPluginIDs.PREF_MAIN_PROJECT_KEY, null);
        active_projects = prefs.get(BTSPluginIDs.PREF_ACTIVE_PROJECTS, null);
        logger = context.get(Logger.class);

        loadListInput();

    }
项目:bts    文件:ThsSettingsPage.java   
/**
     * Initialize the preference page.
     */
    public void init(IWorkbench workbench) {
//      BundleContext bundleContext = Platform.getBundle("org.bbaw.bts.ui.main").getBundleContext();
        context = StaticAccessController.getContext();
        projectController = context.get(BTSProjectController.class);
        prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app");
        main_thsList = prefs.get(BTSPluginIDs.PREF_MAIN_THS_KEY, prefs.get(BTSPluginIDs.PREF_MAIN_PROJECT_KEY, null));
        active_thsLists = prefs.get(BTSPluginIDs.PREF_ACTIVE_THSS, prefs.get(BTSPluginIDs.PREF_ACTIVE_PROJECTS, null));
        logger = context.get(Logger.class);

        loadListInput();

    }
项目:bts    文件:ATextSettingsPage.java   
/**
     * Initialize the preference page.
     */
    public void init(IWorkbench workbench) {
//      BundleContext bundleContext = Platform.getBundle("org.bbaw.bts.ui.main").getBundleContext();
        context = StaticAccessController.getContext();
        projectController = context.get(BTSProjectController.class);
        prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app");
        main_atexts = prefs.get(BTSPluginIDs.PREF_MAIN_ATEXT_KEY, prefs.get(BTSPluginIDs.PREF_MAIN_PROJECT_KEY, null));
        active_atexts = prefs.get(BTSPluginIDs.PREF_ACTIVE_ATEXTS, prefs.get(BTSPluginIDs.PREF_ACTIVE_PROJECTS, null));
        logger = context.get(Logger.class);

        loadListInput();

    }
项目:bts    文件:LemmaListSettingsPage.java   
/**
     * Initialize the preference page.
     */
    public void init(IWorkbench workbench) {
//      BundleContext bundleContext = Platform.getBundle("org.bbaw.bts.ui.main").getBundleContext();
        context = StaticAccessController.getContext();
        projectController = context.get(BTSProjectController.class);
        prefs = ConfigurationScope.INSTANCE.getNode("org.bbaw.bts.app");
        main_lemmaList = prefs.get(BTSPluginIDs.PREF_MAIN_LEMMALIST_KEY, prefs.get(BTSPluginIDs.PREF_MAIN_PROJECT_KEY, null));
        active_lemmaLists = prefs.get(BTSPluginIDs.PREF_ACTIVE_LEMMALISTS, prefs.get(BTSPluginIDs.PREF_ACTIVE_PROJECTS, null));
        logger = context.get(Logger.class);

        loadListInput();

    }
项目: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);
}
项目:APICloud-Studio    文件:SendPingJob.java   
private boolean enroll()
{
    ConfigurationScope scope = EclipseUtil.configurationScope();
    boolean hasEnrolled = Platform.getPreferencesService().getBoolean(UsagePlugin.PLUGIN_ID,
            IPreferenceConstants.HAS_ENROLLED, false, new IScopeContext[] { scope });
    if (!hasEnrolled)
    {
        AnalyticsInfo info = UsagePlugin.getDefault().getAnalyticsInfoManager()
                .getInfo("com.aptana.usage.analytics"); //$NON-NLS-1$
        String guid = info.getAppGuid();
        // only sends the enroll ping if it's Aptana Studio
        if ((new DefaultAnalyticsInfo()).getAppGuid().equals(guid))
        {
            // @formatter:off
            Map<String, String> payload = CollectionsUtil.newInOrderMap(
                "guid", guid, //$NON-NLS-1$
                "mid", CorePlugin.getMID()); //$NON-NLS-1$
            // @formatter:on

            StudioAnalytics.getInstance().sendEvent(new AnalyticsEvent(STUDIO_ENROLL, STUDIO_ENROLL, payload));
        }

        IEclipsePreferences store = scope.getNode(UsagePlugin.PLUGIN_ID);
        store.putBoolean(IPreferenceConstants.HAS_ENROLLED, true);
        try
        {
            store.flush();
            return true;
        }
        catch (BackingStoreException e)
        {
            UsagePlugin.logError(e);
        }
    }
    return false;
}
项目:APICloud-Studio    文件:SendPingJob.java   
private boolean sendFirstRunEvent()
{
    ConfigurationScope scope = EclipseUtil.configurationScope();
    boolean hasRun = Platform.getPreferencesService().getBoolean(UsagePlugin.PLUGIN_ID,
            IPreferenceConstants.P_IDE_HAS_RUN, false, new IScopeContext[] { scope });
    if (!hasRun)
    {
        // checks with the previous plugin id
        hasRun = Platform.getPreferencesService().getBoolean(UsagePlugin.OLD_PLUGIN_ID,
                IPreferenceConstants.P_IDE_HAS_RUN, false, new IScopeContext[] { scope });
        if (!hasRun)
        {
            StudioAnalytics.getInstance().sendEvent(new AnalyticsEvent(STUDIO_FIRST_RUN, STUDIO_FIRST_RUN, null));

            IEclipsePreferences store = scope.getNode(UsagePlugin.PLUGIN_ID);
            store.putBoolean(IPreferenceConstants.P_IDE_HAS_RUN, true);
            try
            {
                store.flush();
                return true;
            }
            catch (BackingStoreException e)
            {
                UsagePlugin.logError(e);
            }
        }
    }
    return false;
}
项目:translationstudio8    文件:TSPreferenceInitializer.java   
@Override
public void initializeDefaultPreferences() {
    // 设置 colors 首选项页的初始值
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_FG_COLOR, new RGB(234, 234, 234));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_BG_COLOR, new RGB(223, 112, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.WRONG_TAG_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_FG_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_BG_COLOR, new RGB(244, 244, 159));

    PreferenceConverter.setDefault(store, IColorPreferenceConstant.PT_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.QT_COLOR, new RGB(255, 204, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.MT_COLOR, new RGB(171, 217, 198));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH101_COLOR, new RGB(255, 255, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH100_COLOR, new RGB(37, 168, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH90_COLOR, new RGB(79, 185, 214));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH80_COLOR, new RGB(114, 199, 222));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH70_COLOR, new RGB(155, 215, 231));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH0_COLOR, new RGB(198, 240, 251));

    PreferenceConverter.setDefault(store, IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR, new RGB(170, 255, 85));

    // 设置 net.heartsome.cat.common.core 插件中的语言代码初始值
    IPreferenceStore corePreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, CoreActivator
            .getDefault().getBundle().getSymbolicName());
    corePreferenceStore.setDefault(IPreferenceConstants.LANGUAGECODE, LocaleService.getLanguageConfigAsString());

    // 设置选择路径对话框的初始值
    PlatformUI.getPreferenceStore()
            .setDefault(IPreferenceConstants.LAST_DIRECTORY, System.getProperty("user.home"));

    ColorConfigLoader.init();
}
项目:developer-studio    文件:UpdateCheckerJobListener.java   
@Override
public void done(IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        Display.getDefault().syncExec(new Runnable() {
            @Override
            public void run() {
                try {
                    // Wait half a second to let progress reporting complete
                    // FIXME: Find a proper fix
                    Thread.sleep(500);
                    // Set last check for Updates Time-stamp in OSGI bundle
                    // prefs
                    Preferences preferences = ConfigurationScope.INSTANCE.getNode(Constants.NODE_UPDATE_HANDER);
                    preferences.putLong(Constants.PREF_LAST_PROMPT_FOR_UPDATES, new Date().getTime());
                    preferences.flush();
                    UpdateCheckerJob.setIsJobRunning(false);
                    if (isAutomaticUpdater && !updateManager.hasPossibleUpdates()) {
                        // no updates - no need to open the window
                        return;
                    }

                    UpdaterDialog dialog = new UpdaterDialog(updateManager, activeTab);
                    dialog.open();
                } catch (Exception e) {
                    log.error(Messages.UpdateCheckerJobListener_0, e);
                }
            }
        });
    }
}
项目:emfstore-rest    文件:EMFStorePreferenceHelper.java   
/**
 * Set the preference value for a specific key. Key and value must not equal <code>null</code>.
 * 
 * @param key
 *            the key that is used to identify the given value
 * @param value
 *            the value of the preference to be set
 */
public static void setPreference(String key, String value) {
    if (key != null && value != null) {
        Preferences node = Platform.getPreferencesService().getRootNode().node(ConfigurationScope.SCOPE)
            .node(PREFERENCE_NODE);
        node.put(key, value);
        try {
            node.flush();
        } catch (BackingStoreException e) {
            WorkspaceUtil.handleException("Could not persist the preference change: {" + key + ", " + value + "}",
                e);
        }
    }
}
项目:mybatipse    文件:JavaMapperUtil.java   
private boolean isParamAttrGenerated()
{
    IScopeContext[] contexts;
    if (project != null)
    {
        contexts = new IScopeContext[]{
            new ProjectScope(project.getProject()), InstanceScope.INSTANCE,
            ConfigurationScope.INSTANCE, DefaultScope.INSTANCE
        };
    }
    else
    {
        contexts = new IScopeContext[]{
            InstanceScope.INSTANCE, ConfigurationScope.INSTANCE, DefaultScope.INSTANCE
        };
    }
    for (int j = 0; j < contexts.length; ++j)
    {
        String value = contexts[j].getNode(JavaCore.PLUGIN_ID)
            .get(JavaCore.COMPILER_CODEGEN_METHOD_PARAMETERS_ATTR, null);
        if (value != null)
        {
            value = value.trim();
            if (!value.isEmpty())
                return "generate".equals(value.trim());
        }
    }
    return false;
}
项目:SensIDL    文件:SettingsHandler.java   
/**
 * Save Settings that are the path and the language
 * 
 * @param modelPath
 *            the model path to save
 * @param path
 *            the path to save
 * @param language
 *            the language to save
 */
public static void saveSettings(String modelPath, String path, String language) {
    Preferences prefs = ConfigurationScope.INSTANCE.getNode("de.fzi.sensidl.language.ui");
    prefs.put("modelPath", modelPath.toString());
    prefs.put("path", path.toString());
    prefs.put("language", language.toString());

    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
项目:tmxeditor8    文件:TSPreferenceInitializer.java   
@Override
public void initializeDefaultPreferences() {
    // 设置 colors 首选项页的初始值
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_FG_COLOR, new RGB(234, 234, 234));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TAG_BG_COLOR, new RGB(223, 112, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.WRONG_TAG_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_FG_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.DIFFERENCE_BG_COLOR, new RGB(244, 244, 159));

    PreferenceConverter.setDefault(store, IColorPreferenceConstant.PT_COLOR, new RGB(255, 0, 0));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.QT_COLOR, new RGB(255, 204, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.MT_COLOR, new RGB(171, 217, 198));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH101_COLOR, new RGB(255, 255, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH100_COLOR, new RGB(37, 168, 204));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH90_COLOR, new RGB(79, 185, 214));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH80_COLOR, new RGB(114, 199, 222));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH70_COLOR, new RGB(155, 215, 231));
    PreferenceConverter.setDefault(store, IColorPreferenceConstant.TM_MATCH0_COLOR, new RGB(198, 240, 251));

    PreferenceConverter.setDefault(store, IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR, new RGB(170, 255, 85));

    // 设置 net.heartsome.cat.common.core 插件中的语言代码初始值
    IPreferenceStore corePreferenceStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, CoreActivator
            .getDefault().getBundle().getSymbolicName());
    corePreferenceStore.setDefault(IPreferenceConstants.LANGUAGECODE, LocaleService.getLanguageConfigAsString());

    // 设置选择路径对话框的初始值
    PlatformUI.getPreferenceStore()
            .setDefault(IPreferenceConstants.LAST_DIRECTORY, System.getProperty("user.home"));

    ColorConfigLoader.init();
}