001: /*
002: * MouseOptionPane.java - Editor window options
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 2003 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.options;
024:
025: //{{{ Imports
026: import javax.swing.border.*;
027: import javax.swing.*;
028: import java.awt.event.*;
029: import java.awt.*;
030: import java.io.*;
031: import org.gjt.sp.jedit.*;
032: import org.gjt.sp.util.Log;
033:
034: //}}}
035:
036: public class MouseOptionPane extends AbstractOptionPane {
037: //{{{ MouseOptionPane constructor
038: public MouseOptionPane() {
039: super ("mouse");
040: } //}}}
041:
042: //{{{ _init() method
043: protected void _init() {
044: /* Text drag and drop */
045: dragAndDrop = new JCheckBox(jEdit
046: .getProperty("options.mouse.dragAndDrop"));
047: dragAndDrop.setSelected(jEdit
048: .getBooleanProperty("view.dragAndDrop"));
049: addComponent(dragAndDrop);
050:
051: /* Non word character selection behavior */
052: joinNonWordChars = new JCheckBox(jEdit
053: .getProperty("options.mouse.joinNonWordChars"));
054: joinNonWordChars.setSelected(jEdit
055: .getBooleanProperty("view.joinNonWordChars"));
056: addComponent(joinNonWordChars);
057:
058: /* Middle mouse button click pastes % register */
059: middleMousePaste = new JCheckBox(jEdit
060: .getProperty("options.mouse" + ".middleMousePaste"));
061: middleMousePaste.setSelected(jEdit
062: .getBooleanProperty("view.middleMousePaste"));
063: addComponent(middleMousePaste);
064:
065: /*
066: * Pressing Ctrl while mouse actions makes them as if
067: * selection mode were rectangular mode
068: */
069: ctrlForRectangularSelection = new JCheckBox(
070: jEdit
071: .getProperty("options.mouse.ctrlForRectangularSelection"));
072: ctrlForRectangularSelection
073: .setSelected(jEdit
074: .getBooleanProperty("view.ctrlForRectangularSelection"));
075: addComponent(ctrlForRectangularSelection);
076:
077: /* Gutter mouse actions */
078: int c = clickActionKeys.length;
079: String[] clickActionNames = new String[c];
080: for (int i = 0; i < c; i++) {
081: clickActionNames[i] = jEdit
082: .getProperty("options.mouse.gutter."
083: + clickActionKeys[i]);
084: }
085:
086: c = clickModifierKeys.length;
087: String[] clickModifierNames = new String[c];
088: for (int i = 0; i < c; i++) {
089: clickModifierNames[i] = jEdit
090: .getProperty("options.mouse.gutter."
091: + clickModifierKeys[i]);
092: }
093:
094: gutterClickActions = new JComboBox[c];
095:
096: for (int i = 0; i < c; i++) {
097: JComboBox cb = new JComboBox(clickActionNames);
098: gutterClickActions[i] = cb;
099:
100: String val = jEdit.getProperty("view.gutter."
101: + clickModifierKeys[i]);
102: for (int j = 0; j < clickActionKeys.length; j++) {
103: if (val.equals(clickActionKeys[j])) {
104: cb.setSelectedIndex(j);
105: }
106: }
107:
108: addComponent(clickModifierNames[i], cb);
109: }
110: } //}}}
111:
112: //{{{ _save() method
113: public void _save() {
114: jEdit.setBooleanProperty("view.dragAndDrop", dragAndDrop
115: .isSelected());
116: jEdit.setBooleanProperty("view.joinNonWordChars",
117: joinNonWordChars.isSelected());
118: jEdit.setBooleanProperty("view.middleMousePaste",
119: middleMousePaste.isSelected());
120: jEdit.setBooleanProperty("view.ctrlForRectangularSelection",
121: ctrlForRectangularSelection.isSelected());
122:
123: int c = clickModifierKeys.length;
124: for (int i = 0; i < c; i++) {
125: int idx = gutterClickActions[i].getSelectedIndex();
126: jEdit.setProperty("view.gutter." + clickModifierKeys[i],
127: clickActionKeys[idx]);
128: }
129: } //}}}
130:
131: //{{{ Private members
132: private JCheckBox dragAndDrop;
133: private JCheckBox joinNonWordChars;
134: private JCheckBox middleMousePaste;
135: private JCheckBox ctrlForRectangularSelection;
136:
137: private JComboBox[] gutterClickActions;
138:
139: // simplified these settings a little...
140: private static final String[] clickActionKeys = new String[] {
141: "toggle-fold", "toggle-fold-fully" };
142:
143: private static final String[] clickModifierKeys = new String[] {
144: "foldClick", "SfoldClick" }; //}}}
145: }
|