Prevent unnecessary refresh when setting up Image View groupBy/pileBy

This commit is contained in:
drdev
2014-02-04 04:35:42 +00:00
parent b38346e00c
commit c1e72c380b
2 changed files with 16 additions and 8 deletions

View File

@@ -294,8 +294,8 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel {
}
public void setup(final Map<ColumnDef, ItemColumn> cols, GroupDef groupBy, ColumnDef pileBy) {
this.listView.setup(cols);
this.imageView.setGroupBy(groupBy);
this.imageView.setPileBy(pileBy);
this.imageView.setGroupBy(groupBy, true);
this.imageView.setPileBy(pileBy, true);
}
public void setViewIndex(int index) {

View File

@@ -148,12 +148,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
});
groups.add(new Group("")); //add default group
getScroller().setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}
public GroupDef getGroupBy() {
return groupBy;
}
public void setGroupBy(GroupDef groupBy0) {
setGroupBy(groupBy, false);
}
public void setGroupBy(GroupDef groupBy0, boolean forSetup) {
if (groupBy == groupBy0) { return; }
groupBy = groupBy0;
@@ -168,19 +172,23 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
}
refresh(this.getSelectedItems(), this.getSelectedIndex());
if (!forSetup) {
refresh(this.getSelectedItems(), this.getSelectedIndex());
}
}
public ColumnDef getPileBy() {
return pileBy;
}
public void setPileBy(ColumnDef pileBy0) {
setPileBy(pileBy0, false);
}
public void setPileBy(ColumnDef pileBy0, boolean forSetup) {
if (pileBy == pileBy0) { return; }
pileBy = pileBy0;
if (pileBy == null) {
getScroller().setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}
else {
getScroller().setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
if (!forSetup) {
refresh(this.getSelectedItems(), this.getSelectedIndex());
}
}