PrefsDialogpublic final class PrefsDialog extends Object
Fields Summary |
---|
private static org.eclipse.jface.preference.PreferenceStore | mPrefStore | public static final String | SHELL_X | public static final String | SHELL_Y | public static final String | SHELL_WIDTH | public static final String | SHELL_HEIGHT | public static final String | EXPLORER_SHELL_X | public static final String | EXPLORER_SHELL_Y | public static final String | EXPLORER_SHELL_WIDTH | public static final String | EXPLORER_SHELL_HEIGHT | public static final String | SHOW_NATIVE_HEAP | public static final String | LOGCAT_COLUMN_MODE | public static final String | LOGCAT_FONT | public static final String | LOGCAT_COLUMN_MODE_AUTO | public static final String | LOGCAT_COLUMN_MODE_MANUAL | private static final String | PREFS_DEBUG_PORT_BASE | private static final String | PREFS_SELECTED_DEBUG_PORT | private static final String | PREFS_DEFAULT_THREAD_UPDATE | private static final String | PREFS_DEFAULT_HEAP_UPDATE | private static final String | PREFS_THREAD_REFRESH_INTERVAL | private static final String | PREFS_LOG_LEVEL |
Constructors Summary |
---|
private PrefsDialog()Private constructor -- do not instantiate. //$NON-NLS-1$
|
Methods Summary |
---|
public static org.eclipse.jface.preference.PreferenceStore | getStore()Return the PreferenceStore that holds our values.
return mPrefStore;
| public static void | init()Do some one-time prep.
The original plan was to let the individual classes define their
own defaults, which we would get and then override with the config
file. However, PreferencesStore.load() doesn't trigger the "changed"
events, which means we have to pull the loaded config values out by
hand.
So, we set the defaults, load the values from the config file, and
then run through and manually export the values. Then we duplicate
the second part later on for the "changed" events.
assert mPrefStore == null;
mPrefStore = SdkStatsService.getPreferenceStore();
if (mPrefStore == null) {
// we have a serious issue here...
Log.e("ddms",
"failed to access both the user HOME directory and the system wide temp folder. Quitting.");
System.exit(1);
}
// configure default values
setDefaults(System.getProperty("user.home")); //$NON-NLS-1$
// listen for changes
mPrefStore.addPropertyChangeListener(new ChangeListener());
// Now we initialize the value of the preference, from the values in the store.
// First the ddm lib.
DdmPreferences.setDebugPortBase(mPrefStore.getInt(PREFS_DEBUG_PORT_BASE));
DdmPreferences.setSelectedDebugPort(mPrefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
DdmPreferences.setLogLevel(mPrefStore.getString(PREFS_LOG_LEVEL));
DdmPreferences.setInitialThreadUpdate(mPrefStore.getBoolean(PREFS_DEFAULT_THREAD_UPDATE));
DdmPreferences.setInitialHeapUpdate(mPrefStore.getBoolean(PREFS_DEFAULT_HEAP_UPDATE));
// some static values
String out = System.getenv("ANDROID_PRODUCT_OUT"); //$NON-NLS-1$
DdmUiPreferences.setSymbolsLocation(out + File.separator + "symbols"); //$NON-NLS-1$
DdmUiPreferences.setAddr2LineLocation("arm-eabi-addr2line"); //$NON-NLS-1$
String traceview = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
if (traceview != null && traceview.length() != 0) {
traceview += File.separator + "traceview"; //$NON-NLS-1$
} else {
traceview = "traceview"; //$NON-NLS-1$
}
DdmUiPreferences.setTraceviewLocation(traceview);
// Now the ddmui lib
DdmUiPreferences.setStore(mPrefStore);
DdmUiPreferences.setThreadRefreshInterval(mPrefStore.getInt(PREFS_THREAD_REFRESH_INTERVAL));
| public static void | run(org.eclipse.swt.widgets.Shell shell)Create and display the dialog.
assert mPrefStore != null;
PreferenceManager prefMgr = new PreferenceManager();
PreferenceNode node, subNode;
// this didn't work -- got NPE, possibly from class lookup:
//PreferenceNode app = new PreferenceNode("app", "Application", null,
// AppPrefs.class.getName());
node = new PreferenceNode("client", new ClientPrefs());
prefMgr.addToRoot(node);
subNode = new PreferenceNode("panel", new PanelPrefs());
//prefMgr.addTo(node.getId(), subNode);
prefMgr.addToRoot(subNode);
node = new PreferenceNode("device", new DevicePrefs());
prefMgr.addToRoot(node);
node = new PreferenceNode("LogCat", new LogCatPrefs());
prefMgr.addToRoot(node);
node = new PreferenceNode("app", new AppPrefs());
prefMgr.addToRoot(node);
node = new PreferenceNode("stats", new UsageStatsPrefs());
prefMgr.addToRoot(node);
PreferenceDialog dlg = new PreferenceDialog(shell, prefMgr);
dlg.setPreferenceStore(mPrefStore);
// run it
dlg.open();
// save prefs
try {
mPrefStore.save();
}
catch (IOException ioe) {
}
// discard the stuff we created
//prefMgr.dispose();
//dlg.dispose();
| public static void | save()Save the prefs to the config file.
try {
mPrefStore.save();
}
catch (IOException ioe) {
Log.w("ddms", "Failed saving prefs file: " + ioe.getMessage());
}
| private static void | setDefaults(java.lang.String homeDir)
mPrefStore.setDefault(PREFS_DEBUG_PORT_BASE, DdmPreferences.DEFAULT_DEBUG_PORT_BASE);
mPrefStore.setDefault(PREFS_SELECTED_DEBUG_PORT,
DdmPreferences.DEFAULT_SELECTED_DEBUG_PORT);
mPrefStore.setDefault(PREFS_DEFAULT_THREAD_UPDATE, true);
mPrefStore.setDefault(PREFS_DEFAULT_HEAP_UPDATE, false);
mPrefStore.setDefault(PREFS_THREAD_REFRESH_INTERVAL,
DdmUiPreferences.DEFAULT_THREAD_REFRESH_INTERVAL);
mPrefStore.setDefault("textSaveDir", homeDir); //$NON-NLS-1$
mPrefStore.setDefault("imageSaveDir", homeDir); //$NON-NLS-1$
mPrefStore.setDefault(PREFS_LOG_LEVEL, "info"); //$NON-NLS-1$
// choose a default font for the text output
FontData fdat = new FontData("Courier", 10, SWT.NORMAL); //$NON-NLS-1$
mPrefStore.setDefault("textOutputFont", fdat.toString()); //$NON-NLS-1$
// layout information.
mPrefStore.setDefault(SHELL_X, 100);
mPrefStore.setDefault(SHELL_Y, 100);
mPrefStore.setDefault(SHELL_WIDTH, 800);
mPrefStore.setDefault(SHELL_HEIGHT, 600);
mPrefStore.setDefault(EXPLORER_SHELL_X, 50);
mPrefStore.setDefault(EXPLORER_SHELL_Y, 50);
mPrefStore.setDefault(SHOW_NATIVE_HEAP, false);
|
|