package cn.net.connor.std.processedit.meopviewfx.bean;

import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCPropertyDescriptor;

import javafx.scene.control.Control;

public class PropConfig {
	public String propName;
	public String propDisplayName;
	public String propLoc;
	public TCComponentListOfValues lov;
	public String filterValue;
	public TCPropertyDescriptor propDesc;
	public int width;
	public int maxCharacterInRow;
	public boolean canEdit;
	private Control control;
	private Object savedValue;
	public int height;

	public PropConfig(String propLoc, TCPropertyDescriptor propDesc, String filterValue, int width, int height, int maxCharacterInRow) {
		this.propName = propDesc.getName();
		this.propDisplayName = propDesc.getDisplayName();
		this.propLoc = propLoc;
		this.filterValue = filterValue;
		this.lov = propDesc.getLOV();
		this.propDesc = propDesc;
		this.width = width;
		this.height = height;
		this.maxCharacterInRow = maxCharacterInRow;
		// this.canEdit =
		// propDesc.isModifiable()&&!"bl_occ_type".equals(propName)&&!"item_id".equals(propName);
		this.canEdit = propDesc.isModifiable() && !"item_id".equals(propName);
		System.out.println(propName + " >> " + lov + " >> " + canEdit + " >> " + width + "x" + height);
	}

	public void setSavedValue(Object savedValue) {
		this.savedValue = savedValue;
	}

	public boolean valueChanged(Object newValue) {
		if (savedValue != null) {
			return !savedValue.equals(newValue);
		}
		return newValue != null;
	}

	public void setControl(Control control) {
		this.control = control;
	}

	public Control getControl() {
		return control;
	}

	@Override
	public String toString() {
		return propName;
	}
}
