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:
Andrew Lalis 2023-07-14 22:50:57 -04:00
parent cfb70b14e8
commit 7735602a2c
6 changed files with 19 additions and 41 deletions

View File

@ -6,7 +6,7 @@
<groupId>nl.andrewlalis</groupId>
<artifactId>BlockBookBinder</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>

View File

@ -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();

View File

@ -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,6 +27,15 @@ public class CompileFromSourceAction extends AbstractAction {
@Override
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(
new BookBuilder(
ApplicationProperties.getIntProp("book.page_max_lines"),
@ -34,4 +44,5 @@ public class CompileFromSourceAction extends AbstractAction {
).addText(this.sourceTextPanel.getSourceText()).build()
);
}
}
}

View File

@ -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";
}
}
}

View File

@ -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) {

View File

@ -1,4 +1,4 @@
version=1.3.0
version=1.3.1
# Settings for the application's GUI.
frame.title=Block Book Binder