package c4lab.iot.smarthomevisualeditor.ddsource;

import com.vaadin.ui.Component;
import fi.jasoft.dragdroplayouts.DDVerticalLayout;

public class UISource extends DDVerticalLayout {
	private boolean isContainer = false;
	
	private String id = "";
	private String name = "";
	private String type = "";
	private Component content = null;
	private Class contentClass = null;

	public UISource(String name) {
		super();
		this.setSizeFull();
		this.name = name;
	}
	
	public UISource(Component c, String name) {
		super();
		this.setSizeFull();
		this.name = name;
		
		c.setSizeFull();
		this.setContent(c);
	}
	
	public boolean isContainer() {
		return isContainer;
	}

	public void setIsContainer(boolean isContainer) {
		this.isContainer = isContainer;
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Component getContent() {
		return content;
	}
	
	public void setContent(Component content) {
		this.content = content;
		this.contentClass = content.getClass();
		this.addComponent(this.content);
	}

	public Class getContentClass() {
		return contentClass;
	}
}

@@ -44,16 +44,52 @@
 ource;%0A%0A
+import java.security.SecureRandom;%0A%0A
 import c
@@ -112,16 +112,16 @@
 ponent;%0A
-
 import f
@@ -213,16 +213,157 @@
 ayout %7B%0A
+%09static final String SET = %220123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz%22;%0A%09static SecureRandom rnd = new SecureRandom();%0A%0A
 %09private
@@ -392,18 +392,17 @@
  false;%0A
-%09
 %0A
+
 %09private
@@ -628,26 +628,25 @@
  = name;%0A%09%7D%0A
-%09
 %0A
+
 %09public UISo
@@ -735,11 +735,9 @@
 me;%0A
-%09%09
 %0A
+
 %09%09c.
@@ -772,25 +772,237 @@
 tent(c);%0A%09%7D%0A
-%09
+%0A%09public static String randomString() %7B%0A%09%09int len = 10;%0A%09%09StringBuilder sb = new StringBuilder(len);%0A%09%09for (int i = 0; i %3C len; i++)%0A%09%09%09sb.append(SET.charAt(rnd.nextInt(SET.length())));%0A%09%09return sb.toString();%0A%09%7D%0A
 %0A%09public boo
@@ -1132,26 +1132,25 @@
 ntainer;%0A%09%7D%0A
-%09
 %0A
+
 %09public Stri
@@ -1497,17 +1497,16 @@
 ent;%0A%09%7D%0A
-%09
 %0A%09public

add generate unique id function