@Override public int getDockActionCount(){ int count = source.getDockActionCount(); if( count > 0 ){ count++; } return count; }
public int getDockActionCount(){ if( delegate == null ){ return 0; } return delegate.getDockActionCount(); }
public int getDockActionCount(){ if( source == null ) return 0; else return source.getDockActionCount(); }
public int getDockActionCount(){ if( delegate == null ){ return 0; } return delegate.getDockActionCount(); }
public int getDockActionCount(){ if( source == null ) return 0; else return source.getDockActionCount(); }
public int getDockActionCount(){ DockActionSource source = source(); if( source == null ){ return 0; } else{ return source.getDockActionCount(); } }
public boolean suppress( Dockable dockable, DockActionSource source ) { if( source.getDockActionCount() > 1 ) return false; DockTitle[] titles = dockable.listBoundTitles(); if( titles == null || titles.length == 0 ) return false; return true; } };
public int getDockActionCount(){ DockActionSource source = source(); if( source == null ){ return 0; } else{ return source.getDockActionCount(); } }
/** * Gets the index of the child-source which contains <code>action</code>. * @param action the action for which is searched * @return the index of the source which contains the action or -1 */ protected int getSource( DockAction action ){ for( int i = 0, n = sources.size(); i<n; i++ ){ DockActionSource source = sources.get( i ); for( int j = 0, m = source.getDockActionCount(); j<m; j++ ){ if( source.getDockAction( j ) == action ) return i; } } return -1; }
public DockAction getDockAction( int index ) { if( listeners.isEmpty() ) updateSeparators(); int sum = 0; for( int i = 0, n = sources.size(); i<n; i++ ){ int length = sources.get( i ).getDockActionCount(); if( sum <= index && index < sum + length ) return sources.get( i ).getDockAction( index - sum ); sum += length; } throw new ArrayIndexOutOfBoundsException(); }
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; }
/** * Counts how many {@link DockAction DockActions} are provided by the * source-children with index 0 (incl) to <code>index</code> (excl). * @param index the index of the first source that should not be counted * @param allowUpdate whether the {@link #updateSeparators()} can be called * by this method or not * @return the number of actions of the first <code>index</code> * child-sources. */ protected int getDockActionCountUntil( int index, boolean allowUpdate ){ if( allowUpdate && listeners.isEmpty() ) updateSeparators(); int sum = 0; for( int i = 0; i < index; i++ ) sum += sources.get( i ).getDockActionCount(); return sum; }
@Override public void actionsRemoved( DockActionSource source, int firstIndex, int lastIndex ){ if( source.getDockActionCount() == 0 ){ fireRemoved( 0, lastIndex+1 ); } else{ fireRemoved( firstIndex+1, lastIndex+1 ); } }
@Override public void actionsAdded( DockActionSource source, int firstIndex, int lastIndex ){ int count = lastIndex - firstIndex + 1; if( count == source.getDockActionCount() ){ fireAdded( 0, lastIndex+1 ); } else{ fireAdded( firstIndex+1, lastIndex+1 ); } } };
/** * Removes all listeners added by this listener. */ public void destroy(){ DockActionSource source = dockable.getGlobalActionOffers(); source.removeDockActionSourceListener( this ); actionsRemoved( source, 0, source.getDockActionCount()-1 ); }
public void update( boolean last ){ if( !separateSources || last ) remove( SeparatorAction.SEPARATOR ); else if( predecessor.getDockActionCount() > 0 && getDockActionCount() == 0 ) add( SeparatorAction.SEPARATOR ); } }
/** * Creates a new observer * @param dockable the element whose actions will be managed */ public SourceObserver( Dockable dockable ){ this.dockable = dockable; DockActionSource source = dockable.getGlobalActionOffers(); actionsAdded( source, 0, source.getDockActionCount()-1 ); source.addDockActionSourceListener( this ); }
/** * Adds a source as child of this source. All {@link DockAction DockActions} * of <code>source</code> will be presented as actions of this source.<br> * Note: creating circles or adding a source more than once will lead to * unspecified behavior. * @param source the new child */ public void add( DockActionSource source ){ SeparatorSource separator = new SeparatorSource( source ); sources.add( source ); sources.add( separator ); separators.add( separator ); if( !listeners.isEmpty() ){ source.addDockActionSourceListener( listener ); separator.addDockActionSourceListener( listener ); } int index = getDockActionCountUntil( sources.size()-2, false ); int length = source.getDockActionCount(); if( length > 0 ) fireAdded( index, index+length-1 ); updateSeparators(); }
@Override public void bind() { super.bind(); source.addDockActionSourceListener( sourceListener ); for( int i = 0, n = source.getDockActionCount(); i<n; i++ ){ DockAction action = source.getDockAction( i ); ActionItem item = new ActionItem(); item.action = action; actions.add( item ); MenuViewItem<JComponent> handler = handlerFor( action ); if( handler != null ){ item.handler = handler; item.bind(); item.action.bind( dockable ); handler.bind(); if( handler.getItem() != null ){ menu.add( handler.getItem() ); } } } }