PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre3/org/gjt/sp/jedit/options/GutterOptionPane.java

#
Java | 133 lines | 97 code | 15 blank | 21 comment | 3 complexity | 33d7d552e49dff392037ad86f000dd49 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. * Copyright (C) 2000 mike dillon
  4. * Portions copyright (C) 2001 Slava Pestov
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. package org.gjt.sp.jedit.options;
  21. import javax.swing.*;
  22. import java.awt.*;
  23. import org.gjt.sp.jedit.gui.FontSelector;
  24. import org.gjt.sp.jedit.*;
  25. public class GutterOptionPane extends AbstractOptionPane
  26. {
  27. public GutterOptionPane()
  28. {
  29. super("gutter");
  30. }
  31. public void _init()
  32. {
  33. lineNumbersEnabled = new JCheckBox(jEdit.getProperty(
  34. "options.gutter.lineNumbers"));
  35. lineNumbersEnabled.setSelected(jEdit.getBooleanProperty(
  36. "view.gutter.lineNumbers"));
  37. addComponent(lineNumbersEnabled);
  38. /* Font */
  39. gutterFont = new FontSelector(
  40. jEdit.getFontProperty("view.gutter.font",
  41. new Font("Monospaced",Font.PLAIN,10)));
  42. addComponent(jEdit.getProperty("options.gutter.font"),gutterFont);
  43. gutterBorderWidth = new JTextField(jEdit.getProperty(
  44. "view.gutter.borderWidth"));
  45. addComponent(jEdit.getProperty("options.gutter.borderWidth"),
  46. gutterBorderWidth);
  47. gutterHighlightInterval = new JTextField(jEdit.getProperty(
  48. "view.gutter.highlightInterval"));
  49. addComponent(jEdit.getProperty("options.gutter.interval"),
  50. gutterHighlightInterval);
  51. String[] alignments = new String[] {
  52. "Left", "Center", "Right"
  53. };
  54. gutterNumberAlignment = new JComboBox(alignments);
  55. String alignment = jEdit.getProperty("view.gutter.numberAlignment");
  56. if("right".equals(alignment))
  57. gutterNumberAlignment.setSelectedIndex(2);
  58. else if("center".equals(alignment))
  59. gutterNumberAlignment.setSelectedIndex(1);
  60. else
  61. gutterNumberAlignment.setSelectedIndex(0);
  62. addComponent(jEdit.getProperty("options.gutter.numberAlignment"),
  63. gutterNumberAlignment);
  64. gutterCurrentLineHighlightEnabled = new JCheckBox(jEdit.getProperty(
  65. "options.gutter.currentLineHighlight"));
  66. gutterCurrentLineHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  67. "view.gutter.highlightCurrentLine"));
  68. addComponent(gutterCurrentLineHighlightEnabled);
  69. gutterBracketHighlightEnabled = new JCheckBox(jEdit.getProperty(
  70. "options.gutter.bracketHighlight"));
  71. gutterBracketHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  72. "view.gutter.bracketHighlight"));
  73. addComponent(gutterBracketHighlightEnabled);
  74. gutterMarkerHighlightEnabled = new JCheckBox(jEdit.getProperty(
  75. "options.gutter.markerHighlight"));
  76. gutterMarkerHighlightEnabled.setSelected(jEdit.getBooleanProperty(
  77. "view.gutter.markerHighlight"));
  78. addComponent(gutterMarkerHighlightEnabled);
  79. }
  80. public void _save()
  81. {
  82. jEdit.setFontProperty("view.gutter.font",gutterFont.getFont());
  83. jEdit.setProperty("view.gutter.borderWidth",
  84. gutterBorderWidth.getText());
  85. jEdit.setProperty("view.gutter.highlightInterval",
  86. gutterHighlightInterval.getText());
  87. String alignment = null;
  88. switch(gutterNumberAlignment.getSelectedIndex())
  89. {
  90. case 2:
  91. alignment = "right";
  92. break;
  93. case 1:
  94. alignment = "center";
  95. break;
  96. case 0: default:
  97. alignment = "left";
  98. }
  99. jEdit.setProperty("view.gutter.numberAlignment", alignment);
  100. jEdit.setBooleanProperty("view.gutter.lineNumbers", lineNumbersEnabled
  101. .isSelected());
  102. jEdit.setBooleanProperty("view.gutter.highlightCurrentLine",
  103. gutterCurrentLineHighlightEnabled.isSelected());
  104. jEdit.setBooleanProperty("view.gutter.bracketHighlight",
  105. gutterBracketHighlightEnabled.isSelected());
  106. jEdit.setBooleanProperty("view.gutter.markerHighlight",
  107. gutterMarkerHighlightEnabled.isSelected());
  108. }
  109. // private members
  110. private FontSelector gutterFont;
  111. private JTextField gutterBorderWidth;
  112. private JTextField gutterHighlightInterval;
  113. private JComboBox gutterNumberAlignment;
  114. private JCheckBox lineNumbersEnabled;
  115. private JCheckBox gutterCurrentLineHighlightEnabled;
  116. private JCheckBox gutterBracketHighlightEnabled;
  117. private JCheckBox gutterMarkerHighlightEnabled;
  118. }