PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Java | 104 lines | 70 code | 16 blank | 18 comment | 9 complexity | 4a62eba4219c5484b2a0afb25d3b02b6 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. * OptionGroup.java - Option pane group
  3. * Copyright (C) 2000 mike dillon
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package org.gjt.sp.jedit;
  20. import java.util.Enumeration;
  21. import java.util.Vector;
  22. import org.gjt.sp.util.Log;
  23. public class OptionGroup
  24. {
  25. public OptionGroup(String name)
  26. {
  27. this.name = name;
  28. members = new Vector();
  29. }
  30. public String getName()
  31. {
  32. return name;
  33. }
  34. public void addOptionGroup(OptionGroup group)
  35. {
  36. if (members.indexOf(group) != -1) return;
  37. members.addElement(group);
  38. }
  39. public void addOptionPane(OptionPane pane)
  40. {
  41. if (members.indexOf(pane) != -1) return;
  42. members.addElement(pane);
  43. }
  44. public Enumeration getMembers()
  45. {
  46. return members.elements();
  47. }
  48. public Object getMember(int index)
  49. {
  50. return (index >= 0 && index < members.size())
  51. ? members.elementAt(index) : null;
  52. }
  53. public int getMemberIndex(Object member)
  54. {
  55. return members.indexOf(member);
  56. }
  57. public int getMemberCount()
  58. {
  59. return members.size();
  60. }
  61. public void save()
  62. {
  63. Enumeration enum = members.elements();
  64. while (enum.hasMoreElements())
  65. {
  66. Object elem = enum.nextElement();
  67. try
  68. {
  69. if (elem instanceof OptionPane)
  70. {
  71. ((OptionPane)elem).save();
  72. }
  73. else if (elem instanceof OptionGroup)
  74. {
  75. ((OptionGroup)elem).save();
  76. }
  77. }
  78. catch(Throwable t)
  79. {
  80. Log.log(Log.ERROR, elem,
  81. "Error saving option pane");
  82. Log.log(Log.ERROR, elem, t);
  83. }
  84. }
  85. }
  86. private String name;
  87. private Vector members;
  88. }