Package com.cedarsoft.spring.rcp.editor

Source Code of com.cedarsoft.spring.rcp.editor.TitledEditor

package com.cedarsoft.spring.rcp.editor;

import org.jetbrains.annotations.NotNull;
import org.springframework.richclient.core.DefaultMessage;
import org.springframework.richclient.core.UIConstants;
import org.springframework.richclient.dialog.TitlePane;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import java.awt.BorderLayout;

/**
* An editor with a title
*
* @param <T> the type of the editor
*/
public abstract class TitledEditor<T> extends ExtendedEditor<T> {
  /**
   * @noinspection RefusedBequest
   */
  @Override
  public JComponent getControl() {
    if ( control == null ) {
      control = new JPanel( new BorderLayout() );

      TitlePane titlePane = new TitlePane();
      titlePane.setTitle( getTitle() );
      titlePane.setMessage( new DefaultMessage( getMessage() ) );

      JPanel titlePaneContainer = new JPanel( new BorderLayout() );
      titlePaneContainer.add( titlePane.getControl(), BorderLayout.CENTER );
      titlePaneContainer.add( new JSeparator(), BorderLayout.SOUTH );

      control.add( BorderLayout.NORTH, titlePaneContainer );
      JComponent content = createControl();
      content.setBorder( BorderFactory.createEmptyBorder( UIConstants.ONE_SPACE, UIConstants.TWO_SPACES, UIConstants.ONE_SPACE, UIConstants.TWO_SPACES ) );
      control.add( BorderLayout.CENTER, content );
    }
    return control;
  }

  @NotNull
  protected abstract String getTitle();

  @NotNull
  protected abstract String getMessage();
}
TOP

Related Classes of com.cedarsoft.spring.rcp.editor.TitledEditor

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.