Search in sources :

Example 1 with ILayerEvent

use of net.sourceforge.nattable.layer.event.ILayerEvent in project translationstudio8 by heartsome.

the class ColumnGroupExpandCollapseCommandHandler method doCommand.

@Override
protected boolean doCommand(ColumnGroupExpandCollapseCommand command) {
    int columnIndex = columnGroupExpandCollapseLayer.getColumnIndexByPosition(command.getColumnPosition());
    ColumnGroupModel model = columnGroupExpandCollapseLayer.getModel();
    boolean wasCollapsed = model.isCollapsed(columnIndex);
    ColumnGroup columnGroup = model.toggleColumnGroupExpandCollapse(columnIndex);
    List<Integer> columnPositions = new ArrayList<Integer>(columnGroup.getMembers());
    columnPositions.remove(0);
    ILayerEvent event;
    if (wasCollapsed) {
        event = new ShowColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions);
    } else {
        event = new HideColumnPositionsEvent(columnGroupExpandCollapseLayer, columnPositions);
    }
    columnGroupExpandCollapseLayer.fireLayerEvent(event);
    return true;
}
Also used : ILayerEvent(net.sourceforge.nattable.layer.event.ILayerEvent) HideColumnPositionsEvent(net.sourceforge.nattable.hideshow.event.HideColumnPositionsEvent) ArrayList(java.util.ArrayList) ColumnGroup(net.sourceforge.nattable.group.ColumnGroupModel.ColumnGroup) ColumnGroupModel(net.sourceforge.nattable.group.ColumnGroupModel) ShowColumnPositionsEvent(net.sourceforge.nattable.hideshow.event.ShowColumnPositionsEvent)

Example 2 with ILayerEvent

use of net.sourceforge.nattable.layer.event.ILayerEvent in project translationstudio8 by heartsome.

the class AbstractLayer method fireLayerEvent.

/**
	 * Pass the event to all the {@link ILayerListener} registered on this layer.
	 * A cloned copy is passed to each listener.
	 */
public void fireLayerEvent(ILayerEvent event) {
    if (listeners.size() > 0) {
        Iterator<ILayerListener> it = listeners.iterator();
        boolean isLastListener = false;
        do {
            ILayerListener l = it.next();
            // Lookahead
            isLastListener = !it.hasNext();
            // Fire cloned event to first n-1 listeners; fire original event to last listener
            ILayerEvent eventToFire = isLastListener ? event : event.cloneEvent();
            //				System.out.println("eventToFire="+eventToFire);
            l.handleLayerEvent(eventToFire);
        } while (!isLastListener);
    }
}
Also used : ILayerEvent(net.sourceforge.nattable.layer.event.ILayerEvent)

Aggregations

ILayerEvent (net.sourceforge.nattable.layer.event.ILayerEvent)2 ArrayList (java.util.ArrayList)1 ColumnGroupModel (net.sourceforge.nattable.group.ColumnGroupModel)1 ColumnGroup (net.sourceforge.nattable.group.ColumnGroupModel.ColumnGroup)1 HideColumnPositionsEvent (net.sourceforge.nattable.hideshow.event.HideColumnPositionsEvent)1 ShowColumnPositionsEvent (net.sourceforge.nattable.hideshow.event.ShowColumnPositionsEvent)1