PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms 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
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. /* Gutter mouse actions */
  61. int c = clickActionKeys.length;
  62. String[] clickActionNames = new String[c];
  63. for(int i = 0; i < c; i++)
  64. {
  65. clickActionNames[i] = jEdit.getProperty(
  66. "options.mouse.gutter."+clickActionKeys[i]);
  67. }
  68. c = clickModifierKeys.length;
  69. String[] clickModifierNames = new String[c];
  70. for(int i = 0; i < c; i++)
  71. {
  72. clickModifierNames[i] = jEdit.getProperty(
  73. "options.mouse.gutter."+clickModifierKeys[i]);
  74. }
  75. gutterClickActions = new JComboBox[c];
  76. for(int i = 0; i < c; i++)
  77. {
  78. JComboBox cb = new JComboBox(clickActionNames);
  79. gutterClickActions[i] = cb;
  80. String val = jEdit.getProperty("view.gutter."+clickModifierKeys[i]);
  81. for(int j = 0; j < clickActionKeys.length; j++)
  82. {
  83. if(val.equals(clickActionKeys[j]))
  84. {
  85. cb.setSelectedIndex(j);
  86. }
  87. }
  88. addComponent(clickModifierNames[i],cb);
  89. }
  90. } //}}}
  91. //{{{ _save() method
  92. public void _save()
  93. {
  94. jEdit.setBooleanProperty("view.dragAndDrop",dragAndDrop.isSelected());
  95. jEdit.setBooleanProperty("view.joinNonWordChars",joinNonWordChars.isSelected());
  96. jEdit.setBooleanProperty("view.middleMousePaste",
  97. middleMousePaste.isSelected());
  98. int c = clickModifierKeys.length;
  99. for(int i = 0; i < c; i++)
  100. {
  101. int idx = gutterClickActions[i].getSelectedIndex();
  102. jEdit.setProperty("view.gutter."+clickModifierKeys[i],
  103. clickActionKeys[idx]);
  104. }
  105. } //}}}
  106. //{{{ Private members
  107. private JCheckBox dragAndDrop;
  108. private JCheckBox middleMousePaste;
  109. private JCheckBox joinNonWordChars;
  110. private JComboBox[] gutterClickActions;
  111. // simplified these settings a little...
  112. private static final String[] clickActionKeys = new String[] {
  113. "toggle-fold",
  114. "toggle-fold-fully"
  115. };
  116. private static final String[] clickModifierKeys = new String[] {
  117. "foldClick",
  118. "SfoldClick"
  119. }; //}}}
  120. }