PageRenderTime 105ms CodeModel.GetById 98ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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
 20package org.gjt.sp.jedit;
 21
 22import java.util.Enumeration;
 23import java.util.Vector;
 24
 25import org.gjt.sp.util.Log;
 26
 27public class OptionGroup
 28{
 29	public OptionGroup(String name)
 30	{
 31		this.name = name;
 32		members = new Vector();
 33	}
 34
 35	public String getName()
 36	{
 37		return name;
 38	}
 39
 40	public void addOptionGroup(OptionGroup group)
 41	{
 42		if (members.indexOf(group) != -1) return;
 43
 44		members.addElement(group);
 45	}
 46
 47	public void addOptionPane(OptionPane pane)
 48	{
 49		if (members.indexOf(pane) != -1) return;
 50
 51		members.addElement(pane);
 52	}
 53
 54	public Enumeration getMembers()
 55	{
 56		return members.elements();
 57	}
 58
 59	public Object getMember(int index)
 60	{
 61		return (index >= 0 && index < members.size())
 62			? members.elementAt(index) : null;
 63	}
 64
 65	public int getMemberIndex(Object member)
 66	{
 67		return members.indexOf(member);
 68	}
 69
 70	public int getMemberCount()
 71	{
 72		return members.size();
 73	}
 74
 75	public void save()
 76	{
 77		Enumeration enum = members.elements();
 78
 79		while (enum.hasMoreElements())
 80		{
 81			Object elem = enum.nextElement();
 82			try
 83			{
 84				if (elem instanceof OptionPane)
 85				{
 86					((OptionPane)elem).save();
 87				}
 88				else if (elem instanceof OptionGroup)
 89				{
 90					((OptionGroup)elem).save();
 91				}
 92			}
 93			catch(Throwable t)
 94			{
 95				Log.log(Log.ERROR, elem,
 96					"Error saving option pane");
 97				Log.log(Log.ERROR, elem, t);
 98			}
 99		}
100	}
101
102	private String name;
103	private Vector members;
104}