feature: Switching initializer to new API
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java
index 3c9803d..129df66 100644
--- a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/CorePreferences.java
@@ -12,8 +12,8 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Network;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -31,7 +31,16 @@
public static final String INETADDRESS_KEY = Activator.PLUGIN_ID + ".preferences.InetAddressDefault";
public static InetAddress getDefaultInetAddress() throws UnknownHostException {
- IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ StackTraceElement[] stackTrace = new Exception().getStackTrace();
+ System.out.println(
+ "*********************************************************************************************************************");
+ System.out.println(" GETTING PREFERENCES");
+ for (int i = 0; i < 4 && i < stackTrace.length; i++) {
+ System.out.println(stackTrace[i].toString());
+ }
+ System.out.println(
+ "*********************************************************************************************************************");
+ IEclipsePreferences prefs = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);
String inetaddress = prefs.get(INETADDRESS_KEY, Network.getValidIP().getHostAddress());
System.out.println("NewPrefs = " + inetaddress);
System.out.println("Address in pref = " + inetaddress);
@@ -41,6 +50,24 @@
return Network.getValidIP();
}
+ @SuppressWarnings("deprecation")
+ public static InetAddress getDefaultInetAddress2() throws UnknownHostException {
+ StackTraceElement[] stackTrace = new Exception().getStackTrace();
+ System.out.println(
+ "*********************************************************************************************************************");
+ System.out.println(" GETTING PREFERENCES OLD WAY");
+ for (int i = 0; i < 4 && i < stackTrace.length; i++) {
+ System.out.println(stackTrace[i].toString());
+ }
+ System.out.println(
+ "*********************************************************************************************************************");
+ String inetaddress = Activator.getInstance().getPluginPreferences().getString(CorePreferences.INETADDRESS_KEY);
+ if (Strings.isValid(inetaddress)) {
+ return InetAddress.getByName(inetaddress);
+ }
+ return Network.getValidIP();
+ }
+
/**
* @param hostAddress
* @throws UnknownHostException
@@ -48,7 +75,7 @@
*/
public static void setDefaultAddress(String hostAddress) {
System.out.println("Setting new way to " + hostAddress);
- IEclipsePreferences node = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);
node.put(INETADDRESS_KEY, hostAddress);
try {
node.flush();
diff --git a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java
index 9a82fb1..bb35e13 100644
--- a/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java
+++ b/plugins/org.eclipse.osee.framework.plugin.core/src/org/eclipse/osee/framework/plugin/core/internal/CorePreferenceInitializer.java
@@ -13,8 +13,9 @@
import java.net.UnknownHostException;
import java.util.logging.Level;
-import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.osee.framework.jdk.core.util.Network;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -23,21 +24,20 @@
/**
* @author Roberto E. Escobar
*/
-@SuppressWarnings("deprecation")
public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
@Override
public void initializeDefaultPreferences() {
- Preferences store = Activator.getInstance().getPluginPreferences();
+ IEclipsePreferences prefs = ConfigurationScope.INSTANCE.getNode(Activator.PLUGIN_ID);
try {
- String defaultNetworkValue = Network.getValidIP().getHostAddress();
- store.setDefault(CorePreferences.INETADDRESS_KEY, defaultNetworkValue);
- String value = store.getString(CorePreferences.INETADDRESS_KEY);
- if (!Strings.isValid(value)) {
- store.setValue(CorePreferences.INETADDRESS_KEY, store.getDefaultString(CorePreferences.INETADDRESS_KEY));
+ String currentValue = prefs.get(CorePreferences.INETADDRESS_KEY, "");
+ if (!Strings.isInValid(currentValue)) {
+ String defaultNetworkValue = Network.getValidIP().getHostAddress();
+ prefs.put(CorePreferences.INETADDRESS_KEY, defaultNetworkValue);
}
} catch (UnknownHostException ex) {
OseeLog.log(Activator.class, Level.SEVERE, "Error initializing default inet address key", ex);
}
+
}
}