KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > options > MouseOptionPane


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
23 package org.gjt.sp.jedit.options;
24
25 //{{{ Imports
26
import javax.swing.border.*;
27 import javax.swing.*;
28 import java.awt.event.*;
29 import java.awt.*;
30 import java.io.*;
31 import org.gjt.sp.jedit.*;
32 import org.gjt.sp.util.Log;
33 //}}}
34

35 public 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 JavaDoc[] clickActionNames = new String JavaDoc[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 JavaDoc[] clickModifierNames = new String JavaDoc[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 JavaDoc 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 JavaDoc[] clickActionKeys = new String JavaDoc[] {
130         "toggle-fold",
131         "toggle-fold-fully"
132     };
133     
134     private static final String JavaDoc[] clickModifierKeys = new String JavaDoc[] {
135         "foldClick",
136         "SfoldClick"
137     }; //}}}
138
}
139
Popular Tags