@Override
 public void initializeDefaultPreferences() {
   IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(CoreIOPlugin.PLUGIN_ID);
   prefs.putBoolean(IPreferenceConstants.UPLOAD_UPDATE_PERMISSIONS, true);
   prefs.putBoolean(IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, true);
   prefs.putLong(IPreferenceConstants.UPLOAD_FILE_PERMISSION, DEFAULT_FILE_PERMISSIONS);
   prefs.putLong(IPreferenceConstants.UPLOAD_FOLDER_PERMISSION, DEFAULT_DIRECTORY_PERMISSIONS);
   prefs.putBoolean(IPreferenceConstants.DOWNLOAD_UPDATE_PERMISSIONS, true);
   prefs.putBoolean(IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, true);
   prefs.putLong(IPreferenceConstants.DOWNLOAD_FILE_PERMISSION, DEFAULT_FILE_PERMISSIONS);
   prefs.putLong(IPreferenceConstants.DOWNLOAD_FOLDER_PERMISSION, DEFAULT_DIRECTORY_PERMISSIONS);
   prefs.put(IPreferenceConstants.GLOBAL_CLOAKING_EXTENSIONS, DEFAULT_CLOAK_EXPRESSIONS);
 }
 /**
  * Initializes the given preference store with the default values.
  *
  * @param store the preference store to be initialized
  */
 public static void initializeDefaultValues() {
   IEclipsePreferences node = new DefaultScope().getNode(TernNodejsCorePlugin.PLUGIN_ID);
   // By default native node.js install is used.
   node.put(TernNodejsCoreConstants.NODEJS_INSTALL, NodejsInstall.NODE_NATIVE);
   node.put(TernNodejsCoreConstants.NODEJS_PATH, IDENodejsProcessHelper.getNodejsPath());
   // timeout to start node.js
   node.putLong(TernNodejsCoreConstants.NODEJS_TIMEOUT, NodejsTernHelper.DEFAULT_TIMEOUT);
   // test number to start node.js
   node.putInt(TernNodejsCoreConstants.NODEJS_TEST_NUMBER, NodejsTernHelper.DEFAULT_TEST_NUMBER);
   // node.js persistent (not auto-shutdown ?)
   node.putBoolean(TernNodejsCoreConstants.NODEJS_PERSISTENT, false);
 }
