Source Code Cross Referenced for QueryLocalesDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » plugin » locale » 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 » Report » iReport 2.0.5 » it.businesslogic.ireport.plugin.locale 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * TranslationOptionsDialog.java
028:         * 
029:         * Created on 22 maggio 2005, 0.39
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.plugin.locale;
034:
035:        import it.businesslogic.ireport.util.I18n;
036:        import it.businesslogic.ireport.util.LocaleAdapter;
037:        import it.businesslogic.ireport.util.Misc;
038:        import java.awt.Cursor;
039:        import java.util.Arrays;
040:        import java.util.Locale;
041:        import javax.swing.DefaultListModel;
042:        import javax.swing.JOptionPane;
043:        import javax.swing.SwingUtilities;
044:
045:        /**
046:         *
047:         * @author  Administrator
048:         */
049:        public class QueryLocalesDialog extends javax.swing.JDialog implements 
050:                JasperBabylonRunnerListener {
051:
052:            private int dialogResult = JOptionPane.CANCEL_OPTION;
053:            private java.util.Properties localeProperties = null;
054:            private String locale_code = null;
055:
056:            /**
057:             * Creates new form TranslationOptionsDialog
058:             */
059:            public QueryLocalesDialog(java.awt.Dialog parent, boolean modal) {
060:                super (parent, modal);
061:                initComponents();
062:                applyI18n();
063:
064:                it.businesslogic.ireport.util.Misc.centerFrame(this );
065:
066:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
067:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
068:                                false);
069:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
070:                    public void actionPerformed(java.awt.event.ActionEvent e) {
071:                        jButton2ActionPerformed(e);
072:                    }
073:                };
074:
075:                getRootPane().getInputMap(
076:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
077:                        escape, "ESCAPE");
078:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
079:
080:                this .jButtonImport.setEnabled(false);
081:                jList1.setModel(new DefaultListModel());
082:
083:                //to make the default button ...
084:                this .getRootPane().setDefaultButton(this .jButton2);
085:            }
086:
087:            public void setVisible(boolean b) {
088:                super .setVisible(b);
089:            }
090:
091:            /** This method is called from within the constructor to
092:             * initialize the form.
093:             * WARNING: Do NOT modify this code. The content of this method is
094:             * always regenerated by the Form Editor.
095:             */
096:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
097:            private void initComponents() {
098:                java.awt.GridBagConstraints gridBagConstraints;
099:
100:                jLabelJasperBabylon = new javax.swing.JLabel();
101:                jScrollPane1 = new javax.swing.JScrollPane();
102:                jList1 = new javax.swing.JList();
103:                jSeparator1 = new javax.swing.JSeparator();
104:                jPanel1 = new javax.swing.JPanel();
105:                jPanel2 = new javax.swing.JPanel();
106:                jButtonImport = new javax.swing.JButton();
107:                jButton2 = new javax.swing.JButton();
108:
109:                getContentPane().setLayout(new java.awt.GridBagLayout());
110:
111:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
112:                addWindowListener(new java.awt.event.WindowAdapter() {
113:                    public void windowOpened(java.awt.event.WindowEvent evt) {
114:                        formWindowOpened(evt);
115:                    }
116:                });
117:
118:                jLabelJasperBabylon.setText("Available locales:");
119:                gridBagConstraints = new java.awt.GridBagConstraints();
120:                gridBagConstraints.gridx = 0;
121:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
122:                gridBagConstraints.weightx = 1.0;
123:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
124:                getContentPane().add(jLabelJasperBabylon, gridBagConstraints);
125:
126:                jScrollPane1.setPreferredSize(new java.awt.Dimension(300, 200));
127:                jList1.setModel(new javax.swing.AbstractListModel() {
128:                    String[] strings = { "Item 1", "Item 2", "Item 3",
129:                            "Item 4", "Item 5" };
130:
131:                    public int getSize() {
132:                        return strings.length;
133:                    }
134:
135:                    public Object getElementAt(int i) {
136:                        return strings[i];
137:                    }
138:                });
139:                jList1
140:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
141:                            public void valueChanged(
142:                                    javax.swing.event.ListSelectionEvent evt) {
143:                                jList1ValueChanged(evt);
144:                            }
145:                        });
146:
147:                jScrollPane1.setViewportView(jList1);
148:
149:                gridBagConstraints = new java.awt.GridBagConstraints();
150:                gridBagConstraints.gridx = 0;
151:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
152:                gridBagConstraints.weightx = 1.0;
153:                gridBagConstraints.weighty = 1.0;
154:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
155:                getContentPane().add(jScrollPane1, gridBagConstraints);
156:
157:                jSeparator1.setMinimumSize(new java.awt.Dimension(0, 4));
158:                jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4));
159:                gridBagConstraints = new java.awt.GridBagConstraints();
160:                gridBagConstraints.gridx = 0;
161:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
162:                gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
163:                gridBagConstraints.weightx = 1.0;
164:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
165:                getContentPane().add(jSeparator1, gridBagConstraints);
166:
167:                jPanel1.setLayout(new java.awt.GridBagLayout());
168:
169:                gridBagConstraints = new java.awt.GridBagConstraints();
170:                gridBagConstraints.weightx = 1.0;
171:                jPanel1.add(jPanel2, gridBagConstraints);
172:
173:                jButtonImport.setText("Import");
174:                jButtonImport
175:                        .addActionListener(new java.awt.event.ActionListener() {
176:                            public void actionPerformed(
177:                                    java.awt.event.ActionEvent evt) {
178:                                jButtonImportActionPerformed(evt);
179:                            }
180:                        });
181:
182:                gridBagConstraints = new java.awt.GridBagConstraints();
183:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
184:                jPanel1.add(jButtonImport, gridBagConstraints);
185:
186:                jButton2.setText("Cancel");
187:                jButton2.addActionListener(new java.awt.event.ActionListener() {
188:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
189:                        jButton2ActionPerformed(evt);
190:                    }
191:                });
192:
193:                gridBagConstraints = new java.awt.GridBagConstraints();
194:                gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 10);
195:                jPanel1.add(jButton2, gridBagConstraints);
196:
197:                gridBagConstraints = new java.awt.GridBagConstraints();
198:                gridBagConstraints.gridx = 0;
199:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
200:                gridBagConstraints.weightx = 1.0;
201:                getContentPane().add(jPanel1, gridBagConstraints);
202:
203:                pack();
204:            }// </editor-fold>//GEN-END:initComponents
205:
206:            private void jList1ValueChanged(
207:                    javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
208:
209:                if (jList1.getSelectedIndex() >= 0
210:                        && jList1.getSelectedValue() instanceof  LocaleAdapter) {
211:                    jButtonImport.setEnabled(true);
212:                } else {
213:                    jButtonImport.setEnabled(false);
214:                }
215:
216:            }//GEN-LAST:event_jList1ValueChanged
217:
218:            private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
219:                setVisible(false);
220:                dispose();
221:            }//GEN-LAST:event_jButton2ActionPerformed
222:
223:            private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
224:
225:                JasperBabylonRunner jbr = new JasperBabylonRunner();
226:                jbr.setRunnerListener(this );
227:                ((DefaultListModel) jList1.getModel()).clear();
228:                ((DefaultListModel) jList1.getModel())
229:                        .addElement("Reading locales...");
230:                jList1.updateUI();
231:                jbr.listLocales();
232:            }//GEN-LAST:event_formWindowOpened
233:
234:            private void jButtonImportActionPerformed(
235:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonImportActionPerformed
236:
237:                JasperBabylonRunner jbr = new JasperBabylonRunner();
238:                jbr.setRunnerListener(this );
239:                LocaleAdapter la = (LocaleAdapter) jList1.getSelectedValue();
240:
241:                String code = la.getLocale().getLanguage();
242:                if (la.getLocale().getCountry().length() > 0) {
243:                    code += "_" + la.getLocale().getCountry();
244:                }
245:                if (la.getLocale().getVariant().length() > 0) {
246:                    code += "_" + la.getLocale().getVariant();
247:                }
248:
249:                this .setLocale_code(code);
250:                jbr.getLocale(code);
251:
252:                this .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
253:                jButtonImport.setEnabled(false);
254:
255:            }//GEN-LAST:event_jButtonImportActionPerformed
256:
257:            // Variables declaration - do not modify//GEN-BEGIN:variables
258:            private javax.swing.JButton jButton2;
259:            private javax.swing.JButton jButtonImport;
260:            private javax.swing.JLabel jLabelJasperBabylon;
261:            private javax.swing.JList jList1;
262:            private javax.swing.JPanel jPanel1;
263:            private javax.swing.JPanel jPanel2;
264:            private javax.swing.JScrollPane jScrollPane1;
265:            private javax.swing.JSeparator jSeparator1;
266:
267:            // End of variables declaration//GEN-END:variables
268:
269:            public void applyI18n() {
270:
271:            }
272:
273:            public void listLocalesComplete(java.util.List list) {
274:                ((DefaultListModel) jList1.getModel()).clear();
275:                Object[] ar = list.toArray();
276:                Arrays.sort(ar);
277:
278:                for (int i = 0; i < ar.length; ++i) {
279:                    String code = "" + ar[i];
280:                    Locale loc = Misc.getLocaleFromString(code);
281:                    LocaleAdapter la = new LocaleAdapter(loc);
282:                    ((DefaultListModel) jList1.getModel()).addElement(la);
283:                }
284:
285:                try {
286:                    SwingUtilities.invokeAndWait(new Runnable() {
287:                        public void run() {
288:                            jList1.updateUI();
289:                        }
290:                    });
291:                } catch (Exception ex) {
292:                }
293:
294:            }
295:
296:            public void getLocaleComplete(java.util.Properties props) {
297:                setLocaleProperties(props);
298:                try {
299:                    SwingUtilities.invokeAndWait(new Runnable() {
300:                        public void run() {
301:                            setCursor(Cursor.getDefaultCursor());
302:                            setDialogResult(JOptionPane.OK_OPTION);
303:                            setVisible(false);
304:                            dispose();
305:                        }
306:                    });
307:                } catch (Exception ex) {
308:                    ex.printStackTrace();
309:                }
310:            }
311:
312:            public void putLocaleComplete(String returnMessage) {
313:
314:            }
315:
316:            public void operationError(int operation, String message) {
317:                if (operation == JasperBabylonRunner.OP_GET_LOCALE) {
318:                    try {
319:                        final String msg = message;
320:                        SwingUtilities.invokeAndWait(new Runnable() {
321:                            public void run() {
322:                                setCursor(Cursor.getDefaultCursor());
323:                                jList1ValueChanged(null);
324:                                JOptionPane.showMessageDialog(
325:                                        QueryLocalesDialog.this , msg);
326:                            }
327:                        });
328:                    } catch (Exception ex) {
329:                    }
330:                } else {
331:                    ((DefaultListModel) jList1.getModel()).clear();
332:                    ((DefaultListModel) jList1.getModel()).addElement(message);
333:
334:                    try {
335:                        SwingUtilities.invokeAndWait(new Runnable() {
336:                            public void run() {
337:                                jList1.updateUI();
338:                            }
339:                        });
340:                    } catch (Exception ex) {
341:                    }
342:                }
343:
344:            }
345:
346:            public java.util.Properties getLocaleProperties() {
347:                return localeProperties;
348:            }
349:
350:            public void setLocaleProperties(
351:                    java.util.Properties localeProperties) {
352:                this .localeProperties = localeProperties;
353:            }
354:
355:            public String getLocale_code() {
356:                return locale_code;
357:            }
358:
359:            public void setLocale_code(String locale_code) {
360:                this .locale_code = locale_code;
361:            }
362:
363:            public int getDialogResult() {
364:                return dialogResult;
365:            }
366:
367:            public void setDialogResult(int dialogResult) {
368:                this.dialogResult = dialogResult;
369:            }
370:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.