Source Code Cross Referenced for FontsPathDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » gui » fonts » 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.gui.fonts 
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:         * FontsPathDialog.java
028:         *
029:         * Created on 22 aprile 2005, 18.05
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui.fonts;
034:
035:        import it.businesslogic.ireport.gui.*;
036:        import java.awt.event.MouseAdapter;
037:        import java.awt.event.MouseEvent;
038:        import javax.swing.DefaultListModel;
039:        import java.util.*;
040:        import javax.swing.JCheckBox;
041:        import it.businesslogic.ireport.util.I18n;
042:
043:        /**
044:         *
045:         * @author  Administrator
046:         */
047:        public class FontsPathDialog extends javax.swing.JDialog {
048:
049:            private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
050:            private boolean modifiedPath = false;
051:
052:            /** Creates new form ClassPathDialog */
053:            public FontsPathDialog(java.awt.Frame parent, boolean modal) {
054:                super (parent, modal);
055:                initComponents();
056:                applyI18n();
057:                jList1.setModel(new DefaultListModel());
058:                it.businesslogic.ireport.util.Misc.centerFrame(this );
059:
060:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
061:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
062:                                false);
063:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
064:                    public void actionPerformed(java.awt.event.ActionEvent e) {
065:                        jButtonCancelActionPerformed(e);
066:                    }
067:                };
068:
069:                getRootPane().getInputMap(
070:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
071:                        escape, "ESCAPE");
072:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
073:
074:                jList1.addMouseListener(new MouseAdapter() {
075:                    public void mousePressed(MouseEvent e) {
076:                        modifiedPath = true;
077:                    }
078:                });
079:
080:                //to make the default button ...
081:                this .getRootPane().setDefaultButton(this .jButtonSave);
082:            }
083:
084:            /** This method is called from within the constructor to
085:             * initialize the form.
086:             * WARNING: Do NOT modify this code. The content of this method is
087:             * always regenerated by the Form Editor.
088:             */
089:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
090:            private void initComponents() {
091:                java.awt.GridBagConstraints gridBagConstraints;
092:
093:                jLabelClasspath = new javax.swing.JLabel();
094:                jScrollPane1 = new javax.swing.JScrollPane();
095:                jList1 = new it.businesslogic.ireport.gui.fonts.CheckBoxList();
096:                jPanel1 = new javax.swing.JPanel();
097:                jButtonSelectAll = new javax.swing.JButton();
098:                jButtonDeselectAll = new javax.swing.JButton();
099:                jPanel2 = new javax.swing.JPanel();
100:                jButtonSave = new javax.swing.JButton();
101:                jButtonCancel = new javax.swing.JButton();
102:
103:                getContentPane().setLayout(new java.awt.GridBagLayout());
104:
105:                setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
106:                setTitle(it.businesslogic.ireport.util.I18n.getString("fonts",
107:                        "Classpath"));
108:                addWindowListener(new java.awt.event.WindowAdapter() {
109:                    public void windowClosed(java.awt.event.WindowEvent evt) {
110:                        formWindowClosed(evt);
111:                    }
112:
113:                    public void windowClosing(java.awt.event.WindowEvent evt) {
114:                        formWindowClosing(evt);
115:                    }
116:                });
117:
118:                jLabelClasspath
119:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
120:                jLabelClasspath.setText(it.businesslogic.ireport.util.I18n
121:                        .getString("fonts", "Fonts path"));
122:                gridBagConstraints = new java.awt.GridBagConstraints();
123:                gridBagConstraints.gridx = 0;
124:                gridBagConstraints.gridy = 0;
125:                gridBagConstraints.gridwidth = 2;
126:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
127:                gridBagConstraints.ipadx = 1;
128:                gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
129:                getContentPane().add(jLabelClasspath, gridBagConstraints);
130:
131:                jScrollPane1.setPreferredSize(new java.awt.Dimension(359, 260));
132:                jList1.setModel(new javax.swing.AbstractListModel() {
133:                    String[] strings = { "Item 1", "Item 2", "Item 3",
134:                            "Item 4", "Item 5" };
135:
136:                    public int getSize() {
137:                        return strings.length;
138:                    }
139:
140:                    public Object getElementAt(int i) {
141:                        return strings[i];
142:                    }
143:                });
144:                jScrollPane1.setViewportView(jList1);
145:
146:                gridBagConstraints = new java.awt.GridBagConstraints();
147:                gridBagConstraints.gridx = 0;
148:                gridBagConstraints.gridy = 1;
149:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
150:                gridBagConstraints.weightx = 1.0;
151:                gridBagConstraints.weighty = 1.0;
152:                gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
153:                getContentPane().add(jScrollPane1, gridBagConstraints);
154:
155:                jPanel1.setLayout(new java.awt.GridBagLayout());
156:
157:                jPanel1.setMinimumSize(new java.awt.Dimension(120, 10));
158:                jPanel1.setPreferredSize(new java.awt.Dimension(120, 10));
159:                jButtonSelectAll.setText(it.businesslogic.ireport.util.I18n
160:                        .getString("selectAll", "Select all"));
161:                jButtonSelectAll
162:                        .setMaximumSize(new java.awt.Dimension(200, 26));
163:                jButtonSelectAll.setMinimumSize(new java.awt.Dimension(90, 26));
164:                jButtonSelectAll.setPreferredSize(new java.awt.Dimension(120,
165:                        26));
166:                jButtonSelectAll
167:                        .addActionListener(new java.awt.event.ActionListener() {
168:                            public void actionPerformed(
169:                                    java.awt.event.ActionEvent evt) {
170:                                jButtonSelectAllActionPerformed(evt);
171:                            }
172:                        });
173:
174:                gridBagConstraints = new java.awt.GridBagConstraints();
175:                gridBagConstraints.gridx = 0;
176:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
177:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
178:                jPanel1.add(jButtonSelectAll, gridBagConstraints);
179:
180:                jButtonDeselectAll.setText(it.businesslogic.ireport.util.I18n
181:                        .getString("deSelectAll", "Deselect all"));
182:                jButtonDeselectAll.setMaximumSize(new java.awt.Dimension(200,
183:                        26));
184:                jButtonDeselectAll
185:                        .setMinimumSize(new java.awt.Dimension(90, 26));
186:                jButtonDeselectAll.setPreferredSize(new java.awt.Dimension(120,
187:                        26));
188:                jButtonDeselectAll
189:                        .addActionListener(new java.awt.event.ActionListener() {
190:                            public void actionPerformed(
191:                                    java.awt.event.ActionEvent evt) {
192:                                jButtonDeselectAllActionPerformed(evt);
193:                            }
194:                        });
195:
196:                gridBagConstraints = new java.awt.GridBagConstraints();
197:                gridBagConstraints.gridx = 0;
198:                gridBagConstraints.gridy = 1;
199:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
200:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
201:                jPanel1.add(jButtonDeselectAll, gridBagConstraints);
202:
203:                gridBagConstraints = new java.awt.GridBagConstraints();
204:                gridBagConstraints.gridx = 0;
205:                gridBagConstraints.weighty = 1.0;
206:                jPanel1.add(jPanel2, gridBagConstraints);
207:
208:                jButtonSave.setText(it.businesslogic.ireport.util.I18n
209:                        .getString("saveFontPath", "Save fonts path"));
210:                jButtonSave.setMaximumSize(new java.awt.Dimension(200, 26));
211:                jButtonSave.setMinimumSize(new java.awt.Dimension(90, 26));
212:                jButtonSave.setPreferredSize(new java.awt.Dimension(120, 26));
213:                jButtonSave
214:                        .addActionListener(new java.awt.event.ActionListener() {
215:                            public void actionPerformed(
216:                                    java.awt.event.ActionEvent evt) {
217:                                jButtonSaveActionPerformed(evt);
218:                            }
219:                        });
220:
221:                gridBagConstraints = new java.awt.GridBagConstraints();
222:                gridBagConstraints.gridx = 0;
223:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
224:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
225:                jPanel1.add(jButtonSave, gridBagConstraints);
226:
227:                jButtonCancel.setText(it.businesslogic.ireport.util.I18n
228:                        .getString("cancel", "Cancel"));
229:                jButtonCancel.setMaximumSize(new java.awt.Dimension(200, 26));
230:                jButtonCancel.setMinimumSize(new java.awt.Dimension(90, 26));
231:                jButtonCancel.setPreferredSize(new java.awt.Dimension(120, 26));
232:                jButtonCancel
233:                        .addActionListener(new java.awt.event.ActionListener() {
234:                            public void actionPerformed(
235:                                    java.awt.event.ActionEvent evt) {
236:                                jButtonCancelActionPerformed(evt);
237:                            }
238:                        });
239:
240:                gridBagConstraints = new java.awt.GridBagConstraints();
241:                gridBagConstraints.gridx = 0;
242:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
243:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
244:                jPanel1.add(jButtonCancel, gridBagConstraints);
245:
246:                gridBagConstraints = new java.awt.GridBagConstraints();
247:                gridBagConstraints.gridx = 1;
248:                gridBagConstraints.gridy = 1;
249:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
250:                gridBagConstraints.weighty = 1.0;
251:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 4);
252:                getContentPane().add(jPanel1, gridBagConstraints);
253:
254:                pack();
255:            }// </editor-fold>//GEN-END:initComponents
256:
257:            private void jButtonDeselectAllActionPerformed(
258:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeselectAllActionPerformed
259:                DefaultListModel dlm = (DefaultListModel) jList1.getModel();
260:
261:                for (int i = 0; i < dlm.size(); ++i) {
262:                    Object obj = dlm.getElementAt(i);
263:                    if (obj instanceof  JCheckBox) {
264:                        JCheckBox checkbox = (JCheckBox) obj;
265:                        checkbox.setSelected(false);
266:                    }
267:                }
268:                jList1.updateUI();
269:            }//GEN-LAST:event_jButtonDeselectAllActionPerformed
270:
271:            private void jButtonSelectAllActionPerformed(
272:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSelectAllActionPerformed
273:
274:                DefaultListModel dlm = (DefaultListModel) jList1.getModel();
275:
276:                for (int i = 0; i < dlm.size(); ++i) {
277:                    Object obj = dlm.getElementAt(i);
278:                    if (obj instanceof  JCheckBox) {
279:                        JCheckBox checkbox = (JCheckBox) obj;
280:                        checkbox.setSelected(true);
281:                    }
282:                }
283:                jList1.updateUI();
284:
285:            }//GEN-LAST:event_jButtonSelectAllActionPerformed
286:
287:            private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
288:
289:            }//GEN-LAST:event_formWindowClosed
290:
291:            private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
292:
293:                if (modifiedPath) {
294:                    int ret = javax.swing.JOptionPane.showConfirmDialog(this ,
295:                            it.businesslogic.ireport.util.I18n.getString(
296:                                    "saveFontsPathQuestion",
297:                                    "Do you want save the fontspath ?"));
298:
299:                    if (ret == javax.swing.JOptionPane.CANCEL_OPTION) {
300:                        return;
301:                    }
302:
303:                    jButtonSaveActionPerformed(null);
304:                } else {
305:                    setVisible(false);
306:                }
307:            }//GEN-LAST:event_formWindowClosing
308:
309:            private void jButtonCancelActionPerformed(
310:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
311:                setVisible(false);
312:            }//GEN-LAST:event_jButtonCancelActionPerformed
313:
314:            private void jButtonSaveActionPerformed(
315:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
316:
317:                javax.swing.JOptionPane
318:                        .showMessageDialog(
319:                                this ,
320:                                it.businesslogic.ireport.util.I18n
321:                                        .getString("saveFontsRestartInfo",
322:                                                "You have to restart iReport for the changes to take effect"));
323:
324:                setDialogResult(javax.swing.JOptionPane.OK_OPTION);
325:                setVisible(false);
326:            }//GEN-LAST:event_jButtonSaveActionPerformed
327:
328:            /**
329:             * @param args the command line arguments
330:             */
331:            public static void main(String args[]) {
332:                java.awt.EventQueue.invokeLater(new Runnable() {
333:                    public void run() {
334:                        new ClassPathDialog(new javax.swing.JFrame(), true)
335:                                .setVisible(true);
336:                    }
337:                });
338:            }
339:
340:            public void setFontspath(Vector fontPath, Vector cp) {
341:                Vector newcp = new Vector(cp);
342:                Vector cp_old = new Vector();
343:                String path = System.getProperty("java.class.path");
344:                //path += System.getProperty("path.separator") + "C:\\winnt\\fonts";
345:                if (path != null && path.length() > 0) {
346:                    StringTokenizer st = new StringTokenizer(path, System
347:                            .getProperty("path.separator"));
348:
349:                    while (st.hasMoreTokens()) {
350:                        String s = (String) st.nextToken();
351:                        if (!newcp.contains(s)) {
352:                            newcp.add(s);
353:                            cp_old.add(s);
354:                        }
355:                    }
356:                }
357:                for (int i = 0; i < fontPath.size(); ++i) {
358:                    String s = (String) fontPath.elementAt(i);
359:                    if (!newcp.contains(s)) {
360:                        newcp.add(s);
361:                    }
362:                }
363:
364:                Object[] allStrings = new Object[newcp.size()];
365:                newcp.copyInto(allStrings);
366:
367:                Arrays.sort(allStrings);
368:
369:                for (int i = 0; i < allStrings.length; ++i) {
370:                    String s = "" + allStrings[i];
371:                    CheckBoxListEntry cble = new CheckBoxListEntry(s, fontPath
372:                            .contains(s));
373:
374:                    if (!cp.contains(s) && !cp_old.contains(s)) {
375:                        cble.setRed(true);
376:                    }
377:
378:                    ((DefaultListModel) jList1.getModel()).addElement(cble);
379:                }
380:            }
381:
382:            public Vector getFontspath() {
383:                Vector cp = new Vector();
384:                java.util.List list = jList1.getCheckedItems();
385:                for (int i = 0; i < list.size(); ++i) {
386:                    CheckBoxListEntry cble = (CheckBoxListEntry) list.get(i);
387:                    cp.addElement(cble.getValue() + "");
388:                }
389:
390:                return cp;
391:            }
392:
393:            public int getDialogResult() {
394:                return dialogResult;
395:            }
396:
397:            public void setDialogResult(int dialogResult) {
398:                this .dialogResult = dialogResult;
399:            }
400:
401:            // Variables declaration - do not modify//GEN-BEGIN:variables
402:            private javax.swing.JButton jButtonCancel;
403:            private javax.swing.JButton jButtonDeselectAll;
404:            private javax.swing.JButton jButtonSave;
405:            private javax.swing.JButton jButtonSelectAll;
406:            private javax.swing.JLabel jLabelClasspath;
407:            private it.businesslogic.ireport.gui.fonts.CheckBoxList jList1;
408:            private javax.swing.JPanel jPanel1;
409:            private javax.swing.JPanel jPanel2;
410:            private javax.swing.JScrollPane jScrollPane1;
411:
412:            // End of variables declaration//GEN-END:variables
413:
414:            public void applyI18n() {
415:                // Start autogenerated code ----------------------
416:                // End autogenerated code ----------------------
417:            }
418:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.