PageRenderTime 57ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/options/MouseOptionPane.java

#
Java | 153 lines | 98 code | 19 blank | 36 comment | 6 complexity | bfdd2235ac8be3f462c2e6c4f23a67d0 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package org.gjt.sp.jedit.options;
  23. //{{{ Imports
  24. import javax.swing.border.*;
  25. import javax.swing.*;
  26. import java.awt.event.*;
  27. import java.awt.*;
  28. import java.io.*;
  29. import org.gjt.sp.jedit.*;
  30. import org.gjt.sp.util.Log;
  31. //}}}
  32. public class MouseOptionPane extends AbstractOptionPane
  33. {
  34. //{{{ MouseOptionPane constructor
  35. public MouseOptionPane()
  36. {
  37. super("mouse");
  38. } //}}}
  39. //{{{ _init() method
  40. protected void _init()
  41. {
  42. /* Text drag and drop */
  43. dragAndDrop = new JCheckBox(jEdit.getProperty(
  44. "options.mouse.dragAndDrop"));
  45. dragAndDrop.setSelected(jEdit.getBooleanProperty(
  46. "view.dragAndDrop"));
  47. addComponent(dragAndDrop);
  48. /* Non word character selection behavior */
  49. joinNonWordChars = new JCheckBox(jEdit.getProperty(
  50. "options.mouse.joinNonWordChars"));
  51. joinNonWordChars.setSelected(jEdit.getBooleanProperty(
  52. "view.joinNonWordChars"));
  53. addComponent(joinNonWordChars);
  54. /* Middle mouse button click pastes % register */
  55. middleMousePaste = new JCheckBox(jEdit.getProperty("options.mouse"
  56. + ".middleMousePaste"));
  57. middleMousePaste.setSelected(jEdit.getBooleanProperty(
  58. "view.middleMousePaste"));
  59. addComponent(middleMousePaste);
  60. /*
  61. * Pressing Ctrl while mouse actions makes them as if
  62. * selection mode were rectangular mode
  63. */
  64. ctrlForRectangularSelection = new JCheckBox(jEdit.getProperty(
  65. "options.mouse.ctrlForRectangularSelection"));
  66. ctrlForRectangularSelection.setSelected(jEdit.getBooleanProperty(
  67. "view.ctrlForRectangularSelection"));
  68. addComponent(ctrlForRectangularSelection);
  69. /* Gutter mouse actions */
  70. int c = clickActionKeys.length;
  71. String[] clickActionNames = new String[c];
  72. for(int i = 0; i < c; i++)
  73. {
  74. clickActionNames[i] = jEdit.getProperty(
  75. "options.mouse.gutter."+clickActionKeys[i]);
  76. }
  77. c = clickModifierKeys.length;
  78. String[] clickModifierNames = new String[c];
  79. for(int i = 0; i < c; i++)
  80. {
  81. clickModifierNames[i] = jEdit.getProperty(
  82. "options.mouse.gutter."+clickModifierKeys[i]);
  83. }
  84. gutterClickActions = new JComboBox[c];
  85. for(int i = 0; i < c; i++)
  86. {
  87. JComboBox cb = new JComboBox(clickActionNames);
  88. gutterClickActions[i] = cb;
  89. String val = jEdit.getProperty("view.gutter."+clickModifierKeys[i]);
  90. for(int j = 0; j < clickActionKeys.length; j++)
  91. {
  92. if(val.equals(clickActionKeys[j]))
  93. {
  94. cb.setSelectedIndex(j);
  95. }
  96. }
  97. addComponent(clickModifierNames[i],cb);
  98. }
  99. } //}}}
  100. //{{{ _save() method
  101. public void _save()
  102. {
  103. jEdit.setBooleanProperty("view.dragAndDrop",
  104. dragAndDrop.isSelected());
  105. jEdit.setBooleanProperty("view.joinNonWordChars",
  106. joinNonWordChars.isSelected());
  107. jEdit.setBooleanProperty("view.middleMousePaste",
  108. middleMousePaste.isSelected());
  109. jEdit.setBooleanProperty("view.ctrlForRectangularSelection",
  110. ctrlForRectangularSelection.isSelected());
  111. int c = clickModifierKeys.length;
  112. for(int i = 0; i < c; i++)
  113. {
  114. int idx = gutterClickActions[i].getSelectedIndex();
  115. jEdit.setProperty("view.gutter."+clickModifierKeys[i],
  116. clickActionKeys[idx]);
  117. }
  118. } //}}}
  119. //{{{ Private members
  120. private JCheckBox dragAndDrop;
  121. private JCheckBox joinNonWordChars;
  122. private JCheckBox middleMousePaste;
  123. private JCheckBox ctrlForRectangularSelection;
  124. private JComboBox[] gutterClickActions;
  125. // simplified these settings a little...
  126. private static final String[] clickActionKeys = new String[] {
  127. "toggle-fold",
  128. "toggle-fold-fully"
  129. };
  130. private static final String[] clickModifierKeys = new String[] {
  131. "foldClick",
  132. "SfoldClick"
  133. }; //}}}
  134. }