public void actionsRemoved( DockActionSource source, int firstIndex, int lastIndex ){ // find location to remove old actions int remove = 0; for( int i = 0; i < firstIndex; i++ ){ if( actions.get( i )){ remove++; } } // remove old actions int count = 0; for( int i = lastIndex; i >= firstIndex; i-- ){ if( actions.remove( i )) count++; } // fire events if( count > 0 ){ fireRemoved( remove, remove+count-1 ); } } }
private void advance(){ while( iterator.hasNext() ){ DockAction check = iterator.next(); if( include( check )){ next = check; return; } } next = null; }
/** * Recalculates the visibility of all actions and fires events to the registered {@link DockActionSourceListener} * if the state of an action changed. */ public void refresh(){ if( actions != null ){ int index = 0; for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ boolean include = include( source.getDockAction( i ) ); if( include != actions.get( i ).booleanValue() ){ actions.set( i, include ); if( include ){ // action has been added fireAdded( index, index ); } else{ // action was removed fireRemoved( index, index ); } } if( include ){ index++; } } } }
public void actionsAdded( DockActionSource source, int firstIndex, int lastIndex ){ // find location to insert new actions int insert = 0; for( int i = 0; i < firstIndex; i++ ){ if( actions.get( i )){ insert++; } } // filter new actions int count = 0; for( int i = firstIndex; i <= lastIndex; i++ ){ DockAction action = source.getDockAction( i ); boolean include = include( action ); actions.add( i, include ); if( include ){ count++; } } // fire events if( count > 0 ){ fireAdded( insert, insert+count-1 ); } }
/** * Recalculates the visibility of all actions and fires events to the registered {@link DockActionSourceListener} * if the state of an action changed. */ public void refresh(){ if( actions != null ){ int index = 0; for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ boolean include = include( source.getDockAction( i ) ); if( include != actions.get( i ).booleanValue() ){ actions.set( i, include ); if( include ){ // action has been added fireAdded( index, index ); } else{ // action was removed fireRemoved( index, index ); } } if( include ){ index++; } } } }
public void actionsAdded( DockActionSource source, int firstIndex, int lastIndex ){ // find location to insert new actions int insert = 0; for( int i = 0; i < firstIndex; i++ ){ if( actions.get( i )){ insert++; } } // filter new actions int count = 0; for( int i = firstIndex; i <= lastIndex; i++ ){ DockAction action = source.getDockAction( i ); boolean include = include( action ); actions.add( i, include ); if( include ){ count++; } } // fire events if( count > 0 ){ fireAdded( insert, insert+count-1 ); } }
private void advance(){ while( iterator.hasNext() ){ DockAction check = iterator.next(); if( include( check )){ next = check; return; } } next = null; }
public void actionsRemoved( DockActionSource source, int firstIndex, int lastIndex ){ // find location to remove old actions int remove = 0; for( int i = 0; i < firstIndex; i++ ){ if( actions.get( i )){ remove++; } } // remove old actions int count = 0; for( int i = lastIndex; i >= firstIndex; i-- ){ if( actions.remove( i )) count++; } // fire events if( count > 0 ){ fireRemoved( remove, remove+count-1 ); } } }
@Override public void addDockActionSourceListener( DockActionSourceListener listener ){ if( listeners.isEmpty() ){ source.addDockActionSourceListener( this.listener ); actions = new ArrayList<Boolean>(); for( DockAction action : source ){ actions.add( include( action )); } } super.addDockActionSourceListener( listener ); }
public int getDockActionCount(){ int count = 0; if( actions == null ){ for( DockAction action : source ){ if( include( action )) count++; } } else{ for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ if( actions.get( i )) count++; } } return count; }
public int getDockActionCount(){ int count = 0; if( actions == null ){ for( DockAction action : source ){ if( include( action )) count++; } } else{ for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ if( actions.get( i )) count++; } } return count; }
@Override public void addDockActionSourceListener( DockActionSourceListener listener ){ if( listeners.isEmpty() ){ source.addDockActionSourceListener( this.listener ); actions = new ArrayList<Boolean>(); for( DockAction action : source ){ actions.add( include( action )); } } super.addDockActionSourceListener( listener ); }
public DockAction getDockAction( int index ){ if( index < 0 ) throw new IllegalArgumentException( "Index out of bounds: " + index ); int count = -1; if( actions == null ){ for( DockAction action : source ){ if( include( action )){ count++; if( index == count ) return action; } } } else{ for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ if( actions.get( i )){ count++; if( index == count ) return source.getDockAction( i ); } } } throw new IllegalArgumentException( "Index out of bounds: " + index ); }
public DockAction getDockAction( int index ){ if( index < 0 ) throw new IllegalArgumentException( "Index out of bounds: " + index ); int count = -1; if( actions == null ){ for( DockAction action : source ){ if( include( action )){ count++; if( index == count ) return action; } } } else{ for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ if( actions.get( i )){ count++; if( index == count ) return source.getDockAction( i ); } } } throw new IllegalArgumentException( "Index out of bounds: " + index ); }