/** * Adds a separator at the end of the current list of actions */ public void addSeparator(){ add( SeparatorAction.SEPARATOR ); }
public void actionsAdded( DockActionSource source, int firstIndex, int lastIndex ) { int index = getDockActionCountUntil( sources.indexOf( source ), false ); fireAdded( firstIndex + index, lastIndex + index ); updateSeparators(); }
/** * Removes <code>source</code> from this {@link MultiDockActionSource}. * @param source the child to remove */ public void remove( DockActionSource source ){ int index = sources.indexOf( source ); if( index < 0 ) return; SeparatorSource separator = (SeparatorSource)sources.get( index+1 ); int actionIndex = getDockActionCountUntil( index, false ); int length = source.getDockActionCount(); sources.remove( index+1 ); sources.remove( index ); separators.remove( separator ); if( !listeners.isEmpty() ){ source.removeDockActionSourceListener( listener ); separator.removeDockActionSourceListener( listener ); } if( length > 0 ){ fireRemoved( actionIndex, index+length-1 ); } updateSeparators(); }
public void actionsRemoved( DockActionSource source, int firstIndex, int lastIndex ) { int index = getDockActionCountUntil( sources.indexOf( source ), false ); fireRemoved( firstIndex + index, lastIndex + index ); updateSeparators(); } }
/** * Removes all children of this source. */ public void removeAll(){ int length = getDockActionCount(); if( !listeners.isEmpty() ){ for( SeparatorSource source : separators ){ source.removeDockActionSourceListener( listener ); } for( DockActionSource source : sources ){ source.removeDockActionSourceListener( listener ); } } separators.clear(); sources.clear(); if( length > 0 ){ fireRemoved( 0, length-1 ); } }
public DockActionSource getSource( Dockable dockable, DockActionSource source, DockActionSource[] guards, DockActionSource parent, DockActionSource[] parents ){ MultiDockActionSource multiSource = new MultiDockActionSource(); multiSource.setHint( new LocationHint( LocationHint.ACTION_OFFER, LocationHint.MIDDLE )); multiSource.setSeparateSources( isSeparators() ); multiSource.add( action );
private void updateActionSource( boolean force ){ boolean showChildren = behavior.isShowChildren(); boolean showActions = behavior.isShowActions(); boolean filterActions = behavior.isFilterActions(); if( force || this.showChildren != showChildren || this.showActions != showActions || this.filterActions != filterActions ){ allActionsSource.removeAll(); if( showChildren ){ allActionsSource.add( getChildrenActionSourceFor( getDockable() ) ); } if( showActions ){ if( filterActions ){ allActionsSource.add( createFilter( getDefaultActionSourceFor( getDockable() ) ) ); } else{ allActionsSource.add( getDefaultActionSourceFor( getDockable() ) ); } } this.showChildren = showChildren; this.showActions = showActions; } }
@Override public DockActionSource getSharedActions( DockStation station ){ Dockable selected = station.getFrontDockable(); if( selected == null ){ return null; } LocationMode mode = getCurrentMode( selected ); if( mode == null ){ return null; } MultiDockActionSource result = new MultiDockActionSource(); for( LocationMode other : modes() ){ if( behavior.shouldForwardActions( this, station, selected, other.getExtendedMode() ) ){ DockActionSource source = other.getActionsFor( selected, mode ); if( source != null ){ result.add( source ); } } } return result; }
/** * 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(); }
/** * Creates a new title. * @param dockable the dockable for which this title will be shown * @param origin the {@link DockTitleVersion} which was used to create this title */ public BubbleButtonDockTitle( Dockable dockable, DockTitleVersion origin ) { if( origin != null ){ connector.setProperties( origin.getController() ); } behavior = new ButtonContentValue( new ButtonContent( TRUE, TRUE, IF_DOCKABLE, IF_STATION, TRUE, TRUE ) ){ @Override protected void propertyChanged(){ updateContent(); } }; init( dockable, origin, false ); allActionsSource.setSeparateSources( true ); updateContent(); }
private void updateActionSource( boolean force ){ boolean showChildren = behavior.isShowChildren(); boolean showActions = behavior.isShowActions(); boolean filterActions = behavior.isFilterActions(); if( force || this.showChildren != showChildren || this.showActions != showActions || this.filterActions != filterActions ){ allActionsSource.removeAll(); if( showChildren ){ allActionsSource.add( getChildrenActionSourceFor( getDockable() ) ); } if( showActions ){ if( filterActions ){ allActionsSource.add( createFilter( getDefaultActionSourceFor( getDockable() ) ) ); } else{ allActionsSource.add( getDefaultActionSourceFor( getDockable() ) ); } } this.showChildren = showChildren; this.showActions = showActions; } }
@Override public DockActionSource getSharedActions( DockStation station ){ Dockable selected = station.getFrontDockable(); if( selected == null ){ return null; } LocationMode mode = getCurrentMode( selected ); if( mode == null ){ return null; } MultiDockActionSource result = new MultiDockActionSource(); for( LocationMode other : modes() ){ if( behavior.shouldForwardActions( this, station, selected, other.getExtendedMode() ) ){ DockActionSource source = other.getActionsFor( selected, mode ); if( source != null ){ result.add( source ); } } } return result; }
/** * Creates a new title. * @param dockable the dockable for which this title will be shown * @param origin the {@link DockTitleVersion} which was used to create this title */ public BubbleButtonDockTitle( Dockable dockable, DockTitleVersion origin ) { if( origin != null ){ connector.setProperties( origin.getController() ); } behavior = new ButtonContentValue( new ButtonContent( TRUE, TRUE, IF_DOCKABLE, IF_STATION, TRUE, TRUE ) ){ @Override protected void propertyChanged(){ updateContent(); } }; init( dockable, origin, false ); allActionsSource.setSeparateSources( true ); updateContent(); }
private void updateActionSource( boolean force ){ boolean showChildren = behavior.isShowChildren(); boolean showActions = behavior.isShowActions(); boolean filterActions = behavior.isFilterActions(); if( force || this.showChildren != showChildren || this.showActions != showActions || this.filterActions != filterActions ){ allActionsSource.removeAll(); if( showChildren ){ allActionsSource.add( getChildrenActionSourceFor( getDockable() ) ); } if( showActions ){ if( filterActions ){ allActionsSource.add( createFilter( getDefaultActionSourceFor( getDockable() ) ) ); } else{ allActionsSource.add( getDefaultActionSourceFor( getDockable() ) ); } } this.showChildren = showChildren; this.showActions = showActions; } }
/** * Adds several actions to this source. * @param actions the new actions */ public void add( DockAction... actions ){ add( new DefaultDockActionSource( actions )); }
allActionsSource.setSeparateSources( true ); updateContent();