12e5b6d6dSopenharmony_ci/* 22e5b6d6dSopenharmony_ci ***************************************************************************** 32e5b6d6dSopenharmony_ci * Copyright (C) 2000-2004, International Business Machines Corporation and * 42e5b6d6dSopenharmony_ci * others. All Rights Reserved. * 52e5b6d6dSopenharmony_ci ***************************************************************************** 62e5b6d6dSopenharmony_ci */ 72e5b6d6dSopenharmony_cipackage com.ibm.rbm.gui; 82e5b6d6dSopenharmony_ci 92e5b6d6dSopenharmony_ciimport java.awt.*; 102e5b6d6dSopenharmony_ciimport java.awt.event.*; 112e5b6d6dSopenharmony_ci 122e5b6d6dSopenharmony_ciimport javax.swing.*; 132e5b6d6dSopenharmony_ciimport javax.swing.text.JTextComponent; 142e5b6d6dSopenharmony_ci 152e5b6d6dSopenharmony_ciimport com.ibm.rbm.*; 162e5b6d6dSopenharmony_ci 172e5b6d6dSopenharmony_ci/** 182e5b6d6dSopenharmony_ci * The class used to display statistics 192e5b6d6dSopenharmony_ci */ 202e5b6d6dSopenharmony_ciclass RBStatisticsPanel extends JPanel { 212e5b6d6dSopenharmony_ci RBManager rbm; 222e5b6d6dSopenharmony_ci Bundle bundle; 232e5b6d6dSopenharmony_ci 242e5b6d6dSopenharmony_ci // Components - Bundle 252e5b6d6dSopenharmony_ci JLabel jLabelStatsTitle; 262e5b6d6dSopenharmony_ci 272e5b6d6dSopenharmony_ci JLabel jLabelStatsName; 282e5b6d6dSopenharmony_ci JLabel jLabelStatsComment; 292e5b6d6dSopenharmony_ci JLabel jLabelStatsManager; 302e5b6d6dSopenharmony_ci JLabel jLabelStatsLanguage; 312e5b6d6dSopenharmony_ci JLabel jLabelStatsCountry; 322e5b6d6dSopenharmony_ci JLabel jLabelStatsVariant; 332e5b6d6dSopenharmony_ci JLabel jLabelStatsNumTrans; 342e5b6d6dSopenharmony_ci JLabel jLabelStatsNumUntrans; 352e5b6d6dSopenharmony_ci 362e5b6d6dSopenharmony_ci JTextField jTextFieldStatsName; 372e5b6d6dSopenharmony_ci JTextField jTextFieldStatsComment; 382e5b6d6dSopenharmony_ci JTextField jTextFieldStatsManager; 392e5b6d6dSopenharmony_ci JTextField jTextFieldStatsLanguage; 402e5b6d6dSopenharmony_ci JTextField jTextFieldStatsCountry; 412e5b6d6dSopenharmony_ci JTextField jTextFieldStatsVariant; 422e5b6d6dSopenharmony_ci 432e5b6d6dSopenharmony_ci JButton updateButton; 442e5b6d6dSopenharmony_ci 452e5b6d6dSopenharmony_ci Box boxStatsLeftRight1; 462e5b6d6dSopenharmony_ci Box boxStatsLeftRight2; 472e5b6d6dSopenharmony_ci 482e5b6d6dSopenharmony_ci // Components - bundle manager 492e5b6d6dSopenharmony_ci JLabel titleLabel; 502e5b6d6dSopenharmony_ci JLabel numFileLabel; 512e5b6d6dSopenharmony_ci JLabel numDupLabel; 522e5b6d6dSopenharmony_ci JLabel numGroupLabel; 532e5b6d6dSopenharmony_ci JLabel numItemLabel; 542e5b6d6dSopenharmony_ci 552e5b6d6dSopenharmony_ci JList groupList; 562e5b6d6dSopenharmony_ci JList fileList; 572e5b6d6dSopenharmony_ci JList dupList; 582e5b6d6dSopenharmony_ci 592e5b6d6dSopenharmony_ci JScrollPane groupScroll; 602e5b6d6dSopenharmony_ci JScrollPane dupScroll; 612e5b6d6dSopenharmony_ci JScrollPane fileScroll; 622e5b6d6dSopenharmony_ci 632e5b6d6dSopenharmony_ci JPanel filePanel; 642e5b6d6dSopenharmony_ci JPanel itemPanel; 652e5b6d6dSopenharmony_ci JPanel groupPanel; 662e5b6d6dSopenharmony_ci 672e5b6d6dSopenharmony_ci JButton fileButton; 682e5b6d6dSopenharmony_ci JButton groupButton; 692e5b6d6dSopenharmony_ci JButton itemButton; 702e5b6d6dSopenharmony_ci 712e5b6d6dSopenharmony_ci Box mainBox; 722e5b6d6dSopenharmony_ci Box dupBox; 732e5b6d6dSopenharmony_ci 742e5b6d6dSopenharmony_ci 752e5b6d6dSopenharmony_ci public void setBundle(Bundle b) { 762e5b6d6dSopenharmony_ci rbm = null; 772e5b6d6dSopenharmony_ci if (bundle == null) { 782e5b6d6dSopenharmony_ci bundle = b; 792e5b6d6dSopenharmony_ci initComponents(); 802e5b6d6dSopenharmony_ci } else if (bundle != b) { 812e5b6d6dSopenharmony_ci bundle = b; 822e5b6d6dSopenharmony_ci updateComponents(); 832e5b6d6dSopenharmony_ci } 842e5b6d6dSopenharmony_ci } 852e5b6d6dSopenharmony_ci 862e5b6d6dSopenharmony_ci public void setManager(RBManager m) { 872e5b6d6dSopenharmony_ci bundle = null; 882e5b6d6dSopenharmony_ci if (rbm == null) { 892e5b6d6dSopenharmony_ci rbm = m; 902e5b6d6dSopenharmony_ci initComponents(); 912e5b6d6dSopenharmony_ci } else if (rbm != m) { 922e5b6d6dSopenharmony_ci rbm = m; 932e5b6d6dSopenharmony_ci updateComponents(); 942e5b6d6dSopenharmony_ci } 952e5b6d6dSopenharmony_ci } 962e5b6d6dSopenharmony_ci 972e5b6d6dSopenharmony_ci public void removeElements() { 982e5b6d6dSopenharmony_ci if (rbm != null || bundle != null) { 992e5b6d6dSopenharmony_ci rbm = null; 1002e5b6d6dSopenharmony_ci bundle = null; 1012e5b6d6dSopenharmony_ci initComponents(); 1022e5b6d6dSopenharmony_ci } 1032e5b6d6dSopenharmony_ci } 1042e5b6d6dSopenharmony_ci 1052e5b6d6dSopenharmony_ci public void initComponents() { 1062e5b6d6dSopenharmony_ci // Initialize components 1072e5b6d6dSopenharmony_ci if (bundle != null) { 1082e5b6d6dSopenharmony_ci RBManagerGUI.debugMsg("Initializing components for Resource File"); 1092e5b6d6dSopenharmony_ci int untranslated = bundle.getUntranslatedItemsSize(); 1102e5b6d6dSopenharmony_ci 1112e5b6d6dSopenharmony_ci jLabelStatsTitle = new JLabel(bundle.name); 1122e5b6d6dSopenharmony_ci 1132e5b6d6dSopenharmony_ci jLabelStatsName = new JLabel(Resources.getTranslation("languagestats_title")); 1142e5b6d6dSopenharmony_ci jLabelStatsComment = new JLabel(Resources.getTranslation("languagestats_comment")); 1152e5b6d6dSopenharmony_ci jLabelStatsManager = new JLabel(Resources.getTranslation("languagestats_manager")); 1162e5b6d6dSopenharmony_ci jLabelStatsLanguage = new JLabel(Resources.getTranslation("languagestats_language")); 1172e5b6d6dSopenharmony_ci jLabelStatsCountry = new JLabel(Resources.getTranslation("languagestats_country")); 1182e5b6d6dSopenharmony_ci jLabelStatsVariant = new JLabel(Resources.getTranslation("languagestats_variant")); 1192e5b6d6dSopenharmony_ci jLabelStatsNumTrans = new JLabel(Resources.getTranslation("languagestats_item_count") + " " + 1202e5b6d6dSopenharmony_ci String.valueOf(bundle.allItems.size())); 1212e5b6d6dSopenharmony_ci jLabelStatsNumUntrans = new JLabel(Resources.getTranslation("languagestats_translation_count") + 1222e5b6d6dSopenharmony_ci String.valueOf(untranslated)); 1232e5b6d6dSopenharmony_ci 1242e5b6d6dSopenharmony_ci jTextFieldStatsName = new JTextField((bundle.name == null ? Resources.getTranslation("untitled") : bundle.name)); 1252e5b6d6dSopenharmony_ci jTextFieldStatsComment = new JTextField((bundle.comment == null ? "" : bundle.comment)); 1262e5b6d6dSopenharmony_ci jTextFieldStatsManager = new JTextField((bundle.manager == null ? "" : bundle.manager)); 1272e5b6d6dSopenharmony_ci jTextFieldStatsLanguage = new JTextField((bundle.language == null ? "" : bundle.language),25); 1282e5b6d6dSopenharmony_ci jTextFieldStatsCountry = new JTextField((bundle.country == null ? "" : bundle.country),25); 1292e5b6d6dSopenharmony_ci jTextFieldStatsVariant = new JTextField((bundle.variant == null ? "" : bundle.variant),25); 1302e5b6d6dSopenharmony_ci 1312e5b6d6dSopenharmony_ci boxStatsLeftRight1 = new Box(BoxLayout.X_AXIS); 1322e5b6d6dSopenharmony_ci boxStatsLeftRight2 = new Box(BoxLayout.X_AXIS); 1332e5b6d6dSopenharmony_ci 1342e5b6d6dSopenharmony_ci updateButton = new JButton(Resources.getTranslation("button_update")); 1352e5b6d6dSopenharmony_ci updateButton.setMnemonic(RBManagerMenuBar.getKeyEventKey(Resources.getTranslation("button_update_trigger"))); 1362e5b6d6dSopenharmony_ci 1372e5b6d6dSopenharmony_ci // Set up the components 1382e5b6d6dSopenharmony_ci jLabelStatsTitle.setFont(new Font("SansSerif",Font.PLAIN,18)); 1392e5b6d6dSopenharmony_ci 1402e5b6d6dSopenharmony_ci ButtonEnablerFocusListener befl = new ButtonEnablerFocusListener(updateButton); 1412e5b6d6dSopenharmony_ci 1422e5b6d6dSopenharmony_ci // Add listeners 1432e5b6d6dSopenharmony_ci updateButton.addActionListener(new ActionListener(){ 1442e5b6d6dSopenharmony_ci public void actionPerformed(ActionEvent ev) { 1452e5b6d6dSopenharmony_ci updateBundleInfo(); 1462e5b6d6dSopenharmony_ci } 1472e5b6d6dSopenharmony_ci }); 1482e5b6d6dSopenharmony_ci 1492e5b6d6dSopenharmony_ci jTextFieldStatsName.addFocusListener(befl); 1502e5b6d6dSopenharmony_ci jTextFieldStatsComment.addFocusListener(befl); 1512e5b6d6dSopenharmony_ci jTextFieldStatsManager.addFocusListener(befl); 1522e5b6d6dSopenharmony_ci jTextFieldStatsLanguage.addFocusListener(befl); 1532e5b6d6dSopenharmony_ci jTextFieldStatsCountry.addFocusListener(befl); 1542e5b6d6dSopenharmony_ci jTextFieldStatsVariant.addFocusListener(befl); 1552e5b6d6dSopenharmony_ci 1562e5b6d6dSopenharmony_ci jTextFieldStatsName.setColumns(35); 1572e5b6d6dSopenharmony_ci jTextFieldStatsComment.setColumns(35); 1582e5b6d6dSopenharmony_ci jTextFieldStatsManager.setColumns(35); 1592e5b6d6dSopenharmony_ci jTextFieldStatsLanguage.setColumns(25); 1602e5b6d6dSopenharmony_ci jTextFieldStatsCountry.setColumns(25); 1612e5b6d6dSopenharmony_ci jTextFieldStatsVariant.setColumns(25); 1622e5b6d6dSopenharmony_ci 1632e5b6d6dSopenharmony_ci //updateButton.setEnabled(false); 1642e5b6d6dSopenharmony_ci 1652e5b6d6dSopenharmony_ci // Update the display 1662e5b6d6dSopenharmony_ci if (mainBox != null){ 1672e5b6d6dSopenharmony_ci mainBox.removeAll(); 1682e5b6d6dSopenharmony_ci } else { 1692e5b6d6dSopenharmony_ci mainBox = new Box(BoxLayout.Y_AXIS); 1702e5b6d6dSopenharmony_ci } 1712e5b6d6dSopenharmony_ci if (dupBox != null) 1722e5b6d6dSopenharmony_ci dupBox.removeAll(); 1732e5b6d6dSopenharmony_ci removeAll(); 1742e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsTitle); 1752e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(10)); 1762e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsName); 1772e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsName); 1782e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1792e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsComment); 1802e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsComment); 1812e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1822e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsManager); 1832e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsManager); 1842e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1852e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsLanguage); 1862e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsLanguage); 1872e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1882e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsCountry); 1892e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsCountry); 1902e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1912e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsVariant); 1922e5b6d6dSopenharmony_ci mainBox.add(jTextFieldStatsVariant); 1932e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1942e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsNumTrans); 1952e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(5)); 1962e5b6d6dSopenharmony_ci mainBox.add(jLabelStatsNumUntrans); 1972e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(10)); 1982e5b6d6dSopenharmony_ci mainBox.add(updateButton); 1992e5b6d6dSopenharmony_ci mainBox.add(Box.createHorizontalGlue()); 2002e5b6d6dSopenharmony_ci if (!(getLayout() instanceof FlowLayout)) { 2012e5b6d6dSopenharmony_ci setLayout(new FlowLayout()); 2022e5b6d6dSopenharmony_ci } 2032e5b6d6dSopenharmony_ci add(mainBox); 2042e5b6d6dSopenharmony_ci } else if (rbm != null) { 2052e5b6d6dSopenharmony_ci RBManagerGUI.debugMsg("Initializing components for Resource Bundle"); 2062e5b6d6dSopenharmony_ci titleLabel = new JLabel(rbm.getBaseClass() + " - " + Resources.getTranslation("baseclass")); 2072e5b6d6dSopenharmony_ci 2082e5b6d6dSopenharmony_ci numFileLabel = new JLabel(Resources.getTranslation("basestats_file_count") + " " + rbm.getNumberLanguages()); 2092e5b6d6dSopenharmony_ci numGroupLabel = new JLabel(Resources.getTranslation("basestats_group_count") + " " + rbm.getNumberGroups()); 2102e5b6d6dSopenharmony_ci numItemLabel = new JLabel(Resources.getTranslation("basestats_item_count") + " " + rbm.getNumberTotalTranslations()); 2112e5b6d6dSopenharmony_ci numDupLabel = new JLabel(Resources.getTranslation("basestats_duplicates_count") + " " + rbm.getNumberDuplicates()); 2122e5b6d6dSopenharmony_ci 2132e5b6d6dSopenharmony_ci fileList = new JList(rbm.getLanguageListingVector()); 2142e5b6d6dSopenharmony_ci groupList = new JList(rbm.getGroupListingVector()); 2152e5b6d6dSopenharmony_ci dupList = new JList(rbm.getDuplicatesListingVector()); 2162e5b6d6dSopenharmony_ci 2172e5b6d6dSopenharmony_ci fileButton = new JButton(Resources.getTranslation("button_add_file")); 2182e5b6d6dSopenharmony_ci groupButton = new JButton(Resources.getTranslation("button_add_group")); 2192e5b6d6dSopenharmony_ci itemButton = new JButton(Resources.getTranslation("button_add_resource")); 2202e5b6d6dSopenharmony_ci 2212e5b6d6dSopenharmony_ci filePanel = new JPanel(); 2222e5b6d6dSopenharmony_ci groupPanel = new JPanel(); 2232e5b6d6dSopenharmony_ci itemPanel = new JPanel(); 2242e5b6d6dSopenharmony_ci 2252e5b6d6dSopenharmony_ci fileScroll = new JScrollPane(fileList); 2262e5b6d6dSopenharmony_ci groupScroll = new JScrollPane(groupList); 2272e5b6d6dSopenharmony_ci dupScroll = new JScrollPane(dupList); 2282e5b6d6dSopenharmony_ci 2292e5b6d6dSopenharmony_ci if (mainBox == null) { 2302e5b6d6dSopenharmony_ci mainBox = new Box(BoxLayout.Y_AXIS); 2312e5b6d6dSopenharmony_ci } else { 2322e5b6d6dSopenharmony_ci mainBox.removeAll(); 2332e5b6d6dSopenharmony_ci } 2342e5b6d6dSopenharmony_ci dupBox = new Box(BoxLayout.Y_AXIS); 2352e5b6d6dSopenharmony_ci 2362e5b6d6dSopenharmony_ci // Set up the components 2372e5b6d6dSopenharmony_ci filePanel.setLayout(new BorderLayout()); 2382e5b6d6dSopenharmony_ci groupPanel.setLayout(new BorderLayout()); 2392e5b6d6dSopenharmony_ci itemPanel.setLayout(new BorderLayout()); 2402e5b6d6dSopenharmony_ci 2412e5b6d6dSopenharmony_ci filePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), 2422e5b6d6dSopenharmony_ci Resources.getTranslation("basestats_file_group"))); 2432e5b6d6dSopenharmony_ci groupPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), 2442e5b6d6dSopenharmony_ci Resources.getTranslation("basestats_group_group"))); 2452e5b6d6dSopenharmony_ci itemPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), 2462e5b6d6dSopenharmony_ci Resources.getTranslation("basestats_item_group"))); 2472e5b6d6dSopenharmony_ci 2482e5b6d6dSopenharmony_ci titleLabel.setFont(new Font("SansSerif",Font.PLAIN,18)); 2492e5b6d6dSopenharmony_ci 2502e5b6d6dSopenharmony_ci fileButton.setMnemonic(RBManagerMenuBar.getKeyEventKey(Resources.getTranslation("button_add_file_trigger"))); 2512e5b6d6dSopenharmony_ci groupButton.setMnemonic(RBManagerMenuBar.getKeyEventKey(Resources.getTranslation("button_add_group_trigger"))); 2522e5b6d6dSopenharmony_ci itemButton.setMnemonic(RBManagerMenuBar.getKeyEventKey(Resources.getTranslation("button_add_resource_trigger"))); 2532e5b6d6dSopenharmony_ci 2542e5b6d6dSopenharmony_ci // Add listeners 2552e5b6d6dSopenharmony_ci fileButton.addActionListener(new ActionListener(){ 2562e5b6d6dSopenharmony_ci public void actionPerformed(ActionEvent ev) { 2572e5b6d6dSopenharmony_ci Container c = ((JButton)ev.getSource()).getParent(); 2582e5b6d6dSopenharmony_ci RBManagerGUI gui = null; 2592e5b6d6dSopenharmony_ci while (!(c.getParent() instanceof RBManagerGUI)) c = c.getParent(); 2602e5b6d6dSopenharmony_ci gui = (RBManagerGUI)c.getParent(); 2612e5b6d6dSopenharmony_ci gui.createResourceFile(); 2622e5b6d6dSopenharmony_ci } 2632e5b6d6dSopenharmony_ci }); 2642e5b6d6dSopenharmony_ci 2652e5b6d6dSopenharmony_ci groupButton.addActionListener(new ActionListener(){ 2662e5b6d6dSopenharmony_ci public void actionPerformed(ActionEvent ev) { 2672e5b6d6dSopenharmony_ci Container c = ((JButton)ev.getSource()).getParent(); 2682e5b6d6dSopenharmony_ci RBManagerGUI gui = null; 2692e5b6d6dSopenharmony_ci while (!(c.getParent() instanceof RBManagerGUI)) c = c.getParent(); 2702e5b6d6dSopenharmony_ci gui = (RBManagerGUI)c.getParent(); 2712e5b6d6dSopenharmony_ci gui.createBundleGroup(); 2722e5b6d6dSopenharmony_ci } 2732e5b6d6dSopenharmony_ci }); 2742e5b6d6dSopenharmony_ci 2752e5b6d6dSopenharmony_ci itemButton.addActionListener(new ActionListener(){ 2762e5b6d6dSopenharmony_ci public void actionPerformed(ActionEvent ev) { 2772e5b6d6dSopenharmony_ci Container c = ((JButton)ev.getSource()).getParent(); 2782e5b6d6dSopenharmony_ci RBManagerGUI gui = null; 2792e5b6d6dSopenharmony_ci while (!(c.getParent() instanceof RBManagerGUI)) c = c.getParent(); 2802e5b6d6dSopenharmony_ci gui = (RBManagerGUI)c.getParent(); 2812e5b6d6dSopenharmony_ci gui.createBundleItem(); 2822e5b6d6dSopenharmony_ci } 2832e5b6d6dSopenharmony_ci }); 2842e5b6d6dSopenharmony_ci 2852e5b6d6dSopenharmony_ci // Update the display 2862e5b6d6dSopenharmony_ci filePanel.removeAll(); 2872e5b6d6dSopenharmony_ci filePanel.add(numFileLabel, BorderLayout.NORTH); 2882e5b6d6dSopenharmony_ci filePanel.add(fileScroll, BorderLayout.CENTER); 2892e5b6d6dSopenharmony_ci filePanel.add(fileButton, BorderLayout.SOUTH); 2902e5b6d6dSopenharmony_ci 2912e5b6d6dSopenharmony_ci groupPanel.removeAll(); 2922e5b6d6dSopenharmony_ci groupPanel.add(numGroupLabel, BorderLayout.NORTH); 2932e5b6d6dSopenharmony_ci groupPanel.add(groupScroll, BorderLayout.CENTER); 2942e5b6d6dSopenharmony_ci groupPanel.add(groupButton, BorderLayout.SOUTH); 2952e5b6d6dSopenharmony_ci 2962e5b6d6dSopenharmony_ci dupBox.removeAll(); 2972e5b6d6dSopenharmony_ci dupBox.add(numDupLabel); 2982e5b6d6dSopenharmony_ci dupBox.add(dupScroll); 2992e5b6d6dSopenharmony_ci 3002e5b6d6dSopenharmony_ci itemPanel.removeAll(); 3012e5b6d6dSopenharmony_ci itemPanel.add(numItemLabel, BorderLayout.NORTH); 3022e5b6d6dSopenharmony_ci itemPanel.add(dupBox, BorderLayout.CENTER); 3032e5b6d6dSopenharmony_ci itemPanel.add(itemButton, BorderLayout.SOUTH); 3042e5b6d6dSopenharmony_ci 3052e5b6d6dSopenharmony_ci mainBox.removeAll(); 3062e5b6d6dSopenharmony_ci mainBox.add(titleLabel); 3072e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(10)); 3082e5b6d6dSopenharmony_ci mainBox.add(filePanel); 3092e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(10)); 3102e5b6d6dSopenharmony_ci mainBox.add(groupPanel); 3112e5b6d6dSopenharmony_ci mainBox.add(Box.createVerticalStrut(10)); 3122e5b6d6dSopenharmony_ci mainBox.add(itemPanel); 3132e5b6d6dSopenharmony_ci 3142e5b6d6dSopenharmony_ci removeAll(); 3152e5b6d6dSopenharmony_ci if (!(getLayout() instanceof BorderLayout)) 3162e5b6d6dSopenharmony_ci setLayout(new BorderLayout()); 3172e5b6d6dSopenharmony_ci add(mainBox, BorderLayout.CENTER); 3182e5b6d6dSopenharmony_ci updateComponents(); 3192e5b6d6dSopenharmony_ci } else { 3202e5b6d6dSopenharmony_ci removeAll(); 3212e5b6d6dSopenharmony_ci } 3222e5b6d6dSopenharmony_ci repaint(); 3232e5b6d6dSopenharmony_ci } 3242e5b6d6dSopenharmony_ci 3252e5b6d6dSopenharmony_ci public void updateComponents() { 3262e5b6d6dSopenharmony_ci if (bundle != null) { 3272e5b6d6dSopenharmony_ci int untranslated = bundle.getUntranslatedItemsSize(); 3282e5b6d6dSopenharmony_ci 3292e5b6d6dSopenharmony_ci jLabelStatsTitle.setText(bundle.name); 3302e5b6d6dSopenharmony_ci 3312e5b6d6dSopenharmony_ci jTextFieldStatsName.setText(bundle.name == null ? Resources.getTranslation("untitled") : bundle.name); 3322e5b6d6dSopenharmony_ci jTextFieldStatsComment.setText(bundle.comment == null ? "" : bundle.comment); 3332e5b6d6dSopenharmony_ci jTextFieldStatsManager.setText(bundle.manager == null ? "" : bundle.manager); 3342e5b6d6dSopenharmony_ci jTextFieldStatsLanguage.setText(bundle.language == null ? "" : bundle.language); 3352e5b6d6dSopenharmony_ci jTextFieldStatsCountry.setText(bundle.country == null ? "" : bundle.country); 3362e5b6d6dSopenharmony_ci jTextFieldStatsVariant.setText(bundle.variant == null ? "" : bundle.variant); 3372e5b6d6dSopenharmony_ci jLabelStatsNumTrans.setText(Resources.getTranslation("languagestats_item_count") + " " + 3382e5b6d6dSopenharmony_ci String.valueOf(bundle.allItems.size())); 3392e5b6d6dSopenharmony_ci jLabelStatsNumUntrans.setText(Resources.getTranslation("languagestats_translation_count") + 3402e5b6d6dSopenharmony_ci String.valueOf(untranslated)); 3412e5b6d6dSopenharmony_ci } else if (rbm == null) { 3422e5b6d6dSopenharmony_ci removeAll(); 3432e5b6d6dSopenharmony_ci } 3442e5b6d6dSopenharmony_ci 3452e5b6d6dSopenharmony_ci } 3462e5b6d6dSopenharmony_ci 3472e5b6d6dSopenharmony_ci void updateBundleInfo() { 3482e5b6d6dSopenharmony_ci bundle.name = jTextFieldStatsName.getText().trim(); 3492e5b6d6dSopenharmony_ci bundle.comment = jTextFieldStatsComment.getText().trim(); 3502e5b6d6dSopenharmony_ci bundle.manager = jTextFieldStatsManager.getText().trim(); 3512e5b6d6dSopenharmony_ci bundle.language = jTextFieldStatsLanguage.getText().trim(); 3522e5b6d6dSopenharmony_ci bundle.country = jTextFieldStatsCountry.getText().trim(); 3532e5b6d6dSopenharmony_ci bundle.variant = jTextFieldStatsVariant.getText().trim(); 3542e5b6d6dSopenharmony_ci updateButton.setEnabled(false); 3552e5b6d6dSopenharmony_ci } 3562e5b6d6dSopenharmony_ci 3572e5b6d6dSopenharmony_ci public RBStatisticsPanel() { 3582e5b6d6dSopenharmony_ci super(); 3592e5b6d6dSopenharmony_ci bundle = null; 3602e5b6d6dSopenharmony_ci rbm = null; 3612e5b6d6dSopenharmony_ci } 3622e5b6d6dSopenharmony_ci 3632e5b6d6dSopenharmony_ci} 3642e5b6d6dSopenharmony_ci 3652e5b6d6dSopenharmony_ciclass ButtonEnablerFocusListener implements FocusListener { 3662e5b6d6dSopenharmony_ci JButton button; 3672e5b6d6dSopenharmony_ci String beforeText = null; 3682e5b6d6dSopenharmony_ci 3692e5b6d6dSopenharmony_ci public ButtonEnablerFocusListener(JButton button) { 3702e5b6d6dSopenharmony_ci super(); 3712e5b6d6dSopenharmony_ci this.button = button; 3722e5b6d6dSopenharmony_ci } 3732e5b6d6dSopenharmony_ci 3742e5b6d6dSopenharmony_ci public void focusGained(FocusEvent ev) { 3752e5b6d6dSopenharmony_ci Object o = ev.getSource(); 3762e5b6d6dSopenharmony_ci if (o instanceof JTextComponent) { 3772e5b6d6dSopenharmony_ci JTextComponent jtc = (JTextComponent)o; 3782e5b6d6dSopenharmony_ci beforeText = jtc.getText(); 3792e5b6d6dSopenharmony_ci } 3802e5b6d6dSopenharmony_ci } 3812e5b6d6dSopenharmony_ci 3822e5b6d6dSopenharmony_ci public void focusLost(FocusEvent ev) { 3832e5b6d6dSopenharmony_ci Object o = ev.getSource(); 3842e5b6d6dSopenharmony_ci if (o instanceof JTextComponent) { 3852e5b6d6dSopenharmony_ci JTextComponent jtc = (JTextComponent)o; 3862e5b6d6dSopenharmony_ci String afterText = jtc.getText(); 3872e5b6d6dSopenharmony_ci if (!afterText.equals(beforeText)) button.setEnabled(true); 3882e5b6d6dSopenharmony_ci } else button.setEnabled(true); 3892e5b6d6dSopenharmony_ci } 3902e5b6d6dSopenharmony_ci} 3912e5b6d6dSopenharmony_ci 392