mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-07 20:34:55 +10:00
Compare commits
1 Commits
v5.9.0
...
test/spring
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e20f61946 |
+20
-20
@@ -1,20 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
|
||||
<classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.19.jar"/>
|
||||
<classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gerber-writer-api-1.0.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/app-framework.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
|
||||
<classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
|
||||
<classpathentry kind="lib" path="lib/xstream-1.4.19.jar"/>
|
||||
<classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/>
|
||||
<classpathentry kind="lib" path="lib/gerber-writer-api-1.0.0.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-parent</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>diylc-core</artifactId>
|
||||
<!-- No need to specify version - it inherits from parent -->
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Common dependencies from Maven Central -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.jms</groupId>
|
||||
<artifactId>jms</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jdmk</groupId>
|
||||
<artifactId>jmxtools</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jmx</groupId>
|
||||
<artifactId>jmxri</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.4.0-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.10.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Local dependencies from lib folder -->
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>app-framework</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>gerber-writer-api-1.0.0</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>java-http-proxy</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>6.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>6.1.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.diylc.config;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.EventType;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@Configuration
|
||||
public class DIYLCConfig {
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public IConfigurationManager configurationManager() {
|
||||
return ConfigurationManager.getInstance();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public MessageDispatcher<EventType> messageDispatcher() {
|
||||
return new MessageDispatcher<>(true);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public DrawingService drawingService(
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
IConfigurationManager configManager) {
|
||||
return new DrawingManager(messageDispatcher, configManager);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public ProjectFileService projectFileService(MessageDispatcher<EventType> messageDispatcher) {
|
||||
return new ProjectFileManager(messageDispatcher);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public InstantiationService instantiationService() {
|
||||
return new InstantiationManager();
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public VariantService variantService(
|
||||
IConfigurationManager configManager,
|
||||
ProjectFileService projectFileService) {
|
||||
return new VariantManager(configManager, projectFileService.getXStream());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BuildingBlockService buildingBlockService(
|
||||
IConfigurationManager configManager,
|
||||
ProjectFileService projectFileService,
|
||||
InstantiationService instantiationService) {
|
||||
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public Presenter presenter(
|
||||
@Lazy
|
||||
IView view,
|
||||
IConfigurationManager configManager,
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
DrawingService drawingService,
|
||||
ProjectFileService projectFileService,
|
||||
InstantiationService instantiationService,
|
||||
VariantService variantService,
|
||||
BuildingBlockService buildingBlockService) {
|
||||
return new Presenter(
|
||||
view,
|
||||
configManager,
|
||||
messageDispatcher,
|
||||
drawingService,
|
||||
projectFileService,
|
||||
instantiationService,
|
||||
variantService,
|
||||
buildingBlockService,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.diylc.config;
|
||||
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class DummyViewDIYLCConfig {
|
||||
|
||||
@Bean
|
||||
public IConfigurationManager dummyViewConfigManager() {
|
||||
return InMemoryConfigurationManager.getInstance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageDispatcher<EventType> dummyViewMessageDispatcher() {
|
||||
return new MessageDispatcher<>(true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DrawingService dummyViewDrawingService(
|
||||
@Qualifier("dummyViewMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("dummyViewConfigManager")
|
||||
IConfigurationManager configManager) {
|
||||
return new DrawingManager(messageDispatcher, configManager);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ProjectFileService dummyViewProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
|
||||
return new ProjectFileManager(messageDispatcher);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public InstantiationService dummyViewInstantiationService() {
|
||||
return new InstantiationManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public VariantService dummyViewVariantService(
|
||||
@Qualifier("dummyViewConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("dummyViewProjectFileService")
|
||||
ProjectFileService projectFileService) {
|
||||
return new VariantManager(configManager, projectFileService.getXStream());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BuildingBlockService dummyViewBuildingBlockService(
|
||||
@Qualifier("dummyViewConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("dummyViewProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("dummyViewInstantiationService")
|
||||
InstantiationService instantiationService) {
|
||||
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Presenter dummyViewPresenter(
|
||||
@Qualifier("dummyView")
|
||||
IView view,
|
||||
@Qualifier("dummyViewConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("dummyViewMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("dummyViewDrawingService")
|
||||
DrawingService drawingService,
|
||||
@Qualifier("dummyViewProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("dummyViewInstantiationService")
|
||||
InstantiationService instantiationService,
|
||||
@Qualifier("dummyViewVariantService")
|
||||
VariantService variantService,
|
||||
@Qualifier("dummyViewBuildingBlockService")
|
||||
BuildingBlockService buildingBlockService) {
|
||||
return new Presenter(
|
||||
view,
|
||||
configManager,
|
||||
messageDispatcher,
|
||||
drawingService,
|
||||
projectFileService,
|
||||
instantiationService,
|
||||
variantService,
|
||||
buildingBlockService,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.diylc.config;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@Configuration
|
||||
public class ImportFileDIYLCConfig {
|
||||
|
||||
@Bean
|
||||
public IConfigurationManager importFileConfigManager() {
|
||||
return InMemoryConfigurationManager.getInstance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageDispatcher<EventType> importFileMessageDispatcher() {
|
||||
return new MessageDispatcher<>(true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DrawingService importFileDrawingService(
|
||||
@Qualifier("importFileMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("importFileConfigManager")
|
||||
IConfigurationManager configManager) {
|
||||
return new DrawingManager(messageDispatcher, configManager);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ProjectFileService importFileProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
|
||||
return new ProjectFileManager(messageDispatcher);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public InstantiationService importFileInstantiationService() {
|
||||
return new InstantiationManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public VariantService importFileVariantService(
|
||||
@Qualifier("importFileConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("importFileProjectFileService")
|
||||
ProjectFileService projectFileService) {
|
||||
return new VariantManager(configManager, projectFileService.getXStream());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BuildingBlockService importFileBuildingBlockService(
|
||||
@Qualifier("importFileConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("importFileProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("importFileInstantiationService")
|
||||
InstantiationService instantiationService) {
|
||||
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Presenter importFilePresenter(
|
||||
@Qualifier("importFileView")
|
||||
IView view,
|
||||
@Qualifier("importFileConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("importFileMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("importFileDrawingService")
|
||||
DrawingService drawingService,
|
||||
@Qualifier("importFileProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("importFileInstantiationService")
|
||||
InstantiationService instantiationService,
|
||||
@Qualifier("importFileVariantService")
|
||||
VariantService variantService,
|
||||
@Qualifier("importFileBuildingBlockService")
|
||||
BuildingBlockService buildingBlockService) {
|
||||
return new Presenter(
|
||||
view,
|
||||
configManager,
|
||||
messageDispatcher,
|
||||
drawingService,
|
||||
projectFileService,
|
||||
instantiationService,
|
||||
variantService,
|
||||
buildingBlockService,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.diylc.config;
|
||||
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class LoadlineDIYLCConfig {
|
||||
|
||||
@Bean
|
||||
public IConfigurationManager loadlineConfigManager() {
|
||||
return InMemoryConfigurationManager.getInstance();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageDispatcher<EventType> loadlineMessageDispatcher() {
|
||||
return new MessageDispatcher<>(true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DrawingService loadlineDrawingService(
|
||||
@Qualifier("loadlineMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("loadlineConfigManager")
|
||||
IConfigurationManager configManager) {
|
||||
return new DrawingManager(messageDispatcher, configManager);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ProjectFileService loadlineProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
|
||||
return new ProjectFileManager(messageDispatcher);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public InstantiationService loadlineInstantiationService() {
|
||||
return new InstantiationManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public VariantService loadlineVariantService(
|
||||
@Qualifier("loadlineConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("loadlineProjectFileService")
|
||||
ProjectFileService projectFileService) {
|
||||
return new VariantManager(configManager, projectFileService.getXStream());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BuildingBlockService loadlineBuildingBlockService(
|
||||
@Qualifier("loadlineConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("loadlineProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("loadlineInstantiationService")
|
||||
InstantiationService instantiationService) {
|
||||
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Presenter loadlinePresenter(
|
||||
@Qualifier("loadlineView")
|
||||
IView view,
|
||||
@Qualifier("loadlineConfigManager")
|
||||
IConfigurationManager configManager,
|
||||
@Qualifier("loadlineMessageDispatcher")
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
@Qualifier("loadlineDrawingService")
|
||||
DrawingService drawingService,
|
||||
@Qualifier("loadlineProjectFileService")
|
||||
ProjectFileService projectFileService,
|
||||
@Qualifier("loadlineInstantiationService")
|
||||
InstantiationService instantiationService,
|
||||
@Qualifier("loadlineVariantService")
|
||||
VariantService variantService,
|
||||
@Qualifier("loadlineBuildingBlockService")
|
||||
BuildingBlockService buildingBlockService) {
|
||||
return new Presenter(
|
||||
view,
|
||||
configManager,
|
||||
messageDispatcher,
|
||||
drawingService,
|
||||
projectFileService,
|
||||
instantiationService,
|
||||
variantService,
|
||||
buildingBlockService,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.diylc.common;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public abstract class AbstractPlugin implements IPlugIn {
|
||||
|
||||
protected IPlugInPort plugInPort;
|
||||
|
||||
@Override
|
||||
public void connect(IPlugInPort plugInPort) {
|
||||
this.plugInPort = plugInPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract EnumSet<EventType> getSubscribedEventTypes();
|
||||
|
||||
@Override
|
||||
public abstract void processMessage(EventType eventType, Object... params);
|
||||
}
|
||||
@@ -42,7 +42,18 @@ import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/BuildingBlockManager.java
|
||||
public class BuildingBlockManager {
|
||||
=======
|
||||
import org.diylc.common.BuildingBlockPackage;
|
||||
import org.diylc.common.IBlockProcessor;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.IBlockProcessor.InvalidBlockException;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
|
||||
public class BuildingBlockManager implements BuildingBlockService {
|
||||
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/BuildingBlockManager.java
|
||||
|
||||
private static final String BLOCKS_FILE_NAME = "blocks.xml";
|
||||
|
||||
@@ -50,10 +61,10 @@ public class BuildingBlockManager {
|
||||
|
||||
private IConfigurationManager<?> configManager;
|
||||
private XStream xStream;
|
||||
private InstantiationManager instantiationManager;
|
||||
private InstantiationService instantiationManager;
|
||||
|
||||
public BuildingBlockManager(IConfigurationManager<?> configManager, XStream xStream,
|
||||
InstantiationManager instantiationManager) {
|
||||
InstantiationService instantiationManager) {
|
||||
super();
|
||||
this.configManager = configManager;
|
||||
this.xStream = xStream;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.common.IBlockProcessor;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
|
||||
public interface BuildingBlockService {
|
||||
// Core block operations
|
||||
void saveSelectionAsBlock(String blockName, Collection<IDIYComponent<?>> selectedComponents,
|
||||
List<IDIYComponent<?>> allComponents);
|
||||
List<IDIYComponent<?>> loadBlock(String blockName, List<IDIYComponent<?>> existingComponents)
|
||||
throws IBlockProcessor.InvalidBlockException;
|
||||
void deleteBlock(String blockName);
|
||||
|
||||
// Import/Export
|
||||
void importDefaultBlocks();
|
||||
int importBlocks(String fileName) throws IOException;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ import org.diylc.utils.Constants;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class DrawingManager {
|
||||
public class DrawingManager implements DrawingService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(DrawingManager.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IComponentFilter;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Theme;
|
||||
|
||||
public interface DrawingService {
|
||||
// Core drawing methods
|
||||
List<IDIYComponent<?>> drawProject(Graphics2D g2d, Project project,
|
||||
Set<DrawOption> drawOptions, IComponentFilter filter, Rectangle selectionRect,
|
||||
Collection<IDIYComponent<?>> selectedComponents, Set<IDIYComponent<?>> lockedComponents,
|
||||
Set<IDIYComponent<?>> groupedComponents, List<Point2D> controlPointSlot,
|
||||
List<IDIYComponent<?>> componentSlot, boolean dragInProgress, Double externalZoom,
|
||||
Double scaleFactor, Rectangle2D visibleRect);
|
||||
|
||||
// Component area handling
|
||||
ComponentArea getComponentArea(IDIYComponent<?> component);
|
||||
void clearComponentAreaMap();
|
||||
List<IDIYComponent<?>> findComponentsAt(Point2D point, Project project);
|
||||
void invalidateComponent(IDIYComponent<?> component);
|
||||
|
||||
// Continuity area handling
|
||||
void clearContinuityArea();
|
||||
List<ContinuityArea> getContinuityAreas();
|
||||
List<Area> getContinuityAreaProximity(float threshold);
|
||||
void findContinuityAreaAtPoint(Point2D point);
|
||||
|
||||
// Theme handling
|
||||
Theme getTheme();
|
||||
void setTheme(Theme theme);
|
||||
|
||||
// Zoom control
|
||||
double getZoomLevel();
|
||||
void setZoomLevel(double zoomLevel);
|
||||
void fireZoomChanged();
|
||||
|
||||
// Canvas dimensions
|
||||
Dimension getCanvasDimensions(Project project, Double zoomLevel,
|
||||
boolean includeExtraSpace);
|
||||
double getExtraSpace(Project project);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ import org.diylc.core.measures.Size;
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class InstantiationManager {
|
||||
public class InstantiationManager implements InstantiationService{
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(InstantiationManager.class);
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
import org.diylc.clipboard.ComponentTransferable;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.Template;
|
||||
import org.diylc.core.measures.Size;
|
||||
|
||||
public interface InstantiationService {
|
||||
// Component type slot management
|
||||
ComponentType getComponentTypeSlot();
|
||||
Template getTemplate();
|
||||
String[] getModel();
|
||||
List<IDIYComponent<?>> getComponentSlot();
|
||||
void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, String[] model,
|
||||
Project currentProject, boolean forceInstantiate) throws Exception;
|
||||
|
||||
// Point-by-point creation
|
||||
Point2D getFirstControlPoint();
|
||||
Point2D getPotentialControlPoint();
|
||||
void setPotentialControlPoint(Point2D potentialControlPoint);
|
||||
void instatiatePointByPoint(Point2D scaledPoint, Project currentProject) throws Exception;
|
||||
boolean updatePointByPoint(Point2D scaledPoint);
|
||||
boolean updateSingleClick(Point2D point, boolean snapToGrid, Size gridSpacing);
|
||||
|
||||
// Component operations
|
||||
void pasteComponents(ComponentTransferable componentTransferable, Point2D scaledPoint,
|
||||
boolean snapToGrid, Size gridSpacing, boolean autoGroup, Project currentProject,
|
||||
boolean assignNewNames);
|
||||
String createUniqueName(ComponentType componentType, List<IDIYComponent<?>> components);
|
||||
void fillWithDefaultProperties(Object object, Template template);
|
||||
void loadComponentShapeFromTemplate(IDIYComponent<?> component, Template template);
|
||||
void tryToRotateComponentSlot();
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.JarScanner;
|
||||
@@ -90,15 +91,27 @@ import org.diylc.test.DIYTest;
|
||||
import org.diylc.test.Snapshot;
|
||||
import org.diylc.utils.Constants;
|
||||
import org.diylc.utils.ReflectionUtils;
|
||||
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/Presenter.java
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
=======
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static org.reflections.scanners.Scanners.TypesAnnotated;
|
||||
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java
|
||||
|
||||
/**
|
||||
* The main presenter class, contains core app logic and drawing routines.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
@Component
|
||||
public class Presenter implements IPlugInPort, IConfigListener {
|
||||
|
||||
private static final String REACHED_BOTTOM =
|
||||
@@ -165,7 +178,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
private Map<String, List<ComponentType>> componentTypes;
|
||||
|
||||
// Maps component class names to ComponentType objects.
|
||||
private List<IPlugIn> plugIns;
|
||||
private List<IPlugIn> plugIns = new ArrayList<>();
|
||||
|
||||
private Set<IDIYComponent<?>> selectedComponents;
|
||||
// Maps components that have at least one dragged point to set of indices
|
||||
@@ -175,11 +188,11 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
|
||||
// Utilities
|
||||
// private Cloner cloner;
|
||||
private DrawingManager drawingManager;
|
||||
private ProjectFileManager projectFileManager;
|
||||
private InstantiationManager instantiationManager;
|
||||
private VariantManager variantManager;
|
||||
private BuildingBlockManager buildingBlockManager;
|
||||
private DrawingService drawingManager;
|
||||
private ProjectFileService projectFileManager;
|
||||
private InstantiationService instantiationManager;
|
||||
private VariantService variantManager;
|
||||
private BuildingBlockService buildingBlockManager;
|
||||
|
||||
private Rectangle selectionRect;
|
||||
|
||||
@@ -202,6 +215,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
|
||||
private DIYTest test = null;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/Presenter.java
|
||||
public Presenter(IView view, IConfigurationManager<?> configManager) {
|
||||
this(view, configManager, false);
|
||||
}
|
||||
@@ -221,6 +235,28 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
||||
instantiationManager = new InstantiationManager();
|
||||
variantManager = new VariantManager(configManager, projectFileManager.getXStream());
|
||||
buildingBlockManager = new BuildingBlockManager(configManager, projectFileManager.getXStream(), instantiationManager);
|
||||
=======
|
||||
@Autowired
|
||||
public Presenter(
|
||||
@Lazy
|
||||
IView view,
|
||||
IConfigurationManager configManager,
|
||||
MessageDispatcher<EventType> messageDispatcher,
|
||||
DrawingService drawingService,
|
||||
ProjectFileService projectFileService,
|
||||
InstantiationService instantiationService,
|
||||
VariantService variantService,
|
||||
BuildingBlockService buildingBlockService,
|
||||
boolean importVariantsAndBlocks) {
|
||||
this.view = view;
|
||||
this.configManager = configManager;
|
||||
this.messageDispatcher = messageDispatcher;
|
||||
this.drawingManager = drawingService;
|
||||
this.projectFileManager = projectFileService;
|
||||
this.instantiationManager = instantiationService;
|
||||
this.variantManager = variantService;
|
||||
this.buildingBlockManager = buildingBlockService;
|
||||
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java
|
||||
|
||||
// lockedLayers = EnumSet.noneOf(ComponentLayer.class);
|
||||
// visibleLayers = EnumSet.allOf(ComponentLayer.class);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.xml.sax.SAXException;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.test.DIYTest;
|
||||
|
||||
public interface ProjectFileService {
|
||||
// Project operations
|
||||
void serializeProjectToFile(Project project, String fileName, boolean isBackup) throws IOException;
|
||||
Project deserializeProjectFromFile(String fileName, List<String> warnings)
|
||||
throws SAXException, IOException, ParserConfigurationException;
|
||||
|
||||
// Test operations
|
||||
void serializeTestToFile(DIYTest test, String fileName) throws IOException;
|
||||
DIYTest deserializeTestFromFile(String fileName)
|
||||
throws SAXException, IOException, ParserConfigurationException;
|
||||
|
||||
// File status
|
||||
void startNewFile();
|
||||
void notifyFileChange();
|
||||
String getCurrentFileName();
|
||||
boolean isModified();
|
||||
void fireFileStatusChanged();
|
||||
|
||||
// Serialization
|
||||
XStream getXStream();
|
||||
}
|
||||
@@ -41,7 +41,7 @@ import org.diylc.core.Template;
|
||||
import org.diylc.serialization.ProjectFileManager;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
public class VariantManager {
|
||||
public class VariantManager implements VariantService {
|
||||
|
||||
private static final String VARIANTS_FILE_NAME = "variants.xml";
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.core.Template;
|
||||
|
||||
public interface VariantService {
|
||||
void importDefaultVariants();
|
||||
void upgradeVariants(Map<String, List<ComponentType>> componentTypes);
|
||||
List<Template> getVariantsFor(ComponentType type);
|
||||
int importVariants(String fileName) throws IOException;
|
||||
String getDefaultVariant(ComponentType type);
|
||||
void deleteVariant(ComponentType type, String templateName);
|
||||
}
|
||||
@@ -43,10 +43,14 @@ import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/serialization/ProjectFileManager.java
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.test.DIYTest;
|
||||
=======
|
||||
import org.diylc.presenter.ProjectFileService;
|
||||
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -56,6 +60,7 @@ import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import com.thoughtworks.xstream.mapper.MapperWrapper;
|
||||
import com.thoughtworks.xstream.security.AnyTypePermission;
|
||||
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/serialization/ProjectFileManager.java
|
||||
|
||||
public class ProjectFileManager {
|
||||
|
||||
@@ -64,6 +69,21 @@ public class ProjectFileManager {
|
||||
private XStream xStream;
|
||||
// Legacy deserializer for 3.0.1 through 3.0.7, loads Points referenced in
|
||||
// pixels.
|
||||
=======
|
||||
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.test.DIYTest;
|
||||
|
||||
public class ProjectFileManager implements ProjectFileService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ProjectFileManager.class);
|
||||
|
||||
private XStream xStream;
|
||||
// Legacy deserializer for 3.0.1 through 3.0.7, loads Points referenced in
|
||||
// pixels.
|
||||
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java
|
||||
private XStream xStreamOld;
|
||||
|
||||
public static final XStream xStreamSerializer = new XStream(new DomDriver("UTF-8"));
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//appimage/setup_wsl_appimage.bat=UTF-8
|
||||
encoding//lang/Deutsch.txt=UTF-8
|
||||
encoding//src/org/diylc/swing/gui/CollapsiblePanel.java=UTF-8
|
||||
encoding/lang=UTF-8
|
||||
encoding/<project>=ISO-8859-1
|
||||
|
||||
@@ -0,0 +1,559 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-parent</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>diylc-swing</artifactId>
|
||||
<!-- No need to specify version - it inherits from parent -->
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Internal module dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc</groupId>
|
||||
<artifactId>diylc-library</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Common dependencies from Maven Central -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.jms</groupId>
|
||||
<artifactId>jms</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jdmk</groupId>
|
||||
<artifactId>jmxtools</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jmx</groupId>
|
||||
<artifactId>jmxri</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.5-FINAL</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.4.0-jre</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.27</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orsonpdf</groupId>
|
||||
<artifactId>orsonpdf</artifactId>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>janino</artifactId>
|
||||
<version>3.1.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>commons-compiler</artifactId>
|
||||
<version>3.1.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.balloontip</groupId>
|
||||
<artifactId>balloontip</artifactId>
|
||||
<version>1.2.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.guigarage</groupId>
|
||||
<artifactId>gestures-wrapper</artifactId>
|
||||
<version>0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.36</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Local dependencies from lib folder -->
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>app-framework</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>gerber-writer-api-1.0.0</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>java-http-proxy</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>jep-2.4.1</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>svgSalamander-1.1.2.4</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.diylc.local</groupId>
|
||||
<artifactId>swing-framework</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<finalName>diylc</finalName>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>org.diylc.DIYLCStarter</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>universal-zip</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>deploy/universal-zip.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<configuration>
|
||||
<finalName>diylc-${project.version}</finalName>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
</configuration>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>linux-appimage</id>
|
||||
<properties>
|
||||
<appdir.dir>${project.build.directory}/AppDir</appdir.dir>
|
||||
<jdk.version>17.0.14+7</jdk.version>
|
||||
<jdk.version.file>17.0.14_7</jdk.version.file>
|
||||
<jdk.archive.linux>OpenJDK17U-jre_x64_linux_hotspot_${jdk.version.file}.tar.gz</jdk.archive.linux>
|
||||
<jdk.url.linux>https://github.com/adoptium/temurin17-binaries/releases/download/jdk-${jdk.version}/${jdk.archive.linux}</jdk.url.linux>
|
||||
<jre.dest.linux>${project.build.directory}/jre-temp</jre.dest.linux>
|
||||
<appdir.jre>${appdir.dir}/usr/bin/jre</appdir.jre>
|
||||
<wsl.command>wsl bash -c</wsl.command>
|
||||
<appimage.output.file>DIYLayoutCreator-${project.version}-x86_64.AppImage</appimage.output.file>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Create AppDir structure and copy files -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-appdir</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<!-- Create directory structure -->
|
||||
<mkdir dir="${appdir.dir}/usr/bin" />
|
||||
<mkdir dir="${appdir.dir}/usr/lib" />
|
||||
<mkdir dir="${appdir.dir}/usr/share/icons/hicolor/512x512/apps" />
|
||||
<mkdir dir="${appdir.dir}/usr/share/metainfo" />
|
||||
|
||||
<!-- Copy app files -->
|
||||
<copy file="${project.build.directory}/diylc.jar" todir="${appdir.dir}/usr/lib" />
|
||||
|
||||
<!-- Copy AppImage specific files -->
|
||||
<copy file="${project.basedir}/deploy/linux/appimage/diylc.sh" tofile="${appdir.dir}/usr/bin/diylc.sh" />
|
||||
<copy file="${project.basedir}/deploy/linux/appimage/AppRun" tofile="${appdir.dir}/AppRun" />
|
||||
<chmod file="${appdir.dir}/AppRun" perm="755" />
|
||||
<chmod file="${appdir.dir}/usr/bin/diylc.sh" perm="755" />
|
||||
|
||||
<!-- Copy icons and desktop files -->
|
||||
<copy file="${project.basedir}/src/main/resources/icons/icon_512x512.png"
|
||||
tofile="${appdir.dir}/usr/share/icons/hicolor/512x512/apps/com.diy_fever.DIYLayoutCreator.png" />
|
||||
<copy file="${project.basedir}/src/main/resources/icons/icon_512x512.png"
|
||||
tofile="${appdir.dir}/com.diy_fever.DIYLayoutCreator.png" />
|
||||
<copy file="${project.basedir}/deploy/linux/appimage/com.diy_fever.DIYLayoutCreator.desktop"
|
||||
todir="${appdir.dir}" />
|
||||
<copy file="${project.basedir}/deploy/linux/appimage/com.diy_fever.DIYLayoutCreator.metainfo.xml"
|
||||
todir="${appdir.dir}/usr/share/metainfo" />
|
||||
|
||||
<!-- Download and extract JRE for Linux -->
|
||||
<!-- Ensure clean jre folders -->
|
||||
<delete dir="${jre.dest.linux}" />
|
||||
<mkdir dir="${jre.dest.linux}" />
|
||||
<mkdir dir="${project.build.directory}/downloads" />
|
||||
|
||||
<!-- Download JRE 17 if not already present -->
|
||||
<get src="${jdk.url.linux}"
|
||||
dest="${project.build.directory}/downloads/${jdk.archive.linux}"
|
||||
usetimestamp="true" />
|
||||
|
||||
<!-- Extract JRE -->
|
||||
<untar src="${project.build.directory}/downloads/${jdk.archive.linux}"
|
||||
dest="${jre.dest.linux}"
|
||||
compression="gzip" />
|
||||
|
||||
<!-- Move extracted folder into AppImage location -->
|
||||
<mkdir dir="${appdir.jre}" />
|
||||
<move todir="${appdir.jre}">
|
||||
<fileset dir="${jre.dest.linux}/jdk-${jdk.version}-jre" />
|
||||
</move>
|
||||
|
||||
<!-- Clean up temporary directory -->
|
||||
<delete dir="${jre.dest.linux}" />
|
||||
|
||||
<echo message="JRE 17 bundled into ${appdir.jre}" />
|
||||
|
||||
<!-- Convert line endings to Unix format -->
|
||||
<fixcrlf file="${appdir.dir}/com.diy_fever.DIYLayoutCreator.desktop" eol="unix" />
|
||||
<fixcrlf file="${appdir.dir}/AppRun" eol="unix" />
|
||||
<fixcrlf file="${appdir.dir}/usr/bin/diylc.sh" eol="unix" />
|
||||
|
||||
<echo message="AppDir structure created successfully at: ${appdir.dir}" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<!-- Build AppImage -->
|
||||
<execution>
|
||||
<id>build-appimage</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<echo message="Starting AppImage build process..." />
|
||||
|
||||
<!-- Detect operating system -->
|
||||
<condition property="isWindows">
|
||||
<os family="windows" />
|
||||
</condition>
|
||||
|
||||
<condition property="isMac">
|
||||
<os family="mac" />
|
||||
</condition>
|
||||
|
||||
<condition property="isLinux">
|
||||
<and>
|
||||
<os family="unix" />
|
||||
<not>
|
||||
<os family="mac" />
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<echo message="Detected OS: ${os.name}" />
|
||||
|
||||
<!-- Windows-specific build -->
|
||||
<echo message="Windows build will execute: ${isWindows}" />
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c echo Building AppImage using Windows with WSL..." />
|
||||
</exec>
|
||||
|
||||
<!-- Check if WSL is available -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c where wsl" />
|
||||
</exec>
|
||||
|
||||
<!-- Set WSL command -->
|
||||
<property name="wsl.command" value="wsl bash -c" />
|
||||
|
||||
<!-- Check if WSL has a Linux distribution installed -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c wsl -l" />
|
||||
</exec>
|
||||
|
||||
<!-- Copy AppDir to WSL /tmp directory -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c wsl cp -r "$(wslpath -u '${appdir.dir}')" /tmp/AppDir" />
|
||||
</exec>
|
||||
|
||||
<!-- Convert line endings to Unix format in WSL -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "sed -i 's/\r$//' /tmp/AppDir/com.diy_fever.DIYLayoutCreator.desktop"" />
|
||||
</exec>
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "sed -i 's/\r$//' /tmp/AppDir/AppRun"" />
|
||||
</exec>
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "sed -i 's/\r$//' /tmp/AppDir/usr/bin/diylc.sh"" />
|
||||
</exec>
|
||||
|
||||
<!-- Setup WSL with required dependencies -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c echo Setting up WSL with required dependencies..." />
|
||||
</exec>
|
||||
|
||||
<!-- Install necessary Linux dependencies inside WSL -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "sudo apt update && sudo apt install -y wget libfuse2 fuse"" />
|
||||
</exec>
|
||||
|
||||
<!-- Download AppImageTool into WSL if not already present -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "if [ ! -f ~/appimagetool ]; then wget -O ~/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage && chmod +x ~/appimagetool; fi"" />
|
||||
</exec>
|
||||
|
||||
<!-- Build AppImage using appimagetool in WSL -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c ${wsl.command} "cd /tmp && ~/appimagetool /tmp/AppDir /tmp/${appimage.output.file}"" />
|
||||
</exec>
|
||||
|
||||
<!-- Copy the AppImage back to the build directory -->
|
||||
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
|
||||
<arg line="/c wsl bash -c "cp /tmp/${appimage.output.file} $(wslpath -u '${project.build.directory}/${appimage.output.file}')"" />
|
||||
</exec>
|
||||
|
||||
<!-- macOS-specific build -->
|
||||
<echo message="Mac build will execute: ${isMac}" />
|
||||
<exec executable="bash" failonerror="true" osfamily="mac">
|
||||
<arg line="-c 'echo Building AppImage using macOS with Docker...'" />
|
||||
</exec>
|
||||
|
||||
<!-- Check if Docker is available -->
|
||||
<exec executable="docker" resultproperty="docker.result" failifexecutionfails="false" osfamily="mac">
|
||||
<arg line="--version" />
|
||||
</exec>
|
||||
|
||||
<!-- Create a temporary directory for Docker volume mapping -->
|
||||
<mkdir dir="${project.build.directory}/docker-tmp" />
|
||||
|
||||
<!-- Copy AppDir to the Docker volume directory -->
|
||||
<copy todir="${project.build.directory}/docker-tmp/AppDir">
|
||||
<fileset dir="${appdir.dir}" />
|
||||
</copy>
|
||||
|
||||
<!-- Run AppImageTool in Docker -->
|
||||
<exec executable="docker" failonerror="true" osfamily="mac">
|
||||
<arg line="run --rm -v "${project.build.directory}/docker-tmp:/workspace" -w /workspace appimagecrafters/appimage-builder:latest /bin/bash -c "ARCH=x86_64 appimagetool AppDir ${appimage.output.file}"" />
|
||||
</exec>
|
||||
|
||||
<!-- Copy the AppImage to the build directory -->
|
||||
<copy file="${project.build.directory}/docker-tmp/${appimage.output.file}" todir="${project.build.directory}" />
|
||||
|
||||
<!-- Clean up temporary directory -->
|
||||
<delete dir="${project.build.directory}/docker-tmp" />
|
||||
|
||||
<!-- <!– Linux-specific build –>-->
|
||||
<!-- <echo message="Linux build will execute: ${isLinux}" />-->
|
||||
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
|
||||
<!-- <arg line="-c 'echo Building AppImage natively on Linux...'" />-->
|
||||
<!-- </exec>-->
|
||||
<!-- -->
|
||||
<!-- <!– Install dependencies if needed –>-->
|
||||
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
|
||||
<!-- <arg line="-c 'which appimagetool || (echo "Installing appimagetool..." && sudo apt-get update && sudo apt-get install -y libfuse2 fuse && wget -O /tmp/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage && chmod +x /tmp/appimagetool && sudo mv /tmp/appimagetool /usr/local/bin/)'" />-->
|
||||
<!-- </exec>-->
|
||||
<!-- -->
|
||||
<!-- <!– Build AppImage –>-->
|
||||
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
|
||||
<!-- <arg line="-c 'appimagetool ${appdir.dir} ${project.build.directory}/${appimage.output.file}'" />-->
|
||||
<!-- </exec>-->
|
||||
|
||||
<!-- Create zip package -->
|
||||
<zip destfile="${project.build.directory}/diylc-${project.version}-linux.zip">
|
||||
<zipfileset file="${project.build.directory}/${appimage.output.file}"
|
||||
filemode="755" />
|
||||
</zip>
|
||||
|
||||
<echo message="AppImage build completed successfully! Output: ${project.build.directory}/${appimage.output.file}" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!-- Windows InnoSetup build profile using Docker -->
|
||||
<profile>
|
||||
<id>win64-installer</id>
|
||||
<properties>
|
||||
<jdk.version>17.0.14+7</jdk.version>
|
||||
<jdk.version.file>17.0.14_7</jdk.version.file>
|
||||
<jdk.archive.win64>OpenJDK17U-jre_x64_windows_hotspot_${jdk.version.file}.zip</jdk.archive.win64>
|
||||
<jdk.url.win64>https://github.com/adoptium/temurin17-binaries/releases/download/jdk-${jdk.version}/${jdk.archive.win64}</jdk.url.win64>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Download and extract JRE -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>download-extract-jre</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<!-- Clean old jre_win folder -->
|
||||
<delete dir="${project.build.directory}/jre_win" />
|
||||
|
||||
<!-- Create folder to hold extracted JRE -->
|
||||
<mkdir dir="${project.build.directory}/jre_win" />
|
||||
|
||||
<!-- Download JRE 64-bit for Windows -->
|
||||
<mkdir dir="${project.build.directory}/downloads" />
|
||||
<get src="${jdk.url.win64}"
|
||||
dest="${project.build.directory}/downloads/${jdk.archive.win64}"
|
||||
usetimestamp="true" />
|
||||
|
||||
<!-- Extract JRE into jre_win -->
|
||||
<unzip src="${project.build.directory}/downloads/${jdk.archive.win64}"
|
||||
dest="${project.build.directory}/jre_win" />
|
||||
|
||||
<!-- Move files up one level -->
|
||||
<move todir="${project.build.directory}/jre_win">
|
||||
<fileset dir="${project.build.directory}/jre_win/jdk-${jdk.version}-jre" />
|
||||
</move>
|
||||
|
||||
<!-- Remove empty top-level folder -->
|
||||
<delete dir="${project.build.directory}/jre_win/jdk-${jdk.version}-jre" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Run InnoSetup -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build-windows-installer</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>docker</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>--rm</argument>
|
||||
<argument>-v</argument>
|
||||
<argument>${project.basedir}:/workspace</argument>
|
||||
<argument>amake/innosetup</argument>
|
||||
<argument>/Ddiylcver=${project.version}</argument>
|
||||
<argument>/Darch=x64</argument>
|
||||
<argument>/workspace/deploy/win/install.iss</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -31,6 +31,13 @@ import org.apache.log4j.PropertyConfigurator;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.PropertyInjector;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
|
||||
=======
|
||||
import org.diylc.config.DIYLCConfig;
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
import org.diylc.swingframework.fonts.FontOptimizer;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.lang.LangUtil;
|
||||
@@ -39,10 +46,16 @@ import org.diylc.serialization.ProjectFileManager;
|
||||
import org.diylc.swing.gui.MainFrame;
|
||||
import org.diylc.swing.gui.TemplateDialog;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
import org.diylc.swingframework.fonts.FontOptimizer;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import ca.cgjennings.jvm.JarLoader;
|
||||
=======
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java
|
||||
|
||||
/**
|
||||
* Main class that runs DIYLC.
|
||||
@@ -177,8 +190,15 @@ public class DIYLCStarter {
|
||||
|
||||
LOG.info("Creating the main frame...");
|
||||
|
||||
MainFrame mainFrame = new MainFrame();
|
||||
Presenter presenter = mainFrame.getPresenter();
|
||||
// Disable web server since this is a Swing app
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(DIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run(args);
|
||||
|
||||
// Get MainFrame from Spring context and show it
|
||||
MainFrame mainFrame = context.getBean(MainFrame.class);
|
||||
Presenter presenter = context.getBean(Presenter.class);
|
||||
|
||||
LOG.info("Main frame created.");
|
||||
// mainFrame.setLocationRelativeTo(null);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.diylc;
|
||||
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.swing.actions.file.ImportFileView;
|
||||
import org.diylc.swing.gui.DummyView;
|
||||
import org.diylc.swing.loadline.LoadlineEditorFrame;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.diylc.config.DIYLCConfig;
|
||||
import org.diylc.swing.gui.MainFrame;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.swing.plugins.PluginConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
//@Import({DIYLCConfig.class})
|
||||
public class DIYLCSwingConfig {
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public IView mainFrame(@Lazy
|
||||
Presenter presenter, IConfigurationManager configurationManager, List<IPlugIn> plugins) {
|
||||
return new MainFrame(presenter, configurationManager, plugins);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IView importFileView() {
|
||||
return new ImportFileView();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IView dummyView() {
|
||||
return new DummyView();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IView loadlineView(Presenter presenter) {
|
||||
return new LoadlineEditorFrame(presenter);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,15 @@ import java.util.Set;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.clipboard.ComponentTransferableFactory;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.config.DIYLCConfig;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
@@ -21,6 +25,9 @@ import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
public class ImportAction extends AbstractAction {
|
||||
|
||||
@@ -34,35 +41,14 @@ public class ImportAction extends AbstractAction {
|
||||
super();
|
||||
this.plugInPort = plugInPort;
|
||||
this.swingUI = swingUI;
|
||||
this.presenter = new Presenter(new IView() {
|
||||
|
||||
@Override
|
||||
public int showConfirmDialog(String message, String title, int optionType,
|
||||
int messageType) {
|
||||
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
|
||||
}
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
@Override
|
||||
public void showMessage(String message, String title, int messageType) {
|
||||
JOptionPane.showMessageDialog(null, message, title, messageType);
|
||||
}
|
||||
this.presenter = context.getBean(Presenter.class);
|
||||
|
||||
@Override
|
||||
public String showInputDialog(String message, String title) {
|
||||
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File promptFileSave() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editProperties(List<PropertyWrapper> properties,
|
||||
Set<PropertyWrapper> defaultedProperties, String title) {
|
||||
return false;
|
||||
}
|
||||
}, InMemoryConfigurationManager.getInstance());
|
||||
putValue(AbstractAction.NAME, "Import");
|
||||
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_I,
|
||||
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.diylc.swing.actions.file;
|
||||
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IView;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class ImportFileView implements IView {
|
||||
|
||||
@Override
|
||||
public int showConfirmDialog(String message, String title, int optionType,
|
||||
int messageType) {
|
||||
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(String message, String title, int messageType) {
|
||||
JOptionPane.showMessageDialog(null, message, title, messageType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String showInputDialog(String message, String title) {
|
||||
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File promptFileSave() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editProperties(List< PropertyWrapper > properties,
|
||||
Set<PropertyWrapper> defaultedProperties, String title) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,41 @@ import org.diylc.swing.plugins.toolbox.ToolBox;
|
||||
import org.diylc.swing.plugins.tree.ComponentTree;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
|
||||
=======
|
||||
import org.diylc.common.BadPositionException;
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.core.images.IconLoader;
|
||||
import org.diylc.lang.LangUtil;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.actionbar.ActionBarPlugin;
|
||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
|
||||
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
||||
import org.diylc.swing.plugins.cloud.CloudPlugIn;
|
||||
import org.diylc.swing.plugins.config.ConfigPlugin;
|
||||
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
||||
import org.diylc.swing.plugins.explorer.ExplorerPlugin;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
||||
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
||||
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
|
||||
import org.diylc.swing.plugins.statusbar.StatusBar;
|
||||
import org.diylc.swing.plugins.test.TestMenuPlugin;
|
||||
import org.diylc.swing.plugins.toolbox.ToolBox;
|
||||
import org.diylc.swing.plugins.tree.ComponentTree;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.diylc.swing.plugins.PluginFactory;
|
||||
|
||||
@Component
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
|
||||
public class MainFrame extends JFrame implements ISwingUI {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(MainFrame.class);
|
||||
@@ -100,7 +135,8 @@ public class MainFrame extends JFrame implements ISwingUI {
|
||||
private JPanel topPanel;
|
||||
private JPanel bottomPanel;
|
||||
|
||||
private Presenter presenter;
|
||||
private final Presenter presenter;
|
||||
private final IConfigurationManager configManager;
|
||||
|
||||
private JMenuBar mainMenuBar;
|
||||
private Map<String, JMenu> menuMap;
|
||||
@@ -108,26 +144,47 @@ public class MainFrame extends JFrame implements ISwingUI {
|
||||
|
||||
private CanvasPlugin canvasPlugin;
|
||||
|
||||
public MainFrame() {
|
||||
@Autowired
|
||||
public MainFrame(
|
||||
Presenter presenter,
|
||||
IConfigurationManager configManager,
|
||||
List<IPlugIn> plugins) { // Spring will inject all IPlugIn implementations
|
||||
super("DIYLC 4");
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
|
||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
=======
|
||||
this.presenter = presenter;
|
||||
this.configManager = configManager;
|
||||
|
||||
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
|
||||
setPreferredSize(new Dimension(1024, 700));
|
||||
createBasePanels();
|
||||
menuMap = new HashMap<String, JMenu>();
|
||||
buttonGroupMap = new HashMap<String, ButtonGroup>();
|
||||
setIconImages(Arrays.asList(IconLoader.IconSmall.getImage(), IconLoader.IconMedium.getImage(),
|
||||
IconLoader.IconLarge.getImage()));
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
|
||||
DialogFactory.getInstance().initialize(this);
|
||||
|
||||
IConfigurationManager<?> configManager = ConfigurationManager.getInstance();
|
||||
=======
|
||||
DialogFactory.getInstance().initialize(this);
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
|
||||
|
||||
this.presenter = new Presenter(this, configManager, true);
|
||||
for (IPlugIn plugIn : plugins) {
|
||||
presenter.installPlugin(() -> plugIn);
|
||||
}
|
||||
|
||||
presenter.installPlugin(() -> new ToolBox(this));
|
||||
// this.canvasPlugin = (CanvasPlugin) plugins.stream()
|
||||
// .filter(x -> CanvasPlugin.class.isInstance(x))
|
||||
// .findFirst().orElseThrow();
|
||||
presenter.installPlugin(() -> new ToolBox(this));
|
||||
presenter.installPlugin(() -> new FileMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new EditMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new ConfigPlugin(this));
|
||||
presenter.installPlugin(() -> new LayersMenuPlugin(this));
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
|
||||
presenter.installPlugin(() -> new CloudPlugIn(this));
|
||||
if ("true".equalsIgnoreCase(System.getProperty("org.diylc.enableTests")))
|
||||
presenter.installPlugin(() -> new TestMenuPlugin(this));
|
||||
@@ -144,6 +201,20 @@ public class MainFrame extends JFrame implements ISwingUI {
|
||||
presenter.installPlugin(() -> new FramePlugin());
|
||||
|
||||
presenter.installPlugin(() -> new AutoSavePlugin(this));
|
||||
=======
|
||||
presenter.installPlugin(() -> new CloudPlugIn(this));
|
||||
if ("true".equalsIgnoreCase(System.getProperty("org.diylc.enableTests")))
|
||||
presenter.installPlugin(() -> new TestMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new HelpMenuPlugin(this));
|
||||
presenter.installPlugin(() -> new ActionBarPlugin(this));
|
||||
|
||||
presenter.installPlugin(() -> new StatusBar(this));
|
||||
|
||||
canvasPlugin = new CanvasPlugin(this, configManager);
|
||||
presenter.installPlugin(() -> canvasPlugin);
|
||||
presenter.installPlugin(() -> new ComponentTree(this, canvasPlugin.getCanvasPanel()));
|
||||
presenter.installPlugin(() -> new ExplorerPlugin(this, canvasPlugin.getCanvasPanel()));
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
|
||||
|
||||
presenter.createNewProject();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.diylc.swing.gui;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/TemplateDialog.java
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -58,7 +59,52 @@ import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IView;
|
||||
=======
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.core.IView;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/TemplateDialog.java
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
public class TemplateDialog extends JDialog {
|
||||
|
||||
@@ -85,13 +131,13 @@ public class TemplateDialog extends JDialog {
|
||||
setModal(true);
|
||||
setResizable(false);
|
||||
this.plugInPort = plugInPort;
|
||||
this.presenter = new Presenter(new IView() {
|
||||
|
||||
@Override
|
||||
public int showConfirmDialog(String message, String title, int optionType, int messageType) {
|
||||
return JOptionPane.showConfirmDialog(TemplateDialog.this, message, title, optionType, messageType);
|
||||
}
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/TemplateDialog.java
|
||||
@Override
|
||||
public void showMessage(String message, String title, int messageType) {
|
||||
JOptionPane.showMessageDialog(TemplateDialog.this, message, title, messageType);
|
||||
@@ -101,17 +147,10 @@ public class TemplateDialog extends JDialog {
|
||||
public String showInputDialog(String message, String title) {
|
||||
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
|
||||
}
|
||||
=======
|
||||
this.presenter = context.getBean(Presenter.class);
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/TemplateDialog.java
|
||||
|
||||
@Override
|
||||
public File promptFileSave() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties, String title) {
|
||||
return false;
|
||||
}
|
||||
}, InMemoryConfigurationManager.getInstance());
|
||||
// this.presenter.installPlugin(new IPlugIn() {
|
||||
//
|
||||
// @Override
|
||||
|
||||
@@ -47,12 +47,14 @@ import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Mini toolbar with common actions
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
@Component
|
||||
public class ActionBarPlugin implements IPlugIn {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ActionBarPlugin.class);
|
||||
|
||||
@@ -32,9 +32,27 @@ import javax.swing.JTextField;
|
||||
import javax.swing.UIManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.Utils;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java
|
||||
=======
|
||||
import org.diylc.components.connectivity.Dot;
|
||||
import org.diylc.components.connectivity.Line;
|
||||
import org.diylc.components.misc.Image;
|
||||
import org.diylc.components.misc.Image.ImageSizingMode;
|
||||
import org.diylc.components.misc.Label;
|
||||
import org.diylc.components.misc.LoadlineCurve;
|
||||
import org.diylc.components.misc.LoadlineEntity;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.config.LoadlineDIYLCConfig;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
import org.diylc.swingframework.DoubleTextField;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/loadline/LoadlineEditorFrame.java
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.HorizontalAlignment;
|
||||
import org.diylc.common.IPlugIn;
|
||||
@@ -63,11 +81,19 @@ import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.plugins.canvas.CanvasPanel;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
import org.diylc.swingframework.DoubleTextField;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
=======
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/loadline/LoadlineEditorFrame.java
|
||||
|
||||
@Component
|
||||
public class LoadlineEditorFrame extends JFrame implements IView {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -94,7 +120,7 @@ public class LoadlineEditorFrame extends JFrame implements IView {
|
||||
private int xIncrement;
|
||||
private int yIncrement;
|
||||
|
||||
public LoadlineEditorFrame() {
|
||||
public LoadlineEditorFrame(Presenter plugInPort) {
|
||||
super("Loadline Editor");
|
||||
setIconImage(IconLoader.Loadline.getImage());
|
||||
setResizable(false);
|
||||
@@ -116,8 +142,9 @@ public class LoadlineEditorFrame extends JFrame implements IView {
|
||||
}
|
||||
});
|
||||
|
||||
this.plugInPort = plugInPort;
|
||||
|
||||
|
||||
this.plugInPort = new Presenter(this, configManager);
|
||||
this.plugInPort.installPlugin(() -> new IPlugIn() {
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@@ -711,7 +738,13 @@ public class LoadlineEditorFrame extends JFrame implements IView {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new LoadlineEditorFrame().setVisible(true);
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(LoadlineDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
IView view = context.getBean(IView.class);
|
||||
((LoadlineEditorFrame)view).setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.diylc.swing.plugins;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.diylc.swing.plugins")
|
||||
public class PluginConfig {
|
||||
// Plugin-specific beans can be defined here if needed
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.diylc.swing.plugins;
|
||||
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.swing.gui.*;
|
||||
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
||||
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
||||
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
||||
import org.diylc.swing.plugins.config.ConfigPlugin;
|
||||
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
|
||||
import org.diylc.swing.plugins.cloud.CloudPlugIn;
|
||||
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
||||
import org.diylc.swing.plugins.test.TestMenuPlugin;
|
||||
import org.diylc.swing.plugins.statusbar.StatusBar;
|
||||
import org.diylc.swing.plugins.tree.ComponentTree;
|
||||
import org.diylc.swing.plugins.explorer.ExplorerPlugin;
|
||||
import org.diylc.swing.plugins.toolbox.ToolBox;
|
||||
import org.diylc.swing.gui.actionbar.ActionBarPlugin;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@Component
|
||||
public class PluginFactory {
|
||||
|
||||
private final IConfigurationManager configManager;
|
||||
|
||||
@Autowired
|
||||
public PluginFactory(IConfigurationManager configManager) {
|
||||
this.configManager = configManager;
|
||||
}
|
||||
|
||||
public CanvasPlugin createCanvasPlugin(ISwingUI ui) {
|
||||
return new CanvasPlugin(ui, configManager);
|
||||
}
|
||||
|
||||
public FileMenuPlugin createFileMenuPlugin(ISwingUI ui) {
|
||||
return new FileMenuPlugin(ui);
|
||||
}
|
||||
|
||||
public EditMenuPlugin createEditMenuPlugin(ISwingUI ui) {
|
||||
return new EditMenuPlugin(ui);
|
||||
}
|
||||
|
||||
public ConfigPlugin createConfigPlugin(ISwingUI ui) {
|
||||
return new ConfigPlugin(ui);
|
||||
}
|
||||
|
||||
public LayersMenuPlugin createLayersMenuPlugin(ISwingUI ui) {
|
||||
return new LayersMenuPlugin(ui);
|
||||
}
|
||||
|
||||
public CloudPlugIn createCloudPlugIn(ISwingUI ui) {
|
||||
return new CloudPlugIn(ui);
|
||||
}
|
||||
|
||||
public TestMenuPlugin createTestMenuPlugin(ISwingUI ui) {
|
||||
return new TestMenuPlugin(ui);
|
||||
}
|
||||
|
||||
public HelpMenuPlugin createHelpMenuPlugin(ISwingUI ui) {
|
||||
return new HelpMenuPlugin(ui);
|
||||
}
|
||||
|
||||
public ActionBarPlugin createActionBarPlugin(ISwingUI ui) {
|
||||
return new ActionBarPlugin(ui);
|
||||
}
|
||||
|
||||
public StatusBar createStatusBar(ISwingUI ui) {
|
||||
return new StatusBar(ui);
|
||||
}
|
||||
|
||||
public ToolBox createToolBox(ISwingUI ui) {
|
||||
return new ToolBox(ui);
|
||||
}
|
||||
|
||||
public ComponentTree createComponentTree(ISwingUI ui, JComponent canvasPanel) {
|
||||
return new ComponentTree(ui, canvasPanel);
|
||||
}
|
||||
|
||||
public ExplorerPlugin createExplorerPlugin(ISwingUI ui, JComponent canvasPanel) {
|
||||
return new ExplorerPlugin(ui, canvasPanel);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,9 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IView;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AutoSavePlugin implements IPlugIn {
|
||||
|
||||
private static final String AUTO_SAVE_PATH = Utils.getUserDataDirectory("diylc") + "backup";
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.ComponentPopupMenu;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
|
||||
import org.diylc.swingframework.ruler.IRulerListener;
|
||||
import org.diylc.swingframework.ruler.Ruler.InchSubdivision;
|
||||
import org.diylc.swingframework.ruler.RulerScrollPane;
|
||||
@@ -59,7 +60,11 @@ import com.guigarage.gestures.GestureMagnificationEvent;
|
||||
import com.guigarage.gestures.GestureMagnificationListener;
|
||||
import com.guigarage.gestures.GestureUtilities;
|
||||
import com.guigarage.gestures.GesturesNotSupportedException;
|
||||
=======
|
||||
import org.springframework.stereotype.Component;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/canvas/CanvasPlugin.java
|
||||
|
||||
@Component
|
||||
public class CanvasPlugin implements IPlugIn{
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(CanvasPlugin.class);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.diylc.swing.plugins.cloud;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -52,6 +53,48 @@ import org.diylc.swing.plugins.cloud.view.browser.UploadManagerFrame;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
=======
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.AbstractAction;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.config.DummyViewDIYLCConfig;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swing.gui.DummyView;
|
||||
import org.diylc.utils.IconLoader;
|
||||
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.browser.CloudBrowserFrame;
|
||||
import org.diylc.swing.plugins.cloud.view.browser.UploadManagerFrame;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/CloudPlugIn.java
|
||||
public class CloudPlugIn implements IPlugIn {
|
||||
|
||||
private static final String ONLINE_TITLE = "Project Cloud";
|
||||
@@ -80,7 +123,18 @@ public class CloudPlugIn implements IPlugIn {
|
||||
super();
|
||||
|
||||
this.swingUI = swingUI;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
|
||||
this.thumbnailPresenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
|
||||
=======
|
||||
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
this.thumbnailPresenter = context.getBean(Presenter.class);
|
||||
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/CloudPlugIn.java
|
||||
this.thumbnailGenerator = new ThumbnailGenerator(thumbnailPresenter);
|
||||
|
||||
swingUI.injectMenuAction(getLibraryAction(), ONLINE_TITLE);
|
||||
|
||||
+19
-3
@@ -50,7 +50,14 @@ import javax.swing.SwingUtilities;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.text.DefaultCaret;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
|
||||
=======
|
||||
import org.diylc.config.DummyViewDIYLCConfig;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
@@ -72,6 +79,9 @@ import org.diylc.swing.plugins.cloud.view.CommentDialog;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
import org.diylc.utils.Pair;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* Component that is capable of showing a list of {@link ProjectEntity} objects. Can work in paging
|
||||
@@ -398,9 +408,15 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
+ project.getName()
|
||||
+ "\" with a new file?\nThis opperation is irreversible. Once replaced, the old version of the project cannot be restored.",
|
||||
"Replace Project", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) == IView.YES_OPTION) {
|
||||
|
||||
final Presenter thumbnailPresenter =
|
||||
new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
|
||||
|
||||
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
Presenter thumbnailPresenter = context.getBean(Presenter.class);
|
||||
|
||||
final ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(thumbnailPresenter);
|
||||
|
||||
final File file =
|
||||
|
||||
@@ -34,13 +34,18 @@ import org.diylc.swing.IDynamicSubmenuHandler;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.images.IconLoader;
|
||||
import org.diylc.swing.loadline.LoadlineEditorFrame;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.common.AbstractPlugin;
|
||||
|
||||
/**
|
||||
* Entry point class for File management utilities.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
|
||||
@Component
|
||||
public class FileMenuPlugin extends AbstractPlugin implements IDynamicSubmenuHandler {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(FileMenuPlugin.class);
|
||||
|
||||
@@ -56,6 +61,7 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
|
||||
private ISwingUI swingUI;
|
||||
private IPlugInPort plugInPort;
|
||||
|
||||
@Autowired
|
||||
public FileMenuPlugin(ISwingUI swingUI) {
|
||||
super();
|
||||
this.swingUI = swingUI;
|
||||
@@ -130,7 +136,7 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
|
||||
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return null;
|
||||
return EnumSet.of(EventType.FILE_STATUS_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
package org.diylc.swing.plugins.file;
|
||||
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/file/ProjectPreview.java
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
@@ -44,6 +45,39 @@ import org.diylc.serialization.ProjectFileManager;
|
||||
import org.diylc.swing.gui.DummyView;
|
||||
import org.diylc.swingframework.IFileChooserAccessory;
|
||||
|
||||
=======
|
||||
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.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.config.DummyViewDIYLCConfig;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.swingframework.IFileChooserAccessory;
|
||||
|
||||
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.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/file/ProjectPreview.java
|
||||
/**
|
||||
* {@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
|
||||
@@ -64,7 +98,13 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
|
||||
super();
|
||||
|
||||
setPreferredSize(new Dimension(140, 128));
|
||||
presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
|
||||
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
this.presenter = context.getBean(Presenter.class);
|
||||
|
||||
emptyProject = new Project();
|
||||
emptyProject.setTitle("");
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.net.URL;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/utils/BatchConverter.java
|
||||
import org.diylc.DIYLCStarter;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.presenter.Presenter;
|
||||
@@ -61,3 +62,50 @@ public class BatchConverter {
|
||||
}
|
||||
|
||||
}
|
||||
=======
|
||||
import org.diylc.DIYLCSwingConfig;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
|
||||
import org.diylc.DIYLCStarter;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.gui.DummyView;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
public class BatchConverter {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(BatchConverter.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
URL url = DIYLCStarter.class.getResource("/log4j.properties");
|
||||
Properties properties = new Properties();
|
||||
try (InputStream inputStream = url.openStream()) {
|
||||
properties.load(inputStream);
|
||||
PropertyConfigurator.configure(properties);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not initialize log4j configuration", e);
|
||||
}
|
||||
|
||||
File dir = new File("C:\\Users\\Branislav Stojkovic\\Documents\\layouts_v1");
|
||||
File[] matchingFiles = dir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
Presenter presenter = context.getBean(Presenter.class);
|
||||
for (File file : matchingFiles) {
|
||||
if (file.getName() != "" && file.getName() != "." && file.getName() != ".." && !file.isDirectory())
|
||||
presenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
presenter.saveProjectToFile(file.getParentFile().getAbsolutePath() + "\\converted\\" + file.getName(), false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/utils/BatchConverter.java
|
||||
|
||||
@@ -20,19 +20,40 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
|
||||
=======
|
||||
import org.diylc.common.EventType;
|
||||
import org.diylc.config.DummyViewDIYLCConfig;
|
||||
import org.diylc.config.ImportFileDIYLCConfig;
|
||||
import org.diylc.presenter.*;
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.NetlistException;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
=======
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
|
||||
import com.github.romankh3.image.comparison.ImageComparison;
|
||||
import com.github.romankh3.image.comparison.ImageComparisonUtil;
|
||||
import com.github.romankh3.image.comparison.model.ImageComparisonResult;
|
||||
import com.github.romankh3.image.comparison.model.ImageComparisonState;
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
|
||||
=======
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
|
||||
|
||||
public class RegressionTestRunner {
|
||||
|
||||
@@ -79,7 +100,8 @@ public class RegressionTestRunner {
|
||||
private static void createReport(List<RegressionTestResult> results, String basePath)
|
||||
throws IOException {
|
||||
IView view = new MockView();
|
||||
Presenter presenter = new Presenter(view, InMemoryConfigurationManager.getInstance());
|
||||
|
||||
Presenter presenter = TestBase.getPresenter(view);
|
||||
VersionNumber currentVersionNumber = presenter.getCurrentVersionNumber();
|
||||
|
||||
String fileName = basePath + File.separator + "reports" + File.separator
|
||||
@@ -161,7 +183,7 @@ public class RegressionTestRunner {
|
||||
String prefix = "File: " + file.getName() + " status: ";
|
||||
try {
|
||||
MockView view = new MockView();
|
||||
Presenter presenter = new Presenter(view, InMemoryConfigurationManager.getInstance());
|
||||
Presenter presenter = TestBase.getPresenter(view);
|
||||
ProjectDrawingProvider drawingProvider =
|
||||
new ProjectDrawingProvider(presenter, false, true, false);
|
||||
presenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/TestBase.java
|
||||
package org.diylc;
|
||||
|
||||
import java.awt.Point;
|
||||
@@ -49,3 +50,82 @@ public class TestBase {
|
||||
presenter.mouseClicked(point2, MouseEvent.BUTTON1, false, false, false, 1);
|
||||
}
|
||||
}
|
||||
=======
|
||||
package org.diylc;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
|
||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||
import org.diylc.common.ComponentType;
|
||||
import org.diylc.config.DummyViewDIYLCConfig;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.presenter.*;
|
||||
import org.springframework.boot.WebApplicationType;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
public class TestBase {
|
||||
|
||||
protected Presenter presenter;
|
||||
protected IView view;
|
||||
|
||||
public TestBase() {
|
||||
URL url = DIYLCStarter.class.getResource("/log4j.properties");
|
||||
Properties properties = new Properties();
|
||||
try (InputStream inputStream = url.openStream()) {
|
||||
properties.load(inputStream);
|
||||
PropertyConfigurator.configure(properties);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Could not initialize log4j configuration: " + e.getMessage());
|
||||
}
|
||||
|
||||
ConfigurationManager.getInstance().initialize("diylc-test");
|
||||
view = new MockView();
|
||||
presenter = getPresenter(view);
|
||||
}
|
||||
|
||||
protected void instantiateOneClick(String category, String name, Point point1) {
|
||||
Map<String, List<ComponentType>> componentTypes = presenter.getComponentTypes();
|
||||
ComponentType resistorType = componentTypes.get(category).stream().filter(x -> x.getName().equals(name)).findFirst().get();
|
||||
presenter.setNewComponentTypeSlot(resistorType, null, null, false);
|
||||
presenter.mouseClicked(point1, MouseEvent.BUTTON1, false, false, false, 1);
|
||||
}
|
||||
|
||||
protected void instantiateTwoClick(String category, String name, Point point1, Point point2) {
|
||||
Map<String, List<ComponentType>> componentTypes = presenter.getComponentTypes();
|
||||
ComponentType resistorType = componentTypes.get(category).stream().filter(x -> x.getName().equals(name)).findFirst().get();
|
||||
presenter.setNewComponentTypeSlot(resistorType, null, null, false);
|
||||
presenter.mouseClicked(point1, MouseEvent.BUTTON1, false, false, false, 1);
|
||||
presenter.mouseMoved(point2, false, false, false);
|
||||
presenter.mouseClicked(point2, MouseEvent.BUTTON1, false, false, false, 1);
|
||||
}
|
||||
|
||||
static Presenter getPresenter(IView view) {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.headless(false)
|
||||
.run();
|
||||
|
||||
Presenter presenter = new Presenter(view,
|
||||
context.getBean(IConfigurationManager.class),
|
||||
context.getBean(MessageDispatcher.class),
|
||||
context.getBean(DrawingService.class),
|
||||
context.getBean(ProjectFileService.class),
|
||||
context.getBean(InstantiationService.class),
|
||||
context.getBean(VariantService.class),
|
||||
context.getBean(BuildingBlockService.class),
|
||||
false);
|
||||
return presenter;
|
||||
}
|
||||
}
|
||||
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/TestBase.java
|
||||
|
||||
Reference in New Issue
Block a user