PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/options/GutterOptionPane.java

#
Java | 230 lines | 130 code | 25 blank | 75 comment | 0 complexity | a718c9972a558c490b7c231cdfdc9f63 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. * GutterOptionPane.java - Gutter options panel
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2000 mike dillon
  7. * Portions copyright (C) 2001, 2002 Slava Pestov
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. package org.gjt.sp.jedit.options;
  24. //{{{ Imports
  25. import javax.swing.*;
  26. import java.awt.*;
  27. import org.gjt.sp.jedit.gui.*;
  28. import org.gjt.sp.jedit.*;
  29. //}}}
  30. public class GutterOptionPane extends AbstractOptionPane
  31. {
  32. //{{{ GutterOptionPane constructor
  33. public GutterOptionPane()
  34. {
  35. super("gutter");
  36. } //}}}
  37. //{{{ _init() method
  38. public void _init()
  39. {
  40. /* Line numbering */
  41. lineNumbersEnabled = new JCheckBox(jEdit.getProperty(
  42. "options.gutter.lineNumbers"));
  43. lineNumbersEnabled.setSelected(jEdit.getBooleanProperty(
  44. "view.gutter.lineNumbers"));
  45. addComponent(lineNumbersEnabled);
  46. /* Text font */
  47. gutterFont = new FontSelector(
  48. jEdit.getFontProperty("view.gutter.font",
  49. new Font("Monospaced",Font.PLAIN,10)));
  50. addComponent(jEdit.getProperty("options.gutter.font"),gutterFont);
  51. /* Text color */
  52. addComponent(jEdit.getProperty("options.gutter.foreground"),
  53. gutterForeground = new ColorWellButton(
  54. jEdit.getColorProperty("view.gutter.fgColor")),
  55. GridBagConstraints.VERTICAL);
  56. /* Background color */
  57. addComponent(jEdit.getProperty("options.gutter.background"),
  58. gutterBackground = new ColorWellButton(
  59. jEdit.getColorProperty("view.gutter.bgColor")),
  60. GridBagConstraints.VERTICAL);
  61. /* Border width */
  62. /* gutterBorderWidth = new JTextField(jEdit.getProperty(
  63. "view.gutter.borderWidth"));
  64. addComponent(jEdit.getProperty("options.gutter.borderWidth"),
  65. gutterBorderWidth); */
  66. /* Number alignment */
  67. /* String[] alignments = new String[] {
  68. "Left", "Center", "Right"
  69. };
  70. gutterNumberAlignment = new JComboBox(alignments);
  71. String alignment = jEdit.getProperty("view.gutter.numberAlignment");
  72. if("right".equals(alignment))
  73. gutterNumberAlignment.setSelectedIndex(2);
  74. else if("center".equals(alignment))
  75. gutterNumberAlignment.setSelectedIndex(1);
  76. else
  77. gutterNumberAlignment.setSelectedIndex(0);
  78. addComponent(jEdit.getProperty("options.gutter.numberAlignment"),
  79. gutterNumberAlignment); */
  80. /* Current line highlight */
  81. gutterCurrentLineHighlightEnabled = new JCheckBox(jEdit.getProperty(
  82. "options.gutter.currentLineHighlight"));
  83. gutterCurrentLineHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  84. "view.gutter.highlightCurrentLine"));
  85. addComponent(gutterCurrentLineHighlightEnabled,
  86. gutterCurrentLineHighlight = new ColorWellButton(
  87. jEdit.getColorProperty("view.gutter.currentLineColor")),
  88. GridBagConstraints.VERTICAL);
  89. /* Highlight interval and color */
  90. gutterHighlightInterval = new JTextField(jEdit.getProperty(
  91. "view.gutter.highlightInterval"),3);
  92. Box gutterHighlightBox = new Box(BoxLayout.X_AXIS);
  93. gutterHighlightBox.add(new JLabel(jEdit.getProperty(
  94. "options.gutter.interval-1")));
  95. gutterHighlightBox.add(Box.createHorizontalStrut(3));
  96. gutterHighlightBox.add(gutterHighlightInterval);
  97. gutterHighlightBox.add(Box.createHorizontalStrut(3));
  98. gutterHighlightBox.add(new JLabel(jEdit.getProperty(
  99. "options.gutter.interval-2")));
  100. gutterHighlightBox.add(Box.createHorizontalStrut(12));
  101. addComponent(gutterHighlightBox,gutterHighlightColor
  102. = new ColorWellButton(jEdit.getColorProperty(
  103. "view.gutter.highlightColor")),
  104. GridBagConstraints.VERTICAL);
  105. /* Structure highlight */
  106. gutterStructureHighlightEnabled = new JCheckBox(jEdit.getProperty(
  107. "options.gutter.structureHighlight"));
  108. gutterStructureHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  109. "view.gutter.structureHighlight"));
  110. addComponent(gutterStructureHighlightEnabled,
  111. gutterStructureHighlight = new ColorWellButton(
  112. jEdit.getColorProperty("view.gutter.structureHighlightColor")),
  113. GridBagConstraints.VERTICAL);
  114. /* Marker highlight */
  115. gutterMarkerHighlightEnabled = new JCheckBox(jEdit.getProperty(
  116. "options.gutter.markerHighlight"));
  117. gutterMarkerHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  118. "view.gutter.markerHighlight"));
  119. addComponent(gutterMarkerHighlightEnabled,
  120. gutterMarkerHighlight = new ColorWellButton(
  121. jEdit.getColorProperty("view.gutter.markerColor")),
  122. GridBagConstraints.VERTICAL);
  123. /* Fold marker color */
  124. addComponent(jEdit.getProperty("options.gutter.foldColor"),
  125. gutterFoldMarkers = new ColorWellButton(
  126. jEdit.getColorProperty("view.gutter.foldColor")),
  127. GridBagConstraints.VERTICAL);
  128. /* Focused border color */
  129. addComponent(jEdit.getProperty("options.gutter.focusBorderColor"),
  130. gutterFocusBorder = new ColorWellButton(
  131. jEdit.getColorProperty("view.gutter.focusBorderColor")),
  132. GridBagConstraints.VERTICAL);
  133. /* unfocused border color */
  134. addComponent(jEdit.getProperty("options.gutter.noFocusBorderColor"),
  135. gutterNoFocusBorder = new ColorWellButton(
  136. jEdit.getColorProperty("view.gutter.noFocusBorderColor")),
  137. GridBagConstraints.VERTICAL);
  138. } //}}}
  139. //{{{ _save() method
  140. public void _save()
  141. {
  142. jEdit.setBooleanProperty("view.gutter.lineNumbers", lineNumbersEnabled
  143. .isSelected());
  144. jEdit.setFontProperty("view.gutter.font",gutterFont.getFont());
  145. jEdit.setColorProperty("view.gutter.fgColor",gutterForeground
  146. .getSelectedColor());
  147. jEdit.setColorProperty("view.gutter.bgColor",gutterBackground
  148. .getSelectedColor());
  149. /* jEdit.setProperty("view.gutter.borderWidth",
  150. gutterBorderWidth.getText());
  151. String alignment = null;
  152. switch(gutterNumberAlignment.getSelectedIndex())
  153. {
  154. case 2:
  155. alignment = "right";
  156. break;
  157. case 1:
  158. alignment = "center";
  159. break;
  160. case 0: default:
  161. alignment = "left";
  162. }
  163. jEdit.setProperty("view.gutter.numberAlignment", alignment); */
  164. jEdit.setBooleanProperty("view.gutter.highlightCurrentLine",
  165. gutterCurrentLineHighlightEnabled.isSelected());
  166. jEdit.setColorProperty("view.gutter.currentLineColor",
  167. gutterCurrentLineHighlight.getSelectedColor());
  168. jEdit.setProperty("view.gutter.highlightInterval",
  169. gutterHighlightInterval.getText());
  170. jEdit.setColorProperty("view.gutter.highlightColor",
  171. gutterHighlightColor.getSelectedColor());
  172. jEdit.setBooleanProperty("view.gutter.structureHighlight",
  173. gutterStructureHighlightEnabled.isSelected());
  174. jEdit.setColorProperty("view.gutter.structureHighlightColor",
  175. gutterStructureHighlight.getSelectedColor());
  176. jEdit.setBooleanProperty("view.gutter.markerHighlight",
  177. gutterMarkerHighlightEnabled.isSelected());
  178. jEdit.setColorProperty("view.gutter.markerColor",
  179. gutterMarkerHighlight.getSelectedColor());
  180. jEdit.setColorProperty("view.gutter.foldColor",
  181. gutterFoldMarkers.getSelectedColor());
  182. jEdit.setColorProperty("view.gutter.focusBorderColor",
  183. gutterFocusBorder.getSelectedColor());
  184. jEdit.setColorProperty("view.gutter.noFocusBorderColor",
  185. gutterNoFocusBorder.getSelectedColor());
  186. } //}}}
  187. //{{{ Private members
  188. private FontSelector gutterFont;
  189. private ColorWellButton gutterForeground;
  190. private ColorWellButton gutterBackground;
  191. private JTextField gutterHighlightInterval;
  192. private ColorWellButton gutterHighlightColor;
  193. private JCheckBox lineNumbersEnabled;
  194. private JCheckBox gutterCurrentLineHighlightEnabled;
  195. private ColorWellButton gutterCurrentLineHighlight;
  196. private JCheckBox gutterStructureHighlightEnabled;
  197. private ColorWellButton gutterStructureHighlight;
  198. private JCheckBox gutterMarkerHighlightEnabled;
  199. private ColorWellButton gutterMarkerHighlight;
  200. private ColorWellButton gutterFoldMarkers;
  201. private ColorWellButton gutterFocusBorder;
  202. private ColorWellButton gutterNoFocusBorder;
  203. //}}}
  204. }