package de.ugoe.cs.quest.plugin.jfc.guimodel;

import de.ugoe.cs.quest.eventcore.guimodel.AbstractDefaultGUIElement;
import de.ugoe.cs.quest.eventcore.guimodel.IGUIElementSpec;

/**
 * TODO comment
 * 
 * @version $Revision: $ $Date: $
 * @author 2011, last modified by $Author: $
 */
public class JFCGUIElement extends AbstractDefaultGUIElement {
    
    /**  */
    private static final long serialVersionUID = 1L;

    /** the specification of the GUI Element */
    private JFCGUIElementSpec specification;

    /**
     * @param name
     * @param id
     * @param isModal
     */
    public JFCGUIElement(JFCGUIElementSpec specification, JFCGUIElement parent) {
        super(specification, parent);
        this.specification = specification;
    }

    /* (non-Javadoc)
     * @see de.ugoe.cs.quest.eventcore.IEventTarget#getPlatform()
     */
    @Override
    public String getPlatform() {
        return "JFC";
    }

    /**
     * TODO: comment
     * 
     * @return
     */
    public String getJavaType() {
        return specification.getType();
    }

    /**
     * @return Returns the name.
     */
    String getName() {
        return specification.getName();
    }

    /**
     * @return the icon
     */
    String getIcon() {
        return specification.getIcon();
    }

    /**
     * @return the index
     */
    int getIndex() {
        return specification.getIndex();
    }

    /**
     * @return the hashCode
     */
    String getElementHash() {
        return specification.getElementHash();
    }

    /**
     * <p>
     * TODO comment
     * </p>
     */
    @Override
    public void updateSpecification(IGUIElementSpec updateSpecification) {
        if( updateSpecification instanceof JFCGUIElementSpec ) {
            specification.setName(((JFCGUIElementSpec) updateSpecification).getName());
            specification.setElementHash(((JFCGUIElementSpec) updateSpecification).getElementHash());
        }
    }
    
    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        String str = getElementDescriptor() + "(" + getName() + ", " + getElementHash() + "," + getIcon() + "," + getIndex() +")";
        if( getParent()!=null ) {
            return getParent().toString() + "->" + str;
        }
        return str;
    }
    
    protected String getElementDescriptor() {
        return "Default";
    }

}
