Source Code Cross Referenced for FontsDialog.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » 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 » Report » iReport 2.0.5 » it.businesslogic.ireport.gui 
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:         * FontsDialog.java
028:         * 
029:         * Created on 7 maggio 2003, 23.43
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.gui;
034:
035:        import javax.swing.table.*;
036:        import javax.swing.*;
037:        import javax.swing.event.*;
038:        import it.businesslogic.ireport.*;
039:
040:        import java.util.*;
041:
042:        import org.apache.xerces.parsers.DOMParser;
043:        import org.w3c.dom.*;
044:        import org.xml.sax.SAXException;
045:        import it.businesslogic.ireport.util.I18n;
046:
047:        /**
048:         *
049:         * @author  Administrator
050:         */
051:        public class FontsDialog extends javax.swing.JDialog {
052:
053:            /** Creates new form ValuesDialog */
054:            public FontsDialog(java.awt.Frame parent, boolean modal) {
055:                super (parent, modal);
056:                initComponents();
057:                applyI18n();
058:                this .setSize(490, 250);
059:
060:                DefaultListSelectionModel dlsm = (DefaultListSelectionModel) this .jTableParameters
061:                        .getSelectionModel();
062:                dlsm
063:                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
064:                            public void valueChanged(ListSelectionEvent e) {
065:                                jTableParametersListSelectionValueChanged(e);
066:                            }
067:                        });
068:
069:                javax.swing.KeyStroke escape = javax.swing.KeyStroke
070:                        .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
071:                                false);
072:                javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
073:                    public void actionPerformed(java.awt.event.ActionEvent e) {
074:                        setVisible(false);
075:                    }
076:                };
077:
078:                getRootPane().getInputMap(
079:                        javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
080:                        escape, "ESCAPE");
081:                getRootPane().getActionMap().put("ESCAPE", escapeAction);
082:
083:                // Open in center...
084:                it.businesslogic.ireport.util.Misc.centerFrame(this );
085:            }
086:
087:            public void jTableParametersListSelectionValueChanged(
088:                    javax.swing.event.ListSelectionEvent e) {
089:                if (this .jTableParameters.getSelectedRowCount() > 0) {
090:                    this .jButtonModifyParameter.setEnabled(true);
091:                    this .jButtonDeleteParameter.setEnabled(true);
092:                } else {
093:                    this .jButtonModifyParameter.setEnabled(false);
094:                    this .jButtonDeleteParameter.setEnabled(false);
095:                }
096:            }
097:
098:            /** This method is called from within the constructor to
099:             * initialize the form.
100:             * WARNING: Do NOT modify this code. The content of this method is
101:             * always regenerated by the Form Editor.
102:             */
103:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
104:            private void initComponents() {
105:                java.awt.GridBagConstraints gridBagConstraints;
106:
107:                jPanelParameters = new javax.swing.JPanel();
108:                jScrollPane1 = new javax.swing.JScrollPane();
109:                jTableParameters = new javax.swing.JTable();
110:                jPanelButtons = new javax.swing.JPanel();
111:                jButtonNewParameter = new javax.swing.JButton();
112:                jButtonModifyParameter = new javax.swing.JButton();
113:                jButtonDeleteParameter = new javax.swing.JButton();
114:
115:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
116:                setTitle("Report fonts");
117:                addWindowListener(new java.awt.event.WindowAdapter() {
118:                    public void windowClosing(java.awt.event.WindowEvent evt) {
119:                        closeDialog(evt);
120:                    }
121:                });
122:
123:                jPanelParameters.setLayout(new java.awt.BorderLayout(2, 2));
124:
125:                jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
126:                jTableParameters
127:                        .setModel(new javax.swing.table.DefaultTableModel(
128:                                new Object[][] {
129:
130:                                }, new String[] { "Report font name", "Font",
131:                                        "Default" }) {
132:                            boolean[] canEdit = new boolean[] { false, false,
133:                                    false };
134:
135:                            public boolean isCellEditable(int rowIndex,
136:                                    int columnIndex) {
137:                                return canEdit[columnIndex];
138:                            }
139:                        });
140:                jScrollPane1.setViewportView(jTableParameters);
141:
142:                jPanelParameters
143:                        .add(jScrollPane1, java.awt.BorderLayout.CENTER);
144:
145:                jPanelButtons.setLayout(new java.awt.GridBagLayout());
146:
147:                jPanelButtons.setPreferredSize(new java.awt.Dimension(100, 10));
148:                jPanelButtons.setMinimumSize(new java.awt.Dimension(100, 10));
149:                jButtonNewParameter.setText("New");
150:                jButtonNewParameter
151:                        .addActionListener(new java.awt.event.ActionListener() {
152:                            public void actionPerformed(
153:                                    java.awt.event.ActionEvent evt) {
154:                                jButtonNewParameterActionPerformed(evt);
155:                            }
156:                        });
157:
158:                gridBagConstraints = new java.awt.GridBagConstraints();
159:                gridBagConstraints.gridx = 0;
160:                gridBagConstraints.gridy = 0;
161:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
162:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
163:                gridBagConstraints.insets = new java.awt.Insets(3, 3, 5, 3);
164:                jPanelButtons.add(jButtonNewParameter, gridBagConstraints);
165:
166:                jButtonModifyParameter.setText("Modify");
167:                jButtonModifyParameter.setEnabled(false);
168:                jButtonModifyParameter
169:                        .addActionListener(new java.awt.event.ActionListener() {
170:                            public void actionPerformed(
171:                                    java.awt.event.ActionEvent evt) {
172:                                jButtonModifyParameterActionPerformed(evt);
173:                            }
174:                        });
175:
176:                gridBagConstraints = new java.awt.GridBagConstraints();
177:                gridBagConstraints.gridx = 0;
178:                gridBagConstraints.gridy = 1;
179:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
180:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
182:                jPanelButtons.add(jButtonModifyParameter, gridBagConstraints);
183:
184:                jButtonDeleteParameter.setText("Delete");
185:                jButtonDeleteParameter.setEnabled(false);
186:                jButtonDeleteParameter
187:                        .addActionListener(new java.awt.event.ActionListener() {
188:                            public void actionPerformed(
189:                                    java.awt.event.ActionEvent evt) {
190:                                jButtonDeleteParameterActionPerformed(evt);
191:                            }
192:                        });
193:
194:                gridBagConstraints = new java.awt.GridBagConstraints();
195:                gridBagConstraints.gridx = 0;
196:                gridBagConstraints.gridy = 2;
197:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
198:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
199:                gridBagConstraints.weightx = 1.0;
200:                gridBagConstraints.weighty = 1.0;
201:                gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
202:                jPanelButtons.add(jButtonDeleteParameter, gridBagConstraints);
203:
204:                jPanelParameters.add(jPanelButtons, java.awt.BorderLayout.EAST);
205:
206:                getContentPane().add(jPanelParameters,
207:                        java.awt.BorderLayout.CENTER);
208:
209:                pack();
210:            }// </editor-fold>//GEN-END:initComponents
211:
212:            private void jButtonDeleteParameterActionPerformed(
213:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteParameterActionPerformed
214:
215:                jTableParameters.getSelectedRows();
216:
217:                while (this .jTableParameters.getSelectedRow() >= 0) {
218:                    int row = this .jTableParameters.getSelectedRow();
219:                    IReportFont font = (IReportFont) jTableParameters
220:                            .getValueAt(row, 0);
221:                    // Adjust all elements that refer to this font...
222:                    Enumeration e = this .getJReportFrame().getReport()
223:                            .getElements().elements();
224:                    while (e.hasMoreElements()) {
225:                        ReportElement re = (ReportElement) e.nextElement();
226:                        if (re instanceof  TextReportElement
227:                                && ((TextReportElement) re).getReportFont()
228:                                        .equals(font.getReportFont()))
229:                            ((TextReportElement) re).setReportFont("");
230:                    }
231:                    this .getJReportFrame().getReport().getFonts().remove(font);
232:                    this .jTableParameters.removeRowSelectionInterval(row, row);
233:                }
234:                updateReportFonts();
235:                ((MainFrame) this .getParent()).getElementPropertiesDialog()
236:                        .updateReportFonts();
237:                ((MainFrame) this .getParent()).getElementPropertiesDialog()
238:                        .updateSelection();
239:            }//GEN-LAST:event_jButtonDeleteParameterActionPerformed
240:
241:            private void jButtonModifyParameterActionPerformed(
242:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyParameterActionPerformed
243:
244:                JRFontDialog fd = new JRFontDialog(null, true);
245:                fd.updateFonts(this .getJReportFrame().getMainFrame()
246:                        .getTtfFonts());
247:                DefaultTableModel dtm = (DefaultTableModel) jTableParameters
248:                        .getModel();
249:                IReportFont font = (IReportFont) dtm.getValueAt(
250:                        jTableParameters.getSelectedRow(), 0);
251:
252:                fd.setIReportFont(font);
253:                fd.setVisible(true);
254:
255:                if (fd.getDialogResult() == JOptionPane.OK_OPTION) {
256:                    IReportFont new_font = fd.getIReportFont();
257:                    // If change the report font name, we must change all references...
258:                    String oldName = font.getReportFont();
259:                    font.setReportFont(new_font.getReportFont());
260:                    if (!it.businesslogic.ireport.util.Misc.nvl(oldName, "")
261:                            .equals(
262:                                    it.businesslogic.ireport.util.Misc.nvl(
263:                                            new_font.getReportFont(), ""))
264:                            && new_font.getReportFont() != null) {
265:                        // This modification can occur only in textElements....
266:                        Enumeration e = this .getJReportFrame().getReport()
267:                                .getElements().elements();
268:                        while (e.hasMoreElements()) {
269:                            ReportElement re = (ReportElement) e.nextElement();
270:                            if (re instanceof  TextReportElement
271:                                    && ((TextReportElement) re).getReportFont()
272:                                            .equals(oldName))
273:                                ((TextReportElement) re).setReportFont(new_font
274:                                        .getReportFont());
275:                        }
276:                    }
277:                    font.setFontName(new_font.getFontName());
278:                    font.setFontSize(new_font.getFontSize());
279:                    font.setBold(new_font.isBold());
280:                    font.setItalic(new_font.isItalic());
281:                    font.setPDFFontName(new_font.getPDFFontName());
282:                    font.setPdfEmbedded(new_font.isPdfEmbedded());
283:                    font.setPdfEncoding(new_font.getPdfEncoding());
284:                    font.setStrikeTrought(new_font.isStrikeTrought());
285:                    font.setUnderline(new_font.isUnderline());
286:                    font.setDefaultFont(new_font.isDefaultFont());
287:                    //font.setTTFFont( new_font.getTTFFont() );
288:
289:                    // Update the table row....
290:
291:                    jTableParameters.setValueAt(font, jTableParameters
292:                            .getSelectedRow(), 0);
293:                    jTableParameters.setValueAt(font.getDescription(),
294:                            jTableParameters.getSelectedRow(), 1);
295:                    jTableParameters.setValueAt(font.isDefaultFont() + "",
296:                            jTableParameters.getSelectedRow(), 2);
297:
298:                    jTableParameters.updateUI();
299:                    ((MainFrame) this .getParent()).getElementPropertiesDialog()
300:                            .updateReportFonts();
301:                    ((MainFrame) this .getParent()).getElementPropertiesDialog()
302:                            .updateSelection();
303:                    this .getJReportFrame().setIsDocDirty(true);
304:                    this .getJReportFrame().repaint();
305:                }
306:            }//GEN-LAST:event_jButtonModifyParameterActionPerformed
307:
308:            private void jButtonNewParameterActionPerformed(
309:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewParameterActionPerformed
310:                JRFontDialog fd = new JRFontDialog(null, true);
311:                fd.updateFonts(this .getJReportFrame().getMainFrame()
312:                        .getTtfFonts());
313:                fd.setVisible(true);
314:
315:                if (fd.getDialogResult() == JOptionPane.OK_OPTION) {
316:                    IReportFont font = fd.getIReportFont();
317:                    DefaultTableModel dtm = (DefaultTableModel) jTableParameters
318:                            .getModel();
319:                    revertDefaultFontProperties();
320:                    dtm.addRow(new Object[] { font, font.getDescription(),
321:                            font.isDefaultFont() + "" });
322:                    //
323:                    this .getJReportFrame().getReport().getFonts().addElement(
324:                            font);
325:                    /**
326:                     * update text elements and properties frame....
327:                     */
328:
329:                    this .getJReportFrame().getMainFrame()
330:                            .getElementPropertiesDialog().updateReportFonts();
331:                }
332:            }//GEN-LAST:event_jButtonNewParameterActionPerformed
333:
334:            /** Set defaultFont Property to false for all defined fonts in Report */
335:            private void revertDefaultFontProperties() {
336:                DefaultTableModel dtm = (DefaultTableModel) jTableParameters
337:                        .getModel();
338:                for (int i = 0; i < dtm.getRowCount(); i++) {
339:                    IReportFont font = (IReportFont) dtm.getValueAt(i, 0);
340:                    font.setDefaultFont(false);
341:                    jTableParameters
342:                            .setValueAt(font.isDefaultFont() + "", i, 2);
343:                }
344:                jTableParameters.updateUI();
345:                ((MainFrame) this .getParent()).getElementPropertiesDialog()
346:                        .updateReportFonts();
347:                ((MainFrame) this .getParent()).getElementPropertiesDialog()
348:                        .updateSelection();
349:            }
350:
351:            /** Closes the dialog */
352:            private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
353:                setVisible(false);
354:            }//GEN-LAST:event_closeDialog
355:
356:            /**
357:             * @param args the command line arguments
358:             */
359:            public static void main(String args[]) {
360:                new ValuesDialog(new javax.swing.JFrame(), true)
361:                        .setVisible(true);
362:            }
363:
364:            // Variables declaration - do not modify//GEN-BEGIN:variables
365:            private javax.swing.JButton jButtonDeleteParameter;
366:            private javax.swing.JButton jButtonModifyParameter;
367:            private javax.swing.JButton jButtonNewParameter;
368:            private javax.swing.JPanel jPanelButtons;
369:            private javax.swing.JPanel jPanelParameters;
370:            private javax.swing.JScrollPane jScrollPane1;
371:            private javax.swing.JTable jTableParameters;
372:            // End of variables declaration//GEN-END:variables
373:
374:            private JReportFrame jReportFrame;
375:
376:            /** Getter for property jReportFrame.
377:             * @return Value of property jReportFrame.
378:             *
379:             */
380:            public it.businesslogic.ireport.gui.JReportFrame getJReportFrame() {
381:                return jReportFrame;
382:            }
383:
384:            /** Setter for property jReportFrame.
385:             * @param jReportFrame New value of property jReportFrame.
386:             *
387:             */
388:            public void setJReportFrame(
389:                    it.businesslogic.ireport.gui.JReportFrame jReportFrame) {
390:                this .jReportFrame = jReportFrame;
391:
392:                if (jReportFrame == null) {
393:                    setVisible(false);
394:                    return;
395:                }
396:                this .setTitle(jReportFrame.getReport().getName() + " "
397:                        + I18n.getString("fontsDialog.fonts", " fonts..."));
398:                if (isVisible()) {
399:                    updateReportFonts();
400:                }
401:            }
402:
403:            public void updateReportFonts() {
404:                DefaultTableModel dtm = (DefaultTableModel) jTableParameters
405:                        .getModel();
406:                dtm.setRowCount(0);
407:
408:                if (jReportFrame != null) {
409:                    Enumeration e = jReportFrame.getReport().getFonts()
410:                            .elements();
411:                    while (e.hasMoreElements()) {
412:                        IReportFont font = (IReportFont) e.nextElement();
413:                        dtm.addRow(new Object[] { font, font.getDescription(),
414:                                font.isDefaultFont() + "" });
415:                    }
416:                }
417:            }
418:
419:            public void setVisible(boolean visible) {
420:                if (visible == isVisible())
421:                    return;
422:                super .setVisible(visible);
423:                if (visible == true) {
424:                    this .setJReportFrame(jReportFrame);
425:                }
426:            }
427:
428:            public void applyI18n() {
429:                // Start autogenerated code ----------------------
430:                jButtonDeleteParameter.setText(I18n.getString(
431:                        "fontsDialog.buttonDeleteParameter", "Delete"));
432:                jButtonModifyParameter.setText(I18n.getString(
433:                        "fontsDialog.buttonModifyParameter", "Modify"));
434:                jButtonNewParameter.setText(I18n.getString(
435:                        "fontsDialog.buttonNewParameter", "New"));
436:                // End autogenerated code ----------------------
437:
438:                jTableParameters.getColumnModel().getColumn(0).setHeaderValue(
439:                        I18n.getString(
440:                                "fontsDialog.tablecolumn.reportFontName",
441:                                "Report font name"));
442:                jTableParameters.getColumnModel().getColumn(1).setHeaderValue(
443:                        I18n.getString("fontsDialog.tablecolumn.font", "Font"));
444:                jTableParameters.getColumnModel().getColumn(2).setHeaderValue(
445:                        I18n.getString("fontsDialog.tablecolumn.default",
446:                                "Default"));
447:                this .setTitle(I18n.getString("fontsDialog.title",
448:                        "Report fonts"));
449:            }
450:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.