All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fife.tmm.TmmPanel Maven / Gradle / Ivy

Go to download

An application to easily create syntax highlighting for custom languages in RSyntaxTextArea.

The newest version!
package org.fife.tmm;

import java.awt.Component;
import java.awt.Container;

import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JPanel;

import org.fife.ui.UIUtil;


/**
 * Base class for panels in the tabbed pane.
 *
 * @author Robert Futrell
 * @version 1.0
 */
abstract class TmmPanel {

	/**
	 * Client property set on the child JPanel to reference this
	 * TmmPanel.  This is a hack to make our code simpler in
	 * other places.
	 */
	public static final String PROPERTY_TMM_PANEL		= "tmmPanel";

	protected static final String DONT_ENABLE			= "DontEnable";

	protected TokenMakerMaker app;
	protected JPanel panel;


	TmmPanel(TokenMakerMaker app) {
		this.app = app;
		panel = UIUtil.newTabbedPanePanel();
		panel.putClientProperty(PROPERTY_TMM_PANEL, this);
	}


	/**
	 * Sets the options in a {@link TokenMakerInfo} that this panel
	 * knows about.
	 *
	 * @param info The object to configure.
	 * @see #initializeFrom(TokenMakerInfo)
	 */
	public abstract void configureTokenMakerInfo(TokenMakerInfo info);


	/**
	 * Creates a non-opaque check box.
	 *
	 * @param text The text for the check box.
	 * @return The check box.
	 * @see #createCheckBox(String, boolean)
	 */
	protected JCheckBox createCheckBox(String text) {
		return createCheckBox(text, false);
	}


	/**
	 * Creates a non-opaque check box.
	 *
	 * @param text The text for the check box.
	 * @param selected Whether it is initially selected.
	 * @return The check box.
	 * @see #createCheckBox(String)
	 */
	protected JCheckBox createCheckBox(String text, boolean selected) {
		JCheckBox cb = new JCheckBox(text, selected);
		cb.setOpaque(false);
		return cb;
	}


	private static int getIndexOf(Container parent, Component c) {
		for (int i=0; i-1) { // Always true
			for (int i=index+1; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy