diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java index cf85446..add3b7f 100644 --- a/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java +++ b/src/main/java/pro/litvinovg/w2phtml/gui/ConfigurationWindow.java @@ -8,6 +8,7 @@ import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; import java.util.HashMap; @@ -42,7 +43,7 @@ public class ConfigurationWindow extends JFrame { */ public static void main(String[] args) { - runGUI(null); + runGUI(""); } private XComponentContext context; @@ -123,4 +124,35 @@ public class ConfigurationWindow extends JFrame { }); } + public static void runGUI(String fileName) { + ODTDocument doc = new ODTDocument(fileName); + if (singleFrame != null) { + singleFrame.dispose(); + } + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Throwable e) { + String message = e.getLocalizedMessage(); + JOptionPane.showMessageDialog(singleFrame, message); + } + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + ConfigurationWindow frame = new ConfigurationWindow(null,doc); + singleFrame = frame; + frame.setBounds(100, 100, 1100, 800); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setVisible(true); + + } catch (Throwable e) { + String message = e.getLocalizedMessage(); + e.printStackTrace(); + JOptionPane.showMessageDialog(singleFrame, message); + } + } + }); + + } + + } diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/ODTDocument.java b/src/main/java/pro/litvinovg/w2phtml/gui/ODTDocument.java index 12c2a02..e1aadf3 100644 --- a/src/main/java/pro/litvinovg/w2phtml/gui/ODTDocument.java +++ b/src/main/java/pro/litvinovg/w2phtml/gui/ODTDocument.java @@ -41,6 +41,10 @@ public class ODTDocument { private XDispatchProvider dispatchProvider; XTextDocument textDocument; + public ODTDocument(String fileName) { + this.fileName = fileName; + } + public ODTDocument(XComponentContext componentContext) { if (componentContext != null) { context = componentContext; diff --git a/src/main/java/w2phtml/Application.java b/src/main/java/w2phtml/Application.java index 6614f5d..a5c0850 100644 --- a/src/main/java/w2phtml/Application.java +++ b/src/main/java/w2phtml/Application.java @@ -67,9 +67,13 @@ public final class Application { * The argument passed on the command line. */ public static final void main(String[] args) throws Exception { - if (args.length == 0) { - showUsage(""); - ConfigurationWindow.runGUI(null); + if (args.length < 2) { + showUsage(""); + String fileName = ""; + if (args.length == 1){ + fileName = args[0]; + } + ConfigurationWindow.runGUI(fileName); } else { try { long time = System.currentTimeMillis();