001: /*
002: * Copyright (C) 2004 Giuseppe MANNA
003: *
004: * This file is part of FreeReportBuilder
005: *
006: * FreeReportBuilder is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * 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, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package it.frb;
023:
024: import java.io.OutputStream;
025: import java.io.PrintStream;
026: import javax.swing.JLabel;
027: import javax.swing.JTextArea;
028: import javax.swing.JTextField;
029:
030: public class XmlFileWriter {
031: java.awt.Container container;
032: java.io.FileWriter flws;
033:
034: String pathSaveFile;
035: OutputStream outXmlStream = null;
036: PrintStream printXmlStream = null;
037:
038: public XmlFileWriter(java.awt.Container cont, String path) {
039: this .container = cont;
040: this .pathSaveFile = path;
041: }
042:
043: public XmlFileWriter(java.awt.Container cont,
044: OutputStream outXmlStream) {
045: this .container = cont;
046: this .outXmlStream = outXmlStream;
047: this .printXmlStream = new PrintStream(outXmlStream);
048: }
049:
050: public static String replace(StringBuffer sbSource, int nStart,
051: int nEnd, String sStr) {
052: String sHead = sbSource.toString().substring(0, nStart);
053: String sFoot = sbSource.toString().substring(nEnd);
054:
055: StringBuffer sbRet = new StringBuffer(sHead);
056: sbRet.append(sStr);
057: sbRet.append(sFoot);
058:
059: return sbRet.toString();
060: }
061:
062: private String replaceString(String strSource, String strFind,
063: String strReplace) {
064: int indice = strSource.indexOf(strFind);
065:
066: if (indice >= 0) {
067: String s = replace(new StringBuffer(strSource), indice,
068: indice + strFind.length(), strReplace);
069: strSource = this .replaceString(s, strFind, strReplace);
070: }
071:
072: return strSource;
073: }
074:
075: private String replaceSpecialCharacter(String source) {
076: if (source != null) {
077: //source =replaceString(source,"&","&");
078: source = replaceString(source, "&", "?");
079: source = replaceString(source, "<", "<");
080: source = replaceString(source, ">", ">");
081: source = replaceString(source, "'", "'");
082: source = replaceString(source, "\"", """);
083:
084: /*
085: source =replaceString(source,"Á","?");
086: source =replaceString(source,"À","?");
087: source =replaceString(source,"Â","?");
088: source =replaceString(source,"Ã","?");
089: source =replaceString(source,"Å","?");
090: source =replaceString(source,"Ä","?");
091: source =replaceString(source,"Æ","?");
092: source =replaceString(source,"Ç","?");
093: source =replaceString(source,"É","?");
094: source =replaceString(source,"È","?");
095: source =replaceString(source,"Ê","?");
096: source =replaceString(source,"Ë","?");
097: source =replaceString(source,"Í","?");
098: source =replaceString(source,"Ì","?");
099: source =replaceString(source,"Î","?");
100: source =replaceString(source,"Ï","?");
101: source =replaceString(source,"Ð","?");
102: source =replaceString(source,"Ñ","?");
103: source =replaceString(source,"Ó","?");
104: source =replaceString(source,"Ò","?");
105: source =replaceString(source,"Ô","?");
106: source =replaceString(source,"Õ","?");
107: source =replaceString(source,"Ö","?");
108: source =replaceString(source,"Ø","?");
109: source =replaceString(source,"Ú","?");
110: source =replaceString(source,"Ù","?");
111: source =replaceString(source,"Û","?");
112: source =replaceString(source,"Ü","?");
113: source =replaceString(source,"Ý","?");
114: source =replaceString(source,"Þ","?");
115: source =replaceString(source,"ß","?");
116: source =replaceString(source,"á","?");
117: source =replaceString(source,"à","?");
118: source =replaceString(source,"â","?");
119: source =replaceString(source,"ã","?");
120: source =replaceString(source,"å","?");
121: source =replaceString(source,"ä","?");
122: source =replaceString(source,"æ","?");
123: source =replaceString(source,"ç","?");
124: source =replaceString(source,"é","?");
125: source =replaceString(source,"è","?");
126: source =replaceString(source,"í","?");
127: source =replaceString(source,"ì","?");
128: source =replaceString(source,"î","?");
129: source =replaceString(source,"ï","?");
130: source =replaceString(source,"ð","?");
131: source =replaceString(source,"ñ","?");
132: source =replaceString(source,"ó","?");
133: source =replaceString(source,"ò","?");
134: source =replaceString(source,"ô","?");
135: source =replaceString(source,"õ","?");
136: source =replaceString(source,"ö","?");
137: source =replaceString(source,"ø","?");
138: source =replaceString(source,"ú","?");
139: source =replaceString(source,"ù","?");
140: source =replaceString(source,"û","?");
141: source =replaceString(source,"ü","?");
142: source =replaceString(source,"ý","?");
143: source =replaceString(source,"þ","?");
144: source =replaceString(source,"ÿ","?");
145: source =replaceString(source,"ë","?");
146: source =replaceString(source,"ê","?");
147:
148: source =replaceString(source,"&","&");
149: source =replaceString(source,"Á","Á");
150: source =replaceString(source,"À","À");
151: source =replaceString(source,"Â","Â");
152: source =replaceString(source,"Ã","Ã");
153: source =replaceString(source,"Å","Å");
154: source =replaceString(source,"Ä","Ä");
155: source =replaceString(source,"Æ","Æ");
156: source =replaceString(source,"Ç","Ç");
157: source =replaceString(source,"É","É");
158: source =replaceString(source,"È","È");
159: source =replaceString(source,"Ê","Ê");
160: source =replaceString(source,"Ë","Ë");
161: source =replaceString(source,"Í","Í");
162: source =replaceString(source,"Ì","Ì");
163: source =replaceString(source,"Î","Î");
164: source =replaceString(source,"Ï","Ï");
165: source =replaceString(source,"Ð","Ð");
166: source =replaceString(source,"Ñ","Ñ");
167: source =replaceString(source,"Ó","Ó");
168: source =replaceString(source,"Ò","Ò");
169: source =replaceString(source,"Ô","Ô ");
170: source =replaceString(source,"Õ","Õ");
171: source =replaceString(source,"Ö","Ö");
172: source =replaceString(source,"Ø","Ø");
173: source =replaceString(source,"Ú","Ú");
174: source =replaceString(source,"Ù","Ù");
175: source =replaceString(source,"Û","Û");
176: source =replaceString(source,"Ü","Ü");
177: source =replaceString(source,"Ý","Ý");
178: source =replaceString(source,"Þ","Þ");
179: source =replaceString(source,"ß","ß");
180: source =replaceString(source,"á","á");
181: source =replaceString(source,"à","à");
182: source =replaceString(source,"â","â ");
183: source =replaceString(source,"ã","ã");
184: source =replaceString(source,"å","å");
185: source =replaceString(source,"ä","ä");
186: source =replaceString(source,"æ","æ");
187: source =replaceString(source,"ç","ç");
188: source =replaceString(source,"é","é");
189: source =replaceString(source,"è","è");
190: source =replaceString(source,"í","í");
191: source =replaceString(source,"ì","ì");
192: source =replaceString(source,"î","î");
193: source =replaceString(source,"ï","ï");
194: source =replaceString(source,"ð","ð");
195: source =replaceString(source,"ñ","ñ");
196: source =replaceString(source,"ó","ó");
197: source =replaceString(source,"ò","ò");
198: source =replaceString(source,"ô","ô");
199: source =replaceString(source,"õ","õ");
200: source =replaceString(source,"ö","ö");
201: source =replaceString(source,"ø","ø");
202: source =replaceString(source,"ú","ú");
203: source =replaceString(source,"ù","ù");
204: source =replaceString(source,"û","û ");
205: source =replaceString(source,"ü","ü");
206: source =replaceString(source,"ý","ý");
207: source =replaceString(source,"þ","þ ");
208: source =replaceString(source,"ÿ","ÿ");
209: source =replaceString(source,"ë","ë");
210: source =replaceString(source,"ê","ê");
211: */
212: }
213:
214: return source;
215: }
216:
217: public void writeOnStream() {
218: try {
219: if (!(container instanceof DataPanel)) {
220: printXmlStream.print("<Objects>");
221: printXmlStream.print("\r");
222:
223: this .writeContainer(container);
224: printXmlStream.print("</Objects>");
225:
226: printXmlStream.close();
227:
228: } else {
229: DataPanel datapanel = (DataPanel) container;
230: int groupCount = datapanel.getGroupCount();
231:
232: printXmlStream.print("<DataPanel groupCount=\""
233: + datapanel.getGroupCount() + "\">");
234: printXmlStream.print("\r");
235:
236: printXmlStream.print("<Header height=\""
237: + datapanel.getHeaderDividerRelativeLocation()
238: + "\">");
239: printXmlStream.print("\r");
240: printXmlStream.print(" <Objects>");
241: printXmlStream.print("\r");
242: this .writeContainer(datapanel.getHeaderPanel());
243: printXmlStream.print(" </Objects>");
244: printXmlStream.print("\r");
245: printXmlStream.print("</Header>");
246:
247: for (int i = 1; i <= groupCount; i++) {
248: printXmlStream.print("\r");
249: printXmlStream
250: .print("<Header."
251: + i
252: + " height=\""
253: + datapanel
254: .getHeaderGroupDividerRelativeLocation(i)
255: + "\">");
256: printXmlStream.print("\r");
257: printXmlStream.print(" <Objects>");
258: printXmlStream.print("\r");
259: this .writeContainer(datapanel
260: .getHeaderGroupPanel(i));
261: printXmlStream.print(" </Objects>");
262: printXmlStream.print("\r");
263: printXmlStream.print("</Header." + i + ">");
264: }
265:
266: printXmlStream.print("\r");
267: printXmlStream.print("<Detail height=\""
268: + datapanel.getDetailDividerRelativeLocation()
269: + "\">");
270: printXmlStream.print("\r");
271: printXmlStream.print(" <Objects>");
272: printXmlStream.print("\r");
273: this .writeContainer(datapanel.getDetailPanel());
274: printXmlStream.print(" </Objects>");
275: printXmlStream.print("\r");
276: printXmlStream.print("</Detail>");
277:
278: int countDown = groupCount;
279:
280: for (int i = 1; i <= groupCount; i++) {
281: printXmlStream.print("\r");
282: printXmlStream
283: .print("<Trailer."
284: + countDown
285: + " height=\""
286: + datapanel
287: .getTrailerGroupDividerRelativeLocation(countDown)
288: + "\">");
289: printXmlStream.print("\r");
290: printXmlStream.print(" <Objects>");
291: printXmlStream.print("\r");
292: this .writeContainer(datapanel
293: .getTrailerGroupPanel(countDown));
294: printXmlStream.print(" </Objects>");
295: printXmlStream.print("\r");
296: printXmlStream
297: .print("</Trailer." + countDown + ">");
298: countDown = countDown - 1;
299: }
300:
301: printXmlStream.print("\r");
302: printXmlStream.print("<Summary height=\""
303: + datapanel.getSummaryDividerRelativeLocation()
304: + "\">");
305: printXmlStream.print("\r");
306: printXmlStream.print(" <Objects>");
307: printXmlStream.print("\r");
308: this .writeContainer(datapanel.getSummaryPanel());
309: printXmlStream.print(" </Objects>");
310: printXmlStream.print("\r");
311: printXmlStream.print("</Summary>");
312:
313: printXmlStream.print("\r");
314: printXmlStream.print("<Footer height=\""
315: + datapanel.getFooterDividerRelativeLocation()
316: + "\">");
317: printXmlStream.print("\r");
318: printXmlStream.print(" <Objects>");
319: printXmlStream.print("\r");
320: this .writeContainer(datapanel.getFooterPanel());
321: printXmlStream.print(" </Objects>");
322: printXmlStream.print("\r");
323: printXmlStream.print("</Footer>");
324: printXmlStream.print("\r");
325:
326: printXmlStream.print("<SQL xml:space=\"preserve\">");
327: //printXmlStream.print(replaceSpecialCharacter(datapanel.getSql()));
328:
329: String sql = datapanel.getSql();
330: if (sql != null) {
331: sql = replaceString(sql, "<", "<");
332: sql = replaceString(sql, ">", ">");
333: }
334: printXmlStream.print(sql);
335:
336: printXmlStream.print("\r");
337: printXmlStream.print("</SQL>");
338: printXmlStream.print("\r");
339:
340: printXmlStream.print("</DataPanel>");
341: printXmlStream.close();
342: }
343:
344: } catch (java.io.IOException e) {
345: System.out.println(e.getMessage());
346: }
347: }
348:
349: public void writeOnFile() {
350: try {
351: flws = new java.io.FileWriter(pathSaveFile, false);
352:
353: if (!(container instanceof DataPanel)) {
354: flws.write("<Objects>");
355: flws.write("\r");
356:
357: this .writeContainer(container);
358: flws.write("</Objects>");
359:
360: flws.close();
361:
362: } else {
363: DataPanel datapanel = (DataPanel) container;
364: int groupCount = datapanel.getGroupCount();
365:
366: flws.write("<DataPanel groupCount=\""
367: + datapanel.getGroupCount() + "\">");
368: flws.write("\r");
369:
370: flws.write("<Header height=\""
371: + datapanel.getHeaderDividerRelativeLocation()
372: + "\">");
373: flws.write("\r");
374: flws.write(" <Objects>");
375: flws.write("\r");
376: this .writeContainer(datapanel.getHeaderPanel());
377: flws.write(" </Objects>");
378: flws.write("\r");
379: flws.write("</Header>");
380:
381: for (int i = 1; i <= groupCount; i++) {
382: flws.write("\r");
383: flws
384: .write("<Header."
385: + i
386: + " height=\""
387: + datapanel
388: .getHeaderGroupDividerRelativeLocation(i)
389: + "\">");
390: flws.write("\r");
391: flws.write(" <Objects>");
392: flws.write("\r");
393: this .writeContainer(datapanel
394: .getHeaderGroupPanel(i));
395: flws.write(" </Objects>");
396: flws.write("\r");
397: flws.write("</Header." + i + ">");
398: }
399:
400: flws.write("\r");
401: flws.write("<Detail height=\""
402: + datapanel.getDetailDividerRelativeLocation()
403: + "\">");
404: flws.write("\r");
405: flws.write(" <Objects>");
406: flws.write("\r");
407: this .writeContainer(datapanel.getDetailPanel());
408: flws.write(" </Objects>");
409: flws.write("\r");
410: flws.write("</Detail>");
411:
412: int countDown = groupCount;
413:
414: for (int i = 1; i <= groupCount; i++) {
415: flws.write("\r");
416: flws
417: .write("<Trailer."
418: + countDown
419: + " height=\""
420: + datapanel
421: .getTrailerGroupDividerRelativeLocation(countDown)
422: + "\">");
423: flws.write("\r");
424: flws.write(" <Objects>");
425: flws.write("\r");
426: this .writeContainer(datapanel
427: .getTrailerGroupPanel(countDown));
428: flws.write(" </Objects>");
429: flws.write("\r");
430: flws.write("</Trailer." + countDown + ">");
431: countDown = countDown - 1;
432: }
433:
434: flws.write("\r");
435: flws.write("<Summary height=\""
436: + datapanel.getSummaryDividerRelativeLocation()
437: + "\">");
438: flws.write("\r");
439: flws.write(" <Objects>");
440: flws.write("\r");
441: this .writeContainer(datapanel.getSummaryPanel());
442: flws.write(" </Objects>");
443: flws.write("\r");
444: flws.write("</Summary>");
445:
446: flws.write("\r");
447: flws.write("<Footer height=\""
448: + datapanel.getFooterDividerRelativeLocation()
449: + "\">");
450: flws.write("\r");
451: flws.write(" <Objects>");
452: flws.write("\r");
453: this .writeContainer(datapanel.getFooterPanel());
454: flws.write(" </Objects>");
455: flws.write("\r");
456: flws.write("</Footer>");
457: flws.write("\r");
458:
459: flws.write("<SQL xml:space=\"preserve\">");
460: //flws.write(replaceSpecialCharacter(datapanel.getSql()));
461:
462: String sql = datapanel.getSql();
463: if (sql != null) {
464: sql = replaceString(sql, "<", "<");
465: sql = replaceString(sql, ">", ">");
466: }
467: flws.write(sql);
468:
469: flws.write("\r");
470: flws.write("</SQL>");
471: flws.write("\r");
472:
473: flws.write("</DataPanel>");
474: flws.close();
475: }
476:
477: } catch (java.io.IOException e) {
478: System.out.println(e.getMessage());
479: }
480: }
481:
482: public void write() {
483: if (outXmlStream == null) {
484: this .writeOnFile();
485: } else {
486: this .writeOnStream();
487: }
488: }
489:
490: public void writeContainer(java.awt.Container panel)
491: throws java.io.IOException {
492: writeContainer(panel, 0, 0);
493: }
494:
495: public void writeContainer(java.awt.Container panel, int x, int y)
496: throws java.io.IOException {
497: int countComponent = panel.getComponentCount();
498:
499: if (countComponent > 0) {
500: for (int i = 0; i <= countComponent - 1; i++) {
501: java.awt.Component comp = panel.getComponent(i);
502:
503: if (comp.isVisible() == true) {
504:
505: if (comp.getClass().getName() == "javax.swing.JLabel") {
506: flws.write(" <" + comp.getClass().getName()
507: + ">\n");
508: flws.write(" <location x=\""
509: + (comp.getX() + x) + "\" y=\""
510: + (comp.getY() + y)
511: + "\"></location>\n");
512: flws
513: .write(" <setText xml:space=\"preserve\">\n");
514: flws
515: .write(" <param value=\""
516: + replaceSpecialCharacter(((JLabel) comp)
517: .getText())
518: + "\" class=\"java.lang.String\"></param>\n");
519: flws.write(" </setText>\n");
520: flws.write(" <setFont>\n");
521: java.awt.Font font = ((JLabel) comp).getFont();
522: flws
523: .write(" <param value=\""
524: + font.getFamily()
525: + "\" class=\"java.lang.String\"></param>\n");
526: flws.write(" <param value=\""
527: + font.getStyle()
528: + "\" class=\"int\"></param>\n");
529: flws.write(" <param value=\""
530: + font.getSize()
531: + "\" class=\"int\"></param>\n");
532: flws.write(" </setFont>\n");
533: if (((JLabel) comp).getName() != null) {
534: flws.write(" <setIcon>\n");
535: flws
536: .write(" <param value=\""
537: + ((JLabel) comp).getName()
538: + "\" class=\"javax.swing.Icon\"></param>\n");
539: flws.write(" </setIcon>\n");
540: flws.write(" <setName>\n");
541: flws
542: .write(" <param value=\""
543: + ((JLabel) comp).getName()
544: + "\" class=\"java.lang.String\"></param>\n");
545: flws.write(" </setName>\n");
546: }
547: flws.write(" <setForeground>\n");
548: flws
549: .write(" <param value=\""
550: + ((JLabel) comp)
551: .getForeground()
552: .getRGB()
553: + "\" class=\"java.awt.Color\"></param>\n");
554: flws.write(" </setForeground>\n");
555: flws.write(" <setSize>\n");
556: flws.write(" <param value=\""
557: + comp.getWidth()
558: + "\" class=\"int\"></param>\n");
559: flws.write(" <param value=\""
560: + comp.getHeight()
561: + "\" class=\"int\"></param>\n");
562: flws.write(" </setSize>\n");
563: flws.write(" </" + comp.getClass().getName()
564: + ">\n");
565:
566: } else if (comp.getClass().getName() == "javax.swing.JTextField") {
567: flws.write(" <" + comp.getClass().getName()
568: + ">\n");
569: flws.write(" <location x=\""
570: + (comp.getX() + x) + "\" y=\""
571: + (comp.getY() + y)
572: + "\"></location>\n");
573: if (((JTextField) comp).getName() != null
574: && !(((JTextField) comp).getName()
575: .equalsIgnoreCase(""))) {
576: flws.write(" <setName>\n");
577: flws
578: .write(" <param value=\""
579: + replaceSpecialCharacter(((JTextField) comp)
580: .getName())
581: + "\" class=\"java.lang.String\"></param>\n");
582: flws.write(" </setName>\n");
583: }
584: flws.write(" <setText>\n");
585: flws
586: .write(" <param value=\""
587: + replaceSpecialCharacter(((JTextField) comp)
588: .getText())
589: + "\" class=\"java.lang.String\"></param>\n");
590: flws.write(" </setText>\n");
591: flws.write(" <setFont>\n");
592: java.awt.Font font = ((JTextField) comp)
593: .getFont();
594: flws
595: .write(" <param value=\""
596: + font.getFontName()
597: + "\" class=\"java.lang.String\"></param>\n");
598: flws.write(" <param value=\""
599: + font.getStyle()
600: + "\" class=\"int\"></param>\n");
601: flws.write(" <param value=\""
602: + font.getSize()
603: + "\" class=\"int\"></param>\n");
604: flws.write(" </setFont>\n");
605: flws.write(" <setForeground>\n");
606: flws
607: .write(" <param value=\""
608: + ((JTextField) comp)
609: .getForeground()
610: .getRGB()
611: + "\" class=\"java.awt.Color\"></param>\n");
612: flws.write(" </setForeground>\n");
613: flws.write(" <setSize>\n");
614: flws.write(" <param value=\""
615: + comp.getWidth()
616: + "\" class=\"int\"></param>\n");
617: flws.write(" <param value=\""
618: + comp.getHeight()
619: + "\" class=\"int\"></param>\n");
620: flws.write(" </setSize>\n");
621: flws.write(" </" + comp.getClass().getName()
622: + ">\n");
623:
624: } else if (comp.getClass().getName() == "javax.swing.JTextArea") {
625: flws.write(" <" + comp.getClass().getName()
626: + ">\n");
627: flws.write(" <location x=\""
628: + (comp.getX() + x) + "\" y=\""
629: + (comp.getY() + y)
630: + "\"></location>\n");
631: flws.write(" <setSize>\n");
632: flws.write(" <param value=\""
633: + comp.getWidth()
634: + "\" class=\"int\"></param>\n");
635: flws.write(" <param value=\""
636: + comp.getHeight()
637: + "\" class=\"int\"></param>\n");
638: flws.write(" </setSize>\n");
639: flws.write(" <setLineWrap>\n");
640: flws.write(" <param value=\""
641: + ((JTextArea) comp).getLineWrap()
642: + "\" class=\"boolean\"></param>\n");
643: flws.write(" </setLineWrap>\n");
644: flws.write(" <setFont>\n");
645: java.awt.Font font = ((JTextArea) comp)
646: .getFont();
647: flws
648: .write(" <param value=\""
649: + font.getFontName()
650: + "\" class=\"java.lang.String\"></param>\n");
651: flws.write(" <param value=\""
652: + font.getStyle()
653: + "\" class=\"int\"></param>\n");
654: flws.write(" <param value=\""
655: + font.getSize()
656: + "\" class=\"int\"></param>\n");
657: flws.write(" </setFont>\n");
658: flws.write(" <setText>\n");
659: flws
660: .write(" <param xml:space=\"preserve\" value=\"\" class=\"java.lang.String\">"
661: + replaceSpecialCharacter(((JTextArea) comp)
662: .getText())
663: + "</param>\n");
664: flws.write(" </setText>\n");
665: flws.write(" <setForeground>\n");
666: flws
667: .write(" <param value=\""
668: + ((JTextArea) comp)
669: .getForeground()
670: .getRGB()
671: + "\" class=\"java.awt.Color\"></param>\n");
672: flws.write(" </setForeground>\n");
673: flws.write(" <setBackground>\n");
674: flws
675: .write(" <param value=\""
676: + ((JTextArea) comp)
677: .getBackground()
678: .getRGB()
679: + "\" class=\"java.awt.Color\"></param>\n");
680: flws.write(" </setBackground>\n");
681: flws.write(" </" + comp.getClass().getName()
682: + ">\n");
683:
684: } else if (comp.getClass().getName() == "javax.swing.JButton") {
685: flws.write(" <" + comp.getClass().getName()
686: + ">\n");
687: flws.write(" <location x=\""
688: + (comp.getX() + x) + "\" y=\""
689: + (comp.getY() + y)
690: + "\"></location>\n");
691: flws.write(" <setText>\n");
692: flws
693: .write(" <param value=\""
694: + replaceSpecialCharacter(((javax.swing.JButton) comp)
695: .getText())
696: + "\" class=\"java.lang.String\"></param>\n");
697: flws.write(" </setText>\n");
698: flws.write(" <setSize>\n");
699: flws.write(" <param value=\""
700: + comp.getWidth()
701: + "\" class=\"int\"></param>\n");
702: flws.write(" <param value=\""
703: + comp.getHeight()
704: + "\" class=\"int\"></param>\n");
705: flws.write(" </setSize>\n");
706: flws.write(" </" + comp.getClass().getName()
707: + ">\n");
708:
709: } else if (comp.getClass().getName() == "javax.swing.JSeparator") {
710: flws.write(" <" + comp.getClass().getName()
711: + ">\n");
712: flws.write(" <location x=\""
713: + (comp.getX() + x) + "\" y=\""
714: + (comp.getY() + y)
715: + "\"></location>\n");
716: flws.write(" <setOrientation>\n");
717: flws.write(" <param value=\""
718: + ((javax.swing.JSeparator) comp)
719: .getOrientation()
720: + "\" class=\"int\"></param>\n");
721: flws.write(" </setOrientation>\n");
722: flws.write(" <setForeground>\n");
723: flws
724: .write(" <param value=\""
725: + ((javax.swing.JSeparator) comp)
726: .getForeground()
727: .getRGB()
728: + "\" class=\"java.awt.Color\"></param>\n");
729: flws.write(" </setForeground>\n");
730: flws.write(" <setSize>\n");
731: flws.write(" <param value=\""
732: + comp.getWidth()
733: + "\" class=\"int\"></param>\n");
734: flws.write(" <param value=\""
735: + comp.getHeight()
736: + "\" class=\"int\"></param>\n");
737: flws.write(" </setSize>\n");
738: flws.write(" </" + comp.getClass().getName()
739: + ">\n");
740:
741: } else if (comp.getClass().getName() == "javax.swing.JToggleButton") {
742: flws.write(" <" + comp.getClass().getName()
743: + ">\n");
744: flws.write(" <location x=\""
745: + (comp.getX() + x) + "\" y=\""
746: + (comp.getY() + y)
747: + "\"></location>\n");
748: flws.write(" <setText>\n");
749: flws
750: .write(" <param value=\""
751: + replaceSpecialCharacter(((javax.swing.JToggleButton) comp)
752: .getText())
753: + "\" class=\"java.lang.String\"></param>\n");
754: flws.write(" </setText>\n");
755: flws.write(" <setSize>\n");
756: flws.write(" <param value=\""
757: + comp.getWidth()
758: + "\" class=\"int\"></param>\n");
759: flws.write(" <param value=\""
760: + comp.getHeight()
761: + "\" class=\"int\"></param>\n");
762: flws.write(" </setSize>\n");
763: flws.write(" </" + comp.getClass().getName()
764: + ">\n");
765:
766: } else if (comp.getClass().getName() == "javax.swing.JCheckBox") {
767: flws.write(" <" + comp.getClass().getName()
768: + ">\n");
769: flws.write(" <location x=\""
770: + (comp.getX() + x) + "\" y=\""
771: + (comp.getY() + y)
772: + "\"></location>\n");
773: flws.write(" <setText>\n");
774: flws
775: .write(" <param value=\""
776: + replaceSpecialCharacter(((javax.swing.JCheckBox) comp)
777: .getText())
778: + "\" class=\"java.lang.String\"></param>\n");
779: flws.write(" </setText>\n");
780: flws.write(" <setSize>\n");
781: flws.write(" <param value=\""
782: + comp.getWidth()
783: + "\" class=\"int\"></param>\n");
784: flws.write(" <param value=\""
785: + comp.getHeight()
786: + "\" class=\"int\"></param>\n");
787: flws.write(" </setSize>\n");
788: flws.write(" </" + comp.getClass().getName()
789: + ">\n");
790:
791: } else if (comp.getClass().getName() == "javax.swing.JEditorPane") {
792: flws.write(" <" + comp.getClass().getName()
793: + ">\n");
794: flws.write(" <location x=\""
795: + (comp.getX() + x) + "\" y=\""
796: + (comp.getY() + y)
797: + "\"></location>\n");
798: flws.write(" <setText>\n");
799: flws
800: .write(" <param value=\""
801: + replaceSpecialCharacter(((javax.swing.JEditorPane) comp)
802: .getText())
803: + "\" class=\"java.lang.String\"></param>\n");
804: flws.write(" </setText>\n");
805: flws.write(" <setSize>\n");
806: flws.write(" <param value=\""
807: + comp.getWidth()
808: + "\" class=\"int\"></param>\n");
809: flws.write(" <param value=\""
810: + comp.getHeight()
811: + "\" class=\"int\"></param>\n");
812: flws.write(" </setSize>\n");
813: flws.write(" </" + comp.getClass().getName()
814: + ">\n");
815:
816: } else if (comp.getClass().getName() == "javax.swing.JPanel") {
817: flws.write(" <" + comp.getClass().getName()
818: + ">\n");
819: flws.write(" <location x=\""
820: + (comp.getX() + x) + "\" y=\""
821: + (comp.getY() + y)
822: + "\"></location>\n");
823: flws.write(" <setName>\n");
824: flws
825: .write(" <param value=\""
826: + ((javax.swing.JPanel) comp)
827: .getName()
828: + "\" class=\"java.lang.String\"></param>\n");
829: flws.write(" </setName>\n");
830: flws.write(" <setSize>\n");
831: flws.write(" <param value=\""
832: + comp.getWidth()
833: + "\" class=\"int\"></param>\n");
834: flws.write(" <param value=\""
835: + comp.getHeight()
836: + "\" class=\"int\"></param>\n");
837: flws.write(" </setSize>\n");
838: flws.write(" <setToolTipText>\n");
839: flws
840: .write(" <param value=\""
841: + ((javax.swing.JPanel) comp)
842: .getToolTipText()
843: + "\" class=\"java.lang.String\"></param>\n");
844: flws.write(" </setToolTipText>\n");
845: flws.write(" </" + comp.getClass().getName()
846: + ">\n");
847:
848: } else if (comp.getClass().getName() == "it.datareport.JPreviewPanel") {
849: writeContainer((javax.swing.JPanel) comp, comp
850: .getLocation().x
851: + x, comp.getLocation().y + y);
852: }
853:
854: flws.write("\r");
855: }
856: }
857: }
858: }
859:
860: private void writeJSplitPane(javax.swing.JSplitPane splitpane) {
861: //splitpane
862: }
863: }
|