Source Code Cross Referenced for ResourceCreationDialog.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:
012:        import javax.swing.*;
013:
014:        import com.ibm.rbm.*;
015:
016:        /**
017:         * A dialog for creating new Resource Files
018:         */
019:        class ResourceCreationDialog extends JDialog {
020:            RBManager rbm;
021:            RBManagerGUI gui;
022:
023:            // Components
024:            Box mainBox = new Box(BoxLayout.Y_AXIS);
025:            Box infoBox = new Box(BoxLayout.Y_AXIS);
026:            JPanel infoPanel = new JPanel();
027:            JPanel infoTitlePanel = new JPanel();
028:            JPanel infoCommentPanel = new JPanel();
029:            JPanel infoManagerPanel = new JPanel();
030:            JPanel langPanel = new JPanel();
031:            JPanel counPanel = new JPanel();
032:            JPanel variPanel = new JPanel();
033:            JPanel buttPanel = new JPanel();
034:
035:            JLabel instructionsLabel = new JLabel("");
036:            JLabel titleLabel = new JLabel(Resources
037:                    .getTranslation("dialog_file_title"));
038:            JLabel commentLabel = new JLabel(Resources
039:                    .getTranslation("dialog_file_comment"));
040:            JLabel managerLabel = new JLabel(Resources
041:                    .getTranslation("dialog_file_manager"));
042:            JLabel enc1Label = new JLabel(Resources
043:                    .getTranslation("dialog_encoding"));
044:            JLabel enc2Label = new JLabel(Resources
045:                    .getTranslation("dialog_encoding"));
046:            JLabel enc3Label = new JLabel(Resources
047:                    .getTranslation("dialog_encoding"));
048:            JLabel nam1Label = new JLabel(Resources
049:                    .getTranslation("dialog_name"));
050:            JLabel nam2Label = new JLabel(Resources
051:                    .getTranslation("dialog_name"));
052:            JLabel nam3Label = new JLabel(Resources
053:                    .getTranslation("dialog_name"));
054:
055:            JTextField titleField = new JTextField("");
056:            JTextField commentField = new JTextField("");
057:            JTextField managerField = new JTextField("");
058:            JTextField enc1Field = new JTextField("");
059:            JTextField enc2Field = new JTextField("");
060:            JTextField enc3Field = new JTextField("");
061:            JTextField nam1Field = new JTextField("");
062:            JTextField nam2Field = new JTextField("");
063:            JTextField nam3Field = new JTextField("");
064:
065:            JCheckBox copyCheckBox = new JCheckBox(Resources
066:                    .getTranslation("dialog_checkbox_copy_elements"), true);
067:
068:            JButton createButton = new JButton(Resources
069:                    .getTranslation("button_create"));
070:            JButton cancelButton = new JButton(Resources
071:                    .getTranslation("button_cancel"));
072:
073:            public ResourceCreationDialog(RBManager rbm, JFrame frame,
074:                    String title, boolean modal) {
075:                super (frame, title, modal);
076:                this .gui = (RBManagerGUI) frame;
077:                this .rbm = rbm;
078:                initComponents();
079:                enableEvents(AWTEvent.KEY_EVENT_MASK);
080:            }
081:
082:            protected void processKeyEvent(KeyEvent ev) {
083:                if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
084:                    boolean success = createResource();
085:                    if (!success) {
086:                        String alert = Resources
087:                                .getTranslation("error_create_file")
088:                                + " "
089:                                + Resources
090:                                        .getTranslation("error_try_again_file");
091:                        JOptionPane.showMessageDialog(this , alert, Resources
092:                                .getTranslation("error"),
093:                                JOptionPane.ERROR_MESSAGE);
094:                    } else {
095:                        setVisible(false);
096:                        dispose();
097:                    }
098:                } else if (ev.getKeyCode() == KeyEvent.VK_CANCEL) {
099:                    closeWindow();
100:                }
101:            }
102:
103:            boolean createResource() {
104:                if (rbm == null)
105:                    return false;
106:                String encoding = enc1Field.getText().trim();
107:                String enc2 = enc2Field.getText().trim();
108:                if (enc2 != null && !enc2.equals(""))
109:                    encoding += "_" + enc2;
110:                String enc3 = enc3Field.getText().trim();
111:                if (enc3 != null && !enc3.equals(""))
112:                    encoding += "_" + enc3;
113:                boolean ret = rbm.createResource(titleField.getText().trim(),
114:                        commentField.getText().trim(), managerField.getText()
115:                                .trim(), encoding, nam1Field.getText().trim(),
116:                        nam2Field.getText().trim(), nam3Field.getText().trim(),
117:                        copyCheckBox.isSelected());
118:                if (ret) {
119:                    gui.updateDisplayTree();
120:                    gui.updateProjectTree();
121:                    gui.updateProjectPanels();
122:                }
123:                return ret;
124:            }
125:
126:            public void initComponents() {
127:                // Error check
128:                if (rbm == null) {
129:                    String alert = Resources
130:                            .getTranslation("error_no_bundle_for_file");
131:                    JOptionPane
132:                            .showMessageDialog(this , alert, Resources
133:                                    .getTranslation("error"),
134:                                    JOptionPane.ERROR_MESSAGE);
135:                    closeWindow();
136:                    return;
137:                }
138:
139:                // Initialize values
140:                int tempWidth = 175;
141:                Dimension labelDim = new Dimension(tempWidth, 30);
142:                titleLabel.setPreferredSize(labelDim);
143:                commentLabel.setPreferredSize(labelDim);
144:                managerLabel.setPreferredSize(labelDim);
145:
146:                infoPanel.setBorder(BorderFactory.createTitledBorder(
147:                        BorderFactory.createEtchedBorder(), Resources
148:                                .getTranslation("dialog_file_info")));
149:                langPanel.setBorder(BorderFactory.createTitledBorder(
150:                        BorderFactory.createEtchedBorder(), Resources
151:                                .getTranslation("dialog_language")));
152:                counPanel.setBorder(BorderFactory.createTitledBorder(
153:                        BorderFactory.createEtchedBorder(), Resources
154:                                .getTranslation("dialog_country")));
155:                variPanel.setBorder(BorderFactory.createTitledBorder(
156:                        BorderFactory.createEtchedBorder(), Resources
157:                                .getTranslation("dialog_variant")));
158:
159:                titleField.setColumns(30);
160:                commentField.setColumns(30);
161:                managerField.setColumns(30);
162:
163:                enc1Field.setColumns(3);
164:                enc2Field.setColumns(3);
165:                enc3Field.setColumns(3);
166:                nam1Field.setColumns(20);
167:                nam2Field.setColumns(20);
168:                nam3Field.setColumns(20);
169:
170:                // Set up the components
171:                infoTitlePanel.add(titleLabel);
172:                infoTitlePanel.add(titleField);
173:                infoCommentPanel.add(commentLabel);
174:                infoCommentPanel.add(commentField);
175:                infoManagerPanel.add(managerLabel);
176:                infoManagerPanel.add(managerField);
177:                infoBox.add(infoTitlePanel);
178:                infoBox.add(infoCommentPanel);
179:                infoBox.add(infoManagerPanel);
180:                infoPanel.add(infoBox);
181:
182:                langPanel.add(enc1Label);
183:                langPanel.add(enc1Field);
184:                langPanel.add(nam1Label);
185:                langPanel.add(nam1Field);
186:                counPanel.add(enc2Label);
187:                counPanel.add(enc2Field);
188:                counPanel.add(nam2Label);
189:                counPanel.add(nam2Field);
190:                variPanel.add(enc3Label);
191:                variPanel.add(enc3Field);
192:                variPanel.add(nam3Label);
193:                variPanel.add(nam3Field);
194:
195:                buttPanel.add(createButton);
196:                buttPanel.add(cancelButton);
197:
198:                // Add the appropriate listeners
199:                cancelButton.addActionListener(new ActionListener() {
200:                    public void actionPerformed(ActionEvent ev) {
201:                        JDialog dialog = (JDialog) ((JButton) ev.getSource())
202:                                .getParent().getParent().getParent()
203:                                .getParent().getParent().getParent();
204:                        dialog.setVisible(false);
205:                        dialog.dispose();
206:                    }
207:                });
208:
209:                createButton.addActionListener(new ActionListener() {
210:                    public void actionPerformed(ActionEvent ev) {
211:                        ResourceCreationDialog dialog = (ResourceCreationDialog) ((JButton) ev
212:                                .getSource()).getParent().getParent()
213:                                .getParent().getParent().getParent()
214:                                .getParent();
215:                        boolean success = dialog.createResource();
216:                        if (!success) {
217:                            String alert = Resources
218:                                    .getTranslation("error_create_file")
219:                                    + " "
220:                                    + Resources
221:                                            .getTranslation("error_try_again_file");
222:                            JOptionPane.showMessageDialog(dialog, alert,
223:                                    Resources.getTranslation("error"),
224:                                    JOptionPane.ERROR_MESSAGE);
225:                        } else {
226:                            dialog.setVisible(false);
227:                            dialog.dispose();
228:                        }
229:                    }
230:                });
231:                getRootPane().setDefaultButton(createButton);
232:
233:                // Complete the component layout
234:                mainBox.removeAll();
235:                //mainBox.add(instructionsLabel);
236:                mainBox.add(infoPanel);
237:                mainBox.add(langPanel);
238:                mainBox.add(counPanel);
239:                mainBox.add(variPanel);
240:                mainBox.add(copyCheckBox);
241:                mainBox.add(buttPanel);
242:
243:                setLocation(new java.awt.Point(50, 50));
244:                getContentPane().add(mainBox, BorderLayout.CENTER);
245:                validateTree();
246:                pack();
247:                setVisible(true);
248:                //setResizable(false);
249:            }
250:
251:            void closeWindow() {
252:                setVisible(false);
253:                dispose();
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.