Removed VersionReader.java, simplified version fetching from props, added warning about compile-from-source when no source text present. Version 1.3.1.
This commit is contained in:
parent
cfb70b14e8
commit
7735602a2c
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>nl.andrewlalis</groupId>
|
<groupId>nl.andrewlalis</groupId>
|
||||||
<artifactId>BlockBookBinder</artifactId>
|
<artifactId>BlockBookBinder</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.3.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package nl.andrewlalis.blockbookbinder;
|
package nl.andrewlalis.blockbookbinder;
|
||||||
|
|
||||||
import com.formdev.flatlaf.FlatDarkLaf;
|
import com.formdev.flatlaf.FlatDarkLaf;
|
||||||
import nl.andrewlalis.blockbookbinder.util.VersionReader;
|
|
||||||
import nl.andrewlalis.blockbookbinder.view.MainFrame;
|
import nl.andrewlalis.blockbookbinder.view.MainFrame;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -10,8 +9,6 @@ import javax.swing.*;
|
||||||
* The main class for the application.
|
* The main class for the application.
|
||||||
*/
|
*/
|
||||||
public class BlockBookBinder {
|
public class BlockBookBinder {
|
||||||
public static final String VERSION = VersionReader.getVersion();
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
FlatDarkLaf.setup();
|
FlatDarkLaf.setup();
|
||||||
|
|
|
@ -8,6 +8,7 @@ import nl.andrewlalis.blockbookbinder.view.SourceTextPanel;
|
||||||
import nl.andrewlalis.blockbookbinder.view.book.BookPreviewPanel;
|
import nl.andrewlalis.blockbookbinder.view.book.BookPreviewPanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class CompileFromSourceAction extends AbstractAction {
|
public class CompileFromSourceAction extends AbstractAction {
|
||||||
|
@ -26,6 +27,15 @@ public class CompileFromSourceAction extends AbstractAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
String text = this.sourceTextPanel.getSourceText();
|
||||||
|
if (text.isBlank()) {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
SwingUtilities.getWindowAncestor((Component) e.getSource()),
|
||||||
|
"No source text to compile.\nEnter some text into the \"Source Text\" panel first.",
|
||||||
|
"No Source Text",
|
||||||
|
JOptionPane.WARNING_MESSAGE
|
||||||
|
);
|
||||||
|
} else {
|
||||||
this.bookPreviewPanel.setBook(
|
this.bookPreviewPanel.setBook(
|
||||||
new BookBuilder(
|
new BookBuilder(
|
||||||
ApplicationProperties.getIntProp("book.page_max_lines"),
|
ApplicationProperties.getIntProp("book.page_max_lines"),
|
||||||
|
@ -34,4 +44,5 @@ public class CompileFromSourceAction extends AbstractAction {
|
||||||
).addText(this.sourceTextPanel.getSourceText()).build()
|
).addText(this.sourceTextPanel.getSourceText()).build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package nl.andrewlalis.blockbookbinder.util;
|
|
||||||
|
|
||||||
import org.apache.maven.model.Model;
|
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
|
|
||||||
public class VersionReader {
|
|
||||||
public static String getVersion() {
|
|
||||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
|
||||||
try {
|
|
||||||
Model model;
|
|
||||||
if ((new File("pom.xml")).exists()) {
|
|
||||||
model = reader.read(new FileReader("pom.xml"));
|
|
||||||
} else {
|
|
||||||
model = reader.read(new InputStreamReader(
|
|
||||||
VersionReader.class.getResourceAsStream("/META-INF/maven/nl.andrewlalis/BlockBookBinder/pom.xml")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return model.getVersion();
|
|
||||||
} catch (IOException | XmlPullParserException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,7 @@ public class MainFrame extends JFrame {
|
||||||
ApplicationProperties.getIntProp("frame.default_width"),
|
ApplicationProperties.getIntProp("frame.default_width"),
|
||||||
ApplicationProperties.getIntProp("frame.default_height")
|
ApplicationProperties.getIntProp("frame.default_height")
|
||||||
));
|
));
|
||||||
this.setTitle(ApplicationProperties.getProp("frame.title") + " Version " + BlockBookBinder.VERSION);
|
this.setTitle(ApplicationProperties.getProp("frame.title") + " Version " + ApplicationProperties.getProp("version"));
|
||||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
final URL iconUrl = this.getClass().getClassLoader().getResource("images/book_and_quill.png");
|
final URL iconUrl = this.getClass().getClassLoader().getResource("images/book_and_quill.png");
|
||||||
if (iconUrl != null) {
|
if (iconUrl != null) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version=1.3.0
|
version=1.3.1
|
||||||
|
|
||||||
# Settings for the application's GUI.
|
# Settings for the application's GUI.
|
||||||
frame.title=Block Book Binder
|
frame.title=Block Book Binder
|
||||||
|
|
Loading…
Reference in New Issue