package de.games.nanoleaf.panelconfig;

import org.eclnt.jsfserver.elements.componentnodes.COLDISTANCENode;
import org.eclnt.jsfserver.elements.componentnodes.LABELNode;
import org.eclnt.jsfserver.elements.componentnodes.PANENode;
import org.eclnt.jsfserver.elements.componentnodes.ROWDISTANCENode;
import org.eclnt.jsfserver.elements.componentnodes.ROWNode;

public class NanoPANENode extends PANENode {

	private PanelInfo m_panelInfo = null;
	
	public PanelInfo getPanelInfo() {
		return m_panelInfo;
	}

	public void setPanelInfo(PanelInfo panelInfo) {
		m_panelInfo = panelInfo;
	}

	public NanoPANENode(PanelInfo panelInfo) {
		this.m_panelInfo = panelInfo;
		
		createInnerPane();
	}

	private void createInnerPane() {
		
		this.setDragsend("NANOLEAF:ID_" + getPanelInfo().getPanelID());
		this.setHeight(80);
		this.setWidth(80);
		this.setBorder("left:2;right:2;top:2;bottom:2;color:#ff0000");
		ROWDISTANCENode rowdistanceNode = new ROWDISTANCENode();
		this.addSubNode(rowdistanceNode);
		
		ROWNode row = new ROWNode();
		
		COLDISTANCENode coldistanceNode = new COLDISTANCENode();
		row.addSubNode(coldistanceNode);
		
		LABELNode labelPaneID = new LABELNode();
		labelPaneID.setText("ID: " + getPanelInfo().getPanelID());
		
		row.addSubNode(labelPaneID);

		this.addSubNode(row);
		
		row = new ROWNode();
		coldistanceNode = new COLDISTANCENode();
		row.addSubNode(coldistanceNode);
		labelPaneID = new LABELNode();
		labelPaneID.setText("Nano ID: ");
		
		row.addSubNode(labelPaneID);

		this.addSubNode(row);
		
		row = new ROWNode();
		coldistanceNode = new COLDISTANCENode();
		row.addSubNode(coldistanceNode);
		labelPaneID = new LABELNode();
		if (getPanelInfo().getPanelNanoleafID() == null) {
			labelPaneID.setText("unbek.");
		} else {
			labelPaneID.setText(getPanelInfo().getPanelNanoleafID());
		}
		
		row.addSubNode(labelPaneID);

		this.addSubNode(row);
		
	}
}
