use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.
the class RowReorderLayer method loadState.
@Override
public void loadState(String prefix, Properties properties) {
super.loadState(prefix, properties);
String property = properties.getProperty(prefix + PERSISTENCE_KEY_ROW_INDEX_ORDER);
if (property != null) {
List<Integer> newRowIndexOrder = new ArrayList<Integer>();
StringTokenizer tok = new StringTokenizer(property, IPersistable.VALUE_SEPARATOR);
while (tok.hasMoreTokens()) {
String index = tok.nextToken();
newRowIndexOrder.add(Integer.valueOf(index));
}
if (isRestoredStateValid(newRowIndexOrder)) {
this.rowIndexOrder.clear();
this.rowIndexOrder.addAll(newRowIndexOrder);
// refresh index-position mapping
refreshIndexPositionMapping();
}
}
invalidateCache();
fireLayerEvent(new RowStructuralRefreshEvent(this));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.
the class RowSelectionPreserver method handleLayerEvent.
/**
* On a change in the underlying data:
* <ol>
* <li>Clears the selection
* <li>Re-select the row objects selected earlier.
* </ol>
*/
@Override
public void handleLayerEvent(IVisualChangeEvent event) {
if (ObjectUtils.isEmpty(this.selectedRowObjects)) {
return;
}
if (event instanceof RowStructuralRefreshEvent || event instanceof RowStructuralChangeEvent || event instanceof SortColumnEvent) {
this.selectionLayer.clear();
this.selectionProvider.setSelection(new StructuredSelection(getValidSelections()));
}
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.
the class ComboBoxFilterRowHeaderComposite method doCommand.
@Override
public boolean doCommand(ILayerCommand command) {
boolean handled = false;
if (command instanceof ToggleFilterRowCommand) {
setFilterRowVisible(!this.filterRowVisible);
return true;
} else // to the FilterRowDataLayer
if (command instanceof ClearFilterCommand && command.convertToTargetLayer(this)) {
int columnPosition = ((ClearFilterCommand) command).getColumnPosition();
this.filterRowDataLayer.setDataValueByPosition(columnPosition, 0, getComboBoxDataProvider().getValues(columnPosition, 0));
handled = true;
} else if (command instanceof ClearAllFiltersCommand) {
setAllValuesSelected();
handled = true;
} else if (command instanceof DisposeResourcesCommand) {
this.comboBoxDataProvider.dispose();
}
if (handled) {
fireLayerEvent(new RowStructuralRefreshEvent(this));
return true;
} else {
return super.doCommand(command);
}
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.
the class ComboBoxFilterRowHeaderComposite method setFilterRowVisible.
/**
* Sets the visibility state of the filter row.
*
* @param filterRowVisible
* <code>true</code> to set the filter row visible,
* <code>false</code> to hide it.
*/
public void setFilterRowVisible(boolean filterRowVisible) {
this.filterRowVisible = filterRowVisible;
fireLayerEvent(new RowStructuralRefreshEvent(this.filterRowDataLayer));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent in project nebula.widgets.nattable by eclipse.
the class GroupByDataLayer method update.
@Override
public void update(Observable o, Object arg) {
// if we know the sort model, we need to clear the sort model to avoid
// strange side effects while updating the tree structure (e.g. not
// applied sorting although showing the sort indicator)
// for better user experience we remember the sort state and reapply it
// after the tree update
List<Integer> sortedIndexes = null;
List<SortDirectionEnum> sortDirections = null;
if (this.treeFormat.getSortModel() != null) {
sortedIndexes = this.treeFormat.getSortModel().getSortedColumnIndexes();
sortDirections = new ArrayList<SortDirectionEnum>();
for (Integer index : sortedIndexes) {
sortDirections.add(this.treeFormat.getSortModel().getSortDirection(index));
}
this.treeFormat.getSortModel().clear();
}
updateTree();
// re-apply the sorting after the tree update
if (this.treeFormat.getSortModel() != null) {
for (int i = 0; i < sortedIndexes.size(); i++) {
Integer index = sortedIndexes.get(i);
this.treeFormat.getSortModel().sort(index, sortDirections.get(i), true);
}
}
fireLayerEvent(new RowStructuralRefreshEvent(this));
}
Aggregations