From 26f9f880b5c3f590578aa76d6a02674a8f21abbb Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 17 Apr 2020 11:30:24 +0200 Subject: [PATCH] Dispose one open second window --- .../libreoffice/metadata/Document.java | 1 + .../libreoffice/metadata/views/EditorGUI.java | 36 +++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/source/pro/litvinovg/libreoffice/metadata/Document.java b/source/pro/litvinovg/libreoffice/metadata/Document.java index 5b65602..9d920a7 100644 --- a/source/pro/litvinovg/libreoffice/metadata/Document.java +++ b/source/pro/litvinovg/libreoffice/metadata/Document.java @@ -74,6 +74,7 @@ public class Document { readMetadataInDocument(); frame = xDesktop.getCurrentFrame(); dispatchProvider = UnoRuntime.queryInterface( com.sun.star.frame.XDispatchProvider.class, frame ); + hideAnnotations(); } catch (Exception e) { System.out.println("xDesktop inaccessible. Can not proceed."); e.printStackTrace(); diff --git a/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java b/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java index b1453f4..723b6f7 100644 --- a/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java +++ b/source/pro/litvinovg/libreoffice/metadata/views/EditorGUI.java @@ -58,7 +58,7 @@ public class EditorGUI extends JFrame { private DefaultTableModel docCustomPropsModel; - //GroupLayouts + private static JFrame singleFrame = null; private Map docProps; @@ -80,22 +80,28 @@ public class EditorGUI extends JFrame { } public static void runGUI(Document doc) { - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable e) { - e.printStackTrace(); + if (singleFrame != null) { + singleFrame.dispose(); } - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - EditorGUI frame = new EditorGUI(doc); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.setVisible(true); - } catch (Exception e) { - e.printStackTrace(); - } + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Throwable e) { + e.printStackTrace(); } - }); + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + EditorGUI frame = new EditorGUI(doc); + singleFrame = frame; + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setVisible(true); + + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } private static void testGUI() {