/*=========================================================================

  Program:   Orbit Visualization Tool
  Source:    $Source: /stor/devel/ovt2g/ovt/object/editor/EarthTypeEditor.java,v $
  Date:      $Date: 2000/10/30 17:59:28 $
  Version:   $Revision: 1.6 $


Copyright (c) 2000 OVT Team (Kristof Stasiewicz, Mykola Khotyaintsev, 
Yuri Khotyaintsev)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification is permitted provided that the following conditions are met:

 * No part of the software can be included in any commercial package without
written consent from the OVT team.

 * Redistributions of the source or binary code must retain the above
copyright notice, this list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT OR
INDIRECT DAMAGES  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE.

OVT Team (http://ovt.irfu.se)   K. Stasiewicz, M. Khotyaintsev, Y.
Khotyaintsev

=========================================================================*/

/*
 * EarthTypeEditor.java
 *
 * Created on April 4, 2000, 10:40 AM
 */
 
package ovt.object.editor;

import ovt.*;
import ovt.object.*;
import ovt.beans.*;

import javax.swing.*;

/** 
 *
 * @author  ko
 * @version 
 */
public class EarthTypeEditor extends MenuPropertyEditor {

  
  /** Creates new earthtype editor*/
  public EarthTypeEditor(BasicPropertyDescriptor pd) {
    super(pd, MenuPropertyEditor.RADIOBUTTON);
    int[] types = {Earth.CONTINENTS, Earth.BOTH, Earth.GRID, Earth.TEXTURE};
    initialize(types);
  }
  
  protected Earth getEarth() {
    return (Earth)getBean();
  }
  
  public void initialize(int[] intValues) {
    Object[] values = new Object[intValues.length];
    String[] tags = new String[intValues.length];
    
    for (int i=0; i<intValues.length; i++) {
      values[i] = new Integer(intValues[i]);
      tags[i]   = Earth.getEarthType(intValues[i]);
    }
    
    setTags(tags);
    setValues(values);
  }
  
  public void setEnabled(int item, boolean enabled) {
    if (!OVTCore.isServer()) {
        JMenuItem menuItem;
        String itemName = Earth.getEarthType(item);
        //System.out.println("Trying to enable="+enabled+" "+itemName);
        for (int i=0; i<getMenuItems().length; i++) {
            menuItem = getMenuItems()[i];
            if (menuItem.getText().equals(itemName)) menuItem.setEnabled(enabled);
        }
    } else System.out.println("EarthTypeEditor.setEnabled : Doesn't disable some earth texture types. To be fixed later...");
  }
  
}