fix mavenized

This commit is contained in:
Branislav Stojkovic
2025-03-11 12:18:00 +01:00
parent 0417947289
commit e088b5e8c9
10 changed files with 198 additions and 190 deletions
BIN
View File
Binary file not shown.
+5
View File
@@ -107,6 +107,11 @@
<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>
@@ -19,6 +19,7 @@ package org.diylc;
import java.awt.Desktop;
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.util.Arrays;
@@ -88,10 +89,9 @@ public class DIYLCStarter {
}
}
URL url = DIYLCStarter.class.getResource("/log4j.properties");
Properties properties = new Properties();
try {
properties.load(url.openStream());
try (InputStream inputStream = DIYLCStarter.class.getResourceAsStream("/log4j.properties")) {
properties.load(inputStream);
PropertyConfigurator.configure(properties);
} catch (Exception e) {
LOG.error("Could not initialize log4j configuration", e);
@@ -222,13 +222,9 @@ public class DIYLCStarter {
}
properties = new Properties();
try {
LOG.info("Injecting default properties.");
URL resource = Presenter.class.getResource("config.properties");
if (resource != null) {
properties.load(resource.openStream());
PropertyInjector.injectProperties(properties);
}
try (InputStream inputStream = Presenter.class.getResourceAsStream("/config.properties")) {
properties.load(inputStream);
PropertyInjector.injectProperties(properties);
} catch (Exception e) {
LOG.error("Could not read config.properties file", e);
}
@@ -1,64 +1,65 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import java.io.File;
import java.io.FilenameFilter;
import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.DIYLCStarter;
import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.DummyView;
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 {
properties.load(url.openStream());
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;
}
});
Presenter presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
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);
}
}
}
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import java.io.File;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.DIYLCStarter;
import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.DummyView;
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;
}
});
Presenter presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
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);
}
}
}
@@ -1,52 +1,53 @@
package org.diylc;
import java.awt.Point;
import java.awt.event.MouseEvent;
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.InMemoryConfigurationManager;
import org.diylc.common.ComponentType;
import org.diylc.core.IView;
import org.diylc.presenter.Presenter;
public class TestBase {
protected Presenter presenter;
protected IView view;
public TestBase() {
URL url = DIYLCStarter.class.getResource("log4j.properties");
Properties properties = new Properties();
try {
properties.load(url.openStream());
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 = new Presenter(view, InMemoryConfigurationManager.getInstance());
}
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);
}
}
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.InMemoryConfigurationManager;
import org.diylc.common.ComponentType;
import org.diylc.core.IView;
import org.diylc.presenter.Presenter;
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 = new Presenter(view, InMemoryConfigurationManager.getInstance());
}
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);
}
}