PageRenderTime 101ms CodeModel.GetById 93ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/options/MouseOptionPane.java

#
Java | 138 lines | 88 code | 18 blank | 32 comment | 6 complexity | a246deac79df229f40b24b63048f5f90 MD5 | raw file
  1/*
  2 * MouseOptionPane.java - Editor window options
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 2003 Slava Pestov
  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 org.gjt.sp.jedit.options;
 24
 25//{{{ Imports
 26import javax.swing.border.*;
 27import javax.swing.*;
 28import java.awt.event.*;
 29import java.awt.*;
 30import java.io.*;
 31import org.gjt.sp.jedit.*;
 32import org.gjt.sp.util.Log;
 33//}}}
 34
 35public class MouseOptionPane extends AbstractOptionPane
 36{
 37	//{{{ MouseOptionPane constructor
 38	public MouseOptionPane()
 39	{
 40		super("mouse");
 41	} //}}}
 42
 43	//{{{ _init() method
 44	protected void _init()
 45	{
 46		/* Text drag and drop */
 47		dragAndDrop = new JCheckBox(jEdit.getProperty(
 48			"options.mouse.dragAndDrop"));
 49		dragAndDrop.setSelected(jEdit.getBooleanProperty(
 50			"view.dragAndDrop"));
 51		addComponent(dragAndDrop);
 52
 53		/* Non word character selection behavior */
 54		joinNonWordChars = new JCheckBox(jEdit.getProperty(
 55			"options.mouse.joinNonWordChars"));
 56		joinNonWordChars.setSelected(jEdit.getBooleanProperty(
 57			"view.joinNonWordChars"));
 58		addComponent(joinNonWordChars);
 59
 60		/* Middle mouse button click pastes % register */
 61		middleMousePaste = new JCheckBox(jEdit.getProperty("options.mouse"
 62			+ ".middleMousePaste"));
 63		middleMousePaste.setSelected(jEdit.getBooleanProperty(
 64			"view.middleMousePaste"));
 65		addComponent(middleMousePaste);
 66
 67		/* Gutter mouse actions */
 68		int c = clickActionKeys.length;
 69		String[] clickActionNames = new String[c];
 70		for(int i = 0; i < c; i++)
 71		{
 72			clickActionNames[i] = jEdit.getProperty(
 73				"options.mouse.gutter."+clickActionKeys[i]);
 74		}
 75
 76		c = clickModifierKeys.length;
 77		String[] clickModifierNames = new String[c];
 78		for(int i = 0; i < c; i++)
 79		{
 80			clickModifierNames[i] = jEdit.getProperty(
 81				"options.mouse.gutter."+clickModifierKeys[i]);
 82		}
 83
 84		gutterClickActions = new JComboBox[c];
 85
 86		for(int i = 0; i < c; i++)
 87		{
 88			JComboBox cb = new JComboBox(clickActionNames);
 89			gutterClickActions[i] = cb;
 90
 91			String val = jEdit.getProperty("view.gutter."+clickModifierKeys[i]);
 92			for(int j = 0; j < clickActionKeys.length; j++)
 93			{
 94				if(val.equals(clickActionKeys[j]))
 95				{
 96					cb.setSelectedIndex(j);
 97				}
 98			}
 99
100			addComponent(clickModifierNames[i],cb);
101		}
102	} //}}}
103
104	//{{{ _save() method
105	public void _save()
106	{
107		jEdit.setBooleanProperty("view.dragAndDrop",dragAndDrop.isSelected());
108		jEdit.setBooleanProperty("view.joinNonWordChars",joinNonWordChars.isSelected());
109		jEdit.setBooleanProperty("view.middleMousePaste",
110			middleMousePaste.isSelected());
111
112		int c = clickModifierKeys.length;
113		for(int i = 0; i < c; i++)
114		{
115			int idx = gutterClickActions[i].getSelectedIndex();
116			jEdit.setProperty("view.gutter."+clickModifierKeys[i],
117				clickActionKeys[idx]);
118		}
119	} //}}}
120
121	//{{{ Private members
122	private JCheckBox dragAndDrop;
123	private JCheckBox middleMousePaste;
124	private JCheckBox joinNonWordChars;
125
126	private JComboBox[] gutterClickActions;
127
128	// simplified these settings a little...
129	private static final String[] clickActionKeys = new String[] {
130		"toggle-fold",
131		"toggle-fold-fully"
132	};
133	
134	private static final String[] clickModifierKeys = new String[] {
135		"foldClick",
136		"SfoldClick"
137	}; //}}}
138}