aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-10-14 01:51:44 -0400
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-10-14 01:51:44 -0400
commit3150c927149e015085bfb78c344fd146e0d84596 (patch)
treeb1e58303cb85591d671d189bcd4b0a4e01013d90 /ddms
parente313f07f211def20a0392fd731271171aa96f059 (diff)
parent9c4bc5cdb4d124544003bfbd9177cc4033f8d446 (diff)
downloadsdk-3150c927149e015085bfb78c344fd146e0d84596.zip
sdk-3150c927149e015085bfb78c344fd146e0d84596.tar.gz
sdk-3150c927149e015085bfb78c344fd146e0d84596.tar.bz2
Merge change Idc447b41 into eclair
* changes: UI to manage/create custom Layout Devices.
Diffstat (limited to 'ddms')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java
index f8d457e..9d557e0 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java
@@ -146,4 +146,58 @@ public final class TableHelper {
}
}
+ /**
+ * Create a TreeColumn with the specified parameters. If a
+ * <code>PreferenceStore</code> object and a preference entry name String
+ * object are provided then the column will listen to change in its width
+ * and update the preference store accordingly.
+ *
+ * @param parent The Table parent object
+ * @param header The header string
+ * @param style The column style
+ * @param width the width of the column if the preference value is missing
+ * @param pref_name The preference entry name for column width
+ * @param prefs The preference store
+ */
+ public static void createTreeColumn(Tree parent, String header, int style,
+ int width, final String pref_name,
+ final IPreferenceStore prefs) {
+
+ // create the column
+ TreeColumn col = new TreeColumn(parent, style);
+
+ // if there is no pref store or the entry is missing, we use the sample
+ // text and pack the column.
+ // Otherwise we just read the width from the prefs and apply it.
+ if (prefs == null || prefs.contains(pref_name) == false) {
+ col.setWidth(width);
+
+ // init the prefs store with the current value
+ if (prefs != null) {
+ prefs.setValue(pref_name, width);
+ }
+ } else {
+ col.setWidth(prefs.getInt(pref_name));
+ }
+
+ // set the header
+ col.setText(header);
+
+ // if there is a pref store and a pref entry name, then we setup a
+ // listener to catch column resize to put store the new width value.
+ if (prefs != null && pref_name != null) {
+ col.addControlListener(new ControlListener() {
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ // get the new width
+ int w = ((TreeColumn)e.widget).getWidth();
+
+ // store in pref store
+ prefs.setValue(pref_name, w);
+ }
+ });
+ }
+ }
}