Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Avoid restoring column widths to zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Mar 31, 2012
1 parent 9997859 commit 814af34
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ public void init(IMemento memento) {
roottype = getEnum(memento, KEY_ROOTTYPE, ElementType.class,
ElementType.GROUP);
hideunusedelements = getBoolean(memento, KEY_HIDEUNUSEDELEMENTS, false);
columnwidths[0] = getInt(memento, KEY_COLUMN0, DEFAULT_COLUMNWIDTH[0]);
columnwidths[1] = getInt(memento, KEY_COLUMN1, DEFAULT_COLUMNWIDTH[1]);
columnwidths[2] = getInt(memento, KEY_COLUMN2, DEFAULT_COLUMNWIDTH[2]);
columnwidths[3] = getInt(memento, KEY_COLUMN3, DEFAULT_COLUMNWIDTH[3]);
columnwidths[4] = getInt(memento, KEY_COLUMN4, DEFAULT_COLUMNWIDTH[4]);
columnwidths[0] = getWidth(memento, KEY_COLUMN0, DEFAULT_COLUMNWIDTH[0]);
columnwidths[1] = getWidth(memento, KEY_COLUMN1, DEFAULT_COLUMNWIDTH[1]);
columnwidths[2] = getWidth(memento, KEY_COLUMN2, DEFAULT_COLUMNWIDTH[2]);
columnwidths[3] = getWidth(memento, KEY_COLUMN3, DEFAULT_COLUMNWIDTH[3]);
columnwidths[4] = getWidth(memento, KEY_COLUMN4, DEFAULT_COLUMNWIDTH[4]);
linked = getBoolean(memento, KEY_LINKED, false);
}

Expand All @@ -179,6 +179,11 @@ public void save(IMemento memento) {
memento.putBoolean(KEY_LINKED, linked);
}

private int getWidth(IMemento memento, String key, int preset) {
final int w = getInt(memento, key, preset);
return w == 0 ? preset : w;
}

private int getInt(IMemento memento, String key, int preset) {
if (memento == null) {
return preset;
Expand Down

0 comments on commit 814af34

Please sign in to comment.