Search in sources :

Example 6 with RowStructuralRefreshEvent

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));
}
Also used : StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 7 with RowStructuralRefreshEvent

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()));
    }
}
Also used : SortColumnEvent(org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) RowStructuralChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralChangeEvent)

Example 8 with RowStructuralRefreshEvent

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);
    }
}
Also used : DisposeResourcesCommand(org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand) ClearFilterCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand) ClearAllFiltersCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand) ToggleFilterRowCommand(org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 9 with RowStructuralRefreshEvent

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));
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)

Example 10 with RowStructuralRefreshEvent

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));
}
Also used : RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) SortDirectionEnum(org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum)

Aggregations

RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)16 Test (org.junit.Test)5 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)3 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)2 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2 ClearAllFiltersCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand)2 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 DisposeResourcesCommand (org.eclipse.nebula.widgets.nattable.command.DisposeResourcesCommand)1 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)1 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)1 DiscardDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand)1 SaveDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand)1 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)1 ToggleFilterRowCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand)1 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)1