<commit_before>/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
 *
 * Original Authors:
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * -----------------------------------------------------------------
 * File:          $RCSfile$
 * Date modified: $Date$
 * Version:       $Revision$
 * -----------------------------------------------------------------
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/
package org.vrjuggler.jccl.editors;

import java.beans.*;
import java.util.*;
import org.vrjuggler.jccl.config.*;
import org.vrjuggler.tweek.beans.BeanRegistry;

/**
 * An editor that knows how to edit enumerated values in a configuration element.
 */
public class EnumeratedPropertyValueEditor
   extends PropertyEditorSupport
{
   /**
    * Gets the property value as text.
    */
   public String getAsText()
   {
      Map enums = mPropertyDef.getEnums();
      for (Iterator itr = enums.keySet().iterator(); itr.hasNext(); )
      {
         String label = (String)itr.next();
         if (enums.get(label).equals(mValue))
         {
            return label;
         }
      }
      return null;
   }

   /**
    * Sets the property value by parsing the given String.
    *
    * @param text    any valid string
    *
    * @throws IllegalArgumentException
    *             if the string is null
    */
   public void setAsText(String text)
      throws IllegalArgumentException
   {
      if (text == null)
      {
         // Ack ... we got a bad string
         throw new IllegalArgumentException(text);
      }
      else
      {
         Map enums = mPropertyDef.getEnums();
         if (enums.containsKey(text))
         {
            setValue(enums.get(text));
         }

         // If we got here, we didn't get a valid string value
         throw new IllegalArgumentException(text);
      }
   }

   /**
    * Gets a list of known values that this property may be.
    */
   public String[] getTags()
   {
      List tags = new ArrayList(mPropertyDef.getEnums().keySet());
      Collections.sort(tags);
      return (String[])tags.toArray(new String[] {});
   }

   /**
    * Sets up the tags list based on the given definition of the property.
    */
   public void setPropertyDefinition(PropertyDefinition propDef)
   {
      mPropertyDef = propDef;
   }

   /**
    * Gets the property value.
    */
   public Object getValue()
   {
      return mValue;
   }

   /**
    * Sets the object that is to be edited.
    */
   public void setValue(Object value)
   {
      mValue = value;
      firePropertyChange();
   }

   /**
    * The value of the property being edited.
    */
   private Object mValue;

   /**
    * The property definition for the value being edited.
    */
   private PropertyDefinition mPropertyDef;
}
<commit_msg>Fixed a very simple bug that caused all comboboxes to not save selected values.<commit_after>/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
 *
 * Original Authors:
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>,
 *   <NAME>, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * -----------------------------------------------------------------
 * File:          $RCSfile$
 * Date modified: $Date$
 * Version:       $Revision$
 * -----------------------------------------------------------------
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/
package org.vrjuggler.jccl.editors;

import java.beans.*;
import java.util.*;
import org.vrjuggler.jccl.config.*;
import org.vrjuggler.tweek.beans.BeanRegistry;

/**
 * An editor that knows how to edit enumerated values in a configuration element.
 */
public class EnumeratedPropertyValueEditor
   extends PropertyEditorSupport
{
   /**
    * Gets the property value as text.
    */
   public String getAsText()
   {
      Map enums = mPropertyDef.getEnums();
      for (Iterator itr = enums.keySet().iterator(); itr.hasNext(); )
      {
         String label = (String)itr.next();
         if (enums.get(label).equals(mValue))
         {
            return label;
         }
      }
      return null;
   }

   /**
    * Sets the property value by parsing the given String.
    *
    * @param text    any valid string
    *
    * @throws IllegalArgumentException
    *             if the string is null
    */
   public void setAsText(String text)
      throws IllegalArgumentException
   {
      if (text == null)
      {
         // Ack ... we got a bad string
         throw new IllegalArgumentException(text);
      }
      else
      {
         Map enums = mPropertyDef.getEnums();
         if (!enums.containsKey(text))
         {
            // If we got here, we didn't get a valid string value
            throw new IllegalArgumentException(text);
         }
         setValue(enums.get(text));
      }
   }

   /**
    * Gets a list of known values that this property may be.
    */
   public String[] getTags()
   {
      List tags = new ArrayList(mPropertyDef.getEnums().keySet());
      Collections.sort(tags);
      return (String[])tags.toArray(new String[] {});
   }

   /**
    * Sets up the tags list based on the given definition of the property.
    */
   public void setPropertyDefinition(PropertyDefinition propDef)
   {
      mPropertyDef = propDef;
   }

   /**
    * Gets the property value.
    */
   public Object getValue()
   {
      return mValue;
   }

   /**
    * Sets the object that is to be edited.
    */
   public void setValue(Object value)
   {
      mValue = value;
      firePropertyChange();
   }

   /**
    * The value of the property being edited.
    */
   private Object mValue;

   /**
    * The property definition for the value being edited.
    */
   private PropertyDefinition mPropertyDef;
}

{'fraction_non_alphanumeric': 0.14144424874678227, 'fraction_numerical': 0.006232217856658989, 'mean_word_length': 2.1479744136460552, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6443936', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1967, 'n_words': 725}