X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FFirstPanel.java;h=e99a76edf421e44985af6b11cea5458c17158a38;hp=5bd9cf1ce4f1c078544110cf5b168f45a5f56bba;hb=6f55be9f0b2cc3be374def40a238fc879edd4ea4;hpb=b02824125f2a6d9e6f9ea50447d182334060c5cb diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java index 5bd9cf1ce4..e99a76edf4 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java @@ -18,24 +18,31 @@ import java.io.*; import java.util.*; import javax.swing.*; -public class FirstPanel extends JPanel implements ActionListener, UI { +public final class FirstPanel extends JPanel implements ActionListener, ItemListener, UI { /** * Define class Serial Version UID */ private static final long serialVersionUID = 207759413522910399L; - private String modulepath; + private static final FirstPanel INSTANCE = FirstPanel.init(); - private JButton moduleButton , goButton; + private String startpath; + + private JButton moduleButton, goButton, msaEditorButton, criticButton, specifyCommentButton; private JTextField moduletext; private JTextArea log; - private JFileChooser fc; - private JCheckBox filebox, screenbox; + private JFileChooser fc = new JFileChooser(); + private JCheckBox filebox, screenbox, mibox, criticbox, defaultpathbox; private boolean tofile = true, toscreen = true; private PrintWriter logfile; - FirstPanel() throws Exception { + FirstPanel() { + GridBagLayout gridbag = new GridBagLayout(); + setLayout(gridbag); + + GridBagConstraints cst = new GridBagConstraints(); + goButton = new JButton("Go"); goButton.addActionListener(this); goButton.setActionCommand("go"); @@ -43,28 +50,76 @@ public class FirstPanel extends JPanel implements ActionListener, UI { moduleButton = new JButton("Choose ModulePath"); moduleButton.addActionListener(this); + msaEditorButton = new JButton("MsaEditor"); + msaEditorButton.addActionListener(this); + + criticButton = new JButton("Critic"); + criticButton.addActionListener(this); + + specifyCommentButton = new JButton("Comment Style"); + specifyCommentButton.addActionListener(this); + moduletext = new JTextField(30); filebox = new JCheckBox("Output to logfile", true); + filebox.addItemListener(this); + screenbox = new JCheckBox("Specify logfile", false); + screenbox.addItemListener(this); + + mibox = new JCheckBox("Print ModuleInfo", false); + mibox.addItemListener(this); + MigrationTool.printModuleInfo = false; + + criticbox = new JCheckBox("Run Critic", true); + criticbox.addItemListener(this); + MigrationTool.doCritic = true; + + defaultpathbox = new JCheckBox("Use Default Output Path", true); + defaultpathbox.addItemListener(this); + MigrationTool.defaultoutput = true; JPanel modulePanel = new JPanel(); modulePanel.add(moduleButton); modulePanel.add(moduletext); - modulePanel.add(filebox); - modulePanel.add(screenbox); modulePanel.add(goButton); + //modulePanel.add(msaEditorButton); + cst.gridx = 0; + cst.gridy = 0; + //cst.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(modulePanel, cst); add(modulePanel); - log = new JTextArea(50,25); + cst.gridx = 1; + cst.gridy = 0; + gridbag.setConstraints(specifyCommentButton, cst); + add(specifyCommentButton); + //gridbag.setConstraints(criticButton, cst); + //add(criticButton); + + JPanel checkboxPanel = new JPanel(); + checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS)); + checkboxPanel.add(filebox); + checkboxPanel.add(screenbox); + checkboxPanel.add(mibox); + checkboxPanel.add(criticbox); + checkboxPanel.add(defaultpathbox); + cst.gridx = 1; + cst.gridy = 1; + //cst.gridheight = 2; + gridbag.setConstraints(checkboxPanel, cst); + add(checkboxPanel); + + log = new JTextArea(10,20); log.setMargin(new Insets(5,5,5,5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); + cst.gridx = 0; + cst.gridy = 1; + cst.fill = GridBagConstraints.BOTH; + gridbag.setConstraints(logScrollPane, cst); add(logScrollPane); - - fc = new JFileChooser(); - fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - } + } //---------------------------------------------------------------------------------------// @@ -96,63 +151,130 @@ public class FirstPanel extends JPanel implements ActionListener, UI { } } - //---------------------------------------------------------------------------------------// + public String choose(String message, Object[] choicelist) { + return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]); + } - /* - public boolean getOption(String item) { - if (item.matches("file")) { + public String getInput(String message) { + return (String)JOptionPane.showInputDialog(message); + } + + //---------------------------------------------------------------------------------------// + + public String getFilepath(String title, int mode) { + fc.setDialogTitle(title); + fc.setFileSelectionMode(mode); + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + log.append(fc.getSelectedFile().getAbsolutePath() + "\n"); + return fc.getSelectedFile().getAbsolutePath(); } + return null; } - */ - + + //---------------------------------------------------------------------------------------// + public void actionPerformed(ActionEvent e) { if ( e.getSource() == moduleButton ) { - int ret = fc.showOpenDialog(this); - if (ret == JFileChooser.APPROVE_OPTION) { - modulepath = fc.getSelectedFile().getAbsolutePath(); - moduletext.setText(modulepath); - log.append("ModulePath: " + modulepath + "\n"); - } + startpath = getFilepath("Please choose a starting path", JFileChooser.DIRECTORIES_ONLY); + moduletext.setText(startpath); } if ( e.getSource() == goButton ) { try { - logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log"))); - println("Project MsaGen"); - println("Copyright (c) 2006, Intel Corporation"); - new ModuleInfo(modulepath, this, new Database()); + logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log"))); + MigrationTool.startMigrateAll(startpath); logfile.flush(); } catch (Exception en) { println(en.getMessage()); } } + if ( e.getSource() == msaEditorButton) { + try { + MsaTreeEditor.init(); + } catch (Exception en) { + println(en.getMessage()); + } + } + if ( e.getSource() == criticButton) { + try { + Critic.fireAt(startpath); + } catch (Exception en) { + println(en.getMessage()); + } + } + if ( e.getSource() == specifyCommentButton) { + try { // input examine is not imposed but should be added + MigrationTool.MIGRATIONCOMMENT = getInput("Please type in wanted comment style used by the tool\nbe sure to start with '//', or you won't enjoy the result"); + //MsaWriter.parse("C:\\tianocore\\edk2\\MdePkg\\Library\\BaseLib\\BaseLib.msa"); + } catch (Exception en) { + println(en.getMessage()); + } + } } public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.DESELECTED) { - System.out.println("changed"); + if (e.getSource() == filebox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("filebox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("filebox SELECTED"); + } + } else if (e.getSource() == screenbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("screenbox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("screenbox SELECTED"); + } + } else if (e.getSource() == mibox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + MigrationTool.printModuleInfo = false; + } else if (e.getStateChange() == ItemEvent.SELECTED) { + MigrationTool.printModuleInfo = true; + } + } else if (e.getSource() == criticbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + MigrationTool.doCritic = false; + } else if (e.getStateChange() == ItemEvent.SELECTED) { + MigrationTool.doCritic = true; + } + } else if (e.getSource() == defaultpathbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + MigrationTool.defaultoutput = false; + } else if (e.getStateChange() == ItemEvent.SELECTED) { + MigrationTool.defaultoutput = true; + } } } //---------------------------------------------------------------------------------------// - public static void 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); FirstPanel fp = new FirstPanel(); - fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS)); + //fp.setLayout(new GridBagLayout()); + //fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS)); fp.setOpaque(true); frame.setContentPane(fp); - frame.setSize(800,600); + frame.pack(); frame.setVisible(true); + + return fp; + } + + public static final FirstPanel getInstance() { + return INSTANCE; } } \ No newline at end of file