Пример #3
0
  public void setCurrentTheme(Theme theme) {
    fCurrentTheme = theme;

    // Set the find in file search color
    IEclipsePreferences prefs = new InstanceScope().getNode("org.eclipse.search"); // $NON-NLS-1$
    prefs.put(
        "org.eclipse.search.potentialMatch.fgColor",
        toString(theme.getSearchResultColor())); // $NON-NLS-1$
    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      ThemePlugin.logError(e);
    }

    // Set the color for the search result annotation, the pref key is "searchResultIndicationColor"
    prefs = new InstanceScope().getNode("org.eclipse.ui.editors"); // $NON-NLS-1$
    if (!theme.hasEntry("override.searchResultIndication")) // $NON-NLS-1$
    {
      prefs.put(
          "searchResultIndicationColor", toString(theme.getSearchResultColor())); // $NON-NLS-1$
    }
    // TODO Use markup.changed bg color for "decoration color" in Prefs>General>Appearance>Colors
    // and Fonts

    // TODO Move this stuff over to theme change listeners in the XML/HTML/Ruby editor plugins?
    if (!theme.hasEntry("override.xmlTagPairOccurrenceIndication")) // $NON-NLS-1$
    {
      prefs.putBoolean("xmlTagPairOccurrenceIndicationHighlighting", false); // $NON-NLS-1$
      prefs.putBoolean("xmlTagPairOccurrenceIndication", true); // $NON-NLS-1$
      prefs.put(
          "xmlTagPairOccurrenceIndicationColor",
          toString(theme.getOccurenceHighlightColor())); // $NON-NLS-1$
      prefs.put(
          "xmlTagPairOccurrenceIndicationTextStyle", AnnotationPreference.STYLE_BOX); // $NON-NLS-1$
    }
    if (!theme.hasEntry("override.htmlTagPairOccurrenceIndication")) // $NON-NLS-1$
    {
      prefs.putBoolean("htmlTagPairOccurrenceIndicationHighlighting", false); // $NON-NLS-1$
      prefs.putBoolean("htmlTagPairOccurrenceIndication", true); // $NON-NLS-1$
      prefs.put(
          "htmlTagPairOccurrenceIndicationColor",
          toString(theme.getOccurenceHighlightColor())); // $NON-NLS-1$
      prefs.put(
          "htmlTagPairOccurrenceIndicationTextStyle",
          AnnotationPreference.STYLE_BOX); // $NON-NLS-1$
    }
    if (!theme.hasEntry("override.rubyBlockPairOccurrenceIndication")) // $NON-NLS-1$
    {
      prefs.putBoolean("rubyBlockPairOccurrenceIndicationHighlighting", false); // $NON-NLS-1$
      prefs.putBoolean("rubyBlockPairOccurrenceIndication", true); // $NON-NLS-1$
      prefs.put(
          "rubyBlockPairOccurrenceIndicationColor",
          toString(theme.getOccurenceHighlightColor())); // $NON-NLS-1$
      prefs.put(
          "rubyBlockPairOccurrenceIndicationTextStyle",
          AnnotationPreference.STYLE_BOX); // $NON-NLS-1$
    }
    // PyDev Occurrences (com.python.pydev.occurrences)
    // Override them if pydev is set to use our themes
    if (Platform.getPreferencesService()
        .getBoolean(
            "org.python.pydev.red_core",
            "PYDEV_USE_APTANA_THEMES",
            true, //$NON-NLS-1$ //$NON-NLS-2$
            null)) {
      if (!theme.hasEntry("override.pydevOccurrenceIndication")) // $NON-NLS-1$
      {
        MarkerAnnotationPreferences preferences = new MarkerAnnotationPreferences();
        AnnotationPreference pydevOccurPref = null;
        for (Object obj : preferences.getAnnotationPreferences()) {
          AnnotationPreference pref = (AnnotationPreference) obj;
          Object type = pref.getAnnotationType();
          if ("com.python.pydev.occurrences".equals(type)) // $NON-NLS-1$
          {
            pydevOccurPref = pref;
          }
        }
        if (pydevOccurPref != null) {
          if (pydevOccurPref.getTextStylePreferenceKey() != null) {
            // Now that pydev supports text style, use the box style and don't highlight.
            prefs.putBoolean("pydevOccurrenceHighlighting", false); // $NON-NLS-1$
            prefs.putBoolean("pydevOccurrenceIndication", true); // $NON-NLS-1$
            prefs.put(
                "pydevOccurrenceIndicationColor",
                toString(theme.getOccurenceHighlightColor())); // $NON-NLS-1$
            prefs.put(
                "pydevOccurrenceIndicationTextStyle",
                AnnotationPreference.STYLE_BOX); // $NON-NLS-1$
          } else {
            // Must use highlighting, since we're against older pydev that had no text style
            prefs.putBoolean("pydevOccurrenceHighlighting", true); // $NON-NLS-1$
            prefs.putBoolean("pydevOccurrenceIndication", true); // $NON-NLS-1$
            prefs.put(
                "pydevOccurrenceIndicationColor",
                toString(theme.getSearchResultColor())); // $NON-NLS-1$
          }
        }
      }
    }

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      ThemePlugin.logError(e);
    }

    // Set the bg/fg/selection colors for compare editors
    prefs = new InstanceScope().getNode("org.eclipse.compare"); // $NON-NLS-1$
    prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
    prefs.put(
        AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
        StringConverter.asString(theme.getBackground()));
    prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
    prefs.put(
        AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
        StringConverter.asString(theme.getForeground()));
    prefs.putBoolean(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, false);
    prefs.put(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND,
        StringConverter.asString(theme.getSelectionAgainstBG()));
    prefs.putBoolean(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false);
    prefs.put(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND,
        StringConverter.asString(theme.getForeground()));
    prefs.put(
        AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
        toString(theme.getLineHighlightAgainstBG()));

    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      ThemePlugin.logError(e);
    }

    // Also set the standard eclipse editor props, like fg, bg, selection fg, bg
    prefs = new InstanceScope().getNode("com.aptana.editor.common"); // $NON-NLS-1$
    prefs.putBoolean(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false);
    prefs.put(
        AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND,
        toString(theme.getSelectionAgainstBG()));

    prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
    prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, toString(theme.getBackground()));

    prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
    prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, toString(theme.getForeground()));

    prefs.put(
        AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
        toString(theme.getLineHighlightAgainstBG()));
    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      ThemePlugin.logError(e);
    }

    prefs = new InstanceScope().getNode(ThemePlugin.PLUGIN_ID);
    prefs.put(IPreferenceConstants.ACTIVE_THEME, theme.getName());
    prefs.putLong(THEME_CHANGED, System.currentTimeMillis());
    try {
      prefs.flush();
    } catch (BackingStoreException e) {
      ThemePlugin.logError(e);
    }

    // Force font
    final String[] fontIds =
        new String[] {
          IThemeManager.VIEW_FONT_NAME,
          JFaceResources.TEXT_FONT,
          "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont"
        }; //$NON-NLS-1$
    UIUtils.getDisplay()
        .asyncExec(
            new Runnable() {

              public void run() {
                for (String fontId : fontIds) {
                  Font fFont = JFaceResources.getFontRegistry().get(fontId);
                  // Only set new values if they're different from existing!
                  Font existing = JFaceResources.getFont(fontId);
                  String existingString = ""; // $NON-NLS-1$
                  if (!existing.isDisposed()) {
                    existingString =
                        PreferenceConverter.getStoredRepresentation(existing.getFontData());
                  }
                  String fdString =
                      PreferenceConverter.getStoredRepresentation(fFont.getFontData());
                  if (!existingString.equals(fdString)) {
                    // put in registry...
                    JFaceResources.getFontRegistry().put(fontId, fFont.getFontData());
                  }
                }
              }
            });
  }