/jEdit/tags/jedit-4-2-pre14/org/gjt/sp/jedit/options/MouseOptionPane.java
# · Java · 138 lines · 88 code · 18 blank · 32 comment · 6 complexity · a246deac79df229f40b24b63048f5f90 MD5 · raw file
- /*
- * MouseOptionPane.java - Editor window options
- * :tabSize=8:indentSize=8:noTabs=false:
- * :folding=explicit:collapseFolds=1:
- *
- * Copyright (C) 2003 Slava Pestov
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- package org.gjt.sp.jedit.options;
- //{{{ Imports
- import javax.swing.border.*;
- import javax.swing.*;
- import java.awt.event.*;
- import java.awt.*;
- import java.io.*;
- import org.gjt.sp.jedit.*;
- import org.gjt.sp.util.Log;
- //}}}
- public class MouseOptionPane extends AbstractOptionPane
- {
- //{{{ MouseOptionPane constructor
- public MouseOptionPane()
- {
- super("mouse");
- } //}}}
- //{{{ _init() method
- protected void _init()
- {
- /* Text drag and drop */
- dragAndDrop = new JCheckBox(jEdit.getProperty(
- "options.mouse.dragAndDrop"));
- dragAndDrop.setSelected(jEdit.getBooleanProperty(
- "view.dragAndDrop"));
- addComponent(dragAndDrop);
- /* Non word character selection behavior */
- joinNonWordChars = new JCheckBox(jEdit.getProperty(
- "options.mouse.joinNonWordChars"));
- joinNonWordChars.setSelected(jEdit.getBooleanProperty(
- "view.joinNonWordChars"));
- addComponent(joinNonWordChars);
- /* Middle mouse button click pastes % register */
- middleMousePaste = new JCheckBox(jEdit.getProperty("options.mouse"
- + ".middleMousePaste"));
- middleMousePaste.setSelected(jEdit.getBooleanProperty(
- "view.middleMousePaste"));
- addComponent(middleMousePaste);
- /* Gutter mouse actions */
- int c = clickActionKeys.length;
- String[] clickActionNames = new String[c];
- for(int i = 0; i < c; i++)
- {
- clickActionNames[i] = jEdit.getProperty(
- "options.mouse.gutter."+clickActionKeys[i]);
- }
- c = clickModifierKeys.length;
- String[] clickModifierNames = new String[c];
- for(int i = 0; i < c; i++)
- {
- clickModifierNames[i] = jEdit.getProperty(
- "options.mouse.gutter."+clickModifierKeys[i]);
- }
- gutterClickActions = new JComboBox[c];
- for(int i = 0; i < c; i++)
- {
- JComboBox cb = new JComboBox(clickActionNames);
- gutterClickActions[i] = cb;
- String val = jEdit.getProperty("view.gutter."+clickModifierKeys[i]);
- for(int j = 0; j < clickActionKeys.length; j++)
- {
- if(val.equals(clickActionKeys[j]))
- {
- cb.setSelectedIndex(j);
- }
- }
- addComponent(clickModifierNames[i],cb);
- }
- } //}}}
- //{{{ _save() method
- public void _save()
- {
- jEdit.setBooleanProperty("view.dragAndDrop",dragAndDrop.isSelected());
- jEdit.setBooleanProperty("view.joinNonWordChars",joinNonWordChars.isSelected());
- jEdit.setBooleanProperty("view.middleMousePaste",
- middleMousePaste.isSelected());
- int c = clickModifierKeys.length;
- for(int i = 0; i < c; i++)
- {
- int idx = gutterClickActions[i].getSelectedIndex();
- jEdit.setProperty("view.gutter."+clickModifierKeys[i],
- clickActionKeys[idx]);
- }
- } //}}}
- //{{{ Private members
- private JCheckBox dragAndDrop;
- private JCheckBox middleMousePaste;
- private JCheckBox joinNonWordChars;
- private JComboBox[] gutterClickActions;
- // simplified these settings a little...
- private static final String[] clickActionKeys = new String[] {
- "toggle-fold",
- "toggle-fold-fully"
- };
-
- private static final String[] clickModifierKeys = new String[] {
- "foldClick",
- "SfoldClick"
- }; //}}}
- }