mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
show mutual properties across different component types
This commit is contained in:
Binary file not shown.
+16
-8
@@ -1,7 +1,6 @@
|
|||||||
package org.diylc.common;
|
package org.diylc.common;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import org.diylc.core.IPropertyValidator;
|
import org.diylc.core.IPropertyValidator;
|
||||||
|
|
||||||
@@ -16,12 +15,13 @@ public class PropertyWrapper implements Cloneable {
|
|||||||
private String name;
|
private String name;
|
||||||
private Class<?> type;
|
private Class<?> type;
|
||||||
private Object value;
|
private Object value;
|
||||||
private Method setter;
|
private String setter;
|
||||||
private Method getter;
|
private String getter;
|
||||||
private boolean defaultable;
|
private boolean defaultable;
|
||||||
private IPropertyValidator validator;
|
private IPropertyValidator validator;
|
||||||
|
private boolean unique = true;
|
||||||
|
|
||||||
public PropertyWrapper(String name, Class<?> type, Method getter, Method setter,
|
public PropertyWrapper(String name, Class<?> type, String getter, String setter,
|
||||||
boolean defaultable, IPropertyValidator validator) {
|
boolean defaultable, IPropertyValidator validator) {
|
||||||
super();
|
super();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -33,8 +33,8 @@ public class PropertyWrapper implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readFrom(Object object) throws IllegalArgumentException, IllegalAccessException,
|
public void readFrom(Object object) throws IllegalArgumentException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException, SecurityException, NoSuchMethodException {
|
||||||
this.value = getter.invoke(object);
|
this.value = object.getClass().getMethod(getter).invoke(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void readUniqueFrom(IDIYComponent component)
|
// public void readUniqueFrom(IDIYComponent component)
|
||||||
@@ -47,8 +47,8 @@ public class PropertyWrapper implements Cloneable {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException,
|
public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException,
|
||||||
InvocationTargetException {
|
InvocationTargetException, SecurityException, NoSuchMethodException {
|
||||||
setter.invoke(object, value);
|
object.getClass().getMethod(setter, this.value.getClass()).invoke(object, this.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -75,6 +75,14 @@ public class PropertyWrapper implements Cloneable {
|
|||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUnique() {
|
||||||
|
return unique;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnique(boolean unique) {
|
||||||
|
this.unique = unique;
|
||||||
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public Object clone() throws CloneNotSupportedException {
|
// public Object clone() throws CloneNotSupportedException {
|
||||||
// // Try to invoke clone method on value if possible.
|
// // Try to invoke clone method on value if possible.
|
||||||
|
|||||||
+2
-2
@@ -141,8 +141,8 @@ public class ComponentProcessor {
|
|||||||
Method setter = clazz.getMethod("set" + method.getName().substring(3),
|
Method setter = clazz.getMethod("set" + method.getName().substring(3),
|
||||||
method.getReturnType());
|
method.getReturnType());
|
||||||
PropertyWrapper property = new PropertyWrapper(name,
|
PropertyWrapper property = new PropertyWrapper(name,
|
||||||
method.getReturnType(), method, setter, annotation.defaultable(),
|
method.getReturnType(), method.getName(), setter.getName(),
|
||||||
validator);
|
annotation.defaultable(), validator);
|
||||||
properties.add(property);
|
properties.add(property);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
|
|||||||
+3
-1
@@ -173,9 +173,11 @@ public class InstantiationManager {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
* @throws InvocationTargetException
|
* @throws InvocationTargetException
|
||||||
|
* @throws NoSuchMethodException
|
||||||
|
* @throws SecurityException
|
||||||
*/
|
*/
|
||||||
public void fillWithDefaultProperties(Object object) throws IllegalArgumentException,
|
public void fillWithDefaultProperties(Object object) throws IllegalArgumentException,
|
||||||
IllegalAccessException, InvocationTargetException {
|
IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
|
||||||
// Extract properties.
|
// Extract properties.
|
||||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(
|
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(
|
||||||
object.getClass());
|
object.getClass());
|
||||||
|
|||||||
@@ -324,7 +324,11 @@
|
|||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
<com.diyfever.gui.update.Change>
|
<com.diyfever.gui.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Ctrl+click should not cleanup selection when clicked on the canvas</description>
|
<description>Component edit dialog should show mutual properties when components of different types are selected (e.g. curved trace and straight trace witdth)</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Ctrl+click should not clear selection when clicked on the canvas</description>
|
||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
<com.diyfever.gui.update.Change>
|
<com.diyfever.gui.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
+2
-3
@@ -8,7 +8,6 @@ import org.diylc.common.ObjectCache;
|
|||||||
import org.diylc.components.AbstractCurvedComponent;
|
import org.diylc.components.AbstractCurvedComponent;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Theme;
|
|
||||||
import org.diylc.core.annotations.ComponentDescriptor;
|
import org.diylc.core.annotations.ComponentDescriptor;
|
||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
@@ -40,11 +39,11 @@ public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Width")
|
@EditableProperty(name = "Width")
|
||||||
public Size getSize() {
|
public Size getThickness() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(Size size) {
|
public void setThickness(Size size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -105,7 +105,7 @@ public class TubeSocket extends AbstractTransparentComponent<String> {
|
|||||||
break;
|
break;
|
||||||
case B9A:
|
case B9A:
|
||||||
pinCount = 9;
|
pinCount = 9;
|
||||||
pinCircleDiameter = getClosestOdd(new Size(14d, SizeUnit.mm).convertToPixels());
|
pinCircleDiameter = getClosestOdd(new Size(21d, SizeUnit.mm).convertToPixels());
|
||||||
hasEmptySpace = true;
|
hasEmptySpace = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user