PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/options/AppearanceOptionPane.java

#
Java | 154 lines | 97 code | 20 blank | 37 comment | 5 complexity | 0c96096662e1f87df610b4f31b154ec3 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. * AppearanceOptionPane.java - Appearance options panel
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2001 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.*;
  25. import java.awt.event.*;
  26. import java.awt.*;
  27. import java.io.*;
  28. import org.gjt.sp.jedit.gui.FontSelector;
  29. import org.gjt.sp.jedit.*;
  30. import org.gjt.sp.util.Log;
  31. //}}}
  32. public class AppearanceOptionPane extends AbstractOptionPane
  33. {
  34. //{{{ AppearanceOptionPane constructor
  35. public AppearanceOptionPane()
  36. {
  37. super("appearance");
  38. } //}}}
  39. //{{{ _init() method
  40. protected void _init()
  41. {
  42. /* Look and feel */
  43. addComponent(new JLabel(jEdit.getProperty("options.appearance.lf.note")));
  44. lfs = UIManager.getInstalledLookAndFeels();
  45. String[] names = new String[lfs.length];
  46. String lf = UIManager.getLookAndFeel().getClass().getName();
  47. int index = 0;
  48. for(int i = 0; i < names.length; i++)
  49. {
  50. names[i] = lfs[i].getName();
  51. if(lf.equals(lfs[i].getClassName()))
  52. index = i;
  53. }
  54. lookAndFeel = new JComboBox(names);
  55. lookAndFeel.setSelectedIndex(index);
  56. lookAndFeel.addActionListener(new ActionListener()
  57. {
  58. public void actionPerformed(ActionEvent evt)
  59. {
  60. updateEnabled();
  61. }
  62. });
  63. addComponent(jEdit.getProperty("options.appearance.lf"),
  64. lookAndFeel);
  65. /* Primary Metal L&F font */
  66. primaryFont = new FontSelector(jEdit.getFontProperty(
  67. "metal.primary.font"));
  68. addComponent(jEdit.getProperty("options.appearance.primaryFont"),
  69. primaryFont);
  70. /* Secondary Metal L&F font */
  71. secondaryFont = new FontSelector(jEdit.getFontProperty(
  72. "metal.secondary.font"));
  73. addComponent(jEdit.getProperty("options.appearance.secondaryFont"),
  74. secondaryFont);
  75. updateEnabled();
  76. /* Use jEdit colors in all text components */
  77. textColors = new JCheckBox(jEdit.getProperty(
  78. "options.appearance.textColors"));
  79. textColors.setSelected(jEdit.getBooleanProperty("textColors"));
  80. addComponent(textColors);
  81. /* Decorate frames with look and feel (JDK 1.4 only) */
  82. decorateFrames = new JCheckBox(jEdit.getProperty(
  83. "options.appearance.decorateFrames"));
  84. decorateFrames.setSelected(jEdit.getBooleanProperty("decorate.frames"));
  85. /* Decorate dialogs with look and feel (JDK 1.4 only) */
  86. decorateDialogs = new JCheckBox(jEdit.getProperty(
  87. "options.appearance.decorateDialogs"));
  88. decorateDialogs.setSelected(jEdit.getBooleanProperty("decorate.dialogs"));
  89. if(OperatingSystem.hasJava14())
  90. {
  91. addComponent(decorateFrames);
  92. addComponent(decorateDialogs);
  93. }
  94. } //}}}
  95. //{{{ _save() method
  96. protected void _save()
  97. {
  98. String lf = lfs[lookAndFeel.getSelectedIndex()].getClassName();
  99. jEdit.setProperty("lookAndFeel",lf);
  100. jEdit.setFontProperty("metal.primary.font",primaryFont.getFont());
  101. jEdit.setFontProperty("metal.secondary.font",secondaryFont.getFont());
  102. jEdit.setBooleanProperty("textColors",textColors.isSelected());
  103. jEdit.setBooleanProperty("decorate.frames",decorateFrames.isSelected());
  104. jEdit.setBooleanProperty("decorate.dialogs",decorateDialogs.isSelected());
  105. } //}}}
  106. //{{{ Private members
  107. //{{{ Instance variables
  108. private UIManager.LookAndFeelInfo[] lfs;
  109. private JComboBox lookAndFeel;
  110. private FontSelector primaryFont;
  111. private FontSelector secondaryFont;
  112. private JCheckBox textColors;
  113. private JCheckBox decorateFrames;
  114. private JCheckBox decorateDialogs;
  115. //}}}
  116. //{{{ updateEnabled() method
  117. private void updateEnabled()
  118. {
  119. String className = lfs[lookAndFeel.getSelectedIndex()]
  120. .getClassName();
  121. if(className.equals("javax.swing.plaf.metal.MetalLookAndFeel")
  122. || className.equals("com.incors.plaf.kunststoff.KunststoffLookAndFeel"))
  123. {
  124. primaryFont.setEnabled(true);
  125. secondaryFont.setEnabled(true);
  126. }
  127. else
  128. {
  129. primaryFont.setEnabled(false);
  130. secondaryFont.setEnabled(false);
  131. }
  132. } //}}}
  133. //}}}
  134. }