Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2008-11-21 22:23:23 +0000
committerChris Goldthorpe2008-11-21 22:23:23 +0000
commit7af871a76111301aae2b286d1a9a2b9519f6967f (patch)
treeef7982eb45bc977df69b1665afa0b1c455288cf0 /org.eclipse.ui.intro
parent311dcdd1fd7441c4642d588bd9968a65b01f1990 (diff)
downloadeclipse.platform.ua-7af871a76111301aae2b286d1a9a2b9519f6967f.tar.gz
eclipse.platform.ua-7af871a76111301aae2b286d1a9a2b9519f6967f.tar.xz
eclipse.platform.ua-7af871a76111301aae2b286d1a9a2b9519f6967f.zip
Rewrite preference code to eliminate deprecation warnings
Diffstat (limited to 'org.eclipse.ui.intro')
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/FontSelection.java30
-rw-r--r--org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java32
2 files changed, 30 insertions, 32 deletions
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/FontSelection.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/FontSelection.java
index 839ad787a..d7a6d299f 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/FontSelection.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/FontSelection.java
@@ -13,10 +13,12 @@ package org.eclipse.ui.internal.intro.impl;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
+import org.osgi.service.prefs.BackingStoreException;
public class FontSelection {
@@ -57,14 +59,8 @@ public class FontSelection {
}
public static final int getScalePercentage() {
- Preferences prefs = IntroPlugin.getDefault().getPluginPreferences();
- String scale = prefs.getString(SCALE_FACTOR);
- try {
- return Integer.parseInt(scale);
- }
- catch (NumberFormatException n) {
- return 0;
- }
+ int scale = Platform.getPreferencesService().getInt(IntroPlugin.PLUGIN_ID, (SCALE_FACTOR), 0, null);
+ return scale;
}
private static String getFontSizeDeclaration(String element, int baseSize, int percentage, int scale) {
@@ -74,20 +70,26 @@ public class FontSelection {
}
public static void setScalePercentage(int i) {
- Preferences prefs = IntroPlugin.getDefault().getPluginPreferences();
- prefs.setValue(SCALE_FACTOR, "" + i); //$NON-NLS-1$
+ InstanceScope instanceScope = new InstanceScope();
+ IEclipsePreferences prefs = instanceScope.getNode(IntroPlugin.PLUGIN_ID);
+ prefs.putInt(SCALE_FACTOR, i);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ }
}
public static String getFontStyle() {
IProduct product = Platform.getProduct();
if (product != null) {
String pid = product.getId();
- Preferences prefs = IntroPlugin.getDefault().getPluginPreferences();
- String style = prefs.getString(pid + "_" +FontSelection.VAR_FONT_STYLE); //$NON-NLS-1$
+ String style = Platform.getPreferencesService().getString
+ (IntroPlugin.PLUGIN_ID, pid + "_" +FontSelection.VAR_FONT_STYLE, "", null); //$NON-NLS-1$ //$NON-NLS-2$
if (style.length() > 0) {
return style;
}
- style = prefs.getString(FontSelection.VAR_FONT_STYLE);
+ style = Platform.getPreferencesService().getString
+ (IntroPlugin.PLUGIN_ID, (FontSelection.VAR_FONT_STYLE), "", null); //$NON-NLS-1$
if (style.length() > 0) {
return style;
}
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
index 535727d00..c0a5b58ad 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/internal/intro/impl/model/IntroModelRoot.java
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.help.UAContentFilter;
import org.eclipse.help.internal.UAElementFactory;
@@ -271,16 +270,9 @@ public class IntroModelRoot extends AbstractIntroContainer {
}
private void determineHomePage() {
- Preferences pref = IntroPlugin.getDefault().getPluginPreferences();
String pid = Platform.getProduct().getId();
- startPageId = pref.getString(pid + "_INTRO_START_PAGE"); //$NON-NLS-1$
- if (startPageId.length() == 0) {
- startPageId = pref.getString("INTRO_START_PAGE"); //$NON-NLS-1$
- }
- String homePagePreference = pref.getString(pid + "_INTRO_HOME_PAGE"); //$NON-NLS-1$
- if (homePagePreference.length() == 0) {
- homePagePreference = pref.getString("INTRO_HOME_PAGE"); //$NON-NLS-1$
- }
+ startPageId = getProcessPreference("INTRO_START_PAGE", pid); //$NON-NLS-1$
+ String homePagePreference = getProcessPreference("INTRO_HOME_PAGE", pid); //$NON-NLS-1$
homePage = rootPage; // Default, may be overridden
if (homePagePreference.length() != 0) {
AbstractIntroPage page = (AbstractIntroPage) findChild(homePagePreference,
@@ -292,10 +284,7 @@ public class IntroModelRoot extends AbstractIntroContainer {
}
}
}
- String standbyPagePreference = pref.getString(pid + "_INTRO_STANDBY_PAGE"); //$NON-NLS-1$
- if (standbyPagePreference.length() == 0) {
- standbyPagePreference = pref.getString("INTRO_STANDBY_PAGE"); //$NON-NLS-1$
- }
+ String standbyPagePreference = getProcessPreference("INTRO_STANDBY_PAGE", pid); //$NON-NLS-1$
modelStandbyPageId = getPresentation().getStandbyPageId();
if (standbyPagePreference.length() != 0) {
@@ -312,11 +301,8 @@ public class IntroModelRoot extends AbstractIntroContainer {
}
private void loadTheme() {
- Preferences pref = IntroPlugin.getDefault().getPluginPreferences();
String pid = Platform.getProduct().getId();
- String themeId = pref.getString(pid+"_INTRO_THEME"); //$NON-NLS-1$
- if (themeId.length()==0)
- themeId = pref.getString("INTRO_THEME"); //$NON-NLS-1$
+ String themeId = getProcessPreference("INTRO_THEME", pid); //$NON-NLS-1$
IConfigurationElement [] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.intro.configExtension"); //$NON-NLS-1$
IConfigurationElement themeElement=null;
@@ -971,4 +957,14 @@ public class IntroModelRoot extends AbstractIntroContainer {
public String getStartPageId() {
return startPageId;
}
+
+ private String getProcessPreference(String key, String pid) {
+ String result = Platform.getPreferencesService().getString
+ (IntroPlugin.PLUGIN_ID, pid + '_' + key, "", null); //$NON-NLS-1$
+ if (result.length() == 0) {
+ result = Platform.getPreferencesService().getString
+ (IntroPlugin.PLUGIN_ID, key, "", null); //$NON-NLS-1$
+ }
+ return result;
+ }
} \ No newline at end of file

Back to the top