2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.ide.eclipse.ddms.preferences;
19 import com.android.ide.eclipse.ddms.DdmsPlugin;
20 import com.android.ide.eclipse.ddms.views.DeviceView.HProfHandler;
21 import com.android.ddmlib.DdmPreferences;
22 import com.android.ddmuilib.DdmUiPreferences;
24 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
25 import org.eclipse.jface.preference.IPreferenceStore;
26 import org.eclipse.swt.SWT;
27 import org.eclipse.swt.graphics.FontData;
30 * Class used to initialize default preference values.
32 public class PreferenceInitializer extends AbstractPreferenceInitializer {
34 public final static String ATTR_LOG_LEVEL =
35 DdmsPlugin.PLUGIN_ID + ".logLevel"; //$NON-NLS-1$
37 public final static String ATTR_DEBUG_PORT_BASE =
38 DdmsPlugin.PLUGIN_ID + ".adbDebugBasePort"; //$NON-NLS-1$
40 public final static String ATTR_SELECTED_DEBUG_PORT =
41 DdmsPlugin.PLUGIN_ID + ".debugSelectedPort"; //$NON-NLS-1$
43 public final static String ATTR_DEFAULT_THREAD_UPDATE =
44 DdmsPlugin.PLUGIN_ID + ".defaultThreadUpdateEnabled"; //$NON-NLS-1$
46 public final static String ATTR_DEFAULT_HEAP_UPDATE =
47 DdmsPlugin.PLUGIN_ID + ".defaultHeapUpdateEnabled"; //$NON-NLS-1$
49 public final static String ATTR_THREAD_INTERVAL =
50 DdmsPlugin.PLUGIN_ID + ".threadStatusInterval"; //$NON-NLS-1$
52 public final static String ATTR_IMAGE_SAVE_DIR =
53 DdmsPlugin.PLUGIN_ID + ".imageSaveDir"; //$NON-NLS-1$
55 public final static String ATTR_LAST_IMAGE_SAVE_DIR =
56 DdmsPlugin.PLUGIN_ID + ".lastImageSaveDir"; //$NON-NLS-1$
58 public final static String ATTR_LOGCAT_FONT =
59 DdmsPlugin.PLUGIN_ID + ".logcatFont"; //$NON-NLS-1$
61 public final static String ATTR_HPROF_ACTION =
62 DdmsPlugin.PLUGIN_ID + ".hprofAction"; //$NON-NLS-1$
64 public final static String ATTR_TIME_OUT =
65 DdmsPlugin.PLUGIN_ID + ".timeOut"; //$NON-NLS-1$
70 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer
71 * #initializeDefaultPreferences()
74 public void initializeDefaultPreferences() {
75 IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore();
77 store.setDefault(ATTR_DEBUG_PORT_BASE, DdmPreferences.DEFAULT_DEBUG_PORT_BASE);
79 store.setDefault(ATTR_SELECTED_DEBUG_PORT, DdmPreferences.DEFAULT_SELECTED_DEBUG_PORT);
81 store.setDefault(ATTR_DEFAULT_THREAD_UPDATE, DdmPreferences.DEFAULT_INITIAL_THREAD_UPDATE);
82 store.setDefault(ATTR_DEFAULT_HEAP_UPDATE,
83 DdmPreferences.DEFAULT_INITIAL_HEAP_UPDATE);
85 store.setDefault(ATTR_THREAD_INTERVAL, DdmUiPreferences.DEFAULT_THREAD_REFRESH_INTERVAL);
87 String homeDir = System.getProperty("user.home"); //$NON-NLS-1$
88 store.setDefault(ATTR_IMAGE_SAVE_DIR, homeDir);
90 store.setDefault(ATTR_LOG_LEVEL, DdmPreferences.DEFAULT_LOG_LEVEL.getStringValue());
92 store.setDefault(ATTR_LOGCAT_FONT,
93 new FontData("Courier", 10, SWT.NORMAL).toString()); //$NON-NLS-1$
95 store.setDefault(ATTR_HPROF_ACTION, HProfHandler.ACTION_OPEN);
97 store.setDefault(ATTR_TIME_OUT, DdmPreferences.DEFAULT_TIMEOUT);
101 * Initializes the preferences of ddmlib and ddmuilib with values from the eclipse store.
103 public synchronized static void setupPreferences() {
104 IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore();
106 DdmPreferences.setDebugPortBase(store.getInt(ATTR_DEBUG_PORT_BASE));
107 DdmPreferences.setSelectedDebugPort(store.getInt(ATTR_SELECTED_DEBUG_PORT));
108 DdmPreferences.setLogLevel(store.getString(ATTR_LOG_LEVEL));
109 DdmPreferences.setInitialThreadUpdate(store.getBoolean(ATTR_DEFAULT_THREAD_UPDATE));
110 DdmPreferences.setInitialHeapUpdate(store.getBoolean(ATTR_DEFAULT_HEAP_UPDATE));
111 DdmUiPreferences.setThreadRefreshInterval(store.getInt(ATTR_THREAD_INTERVAL));
112 DdmPreferences.setTimeOut(store.getInt(ATTR_TIME_OUT));