PageRenderTime 123ms CodeModel.GetById 41ms app.highlight 22ms RepoModel.GetById 37ms app.codeStats 1ms

/bundles/plugins-trunk/Console/console/options/ToolBarOptionPane.java

#
Java | 113 lines | 61 code | 22 blank | 30 comment | 2 complexity | 5c06cafee9b545042341c20b1fca6c1a MD5 | raw file
  1/*
  2 * ToolBarOptionPane
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 2005 Alan Ezust
  7 *
  8 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * as published by the Free Software Foundation; either version 2
 11 * of the License, or any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License
 19 * along with this program; if not, write to the Free Software
 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 21 */
 22
 23package console.options;
 24
 25// {{{ imports
 26import java.awt.GridLayout;
 27import java.util.TreeMap;
 28
 29import javax.swing.JCheckBox;
 30import javax.swing.JPanel;
 31
 32import org.gjt.sp.jedit.AbstractOptionPane;
 33import org.gjt.sp.jedit.ActionSet;
 34import org.gjt.sp.jedit.EditAction;
 35import org.gjt.sp.jedit.jEdit;
 36
 37import console.ConsolePlugin;
 38import console.commando.CommandoCommand;
 39import console.commando.CommandoToolBar;
 40
 41// }}}
 42
 43public class ToolBarOptionPane extends AbstractOptionPane
 44{
 45
 46	// {{{ public ToolBarOptionPane()
 47	public ToolBarOptionPane()
 48	{
 49		super("console.toolbar");
 50	}
 51
 52	// }}}
 53	
 54	// {{{ public void _init()
 55	protected void _init()
 56	{
 57
 58		addComponent(enabledCheckBox = new JCheckBox(jEdit
 59			.getProperty("options.console.general.commando.toolbar")));
 60
 61		enabledCheckBox.getModel().setSelected(
 62			jEdit.getBooleanProperty("commando.toolbar.enabled"));
 63
 64
 65		createButtons();
 66	}
 67	// }}}
 68	
 69	// {{{ protected void createButtons()
 70	protected void createButtons()
 71	{
 72
 73		checkBoxes.clear();
 74		ActionSet allActions = ConsolePlugin.getAllCommands();
 75		GridLayout glayout = new GridLayout(0, 3);
 76		addSeparator("options.console.toolbar.buttons");
 77		JPanel buttonPanel = new JPanel();
 78		buttonPanel.setLayout(glayout);
 79
 80		for (EditAction ea : allActions.getActions())
 81		{
 82			CommandoCommand cc = (CommandoCommand) ea;
 83			String label = cc.getShortLabel();
 84			JCheckBox cb = new JCheckBox(label);
 85			boolean selected = jEdit.getBooleanProperty("commando.visible." + label,
 86				true);
 87			cb.setSelected(selected);
 88			checkBoxes.put(label, cb);
 89			buttonPanel.add(cb);
 90		}
 91		addComponent(buttonPanel);
 92	} // }}}
 93
 94	// {{{ protected void _save()
 95	protected void _save()
 96	{
 97		jEdit.setBooleanProperty("commando.toolbar.enabled", enabledCheckBox.isSelected());
 98		for (JCheckBox cb : checkBoxes.values())
 99		{
100			jEdit.setBooleanProperty("commando.visible." + cb.getText(), cb
101				.isSelected());
102		}
103		jEdit.saveSettings();
104		CommandoToolBar.init();
105	}
106	// }}}
107
108	private JCheckBox enabledCheckBox;
109
110	TreeMap<String, JCheckBox> checkBoxes = new TreeMap<String, JCheckBox>();
111}
112
113