public BasicTitleViewItem<JComponent> create( ActionViewConverter converter, DropDownAction action, Dockable dockable ){ BasicDropDownButtonHandler handler = new BasicDropDownButtonHandler( action, dockable ); DropDownMiniButton button = new DropDownMiniButton( handler ); handler.setModel( button.getModel() ); return handler; } });
@Override public void updateUI() { disabledDropIcon = null; super.updateUI(); if( handler != null ) handler.updateUI(); } }
/** * Gets an icon that can be used to represent an area that opens the popup menu when clicked. * @return an icon, not <code>null</code> */ public Icon getDropDownIcon(){ ensureDropDownIcon(); return dropDownIcon; }
public void actionTextChanged( StandardDockAction action, Set<Dockable> dockables ){ if( dockables.contains( getDockable() )) update(); }
public void showTextChanged( ButtonContentFilter filter, Dockable dockable, DockAction action ){ if( (action == null || action == getAction()) && (dockable == null || dockable == getDockable())){ buttonView.updateText(); } } };
public void actionEnabledChanged( StandardDockAction action, Set<Dockable> dockables ){ Dockable dockable = getDockable(); if( dockables.contains( dockable )) getModel().setEnabled( action.isEnabled( dockable ) ); }
public void bind(){ DropDownAction action = getAction(); Dockable dockable = getDockable(); dropDownIcon.init( getDockable(), getAction(), this ); add( i, sub ); reset(); selection = items.get( action.getSelection( dockable ) ); if( selection != null ) source.addDockActionSourceListener( listener ); getModel().setEnabled( action.isEnabled( dockable ) ); buttonContentFilter.setProperties( dockable.getController() );
public void unbind(){ DropDownAction action = getAction(); Dockable dockable = getDockable(); remove( i ); getModel().setDockableRepresentative( null );
/** * Creates a new button. * @param handler handler for the internal states of this button */ public DropDownMiniButton( BasicDropDownButtonHandler handler ){ super( null ); this.handler = handler; BasicDropDownButtonModel model = new BasicDropDownButtonModel( this, handler, handler ){ @Override public void changed() { updateBorder(); repaint(); } @Override protected boolean inDropDownArea( int x, int y ) { return isOverDropIcon( x, y ); } }; setModel( model ); dropIcon = handler.getDropDownIcon(); }
if( !isEnabled() ){ if( disabledDropIcon == null ) disabledDropIcon = handler.getDisabledDropDownIcon(); drop = disabledDropIcon;
private void ensureDropDownIcon(){ if( dropDownIcon == null ){ dropDownIcon = new DropDownIcon(); if( isBound() ){ dropDownIcon.init( getDockable(), getAction(), this ); dropDownIcon.setController( getDockable().getController() ); } } }
/** * Updates the text that is shown by the button, respects the {@link BasicDropDownButtonHandler#buttonContentFilter}. */ public void updateText(){ if( buttonContentFilter.getValue().showText( getDockable(), getAction() )){ getModel().setText( text ); } else{ getModel().setText( null ); } }
public void setBackground( Color background ) { Component item = getItem(); if( item != null ) item.setBackground( background ); }
/** * Creates a new button. * @param handler handler for the internal states of this button */ public DropDownMiniButton( BasicDropDownButtonHandler handler ){ super( null ); this.handler = handler; BasicDropDownButtonModel model = new BasicDropDownButtonModel( this, handler, handler ){ @Override public void changed() { updateBorder(); repaint(); } @Override protected boolean inDropDownArea( int x, int y ) { return isOverDropIcon( x, y ); } }; setModel( model ); dropIcon = handler.getDropDownIcon(); }
if( !isEnabled() ){ if( disabledDropIcon == null ) disabledDropIcon = handler.getDisabledDropDownIcon(); drop = disabledDropIcon;
@Override protected void valueChanged( ButtonContentFilter oldValue, ButtonContentFilter newValue ){ if( isBound() ){ if( oldValue != null ){ oldValue.removeListener( buttonContentFilterListener ); oldValue.uninstall( getDockable(), getAction() ); } if( newValue != null ){ newValue.addListener( buttonContentFilterListener ); newValue.install( getDockable(), getAction() ); } } buttonView.updateText(); } };
public void actionRepresentativeChanged( StandardDockAction action, Set<Dockable> dockables ){ if( dockables.contains( getDockable() )) update(); }
/** * Adds an action into the list of all known actions. * @param index the location of the action * @param action the new action */ private void add( int index, DockAction action ){ Dockable dockable = getDockable(); actions.add( index, action ); DropDownViewItem item = action.createView( ViewTarget.DROP_DOWN, dockable.getController().getActionViewConverter(), dockable ); if( item != null ){ DropDownItemHandle entry = new DropDownItemHandle( action, item, dockable, getAction() ); entry.bind(); items.put( action, entry ); if( item.getItem() != null ){ menu.add( item.getItem() ); } } }
public void setForeground( Color foreground ) { Component item = getItem(); if( item != null ) item.setForeground( foreground ); }
public BasicTitleViewItem<JComponent> create( ActionViewConverter converter, DropDownAction action, Dockable dockable ){ BasicDropDownButtonHandler handler = new BasicDropDownButtonHandler( action, dockable ); DropDownMiniButton button = new DropDownMiniButton( handler ); handler.setModel( button.getModel() ); return handler; } });