Search in sources :

Example 1 with ShowColumnPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent in project nebula.widgets.nattable by eclipse.

the class ShowColumnPositionsEventDiffTest method before.

@Before
public void before() {
    this.dataLayer = new DataLayerFixture(20, 20, 100, 40);
    this.hideShowLayer = new ColumnHideShowLayer(this.dataLayer);
    this.viewportLayer = new ViewportLayer(this.hideShowLayer);
    this.viewportLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 800, 400);
        }
    });
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(2));
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(2));
    this.event = new ShowColumnPositionsEvent(this.dataLayer, Arrays.asList(new Integer[] { 2, 4, 7, 8, 9 }));
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) ShowColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent) Before(org.junit.Before)

Example 2 with ShowColumnPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent in project nebula.widgets.nattable by eclipse.

the class ColumnHideShowLayer method showAllColumns.

@Override
public void showAllColumns() {
    Collection<Integer> hiddenColumns = new ArrayList<Integer>(this.hiddenColumnIndexes);
    this.hiddenColumnIndexes.clear();
    invalidateCache();
    fireLayerEvent(new ShowColumnPositionsEvent(this, hiddenColumns));
}
Also used : ArrayList(java.util.ArrayList) ShowColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent)

Example 3 with ShowColumnPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent in project nebula.widgets.nattable by eclipse.

the class ColumnGroupExpandCollapseCommandHandler method doCommand.

@Override
protected boolean doCommand(ColumnGroupExpandCollapseCommand command) {
    int columnIndex = this.columnGroupExpandCollapseLayer.getColumnIndexByPosition(command.getColumnPosition());
    ColumnGroupModel model = this.columnGroupExpandCollapseLayer.getModel(command.getRowPosition());
    ColumnGroup columnGroup = model.getColumnGroupByIndex(columnIndex);
    // further operation ...
    if (columnGroup == null || !columnGroup.isCollapseable()) {
        return true;
    }
    List<Integer> columnIndexes = new ArrayList<Integer>(columnGroup.getMembers());
    columnIndexes.removeAll(columnGroup.getStaticColumnIndexes());
    boolean wasCollapsed = columnGroup.isCollapsed();
    if (wasCollapsed) {
        // we need to cleanup the column position list before we toggle
        // because the columns are hidden before the toggle and will be
        // visible afterwards
        cleanupColumnIndexes(columnIndexes);
    }
    columnGroup.toggleCollapsed();
    if (!wasCollapsed) {
        // we need to cleanup the column position list after we toggle
        // because the columns are hidden now
        cleanupColumnIndexes(columnIndexes);
    }
    ILayerEvent event;
    if (wasCollapsed) {
        event = new ShowColumnPositionsEvent(this.columnGroupExpandCollapseLayer, columnIndexes);
    } else {
        event = new HideColumnPositionsEvent(this.columnGroupExpandCollapseLayer, columnIndexes);
    }
    this.columnGroupExpandCollapseLayer.fireLayerEvent(event);
    return true;
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) HideColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent) ArrayList(java.util.ArrayList) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup) ColumnGroupModel(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel) ShowColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent)

Example 4 with ShowColumnPositionsEvent

use of org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent in project nebula.widgets.nattable by eclipse.

the class ColumnHideShowLayer method showColumnIndexes.

@Override
public void showColumnIndexes(Collection<Integer> columnIndexes) {
    this.hiddenColumnIndexes.removeAll(columnIndexes);
    invalidateCache();
    fireLayerEvent(new ShowColumnPositionsEvent(this, getColumnPositionsByIndexes(columnIndexes)));
}
Also used : ShowColumnPositionsEvent(org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent)

Aggregations

ShowColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.ShowColumnPositionsEvent)4 ArrayList (java.util.ArrayList)2 ColumnGroupModel (org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel)1 ColumnGroup (org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)1 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)1 HideColumnPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideColumnPositionsEvent)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)1 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)1 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Before (org.junit.Before)1