Fix blocks, add tests, fix bounding box calc of some components

This commit is contained in:
Bane Stojkovic
2022-03-18 09:23:03 +01:00
parent d513cb2667
commit bf89b07cea
81 changed files with 41887 additions and 6426 deletions
@@ -97,9 +97,6 @@ import org.diylc.swingframework.TextDialog;
import org.diylc.swingframework.export.DrawingExporter;
import org.diylc.utils.BomEntry;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class ActionFactory {
private static final Logger LOG = Logger.getLogger(ActionFactory.class);
@@ -967,10 +964,8 @@ public class ActionFactory {
LOG.debug("Exporting variants to " + file.getAbsolutePath());
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
XStream xStream = new XStream(new DomDriver());
ProjectFileManager.configure(xStream);
xStream.toXML(variantPkg, out);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
ProjectFileManager.xStreamSerializer.toXML(variantPkg, out);
out.close();
LOG.info("Exported variants succesfully");
} catch (IOException e) {
@@ -1124,10 +1119,8 @@ public class ActionFactory {
LOG.debug("Exporting variants to " + file.getAbsolutePath());
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
XStream xStream = new XStream(new DomDriver());
ProjectFileManager.configure(xStream);
xStream.toXML(variantPkg, out);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
ProjectFileManager.xStreamSerializer.toXML(variantPkg, out);
out.close();
LOG.info("Exported building blocks succesfully");
} catch (IOException e) {
@@ -122,7 +122,7 @@ public class MainFrame extends JFrame implements ISwingUI {
IConfigurationManager configManager = ConfigurationManager.getInstance();
this.presenter = new Presenter(this, configManager);
this.presenter = new Presenter(this, configManager, true);
presenter.installPlugin(() -> new ToolBox(this));
presenter.installPlugin(() -> new FileMenuPlugin(this));
@@ -21,33 +21,29 @@
*/
package org.diylc.swing.plugins.file;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
import java.util.EnumSet;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
import java.util.EnumSet;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.core.Project;
import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.DummyView;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.core.Project;
import org.diylc.presenter.Presenter;
import org.diylc.serialization.ProjectFileManager;
import org.diylc.swing.gui.DummyView;
import org.diylc.swingframework.IFileChooserAccessory;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
/**
* {@link JComponent} that shows preview of the selected project in {@link JFileChooser}. It's
* hooked onto {@link JFileChooser} as {@link PropertyChangeListener} and refreshes when file is
@@ -60,7 +56,6 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
private static final long serialVersionUID = 1L;
private IPlugInPort presenter;
private XStream xStream;
private Project emptyProject;
private RenderComponent renderComponent;
private JLabel nameLabel;
@@ -70,7 +65,6 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
setPreferredSize(new Dimension(140, 128));
presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
xStream = new XStream(new DomDriver());
emptyProject = new Project();
emptyProject.setTitle("");
@@ -97,7 +91,7 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
File selectedFile = (File) evt.getNewValue();
try {
FileInputStream in = new FileInputStream(selectedFile);
selectedProject = (Project) xStream.fromXML(in);
selectedProject = (Project) ProjectFileManager.xStreamSerializer.fromXML(in);
in.close();
} catch (Exception e) {
}