diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/.classpath b/ diy-layout-creator --username bancika@gmail.com/diylc-core/.classpath index 5b6fba27..0d4ad847 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-core/.classpath +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/.classpath @@ -6,12 +6,8 @@ - - - - - + diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/cloning-1.8.1.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/cloning-1.8.1.jar deleted file mode 100644 index ebd2d8c2..00000000 Binary files a/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/cloning-1.8.1.jar and /dev/null differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/objenesis-1.2.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/objenesis-1.2.jar deleted file mode 100644 index fb04d7fa..00000000 Binary files a/ diy-layout-creator --username bancika@gmail.com/diylc-core/lib/objenesis-1.2.jar and /dev/null differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/common/PropertyWrapper.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/common/PropertyWrapper.java index d07af5f4..31e5384d 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/common/PropertyWrapper.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/common/PropertyWrapper.java @@ -22,8 +22,8 @@ public class PropertyWrapper implements Cloneable { private boolean unique = true; private boolean changed = false; - public PropertyWrapper(String name, Class type, String getter, String setter, - boolean defaultable, IPropertyValidator validator) { + public PropertyWrapper(String name, Class type, String getter, + String setter, boolean defaultable, IPropertyValidator validator) { super(); this.name = name; this.type = type; @@ -33,8 +33,9 @@ public class PropertyWrapper implements Cloneable { this.validator = validator; } - public void readFrom(Object object) throws IllegalArgumentException, IllegalAccessException, - InvocationTargetException, SecurityException, NoSuchMethodException { + public void readFrom(Object object) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException, + SecurityException, NoSuchMethodException { this.value = object.getClass().getMethod(getter).invoke(object); } @@ -47,8 +48,9 @@ public class PropertyWrapper implements Cloneable { // } // } - public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException, - InvocationTargetException, SecurityException, NoSuchMethodException { + public void writeTo(Object object) throws IllegalArgumentException, + IllegalAccessException, InvocationTargetException, + SecurityException, NoSuchMethodException { object.getClass().getMethod(setter, type).invoke(object, this.value); } @@ -75,19 +77,19 @@ public class PropertyWrapper implements Cloneable { public IPropertyValidator getValidator() { return validator; } - + public boolean isUnique() { return unique; } - + public void setUnique(boolean unique) { this.unique = unique; } - + public boolean isChanged() { return changed; } - + public void setChanged(boolean changed) { this.changed = changed; } @@ -102,6 +104,15 @@ public class PropertyWrapper implements Cloneable { // } // return new Property(name, type, value); // } + @Override + public Object clone() throws CloneNotSupportedException { + PropertyWrapper clone = new PropertyWrapper(this.name, this.type, this.getter, + this.setter, this.defaultable, this.validator); + clone.value = this.value; + clone.changed = this.changed; + clone.unique = this.unique; + return clone; + } @Override public int hashCode() { diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/components/AbstractComponent.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/components/AbstractComponent.java index 90b84bf4..1dfb2987 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/components/AbstractComponent.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/components/AbstractComponent.java @@ -18,8 +18,6 @@ import org.diylc.common.VerticalAlignment; import org.diylc.core.IDIYComponent; import org.diylc.core.annotations.EditableProperty; -import com.rits.cloning.CloningException; - /** * Abstract implementation of {@link IDIYComponent} that contains component name * and toString. @@ -177,7 +175,7 @@ public abstract class AbstractComponent implements IDIYComponent { } return newInstance; } catch (Exception e) { - throw new CloningException("Could not clone the component", e); + throw new CloneNotSupportedException("Could not clone the component. Reason: " + e.getMessage()); } } } diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/ComponentProcessor.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/ComponentProcessor.java index d99018da..1050b478 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/ComponentProcessor.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/ComponentProcessor.java @@ -24,8 +24,6 @@ import org.diylc.core.annotations.BomPolicy; import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.EditableProperty; -import com.rits.cloning.Cloner; - /** * Utility class with component processing methods. * @@ -42,8 +40,6 @@ public class ComponentProcessor { private Map propertyValidatorCache; private Map componentTypeMap; - private Cloner cloner; - public static ComponentProcessor getInstance() { if (instance == null) { instance = new ComponentProcessor(); @@ -53,7 +49,6 @@ public class ComponentProcessor { private ComponentProcessor() { super(); - this.cloner = new Cloner(); this.propertyCache = new HashMap>(); this.componentTypeMap = new HashMap(); this.propertyValidatorCache = new HashMap(); @@ -132,7 +127,7 @@ public class ComponentProcessor { */ public List extractProperties(Class clazz) { if (propertyCache.containsKey(clazz.getName())) { - return cloner.deepClone(propertyCache.get(clazz.getName())); + return cloneProperties(propertyCache.get(clazz.getName())); } List properties = new ArrayList(); for (Method method : clazz.getMethods()) { @@ -167,7 +162,19 @@ public class ComponentProcessor { } propertyCache.put(clazz.getName(), properties); - return cloner.deepClone(properties); + return cloneProperties(properties); + } + + private List cloneProperties(List properties) { + List result = new ArrayList(properties.size()); + for (PropertyWrapper propertyWrapper : properties) { + try { + result.add((PropertyWrapper) propertyWrapper.clone()); + } catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + } + return result; } /** diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/InstantiationManager.java b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/InstantiationManager.java index bcbb3dec..a4ef95a2 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/InstantiationManager.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-core/src/org/diylc/presenter/InstantiationManager.java @@ -16,8 +16,6 @@ import org.diylc.core.IDIYComponent; import org.diylc.core.Project; import org.diylc.core.measures.Size; -import com.rits.cloning.Cloner; - /** * Manages component instantiation. * @@ -30,15 +28,12 @@ public class InstantiationManager { public static int MAX_RECENT_COMPONENTS = 16; - private Cloner cloner; - private ComponentType componentTypeSlot; private IDIYComponent componentSlot; private Point firstControlPoint; private Point potentialControlPoint; public InstantiationManager() { - cloner = new Cloner(); } public ComponentType getComponentTypeSlot() { @@ -227,7 +222,7 @@ public class InstantiationManager { + object.getClass().getName() + ":" + property.getName(), null); if (defaultValue != null) { - property.setValue(cloner.deepClone(defaultValue)); + property.setValue(defaultValue); property.writeTo(object); } }