Source Code Cross Referenced for RBProjectItemPanel.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) 


001:        /*
002:         *****************************************************************************
003:         * Copyright (C) 2000-2004, International Business Machines Corporation and  *
004:         * others. All Rights Reserved.                                              *
005:         *****************************************************************************
006:         */
007:        package com.ibm.rbm.gui;
008:
009:        import java.awt.*;
010:        import java.awt.event.*;
011:        import java.util.Vector;
012:
013:        import javax.swing.*;
014:
015:        import com.ibm.rbm.*;
016:
017:        /**
018:         */
019:        class RBProjectItemPanel extends JPanel implements  ActionListener {
020:            RBManagerGUI gui;
021:
022:            // Visual Components
023:            Box mainBox;
024:            JTextField itemFields[];
025:            JLabel itemLabels[];
026:            JButton commitButtons[];
027:            JButton commitButton;
028:            JLabel titleLabel;
029:            JLabel keyLabel;
030:            JLabel commentLabel;
031:
032:            public RBProjectItemPanel(RBManagerGUI gui) {
033:                super ();
034:                this .gui = gui;
035:                initComponents();
036:            }
037:
038:            public void actionPerformed(ActionEvent ev) {
039:                JButton button = (JButton) ev.getSource();
040:                String buttonName = button.getName();
041:                if (buttonName == null) {
042:                    // Save all components
043:                    RBManager bundle = gui.getSelectedProjectBundle();
044:                    Vector bundles = bundle.getBundles();
045:                    for (int i = 0; i < itemFields.length; i++) {
046:                        String encoding = commitButtons[i].getName();
047:                        String translation = itemFields[i].getText();
048:                        String key = itemFields[i].getName();
049:                        for (int j = 0; j < bundles.size(); j++) {
050:                            Bundle rbundle = (Bundle) bundles.elementAt(j);
051:                            if (rbundle.encoding.equals(encoding)) {
052:                                BundleItem item = rbundle.getBundleItem(key);
053:                                if (item != null)
054:                                    item.setTranslation(translation);
055:                                break;
056:                            }
057:                        }
058:                    }
059:                    gui.saveResources(bundle);
060:                } else {
061:                    // Save a particular encoding
062:                    String encoding = buttonName;
063:                    RBManager bundle = gui.getSelectedProjectBundle();
064:                    int index = -1;
065:                    for (int i = 0; i < commitButtons.length; i++) {
066:                        if (commitButtons[i] == button) {
067:                            index = i;
068:                            break;
069:                        }
070:                    }
071:                    String translation = itemFields[index].getText();
072:                    String key = itemFields[index].getName();
073:                    Vector bundles = bundle.getBundles();
074:                    for (int i = 0; i < bundles.size(); i++) {
075:                        Bundle rbundle = (Bundle) bundles.elementAt(i);
076:                        if (rbundle.encoding.equals(encoding)) {
077:                            BundleItem item = rbundle.getBundleItem(key);
078:                            if (item != null) {
079:                                item.setTranslation(translation);
080:                                RBManagerGUI.debugMsg("Set translation to : "
081:                                        + translation);
082:                            } else
083:                                RBManagerGUI.debugMsg("Item was null");
084:                            break;
085:                        }
086:                        RBManagerGUI.debugMsg("Compared " + rbundle.encoding
087:                                + " with " + encoding);
088:                    }
089:                    gui.saveResources(bundle, encoding);
090:                }
091:                updateComponents();
092:            }
093:
094:            private void initComponents() {
095:                setLayout(new BorderLayout());
096:                JPanel topPanel = new JPanel(new GridLayout(2, 1));
097:                titleLabel = new JLabel(Resources
098:                        .getTranslation("project_panel_default_title"),
099:                        SwingConstants.CENTER);
100:                titleLabel.setFont(new Font("serif", Font.BOLD, 18));
101:                JPanel commentPanel = new JPanel(new GridLayout(2, 1));
102:                JLabel commentLabel2 = new JLabel(Resources
103:                        .getTranslation("project_panel_comment"),
104:                        SwingConstants.LEFT);
105:                commentLabel = new JLabel(Resources
106:                        .getTranslation("project_panel_comment_none"),
107:                        SwingConstants.LEFT);
108:                commentPanel.add(commentLabel2);
109:                commentPanel.add(commentLabel);
110:                topPanel.add(titleLabel);
111:                topPanel.add(commentPanel);
112:                JPanel centerPanel = new JPanel(new BorderLayout());
113:                mainBox = new Box(BoxLayout.Y_AXIS);
114:                JScrollPane scrollPane = new JScrollPane(mainBox,
115:                        ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
116:                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
117:                centerPanel.add(scrollPane, BorderLayout.NORTH);
118:                centerPanel.setBorder(BorderFactory.createEtchedBorder());
119:                JPanel botPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
120:                commitButton = new JButton(Resources
121:                        .getTranslation("project_panel_commit_button_all"));
122:                commitButton.addActionListener(this );
123:                botPanel.add(commitButton);
124:                add(topPanel, BorderLayout.NORTH);
125:                add(centerPanel, BorderLayout.CENTER);
126:                add(botPanel, BorderLayout.SOUTH);
127:
128:                updateComponents();
129:            }
130:
131:            public void updateComponents() {
132:                BundleItem item = gui.getSelectedProjectBundleItem();
133:
134:                if (item == null) {
135:                    commentLabel.setText(Resources
136:                            .getTranslation("project_panel_comment_none"));
137:                    titleLabel.setText(Resources
138:                            .getTranslation("project_panel_default_title"));
139:                    itemFields = null;
140:                    itemLabels = null;
141:                    commitButtons = null;
142:                    commitButton.setEnabled(false);
143:                } else {
144:                    String comment = item.getComment();
145:                    String key = item.getKey();
146:                    commentLabel.setText(comment);
147:                    titleLabel.setText(Resources.getTranslation(
148:                            "project_panel_title", key));
149:
150:                    RBManager manager = gui.getSelectedProjectBundle();
151:                    Vector bundles = manager.getBundles();
152:                    itemFields = new JTextField[bundles.size()];
153:                    itemLabels = new JLabel[bundles.size()];
154:                    commitButtons = new JButton[bundles.size()];
155:                    for (int i = 0; i < bundles.size(); i++) {
156:                        Bundle bundle = (Bundle) bundles.elementAt(i);
157:                        BundleItem bundleItem = bundle.getBundleItem(key);
158:                        //boolean translated = bundleItem.isTranslated();
159:                        JLabel encodingLabel = new JLabel(Resources
160:                                .getTranslation("project_panel_bundle", bundle
161:                                        .toString()), SwingConstants.LEFT);
162:                        if (bundleItem == null || !bundleItem.isTranslated()) {
163:                            encodingLabel.setText(Resources.getTranslation(
164:                                    "project_panel_bundle_untranslated", bundle
165:                                            .toString()));
166:                        }
167:                        String fieldText = (bundleItem == null ? Resources
168:                                .getTranslation("project_panel_item_inherits")
169:                                : bundleItem.getTranslation());
170:                        JTextField itemField = new JTextField(fieldText);
171:                        itemField.setMaximumSize(new Dimension(
172:                                this .getSize().width - 150, 200));
173:                        itemField.setName(key);
174:                        JButton commitItemButton = new JButton(Resources
175:                                .getTranslation("project_panel_commit_button"));
176:                        commitItemButton.addActionListener(this );
177:                        commitItemButton.setName(bundle.encoding);
178:                        itemFields[i] = itemField;
179:                        itemLabels[i] = encodingLabel;
180:                        commitButtons[i] = commitItemButton;
181:                    }
182:                    commitButton.setEnabled(true);
183:                }
184:
185:                mainBox.removeAll();
186:                if (itemFields != null) {
187:                    for (int i = 0; i < itemFields.length; i++) {
188:                        JPanel bundlePanel = new JPanel(new BorderLayout());
189:                        bundlePanel.setBorder(BorderFactory
190:                                .createLineBorder(Color.darkGray));
191:                        bundlePanel.add(itemLabels[i], BorderLayout.NORTH);
192:                        bundlePanel.add(itemFields[i], BorderLayout.CENTER);
193:                        bundlePanel.add(commitButtons[i], BorderLayout.EAST);
194:                        mainBox.add(bundlePanel);
195:                    }
196:                }
197:
198:                revalidate();
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.