package de.visone.nlpext.gui;

import java.awt.Dimension;

import javax.swing.JOptionPane;
import javax.swing.JPanel;

import de.visone.base.Mediator;
import de.visone.ext.nlp.NLPTextPane;

/**
 * This abstract panel encapsulates methods and fields that are common to all
 * panels used within nlp extension: standard space between components, handling
 * the mediator, popping up an error dialog and the like
 * 
 * @author endele
 */
public abstract class AbstractNLPPanel extends JPanel {

	// UID has to be specified since inheriting from serializable
	private static final long serialVersionUID = -4993624301112220418L;

	// defines space between components
	protected static final int GAP = 10;

	// defines standard dimension of text fields
	protected static final Dimension TF_DIM = new Dimension(197, 19);

	protected Mediator mediator;

	public AbstractNLPPanel(final Mediator mediator) {
		this.mediator = mediator;
		init();
	}

	/** Initialize components. */
	protected void init() {
	}

	/** Pops up an error dialog modal to the visone main window. */
	protected void error(final String msg) {
		JOptionPane.showMessageDialog(mediator.getWindow(), msg,
				NLPTextPane.ERROR_TITLE, JOptionPane.ERROR_MESSAGE);
	}

	/** Pops up an information dialog modal to the visone main window. */
	protected void information(final String msg) {
		JOptionPane.showMessageDialog(mediator.getWindow(), msg, null,
				JOptionPane.INFORMATION_MESSAGE);
	}
}
