/plugins/Hyperlinks/tags/Hyperlinks-1-0-0/src/gatchan/jedit/hyperlinks/HyperlinkOptionPane.java

# · Java · 93 lines · 46 code · 13 blank · 34 comment · 2 complexity · 69254239089f4530485dd441fd5ce86e MD5 · raw file

  1. /*
  2. * HyperlinkOptionPane.java - Hyperlink options panel
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2007 Matthieu Casanova
  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 gatchan.jedit.hyperlinks;
  23. //{{{ Imports
  24. import org.gjt.sp.jedit.AbstractOptionPane;
  25. import org.gjt.sp.jedit.MiscUtilities;
  26. import org.gjt.sp.jedit.ServiceManager;
  27. import org.gjt.sp.jedit.gui.ColorWellButton;
  28. import org.gjt.sp.jedit.jEdit;
  29. import org.gjt.sp.util.StringList;
  30. import javax.swing.*;
  31. import java.awt.*;
  32. import java.util.Arrays;
  33. //}}}
  34. /**
  35. * @author Matthieu Casanova
  36. * @version $Id: Buffer.java 8190 2006-12-07 07:58:34Z kpouer $
  37. */
  38. public class HyperlinkOptionPane extends AbstractOptionPane
  39. {
  40. //{{{ HyperlinkSourceOptionPane constructor
  41. public HyperlinkOptionPane()
  42. {
  43. super("hyperlink");
  44. } //}}}
  45. //{{{ _init() method
  46. public void _init()
  47. {
  48. hyperlinkColor = new ColorWellButton(jEdit.getColorProperty("options.hyperlink.color.value"));
  49. String[] serviceNames = ServiceManager.getServiceNames(HyperlinkSource.SERVICE);
  50. Arrays.sort(serviceNames, new MiscUtilities.StringICaseCompare());
  51. StringList sl = new StringList();
  52. sl.add(HyperlinkSource.NONE);
  53. sl.addAll(serviceNames);
  54. defaultSource = new JComboBox(sl.toArray());
  55. String defaultSourceName = jEdit.getProperty(HyperlinkSource.DEFAULT_PROPERTY);
  56. defaultSource.setSelectedItem(defaultSourceName);
  57. addComponent(jEdit.getProperty("options.hyperlink.color.label"), hyperlinkColor);
  58. addComponent(jEdit.getProperty(HyperlinkSource.DEFAULT_PROPERTY + ".label"), defaultSource);
  59. } //}}}
  60. //{{{ _save() method
  61. public void _save()
  62. {
  63. jEdit.setColorProperty("options.hyperlink.color.value", hyperlinkColor.getSelectedColor());
  64. String selected = (String) defaultSource.getSelectedItem();
  65. if (selected == HyperlinkSource.NONE)
  66. {
  67. jEdit.unsetProperty(HyperlinkSource.DEFAULT_PROPERTY);
  68. }
  69. else
  70. {
  71. jEdit.setProperty(HyperlinkSource.DEFAULT_PROPERTY, selected);
  72. }
  73. } //}}}
  74. //{{{ Private members
  75. //{{{ Instance variables
  76. private ColorWellButton hyperlinkColor;
  77. private JComboBox defaultSource;
  78. //}}}
  79. //}}}
  80. } //}}}