mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 01:02:08 +10:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 934b510fbc | |||
| 385612bc74 | |||
| ae3694c70d | |||
| 56fef06b22 | |||
| 4897b803b6 | |||
| 6c698e935e | |||
| 1645eae18d | |||
| 5adbc2c6ca | |||
| e3b1f0d4e6 | |||
| bc88253c70 | |||
| 1d45bf345c | |||
| c61ec71ee1 | |||
| 35272c1339 | |||
| 93e057dfb2 | |||
| aef5c88a3f | |||
| 591bdd313c | |||
| 3f9caf9918 | |||
| 246decdf7c | |||
| 0bc8141dc7 |
@@ -6,12 +6,8 @@
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iText-2.1.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/cloning-1.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/objenesis-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/>
|
||||
<classpathentry kind="lib" path="library/main.jar"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/app-framework"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -24,12 +24,13 @@ public class ComponentType {
|
||||
private Icon icon;
|
||||
private Class<? extends IDIYComponent<?>> instanceClass;
|
||||
private double zOrder;
|
||||
private boolean flexibleZOrder;
|
||||
private boolean stretchable;
|
||||
private BomPolicy bomPolicy;
|
||||
|
||||
public ComponentType(String name, String description, CreationMethod creationMethod,
|
||||
String category, String namePrefix, String author, Icon icon,
|
||||
Class<? extends IDIYComponent<?>> instanceClass, double zOrder,
|
||||
Class<? extends IDIYComponent<?>> instanceClass, double zOrder, boolean flexibleZOrder,
|
||||
boolean stretchable, BomPolicy bomPolicy) {
|
||||
super();
|
||||
this.name = name;
|
||||
@@ -41,6 +42,7 @@ public class ComponentType {
|
||||
this.icon = icon;
|
||||
this.instanceClass = instanceClass;
|
||||
this.zOrder = zOrder;
|
||||
this.flexibleZOrder = flexibleZOrder;
|
||||
this.stretchable = stretchable;
|
||||
this.bomPolicy = bomPolicy;
|
||||
}
|
||||
@@ -80,6 +82,10 @@ public class ComponentType {
|
||||
public double getZOrder() {
|
||||
return zOrder;
|
||||
}
|
||||
|
||||
public boolean isFlexibleZOrder() {
|
||||
return flexibleZOrder;
|
||||
}
|
||||
|
||||
public boolean isStretchable() {
|
||||
return stretchable;
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -4,10 +4,14 @@ import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.GlyphVector;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.VerticalAlignment;
|
||||
@@ -18,6 +22,10 @@ import org.diylc.core.annotations.EditableProperty;
|
||||
* Abstract implementation of {@link IDIYComponent} that contains component name
|
||||
* and toString.
|
||||
*
|
||||
* IMPORTANT: to improve performance, all fields except for <code>Point</code>
|
||||
* and <code>Point</code> arrays should be immutable. Failing to comply with
|
||||
* this can result in annoying and hard to trace bugs.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*
|
||||
* @param <T>
|
||||
@@ -80,9 +88,11 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
}
|
||||
|
||||
protected void drawCenteredText(Graphics2D g2d, String text, int x, int y,
|
||||
HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
|
||||
HorizontalAlignment horizontalAlignment,
|
||||
VerticalAlignment verticalAlignment) {
|
||||
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||
Rectangle stringBounds = fontMetrics.getStringBounds(text, g2d).getBounds();
|
||||
Rectangle stringBounds = fontMetrics.getStringBounds(text, g2d)
|
||||
.getBounds();
|
||||
|
||||
Font font = g2d.getFont();
|
||||
FontRenderContext renderContext = g2d.getFontRenderContext();
|
||||
@@ -117,4 +127,55 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
|
||||
|
||||
g2d.drawString(text, textX, textY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public IDIYComponent<T> clone() throws CloneNotSupportedException {
|
||||
try {
|
||||
// Instantiate object of the same type
|
||||
AbstractComponent<T> newInstance = (AbstractComponent<T>) this
|
||||
.getClass().getConstructors()[0].newInstance();
|
||||
Class<?> clazz = this.getClass();
|
||||
while (AbstractComponent.class.isAssignableFrom(clazz)) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
clazz = clazz.getSuperclass();
|
||||
// fields = this.getClass().getDeclaredFields();
|
||||
// Copy over all non-static, non-final fields that are declared
|
||||
// in
|
||||
// AbstractComponent or one of it's child classes
|
||||
for (Field field : fields) {
|
||||
if (!Modifier.isStatic(field.getModifiers())
|
||||
&& !Modifier.isFinal(field.getModifiers())) {
|
||||
field.setAccessible(true);
|
||||
Object value = field.get(this);
|
||||
|
||||
// Deep copy point arrays.
|
||||
// TODO: something nicer
|
||||
if (value != null
|
||||
&& value.getClass().isArray()
|
||||
&& value.getClass().getComponentType()
|
||||
.isAssignableFrom(Point.class)) {
|
||||
Object newArray = Array.newInstance(value
|
||||
.getClass().getComponentType(), Array
|
||||
.getLength(value));
|
||||
for (int i = 0; i < Array.getLength(value); i++) {
|
||||
Point p = (Point) Array.get(value, i);
|
||||
Array.set(newArray, i, new Point(p));
|
||||
}
|
||||
value = newArray;
|
||||
}
|
||||
// Deep copy points.
|
||||
// TODO: something nicer
|
||||
if (value != null && value instanceof Point) {
|
||||
value = new Point((Point) value);
|
||||
}
|
||||
|
||||
field.set(newInstance, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newInstance;
|
||||
} catch (Exception e) {
|
||||
throw new CloneNotSupportedException("Could not clone the component. Reason: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ public interface IDIYComponent<T> extends Serializable {
|
||||
* @param project
|
||||
* @param drawingObserver
|
||||
*/
|
||||
void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
void draw(Graphics2D g2d, ComponentState componentState,
|
||||
boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver);
|
||||
|
||||
/**
|
||||
@@ -119,4 +120,11 @@ public interface IDIYComponent<T> extends Serializable {
|
||||
* @param height
|
||||
*/
|
||||
void drawIcon(Graphics2D g2d, int width, int height);
|
||||
|
||||
/**
|
||||
* Clones the component.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IDIYComponent<T> clone() throws CloneNotSupportedException;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package org.diylc.core;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
@@ -210,15 +212,37 @@ public class Project implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Project clone() throws CloneNotSupportedException {
|
||||
// List<IDIYComponent> clonedComponents = new
|
||||
// ArrayList<IDIYComponent>();
|
||||
// for (IDIYComponent component : components) {
|
||||
// clonedComponents.add(component.clone());
|
||||
// }
|
||||
// Project project = new Project(title, author, description,
|
||||
// width.clone(), height.clone(), clonedComponents);
|
||||
// return project;
|
||||
// }
|
||||
@Override
|
||||
public Project clone() {
|
||||
Project project = new Project();
|
||||
project.setTitle(this.getTitle());
|
||||
project.setAuthor(this.getAuthor());
|
||||
project.setDescription(this.getDescription());
|
||||
project.setFileVersion(this.getFileVersion());
|
||||
project.setGridSpacing(this.getGridSpacing());
|
||||
project.setHeight(this.getHeight());
|
||||
project.setWidth(this.getWidth());
|
||||
project.getLockedLayers().addAll(this.getLockedLayers());
|
||||
|
||||
Map<IDIYComponent<?>, IDIYComponent<?>> cloneMap = new HashMap<IDIYComponent<?>, IDIYComponent<?>>();
|
||||
|
||||
for (IDIYComponent<?> component : this.components) {
|
||||
try {
|
||||
IDIYComponent<?> clone = component.clone();
|
||||
project.getComponents().add(clone);
|
||||
cloneMap.put(component, clone);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
for (Set<IDIYComponent<?>> group : this.groups) {
|
||||
Set<IDIYComponent<?>> cloneGroup = new HashSet<IDIYComponent<?>>();
|
||||
for (IDIYComponent<?> component : group) {
|
||||
cloneGroup.add(cloneMap.get(component));
|
||||
}
|
||||
project.groups.add(cloneGroup);
|
||||
}
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.diylc.core.IDIYComponent;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ComponentDescriptor {
|
||||
|
||||
|
||||
/**
|
||||
* @return component type name.
|
||||
*/
|
||||
@@ -53,14 +53,21 @@ public @interface ComponentDescriptor {
|
||||
*/
|
||||
double zOrder();
|
||||
|
||||
/**
|
||||
* @return true if the component may go beyond it's predefined layer. In
|
||||
* that case, <code>zOrder</code> is used as initial z order of the
|
||||
* component.
|
||||
*/
|
||||
boolean flexibleZOrder() default false;
|
||||
|
||||
/**
|
||||
* @return when false, moving one control point will cause all the others to
|
||||
* move together with it.
|
||||
*/
|
||||
boolean stretchable() default true;
|
||||
|
||||
|
||||
/**
|
||||
* @return controls what should be shown the BOM
|
||||
* @return controls what should be shown the BOM
|
||||
*/
|
||||
BomPolicy bomPolicy() default BomPolicy.SHOW_ALL_NAMES;
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@ import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
|
||||
/***
|
||||
* Immutable measure class.
|
||||
*
|
||||
* @author bancika
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -13,8 +20,8 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
|
||||
protected Double value;
|
||||
protected T unit;
|
||||
|
||||
public AbstractMeasure() {
|
||||
}
|
||||
// public AbstractMeasure() {
|
||||
// }
|
||||
|
||||
public AbstractMeasure(Double value, T unit) {
|
||||
super();
|
||||
@@ -26,22 +33,22 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
// public void setValue(Double value) {
|
||||
// this.value = value;
|
||||
// }
|
||||
|
||||
public T getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(T multiplier) {
|
||||
this.unit = multiplier;
|
||||
}
|
||||
// public void setUnit(T multiplier) {
|
||||
// this.unit = multiplier;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
// @Override
|
||||
// public Object clone() throws CloneNotSupportedException {
|
||||
// return super.clone();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
@@ -4,10 +4,10 @@ public class Capacitance extends AbstractMeasure<CapacitanceUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Capacitance() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Capacitance() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Capacitance(Double value, CapacitanceUnit unit) {
|
||||
super(value, unit);
|
||||
|
||||
@@ -4,10 +4,10 @@ public class Inductance extends AbstractMeasure<InductanceUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Inductance() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Inductance() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Inductance(Double value, InductanceUnit unit) {
|
||||
super(value, unit);
|
||||
|
||||
@@ -4,10 +4,10 @@ public class Power extends AbstractMeasure<PowerUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Power() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Power() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Power(Double value, PowerUnit unit) {
|
||||
super(value, unit);
|
||||
|
||||
@@ -15,10 +15,10 @@ public class Resistance extends AbstractMeasure<ResistanceUnit> {
|
||||
Color.decode("#FFB90F"), Color.black, Color.decode("#8B4513"), Color.red, Color.orange,
|
||||
Color.yellow, Color.decode("#76EE00"), Color.blue };
|
||||
|
||||
public Resistance() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Resistance() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Resistance(Double value, ResistanceUnit multiplier) {
|
||||
super(value, multiplier);
|
||||
|
||||
@@ -6,10 +6,10 @@ public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size>
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Size() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Size() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Size(Double value, SizeUnit unit) {
|
||||
super(value, unit);
|
||||
|
||||
@@ -4,10 +4,10 @@ public class Voltage extends AbstractMeasure<VoltageUnit> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Voltage() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
// public Voltage() {
|
||||
// super();
|
||||
// // TODO Auto-generated constructor stub
|
||||
// }
|
||||
|
||||
public Voltage(Double value, VoltageUnit unit) {
|
||||
super(value, unit);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -33,7 +31,8 @@ import com.rits.cloning.Cloner;
|
||||
*/
|
||||
public class ComponentProcessor {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ComponentProcessor.class);
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(ComponentProcessor.class);
|
||||
|
||||
private static ComponentProcessor instance;
|
||||
|
||||
@@ -41,8 +40,6 @@ public class ComponentProcessor {
|
||||
private Map<String, IPropertyValidator> propertyValidatorCache;
|
||||
private Map<String, ComponentType> componentTypeMap;
|
||||
|
||||
private Cloner cloner;
|
||||
|
||||
public static ComponentProcessor getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ComponentProcessor();
|
||||
@@ -52,13 +49,13 @@ public class ComponentProcessor {
|
||||
|
||||
private ComponentProcessor() {
|
||||
super();
|
||||
this.cloner = new Cloner();
|
||||
this.propertyCache = new HashMap<String, List<PropertyWrapper>>();
|
||||
this.componentTypeMap = new HashMap<String, ComponentType>();
|
||||
this.propertyValidatorCache = new HashMap<String, IPropertyValidator>();
|
||||
}
|
||||
|
||||
public ComponentType extractComponentTypeFrom(Class<? extends IDIYComponent<?>> clazz) {
|
||||
public ComponentType extractComponentTypeFrom(
|
||||
Class<? extends IDIYComponent<?>> clazz) {
|
||||
if (componentTypeMap.containsKey(clazz.getName())) {
|
||||
return componentTypeMap.get(clazz.getName());
|
||||
}
|
||||
@@ -70,10 +67,12 @@ public class ComponentProcessor {
|
||||
String author;
|
||||
Icon icon;
|
||||
double zOrder;
|
||||
boolean flexibleZOrder;
|
||||
boolean stretchable;
|
||||
BomPolicy bomPolicy;
|
||||
if (clazz.isAnnotationPresent(ComponentDescriptor.class)) {
|
||||
ComponentDescriptor annotation = clazz.getAnnotation(ComponentDescriptor.class);
|
||||
ComponentDescriptor annotation = clazz
|
||||
.getAnnotation(ComponentDescriptor.class);
|
||||
name = annotation.name();
|
||||
description = annotation.description();
|
||||
creationMethod = annotation.creationMethod();
|
||||
@@ -81,6 +80,7 @@ public class ComponentProcessor {
|
||||
namePrefix = annotation.instanceNamePrefix();
|
||||
author = annotation.author();
|
||||
zOrder = annotation.zOrder();
|
||||
flexibleZOrder = annotation.flexibleZOrder();
|
||||
stretchable = annotation.stretchable();
|
||||
bomPolicy = annotation.bomPolicy();
|
||||
} else {
|
||||
@@ -91,28 +91,30 @@ public class ComponentProcessor {
|
||||
namePrefix = "Unknown";
|
||||
author = "Unknown";
|
||||
zOrder = IDIYComponent.COMPONENT;
|
||||
flexibleZOrder = false;
|
||||
stretchable = true;
|
||||
bomPolicy = BomPolicy.SHOW_ALL_NAMES;
|
||||
}
|
||||
icon = null;
|
||||
// Draw component icon.
|
||||
try {
|
||||
IDIYComponent<?> componentInstance = (IDIYComponent<?>) clazz.newInstance();
|
||||
Image image = new BufferedImage(Presenter.ICON_SIZE, Presenter.ICON_SIZE,
|
||||
IDIYComponent<?> componentInstance = (IDIYComponent<?>) clazz
|
||||
.newInstance();
|
||||
Image image = new BufferedImage(Presenter.ICON_SIZE,
|
||||
Presenter.ICON_SIZE,
|
||||
java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = (Graphics2D) image.getGraphics();
|
||||
g2d
|
||||
.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
componentInstance.drawIcon(g2d, Presenter.ICON_SIZE, Presenter.ICON_SIZE);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
componentInstance.drawIcon(g2d, Presenter.ICON_SIZE,
|
||||
Presenter.ICON_SIZE);
|
||||
icon = new ImageIcon(image);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
ComponentType componentType = new ComponentType(name, description, creationMethod,
|
||||
category, namePrefix, author, icon, clazz, zOrder, stretchable, bomPolicy);
|
||||
ComponentType componentType = new ComponentType(name, description,
|
||||
creationMethod, category, namePrefix, author, icon, clazz,
|
||||
zOrder, flexibleZOrder, stretchable, bomPolicy);
|
||||
componentTypeMap.put(clazz.getName(), componentType);
|
||||
return componentType;
|
||||
}
|
||||
@@ -125,7 +127,7 @@ public class ComponentProcessor {
|
||||
*/
|
||||
public List<PropertyWrapper> extractProperties(Class<?> clazz) {
|
||||
if (propertyCache.containsKey(clazz.getName())) {
|
||||
return cloner.deepClone(propertyCache.get(clazz.getName()));
|
||||
return cloneProperties(propertyCache.get(clazz.getName()));
|
||||
}
|
||||
List<PropertyWrapper> properties = new ArrayList<PropertyWrapper>();
|
||||
for (Method method : clazz.getMethods()) {
|
||||
@@ -133,7 +135,8 @@ public class ComponentProcessor {
|
||||
try {
|
||||
if (method.isAnnotationPresent(EditableProperty.class)
|
||||
&& !method.isAnnotationPresent(Deprecated.class)) {
|
||||
EditableProperty annotation = method.getAnnotation(EditableProperty.class);
|
||||
EditableProperty annotation = method
|
||||
.getAnnotation(EditableProperty.class);
|
||||
String name;
|
||||
if (annotation.name().equals("")) {
|
||||
name = method.getName().substring(3);
|
||||
@@ -142,22 +145,36 @@ public class ComponentProcessor {
|
||||
}
|
||||
IPropertyValidator validator = getPropertyValidator(annotation
|
||||
.validatorClass());
|
||||
Method setter = clazz.getMethod("set" + method.getName().substring(3),
|
||||
method.getReturnType());
|
||||
Method setter = clazz.getMethod("set"
|
||||
+ method.getName().substring(3), method
|
||||
.getReturnType());
|
||||
PropertyWrapper property = new PropertyWrapper(name,
|
||||
method.getReturnType(), method.getName(), setter.getName(),
|
||||
annotation.defaultable(), validator);
|
||||
method.getReturnType(), method.getName(),
|
||||
setter.getName(), annotation.defaultable(),
|
||||
validator);
|
||||
properties.add(property);
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
LOG.debug("No matching setter found for \"" + method.getName()
|
||||
+ "\". Skipping...");
|
||||
LOG.debug("No matching setter found for \""
|
||||
+ method.getName() + "\". Skipping...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
propertyCache.put(clazz.getName(), properties);
|
||||
return cloner.deepClone(properties);
|
||||
return cloneProperties(properties);
|
||||
}
|
||||
|
||||
private List<PropertyWrapper> cloneProperties(List<PropertyWrapper> properties) {
|
||||
List<PropertyWrapper> result = new ArrayList<PropertyWrapper>(properties.size());
|
||||
for (PropertyWrapper propertyWrapper : properties) {
|
||||
try {
|
||||
result.add((PropertyWrapper) propertyWrapper.clone());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +198,8 @@ public class ComponentProcessor {
|
||||
}
|
||||
for (int i = 1; i < selectedComponents.size(); i++) {
|
||||
IDIYComponent<?> component = selectedComponents.get(i);
|
||||
List<PropertyWrapper> newProperties = extractProperties(component.getClass());
|
||||
List<PropertyWrapper> newProperties = extractProperties(component
|
||||
.getClass());
|
||||
for (PropertyWrapper property : newProperties) {
|
||||
property.readFrom(component);
|
||||
}
|
||||
@@ -190,11 +208,14 @@ public class ComponentProcessor {
|
||||
// their values match.
|
||||
for (PropertyWrapper oldProperty : properties) {
|
||||
if (newProperties.contains(oldProperty)) {
|
||||
PropertyWrapper newProperty = newProperties.get(newProperties
|
||||
.indexOf(oldProperty));
|
||||
if ((newProperty.getValue() != null && newProperty.getValue() == null)
|
||||
|| !newProperty.getValue().equals(oldProperty.getValue())) {
|
||||
// Values don't match, so the property is not unique valued.
|
||||
PropertyWrapper newProperty = newProperties
|
||||
.get(newProperties.indexOf(oldProperty));
|
||||
if ((newProperty.getValue() != null && newProperty
|
||||
.getValue() == null)
|
||||
|| !newProperty.getValue().equals(
|
||||
oldProperty.getValue())) {
|
||||
// Values don't match, so the property is not unique
|
||||
// valued.
|
||||
oldProperty.setUnique(false);
|
||||
}
|
||||
}
|
||||
@@ -208,11 +229,13 @@ public class ComponentProcessor {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Collections.sort(properties, ComparatorFactory.getInstance().getPropertyNameComparator());
|
||||
Collections.sort(properties, ComparatorFactory.getInstance()
|
||||
.getPropertyNameComparator());
|
||||
return properties;
|
||||
}
|
||||
|
||||
private IPropertyValidator getPropertyValidator(Class<? extends IPropertyValidator> clazz) {
|
||||
private IPropertyValidator getPropertyValidator(
|
||||
Class<? extends IPropertyValidator> clazz) {
|
||||
if (propertyValidatorCache.containsKey(clazz.getName())) {
|
||||
return propertyValidatorCache.get(clazz.getName());
|
||||
}
|
||||
@@ -220,7 +243,8 @@ public class ComponentProcessor {
|
||||
try {
|
||||
validator = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not instantiate validator for " + clazz.getName(), e);
|
||||
LOG.error("Could not instantiate validator for " + clazz.getName(),
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
propertyValidatorCache.put(clazz.getName(), validator);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ import org.diylc.core.Theme;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
|
||||
/**
|
||||
* The main presenter class, contains core app logic and drawing routines.
|
||||
*
|
||||
@@ -58,8 +56,8 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Presenter.class);
|
||||
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3, 9,
|
||||
0);
|
||||
public static final VersionNumber CURRENT_VERSION = new VersionNumber(3,
|
||||
11, 0);
|
||||
public static final String DEFAULTS_KEY_PREFIX = "default.";
|
||||
|
||||
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections
|
||||
@@ -79,7 +77,7 @@ public class Presenter implements IPlugInPort {
|
||||
private Set<IDIYComponent<?>> lockedComponents;
|
||||
|
||||
// Utilities
|
||||
private Cloner cloner;
|
||||
// private Cloner cloner;
|
||||
private DrawingManager drawingManager;
|
||||
private ProjectFileManager projectFileManager;
|
||||
private InstantiationManager instantiationManager;
|
||||
@@ -109,7 +107,7 @@ public class Presenter implements IPlugInPort {
|
||||
selectedComponents = new ArrayList<IDIYComponent<?>>();
|
||||
lockedComponents = new HashSet<IDIYComponent<?>>();
|
||||
currentProject = new Project();
|
||||
cloner = new Cloner();
|
||||
// cloner = new Cloner();
|
||||
drawingManager = new DrawingManager(messageDispatcher);
|
||||
projectFileManager = new ProjectFileManager(messageDispatcher);
|
||||
instantiationManager = new InstantiationManager();
|
||||
@@ -412,7 +410,7 @@ public class Presenter implements IPlugInPort {
|
||||
// Keep the reference to component type for later.
|
||||
ComponentType componentTypeSlot = instantiationManager
|
||||
.getComponentTypeSlot();
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
switch (componentTypeSlot.getCreationMethod()) {
|
||||
case SINGLE_CLICK:
|
||||
try {
|
||||
@@ -505,8 +503,8 @@ public class Presenter implements IPlugInPort {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(
|
||||
EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||
.deepClone(currentProject), "Add "
|
||||
EventType.PROJECT_MODIFIED, oldProject,
|
||||
currentProject.clone(), "Add "
|
||||
+ componentTypeSlot.getName());
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
@@ -612,10 +610,10 @@ public class Presenter implements IPlugInPort {
|
||||
return false;
|
||||
}
|
||||
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
moveSelectedComponents(controlPointMap, dx, dy, snapToGrid);
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Move Selection");
|
||||
oldProject, currentProject.clone(), "Move Selection");
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
return true;
|
||||
}
|
||||
@@ -760,7 +758,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
this.dragInProgress = true;
|
||||
this.dragAction = dragAction;
|
||||
this.preDragProject = cloner.deepClone(currentProject);
|
||||
this.preDragProject = currentProject.clone();
|
||||
Point scaledPoint = scalePoint(point);
|
||||
this.previousDragPoint = scaledPoint;
|
||||
List<IDIYComponent<?>> components = findComponentsAtScaled(scaledPoint);
|
||||
@@ -1067,7 +1065,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
if (!preDragProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
preDragProject, cloner.deepClone(currentProject), "Drag");
|
||||
preDragProject, currentProject.clone(), "Drag");
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
@@ -1077,7 +1075,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void pasteComponents(List<IDIYComponent<?>> components) {
|
||||
LOG.info(String.format("addComponents(%s)", components));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
for (IDIYComponent<?> component : components) {
|
||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||
Point point = new Point(component.getControlPoint(i));
|
||||
@@ -1096,7 +1094,7 @@ public class Presenter implements IPlugInPort {
|
||||
.getClass()), false);
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Add");
|
||||
oldProject, currentProject.clone(), "Add");
|
||||
projectFileManager.notifyFileChange();
|
||||
updateSelection(new ArrayList<IDIYComponent<?>>(components));
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
@@ -1109,7 +1107,7 @@ public class Presenter implements IPlugInPort {
|
||||
LOG.debug("Nothing to delete");
|
||||
return;
|
||||
}
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
// Remove selected components from any groups.
|
||||
ungroupComponents(selectedComponents);
|
||||
// Remove from area map.
|
||||
@@ -1118,7 +1116,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
currentProject.getComponents().removeAll(selectedComponents);
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Delete");
|
||||
oldProject, currentProject.clone(), "Delete");
|
||||
projectFileManager.notifyFileChange();
|
||||
updateSelection(EMPTY_SELECTION);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
@@ -1160,7 +1158,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void groupSelectedComponents() {
|
||||
LOG.info("groupSelectedComponents()");
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
// First remove the selected components from other groups.
|
||||
ungroupComponents(selectedComponents);
|
||||
// Then group them together.
|
||||
@@ -1170,7 +1168,7 @@ public class Presenter implements IPlugInPort {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Group");
|
||||
oldProject, currentProject.clone(), "Group");
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
}
|
||||
@@ -1178,13 +1176,13 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void ungroupSelectedComponents() {
|
||||
LOG.info("ungroupSelectedComponents()");
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
ungroupComponents(selectedComponents);
|
||||
// Notify the listeners.
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject), "Ungroup");
|
||||
oldProject, currentProject.clone(), "Ungroup");
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
}
|
||||
@@ -1206,7 +1204,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void sendSelectionToBack() {
|
||||
LOG.info("sendSelectionToBack()");
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
for (IDIYComponent<?> component : selectedComponents) {
|
||||
ComponentType componentType = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom(
|
||||
@@ -1225,8 +1223,9 @@ public class Presenter implements IPlugInPort {
|
||||
.extractComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) componentBefore
|
||||
.getClass());
|
||||
if (componentBeforeType.getZOrder() < componentType
|
||||
.getZOrder())
|
||||
if (!componentType.isFlexibleZOrder()
|
||||
&& componentBeforeType.getZOrder() < componentType
|
||||
.getZOrder())
|
||||
break;
|
||||
Collections.swap(currentProject.getComponents(), index,
|
||||
index - 1);
|
||||
@@ -1235,8 +1234,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject),
|
||||
"Send to Back");
|
||||
oldProject, currentProject.clone(), "Send to Back");
|
||||
projectFileManager.notifyFileChange();
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
@@ -1245,7 +1243,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void bringSelectionToFront() {
|
||||
LOG.info("bringSelectionToFront()");
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
for (IDIYComponent<?> component : selectedComponents) {
|
||||
ComponentType componentType = ComponentProcessor.getInstance()
|
||||
.extractComponentTypeFrom(
|
||||
@@ -1264,8 +1262,9 @@ public class Presenter implements IPlugInPort {
|
||||
.extractComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) componentAfter
|
||||
.getClass());
|
||||
if (componentAfterType.getZOrder() > componentType
|
||||
.getZOrder())
|
||||
if (!componentType.isFlexibleZOrder()
|
||||
&& componentAfterType.getZOrder() > componentType
|
||||
.getZOrder())
|
||||
break;
|
||||
Collections.swap(currentProject.getComponents(), index,
|
||||
index + 1);
|
||||
@@ -1274,8 +1273,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject),
|
||||
"Bring to Front");
|
||||
oldProject, currentProject.clone(), "Bring to Front");
|
||||
projectFileManager.notifyFileChange();
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
@@ -1303,7 +1301,7 @@ public class Presenter implements IPlugInPort {
|
||||
if (getSelectedComponents().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
List<IDIYComponent<?>> components = new ArrayList<IDIYComponent<?>>(
|
||||
getSelectedComponents());
|
||||
// Sort components by their location.
|
||||
@@ -1369,8 +1367,7 @@ public class Presenter implements IPlugInPort {
|
||||
}
|
||||
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject),
|
||||
"Renumber selection");
|
||||
oldProject, currentProject.clone(), "Renumber selection");
|
||||
projectFileManager.notifyFileChange();
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
@@ -1538,15 +1535,15 @@ public class Presenter implements IPlugInPort {
|
||||
*/
|
||||
private void addComponent(IDIYComponent<?> component,
|
||||
ComponentType componentType, boolean canCreatePads) {
|
||||
int index = 0;
|
||||
while (index < currentProject.getComponents().size()
|
||||
&& componentType.getZOrder() >= ComponentProcessor
|
||||
int index = currentProject.getComponents().size();
|
||||
while (index > 0
|
||||
&& componentType.getZOrder() < ComponentProcessor
|
||||
.getInstance()
|
||||
.extractComponentTypeFrom(
|
||||
(Class<? extends IDIYComponent<?>>) currentProject
|
||||
.getComponents().get(index).getClass())
|
||||
.getComponents().get(index - 1).getClass())
|
||||
.getZOrder()) {
|
||||
index++;
|
||||
index--;
|
||||
}
|
||||
if (index < currentProject.getComponents().size()) {
|
||||
currentProject.getComponents().add(index, component);
|
||||
@@ -1593,7 +1590,7 @@ public class Presenter implements IPlugInPort {
|
||||
|
||||
private void applyPropertiesToSelection(List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyPropertiesToSelection(%s)", properties));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
try {
|
||||
for (IDIYComponent<?> component : selectedComponents) {
|
||||
drawingManager.invalidateComponent(component);
|
||||
@@ -1613,8 +1610,7 @@ public class Presenter implements IPlugInPort {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject),
|
||||
"Edit Selection");
|
||||
oldProject, currentProject.clone(), "Edit Selection");
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
@@ -1641,7 +1637,7 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void applyPropertiesToProject(List<PropertyWrapper> properties) {
|
||||
LOG.debug(String.format("applyPropertiesToProject(%s)", properties));
|
||||
Project oldProject = cloner.deepClone(currentProject);
|
||||
Project oldProject = currentProject.clone();
|
||||
try {
|
||||
for (PropertyWrapper property : properties) {
|
||||
property.writeTo(currentProject);
|
||||
@@ -1656,8 +1652,7 @@ public class Presenter implements IPlugInPort {
|
||||
// Notify the listeners.
|
||||
if (!oldProject.equals(currentProject)) {
|
||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED,
|
||||
oldProject, cloner.deepClone(currentProject),
|
||||
"Edit Project");
|
||||
oldProject, currentProject.clone(), "Edit Project");
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
drawingManager.fireZoomChanged();
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Mock", author = "bancika", category = "Sample", instanceNamePrefix = "M", description = "test", zOrder = IDIYComponent.COMPONENT)
|
||||
public class MockDIYComponent implements IDIYComponent<Capacitance> {
|
||||
public class MockDIYComponent extends AbstractComponent<Capacitance> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/app-framework"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -20,7 +20,7 @@ import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
|
||||
@ComponentDescriptor(name = "Image", author = "Branislav Stojkovic", category = "Misc", description = "User defined image", instanceNamePrefix = "Img", zOrder = IDIYComponent.TEXT, stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
|
||||
@ComponentDescriptor(name = "Image", author = "Branislav Stojkovic", category = "Misc", description = "User defined image", instanceNamePrefix = "Img", zOrder = IDIYComponent.COMPONENT, flexibleZOrder = true, stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
|
||||
public class Image extends AbstractTransparentComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
|
||||
@ComponentDescriptor(name = "Label", author = "Branislav Stojkovic", category = "Misc", description = "User defined label", instanceNamePrefix = "L", zOrder = IDIYComponent.TEXT, stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
|
||||
@ComponentDescriptor(name = "Label", author = "Branislav Stojkovic", category = "Misc", description = "User defined label", instanceNamePrefix = "L", zOrder = IDIYComponent.TEXT, flexibleZOrder = true, stretchable = false, bomPolicy = BomPolicy.NEVER_SHOW)
|
||||
public class Label extends AbstractComponent<Void> {
|
||||
|
||||
public static String DEFAULT_TEXT = "Double click to edit text";
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/iText-2.1.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/cloning-1.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/objenesis-1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/poi-3.5-FINAL-20090928.jar"/>
|
||||
<classpathentry kind="lib" path="library/main.jar" sourcepath="/diylc-library"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/diylc-core"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/swing-framework.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/app-framework"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/swing-framework"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
|
||||
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;Library&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;DIYLC&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""C:\Documents and Settings\bancika\My Documents\deacy.diy""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms256m -Xmx512m -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugComponentAreas=true"/>
|
||||
</launchConfiguration>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-Xms512m -Xmx1024m -Dorg.diylc.scriptRun=true
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
java -Xms512m -Xmx2048m -Dorg.diylc.scriptRun=true -cp diylc.jar:lib org.diylc.DIYLCStarter
|
||||
@@ -4,6 +4,7 @@ import java.io.FileInputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -26,6 +27,8 @@ public class DIYLCStarter {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(DIYLCStarter.class);
|
||||
|
||||
private static final String SCRIPT_RUN = "org.diylc.scriptRun";
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
@@ -52,6 +55,21 @@ public class DIYLCStarter {
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not set Look&Feel", e);
|
||||
}
|
||||
|
||||
String val = System.getProperty(SCRIPT_RUN);
|
||||
if (!"true".equals(val)) {
|
||||
int response = JOptionPane
|
||||
.showConfirmDialog(
|
||||
null,
|
||||
"It is not recommended to run DIYLC by clicking on the diylc.jar file.\n" +
|
||||
"Please use diylc.exe on Windows or run.sh on OSX/Linux to ensure the best\n" +
|
||||
"performance and reliability. Do you want to continue?",
|
||||
"DIYLC", JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
if (response != JOptionPane.YES_OPTION) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
MainFrame mainFrame = new MainFrame();
|
||||
mainFrame.setLocationRelativeTo(null);
|
||||
@@ -69,7 +87,7 @@ public class DIYLCStarter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
properties = new Properties();
|
||||
try {
|
||||
LOG.info("Injecting default properties.");
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.print.PrinterException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
@@ -31,14 +32,11 @@ import org.diylc.swingframework.IDrawingProvider;
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
import org.diylc.utils.BomEntry;
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
|
||||
public class ActionFactory {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ActionFactory.class);
|
||||
|
||||
private static ActionFactory instance;
|
||||
private static Cloner cloner = new Cloner();
|
||||
|
||||
public static ActionFactory getInstance() {
|
||||
if (instance == null) {
|
||||
@@ -64,7 +62,8 @@ public class ActionFactory {
|
||||
return new SaveAction(plugInPort, swingUI);
|
||||
}
|
||||
|
||||
public SaveAsAction createSaveAsAction(IPlugInPort plugInPort, ISwingUI swingUI) {
|
||||
public SaveAsAction createSaveAsAction(IPlugInPort plugInPort,
|
||||
ISwingUI swingUI) {
|
||||
return new SaveAsAction(plugInPort, swingUI);
|
||||
}
|
||||
|
||||
@@ -72,11 +71,13 @@ public class ActionFactory {
|
||||
return new CreateBomAction(plugInPort);
|
||||
}
|
||||
|
||||
public ExportPDFAction createExportPDFAction(IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
public ExportPDFAction createExportPDFAction(
|
||||
IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
return new ExportPDFAction(drawingProvider, swingUI);
|
||||
}
|
||||
|
||||
public ExportPNGAction createExportPNGAction(IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
public ExportPNGAction createExportPNGAction(
|
||||
IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
return new ExportPNGAction(drawingProvider, swingUI);
|
||||
}
|
||||
|
||||
@@ -90,17 +91,18 @@ public class ActionFactory {
|
||||
|
||||
// Edit menu actions.
|
||||
|
||||
public CutAction createCutAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
public CutAction createCutAction(IPlugInPort plugInPort,
|
||||
Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
return new CutAction(plugInPort, clipboard, clipboardOwner);
|
||||
}
|
||||
|
||||
public CopyAction createCopyAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
public CopyAction createCopyAction(IPlugInPort plugInPort,
|
||||
Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
return new CopyAction(plugInPort, clipboard, clipboardOwner);
|
||||
}
|
||||
|
||||
public PasteAction createPasteAction(IPlugInPort plugInPort, Clipboard clipboard) {
|
||||
public PasteAction createPasteAction(IPlugInPort plugInPort,
|
||||
Clipboard clipboard) {
|
||||
return new PasteAction(plugInPort, clipboard);
|
||||
}
|
||||
|
||||
@@ -124,12 +126,13 @@ public class ActionFactory {
|
||||
return new EditSelectionAction(plugInPort);
|
||||
}
|
||||
|
||||
public DeleteSelectionAction createDeleteSelectionAction(IPlugInPort plugInPort) {
|
||||
public DeleteSelectionAction createDeleteSelectionAction(
|
||||
IPlugInPort plugInPort) {
|
||||
return new DeleteSelectionAction(plugInPort);
|
||||
}
|
||||
|
||||
public ExpandSelectionAction createExpandSelectionAction(IPlugInPort plugInPort,
|
||||
ExpansionMode expansionMode) {
|
||||
public ExpandSelectionAction createExpandSelectionAction(
|
||||
IPlugInPort plugInPort, ExpansionMode expansionMode) {
|
||||
return new ExpandSelectionAction(plugInPort, expansionMode);
|
||||
}
|
||||
|
||||
@@ -143,8 +146,8 @@ public class ActionFactory {
|
||||
|
||||
// Config actions.
|
||||
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue) {
|
||||
public ConfigAction createConfigAction(IPlugInPort plugInPort,
|
||||
String title, String configKey, boolean defaultValue) {
|
||||
return new ConfigAction(plugInPort, title, configKey, defaultValue);
|
||||
}
|
||||
|
||||
@@ -152,7 +155,8 @@ public class ActionFactory {
|
||||
return new ThemeAction(plugInPort, theme);
|
||||
}
|
||||
|
||||
public RenumberAction createRenumberAction(IPlugInPort plugInPort, boolean xAxisFirst) {
|
||||
public RenumberAction createRenumberAction(IPlugInPort plugInPort,
|
||||
boolean xAxisFirst) {
|
||||
return new RenumberAction(plugInPort, xAxisFirst);
|
||||
}
|
||||
|
||||
@@ -168,9 +172,10 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "New");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_N,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentPlainYellow.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_N, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentPlainYellow
|
||||
.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,9 +185,10 @@ public class ActionFactory {
|
||||
return;
|
||||
}
|
||||
plugInPort.createNewProject();
|
||||
List<PropertyWrapper> properties = plugInPort.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(
|
||||
properties, "Edit Project");
|
||||
List<PropertyWrapper> properties = plugInPort
|
||||
.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance()
|
||||
.createPropertyEditorDialog(properties, "Edit Project");
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyPropertiesToProject(properties);
|
||||
@@ -190,8 +196,8 @@ public class ActionFactory {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property
|
||||
.getValue());
|
||||
plugInPort.setProjectDefaultPropertyValue(property
|
||||
.getName(), property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,8 +215,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Open");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.FolderOut.getIcon());
|
||||
}
|
||||
|
||||
@@ -221,8 +227,8 @@ public class ActionFactory {
|
||||
return;
|
||||
}
|
||||
final File file = DialogFactory.getInstance().showOpenDialog(
|
||||
FileFilterEnum.DIY.getFilter(), null, FileFilterEnum.DIY.getExtensions()[0],
|
||||
null);
|
||||
FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -239,7 +245,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not open file. " + e.getMessage(), "Error",
|
||||
swingUI.showMessage("Could not open file. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -259,8 +266,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Save");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DiskBlue.getIcon());
|
||||
}
|
||||
|
||||
@@ -277,7 +284,8 @@ public class ActionFactory {
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
LOG.debug("Saving to " + file.getAbsolutePath());
|
||||
plugInPort.saveProjectToFile(file.getAbsolutePath(), false);
|
||||
plugInPort.saveProjectToFile(
|
||||
file.getAbsolutePath(), false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -287,8 +295,9 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(),
|
||||
"Error", ISwingUI.ERROR_MESSAGE);
|
||||
swingUI.showMessage("Could not save to file. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -297,8 +306,10 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
LOG.debug("Saving to " + plugInPort.getCurrentFileName());
|
||||
plugInPort.saveProjectToFile(plugInPort.getCurrentFileName(), false);
|
||||
LOG.debug("Saving to "
|
||||
+ plugInPort.getCurrentFileName());
|
||||
plugInPort.saveProjectToFile(plugInPort
|
||||
.getCurrentFileName(), false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -308,7 +319,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||
swingUI.showMessage("Could not save to file. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -328,8 +340,9 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
putValue(AbstractAction.NAME, "Save As");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S,
|
||||
ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_S, ActionEvent.CTRL_MASK
|
||||
| ActionEvent.SHIFT_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DiskBlue.getIcon());
|
||||
}
|
||||
|
||||
@@ -337,15 +350,16 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("SaveAsAction triggered");
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.DIY.getFilter(), null, FileFilterEnum.DIY.getExtensions()[0],
|
||||
null);
|
||||
FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@Override
|
||||
public Void doInBackground() throws Exception {
|
||||
LOG.debug("Saving to " + file.getAbsolutePath());
|
||||
plugInPort.saveProjectToFile(file.getAbsolutePath(), false);
|
||||
plugInPort.saveProjectToFile(file.getAbsolutePath(),
|
||||
false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -355,7 +369,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||
swingUI.showMessage("Could not save to file. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -379,8 +394,8 @@ public class ActionFactory {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("CreateBomAction triggered");
|
||||
List<BomEntry> bom = org.diylc.utils.BomMaker.getInstance().createBom(
|
||||
plugInPort.getCurrentProject().getComponents());
|
||||
List<BomEntry> bom = org.diylc.utils.BomMaker.getInstance()
|
||||
.createBom(plugInPort.getCurrentProject().getComponents());
|
||||
BomDialog dialog = DialogFactory.getInstance().createBomDialog(bom);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
@@ -393,7 +408,8 @@ public class ActionFactory {
|
||||
private IDrawingProvider drawingProvider;
|
||||
private ISwingUI swingUI;
|
||||
|
||||
public ExportPDFAction(IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
public ExportPDFAction(IDrawingProvider drawingProvider,
|
||||
ISwingUI swingUI) {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
this.swingUI = swingUI;
|
||||
@@ -405,8 +421,8 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("ExportPDFAction triggered");
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.PDF.getFilter(), null, FileFilterEnum.PDF.getExtensions()[0],
|
||||
null);
|
||||
FileFilterEnum.PDF.getFilter(), null,
|
||||
FileFilterEnum.PDF.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -424,7 +440,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export to PDF. " + e.getMessage(), "Error",
|
||||
swingUI.showMessage("Could not export to PDF. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -439,7 +456,8 @@ public class ActionFactory {
|
||||
private IDrawingProvider drawingProvider;
|
||||
private ISwingUI swingUI;
|
||||
|
||||
public ExportPNGAction(IDrawingProvider drawingProvider, ISwingUI swingUI) {
|
||||
public ExportPNGAction(IDrawingProvider drawingProvider,
|
||||
ISwingUI swingUI) {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
this.swingUI = swingUI;
|
||||
@@ -451,8 +469,8 @@ public class ActionFactory {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("ExportPNGAction triggered");
|
||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
||||
FileFilterEnum.PNG.getFilter(), null, FileFilterEnum.PNG.getExtensions()[0],
|
||||
null);
|
||||
FileFilterEnum.PNG.getFilter(), null,
|
||||
FileFilterEnum.PNG.getExtensions()[0], null);
|
||||
if (file != null) {
|
||||
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -470,7 +488,8 @@ public class ActionFactory {
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
swingUI.showMessage("Could not export to PNG. " + e.getMessage(), "Error",
|
||||
swingUI.showMessage("Could not export to PNG. "
|
||||
+ e.getMessage(), "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -488,8 +507,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.drawingProvider = drawingProvider;
|
||||
putValue(AbstractAction.NAME, "Print...");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_P,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_P, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Print.getIcon());
|
||||
}
|
||||
|
||||
@@ -536,22 +555,24 @@ public class ActionFactory {
|
||||
private Clipboard clipboard;
|
||||
private ClipboardOwner clipboardOwner;
|
||||
|
||||
public CutAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
public CutAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Cut");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_X, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Cut.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Cut triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloner.deepClone(plugInPort
|
||||
.getSelectedComponents())), clipboardOwner);
|
||||
clipboard.setContents(new ComponentTransferable(
|
||||
cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
plugInPort.deleteSelectedComponents();
|
||||
}
|
||||
}
|
||||
@@ -564,22 +585,24 @@ public class ActionFactory {
|
||||
private Clipboard clipboard;
|
||||
private ClipboardOwner clipboardOwner;
|
||||
|
||||
public CopyAction(IPlugInPort plugInPort, Clipboard clipboard, ClipboardOwner clipboardOwner) {
|
||||
public CopyAction(IPlugInPort plugInPort, Clipboard clipboard,
|
||||
ClipboardOwner clipboardOwner) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
this.clipboardOwner = clipboardOwner;
|
||||
putValue(AbstractAction.NAME, "Copy");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_C, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Copy.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Copy triggered");
|
||||
clipboard.setContents(new ComponentTransferable(cloner.deepClone(plugInPort
|
||||
.getSelectedComponents())), clipboardOwner);
|
||||
clipboard.setContents(new ComponentTransferable(
|
||||
cloneComponents(plugInPort.getSelectedComponents())),
|
||||
clipboardOwner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -595,8 +618,8 @@ public class ActionFactory {
|
||||
this.plugInPort = plugInPort;
|
||||
this.clipboard = clipboard;
|
||||
putValue(AbstractAction.NAME, "Paste");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_V, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Paste.getIcon());
|
||||
}
|
||||
|
||||
@@ -607,13 +630,27 @@ public class ActionFactory {
|
||||
try {
|
||||
List<IDIYComponent<?>> components = (List<IDIYComponent<?>>) clipboard
|
||||
.getData(ComponentTransferable.listFlavor);
|
||||
plugInPort.pasteComponents(cloner.deepClone(components));
|
||||
plugInPort.pasteComponents(cloneComponents(components));
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Coule not paste.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<IDIYComponent<?>> cloneComponents(
|
||||
List<IDIYComponent<?>> components) {
|
||||
List<IDIYComponent<?>> result = new ArrayList<IDIYComponent<?>>(
|
||||
components.size());
|
||||
for (IDIYComponent<?> component : components) {
|
||||
try {
|
||||
result.add(component.clone());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class SelectAllAction extends AbstractAction {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -624,8 +661,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Select All");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_A, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Selection.getIcon());
|
||||
}
|
||||
|
||||
@@ -646,8 +683,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Group Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_G,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_G, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Group.getIcon());
|
||||
}
|
||||
|
||||
@@ -668,8 +705,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Ungroup Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_U, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Ungroup.getIcon());
|
||||
}
|
||||
|
||||
@@ -690,15 +727,17 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Edit Project");
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentEdit.getIcon());
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.DocumentEdit
|
||||
.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Edit Project triggered");
|
||||
List<PropertyWrapper> properties = plugInPort.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance().createPropertyEditorDialog(
|
||||
properties, "Edit Project");
|
||||
List<PropertyWrapper> properties = plugInPort
|
||||
.getProjectProperties();
|
||||
PropertyEditorDialog editor = DialogFactory.getInstance()
|
||||
.createPropertyEditorDialog(properties, "Edit Project");
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
plugInPort.applyPropertiesToProject(properties);
|
||||
@@ -706,8 +745,8 @@ public class ActionFactory {
|
||||
// Save default values.
|
||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||
if (property.getValue() != null) {
|
||||
plugInPort.setProjectDefaultPropertyValue(property.getName(), property
|
||||
.getValue());
|
||||
plugInPort.setProjectDefaultPropertyValue(property
|
||||
.getName(), property.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,15 +762,17 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Edit Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E,
|
||||
ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.EditComponent.getIcon());
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_E, ActionEvent.CTRL_MASK));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.EditComponent
|
||||
.getIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOG.info("Edit Selection triggered");
|
||||
List<PropertyWrapper> properties = plugInPort.getMutualSelectionProperties();
|
||||
List<PropertyWrapper> properties = plugInPort
|
||||
.getMutualSelectionProperties();
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
LOG.info("Nothing to edit");
|
||||
return;
|
||||
@@ -750,7 +791,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
putValue(AbstractAction.NAME, "Delete Selection");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
|
||||
KeyEvent.VK_DELETE, 0));
|
||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Delete.getIcon());
|
||||
}
|
||||
|
||||
@@ -768,7 +810,8 @@ public class ActionFactory {
|
||||
private IPlugInPort plugInPort;
|
||||
private ExpansionMode expansionMode;
|
||||
|
||||
public ExpandSelectionAction(IPlugInPort plugInPort, ExpansionMode expansionMode) {
|
||||
public ExpandSelectionAction(IPlugInPort plugInPort,
|
||||
ExpansionMode expansionMode) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.expansionMode = expansionMode;
|
||||
@@ -842,15 +885,15 @@ public class ActionFactory {
|
||||
private IPlugInPort plugInPort;
|
||||
private String configKey;
|
||||
|
||||
public ConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||
boolean defaultValue) {
|
||||
public ConfigAction(IPlugInPort plugInPort, String title,
|
||||
String configKey, boolean defaultValue) {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.configKey = configKey;
|
||||
putValue(AbstractAction.NAME, title);
|
||||
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readBoolean(
|
||||
configKey, defaultValue));
|
||||
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager
|
||||
.getInstance().readBoolean(configKey, defaultValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -875,8 +918,8 @@ public class ActionFactory {
|
||||
this.theme = theme;
|
||||
putValue(AbstractAction.NAME, theme.getName());
|
||||
putValue(IView.RADIO_BUTTON_GROUP_KEY, "theme");
|
||||
putValue(AbstractAction.SELECTED_KEY, plugInPort.getSelectedTheme().getName().equals(
|
||||
theme.getName()));
|
||||
putValue(AbstractAction.SELECTED_KEY, plugInPort.getSelectedTheme()
|
||||
.getName().equals(theme.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -897,7 +940,8 @@ public class ActionFactory {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.xAxisFirst = xAxisFirst;
|
||||
putValue(AbstractAction.NAME, xAxisFirst ? "X Axis First" : "Y Axis First");
|
||||
putValue(AbstractAction.NAME, xAxisFirst ? "X Axis First"
|
||||
: "Y Axis First");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class MeasureEditor extends Container {
|
||||
@SuppressWarnings("unchecked")
|
||||
public MeasureEditor(final PropertyWrapper property) {
|
||||
setLayout(new BorderLayout());
|
||||
AbstractMeasure measure = ((AbstractMeasure) property.getValue());
|
||||
final AbstractMeasure measure = ((AbstractMeasure) property.getValue());
|
||||
valueField = new DoubleTextField(measure.getValue());
|
||||
oldBg = valueField.getBackground();
|
||||
valueField.addPropertyChangeListener(DoubleTextField.VALUE_PROPERTY,
|
||||
@@ -39,14 +40,28 @@ public class MeasureEditor extends Container {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
try {
|
||||
AbstractMeasure<?> newMeasure = (AbstractMeasure<?>) ((AbstractMeasure) property
|
||||
.getValue()).clone();
|
||||
newMeasure.setValue((Double) evt.getNewValue());
|
||||
Constructor ctor = measure.getClass()
|
||||
.getConstructors()[0];
|
||||
AbstractMeasure<?> oldMeasure = (AbstractMeasure<?>) property.getValue();
|
||||
AbstractMeasure<?> newMeasure = (AbstractMeasure<?>) ctor
|
||||
.newInstance((Double) evt.getNewValue(),
|
||||
oldMeasure.getUnit());
|
||||
property.setValue(newMeasure);
|
||||
property.setChanged(true);
|
||||
valueField.setBackground(oldBg);
|
||||
unitBox.setBackground(oldBg);
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -58,16 +73,30 @@ public class MeasureEditor extends Container {
|
||||
unitBox.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
try {
|
||||
AbstractMeasure<Enum<? extends Unit>> newMeasure = (AbstractMeasure<Enum<? extends Unit>>) ((AbstractMeasure) property
|
||||
.getValue()).clone();
|
||||
newMeasure.setUnit((Enum<? extends Unit>) unitBox.getSelectedItem());
|
||||
Constructor ctor = measure.getClass().getConstructors()[0];
|
||||
AbstractMeasure<?> oldMeasure = (AbstractMeasure<?>) property.getValue();
|
||||
AbstractMeasure<?> newMeasure = (AbstractMeasure<?>) ctor
|
||||
.newInstance(oldMeasure.getValue(),
|
||||
(Enum<? extends Unit>) unitBox
|
||||
.getSelectedItem());
|
||||
property.setValue(newMeasure);
|
||||
property.setChanged(true);
|
||||
valueField.setBackground(oldBg);
|
||||
unitBox.setBackground(oldBg);
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -94,17 +123,17 @@ public class MeasureEditor extends Container {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
this.valueField.requestFocus();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean requestFocusInWindow() {
|
||||
return this.valueField.requestFocusInWindow();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void addKeyListener(KeyListener l) {
|
||||
this.valueField.addKeyListener(l);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AutoSavePlugin implements IPlugIn {
|
||||
|
||||
public AutoSavePlugin(IView view) {
|
||||
this.view = view;
|
||||
executor = Executors.newSingleThreadExecutor();
|
||||
executor = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,17 +66,18 @@ public class AutoSavePlugin implements IPlugIn {
|
||||
@Override
|
||||
public void processMessage(EventType eventType, Object... params) {
|
||||
if (eventType == EventType.PROJECT_MODIFIED) {
|
||||
executor.execute(new Runnable() {
|
||||
if (System.currentTimeMillis() - lastSave > autoSaveFrequency) {
|
||||
executor.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
|
||||
if (System.currentTimeMillis() - lastSave > autoSaveFrequency) {
|
||||
lastSave = System.currentTimeMillis();
|
||||
plugInPort.saveProjectToFile(AUTO_SAVE_FILE_NAME, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,5 +677,45 @@
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>10</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2012-08-20 20:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Improved overall performance</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Should be more stable under OSX and not crash unexpectedly</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
<org.diylc.appframework.update.Version>
|
||||
<versionNumber>
|
||||
<major>3</major>
|
||||
<minor>11</minor>
|
||||
<build>0</build>
|
||||
</versionNumber>
|
||||
<releaseDate>2012-08-20 21:00:00.000 CET</releaseDate>
|
||||
<name></name>
|
||||
<changes>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Some components (like Image) can be placed in any layer using Send to Back/Bring to Front</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Replaced deep cloning library with manual implementation</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
</a>
|
||||
</java.util.Arrays_-ArrayList>
|
||||
Reference in New Issue
Block a user