public class TableComponentPreferenceAdapter
extends java.lang.Object
TableComponentPreferenceAdapter
can marshal a
TableComponent
to or from a CustomScopedPreferenceStore
. The
resulting preferences are stored in an IEclipsePreferences
node,
whose relative path is "table.name" where "name" is the name of the
TableComponent
. This node is a child node of the store's underlying
preferences node.
Use of this class requires explicit knowledge of the structure of the
TableComponent
. For instance, for a table with two columns "one" and
"two", the following would not work:
TableComponent table = new TableComponent();
TableComponentPreferenceAdapter adapter = new TableComponentPreferenceAdapter();
adapter.toTableComponent(store, table);
Instead, you would need to construct the TableComponent
's template:
TableComponent table = new TableComponent();
List<Entry> template = new ArrayList<Entry>(2);
// Create the template Entry for column "one" and add it to the list...
// Create the template Entry for column "two" and add it to the list...
table.setRowTemplate(template);
TableComponentPreferenceAdapter adapter = new TableComponentPreferenceAdapter();
adapter.toTableComponent(store, table);
Future implementations of this class may be able to handle
TableComponent
template creation automatically. Currently, the
approach is simply to write only the value for each Entry
in the
table.
Constructor and Description |
---|
TableComponentPreferenceAdapter() |
Modifier and Type | Method and Description |
---|---|
void |
toPreferences(TableComponent table,
CustomScopedPreferenceStore store)
Stores the rows of the specified
TableComponent in the specified
preference store under a node named "table.name", where "name" is the
table's name. |
void |
toTableComponent(CustomScopedPreferenceStore store,
TableComponent table)
Reads in the rows of the specified
TableComponent from the
specified preference store. |
public void toPreferences(TableComponent table, CustomScopedPreferenceStore store)
TableComponent
in the specified
preference store under a node named "table.name", where "name" is the
table's name.table
- The source table whose rows should be stored in the preference
store.store
- The target preference store.public void toTableComponent(CustomScopedPreferenceStore store, TableComponent table)
TableComponent
from the
specified preference store.
Note: The table's template should match the values stored in the preference store. If not, then the table will not be updated.
store
- The source preference store.table
- The target table whose rows should be read in from the
preference store.