Source Code Cross Referenced for RBManagerGUI.java in  » Internationalization-Localization » RBManager » com » ibm » rbm » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » RBManager » com.ibm.rbm.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *****************************************************************************
0003:         * Copyright (C) 2000-2004, International Business Machines Corporation and  *
0004:         * others. All Rights Reserved.                                              *
0005:         *****************************************************************************
0006:         */
0007:        package com.ibm.rbm.gui;
0008:
0009:        import java.awt.*;
0010:        import java.awt.event.*;
0011:        import java.io.*;
0012:        import java.util.*;
0013:        import javax.swing.*;
0014:        import javax.swing.event.*;
0015:        import javax.swing.tree.*;
0016:
0017:        import com.ibm.rbm.*;
0018:
0019:        /**
0020:         * The Graphical User Interface for working with and through a Resource Bundle Manager. The GUI has no public main
0021:         * method. It is instead instantiated from running the main method in RBManager. For help with using this interface,
0022:         * consult the documentation included in the project.
0023:         * 
0024:         * @author Jared Jackson
0025:         * @see com.ibm.rbm.RBManager
0026:         */
0027:        public class RBManagerGUI extends JFrame implements  ActionListener,
0028:                MouseListener, ChangeListener, TreeSelectionListener {
0029:            // CONSTANTS
0030:            private static final int buffer = 20;
0031:            private static final Dimension dimMain = new Dimension(750, 550);
0032:            private static final Dimension dimMainMax = new Dimension(2000,
0033:                    1500);
0034:            private static final Dimension dimMainMin = new Dimension(550, 350);
0035:            private static final Dimension dimTop = new Dimension(dimMain.width
0036:                    - buffer, 50);
0037:            private static final Dimension dimTopMax = new Dimension(
0038:                    dimMainMax.width - buffer, 50);
0039:            private static final Dimension dimTopMin = new Dimension(
0040:                    dimMainMin.width - buffer, 50);
0041:            private static final Dimension dimBottom = new Dimension(
0042:                    dimMain.width - buffer, dimMain.height - dimTop.height
0043:                            - buffer);
0044:            private static final Dimension dimBottomMax = new Dimension(
0045:                    dimMainMax.width - buffer, dimMainMax.height
0046:                            - dimTopMin.height - buffer);
0047:            private static final Dimension dimBottomMin = new Dimension(
0048:                    dimMainMin.width - buffer, dimMainMin.height
0049:                            - dimTopMax.height - buffer);
0050:            private static final Dimension dimLeft = new Dimension(175,
0051:                    dimBottom.height - buffer);
0052:            private static final Dimension dimRight = new Dimension(
0053:                    dimMain.width - dimLeft.width - buffer, dimBottom.height
0054:                            - buffer);
0055:
0056:            /**
0057:             * Used for toggling the debug mode
0058:             */
0059:            public static final boolean debug = false;
0060:            /**
0061:             * Used to count debug messages
0062:             */
0063:            public static int debugcount = 0;
0064:
0065:            // member declarations
0066:
0067:            // ** DATA **
0068:            RBManager rbm = null;
0069:            String userName = Resources.getTranslation("unknown_user");
0070:
0071:            DefaultMutableTreeNode activeNode = null;
0072:
0073:            // ** MAIN MENU **
0074:            RBManagerMenuBar jMenuBarMain = null;
0075:
0076:            // ** CONTENT PANES **
0077:            Box boxMain = new Box(BoxLayout.Y_AXIS);
0078:            //JPanel       jPanelTop = new JPanel();
0079:            JPanel jPanelBottom = new JPanel();
0080:            JSplitPane jSplitPaneMain = new JSplitPane(
0081:                    JSplitPane.HORIZONTAL_SPLIT);
0082:
0083:            // ** SPLIT PANE COMPONENTS **
0084:            JTree jTreeDisplay = new JTree();
0085:            JTabbedPane jTabbedPaneMain = new JTabbedPane();
0086:            RBStatisticsPanel jPanelStats = new RBStatisticsPanel();
0087:            RBUntranslatedPanel jPanelUntrans = new RBUntranslatedPanel(this );
0088:            RBGroupPanel jPanelGroups = new RBGroupPanel(this );
0089:            RBSearchPanel jPanelSearch = new RBSearchPanel(this );
0090:            JScrollPane jScrollPaneTree = new JScrollPane(jTreeDisplay,
0091:                    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
0092:                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
0093:            // ** PROJECT VIEW SPLIT PANE COMPONENTS
0094:            JTabbedPane treeTabbedPane = new JTabbedPane();
0095:            JTree projectTree = new JTree();
0096:            JScrollPane projectScrollPane = new JScrollPane(projectTree,
0097:                    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
0098:                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
0099:            RBProjectItemPanel projectPanel = new RBProjectItemPanel(this );
0100:            RBProject project = null;
0101:
0102:            // ** File Chooser **
0103:            JFileChooser openFileChooser = new JFileChooser();
0104:            JFileChooser saveFileChooser = new JFileChooser();
0105:            JFileChooser projectFileChooser = new JFileChooser();
0106:
0107:            /**
0108:             * Creation of the GUI should be immediately followed by the method calls to initComponents() and setVisible(true).
0109:             * These methods were not called by default for programming discretion
0110:             */
0111:
0112:            public RBManagerGUI() {
0113:            }
0114:
0115:            /**
0116:             * Inherits from JFrame.validate(), with some component updates
0117:             */
0118:
0119:            public void validate() {
0120:                super .validate();
0121:                updateDisplayPanels();
0122:            }
0123:
0124:            /**
0125:             * Initial construction of all of the GUI components. This method should be called immediately following the
0126:             * construction of the GUI object.
0127:             */
0128:
0129:            public void initComponents() throws Exception {
0130:                this 
0131:                        .setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
0132:                // the following code sets the frame's initial state
0133:
0134:                openFileChooser
0135:                        .setFileFilter(new javax.swing.filechooser.FileFilter() {
0136:                            public boolean accept(File f) {
0137:                                if (f.isDirectory())
0138:                                    return true;
0139:
0140:                                String name = f.getName();
0141:                                if (!(name.toLowerCase()
0142:                                        .endsWith(".properties")))
0143:                                    return false;
0144:                                if (name.indexOf("_") > 0)
0145:                                    return false;
0146:                                return true;
0147:                            }
0148:
0149:                            public String getDescription() {
0150:                                return Resources
0151:                                        .getTranslation("dialog_file_filter_description");
0152:                            }
0153:                        });
0154:
0155:                saveFileChooser
0156:                        .setFileFilter(new javax.swing.filechooser.FileFilter() {
0157:                            public boolean accept(File f) {
0158:                                if (f.isDirectory())
0159:                                    return true;
0160:
0161:                                String name = f.getName();
0162:                                if (!(name.toLowerCase()
0163:                                        .endsWith(".properties")))
0164:                                    return false;
0165:                                if (name.indexOf("_") > 0)
0166:                                    return false;
0167:                                return true;
0168:                            }
0169:
0170:                            public String getDescription() {
0171:                                return Resources
0172:                                        .getTranslation("dialog_file_filter_description");
0173:                            }
0174:                        });
0175:
0176:                projectFileChooser
0177:                        .setFileFilter(new javax.swing.filechooser.FileFilter() {
0178:                            public boolean accept(File f) {
0179:                                if (f.isDirectory())
0180:                                    return true;
0181:
0182:                                String name = f.getName();
0183:                                if (!(name.toLowerCase().endsWith(".rbproject")))
0184:                                    return false;
0185:                                return true;
0186:                            }
0187:
0188:                            public String getDescription() {
0189:                                return Resources
0190:                                        .getTranslation("dialog_project_filter_description");
0191:                            }
0192:                        });
0193:
0194:                // ** The Main program icon **
0195:                setIconImage((new ImageIcon(getClass().getResource(
0196:                        "images/tree_icon_bundle.gif"))).getImage());
0197:
0198:                // ** MAIN MENU BAR ITEMS **
0199:                jMenuBarMain = new RBManagerMenuBar(this );
0200:
0201:                // ** DISPLAY TREE **
0202:                //jScrollPaneTree.setSize(dimLeft);
0203:                updateDisplayTree();
0204:                updateProjectTree();
0205:                updateProjectPanels();
0206:
0207:                jPanelStats.setSize(dimRight);
0208:                jPanelUntrans.setSize(dimRight);
0209:                jPanelGroups.setSize(dimRight);
0210:                jPanelSearch.setSize(dimRight);
0211:
0212:                // ** MAIN TABBED PANE **
0213:                jTabbedPaneMain.setSize(dimRight);
0214:                jTabbedPaneMain.addTab(Resources
0215:                        .getTranslation("tab_statistics"), jPanelStats);
0216:                jTabbedPaneMain.addTab(Resources
0217:                        .getTranslation("tab_untranslated"), jPanelUntrans);
0218:                jTabbedPaneMain.addTab(Resources.getTranslation("tab_groups"),
0219:                        jPanelGroups);
0220:                jTabbedPaneMain.addTab(Resources.getTranslation("tab_search"),
0221:                        jPanelSearch);
0222:
0223:                // ** LEFT TABBED PANE **
0224:                treeTabbedPane.setSize(dimLeft);
0225:                treeTabbedPane.setPreferredSize(dimLeft);
0226:                treeTabbedPane.addTab(Resources.getTranslation("tab_bundle"),
0227:                        jScrollPaneTree);
0228:                treeTabbedPane.addTab(Resources.getTranslation("tab_project"),
0229:                        projectScrollPane);
0230:                treeTabbedPane.addChangeListener(this );
0231:
0232:                // ** MAIN SPLIT PANE **
0233:                //jSplitPaneMain.setSize(dimBottom);
0234:                //jSplitPaneMain.setLeftComponent(jScrollPaneTree);
0235:                jSplitPaneMain.setLeftComponent(treeTabbedPane);
0236:                jSplitPaneMain.setRightComponent(jTabbedPaneMain);
0237:                jSplitPaneMain.setContinuousLayout(true);
0238:
0239:                // ** BOTTOM PANEL **
0240:                //jPanelBottom.setPreferredSize(dimBottom);
0241:                jPanelBottom.setMaximumSize(dimBottomMax);
0242:                jPanelBottom.setMinimumSize(dimBottomMin);
0243:                jPanelBottom.setBorder(BorderFactory
0244:                        .createLineBorder(Color.black));
0245:                jPanelBottom.setLayout(new BorderLayout(1, 1));
0246:                jPanelBottom.removeAll();
0247:                jPanelBottom.add(jSplitPaneMain, BorderLayout.CENTER);
0248:
0249:                // ** MAIN FRAME SETUP **
0250:                dimMain.height += jMenuBarMain.getPreferredSize().height;
0251:                setSize(dimMain);
0252:                ((JComponent) getContentPane()).setMaximumSize(dimMainMax);
0253:                ((JComponent) getContentPane()).setMinimumSize(dimMainMin);
0254:                setJMenuBar(jMenuBarMain);
0255:                getContentPane().removeAll();
0256:                getContentPane().add(jPanelBottom, BorderLayout.CENTER);
0257:                setTitle(Resources.getTranslation("resource_bundle_manager"));
0258:                validateTree();
0259:
0260:                addWindowListener(new java.awt.event.WindowAdapter() {
0261:                    public void windowClosing(java.awt.event.WindowEvent e) {
0262:                        this WindowClosing(e);
0263:                    }
0264:                });
0265:            }
0266:
0267:            private boolean mShown = false;
0268:
0269:            /**
0270:             * Reveals the private method of JFrame.validateTree()
0271:             */
0272:
0273:            public void validateMyTree() {
0274:                validateTree();
0275:            }
0276:
0277:            /**
0278:             * Creates a new Resource File (i.e. English, English Canada, Finnish, etc.)
0279:             */
0280:
0281:            public void createResourceFile() {
0282:                new ResourceCreationDialog(rbm, this , Resources
0283:                        .getTranslation("dialog_title_new_file"), true);
0284:            }
0285:
0286:            /**
0287:             * Creates a new group for grouping BundleItems
0288:             */
0289:
0290:            public void createBundleGroup() {
0291:                new BundleGroupCreationDialog(rbm, this , Resources
0292:                        .getTranslation("dialog_title_new_group"), true);
0293:                updateDisplayPanels();
0294:            }
0295:
0296:            /**
0297:             * Creates a new BundleItem
0298:             */
0299:
0300:            public void createBundleItem() {
0301:                new BundleItemCreationDialog(rbm, this , Resources
0302:                        .getTranslation("dialog_title_new_item"), true);
0303:                updateDisplayPanels();
0304:                updateProjectTree();
0305:            }
0306:
0307:            /**
0308:             * Handles events generated
0309:             */
0310:
0311:            public void valueChanged(TreeSelectionEvent ev) {
0312:                if (ev.getSource() == projectTree)
0313:                    updateProjectPanels();
0314:                else if (ev.getSource() == jTreeDisplay) {
0315:                    TreePath selPath = jTreeDisplay.getSelectionPath();
0316:                    activeNode = (DefaultMutableTreeNode) selPath
0317:                            .getLastPathComponent();
0318:                    updateDisplayPanels();
0319:                    /*
0320:                    int selRow = jTreeDisplay.getRowForLocation(ev.getX(), ev.getY());
0321:                    TreePath selPath = jTreeDisplay.getPathForLocation(ev.getX(), ev.getY());
0322:                    if (selRow != -1) {
0323:                    if (ev.getClickCount() == 1 && ev.getSource() == jTreeDisplay) {
0324:                    	
0325:                    	System.out.println("Other tree");
0326:                    } else if (ev.getClickCount() == 1 && ev.getSource() == projectTree) {
0327:                    	System.out.println("Mouse pressed");
0328:                    	updateProjectPanels();	
0329:                    } else System.out.println(String.valueOf(ev.getClickCount()) + " " + ev.getSource().toString());
0330:                    
0331:                     */
0332:                }
0333:            }
0334:
0335:            public void stateChanged(ChangeEvent ev) {
0336:                if (ev.getSource() == treeTabbedPane) {
0337:                    int index = treeTabbedPane.getSelectedIndex();
0338:                    String title = treeTabbedPane.getTitleAt(index);
0339:                    if (title.equals(Resources.getTranslation("tab_bundle"))) {
0340:                        jSplitPaneMain.setRightComponent(jTabbedPaneMain);
0341:                        updateDisplayPanels();
0342:                    } else if (title.equals(Resources
0343:                            .getTranslation("tab_project"))) {
0344:                        jSplitPaneMain.setRightComponent(projectPanel);
0345:                        updateProjectPanels();
0346:                    }
0347:                }
0348:            }
0349:
0350:            public void actionPerformed(ActionEvent ev) {
0351:                if (ev.getID() == ActionEvent.ACTION_PERFORMED) {
0352:                    if (ev.getSource() instanceof  JMenuItem
0353:                            && ((JMenuItem) ev.getSource()).getName() != null
0354:                            && ((JMenuItem) ev.getSource()).getName()
0355:                                    .startsWith("__")) { // Menu -> File -> __Recent File
0356:                        // This item is a recent file selection. We need to open that file
0357:                        String fileLocation = ((JMenuItem) ev.getSource())
0358:                                .getName();
0359:                        fileLocation = fileLocation.substring(2, fileLocation
0360:                                .length());
0361:                        try {
0362:                            rbm = new RBManager(new File(fileLocation));
0363:                            updateDisplayTree();
0364:                            updateProjectTree();
0365:                            updateProjectPanels();
0366:                        } catch (IOException ioe) {
0367:                            JOptionPane
0368:                                    .showMessageDialog(
0369:                                            this ,
0370:                                            Resources
0371:                                                    .getTranslation(
0372:                                                            "error_opening_file",
0373:                                                            ev
0374:                                                                    .getActionCommand()),
0375:                                            Resources
0376:                                                    .getTranslation("dialog_title_error_opening_file"),
0377:                                            JOptionPane.ERROR_MESSAGE);
0378:                            rbm = null;
0379:                        }
0380:                    } else if (ev.getActionCommand().equals(
0381:                            Resources.getTranslation("menu_tree_save"))
0382:                            && ((JMenuItem) ev.getSource()).getName() != null) { // Popup Tree Menu -> Save
0383:                        String selectedEncoding = ((JMenuItem) ev.getSource())
0384:                                .getName();
0385:                        saveResources(selectedEncoding);
0386:                    } else if (ev.getActionCommand().equals(
0387:                            Resources.getTranslation("menu_tree_hide"))
0388:                            && ((JMenuItem) ev.getSource()).getName() != null) { // Popup Tree Menu -> Hide
0389:                        String selectedEncoding = ((JMenuItem) ev.getSource())
0390:                                .getName();
0391:                        // Should I prompt for this?
0392:                        hideResources(selectedEncoding);
0393:                    } else if (ev.getActionCommand().equals(
0394:                            Resources.getTranslation("menu_tree_delete"))
0395:                            && ((JMenuItem) ev.getSource()).getName() != null) { // Popup Tree Menu -> Delete
0396:                        String selectedEncoding = ((JMenuItem) ev.getSource())
0397:                                .getName();
0398:                        int response = JOptionPane
0399:                                .showConfirmDialog(
0400:                                        this ,
0401:                                        Resources
0402:                                                .getTranslation("dialog_delete_warning"),
0403:                                        Resources
0404:                                                .getTranslation("dialog_title_quit"),
0405:                                        JOptionPane.YES_NO_CANCEL_OPTION,
0406:                                        JOptionPane.WARNING_MESSAGE);
0407:                        if (response == JOptionPane.YES_OPTION) {
0408:                            deleteResources(selectedEncoding);
0409:                        }
0410:                    } else if (ev.getActionCommand().equals(
0411:                            Resources.getTranslation("menu_tree_new_project"))) {
0412:                        String response = JOptionPane
0413:                                .showInputDialog(
0414:                                        this , // Popup Project Menu -> New Project
0415:                                        Resources
0416:                                                .getTranslation("dialog_new_project"),
0417:                                        Resources
0418:                                                .getTranslation("dialog_title_new_project"),
0419:                                        JOptionPane.QUESTION_MESSAGE);
0420:                        if (response == null || response.trim().equals(""))
0421:                            return;
0422:                        project = new RBProject(response);
0423:                        updateProjectTree();
0424:                        updateProjectPanels();
0425:                    } else if (ev.getActionCommand().equals(
0426:                            Resources.getTranslation("menu_tree_open_project"))) {
0427:                        int result = projectFileChooser.showOpenDialog(this ); // Popup Project Menu -> Open Project
0428:                        if (result == JFileChooser.APPROVE_OPTION) {
0429:                            File f = projectFileChooser.getSelectedFile();
0430:                            try {
0431:                                project = new RBProject(f);
0432:                                updateProjectTree();
0433:                                updateProjectPanels();
0434:                            } catch (Exception ex) {
0435:                                JOptionPane
0436:                                        .showMessageDialog(
0437:                                                this ,
0438:                                                Resources
0439:                                                        .getTranslation("error_creating_project"),
0440:                                                Resources
0441:                                                        .getTranslation("dialog_title_error"),
0442:                                                JOptionPane.ERROR_MESSAGE);
0443:                            }
0444:                        }
0445:                    } else if (ev.getActionCommand().equals(
0446:                            Resources.getTranslation("menu_tree_save_project"))) {
0447:                        int result = projectFileChooser.showSaveDialog(this ); // Popup Project Menu -> Save Project
0448:                        if (result == JFileChooser.APPROVE_OPTION) {
0449:                            File f = projectFileChooser.getSelectedFile();
0450:                            try {
0451:                                project.write(f);
0452:                            } catch (Exception ex) {
0453:                                JOptionPane
0454:                                        .showMessageDialog(
0455:                                                this ,
0456:                                                Resources
0457:                                                        .getTranslation("error_saving_project"),
0458:                                                Resources
0459:                                                        .getTranslation("dialog_title_error"),
0460:                                                JOptionPane.ERROR_MESSAGE);
0461:                            }
0462:                        }
0463:                    } else if (ev
0464:                            .getActionCommand()
0465:                            .equals(
0466:                                    Resources
0467:                                            .getTranslation("menu_tree_add_project_bundle"))) {
0468:                        int result = openFileChooser.showOpenDialog(this ); // Popup Project Menu -> Add Bundle
0469:                        if (result == JFileChooser.APPROVE_OPTION) {
0470:                            File f = openFileChooser.getSelectedFile();
0471:                            try {
0472:                                project.addBundle(f.getAbsolutePath());
0473:                                updateProjectTree();
0474:                                updateProjectPanels();
0475:                            } catch (Exception ex) {
0476:                                JOptionPane
0477:                                        .showMessageDialog(
0478:                                                this ,
0479:                                                Resources
0480:                                                        .getTranslation("error_adding_project_bundle"),
0481:                                                Resources
0482:                                                        .getTranslation("dialog_title_error"),
0483:                                                JOptionPane.ERROR_MESSAGE);
0484:                            }
0485:                        }
0486:                    } else if (ev
0487:                            .getActionCommand()
0488:                            .equals(
0489:                                    Resources
0490:                                            .getTranslation("menu_tree_remove_project_bundle"))) {
0491:                        String bundleName = ((JMenuItem) ev.getSource())
0492:                                .getName(); // Popup Project Menu -> Remove Bundle
0493:                        project.removeBundle(bundleName);
0494:                        updateProjectTree();
0495:                        updateProjectPanels();
0496:                    } else if (ev
0497:                            .getActionCommand()
0498:                            .equals(
0499:                                    Resources
0500:                                            .getTranslation("menu_tree_select_project_bundle"))) {
0501:                        String bundleName = ((JMenuItem) ev.getSource())
0502:                                .getName(); // Popup Project Menu -> Select Bundle
0503:                        RBManager bundle = project.getBundle(bundleName);
0504:                        rbm = bundle;
0505:                        updateDisplayTree();
0506:                        updateDisplayPanels();
0507:                    } else if (ev.getActionCommand().equals(
0508:                            Resources.getTranslation("menu_file_quit"))) {
0509:                        // Menu -> File -> Quit
0510:                        this WindowClosing(null);
0511:                        return;
0512:                    } else if (ev.getActionCommand().equals(
0513:                            Resources.getTranslation("menu_file_new"))) {
0514:                        // Menu -> File -> New Resource Bundle
0515:                        promptForSave(null);
0516:                        String oldUser = getUser();
0517:                        if (rbm != null
0518:                                && rbm.getUser() != null
0519:                                && !(rbm.getUser().equals(Resources
0520:                                        .getTranslation("unknown_user"))))
0521:                            oldUser = rbm.getUser();
0522:                        String response = JOptionPane
0523:                                .showInputDialog(
0524:                                        this ,
0525:                                        Resources
0526:                                                .getTranslation("dialog_new_baseclass"),
0527:                                        Resources
0528:                                                .getTranslation("dialog_title_new_bundle"),
0529:                                        JOptionPane.QUESTION_MESSAGE);
0530:                        if (response != null) {
0531:                            // Test the response for white space
0532:                            if (response.indexOf(" ") > 0
0533:                                    || response.indexOf("\t") > 0
0534:                                    || response.indexOf("\n") > 0) {
0535:                                JOptionPane
0536:                                        .showMessageDialog(
0537:                                                this ,
0538:                                                Resources
0539:                                                        .getTranslation("error_baseclass_whitespace")
0540:                                                        + "\n"
0541:                                                        + Resources
0542:                                                                .getTranslation("error_bundle_not_created"),
0543:                                                Resources
0544:                                                        .getTranslation("dialog_title_error_creating_bundle"),
0545:                                                JOptionPane.ERROR_MESSAGE);
0546:                            } else {
0547:                                rbm = new RBManager(response);
0548:                                updateDisplayTree();
0549:                                updateProjectTree();
0550:                                updateProjectPanels();
0551:                                updateDisplayPanels();
0552:                            }
0553:                        }
0554:                        // Update the user information
0555:                        if (oldUser.equals(Resources
0556:                                .getTranslation("unknown_user"))) {
0557:                            String user = JOptionPane
0558:                                    .showInputDialog(
0559:                                            this ,
0560:                                            Resources
0561:                                                    .getTranslation("dialog_user_name"),
0562:                                            Resources
0563:                                                    .getTranslation("dialog_title_user_name"),
0564:                                            JOptionPane.QUESTION_MESSAGE);
0565:                            if (user != null && !(user.equals("")))
0566:                                setUser(user);
0567:                        } else
0568:                            rbm.setUser(oldUser);
0569:                    } else if (ev.getActionCommand().equals(
0570:                            Resources.getTranslation("menu_file_open"))) {
0571:                        // Menu -> File -> Open Resource Bundle
0572:                        promptForSave(null);
0573:                        String oldUser = getUser();
0574:                        if (rbm != null
0575:                                && rbm.getUser() != null
0576:                                && !(rbm.getUser().equals(Resources
0577:                                        .getTranslation("unknown_user"))))
0578:                            oldUser = rbm.getUser();
0579:                        openFileChooser.setSelectedFile(new File("Resources"
0580:                                + File.separator + "RBManager.properties"));
0581:                        int status = openFileChooser.showOpenDialog(this );
0582:                        if (status == JFileChooser.CANCEL_OPTION) {
0583:                            // File opening canceled
0584:                        } else if (status == JFileChooser.ERROR_OPTION) {
0585:                            // Error in file open
0586:                        } else {
0587:                            // A file has been selected
0588:                            try {
0589:                                rbm = new RBManager(openFileChooser
0590:                                        .getSelectedFile());
0591:                                updateDisplayTree();
0592:                                updateProjectTree();
0593:                                updateProjectPanels();
0594:                            } catch (IOException ioe) {
0595:                                // Should provide some alert here
0596:                                System.err.println("Could not open the file "
0597:                                        + openFileChooser.getSelectedFile()
0598:                                                .getAbsolutePath() + ": "
0599:                                        + ioe.getMessage());
0600:                                rbm = null;
0601:                            }
0602:                        }
0603:                        if (rbm == null)
0604:                            return;
0605:                        // Update the user information
0606:                        if (oldUser.equals(Resources
0607:                                .getTranslation("unknown_user"))) {
0608:                            String user = JOptionPane
0609:                                    .showInputDialog(
0610:                                            this ,
0611:                                            Resources
0612:                                                    .getTranslation("dialog_user_name"),
0613:                                            Resources
0614:                                                    .getTranslation("dialog_title_user_name"),
0615:                                            JOptionPane.QUESTION_MESSAGE);
0616:                            if (user != null && !(user.equals("")))
0617:                                setUser(user);
0618:                        } else
0619:                            rbm.setUser(oldUser);
0620:                    } else if (ev.getActionCommand().equals(
0621:                            Resources.getTranslation("menu_file_save"))) {
0622:                        // Menu -> File -> Save Resource Bundle
0623:                        saveResources();
0624:                    } else if (ev.getActionCommand().equals(
0625:                            Resources.getTranslation("menu_file_saveas"))) {
0626:                        // Menu -> File -> Save Resource Bundle As
0627:                        saveResourcesAs();
0628:                    } else if (ev
0629:                            .getActionCommand()
0630:                            .equals(
0631:                                    Resources
0632:                                            .getTranslation("menu_file_import_properties"))) {
0633:                        // Menu -> File -> Import -> Properties
0634:                        if (rbm == null || rbm.getBundles() == null)
0635:                            return;
0636:                        RBPropertiesImporter importer = new RBPropertiesImporter(
0637:                                Resources
0638:                                        .getTranslation("import_properties_title"),
0639:                                rbm, this );
0640:                    } else if (ev.getActionCommand().equals(
0641:                            Resources.getTranslation("menu_file_import_java"))) {
0642:                        // Menu -> File -> Import -> Java
0643:                        if (rbm == null || rbm.getBundles() == null)
0644:                            return;
0645:                        RBJavaImporter importer = new RBJavaImporter(Resources
0646:                                .getTranslation("import_java_title"), rbm, this );
0647:                    } else if (ev.getActionCommand().equals(
0648:                            Resources.getTranslation("menu_file_import_TMX"))) {
0649:                        // Menu -> File -> Import -> TMX
0650:                        if (rbm == null || rbm.getBundles() == null)
0651:                            return;
0652:                        RBTMXImporter importer = new RBTMXImporter(Resources
0653:                                .getTranslation("import_TMX_title"), rbm, this );
0654:                    } else if (ev.getActionCommand().equals(
0655:                            Resources.getTranslation("menu_file_import_XLF"))) {
0656:                        // Menu -> File -> Import -> XLIFF
0657:                        if (rbm == null || rbm.getBundles() == null)
0658:                            return;
0659:                        RBxliffImporter importer = new RBxliffImporter(
0660:                                Resources.getTranslation("import_XLF_title"),
0661:                                rbm, this );
0662:                    } else if (ev
0663:                            .getActionCommand()
0664:                            .equals(
0665:                                    Resources
0666:                                            .getTranslation("menu_file_export_properties"))) {
0667:                        // Menu -> File -> Export -> Properties
0668:                        RBPropertiesExporter exp = new RBPropertiesExporter();
0669:                        try {
0670:                            if (rbm != null && rbm.getBundles() != null)
0671:                                exp.export(rbm);
0672:                        } catch (IOException ioe) {
0673:                            JOptionPane.showMessageDialog(this , Resources
0674:                                    .getTranslation("error_export"), Resources
0675:                                    .getTranslation("error"),
0676:                                    JOptionPane.ERROR_MESSAGE);
0677:                        }
0678:                    } else if (ev.getActionCommand().equals(
0679:                            Resources.getTranslation("menu_file_export_java"))) {
0680:                        // Menu -> File -> Export -> Java
0681:                        RBJavaExporter exp = new RBJavaExporter();
0682:                        try {
0683:                            if (rbm != null && rbm.getBundles() != null)
0684:                                exp.export(rbm);
0685:                        } catch (IOException ioe) {
0686:                            JOptionPane.showMessageDialog(this , Resources
0687:                                    .getTranslation("error_export"), Resources
0688:                                    .getTranslation("error"),
0689:                                    JOptionPane.ERROR_MESSAGE);
0690:                        }
0691:                    } else if (ev.getActionCommand().equals(
0692:                            Resources.getTranslation("menu_file_export_ICU"))) {
0693:                        // Menu -> File -> Export -> Java
0694:                        RBICUExporter exp = new RBICUExporter();
0695:                        try {
0696:                            if (rbm != null && rbm.getBundles() != null)
0697:                                exp.export(rbm);
0698:                        } catch (IOException ioe) {
0699:                            JOptionPane.showMessageDialog(this , Resources
0700:                                    .getTranslation("error_export"), Resources
0701:                                    .getTranslation("error"),
0702:                                    JOptionPane.ERROR_MESSAGE);
0703:                        }
0704:                    } else if (ev.getActionCommand().equals(
0705:                            Resources.getTranslation("menu_file_export_TMX"))) {
0706:                        // Menu -> File -> Export -> TMX
0707:                        RBTMXExporter exp = new RBTMXExporter();
0708:                        try {
0709:                            if (rbm != null && rbm.getBundles() != null)
0710:                                exp.export(rbm);
0711:                        } catch (IOException ioe) {
0712:                            JOptionPane.showMessageDialog(this , Resources
0713:                                    .getTranslation("error_export"), Resources
0714:                                    .getTranslation("error"),
0715:                                    JOptionPane.ERROR_MESSAGE);
0716:                        }
0717:                    } else if (ev.getActionCommand().equals(
0718:                            Resources.getTranslation("menu_file_export_XLF"))) {
0719:                        // Menu -> File -> Export -> XLIFF
0720:                        RBxliffExporter exp = new RBxliffExporter();
0721:                        try {
0722:                            if (rbm != null && rbm.getBundles() != null)
0723:                                exp.export(rbm);
0724:                        } catch (IOException ioe) {
0725:                            JOptionPane.showMessageDialog(this , Resources
0726:                                    .getTranslation("error_export"), Resources
0727:                                    .getTranslation("error"),
0728:                                    JOptionPane.ERROR_MESSAGE);
0729:                        }
0730:                    } else if (ev.getActionCommand().equals(
0731:                            Resources.getTranslation("menu_options_addfile"))) {
0732:                        // Menu -> Options -> Add New Resource
0733:                        createResourceFile();
0734:                    } else if (ev.getActionCommand().equals(
0735:                            Resources.getTranslation("menu_options_addgroup"))
0736:                            || ev
0737:                                    .getActionCommand()
0738:                                    .equals(
0739:                                            Resources
0740:                                                    .getTranslation("button_create_group"))) {
0741:                        // Menu -> Options -> Add New Group
0742:                        createBundleGroup();
0743:                    } else if (ev.getActionCommand().equals(
0744:                            Resources.getTranslation("menu_options_addentry"))) {
0745:                        // Menu -> Options -> Add New Entry
0746:                        createBundleItem();
0747:                    } else if (ev
0748:                            .getActionCommand()
0749:                            .equals(
0750:                                    Resources
0751:                                            .getTranslation("menu_options_preferences"))) {
0752:                        // Menu -> Options -> Preferences
0753:                        PreferencesDialog pd = new PreferencesDialog(this );
0754:                    } else if (ev.getActionCommand().equals(
0755:                            Resources.getTranslation("menu_help_about"))) {
0756:                        // Menu -> Help -> About RBManager
0757:                        AboutDialog.showDialog(this );
0758:                    } else
0759:                        RBManagerGUI.debugMsg("Missed Action Command: "
0760:                                + ev.getActionCommand());
0761:
0762:                }
0763:
0764:            }
0765:
0766:            /**
0767:             * Handles events generated
0768:             */
0769:
0770:            public void mousePopup(MouseEvent ev) {
0771:                if (ev.getSource() == jTreeDisplay) {
0772:                    int selRow = jTreeDisplay.getRowForLocation(ev.getX(), ev
0773:                            .getY());
0774:                    TreePath selPath = jTreeDisplay.getPathForLocation(ev
0775:                            .getX(), ev.getY());
0776:                    if (selRow != -1) {
0777:                        if (ev.getClickCount() == 1) {
0778:                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath
0779:                                    .getLastPathComponent();
0780:                            Object obj = node.getUserObject();
0781:                            if (obj == null || !(obj instanceof  Bundle))
0782:                                return;
0783:                            Bundle bundle = (Bundle) obj;
0784:                            String encoding = bundle.encoding;
0785:                            if (encoding == null)
0786:                                encoding = new String();
0787:
0788:                            // Create the menu to display
0789:                            JPopupMenu popupMenu = new JPopupMenu();
0790:                            JMenuItem saveItem = new JMenuItem(Resources
0791:                                    .getTranslation("menu_tree_save"));
0792:                            JMenuItem hideItem = new JMenuItem(Resources
0793:                                    .getTranslation("menu_tree_hide"));
0794:                            JMenuItem deleteItem = new JMenuItem(Resources
0795:                                    .getTranslation("menu_tree_delete"));
0796:
0797:                            saveItem.setName(encoding);
0798:                            saveItem.addActionListener(this );
0799:                            hideItem.setName(encoding);
0800:                            hideItem.addActionListener(this );
0801:                            deleteItem.setName(encoding);
0802:                            deleteItem.addActionListener(this );
0803:
0804:                            popupMenu.add(saveItem);
0805:                            if (node.getLevel() != 1) {
0806:                                popupMenu.add(hideItem);
0807:                                popupMenu.add(deleteItem);
0808:                            }
0809:
0810:                            popupMenu.show(ev.getComponent(), ev.getX(), ev
0811:                                    .getY());
0812:                        }
0813:                    }
0814:                } else if (ev.getSource() == projectTree) {
0815:                    int selRow = projectTree.getRowForLocation(ev.getX(), ev
0816:                            .getY());
0817:                    TreePath selPath = projectTree.getPathForLocation(
0818:                            ev.getX(), ev.getY());
0819:                    if (selRow != -1 && ev.getClickCount() == 1) {
0820:                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) selPath
0821:                                .getLastPathComponent();
0822:                        Object obj = node.getUserObject();
0823:                        if (obj == null)
0824:                            return;
0825:                        else if (obj instanceof  String) {
0826:                            JPopupMenu popupMenu = new JPopupMenu();
0827:                            JMenuItem newItem = new JMenuItem(Resources
0828:                                    .getTranslation("menu_tree_new_project"));
0829:                            JMenuItem openItem = new JMenuItem(Resources
0830:                                    .getTranslation("menu_tree_open_project"));
0831:                            JMenuItem saveItem = new JMenuItem(Resources
0832:                                    .getTranslation("menu_tree_save_project"));
0833:                            newItem.addActionListener(this );
0834:                            openItem.addActionListener(this );
0835:                            saveItem.addActionListener(this );
0836:                            popupMenu.add(newItem);
0837:                            popupMenu.add(openItem);
0838:                            popupMenu.add(saveItem);
0839:                            popupMenu.show(ev.getComponent(), ev.getX(), ev
0840:                                    .getY());
0841:                        } else if (obj instanceof  RBProject) {
0842:                            JPopupMenu popupMenu = new JPopupMenu();
0843:                            JMenuItem newItem = new JMenuItem(Resources
0844:                                    .getTranslation("menu_tree_new_project"));
0845:                            JMenuItem openItem = new JMenuItem(Resources
0846:                                    .getTranslation("menu_tree_open_project"));
0847:                            JMenuItem saveItem = new JMenuItem(Resources
0848:                                    .getTranslation("menu_tree_save_project"));
0849:                            JMenuItem addItem = new JMenuItem(
0850:                                    Resources
0851:                                            .getTranslation("menu_tree_add_project_bundle"));
0852:                            newItem.addActionListener(this );
0853:                            openItem.addActionListener(this );
0854:                            saveItem.addActionListener(this );
0855:                            addItem.addActionListener(this );
0856:                            popupMenu.add(newItem);
0857:                            popupMenu.add(openItem);
0858:                            popupMenu.add(saveItem);
0859:                            popupMenu.add(addItem);
0860:                            popupMenu.show(ev.getComponent(), ev.getX(), ev
0861:                                    .getY());
0862:                        } else if (obj instanceof  RBManager) {
0863:                            RBManager rbm = (RBManager) obj;
0864:                            JPopupMenu popupMenu = new JPopupMenu();
0865:                            JMenuItem selectItem = new JMenuItem(
0866:                                    Resources
0867:                                            .getTranslation("menu_tree_select_project_bundle"));
0868:                            JMenuItem removeItem = new JMenuItem(
0869:                                    Resources
0870:                                            .getTranslation("menu_tree_remove_project_bundle"));
0871:                            selectItem.setName(rbm.getBaseClass());
0872:                            removeItem.setName(rbm.getBaseClass());
0873:                            selectItem.addActionListener(this );
0874:                            removeItem.addActionListener(this );
0875:                            popupMenu.add(selectItem);
0876:                            popupMenu.add(removeItem);
0877:                            popupMenu.show(ev.getComponent(), ev.getX(), ev
0878:                                    .getY());
0879:                        }
0880:                    }
0881:                }
0882:            }
0883:
0884:            public void mousePressed(MouseEvent ev) {
0885:                if (ev.isPopupTrigger()) {
0886:                    mousePopup(ev);
0887:                }
0888:            }
0889:
0890:            public void mouseReleased(MouseEvent ev) {
0891:                if (ev.isPopupTrigger()) {
0892:                    mousePopup(ev);
0893:                    return;
0894:                }
0895:                // Not the popup trigger
0896:            }
0897:
0898:            public void mouseEntered(MouseEvent ev) {
0899:            }
0900:
0901:            public void mouseExited(MouseEvent ev) {
0902:            }
0903:
0904:            public void mouseClicked(MouseEvent ev) {
0905:                if (ev.getClickCount() == 2 && ev.getSource() instanceof  JTable) {
0906:                    // We are going to display the edit frame for the item selected
0907:                    BundleItem item = null;
0908:                    JTable table = (JTable) ev.getSource();
0909:                    if (table.getModel() instanceof  UntranslatedItemsTableModel) {
0910:                        int row = table.getSelectedRow();
0911:                        UntranslatedItemsTableModel model = (UntranslatedItemsTableModel) table
0912:                                .getModel();
0913:                        item = model.getBundleItem(row);
0914:                        BundleItemDialog biDialog = new BundleItemDialog(
0915:                                rbm,
0916:                                item,
0917:                                (rbm == null ? "" : rbm.getUser()),
0918:                                this ,
0919:                                Resources
0920:                                        .getTranslation("dialog_title_edit_item"),
0921:                                true);
0922:                        model.update();
0923:                    } else if (table.getModel() instanceof  SearchItemsTableModel) {
0924:                        int row = table.getSelectedRow();
0925:                        SearchItemsTableModel model = (SearchItemsTableModel) table
0926:                                .getModel();
0927:                        item = model.getBundleItem(row);
0928:                        BundleItemDialog biDialog = new BundleItemDialog(
0929:                                rbm,
0930:                                item,
0931:                                (rbm == null ? "" : rbm.getUser()),
0932:                                this ,
0933:                                Resources
0934:                                        .getTranslation("dialog_title_edit_item"),
0935:                                true);
0936:                        model.update();
0937:                    } else if (table.getModel() instanceof  GroupItemsTableModel) {
0938:                        int row = table.getSelectedRow();
0939:                        GroupItemsTableModel model = (GroupItemsTableModel) table
0940:                                .getModel();
0941:                        item = model.getBundleItem(row);
0942:                        BundleItemDialog biDialog = new BundleItemDialog(
0943:                                rbm,
0944:                                item,
0945:                                (rbm == null ? "" : rbm.getUser()),
0946:                                this ,
0947:                                Resources
0948:                                        .getTranslation("dialog_title_edit_item"),
0949:                                true);
0950:                        model.update();
0951:                    }
0952:                    updateDisplayPanels();
0953:                }
0954:            }
0955:
0956:            protected void updateProjectPanels() {
0957:                projectPanel.updateComponents();
0958:            }
0959:
0960:            // Update the display of the main panels (stats, untrans, groups). Should be called after a new tree selection
0961:            protected void updateDisplayPanels() {
0962:                debugMsg("Updating Display Panels");
0963:
0964:                Bundle bundle = null;
0965:                if (activeNode == null)
0966:                    return;
0967:                Object o = activeNode.getUserObject();
0968:                if (o == null)
0969:                    return;
0970:                if (o instanceof  String) {
0971:                    // A node that is not a root was selected.... I need to do something here
0972:                    String str = (String) o;
0973:                    if (rbm == null)
0974:                        return;
0975:                    if (str.equals(rbm.getBaseClass())) {
0976:                        // The base class node was selected
0977:                        jPanelStats.setManager(rbm);
0978:                        jPanelUntrans.setManager(rbm);
0979:                        jPanelGroups.setManager(rbm);
0980:                        jPanelSearch.setManager(rbm);
0981:                    } else {
0982:                        jPanelStats.removeElements();
0983:                        jPanelUntrans.removeElements();
0984:                        jPanelGroups.removeElements();
0985:                        jPanelSearch.removeElements();
0986:                    }
0987:                    //return;
0988:                } else if (o instanceof  Bundle) {
0989:                    bundle = (Bundle) activeNode.getUserObject();
0990:                    jPanelStats.setBundle(bundle);
0991:                    jPanelUntrans.setBundle(bundle);
0992:                    jPanelGroups.setBundle(bundle);
0993:                    jPanelSearch.setBundle(bundle);
0994:                } else
0995:                    RBManagerGUI.debugMsg(o.toString());
0996:
0997:                jPanelStats.updateComponents();
0998:                jPanelUntrans.updateComponents();
0999:                jPanelGroups.updateComponents();
1000:                jPanelSearch.updateComponents();
1001:
1002:                validateTree();
1003:            }
1004:
1005:            public void updateProjectTree() {
1006:                debugMsg("Updating Project Trees");
1007:
1008:                DefaultMutableTreeNode root = null;
1009:
1010:                if (project != null) {
1011:                    root = new DefaultMutableTreeNode(project);
1012:                    for (int i = 0; i < project.getSize(); i++) {
1013:                        RBManager rbm = project.getBundle(i);
1014:                        DefaultMutableTreeNode bundleNode = new DefaultMutableTreeNode(
1015:                                rbm);
1016:                        root.add(bundleNode);
1017:                        Bundle mainBundle = (Bundle) rbm.getBundles()
1018:                                .firstElement();
1019:                        Vector groups = mainBundle.getGroupsAsVector();
1020:                        for (int j = 0; j < groups.size(); j++) {
1021:                            BundleGroup group = (BundleGroup) groups
1022:                                    .elementAt(j);
1023:                            DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(
1024:                                    group);
1025:                            bundleNode.add(groupNode);
1026:                            Vector items = group.getItemsAsVector();
1027:                            for (int k = 0; k < items.size(); k++) {
1028:                                BundleItem item = (BundleItem) items
1029:                                        .elementAt(k);
1030:                                DefaultMutableTreeNode itemNode = new DefaultMutableTreeNode(
1031:                                        item);
1032:                                groupNode.add(itemNode);
1033:                            }
1034:                        }
1035:                    }
1036:                } else if (rbm != null) {
1037:                    // There is a resource bundle open, but no project
1038:                    root = new DefaultMutableTreeNode(Resources
1039:                            .getTranslation("no_project"));
1040:                    Bundle mainBundle = (Bundle) rbm.getBundles()
1041:                            .firstElement();
1042:                    DefaultMutableTreeNode bundleNode = new DefaultMutableTreeNode(
1043:                            rbm);//(rbm.getBaseClass());
1044:                    root.add(bundleNode);
1045:                    Vector groups = mainBundle.getGroupsAsVector();
1046:                    for (int i = 0; i < groups.size(); i++) {
1047:                        BundleGroup group = (BundleGroup) groups.elementAt(i);
1048:                        DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(
1049:                                group);
1050:                        bundleNode.add(groupNode);
1051:                        Vector items = group.getItemsAsVector();
1052:                        for (int j = 0; j < items.size(); j++) {
1053:                            BundleItem item = (BundleItem) items.elementAt(j);
1054:                            DefaultMutableTreeNode itemNode = new DefaultMutableTreeNode(
1055:                                    item);
1056:                            groupNode.add(itemNode);
1057:                        }
1058:                    }
1059:                } else {
1060:                    root = new DefaultMutableTreeNode(Resources
1061:                            .getTranslation("no_project_bundle"));
1062:                }
1063:
1064:                // Create the tree from the roots
1065:                projectTree = new JTree(root);
1066:                projectTree.addMouseListener(this );
1067:                projectTree.addTreeSelectionListener(this );
1068:                projectTree.setCellRenderer(RBTreeCellRenderer.getInstance());
1069:                projectScrollPane.getViewport().removeAll();
1070:                projectScrollPane.getViewport().add(projectTree);
1071:                repaint();
1072:                validateTree();
1073:                return;
1074:            }
1075:
1076:            // Update the display of the tree file map. Should be called when the tree is changed/updated
1077:            public void updateDisplayTree() {
1078:                debugMsg("Updating Display Trees");
1079:
1080:                DefaultMutableTreeNode root = null;
1081:
1082:                if (rbm == null || rbm.getBundles() == null) {
1083:                    root = new DefaultMutableTreeNode(Resources
1084:                            .getTranslation("no_resource_bundle"));
1085:                } else {
1086:                    // From here on out, there is a defined resource bundle manager
1087:                    Bundle mainBundle = (Bundle) rbm.getBundles()
1088:                            .firstElement();
1089:                    root = new DefaultMutableTreeNode(rbm.getBaseClass());
1090:                    // Add the base class
1091:                    root.add(new DefaultMutableTreeNode(mainBundle));
1092:
1093:                    //DefaultMutableTreeNode currNode = root;
1094:                    for (int i = 1; i < rbm.getBundles().size(); i++) {
1095:                        Bundle currBundle = (Bundle) rbm.getBundles()
1096:                                .elementAt(i);
1097:                        String variant = currBundle.getVariantEncoding();
1098:                        String country = currBundle.getCountryEncoding();
1099:                        String language = currBundle.getLanguageEncoding();
1100:                        //DefaultMutableTreeNode languageNode = null;
1101:                        // Look for a node representing this language
1102:                        if (language == null || language.equals(""))
1103:                            continue;
1104:                        boolean languageNodeFound = false;
1105:                        for (int j = 0; j < root.getChildCount(); j++) {
1106:                            DefaultMutableTreeNode langNode = (DefaultMutableTreeNode) root
1107:                                    .getChildAt(j);
1108:                            Object o = langNode.getUserObject();
1109:                            if (o == null || !(o instanceof  String))
1110:                                continue;
1111:                            String str = (String) o;
1112:                            if (str.equals(Resources.getTranslation(
1113:                                    "tree_language_node", language))) {
1114:                                // There is a non-leaf node with this language
1115:                                languageNodeFound = true;
1116:                                if (country == null || country.equals(""))
1117:                                    langNode.add(new DefaultMutableTreeNode(
1118:                                            currBundle));
1119:                                else {
1120:                                    // We need to look at country, variant
1121:                                    boolean countryNodeFound = false;
1122:                                    for (int k = 0; k < langNode
1123:                                            .getChildCount(); k++) {
1124:                                        DefaultMutableTreeNode countryNode = (DefaultMutableTreeNode) langNode
1125:                                                .getChildAt(k);
1126:                                        Object o2 = countryNode.getUserObject();
1127:                                        if (o2 == null
1128:                                                || !(o2 instanceof  String))
1129:                                            continue;
1130:                                        String str2 = (String) o2;
1131:                                        if (str2.equals(Resources
1132:                                                .getTranslation(
1133:                                                        "tree_country_node",
1134:                                                        country))) {
1135:                                            // There is a non-leaf node for this country
1136:                                            countryNodeFound = true;
1137:                                            if (variant == null
1138:                                                    || variant.equals("")) {
1139:                                                countryNode
1140:                                                        .add(new DefaultMutableTreeNode(
1141:                                                                currBundle));
1142:                                            } else {
1143:                                                // We need to look at variant
1144:                                                boolean variantNodeFound = false;
1145:                                                for (int l = 0; l < countryNode
1146:                                                        .getChildCount(); l++) {
1147:                                                    DefaultMutableTreeNode variantNode = (DefaultMutableTreeNode) countryNode
1148:                                                            .getChildAt(l);
1149:                                                    Object o3 = variantNode
1150:                                                            .getUserObject();
1151:                                                    if (o3 == null
1152:                                                            || !(o3 instanceof  String))
1153:                                                        continue;
1154:                                                    String str3 = (String) o3;
1155:                                                    if (str3
1156:                                                            .equals(Resources
1157:                                                                    .getTranslation("tree_variant_node"))) {
1158:                                                        variantNodeFound = true;
1159:                                                        variantNode
1160:                                                                .add(new DefaultMutableTreeNode(
1161:                                                                        currBundle));
1162:                                                    }
1163:                                                } // end for - country node loop
1164:                                                if (!variantNodeFound) {
1165:                                                    DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(
1166:                                                            Resources
1167:                                                                    .getTranslation("tree_variant_node"));
1168:                                                    countryNode
1169:                                                            .add(variantNode);
1170:                                                    variantNode
1171:                                                            .add(new DefaultMutableTreeNode(
1172:                                                                    currBundle));
1173:                                                }
1174:                                            }
1175:                                        }
1176:                                    } // end for - language node loop
1177:                                    if (!countryNodeFound) {
1178:                                        DefaultMutableTreeNode countryNode = new DefaultMutableTreeNode(
1179:                                                Resources.getTranslation(
1180:                                                        "tree_country_node",
1181:                                                        country));
1182:                                        langNode.add(countryNode);
1183:                                        if (variant == null
1184:                                                || variant.equals("")) {
1185:                                            countryNode
1186:                                                    .add(new DefaultMutableTreeNode(
1187:                                                            currBundle));
1188:                                        } else {
1189:                                            // We need to look at the variant	
1190:                                            boolean variantNodeFound = false;
1191:                                            for (int l = 0; l < countryNode
1192:                                                    .getChildCount(); l++) {
1193:                                                DefaultMutableTreeNode variantNode = (DefaultMutableTreeNode) countryNode
1194:                                                        .getChildAt(l);
1195:                                                Object o3 = variantNode
1196:                                                        .getUserObject();
1197:                                                if (o3 == null
1198:                                                        || !(o3 instanceof  String))
1199:                                                    continue;
1200:                                                String str3 = (String) o3;
1201:                                                if (str3
1202:                                                        .equals(Resources
1203:                                                                .getTranslation("tree_variant_node"))) {
1204:                                                    variantNodeFound = true;
1205:                                                    variantNode
1206:                                                            .add(new DefaultMutableTreeNode(
1207:                                                                    currBundle));
1208:                                                }
1209:                                            } // end for - country node loop
1210:                                            if (!variantNodeFound) {
1211:                                                DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(
1212:                                                        Resources
1213:                                                                .getTranslation("tree_variant_node"));
1214:                                                countryNode.add(variantNode);
1215:                                                variantNode
1216:                                                        .add(new DefaultMutableTreeNode(
1217:                                                                currBundle));
1218:                                            }
1219:                                        }
1220:                                    }
1221:                                }
1222:                            }
1223:                        }
1224:                        if (!languageNodeFound) {
1225:                            // We need to create a node for this country
1226:                            DefaultMutableTreeNode langNode = new DefaultMutableTreeNode(
1227:                                    Resources.getTranslation(
1228:                                            "tree_language_node", language));
1229:                            root.add(langNode);
1230:                            if (country == null || country.equals("")) {
1231:                                langNode.add(new DefaultMutableTreeNode(
1232:                                        currBundle));
1233:                            } else {
1234:                                // We need to look at the country, variant
1235:                                boolean countryNodeFound = false;
1236:                                for (int k = 0; k < langNode.getChildCount(); k++) {
1237:                                    DefaultMutableTreeNode countryNode = (DefaultMutableTreeNode) langNode
1238:                                            .getChildAt(k);
1239:                                    Object o2 = countryNode.getUserObject();
1240:                                    if (o2 == null || !(o2 instanceof  String))
1241:                                        continue;
1242:                                    String str2 = (String) o2;
1243:                                    if (str2.equals(Resources.getTranslation(
1244:                                            "tree_country_node", country))) {
1245:                                        // There is a non-leaf node for this country
1246:                                        countryNodeFound = true;
1247:                                        if (variant == null
1248:                                                || variant.equals("")) {
1249:                                            countryNode
1250:                                                    .add(new DefaultMutableTreeNode(
1251:                                                            currBundle));
1252:                                        } else {
1253:                                            // We need to look at variant
1254:                                            boolean variantNodeFound = false;
1255:                                            for (int l = 0; l < countryNode
1256:                                                    .getChildCount(); l++) {
1257:                                                DefaultMutableTreeNode variantNode = (DefaultMutableTreeNode) countryNode
1258:                                                        .getChildAt(l);
1259:                                                Object o3 = variantNode
1260:                                                        .getUserObject();
1261:                                                if (o3 == null
1262:                                                        || !(o3 instanceof  String))
1263:                                                    continue;
1264:                                                String str3 = (String) o3;
1265:                                                if (str3
1266:                                                        .equals(Resources
1267:                                                                .getTranslation("tree_variant_node"))) {
1268:                                                    variantNodeFound = true;
1269:                                                    variantNode
1270:                                                            .add(new DefaultMutableTreeNode(
1271:                                                                    currBundle));
1272:                                                }
1273:                                            } // end for - country node loop
1274:                                            if (!variantNodeFound) {
1275:                                                DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(
1276:                                                        Resources
1277:                                                                .getTranslation("tree_variant_node"));
1278:                                                countryNode.add(variantNode);
1279:                                                variantNode
1280:                                                        .add(new DefaultMutableTreeNode(
1281:                                                                currBundle));
1282:                                            }
1283:                                        }
1284:                                    }
1285:                                } // end for - language node loop
1286:                                if (!countryNodeFound) {
1287:                                    DefaultMutableTreeNode countryNode = new DefaultMutableTreeNode(
1288:                                            Resources.getTranslation(
1289:                                                    "tree_country_node",
1290:                                                    country));
1291:                                    langNode.add(countryNode);
1292:                                    if (variant == null || variant.equals("")) {
1293:                                        countryNode
1294:                                                .add(new DefaultMutableTreeNode(
1295:                                                        currBundle));
1296:                                    } else {
1297:                                        // We need to look at the variant	
1298:                                        boolean variantNodeFound = false;
1299:                                        for (int l = 0; l < countryNode
1300:                                                .getChildCount(); l++) {
1301:                                            DefaultMutableTreeNode variantNode = (DefaultMutableTreeNode) countryNode
1302:                                                    .getChildAt(l);
1303:                                            Object o3 = variantNode
1304:                                                    .getUserObject();
1305:                                            if (o3 == null
1306:                                                    || !(o3 instanceof  String))
1307:                                                continue;
1308:                                            String str3 = (String) o3;
1309:                                            if (str3
1310:                                                    .equals(Resources
1311:                                                            .getTranslation("tree_variant_node"))) {
1312:                                                variantNodeFound = true;
1313:                                                variantNode
1314:                                                        .add(new DefaultMutableTreeNode(
1315:                                                                currBundle));
1316:                                            }
1317:                                        } // end for - country node loop
1318:                                        if (!variantNodeFound) {
1319:                                            DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(
1320:                                                    Resources
1321:                                                            .getTranslation(
1322:                                                                    "tree_variant_node",
1323:                                                                    variant));
1324:                                            countryNode.add(variantNode);
1325:                                            variantNode
1326:                                                    .add(new DefaultMutableTreeNode(
1327:                                                            currBundle));
1328:                                        }
1329:                                    }
1330:                                }
1331:                            }
1332:                        }
1333:                    }
1334:                }
1335:
1336:                // Create the tree from the roots
1337:                jTreeDisplay = new JTree(root);
1338:                jTreeDisplay.addMouseListener(this );
1339:                jTreeDisplay.addTreeSelectionListener(this );
1340:                jTreeDisplay.setCellRenderer(RBTreeCellRenderer.getInstance());
1341:                jScrollPaneTree.getViewport().removeAll();
1342:                jScrollPaneTree.getViewport().add(jTreeDisplay);
1343:                repaint();
1344:                validateTree();
1345:                return;
1346:            }
1347:
1348:            /**
1349:             * Inherits from JFrame.addNotify(), but also inserts the menu bar
1350:             */
1351:
1352:            public void addNotify() {
1353:                super .addNotify();
1354:
1355:                if (mShown)
1356:                    return;
1357:
1358:                // resize frame to account for menubar
1359:                JMenuBar jMenuBar = getJMenuBar();
1360:                if (jMenuBar != null) {
1361:                    int jMenuBarHeight = jMenuBar.getPreferredSize().height;
1362:                    Dimension dimension = getSize();
1363:                    dimension.height += jMenuBarHeight;
1364:                    setSize(dimension);
1365:                }
1366:
1367:                mShown = true;
1368:            }
1369:
1370:            /**
1371:             * Called when it may be appropriate to check with the user if they want to save the file
1372:             */
1373:
1374:            boolean promptForSave(String message) {
1375:                if (rbm != null) {
1376:                    int response = JOptionPane.showConfirmDialog(this ,
1377:                            (message == null ? Resources
1378:                                    .getTranslation("dialog_save") : message),
1379:                            Resources.getTranslation("dialog_title_quit"),
1380:                            JOptionPane.YES_NO_CANCEL_OPTION,
1381:                            JOptionPane.QUESTION_MESSAGE);
1382:                    if (response == JOptionPane.CANCEL_OPTION)
1383:                        return false;
1384:                    if (response == JOptionPane.YES_OPTION) {
1385:                        return saveResources();
1386:                    }
1387:                }
1388:                return true;
1389:            }
1390:
1391:            public boolean deleteResources(String encoding) {
1392:                if (rbm == null)
1393:                    return false; // This should never happen
1394:                try {
1395:                    rbm.eraseFile(encoding);
1396:                } catch (IOException ioe) {
1397:                    JOptionPane.showMessageDialog(this ,
1398:                            Resources.getTranslation("error_deleting", ioe
1399:                                    .getMessage()), Resources
1400:                                    .getTranslation("error"),
1401:                            JOptionPane.ERROR_MESSAGE);
1402:                    if (RBManagerGUI.debug)
1403:                        System.err.println(ioe);
1404:                    return false;
1405:                }
1406:                updateDisplayTree();
1407:                updateProjectTree();
1408:                updateProjectPanels();
1409:                updateDisplayPanels();
1410:                return true;
1411:            }
1412:
1413:            public void hideResources(String encoding) {
1414:                rbm.hideResource(encoding);
1415:                updateDisplayTree();
1416:                updateProjectTree();
1417:                updateProjectPanels();
1418:                updateDisplayPanels();
1419:            }
1420:
1421:            /**
1422:             * Save a particular resources file within the bundle.
1423:             */
1424:
1425:            public boolean saveResources(String encoding) {
1426:                if (rbm == null)
1427:                    return false; // This should never happen
1428:                return saveResources(rbm, encoding);
1429:            }
1430:
1431:            public boolean saveResources(RBManager bundle, String encoding) {
1432:                try {
1433:                    bundle.writeToFile(encoding);
1434:                } catch (IOException ioe) {
1435:                    JOptionPane.showMessageDialog(this , Resources
1436:                            .getTranslation("error_saving", ioe.getMessage()),
1437:                            Resources.getTranslation("error"),
1438:                            JOptionPane.ERROR_MESSAGE);
1439:                    if (RBManagerGUI.debug)
1440:                        System.err.println(ioe);
1441:                    return false;
1442:                }
1443:                return true;
1444:            }
1445:
1446:            /**
1447:             * Called when the resources are to be saved
1448:             */
1449:
1450:            public boolean saveResources() {
1451:                if (rbm == null)
1452:                    return true;
1453:                return saveResources(rbm);
1454:            }
1455:
1456:            public boolean saveResources(RBManager bundle) {
1457:                try {
1458:                    bundle.writeToFile();
1459:                } catch (IOException ioe) {
1460:                    JOptionPane.showMessageDialog(this , Resources
1461:                            .getTranslation("error_saving", ioe.getMessage()),
1462:                            Resources.getTranslation("error"),
1463:                            JOptionPane.ERROR_MESSAGE);
1464:                    if (RBManagerGUI.debug)
1465:                        System.err.println(ioe);
1466:                    return false;
1467:                }
1468:                return true;
1469:            }
1470:
1471:            /**
1472:             * Called when the resource bundle is to be saved, but displays a window to the user allowing them
1473:             * to selecte the file destination of the folder in which to save the bundle as well as the base
1474:             * class name for the bundle.
1475:             */
1476:
1477:            public boolean saveResourcesAs() {
1478:                if (rbm == null)
1479:                    return true;
1480:                int result = saveFileChooser.showSaveDialog(this );
1481:                if (result == JFileChooser.APPROVE_OPTION) {
1482:                    try {
1483:                        File newFile = saveFileChooser.getSelectedFile();
1484:                        String fileName = newFile.getName();
1485:                        String baseName = fileName;
1486:                        if (fileName.toLowerCase().endsWith(".properties"))
1487:                            baseName = baseName.substring(0,
1488:                                    baseName.length() - 11);
1489:                        rbm.setBaseClass(baseName);
1490:                        rbm.setFileDirectory(newFile.getParentFile());
1491:                        rbm.writeToFile();
1492:                    } catch (IOException ioe) {
1493:                        JOptionPane.showMessageDialog(this , Resources
1494:                                .getTranslation("error_saving", ioe
1495:                                        .getMessage()), Resources
1496:                                .getTranslation("error"),
1497:                                JOptionPane.ERROR_MESSAGE);
1498:                        if (RBManagerGUI.debug)
1499:                            System.err.println(ioe);
1500:                        return false;
1501:                    }
1502:                }
1503:                return true;
1504:            }
1505:
1506:            void updateLocale(Locale l) {
1507:                // Update the menubars
1508:                jMenuBarMain.updateLocale();
1509:
1510:                updateLocale(getContentPane(), l);
1511:                updateLocale(openFileChooser, l);
1512:                updateLocale(saveFileChooser, l);
1513:                // Redraw the panes
1514:                updateDisplayTree();
1515:                updateProjectTree();
1516:                updateProjectPanels();
1517:                updateDisplayPanels();
1518:                // update the tab titles
1519:                jTabbedPaneMain.setTitleAt(0, Resources
1520:                        .getTranslation("tab_statistics"));
1521:                jTabbedPaneMain.setTitleAt(1, Resources
1522:                        .getTranslation("tab_untranslated"));
1523:                jTabbedPaneMain.setTitleAt(2, Resources
1524:                        .getTranslation("tab_groups"));
1525:                setTitle(Resources.getTranslation("resource_bundle_manager"));
1526:            }
1527:
1528:            static void updateLocale(Container c, Locale l) {
1529:                Component comp[] = c.getComponents();
1530:                for (int i = 0; i < comp.length; i++) {
1531:                    if (comp[i] instanceof  JComponent) {
1532:                        ((JComponent) comp[i]).setLocale(l);
1533:                    }
1534:                    if (comp[i] instanceof  Container) {
1535:                        updateLocale((Container) comp[i], l);
1536:                    }
1537:                }
1538:                if (c instanceof  JMenu) {
1539:                    comp = ((JMenu) c).getMenuComponents();
1540:                    for (int i = 0; i < comp.length; i++) {
1541:                        if (comp[i] instanceof  JComponent) {
1542:                            ((JComponent) comp[i]).setLocale(l);
1543:                        }
1544:                        if (comp[i] instanceof  Container) {
1545:                            updateLocale((Container) comp[i], l);
1546:                        }
1547:                    }
1548:                }
1549:            }
1550:
1551:            void updateUI() {
1552:                updateUI(getContentPane());
1553:                jMenuBarMain.updateUI();
1554:                updateUI(jMenuBarMain);
1555:                updateUI(openFileChooser);
1556:                updateUI(saveFileChooser);
1557:            }
1558:
1559:            static void updateUI(Container c) {
1560:                Component comp[] = c.getComponents();
1561:                for (int i = 0; i < comp.length; i++) {
1562:                    if (comp[i] instanceof  JComponent) {
1563:                        ((JComponent) comp[i]).updateUI();
1564:                    }
1565:                    if (comp[i] instanceof  Container) {
1566:                        updateUI((Container) comp[i]);
1567:                    }
1568:                }
1569:                if (c instanceof  JMenu) {
1570:                    comp = ((JMenu) c).getMenuComponents();
1571:                    for (int i = 0; i < comp.length; i++) {
1572:                        if (comp[i] instanceof  JComponent) {
1573:                            ((JComponent) comp[i]).updateUI();
1574:                        }
1575:                        if (comp[i] instanceof  Container) {
1576:                            updateUI((Container) comp[i]);
1577:                        }
1578:                    }
1579:                }
1580:            }
1581:
1582:            // Close the window when the close box is clicked
1583:            void this WindowClosing(java.awt.event.WindowEvent e) {
1584:                if (promptForSave(Resources.getTranslation("dialog_quit_save"))) {
1585:                    setVisible(false);
1586:                    dispose();
1587:                    System.exit(0);
1588:                }
1589:            }
1590:
1591:            public void setUser(String userName) {
1592:                this .userName = userName;
1593:                if (rbm != null)
1594:                    rbm.setUser(userName);
1595:            }
1596:
1597:            public String getUser() {
1598:                return userName;
1599:            }
1600:
1601:            public BundleItem getSelectedProjectBundleItem() {
1602:                TreePath path = projectTree.getSelectionPath();
1603:                if (path == null)
1604:                    return null;
1605:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
1606:                        .getLastPathComponent();
1607:                Object obj = node.getUserObject();
1608:                if (obj == null || !(obj instanceof  BundleItem))
1609:                    return null;
1610:                return (BundleItem) obj;
1611:            }
1612:
1613:            public RBManager getSelectedProjectBundle() {
1614:                TreePath path = projectTree.getSelectionPath();
1615:                if (path == null)
1616:                    return null;
1617:                for (int i = 0; i < path.getPathCount(); i++) {
1618:                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path
1619:                            .getPathComponent(i);
1620:                    Object obj = node.getUserObject();
1621:                    if (obj != null && obj instanceof  RBManager)
1622:                        return (RBManager) obj;
1623:                }
1624:                return null;
1625:            }
1626:
1627:            public static void debugMsg(String msg) {
1628:                if (debug)
1629:                    System.out.println("Debug Message [" + debugcount++ + "]: "
1630:                            + msg);
1631:            }
1632:        }
1633:
1634:        class RBTreeCellRenderer extends DefaultTreeCellRenderer {
1635:            private static RBTreeCellRenderer cellRend = null;
1636:            private static ImageIcon bundleIcon = null;
1637:            private static ImageIcon languageIcon = null;
1638:            private static ImageIcon countryIcon = null;
1639:            private static ImageIcon variantIcon = null;
1640:            private static ImageIcon fileIcon = null;
1641:            private static ImageIcon groupIcon = null;
1642:            private static ImageIcon itemIcon = null;
1643:            private static ImageIcon projectIcon = null;
1644:
1645:            private RBTreeCellRenderer() {
1646:
1647:            }
1648:
1649:            public Component getTreeCellRendererComponent(JTree tree,
1650:                    Object value, boolean selected, boolean expanded,
1651:                    boolean leaf, int row, boolean hasFocus) {
1652:                super .getTreeCellRendererComponent(tree, value, selected,
1653:                        expanded, leaf, row, hasFocus);
1654:
1655:                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
1656:                int level = node.getLevel();
1657:                Object obj = node.getUserObject();
1658:
1659:                if (obj instanceof  BundleGroup) {
1660:                    setIcon(groupIcon);
1661:                } else if (obj instanceof  BundleItem) {
1662:                    setIcon(itemIcon);
1663:                } else if (obj instanceof  RBManager) {
1664:                    setIcon(bundleIcon);
1665:                } else if (obj instanceof  RBProject) {
1666:                    setIcon(projectIcon);
1667:                } else if (leaf) {
1668:                    if (level != 0)
1669:                        setIcon(fileIcon);
1670:                } else {
1671:                    if (level == 0) {
1672:                        if (obj instanceof  String
1673:                                && ((String) obj).equals(Resources
1674:                                        .getTranslation("no_project")))
1675:                            setIcon(projectIcon);
1676:                        else
1677:                            setIcon(bundleIcon);
1678:                    } else if (level == 1)
1679:                        setIcon(languageIcon);
1680:                    else if (level == 2)
1681:                        setIcon(countryIcon);
1682:                    else if (level == 3)
1683:                        setIcon(variantIcon);
1684:                }
1685:
1686:                return this ;
1687:            }
1688:
1689:            public static RBTreeCellRenderer getInstance() {
1690:                if (cellRend == null) {
1691:                    try {
1692:                        Class this Class = Class
1693:                                .forName("com.ibm.rbm.gui.RBManagerGUI");
1694:                        // Create instances of the icons
1695:                        Image scaledImage = (new ImageIcon(this Class
1696:                                .getResource("images/tree_icon_bundle.gif")))
1697:                                .getImage().getScaledInstance(16, 16,
1698:                                        Image.SCALE_DEFAULT);
1699:                        bundleIcon = new ImageIcon(scaledImage);
1700:                        languageIcon = new ImageIcon(this Class
1701:                                .getResource("images/tree_icon_language.gif"));
1702:                        countryIcon = new ImageIcon(this Class
1703:                                .getResource("images/tree_icon_country.gif"));
1704:                        variantIcon = new ImageIcon(this Class
1705:                                .getResource("images/tree_icon_variant.gif"));
1706:                        fileIcon = new ImageIcon(this Class
1707:                                .getResource("images/tree_icon_file.gif"));
1708:                        groupIcon = new ImageIcon(this Class
1709:                                .getResource("images/tree_icon_group.gif"));
1710:                        itemIcon = new ImageIcon(this Class
1711:                                .getResource("images/tree_icon_item.gif"));
1712:                        projectIcon = new ImageIcon(this Class
1713:                                .getResource("images/tree_icon_project.gif"));
1714:                    } catch (ClassNotFoundException e) {
1715:                        RBManagerGUI.debugMsg(e.toString());
1716:                    }
1717:                    // Create the instance of the renderer
1718:                    cellRend = new RBTreeCellRenderer();
1719:                }
1720:                return cellRend;
1721:            }
1722:        }
1723:
1724:        /**
1725:         * Table model for resource bundle projects
1726:         */
1727:        class RBProject {
1728:            java.util.List bundleNames;
1729:            java.util.List bundleFileNames;
1730:            java.util.List bundles;
1731:            String projectName;
1732:
1733:            public RBProject(String projectName) {
1734:                this .projectName = projectName;
1735:                bundleNames = new java.util.LinkedList();
1736:                bundleFileNames = new java.util.LinkedList();
1737:                bundles = new java.util.LinkedList();
1738:            }
1739:
1740:            public RBProject(File inputFile) throws IOException {
1741:                this (inputFile.getName());
1742:
1743:                if (projectName.indexOf(".") > 0) {
1744:                    projectName = projectName.substring(0, projectName
1745:                            .lastIndexOf("."));
1746:                }
1747:
1748:                FileReader fr = new FileReader(inputFile);
1749:                BufferedReader br = new BufferedReader(fr);
1750:                String line = null;
1751:                int linecount = 0;
1752:                while ((line = br.readLine()) != null) {
1753:                    if (linecount % 2 == 0) {
1754:                        bundleNames.add(line.trim());
1755:                    } else {
1756:                        bundleFileNames.add(line.trim());
1757:                    }
1758:                    linecount++;
1759:                }
1760:                fr.close();
1761:                try {
1762:                    for (int i = 0; i < bundleFileNames.size(); i++) {
1763:                        RBManager rbm = new RBManager(new File(
1764:                                (String) bundleFileNames.get(i)));
1765:                        bundles.add(rbm);
1766:                    }
1767:                } catch (Exception ex) {
1768:                    JOptionPane
1769:                            .showMessageDialog(new JFrame(), Resources
1770:                                    .getTranslation("error_load_project"),
1771:                                    Resources.getTranslation("error"),
1772:                                    JOptionPane.ERROR_MESSAGE);
1773:                    ex.printStackTrace();
1774:                    bundleNames.clear();
1775:                    bundleFileNames.clear();
1776:                }
1777:            }
1778:
1779:            public String toString() {
1780:                return projectName;
1781:            }
1782:
1783:            public int getSize() {
1784:                return bundleNames.size();
1785:            }
1786:
1787:            public String getBundleName(int index) {
1788:                return (String) bundleNames.get(index);
1789:            }
1790:
1791:            public String getFileName(int index) {
1792:                return (String) bundleFileNames.get(index);
1793:            }
1794:
1795:            public RBManager getBundle(int index) {
1796:                return (RBManager) bundles.get(index);
1797:            }
1798:
1799:            public RBManager getBundle(String bundleName) {
1800:                int index = bundleNames.indexOf(bundleName);
1801:                if (index >= 0)
1802:                    return getBundle(index);
1803:                return null;
1804:            }
1805:
1806:            public void write(File outputFile) throws IOException {
1807:                FileWriter fw = new FileWriter(outputFile);
1808:                for (int i = 0; i < bundleNames.size(); i++) {
1809:                    fw.write((String) bundleNames.get(i));
1810:                    fw.write("\n");
1811:                    fw.write((String) bundleFileNames.get(i));
1812:                    if (i != bundleNames.size() - 1)
1813:                        fw.write("\n");
1814:                }
1815:                fw.flush();
1816:                fw.close();
1817:            }
1818:
1819:            public void addBundle(String bundleFileName) throws IOException {
1820:                RBManager bundle = new RBManager(new File(bundleFileName));
1821:                bundles.add(bundle);
1822:                bundleNames.add(bundle.getBaseClass());
1823:                bundleFileNames.add(bundleFileName);
1824:            }
1825:
1826:            public void removeBundle(String bundleName) {
1827:                int index = bundleNames.indexOf(bundleName);
1828:                if (index >= 0) {
1829:                    bundleNames.remove(index);
1830:                    bundleFileNames.remove(index);
1831:                    bundles.remove(index);
1832:                }
1833:            }
1834:        }
1835:
1836:        class RBManagerMenuBar extends JMenuBar {
1837:            RBManagerGUI listener;
1838:
1839:            JMenu jMenuFile = new JMenu(); // Menu -> File
1840:            JMenuItem jMenuFileNewResourceBundle = new JMenuItem();
1841:            JMenuItem jMenuFileOpenResourceBundle = new JMenuItem();
1842:            JMenuItem jMenuFileSaveResourceBundle = new JMenuItem();
1843:            JMenuItem jMenuFileSaveResourceBundleAs = new JMenuItem();
1844:            JMenu jMenuFileImportResourceBundle = new JMenu(); // Menu -> File -> Import
1845:            JMenuItem jMenuFileImportJava = new JMenuItem();
1846:            JMenuItem jMenuFileImportProperties = new JMenuItem();
1847:            JMenuItem jMenuFileImportTMX = new JMenuItem();
1848:            JMenuItem jMenuFileImportXLF = new JMenuItem();
1849:            JMenu jMenuFileExportResourceBundle = new JMenu(); // Menu -> File -> Export
1850:            JMenuItem jMenuFileExportJava = new JMenuItem();
1851:            JMenuItem jMenuFileExportICU = new JMenuItem();
1852:            JMenuItem jMenuFileExportProperties = new JMenuItem();
1853:            JMenuItem jMenuFileExportTMX = new JMenuItem();
1854:            JMenuItem jMenuFileExportXLF = new JMenuItem();
1855:            JMenuItem jMenuFileExit = new JMenuItem();
1856:            JMenu jMenuEdit = new JMenu(); // Menu -> Edit
1857:            JMenuItem jMenuEditCut = new JMenuItem();
1858:            JMenuItem jMenuEditCopy = new JMenuItem();
1859:            JMenuItem jMenuEditPaste = new JMenuItem();
1860:            JMenuItem jMenuEditDelete = new JMenuItem();
1861:            JMenu jMenuOptions = new JMenu(); // Menu -> Options
1862:            JMenuItem jMenuOptionsAddNewEntry = new JMenuItem();
1863:            JMenuItem jMenuOptionsAddNewGroup = new JMenuItem();
1864:            JMenuItem jMenuOptionsAddNewResourceFile = new JMenuItem();
1865:            //JMenuItem    jMenuOptionsProjectViewer = new JMenuItem();
1866:            JMenuItem jMenuOptionsPreferences = new JMenuItem();
1867:            JMenu jMenuView = new JMenu(); // Menu -> View
1868:            JMenuItem jMenuViewViewStatistics = new JMenuItem();
1869:            JMenu jMenuHelp = new JMenu(); // Menu -> Help
1870:            JMenuItem jMenuHelpAboutResourceBundleManager = new JMenuItem();
1871:
1872:            void updateLocale() {
1873:                //FILE
1874:                jMenuFile.setText(Resources.getTranslation("menu_file"));
1875:                jMenuFile.setMnemonic(getKeyEventKey(Resources
1876:                        .getTranslation("menu_file_trigger")));
1877:                jMenuFileNewResourceBundle.setText(Resources
1878:                        .getTranslation("menu_file_new"));
1879:                jMenuFileNewResourceBundle.setMnemonic(getKeyEventKey(Resources
1880:                        .getTranslation("menu_file_new_trigger")));
1881:                jMenuFileOpenResourceBundle.setText(Resources
1882:                        .getTranslation("menu_file_open"));
1883:                jMenuFileOpenResourceBundle
1884:                        .setMnemonic(getKeyEventKey(Resources
1885:                                .getTranslation("menu_file_open_trigger")));
1886:                jMenuFileSaveResourceBundle.setText(Resources
1887:                        .getTranslation("menu_file_save"));
1888:                jMenuFileSaveResourceBundle
1889:                        .setMnemonic(getKeyEventKey(Resources
1890:                                .getTranslation("menu_file_save_trigger")));
1891:                jMenuFileSaveResourceBundleAs.setText(Resources
1892:                        .getTranslation("menu_file_saveas"));
1893:                jMenuFileSaveResourceBundleAs
1894:                        .setMnemonic(getKeyEventKey(Resources
1895:                                .getTranslation("menu_file_saveas_trigger")));
1896:                jMenuFileImportResourceBundle.setText(Resources
1897:                        .getTranslation("menu_file_import"));
1898:                jMenuFileImportResourceBundle
1899:                        .setMnemonic(getKeyEventKey(Resources
1900:                                .getTranslation("menu_file_import_trigger")));
1901:                jMenuFileImportJava.setText(Resources
1902:                        .getTranslation("menu_file_import_java"));
1903:                jMenuFileImportJava.setMnemonic(getKeyEventKey(Resources
1904:                        .getTranslation("menu_file_import_java_trigger")));
1905:                jMenuFileImportProperties.setText(Resources
1906:                        .getTranslation("menu_file_import_properties"));
1907:                jMenuFileImportProperties
1908:                        .setMnemonic(getKeyEventKey(Resources
1909:                                .getTranslation("menu_file_import_properties_trigger")));
1910:                jMenuFileImportTMX.setText(Resources
1911:                        .getTranslation("menu_file_import_TMX"));
1912:                jMenuFileImportTMX.setMnemonic(getKeyEventKey(Resources
1913:                        .getTranslation("menu_file_import_TMX_trigger")));
1914:                jMenuFileImportXLF.setText(Resources
1915:                        .getTranslation("menu_file_import_XLF"));
1916:                jMenuFileImportXLF.setMnemonic(getKeyEventKey(Resources
1917:                        .getTranslation("menu_file_import_XLF_trigger")));
1918:                jMenuFileExportResourceBundle.setText(Resources
1919:                        .getTranslation("menu_file_export"));
1920:                jMenuFileExportResourceBundle
1921:                        .setMnemonic(getKeyEventKey(Resources
1922:                                .getTranslation("menu_file_export_trigger")));
1923:                jMenuFileExportJava.setText(Resources
1924:                        .getTranslation("menu_file_export_java"));
1925:                jMenuFileExportJava.setMnemonic(getKeyEventKey(Resources
1926:                        .getTranslation("menu_file_export_java_trigger")));
1927:                jMenuFileExportICU.setText(Resources
1928:                        .getTranslation("menu_file_export_ICU"));
1929:                jMenuFileExportICU.setMnemonic(getKeyEventKey(Resources
1930:                        .getTranslation("menu_file_export_ICU_trigger")));
1931:                jMenuFileExportProperties.setText(Resources
1932:                        .getTranslation("menu_file_export_properties"));
1933:                jMenuFileExportProperties
1934:                        .setMnemonic(getKeyEventKey(Resources
1935:                                .getTranslation("menu_file_export_properties_trigger")));
1936:                jMenuFileExportTMX.setText(Resources
1937:                        .getTranslation("menu_file_export_TMX"));
1938:                jMenuFileExportTMX.setMnemonic(getKeyEventKey(Resources
1939:                        .getTranslation("menu_file_export_TMX_trigger")));
1940:                jMenuFileExportXLF.setText(Resources
1941:                        .getTranslation("menu_file_export_XLF"));
1942:                jMenuFileExportXLF.setMnemonic(getKeyEventKey(Resources
1943:                        .getTranslation("menu_file_export_XLF_trigger")));
1944:                jMenuFileExit.setText(Resources
1945:                        .getTranslation("menu_file_quit"));
1946:                jMenuFileExit.setMnemonic(getKeyEventKey(Resources
1947:                        .getTranslation("menu_file_quit_trigger")));
1948:                //EDIT
1949:                jMenuEdit.setText(Resources.getTranslation("menu_edit"));
1950:                jMenuEdit.setMnemonic(getKeyEventKey(Resources
1951:                        .getTranslation("menu_edit_trigger")));
1952:                jMenuEditCut.setText(Resources.getTranslation("menu_edit_cut"));
1953:                jMenuEditCut.setMnemonic(getKeyEventKey(Resources
1954:                        .getTranslation("menu_edit_cut_trigger")));
1955:                jMenuEditCopy.setText(Resources
1956:                        .getTranslation("menu_edit_copy"));
1957:                jMenuEditCopy.setMnemonic(getKeyEventKey(Resources
1958:                        .getTranslation("menu_edit_copy_trigger")));
1959:                jMenuEditPaste.setText(Resources
1960:                        .getTranslation("menu_edit_paste"));
1961:                jMenuEditPaste.setMnemonic(getKeyEventKey(Resources
1962:                        .getTranslation("menu_edit_paste_trigger")));
1963:                jMenuEditDelete.setText(Resources
1964:                        .getTranslation("menu_edit_delete"));
1965:                jMenuEditDelete.setMnemonic(getKeyEventKey(Resources
1966:                        .getTranslation("menu_edit_delete_trigger")));
1967:                //OPTIONS
1968:                jMenuOptions.setText(Resources.getTranslation("menu_options"));
1969:                jMenuOptions.setMnemonic(getKeyEventKey(Resources
1970:                        .getTranslation("menu_options_trigger")));
1971:                jMenuOptionsAddNewEntry.setText(Resources
1972:                        .getTranslation("menu_options_addentry"));
1973:                jMenuOptionsAddNewEntry.setMnemonic(getKeyEventKey(Resources
1974:                        .getTranslation("menu_options_addentry_trigger")));
1975:                jMenuOptionsAddNewGroup.setText(Resources
1976:                        .getTranslation("menu_options_addgroup"));
1977:                jMenuOptionsAddNewGroup.setMnemonic(getKeyEventKey(Resources
1978:                        .getTranslation("menu_options_addgroup_trigger")));
1979:                jMenuOptionsAddNewResourceFile.setText(Resources
1980:                        .getTranslation("menu_options_addfile"));
1981:                jMenuOptionsAddNewResourceFile
1982:                        .setMnemonic(getKeyEventKey(Resources
1983:                                .getTranslation("menu_options_addfile_trigger")));
1984:                //jMenuOptionsProjectViewer.setText(Resources.getTranslation("menu_options_project_viewer"));
1985:                //jMenuOptionsProjectViewer.setMnemonic(getKeyEventKey(Resources.getTranslation("menu_options_project_viewer_trigger")));
1986:                jMenuOptionsPreferences.setText(Resources
1987:                        .getTranslation("menu_options_preferences"));
1988:                jMenuOptionsPreferences.setMnemonic(getKeyEventKey(Resources
1989:                        .getTranslation("menu_options_preferences_trigger")));
1990:                //VIEW
1991:                jMenuView.setText(Resources.getTranslation("menu_view"));
1992:                jMenuView.setMnemonic(getKeyEventKey(Resources
1993:                        .getTranslation("menu_view_trigger")));
1994:                jMenuViewViewStatistics.setText(Resources
1995:                        .getTranslation("menu_view_statistics"));
1996:                jMenuViewViewStatistics.setMnemonic(getKeyEventKey(Resources
1997:                        .getTranslation("menu_view_statistics_trigger")));
1998:                //HELP
1999:                jMenuHelp.setText(Resources.getTranslation("menu_help"));
2000:                jMenuHelp.setMnemonic(getKeyEventKey(Resources
2001:                        .getTranslation("menu_options_trigger")));
2002:                jMenuHelpAboutResourceBundleManager.setText(Resources
2003:                        .getTranslation("menu_help_about"));
2004:                jMenuHelpAboutResourceBundleManager
2005:                        .setMnemonic(getKeyEventKey(Resources
2006:                                .getTranslation("menu_help_about_trigger")));
2007:            }
2008:
2009:            public RBManagerMenuBar(RBManagerGUI gui) {
2010:                super ();
2011:
2012:                boolean xmlAvailable;
2013:                try {
2014:                    Class.forName("org.apache.xerces.parsers.DOMParser");
2015:                    Class.forName("javax.xml.parsers.DocumentBuilder");
2016:                    xmlAvailable = true;
2017:                } catch (ClassNotFoundException e) {
2018:                    xmlAvailable = false;
2019:                }
2020:                listener = gui;
2021:
2022:                // Add the menus to the menu bar 
2023:                setVisible(true);
2024:                add(jMenuFile);
2025:                //add(jMenuEdit);
2026:                add(jMenuOptions);
2027:                //add(jMenuView);
2028:                add(jMenuHelp);
2029:
2030:                // Add File Menu Items to the File Menu
2031:                jMenuFile.setVisible(true);
2032:                jMenuFile.setText(Resources.getTranslation("menu_file"));
2033:                jMenuFile.setMnemonic(getKeyEventKey(Resources
2034:                        .getTranslation("menu_file_trigger")));
2035:                jMenuFile.add(jMenuFileNewResourceBundle);
2036:                jMenuFile.add(jMenuFileOpenResourceBundle);
2037:                jMenuFile.add(jMenuFileSaveResourceBundle);
2038:                jMenuFile.add(jMenuFileSaveResourceBundleAs);
2039:                jMenuFile.addSeparator();
2040:                jMenuFile.add(jMenuFileImportResourceBundle);
2041:                jMenuFile.add(jMenuFileExportResourceBundle);
2042:                jMenuFile.addSeparator();
2043:                // Add the recent files to the file menu
2044:                Vector recentFiles = Preferences.getRecentFilesPreferences();
2045:                if (recentFiles.size() > 0) {
2046:                    for (int i = 0; i < recentFiles.size(); i += 2) {
2047:                        String name = (String) recentFiles.elementAt(i);
2048:                        String location = (String) recentFiles.elementAt(i + 1);
2049:                        JMenuItem recentMenuItem = new JMenuItem();
2050:                        recentMenuItem.setVisible(true);
2051:                        recentMenuItem.setText(name);
2052:                        recentMenuItem.setName("__" + location.trim());
2053:                        recentMenuItem.addActionListener(listener);
2054:                        jMenuFile.add(recentMenuItem);
2055:                    }
2056:                    jMenuFile.addSeparator();
2057:                }
2058:                jMenuFile.add(jMenuFileExit);
2059:
2060:                //jMenuFileImportResourceBundle.add(jMenuFileImportJava);
2061:                jMenuFileImportResourceBundle.add(jMenuFileImportProperties);
2062:                jMenuFileImportTMX.setEnabled(xmlAvailable);
2063:                jMenuFileImportResourceBundle.add(jMenuFileImportTMX);
2064:                jMenuFileImportXLF.setEnabled(xmlAvailable);
2065:                jMenuFileImportResourceBundle.add(jMenuFileImportXLF);
2066:                jMenuFileExportResourceBundle.add(jMenuFileExportJava);
2067:                jMenuFileExportResourceBundle.add(jMenuFileExportICU);
2068:                jMenuFileExportResourceBundle.add(jMenuFileExportProperties);
2069:                jMenuFileExportTMX.setEnabled(xmlAvailable);
2070:                jMenuFileExportResourceBundle.add(jMenuFileExportTMX);
2071:                jMenuFileExportXLF.setEnabled(xmlAvailable);
2072:                jMenuFileExportResourceBundle.add(jMenuFileExportXLF);
2073:
2074:                jMenuFileNewResourceBundle.setVisible(true);
2075:                jMenuFileNewResourceBundle.setText(Resources
2076:                        .getTranslation("menu_file_new"));
2077:                jMenuFileNewResourceBundle.setMnemonic(getKeyEventKey(Resources
2078:                        .getTranslation("menu_file_new_trigger")));
2079:                jMenuFileNewResourceBundle.setAccelerator(KeyStroke
2080:                        .getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
2081:                jMenuFileNewResourceBundle.addActionListener(listener);
2082:
2083:                jMenuFileOpenResourceBundle.setVisible(true);
2084:                jMenuFileOpenResourceBundle.setText(Resources
2085:                        .getTranslation("menu_file_open"));
2086:                jMenuFileOpenResourceBundle
2087:                        .setMnemonic(getKeyEventKey(Resources
2088:                                .getTranslation("menu_file_open_trigger")));
2089:                jMenuFileOpenResourceBundle.setAccelerator(KeyStroke
2090:                        .getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
2091:                jMenuFileOpenResourceBundle.addActionListener(listener);
2092:
2093:                jMenuFileSaveResourceBundle.setVisible(true);
2094:                jMenuFileSaveResourceBundle.setText(Resources
2095:                        .getTranslation("menu_file_save"));
2096:                jMenuFileSaveResourceBundle
2097:                        .setMnemonic(getKeyEventKey(Resources
2098:                                .getTranslation("menu_file_save_trigger")));
2099:                jMenuFileSaveResourceBundle.setAccelerator(KeyStroke
2100:                        .getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
2101:                jMenuFileSaveResourceBundle.addActionListener(listener);
2102:
2103:                jMenuFileSaveResourceBundleAs.setVisible(true);
2104:                jMenuFileSaveResourceBundleAs.setText(Resources
2105:                        .getTranslation("menu_file_saveas"));
2106:                jMenuFileSaveResourceBundleAs
2107:                        .setMnemonic(getKeyEventKey(Resources
2108:                                .getTranslation("menu_file_saveas_trigger")));
2109:                jMenuFileSaveResourceBundleAs.setAccelerator(KeyStroke
2110:                        .getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK
2111:                                | ActionEvent.SHIFT_MASK));
2112:                jMenuFileSaveResourceBundleAs.addActionListener(listener);
2113:
2114:                jMenuFileImportResourceBundle.setVisible(true);
2115:                jMenuFileImportResourceBundle.setText(Resources
2116:                        .getTranslation("menu_file_import"));
2117:                jMenuFileImportResourceBundle
2118:                        .setMnemonic(getKeyEventKey(Resources
2119:                                .getTranslation("menu_file_import_trigger")));
2120:                jMenuFileImportResourceBundle.addActionListener(listener);
2121:
2122:                jMenuFileImportJava.setVisible(true);
2123:                jMenuFileImportJava.setText(Resources
2124:                        .getTranslation("menu_file_import_java"));
2125:                jMenuFileImportJava.setMnemonic(getKeyEventKey(Resources
2126:                        .getTranslation("menu_file_import_java_trigger")));
2127:                jMenuFileImportJava.addActionListener(listener);
2128:
2129:                jMenuFileImportProperties.setVisible(true);
2130:                jMenuFileImportProperties.setText(Resources
2131:                        .getTranslation("menu_file_import_properties"));
2132:                jMenuFileImportProperties
2133:                        .setMnemonic(getKeyEventKey(Resources
2134:                                .getTranslation("menu_file_import_properties_trigger")));
2135:                jMenuFileImportProperties.addActionListener(listener);
2136:
2137:                jMenuFileImportTMX.setVisible(true);
2138:                jMenuFileImportTMX.setText(Resources
2139:                        .getTranslation("menu_file_import_TMX"));
2140:                jMenuFileImportTMX.setMnemonic(getKeyEventKey(Resources
2141:                        .getTranslation("menu_file_import_TMX_trigger")));
2142:                jMenuFileImportTMX.addActionListener(listener);
2143:
2144:                jMenuFileImportXLF.setVisible(true);
2145:                jMenuFileImportXLF.setText(Resources
2146:                        .getTranslation("menu_file_import_XLF"));
2147:                jMenuFileImportXLF.setMnemonic(getKeyEventKey(Resources
2148:                        .getTranslation("menu_file_import_XLF_trigger")));
2149:                jMenuFileImportXLF.addActionListener(listener);
2150:
2151:                jMenuFileExportResourceBundle.setVisible(true);
2152:                jMenuFileExportResourceBundle.setText(Resources
2153:                        .getTranslation("menu_file_export"));
2154:                jMenuFileExportResourceBundle
2155:                        .setMnemonic(getKeyEventKey(Resources
2156:                                .getTranslation("menu_file_export_trigger")));
2157:                jMenuFileExportResourceBundle.addActionListener(listener);
2158:
2159:                jMenuFileExportJava.setVisible(true);
2160:                jMenuFileExportJava.setText(Resources
2161:                        .getTranslation("menu_file_export_java"));
2162:                jMenuFileExportJava.setMnemonic(getKeyEventKey(Resources
2163:                        .getTranslation("menu_file_export_java_trigger")));
2164:                jMenuFileExportJava.addActionListener(listener);
2165:
2166:                jMenuFileExportICU.setVisible(true);
2167:                jMenuFileExportICU.setText(Resources
2168:                        .getTranslation("menu_file_export_ICU"));
2169:                jMenuFileExportICU.setMnemonic(getKeyEventKey(Resources
2170:                        .getTranslation("menu_file_export_ICU_trigger")));
2171:                jMenuFileExportICU.addActionListener(listener);
2172:
2173:                jMenuFileExportProperties.setVisible(true);
2174:                jMenuFileExportProperties.setText(Resources
2175:                        .getTranslation("menu_file_export_properties"));
2176:                jMenuFileExportProperties
2177:                        .setMnemonic(getKeyEventKey(Resources
2178:                                .getTranslation("menu_file_export_properties_trigger")));
2179:                jMenuFileExportProperties.addActionListener(listener);
2180:
2181:                jMenuFileExportTMX.setVisible(true);
2182:                jMenuFileExportTMX.setText(Resources
2183:                        .getTranslation("menu_file_export_TMX"));
2184:                jMenuFileExportTMX.setMnemonic(getKeyEventKey(Resources
2185:                        .getTranslation("menu_file_export_TMX_trigger")));
2186:                jMenuFileExportTMX.addActionListener(listener);
2187:
2188:                jMenuFileExportXLF.setVisible(true);
2189:                jMenuFileExportXLF.setText(Resources
2190:                        .getTranslation("menu_file_export_XLF"));
2191:                jMenuFileExportXLF.setMnemonic(getKeyEventKey(Resources
2192:                        .getTranslation("menu_file_export_XLF_trigger")));
2193:                jMenuFileExportXLF.addActionListener(listener);
2194:
2195:                jMenuFileExit.setVisible(true);
2196:                jMenuFileExit.setText(Resources
2197:                        .getTranslation("menu_file_quit"));
2198:                jMenuFileExit.setMnemonic(getKeyEventKey(Resources
2199:                        .getTranslation("menu_file_quit_trigger")));
2200:                jMenuFileExit.setAccelerator(KeyStroke.getKeyStroke(
2201:                        KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
2202:                jMenuFileExit.addActionListener(listener);
2203:
2204:                // Add Edit Menu Items to the Edit Menu
2205:                jMenuEdit.setVisible(true);
2206:                jMenuEdit.setText(Resources.getTranslation("menu_edit"));
2207:                jMenuEdit.setMnemonic(getKeyEventKey(Resources
2208:                        .getTranslation("menu_edit_trigger")));
2209:                jMenuEdit.add(jMenuEditCut);
2210:                jMenuEdit.add(jMenuEditCopy);
2211:                jMenuEdit.add(jMenuEditPaste);
2212:                jMenuEdit.add(jMenuEditDelete);
2213:
2214:                jMenuEditCut.setVisible(true);
2215:                jMenuEditCut.setText(Resources.getTranslation("menu_edit_cut"));
2216:                jMenuEditCut.setMnemonic(getKeyEventKey(Resources
2217:                        .getTranslation("menu_edit_cut_trigger")));
2218:                jMenuEditCut.setAccelerator(KeyStroke.getKeyStroke(
2219:                        KeyEvent.VK_X, ActionEvent.CTRL_MASK));
2220:
2221:                jMenuEditCopy.setVisible(true);
2222:                jMenuEditCopy.setText(Resources
2223:                        .getTranslation("menu_edit_copy"));
2224:                jMenuEditCopy.setMnemonic(getKeyEventKey(Resources
2225:                        .getTranslation("menu_edit_copy_trigger")));
2226:                jMenuEditCopy.setAccelerator(KeyStroke.getKeyStroke(
2227:                        KeyEvent.VK_C, ActionEvent.CTRL_MASK));
2228:
2229:                jMenuEditPaste.setVisible(true);
2230:                jMenuEditPaste.setText(Resources
2231:                        .getTranslation("menu_edit_paste"));
2232:                jMenuEditPaste.setMnemonic(getKeyEventKey(Resources
2233:                        .getTranslation("menu_edit_paste_trigger")));
2234:                jMenuEditPaste.setAccelerator(KeyStroke.getKeyStroke(
2235:                        KeyEvent.VK_V, ActionEvent.CTRL_MASK));
2236:
2237:                jMenuEditDelete.setVisible(true);
2238:                jMenuEditDelete.setText(Resources
2239:                        .getTranslation("menu_edit_delete"));
2240:                jMenuEditDelete.setMnemonic(getKeyEventKey(Resources
2241:                        .getTranslation("menu_edit_delete_trigger")));
2242:
2243:                // Add Options Menu Items to the Options Menu
2244:                jMenuOptions.setVisible(true);
2245:                jMenuOptions.setText(Resources.getTranslation("menu_options"));
2246:                jMenuOptions.setMnemonic(getKeyEventKey(Resources
2247:                        .getTranslation("menu_options_trigger")));
2248:                jMenuOptions.add(jMenuOptionsAddNewEntry);
2249:                jMenuOptions.add(jMenuOptionsAddNewGroup);
2250:                jMenuOptions.add(jMenuOptionsAddNewResourceFile);
2251:                //jMenuOptions.addSeparator();
2252:                //jMenuOptions.add(jMenuOptionsProjectViewer);
2253:                jMenuOptions.addSeparator();
2254:                jMenuOptions.add(jMenuOptionsPreferences);
2255:
2256:                jMenuOptionsAddNewEntry.setVisible(true);
2257:                jMenuOptionsAddNewEntry.setText(Resources
2258:                        .getTranslation("menu_options_addentry"));
2259:                jMenuOptionsAddNewEntry.setMnemonic(getKeyEventKey(Resources
2260:                        .getTranslation("menu_options_addentry_trigger")));
2261:                jMenuOptionsAddNewEntry.addActionListener(listener);
2262:
2263:                jMenuOptionsAddNewGroup.setVisible(true);
2264:                jMenuOptionsAddNewGroup.setText(Resources
2265:                        .getTranslation("menu_options_addgroup"));
2266:                jMenuOptionsAddNewGroup.setMnemonic(getKeyEventKey(Resources
2267:                        .getTranslation("menu_options_addgroup_trigger")));
2268:                jMenuOptionsAddNewGroup.addActionListener(listener);
2269:
2270:                jMenuOptionsAddNewResourceFile.setVisible(true);
2271:                jMenuOptionsAddNewResourceFile.setText(Resources
2272:                        .getTranslation("menu_options_addfile"));
2273:                jMenuOptionsAddNewResourceFile
2274:                        .setMnemonic(getKeyEventKey(Resources
2275:                                .getTranslation("menu_options_addfile_trigger")));
2276:                jMenuOptionsAddNewResourceFile.addActionListener(listener);
2277:
2278:                /*
2279:                jMenuOptionsProjectViewer.setVisible(true);
2280:                jMenuOptionsProjectViewer.setText(Resources.getTranslation("menu_options_project_viewer"));
2281:                jMenuOptionsProjectViewer.setMnemonic(getKeyEventKey(Resources.getTranslation("menu_options_project_viewer_trigger")));
2282:                jMenuOptionsProjectViewer.addActionListener(listener);
2283:                 */
2284:
2285:                jMenuOptionsPreferences.setVisible(true);
2286:                jMenuOptionsPreferences.setText(Resources
2287:                        .getTranslation("menu_options_preferences"));
2288:                jMenuOptionsPreferences.setMnemonic(getKeyEventKey(Resources
2289:                        .getTranslation("menu_options_preferences_trigger")));
2290:                jMenuOptionsPreferences.addActionListener(listener);
2291:
2292:                // Add View Menu Items to the View Menu
2293:                jMenuView.setVisible(true);
2294:                jMenuView.setText(Resources.getTranslation("menu_view"));
2295:                jMenuView.setMnemonic(getKeyEventKey(Resources
2296:                        .getTranslation("menu_view_trigger")));
2297:                jMenuView.add(jMenuViewViewStatistics);
2298:
2299:                jMenuViewViewStatistics.setVisible(true);
2300:                jMenuViewViewStatistics.setText(Resources
2301:                        .getTranslation("menu_view_statistics"));
2302:                jMenuViewViewStatistics.setMnemonic(getKeyEventKey(Resources
2303:                        .getTranslation("menu_view_statistics_trigger")));
2304:
2305:                // Add Help Menu Items to the Help Menu
2306:                jMenuHelp.setVisible(true);
2307:                jMenuHelp.setText(Resources.getTranslation("menu_help"));
2308:                jMenuHelp.setMnemonic(getKeyEventKey(Resources
2309:                        .getTranslation("menu_help_trigger")));
2310:                jMenuHelp.add(jMenuHelpAboutResourceBundleManager);
2311:
2312:                jMenuHelpAboutResourceBundleManager.setVisible(true);
2313:                jMenuHelpAboutResourceBundleManager.setText(Resources
2314:                        .getTranslation("menu_help_about"));
2315:                jMenuHelpAboutResourceBundleManager
2316:                        .setMnemonic(getKeyEventKey(Resources
2317:                                .getTranslation("menu_help_about_trigger")));
2318:                jMenuHelpAboutResourceBundleManager.setAccelerator(KeyStroke
2319:                        .getKeyStroke(KeyEvent.VK_H, ActionEvent.CTRL_MASK));
2320:                jMenuHelpAboutResourceBundleManager.addActionListener(listener);
2321:            }
2322:
2323:            public static int getKeyEventKey(String character) {
2324:                if (character == null)
2325:                    return KeyEvent.VK_A;
2326:                character = character.toUpperCase();
2327:
2328:                if (character.startsWith("A"))
2329:                    return KeyEvent.VK_A;
2330:                else if (character.startsWith("B"))
2331:                    return KeyEvent.VK_B;
2332:                else if (character.startsWith("C"))
2333:                    return KeyEvent.VK_C;
2334:                else if (character.startsWith("D"))
2335:                    return KeyEvent.VK_D;
2336:                else if (character.startsWith("E"))
2337:                    return KeyEvent.VK_E;
2338:                else if (character.startsWith("F"))
2339:                    return KeyEvent.VK_F;
2340:                else if (character.startsWith("G"))
2341:                    return KeyEvent.VK_G;
2342:                else if (character.startsWith("H"))
2343:                    return KeyEvent.VK_H;
2344:                else if (character.startsWith("I"))
2345:                    return KeyEvent.VK_I;
2346:                else if (character.startsWith("J"))
2347:                    return KeyEvent.VK_J;
2348:                else if (character.startsWith("K"))
2349:                    return KeyEvent.VK_K;
2350:                else if (character.startsWith("L"))
2351:                    return KeyEvent.VK_L;
2352:                else if (character.startsWith("M"))
2353:                    return KeyEvent.VK_M;
2354:                else if (character.startsWith("N"))
2355:                    return KeyEvent.VK_N;
2356:                else if (character.startsWith("O"))
2357:                    return KeyEvent.VK_O;
2358:                else if (character.startsWith("P"))
2359:                    return KeyEvent.VK_P;
2360:                else if (character.startsWith("Q"))
2361:                    return KeyEvent.VK_Q;
2362:                else if (character.startsWith("R"))
2363:                    return KeyEvent.VK_R;
2364:                else if (character.startsWith("S"))
2365:                    return KeyEvent.VK_S;
2366:                else if (character.startsWith("T"))
2367:                    return KeyEvent.VK_T;
2368:                else if (character.startsWith("U"))
2369:                    return KeyEvent.VK_U;
2370:                else if (character.startsWith("V"))
2371:                    return KeyEvent.VK_V;
2372:                else if (character.startsWith("W"))
2373:                    return KeyEvent.VK_W;
2374:                else if (character.startsWith("X"))
2375:                    return KeyEvent.VK_X;
2376:                else if (character.startsWith("Y"))
2377:                    return KeyEvent.VK_Y;
2378:                else if (character.startsWith("Z"))
2379:                    return KeyEvent.VK_Z;
2380:                else if (character.startsWith("0"))
2381:                    return KeyEvent.VK_0;
2382:                else if (character.startsWith("1"))
2383:                    return KeyEvent.VK_1;
2384:                else if (character.startsWith("2"))
2385:                    return KeyEvent.VK_2;
2386:                else if (character.startsWith("3"))
2387:                    return KeyEvent.VK_3;
2388:                else if (character.startsWith("4"))
2389:                    return KeyEvent.VK_4;
2390:                else if (character.startsWith("5"))
2391:                    return KeyEvent.VK_5;
2392:                else if (character.startsWith("6"))
2393:                    return KeyEvent.VK_6;
2394:                else if (character.startsWith("7"))
2395:                    return KeyEvent.VK_7;
2396:                else if (character.startsWith("8"))
2397:                    return KeyEvent.VK_8;
2398:                else if (character.startsWith("9"))
2399:                    return KeyEvent.VK_9;
2400:
2401:                return KeyEvent.VK_A;
2402:            }
2403:
2404:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.