X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FFirstPanel.java;fp=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FFirstPanel.java;h=0000000000000000000000000000000000000000;hp=6b899c89d0bf9637acabf0d971c168de95486428;hb=feccee87a78e68d575dbdf44b34ca0cb5a21ea8d;hpb=214b0d1914b48d651b25e58f321ddb77a46903b8 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java deleted file mode 100644 index 6b899c89d0..0000000000 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ /dev/null @@ -1,281 +0,0 @@ -/** @file - - Copyright (c) 2006, Intel Corporation - All rights reserved. This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - **/ -package org.tianocore.migration; - -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.util.*; -import javax.swing.*; - -public final class FirstPanel extends JPanel implements ActionListener, ItemListener, UI { - /** - * Define class Serial Version UID - */ - private static final long serialVersionUID = 207759413522910399L; - - private static final FirstPanel INSTANCE = FirstPanel.init(); - - private String startpath = null; - - private JButton moduleButton, goButton, msaEditorButton, criticButton, specifyCommentButton; - private JTextField moduletext; - private JTextArea log; - private JFileChooser fc = new JFileChooser(); - private JCheckBox filebox, screenbox, mibox, criticbox, defaultpathbox; - - private boolean tofile = true, toscreen = true; - private PrintWriter logfile; - - FirstPanel() { - GridBagLayout gridbag = new GridBagLayout(); - setLayout(gridbag); - - GridBagConstraints cst = new GridBagConstraints(); - - goButton = new JButton("Go"); - goButton.addActionListener(this); - goButton.setActionCommand("go"); - - 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(goButton); - //modulePanel.add(msaEditorButton); - cst.gridx = 0; - cst.gridy = 0; - //cst.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints(modulePanel, cst); - add(modulePanel); - - 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); - } - - //---------------------------------------------------------------------------------------// - - public boolean yesOrNo(String question) { - return JOptionPane.showConfirmDialog(this, question, "Yes or No", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; - } - - public void print(String message) { - if (toscreen == true) { - log.append(message); - System.out.print(message); - } - if (tofile == true) { - logfile.append(message); - } - } - - public void println(String message) { - print(message + "\n"); - } - - public void println(Set hash) { - if (toscreen == true) { - log.append(hash + "\n"); - System.out.println(hash); - } - if (tofile == true) { - logfile.append(hash + "\n"); - } - } - - public String choose(String message, Object[] choicelist) { - return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]); - } - - 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 ) { - 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(startpath.replaceAll(Common.STRSEPARATER, "$1") + File.separator + "migration.log"))); - MigrationTool.startMigrateAll(startpath); - logfile.flush(); - logfile.close(); - } 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.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; - } - } - } - - //---------------------------------------------------------------------------------------// - - 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 GridBagLayout()); - //fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS)); - fp.setOpaque(true); - frame.setContentPane(fp); - - frame.pack(); - frame.setVisible(true); - - return fp; - } - - public static final FirstPanel getInstance() { - return INSTANCE; - } -} \ No newline at end of file