Compare commits

...

2 Commits
1.3.0 ... main

6 changed files with 19 additions and 42 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,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()
);
);
}
}
}

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

@ -1,6 +1,5 @@
package nl.andrewlalis.blockbookbinder.view;
import nl.andrewlalis.blockbookbinder.BlockBookBinder;
import nl.andrewlalis.blockbookbinder.control.export.ExportBookToMinecraftAction;
import nl.andrewlalis.blockbookbinder.control.source.CleanSourceAction;
import nl.andrewlalis.blockbookbinder.control.source.CompileFromSourceAction;
@ -22,7 +21,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