Merge change Idc447b41 into eclair

* changes:
  UI to manage/create custom Layout Devices.
This commit is contained in:
Android (Google) Code Review
2009-10-14 01:51:44 -04:00
17 changed files with 1478 additions and 277 deletions

View File

@@ -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);
}
});
}
}
}