From 4f60c26f936d5e878e9fb941f896868c6f452f18 Mon Sep 17 00:00:00 2001 From: alfred Date: Mon, 28 Aug 2006 02:55:44 +0000 Subject: singleton of Database & FirstPanel git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1394 6f19259b-4bc3-4df7-8a09-765794883524 --- .../org/tianocore/migration/Database.java | 30 ++++++++++++++-------- .../org/tianocore/migration/FirstPanel.java | 27 ++++++++++++------- .../org/tianocore/migration/MigrationTool.java | 22 ++++++++-------- 3 files changed, 49 insertions(+), 30 deletions(-) (limited to 'Tools/Source/MigrationTools') diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java index 8b088c9..c986d3b 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Database.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Database.java @@ -17,15 +17,21 @@ import java.util.*; import java.util.regex.*; public final class Database { - Database(String path) throws Exception { + private static final Database INSTANCE = Database.init(); + + Database(String path) { DatabasePath = path; - - importDBLib("Library.csv"); - importDBGuid("Guid.csv", "Guid"); - importDBGuid("Ppi.csv", "Ppi"); - importDBGuid("Protocol.csv", "Protocol"); - importDBMacro("Macro.csv"); - importListR8Only(); + + try { + importDBLib("Library.csv"); + importDBGuid("Guid.csv", "Guid"); + importDBGuid("Ppi.csv", "Ppi"); + importDBGuid("Protocol.csv", "Protocol"); + importDBMacro("Macro.csv"); + importListR8Only(); + } catch (Exception e) { + System.out.println(e.getMessage()); + } } public String DatabasePath; @@ -165,12 +171,16 @@ public final class Database { //-------------------------------------has------------------------------------------// //-------------------------------------init------------------------------------------// - - public static Database init() throws Exception { + + private static final Database init() { if (System.getenv("WORKSPACE") == null) { return new Database("C:" + File.separator + "tianocore" + File.separator + "edk2" + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); } else { return new Database(System.getenv("WORKSPACE") + File.separator + "Tools" + File.separator + "Conf" + File.separator + "Migration"); } } + + public static final Database getInstance() { + return INSTANCE; + } } diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java index d0f9151..c78ad97 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java @@ -24,6 +24,8 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList */ private static final long serialVersionUID = 207759413522910399L; + private static final FirstPanel INSTANCE = FirstPanel.init(); + private String startpath; private ModuleInfo mi; @@ -36,7 +38,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList private boolean tofile = true, toscreen = true; private PrintWriter logfile; - FirstPanel() throws Exception { + FirstPanel() { GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); @@ -235,14 +237,17 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList //---------------------------------------------------------------------------------------// - public static FirstPanel init() throws Exception { - - //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); - //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); - //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); - //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + private static final FirstPanel init() { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + } catch (Exception e) { + System.out.println(e.getMessage()); + } JFrame frame = new JFrame("MigrationTools"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -258,4 +263,8 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList return fp; } + + public static final FirstPanel getInstance() { + return INSTANCE; + } } \ No newline at end of file diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java b/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java index 2cef162..e1e769f 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java @@ -4,6 +4,15 @@ import java.io.File; import java.util.Set; public class MigrationTool { + public static UI ui = null; + public static Database db = null; + + public static final String MIGRATIONCOMMENT = "//%$//"; + + public static boolean printModuleInfo = false; + public static boolean doCritic = false; + public static boolean defaultoutput = false; + private static final void manipulate(ModuleInfo mi) throws Exception { ModuleReader.ModuleScan(mi); @@ -60,17 +69,8 @@ public class MigrationTool { Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR); } - public static UI ui = null; - public static Database db = null; - - public static final String MIGRATIONCOMMENT = "//%$//"; - - public static boolean printModuleInfo = false; - public static boolean doCritic = false; - public static boolean defaultoutput = false; - public static void main(String[] args) throws Exception { - ui = FirstPanel.init(); - db = Database.init(); + ui = FirstPanel.getInstance(); + db = Database.getInstance(); } } -- cgit v1.1