diff --git a/pom.xml b/pom.xml index 1f9694e..47677f9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ nl.andrewlalis BlockBookBinder - 1.3.0 + 1.3.1 17 diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/BlockBookBinder.java b/src/main/java/nl/andrewlalis/blockbookbinder/BlockBookBinder.java index f4af3b8..63ff837 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/BlockBookBinder.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/BlockBookBinder.java @@ -1,7 +1,6 @@ package nl.andrewlalis.blockbookbinder; import com.formdev.flatlaf.FlatDarkLaf; -import nl.andrewlalis.blockbookbinder.util.VersionReader; import nl.andrewlalis.blockbookbinder.view.MainFrame; import javax.swing.*; @@ -10,8 +9,6 @@ import javax.swing.*; * The main class for the application. */ public class BlockBookBinder { - public static final String VERSION = VersionReader.getVersion(); - public static void main(String[] args) { SwingUtilities.invokeLater(() -> { FlatDarkLaf.setup(); diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/control/source/CompileFromSourceAction.java b/src/main/java/nl/andrewlalis/blockbookbinder/control/source/CompileFromSourceAction.java index 382ed58..4c2b55c 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/control/source/CompileFromSourceAction.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/control/source/CompileFromSourceAction.java @@ -8,6 +8,7 @@ import nl.andrewlalis.blockbookbinder.view.SourceTextPanel; import nl.andrewlalis.blockbookbinder.view.book.BookPreviewPanel; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; public class CompileFromSourceAction extends AbstractAction { @@ -26,12 +27,22 @@ public class CompileFromSourceAction extends AbstractAction { @Override public void actionPerformed(ActionEvent e) { - this.bookPreviewPanel.setBook( + 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( new BookBuilder( - ApplicationProperties.getIntProp("book.page_max_lines"), - ApplicationProperties.getIntProp("book.page_max_chars"), - ApplicationProperties.getIntProp("book.page_max_width") + ApplicationProperties.getIntProp("book.page_max_lines"), + ApplicationProperties.getIntProp("book.page_max_chars"), + ApplicationProperties.getIntProp("book.page_max_width") ).addText(this.sourceTextPanel.getSourceText()).build() - ); + ); + } } } diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/util/VersionReader.java b/src/main/java/nl/andrewlalis/blockbookbinder/util/VersionReader.java deleted file mode 100644 index bc34580..0000000 --- a/src/main/java/nl/andrewlalis/blockbookbinder/util/VersionReader.java +++ /dev/null @@ -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"; - } - } -} diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/view/MainFrame.java b/src/main/java/nl/andrewlalis/blockbookbinder/view/MainFrame.java index e54682e..5f5b028 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/view/MainFrame.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/view/MainFrame.java @@ -22,7 +22,7 @@ public class MainFrame extends JFrame { ApplicationProperties.getIntProp("frame.default_width"), 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); final URL iconUrl = this.getClass().getClassLoader().getResource("images/book_and_quill.png"); if (iconUrl != null) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index af77fad..b4ed43c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,4 +1,4 @@ -version=1.3.0 +version=1.3.1 # Settings for the application's GUI. frame.title=Block Book Binder