/** * Sets the visibility of the action. The visibility can be changed at any * time and has effect on all occurrences of the action. * @param visible the new state */ public void setVisible( boolean visible ){ if( visible != isVisible() ){ if( visible ) source.add( action ); else source.remove( 0, source.getDockActionCount() ); } }
/** * Gets the <code>index</code>'th action of this menu. * @param index the index of an action * @return the action at <code>index</code> */ public DockAction getDockAction( int index ){ return actions.getDockAction( index ); }
/** * Default constructor, fills the list with some initial actions. * @param hint the preferred location of this source * @param actions The actions to add */ public DefaultDockActionSource( LocationHint hint, DockAction...actions ){ for( DockAction action : actions ) this.actions.add( action ); setHint( hint ); }
/** * Adds all given actions to the end of this source. * @param action The actions to append */ public void add( DockAction...action ){ add( getDockActionCount(), action ); }
/** * Removes all actions stored in this source. */ public void removeAll(){ remove( 0, getDockActionCount() ); }
/** * Creates a new guard * @param controller The controller for which actions are created. */ public ReplaceActionGuard( DockController controller ){ if( controller == null ) throw new IllegalArgumentException( "Controller should not be null" ); action = new ReplaceAction( controller ); source = new DefaultDockActionSource(); source.setHint( new LocationHint( LocationHint.ACTION_GUARD, LocationHint.LEFT )); setVisible( true ); }
/** * Adds a separator at the end of this source */ public void addSeparator(){ add( SeparatorAction.SEPARATOR ); }
public void remove( int index ){ DockAction action = actions.getDockAction( index ); actions.remove( index ); if( getSelection() == action ){ setSelection( (StandardDockAction)null ); } }
public DefaultDockActionSource getDirectActionOffers( Dockable dockable ){ if( fullScreenAction == null ) return null; else { DefaultDockActionSource source = new DefaultDockActionSource(new LocationHint(LocationHint.DIRECT_ACTION, LocationHint.VERY_RIGHT)); source.add(fullScreenAction); return source; } }
/** * Removes the action at <code>index</code> from this source. * @param index The index of the action to remove */ public void remove( int index ){ remove( index, 1 ); }
/** * Adds several actions to this source. * @param actions the new actions */ public void add( DockAction... actions ){ add( new DefaultDockActionSource( actions )); }
/** * Gets the number of {@link DockAction}s that were added to this menu. * @return the number of actions */ public int getActionCount(){ return menu.getDockActionCount(); }
}; DefaultDockActionSource source = new DefaultDockActionSource(); source.add( center ); source.addSeparator(); source.add( north, south, east, west ); setMenu( source );
/** * Removes all actions between <code>index</code> (incl.) * and <code>index+length</code> (excl.). * @param index The index of the first action to remove * @param length The number of actions to remove * @throws IllegalArgumentException If some actions should be removed that * do not exist */ public void remove( int index, int length ){ if( index < 0 ) throw new IllegalArgumentException( "Index must not be negative" ); if( length < 0 ) throw new IllegalArgumentException( "Length must not be negative" ); if( index + length > getDockActionCount() ) throw new IllegalArgumentException( "index + length too great" ); if( length > 0 ){ for( int i = length-1; i>=0; i-- ) actions.remove( index + i ); fireRemoved( index, index+length-1 ); } } }
/** * Creates a new guard * @param controller The controller for which actions are created. */ public ReplaceActionGuard( DockController controller ){ if( controller == null ) throw new IllegalArgumentException( "Controller should not be null" ); action = new ReplaceAction( controller ); source = new DefaultDockActionSource(); source.setHint( new LocationHint( LocationHint.ACTION_GUARD, LocationHint.LEFT )); setVisible( true ); }
/** * Adds a separator at <code>position</code> * @param position the location where to add the separator */ public void addSeparator( int position ){ add( position, SeparatorAction.SEPARATOR ); }