singleton of Database & FirstPanel

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1394 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
alfred 2006-08-28 02:55:44 +00:00
parent 482407d3d6
commit 4f60c26f93
3 changed files with 49 additions and 30 deletions

View File

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

View File

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

View File

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