mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
fix mavenized
This commit is contained in:
@@ -17,11 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.diylc.presenter;
|
package org.diylc.presenter;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.*;
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -67,9 +63,11 @@ public class BuildingBlockManager {
|
|||||||
// import default templates from variants.xml file only if we didn't do it already
|
// import default templates from variants.xml file only if we didn't do it already
|
||||||
if (!configManager.readBoolean(IPlugInPort.DEFAULT_BLOCKS_IMPORTED_KEY, false)) {
|
if (!configManager.readBoolean(IPlugInPort.DEFAULT_BLOCKS_IMPORTED_KEY, false)) {
|
||||||
try {
|
try {
|
||||||
URL resource = Presenter.class.getResource(BLOCKS_FILE_NAME);
|
InputStream inputStream = Presenter.class.getResourceAsStream("/" + BLOCKS_FILE_NAME);
|
||||||
if (resource != null) {
|
if (inputStream == null) {
|
||||||
BufferedInputStream in = new BufferedInputStream(resource.openStream());
|
return;
|
||||||
|
}
|
||||||
|
BufferedInputStream in = new BufferedInputStream(inputStream);
|
||||||
Map<String, List<IDIYComponent<?>>> defaults =
|
Map<String, List<IDIYComponent<?>>> defaults =
|
||||||
(Map<String, List<IDIYComponent<?>>>) ProjectFileManager.xStreamSerializer
|
(Map<String, List<IDIYComponent<?>>>) ProjectFileManager.xStreamSerializer
|
||||||
.fromXML(in);
|
.fromXML(in);
|
||||||
@@ -92,7 +90,6 @@ public class BuildingBlockManager {
|
|||||||
configManager.writeValue(IPlugInPort.BLOCKS_KEY, blocksMap);
|
configManager.writeValue(IPlugInPort.BLOCKS_KEY, blocksMap);
|
||||||
LOG.info(String.format("Imported %d default building blocks",
|
LOG.info(String.format("Imported %d default building blocks",
|
||||||
defaults == null ? 0 : defaults.size()));
|
defaults == null ? 0 : defaults.size()));
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not load default blocks", e);
|
LOG.error("Could not load default blocks", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,9 +142,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
|||||||
// Read the latest version from the local update.xml file
|
// Read the latest version from the local update.xml file
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
URL resource = Presenter.class.getResource("update.xml");
|
BufferedInputStream in = new BufferedInputStream(Presenter.class.getResourceAsStream("/update.xml"));
|
||||||
if (resource != null) {
|
|
||||||
BufferedInputStream in = new BufferedInputStream(resource.openStream());
|
|
||||||
XStream xStream = new XStream(new DomDriver());
|
XStream xStream = new XStream(new DomDriver());
|
||||||
xStream.addPermission(AnyTypePermission.ANY);
|
xStream.addPermission(AnyTypePermission.ANY);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -156,7 +154,6 @@ public class Presenter implements IPlugInPort, IConfigListener {
|
|||||||
.limit(10)
|
.limit(10)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
in.close();
|
in.close();
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not find version number, using default", e);
|
LOG.error("Could not find version number, using default", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package org.diylc.presenter;
|
|||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -67,9 +68,11 @@ public class VariantManager {
|
|||||||
int importCount = 0;
|
int importCount = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL resource = Presenter.class.getResource(VARIANTS_FILE_NAME);
|
InputStream inputStream = Presenter.class.getResourceAsStream("/" + VARIANTS_FILE_NAME);
|
||||||
if (resource != null) {
|
if (inputStream == null) {
|
||||||
BufferedInputStream in = new BufferedInputStream(resource.openStream());
|
return;
|
||||||
|
}
|
||||||
|
BufferedInputStream in = new BufferedInputStream(inputStream);
|
||||||
Map<String, List<Template>> defaults =
|
Map<String, List<Template>> defaults =
|
||||||
(Map<String, List<Template>>) ProjectFileManager.xStreamSerializer.fromXML(in);
|
(Map<String, List<Template>>) ProjectFileManager.xStreamSerializer.fromXML(in);
|
||||||
in.close();
|
in.close();
|
||||||
@@ -100,7 +103,6 @@ public class VariantManager {
|
|||||||
LocalDateTime.now());
|
LocalDateTime.now());
|
||||||
configManager.writeValue(IPlugInPort.TEMPLATES_KEY, variantMap);
|
configManager.writeValue(IPlugInPort.TEMPLATES_KEY, variantMap);
|
||||||
LOG.info(String.format("Imported default %d variants", importCount));
|
LOG.info(String.format("Imported default %d variants", importCount));
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not load default variants", e);
|
LOG.error("Could not load default variants", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.diylc.utils;
|
package org.diylc.utils;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -17,9 +18,9 @@ import org.diylc.presenter.Presenter;
|
|||||||
public class VersionReader {
|
public class VersionReader {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
URL resource = Presenter.class.getResource("update.xml");
|
InputStream inputStream = Presenter.class.getResourceAsStream("/update.xml");
|
||||||
if (resource != null) {
|
if (inputStream != null) {
|
||||||
BufferedInputStream in = new BufferedInputStream(resource.openStream());
|
BufferedInputStream in = new BufferedInputStream(inputStream);
|
||||||
XStream xStream = new XStream(new DomDriver());
|
XStream xStream = new XStream(new DomDriver());
|
||||||
xStream.addPermission(AnyTypePermission.ANY);
|
xStream.addPermission(AnyTypePermission.ANY);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.diylc.appframework.miscutils.IconImageConverter;
|
import org.diylc.appframework.miscutils.IconImageConverter;
|
||||||
|
|
||||||
@@ -55,6 +58,8 @@ import org.diylc.core.annotations.PercentEditor;
|
|||||||
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, transformer = ImageTransformer.class)
|
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, transformer = ImageTransformer.class)
|
||||||
public class Image extends AbstractTransparentComponent<Void> {
|
public class Image extends AbstractTransparentComponent<Void> {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(Image.class);
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public static String DEFAULT_TEXT = "Double click to edit text";
|
public static String DEFAULT_TEXT = "Double click to edit text";
|
||||||
private static ImageIcon ICON;
|
private static ImageIcon ICON;
|
||||||
@@ -67,9 +72,12 @@ public class Image extends AbstractTransparentComponent<Void> {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
String name = "/image.png";
|
String name = "/image.png";
|
||||||
java.net.URL imgURL = Image.class.getResource(name);
|
try (InputStream inputStream = Image.class.getResourceAsStream(name)) {
|
||||||
if (imgURL != null) {
|
if (inputStream != null) {
|
||||||
ICON = new ImageIcon(imgURL, name);
|
ICON = new ImageIcon(inputStream.readAllBytes(), name);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("Error loading image " + name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
@@ -107,6 +107,11 @@
|
|||||||
<artifactId>gestures-wrapper</artifactId>
|
<artifactId>gestures-wrapper</artifactId>
|
||||||
<version>0.2</version>
|
<version>0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
<version>1.7.36</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Local dependencies from lib folder -->
|
<!-- Local dependencies from lib folder -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.diylc;
|
|||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -88,10 +89,9 @@ public class DIYLCStarter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = DIYLCStarter.class.getResource("/log4j.properties");
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try {
|
try (InputStream inputStream = DIYLCStarter.class.getResourceAsStream("/log4j.properties")) {
|
||||||
properties.load(url.openStream());
|
properties.load(inputStream);
|
||||||
PropertyConfigurator.configure(properties);
|
PropertyConfigurator.configure(properties);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not initialize log4j configuration", e);
|
LOG.error("Could not initialize log4j configuration", e);
|
||||||
@@ -222,13 +222,9 @@ public class DIYLCStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
try {
|
try (InputStream inputStream = Presenter.class.getResourceAsStream("/config.properties")) {
|
||||||
LOG.info("Injecting default properties.");
|
properties.load(inputStream);
|
||||||
URL resource = Presenter.class.getResource("config.properties");
|
|
||||||
if (resource != null) {
|
|
||||||
properties.load(resource.openStream());
|
|
||||||
PropertyInjector.injectProperties(properties);
|
PropertyInjector.injectProperties(properties);
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not read config.properties file", e);
|
LOG.error("Could not read config.properties file", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ package org.diylc.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@@ -38,10 +39,10 @@ public class BatchConverter {
|
|||||||
private static final Logger LOG = Logger.getLogger(BatchConverter.class);
|
private static final Logger LOG = Logger.getLogger(BatchConverter.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
URL url = DIYLCStarter.class.getResource("log4j.properties");
|
URL url = DIYLCStarter.class.getResource("/log4j.properties");
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try {
|
try (InputStream inputStream = url.openStream()) {
|
||||||
properties.load(url.openStream());
|
properties.load(inputStream);
|
||||||
PropertyConfigurator.configure(properties);
|
PropertyConfigurator.configure(properties);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Could not initialize log4j configuration", e);
|
LOG.error("Could not initialize log4j configuration", e);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.diylc;
|
|||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -20,10 +21,10 @@ public class TestBase {
|
|||||||
protected IView view;
|
protected IView view;
|
||||||
|
|
||||||
public TestBase() {
|
public TestBase() {
|
||||||
URL url = DIYLCStarter.class.getResource("log4j.properties");
|
URL url = DIYLCStarter.class.getResource("/log4j.properties");
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try {
|
try (InputStream inputStream = url.openStream()) {
|
||||||
properties.load(url.openStream());
|
properties.load(inputStream);
|
||||||
PropertyConfigurator.configure(properties);
|
PropertyConfigurator.configure(properties);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Could not initialize log4j configuration: " + e.getMessage());
|
System.err.println("Could not initialize log4j configuration: " + e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user