Package com.cedarsoft.spring.rcp.tbpanel

Source Code of com.cedarsoft.spring.rcp.tbpanel.CommandsBarButtonConfigurer

package com.cedarsoft.spring.rcp.tbpanel;

import org.springframework.richclient.command.AbstractCommand;
import org.springframework.richclient.command.config.CommandFaceDescriptor;
import org.springframework.richclient.command.config.DefaultCommandButtonConfigurer;
import org.springframework.richclient.image.ShadowedIcon;

import javax.swing.AbstractButton;
import javax.swing.JButton;
import java.awt.Insets;

/**
* Configures the buttons for a commands bar
*/
public class CommandsBarButtonConfigurer extends DefaultCommandButtonConfigurer {
  private boolean showText = false;

  private boolean textBelowIcon = true;

  private boolean enableShadow = false;

  public boolean isEnableShadow() {
    return enableShadow;
  }

  public void setEnableShadow( boolean enableShadow ) {
    this.enableShadow = enableShadow;
  }

  public void setTextBelowIcon( boolean textBelowIcon ) {
    this.textBelowIcon = textBelowIcon;
  }

  public boolean isTextBelowIcon() {
    return textBelowIcon;
  }

  public void setShowText( boolean showText ) {
    this.showText = showText;
  }

  public boolean isShowText() {
    return showText;
  }

  @Override
  public void configure( AbstractButton button, AbstractCommand command, CommandFaceDescriptor faceDescriptor ) {
    super.configure( button, command, faceDescriptor );

    if ( textBelowIcon ) {
      button.setHorizontalTextPosition( JButton.CENTER );
      button.setVerticalTextPosition( JButton.BOTTOM );
    }

    if ( !showText ) {
      if ( button.getIcon() != null ) {
        button.setText( null );
      }
    }

    if ( enableShadow && button.getIcon() != null && button.getRolloverIcon() == null ) {
      button.setRolloverEnabled( true );
      button.setRolloverIcon( new ShadowedIcon( button.getIcon() ) );
    }

    button.setMargin( new Insets( 5, 2, 5, 2 ) );
  }
}
TOP

Related Classes of com.cedarsoft.spring.rcp.tbpanel.CommandsBarButtonConfigurer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.