0001: /*
0002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
0003: * http://www.jaspersoft.com.
0004: *
0005: * Unless you have purchased a commercial license agreement from JasperSoft,
0006: * the following license terms apply:
0007: *
0008: * This program is free software; you can redistribute it and/or modify
0009: * it under the terms of the GNU General Public License version 2 as published by
0010: * the Free Software Foundation.
0011: *
0012: * This program is distributed WITHOUT ANY WARRANTY; and without the
0013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0014: * See the GNU General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU General Public License
0017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
0018: * or write to:
0019: *
0020: * Free Software Foundation, Inc.,
0021: * 59 Temple Place - Suite 330,
0022: * Boston, MA USA 02111-1307
0023: *
0024: *
0025: *
0026: *
0027: * StyleDialog.java
0028: *
0029: * Created on 9 maggio 2003, 17.25
0030: *
0031: */
0032:
0033: package it.businesslogic.ireport.gui.style;
0034:
0035: import it.businesslogic.ireport.Box;
0036: import it.businesslogic.ireport.ConditionedStyle;
0037: import it.businesslogic.ireport.CrosstabReportElement;
0038: import it.businesslogic.ireport.IReportFont;
0039: import it.businesslogic.ireport.JasperTemplate;
0040: import it.businesslogic.ireport.Report;
0041: import it.businesslogic.ireport.ReportElement;
0042: import it.businesslogic.ireport.SubDataset;
0043: import it.businesslogic.ireport.gui.ExpressionEditor;
0044: import it.businesslogic.ireport.gui.JRParameterDialog;
0045: import it.businesslogic.ireport.gui.event.SheetPropertyValueChangedListener;
0046: import it.businesslogic.ireport.gui.sheet.*;
0047: import it.businesslogic.ireport.Style;
0048: import it.businesslogic.ireport.TemplateStyle;
0049: import it.businesslogic.ireport.UndefinedStyle;
0050: import it.businesslogic.ireport.gui.MainFrame;
0051: import it.businesslogic.ireport.gui.box.BoxBorderEditorPanel;
0052: import it.businesslogic.ireport.gui.box.BoxPanel;
0053: import it.businesslogic.ireport.gui.event.StyleChangedEvent;
0054: import it.businesslogic.ireport.gui.sheet.FontSheetProperty;
0055: import it.businesslogic.ireport.gui.sheet.SheetProperty;
0056: import it.businesslogic.ireport.gui.sheet.Tag;
0057: import java.awt.event.ActionEvent;
0058:
0059: import java.util.Enumeration;
0060: import java.util.HashMap;
0061: import java.util.Iterator;
0062: import java.util.Vector;
0063: import javax.swing.DefaultListModel;
0064: import javax.swing.JOptionPane;
0065: import javax.swing.ListSelectionModel;
0066: import it.businesslogic.ireport.util.I18n;
0067: import java.awt.BorderLayout;
0068: import java.awt.event.ActionListener;
0069: import javax.swing.JComboBox;
0070:
0071: /**
0072: *
0073: * @author Administrator
0074: */
0075: public class StyleDialog extends javax.swing.JDialog implements
0076: SheetPropertyValueChangedListener {
0077:
0078: /**
0079: * If libraryStyle is set to true, this means that you are not editing a report style,
0080: * but a style that belongs to the style library. In this case no events are generated on
0081: * completation and the modified Style is available with the method getStyle.
0082: *
0083: * The default value for this attribute is FALSE.
0084: */
0085: private boolean libraryStyle = false;
0086:
0087: private BoxPanel boxPanel = null;
0088:
0089: /**
0090: * The jasperTemplate is used to disable conditional styles
0091: * and check for duplicated names...
0092: */
0093: private JasperTemplate jasperTemplate = null;
0094:
0095: private boolean readOnly = false;
0096:
0097: public boolean isReadOnly() {
0098: return readOnly;
0099: }
0100:
0101: public void setReadOnly(boolean readOnly) {
0102: this .readOnly = readOnly;
0103: //for (int i=0; i<sheetPanel.getProperties().size(); ++i)
0104: //{
0105: // ((SheetProperty)sheetPanel.getProperties().get(i)).setReadOnly(readOnly);
0106: //}
0107: jButtonOK.setEnabled(!readOnly);
0108: }
0109:
0110: /**
0111: * A reference to the style appearing in the sheet. Could be the master or
0112: * a style referring to a condition
0113: */
0114: private Style style = null;
0115:
0116: /**
0117: * A reference to the style master
0118: */
0119: private Style masterStyle = null;
0120:
0121: /**
0122: * A reference to the style we are modifying. We work on a copy (masterStyle)
0123: */
0124: private Style editingStyle = null;
0125:
0126: /**
0127: * Prevent some events during initializazion...
0128: */
0129: private boolean init = false;
0130:
0131: /**
0132: * Panel showing a sample of the current style
0133: */
0134: JPanelStyleSample panelSample = new JPanelStyleSample();
0135:
0136: private CategorySheetPanel sheetPanel = null;
0137:
0138: private IReportFont ireportFont = null;
0139: private Report currentReport = null;
0140:
0141: //** Creates new dialog StyleDialog */
0142: public StyleDialog(java.awt.Dialog parent, boolean modal) {
0143: super (parent, modal);
0144: initAll();
0145: }
0146:
0147: /** Creates new dialog ChartPropertiesDialog */
0148: public StyleDialog(java.awt.Frame parent, boolean modal) {
0149: super (parent, modal);
0150: initAll();
0151: }
0152:
0153: public void initAll() {
0154: initComponents();
0155:
0156: setInit(true);
0157:
0158: style = new Style();
0159:
0160: boxPanel = new BoxPanel();
0161: jPanelBoxEditorContainer.add(boxPanel, BorderLayout.CENTER);
0162:
0163: boxPanel.addActionListener(new ActionListener() {
0164:
0165: public void actionPerformed(ActionEvent e) {
0166: panelSample.repaint();
0167: }
0168: });
0169:
0170: setMasterStyle(style);
0171: applyI18n();
0172: //this.setSize(420, 620);
0173: this .pack();
0174:
0175: // Open in center...
0176: it.businesslogic.ireport.util.Misc.centerFrame(this );
0177:
0178: java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
0179: gridBagConstraints.gridx = 4;
0180: gridBagConstraints.gridy = 2;
0181: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0182: gridBagConstraints.weightx = 1.0;
0183: gridBagConstraints.weighty = 1.0;
0184: gridBagConstraints.fill = gridBagConstraints.BOTH;
0185: gridBagConstraints.insets = new java.awt.Insets(0, -1, -1, -1);
0186: sheetPanel = new CategorySheetPanel();
0187: sheetPanel.addSheetPropertyValueChangedListener(this );
0188:
0189: jPanelProperties.add(sheetPanel, gridBagConstraints);
0190:
0191: //applyI18n();
0192:
0193: // Add styles....
0194:
0195: //
0196: String category_name = I18n.getString("styleDialog.tabStyle",
0197: "Style");
0198: //
0199: SheetProperty customizerClassProperty = new SheetProperty(
0200: Style.ATTRIBUTE_name, I18n.getString(
0201: "styleDialog.sheetProperty.customizerClass",
0202: "Style name"),
0203: //"Style name",
0204: SheetProperty.STRING);
0205: sheetPanel.addSheetProperty(category_name,
0206: customizerClassProperty);
0207:
0208: SheetProperty isDefaultProperty = new SheetProperty(
0209: Style.ATTRIBUTE_isDefault, I18n.getString(
0210: "styleDialog.sheetProperty.isDefault",
0211: "Default style"),
0212: //"Default style",
0213: SheetProperty.BOOLEAN);
0214: sheetPanel.addSheetProperty(category_name, isDefaultProperty);
0215:
0216: ComboBoxSheetProperty styleProperty = new ComboBoxSheetProperty(
0217: Style.ATTRIBUTE_style, I18n.getString(
0218: "styleDialog.sheetProperty.style",
0219: "Parent style"));
0220: //"Parent style");
0221:
0222: sheetPanel.addSheetProperty(category_name, styleProperty);
0223:
0224: ((JComboBox) styleProperty.getEditor()).setEditable(true);
0225:
0226: //
0227: category_name = I18n.getString("styleDialog.tabCommon",
0228: "Common");
0229: //
0230: SheetProperty modeProperty = new SheetProperty(
0231: Style.ATTRIBUTE_mode, I18n.getString(
0232: "styleDialog.sheetProperty.mode", "Mode"),
0233: //"Mode",
0234: SheetProperty.COMBOBOX);
0235:
0236: modeProperty.setTags(new Tag[] {
0237: new Tag(null, I18n.getString(
0238: "styleDialog.sheetProperty.mode.default",
0239: "Default")),
0240: new Tag("Opaque", I18n.getString(
0241: "styleDialog.sheetProperty.mode.opaque",
0242: "Opaque")),
0243: new Tag("Transparent", I18n.getString(
0244: "styleDialog.sheetProperty.mode.transparent",
0245: "Transparent")) });
0246: //new Tag(null,"Default"),
0247: //new Tag("Opaque","Opaque"),
0248: //new Tag("Transparent","Transparent")});
0249: //
0250: sheetPanel.addSheetProperty(category_name, modeProperty);
0251:
0252: SheetProperty forecolorProperty = new SheetProperty(
0253: Style.ATTRIBUTE_forecolor, I18n.getString(
0254: "styleDialog.sheetProperty.forecolor",
0255: "Forecolor"),
0256: //"Forecolor",
0257: SheetProperty.COLOR);
0258: forecolorProperty.setValue(null);
0259: sheetPanel.addSheetProperty(category_name, forecolorProperty);
0260:
0261: SheetProperty backcolorProperty = new SheetProperty(
0262: Style.ATTRIBUTE_backcolor, I18n.getString(
0263: "styleDialog.sheetProperty.backcolor",
0264: "Backcolor"),
0265: //"Backcolor",
0266: SheetProperty.COLOR);
0267: backcolorProperty.setValue(null);
0268: sheetPanel.addSheetProperty(category_name, backcolorProperty);
0269:
0270: //
0271: category_name = I18n.getString("styleDialog.tabGraphics",
0272: "Graphics");
0273: //
0274: SheetProperty penProperty = new SheetProperty(
0275: Style.ATTRIBUTE_pen, I18n.getString(
0276: "styleDialog.sheetProperty.pen", "Pen"),
0277: //"Pen",
0278: SheetProperty.COMBOBOX);
0279: penProperty.setTags(new Tag[] {
0280: //
0281: new Tag(null, I18n.getString(
0282: "styleDialog.sheetProperty.pen.default",
0283: "Default")),
0284: new Tag("Thin", I18n.getString(
0285: "styleDialog.sheetProperty.pen.thin", "Thin")),
0286: new Tag("1Point", I18n.getString(
0287: "styleDialog.sheetProperty.pen.1Point",
0288: "1Point")),
0289: new Tag("2Point", I18n.getString(
0290: "styleDialog.sheetProperty.pen.2Point",
0291: "2Point")),
0292: new Tag("4Point", I18n.getString(
0293: "styleDialog.sheetProperty.pen.4Point",
0294: "4Point")),
0295: new Tag("Dotted", I18n.getString(
0296: "styleDialog.sheetProperty.pen.dotted",
0297: "Dotted")) });
0298: //new Tag(null,"Default"),
0299: //new Tag("Thin","Thin"),
0300: //new Tag("1Point","1Point"),
0301: //new Tag("2Point","2Point"),
0302: //new Tag("4Point","4Point"),
0303: //new Tag("Dotted","Dotted")});
0304: //
0305: sheetPanel.addSheetProperty(category_name, penProperty);
0306:
0307: SheetProperty fillProperty = new SheetProperty(
0308: Style.ATTRIBUTE_fill, I18n.getString(
0309: "styleDialog.sheetProperty.fill", "Fill"),
0310: //"Fill",
0311: SheetProperty.COMBOBOX);
0312: fillProperty.setTags(new Tag[] {
0313: //
0314: new Tag(null, I18n.getString(
0315: "styleDialog.sheetProperty.fill.default",
0316: "Default")),
0317: new Tag("Solid", I18n
0318: .getString(
0319: "styleDialog.sheetProperty.fill.solid",
0320: "Solid")) });
0321: //new Tag(null,"Default"),
0322: //new Tag("Solid","Solid")});
0323: //
0324: sheetPanel.addSheetProperty(category_name, fillProperty);
0325:
0326: SheetProperty radiusProperty = new SheetProperty(
0327: Style.ATTRIBUTE_radius, I18n.getString(
0328: "styleDialog.sheetProperty.radius", "Radius"),
0329: //"Radius",
0330: SheetProperty.INTEGER);
0331: sheetPanel.addSheetProperty(category_name, radiusProperty);
0332:
0333: SheetProperty scaleImageProperty = new SheetProperty(
0334: Style.ATTRIBUTE_scaleImage, I18n.getString(
0335: "styleDialog.sheetProperty.scaleImage",
0336: "Scale image"),
0337: //"Scale image",
0338: SheetProperty.COMBOBOX);
0339: scaleImageProperty
0340: .setTags(new Tag[] {
0341: //
0342: new Tag(
0343: null,
0344: I18n
0345: .getString(
0346: "styleDialog.sheetProperty.scaleImage.default",
0347: "Default")),
0348: new Tag(
0349: "Clip",
0350: I18n
0351: .getString(
0352: "styleDialog.sheetProperty.scaleImage.clip",
0353: "Clip")),
0354: new Tag(
0355: "FillFrame",
0356: I18n
0357: .getString(
0358: "styleDialog.sheetProperty.scaleImage.fillFrame",
0359: "FillFrame")),
0360: new Tag(
0361: "RetainShape",
0362: I18n
0363: .getString(
0364: "styleDialog.sheetProperty.scaleImage.retainShape",
0365: "RetainShape")) });
0366: //new Tag(null,"Default"),
0367: //new Tag("Clip","Clip"),
0368: //new Tag("FillFrame","FillFrame"),
0369: //new Tag("RetainShape","RetainShape")});
0370: //
0371: sheetPanel.addSheetProperty(category_name, scaleImageProperty);
0372:
0373: SheetProperty hAlignProperty = new SheetProperty(
0374: Style.ATTRIBUTE_hAlign, I18n.getString(
0375: "styleDialog.sheetProperty.hAlign",
0376: "Horizontal align"),
0377: //"Horizontal align",
0378: SheetProperty.COMBOBOX);
0379: hAlignProperty
0380: .setTags(new Tag[] {
0381: //
0382: new Tag(
0383: null,
0384: I18n
0385: .getString(
0386: "styleDialog.sheetProperty.hAlign.default",
0387: "Default")),
0388: new Tag(
0389: "Left",
0390: I18n
0391: .getString(
0392: "styleDialog.sheetProperty.hAlign.left",
0393: "Left")),
0394: new Tag(
0395: "Center",
0396: I18n
0397: .getString(
0398: "styleDialog.sheetProperty.hAlign.center",
0399: "Center")),
0400: new Tag(
0401: "Right",
0402: I18n
0403: .getString(
0404: "styleDialog.sheetProperty.hAlign.right",
0405: "Right")),
0406: new Tag(
0407: "Justified",
0408: I18n
0409: .getString(
0410: "styleDialog.sheetProperty.hAlign.justified",
0411: "Justified")) });
0412: //new Tag(null,"Default"),
0413: //new Tag("Left","Left"),
0414: //new Tag("Center","Center"),
0415: //new Tag("Right","Right"),
0416: //new Tag("Justified","Justified")});
0417: //
0418: sheetPanel.addSheetProperty(category_name, hAlignProperty);
0419:
0420: SheetProperty vAlignProperty = new SheetProperty(
0421: Style.ATTRIBUTE_vAlign, I18n.getString(
0422: "styleDialog.sheetProperty.vAlign",
0423: "Vertical align"),
0424: //"Vertical align",
0425: SheetProperty.COMBOBOX);
0426: vAlignProperty
0427: .setTags(new Tag[] {
0428: //
0429: new Tag(
0430: null,
0431: I18n
0432: .getString(
0433: "styleDialog.sheetProperty.vAlign.default",
0434: "Default")),
0435: new Tag("Top", I18n.getString(
0436: "styleDialog.sheetProperty.vAlign.top",
0437: "Top")),
0438: new Tag(
0439: "Middle",
0440: I18n
0441: .getString(
0442: "styleDialog.sheetProperty.vAlign.middle",
0443: "Middle")),
0444: new Tag(
0445: "Bottom",
0446: I18n
0447: .getString(
0448: "styleDialog.sheetProperty.vAlign.bottom",
0449: "Bottom")) });
0450: //new Tag(null,"Default"),
0451: //new Tag("Top","Top"),
0452: //new Tag("Middle","Middle"),
0453: //new Tag("Bottom","Bottom")});
0454: //
0455: sheetPanel.addSheetProperty(category_name, vAlignProperty);
0456:
0457: //
0458: category_name = I18n
0459: .getString("styleDialog.tabBorderAndPadding",
0460: "Border and padding");
0461: //
0462:
0463: SheetProperty paddingProperty = new SheetProperty(
0464: Style.ATTRIBUTE_padding,
0465: "<html><s><font color=\"#888888\">"
0466: + I18n.getString(
0467: "styleDialog.sheetProperty.padding",
0468: "Padding"), SheetProperty.INTEGER);
0469: sheetPanel.addSheetProperty(category_name, paddingProperty);
0470: SheetProperty topPaddingProperty = new SheetProperty(
0471: Style.ATTRIBUTE_topPadding,
0472: "<html><s><font color=\"#888888\">"
0473: + I18n.getString(
0474: "styleDialog.sheetProperty.topPadding",
0475: "Top padding"), SheetProperty.INTEGER);
0476: sheetPanel.addSheetProperty(category_name, topPaddingProperty);
0477: SheetProperty rightPaddingProperty = new SheetProperty(
0478: Style.ATTRIBUTE_rightPadding,
0479: "<html><s><font color=\"#888888\">"
0480: + I18n
0481: .getString(
0482: "styleDialog.sheetProperty.rightPadding",
0483: "Right padding"),
0484: SheetProperty.INTEGER);
0485: sheetPanel
0486: .addSheetProperty(category_name, rightPaddingProperty);
0487: SheetProperty bottomPaddingProperty = new SheetProperty(
0488: Style.ATTRIBUTE_bottomPadding,
0489: "<html><s><font color=\"#888888\">"
0490: + I18n
0491: .getString(
0492: "styleDialog.sheetProperty.bottomPadding",
0493: "Bottom padding"),
0494: SheetProperty.INTEGER);
0495: sheetPanel.addSheetProperty(category_name,
0496: bottomPaddingProperty);
0497: SheetProperty leftPaddingProperty = new SheetProperty(
0498: Style.ATTRIBUTE_leftPadding,
0499: "<html><s><font color=\"#888888\">"
0500: + I18n
0501: .getString(
0502: "styleDialog.sheetProperty.leftPadding",
0503: "Left padding"),
0504: SheetProperty.INTEGER);
0505: sheetPanel.addSheetProperty(category_name, leftPaddingProperty);
0506:
0507: SheetProperty borderProperty = new SheetProperty(
0508: Style.ATTRIBUTE_border,
0509: "<html><s><font color=\"#888888\">"
0510: + I18n.getString(
0511: "styleDialog.sheetProperty.border",
0512: "Border"),
0513: //"Border",
0514: SheetProperty.COMBOBOX);
0515: borderProperty
0516: .setTags(new Tag[] {
0517: //
0518: new Tag(
0519: null,
0520: I18n
0521: .getString(
0522: "styleDialog.sheetProperty.border.default",
0523: "Default")),
0524: new Tag(
0525: "Thin",
0526: I18n
0527: .getString(
0528: "styleDialog.sheetProperty.border.thin",
0529: "Thin")),
0530: new Tag(
0531: "1Point",
0532: I18n
0533: .getString(
0534: "styleDialog.sheetProperty.border.1Point",
0535: "1Point")),
0536: new Tag(
0537: "2Point",
0538: I18n
0539: .getString(
0540: "styleDialog.sheetProperty.border.2Point",
0541: "2Point")),
0542: new Tag(
0543: "4Point",
0544: I18n
0545: .getString(
0546: "styleDialog.sheetProperty.border.4Point",
0547: "4Point")),
0548: new Tag(
0549: "Dotted",
0550: I18n
0551: .getString(
0552: "styleDialog.sheetProperty.border.dotted",
0553: "Dotted")) });
0554: //new Tag(null,"Default"),
0555: //new Tag("Thin","Thin"),
0556: //new Tag("1Point","1Point"),
0557: //new Tag("2Point","2Point"),
0558: //new Tag("4Point","4Point"),
0559: //new Tag("Dotted","Dotted")});
0560: //
0561: sheetPanel.addSheetProperty(category_name, borderProperty);
0562:
0563: SheetProperty borderColorProperty = new SheetProperty(
0564: Style.ATTRIBUTE_borderColor,
0565: "<html><s><font color=\"#888888\">"
0566: + I18n
0567: .getString(
0568: "styleDialog.sheetProperty.borderColor",
0569: "Border color"),
0570: //"Border color",
0571: SheetProperty.COLOR);
0572: sheetPanel.addSheetProperty(category_name, borderColorProperty);
0573:
0574: SheetProperty topBorderProperty = new SheetProperty(
0575: Style.ATTRIBUTE_topBorder,
0576: "<html><s><font color=\"#888888\">"
0577: + I18n.getString(
0578: "styleDialog.sheetProperty.topBorder",
0579: "Top border"),
0580: //"Top border",
0581: SheetProperty.COMBOBOX);
0582: topBorderProperty.setTags(new Tag[] {
0583: //
0584: new Tag(null, I18n.getString(
0585: "styleDialog.sheetProperty.topBorder.default",
0586: "Default")),
0587: new Tag("Thin", I18n.getString(
0588: "styleDialog.sheetProperty.topBorder.thin",
0589: "Thin")),
0590: new Tag("1Point", I18n.getString(
0591: "styleDialog.sheetProperty.topBorder.1Point",
0592: "1Point")),
0593: new Tag("2Point", I18n.getString(
0594: "styleDialog.sheetProperty.topBorder.2Point",
0595: "2Point")),
0596: new Tag("4Point", I18n.getString(
0597: "styleDialog.sheetProperty.topBorder.4Point",
0598: "4Point")),
0599: new Tag("Dotted", I18n.getString(
0600: "styleDialog.sheetProperty.topBorder.dotted",
0601: "Dotted")) });
0602: //new Tag(null,"Default"),
0603: //new Tag("Thin","Thin"),
0604: //new Tag("1Point","1Point"),
0605: //new Tag("2Point","2Point"),
0606: //new Tag("4Point","4Point"),
0607: //new Tag("Dotted","Dotted")});
0608: //
0609: sheetPanel.addSheetProperty(category_name, topBorderProperty);
0610:
0611: SheetProperty topBorderColorProperty = new SheetProperty(
0612: Style.ATTRIBUTE_topBorderColor,
0613: "<html><s><font color=\"#888888\">"
0614: + I18n
0615: .getString(
0616: "styleDialog.sheetProperty.topBorderColor",
0617: "Top border color"),
0618: //"Top border color",
0619: SheetProperty.COLOR);
0620: sheetPanel.addSheetProperty(category_name,
0621: topBorderColorProperty);
0622:
0623: SheetProperty leftBorderProperty = new SheetProperty(
0624: Style.ATTRIBUTE_leftBorder,
0625: "<html><s><font color=\"#888888\">"
0626: + I18n.getString(
0627: "styleDialog.sheetProperty.leftBorder",
0628: "Left border"),
0629: //"Left border",
0630: SheetProperty.COMBOBOX);
0631: leftBorderProperty.setTags(new Tag[] {
0632: //
0633: new Tag(null, I18n.getString(
0634: "styleDialog.sheetProperty.leftBorder.default",
0635: "Default")),
0636: new Tag("Thin", I18n.getString(
0637: "styleDialog.sheetProperty.leftBorder.thin",
0638: "Thin")),
0639: new Tag("1Point", I18n.getString(
0640: "styleDialog.sheetProperty.leftBorder.1Point",
0641: "1Point")),
0642: new Tag("2Point", I18n.getString(
0643: "styleDialog.sheetProperty.leftBorder.2Point",
0644: "2Point")),
0645: new Tag("4Point", I18n.getString(
0646: "styleDialog.sheetProperty.leftBorder.4Point",
0647: "4Point")),
0648: new Tag("Dotted", I18n.getString(
0649: "styleDialog.sheetProperty.leftBorder.dotted",
0650: "Dotted")) });
0651: //new Tag(null,"Default"),
0652: //new Tag("Thin","Thin"),
0653: //new Tag("1Point","1Point"),
0654: //new Tag("2Point","2Point"),
0655: //new Tag("4Point","4Point"),
0656: //new Tag("Dotted","Dotted")});
0657: //
0658: sheetPanel.addSheetProperty(category_name, leftBorderProperty);
0659:
0660: SheetProperty leftBorderColorProperty = new SheetProperty(
0661: Style.ATTRIBUTE_leftBorderColor,
0662: "<html><s><font color=\"#888888\">"
0663: + I18n
0664: .getString(
0665: "styleDialog.sheetProperty.leftBorderColor",
0666: "Left border color"),
0667: //"Left border color",
0668: SheetProperty.COLOR);
0669: sheetPanel.addSheetProperty(category_name,
0670: leftBorderColorProperty);
0671:
0672: SheetProperty bottomBorderProperty = new SheetProperty(
0673: Style.ATTRIBUTE_bottomBorder,
0674: "<html><s><font color=\"#888888\">"
0675: + I18n
0676: .getString(
0677: "styleDialog.sheetProperty.bottomBorder",
0678: "Bottom border"),
0679: //"Bottom border",
0680: SheetProperty.COMBOBOX);
0681: bottomBorderProperty.setTags(new Tag[] {
0682: //
0683: new Tag(null, I18n.getString(
0684: "styleDialog.sheetProperty.leftBorder.default",
0685: "Default")),
0686: new Tag("Thin", I18n.getString(
0687: "styleDialog.sheetProperty.leftBorder.thin",
0688: "Thin")),
0689: new Tag("1Point", I18n.getString(
0690: "styleDialog.sheetProperty.leftBorder.1Point",
0691: "1Point")),
0692: new Tag("2Point", I18n.getString(
0693: "styleDialog.sheetProperty.leftBorder.2Point",
0694: "2Point")),
0695: new Tag("4Point", I18n.getString(
0696: "styleDialog.sheetProperty.leftBorder.4Point",
0697: "4Point")),
0698: new Tag("Dotted", I18n.getString(
0699: "styleDialog.sheetProperty.leftBorder.dotted",
0700: "Dotted")) });
0701: //new Tag(null,"Default"),
0702: //new Tag("Thin","Thin"),
0703: //new Tag("1Point","1Point"),
0704: //new Tag("2Point","2Point"),
0705: //new Tag("4Point","4Point"),
0706: //new Tag("Dotted","Dotted")});
0707: //
0708: sheetPanel
0709: .addSheetProperty(category_name, bottomBorderProperty);
0710:
0711: SheetProperty bottomBorderColorProperty = new SheetProperty(
0712: Style.ATTRIBUTE_bottomBorderColor,
0713: "<html><s><font color=\"#888888\">"
0714: + I18n
0715: .getString(
0716: "styleDialog.sheetProperty.bottomBorderColor",
0717: "Bottom border color"),
0718: //"Bottom border color",
0719: SheetProperty.COLOR);
0720:
0721: sheetPanel.addSheetProperty(category_name,
0722: bottomBorderColorProperty);
0723:
0724: SheetProperty rightBorderProperty = new SheetProperty(
0725: Style.ATTRIBUTE_rightBorder,
0726: "<html><s><font color=\"#888888\">"
0727: + I18n
0728: .getString(
0729: "styleDialog.sheetProperty.rightBorder",
0730: "Right border"),
0731: //"Right border",
0732: SheetProperty.COMBOBOX);
0733: rightBorderProperty
0734: .setTags(new Tag[] {
0735: //
0736: new Tag(
0737: null,
0738: I18n
0739: .getString(
0740: "styleDialog.sheetProperty.rightBorder.default",
0741: "Default")),
0742: new Tag(
0743: "Thin",
0744: I18n
0745: .getString(
0746: "styleDialog.sheetProperty.rightBorder.thin",
0747: "Thin")),
0748: new Tag(
0749: "1Point",
0750: I18n
0751: .getString(
0752: "styleDialog.sheetProperty.rightBorder.1Point",
0753: "1Point")),
0754: new Tag(
0755: "2Point",
0756: I18n
0757: .getString(
0758: "styleDialog.sheetProperty.rightBorder.2Point",
0759: "2Point")),
0760: new Tag(
0761: "4Point",
0762: I18n
0763: .getString(
0764: "styleDialog.sheetProperty.rightBorder.4Point",
0765: "4Point")),
0766: new Tag(
0767: "Dotted",
0768: I18n
0769: .getString(
0770: "styleDialog.sheetProperty.rightBorder.dotted",
0771: "Dotted")) });
0772: //new Tag(null,"Default"),
0773: //new Tag("Thin","Thin"),
0774: //new Tag("1Point","1Point"),
0775: //new Tag("2Point","2Point"),
0776: //new Tag("4Point","4Point"),
0777: //new Tag("Dotted","Dotted")});
0778: //
0779: sheetPanel.addSheetProperty(category_name, rightBorderProperty);
0780:
0781: SheetProperty rightBorderColorProperty = new SheetProperty(
0782: Style.ATTRIBUTE_rightBorderColor,
0783: "<html><s><font color=\"#888888\">"
0784: + I18n
0785: .getString(
0786: "styleDialog.sheetProperty.rightBorderColor",
0787: "Right border color"),
0788: //"Right border color",
0789: SheetProperty.COLOR);
0790: sheetPanel.addSheetProperty(category_name,
0791: rightBorderColorProperty);
0792:
0793: //
0794: category_name = I18n.getString("styleDialog.tabTextProperties",
0795: "Text properties");
0796: //
0797: SheetProperty rotationProperty = new SheetProperty(
0798: Style.ATTRIBUTE_rotation, I18n.getString(
0799: "styleDialog.sheetProperty.rotation",
0800: "Rotation"),
0801: //"Rotation",
0802: SheetProperty.COMBOBOX);
0803: rotationProperty
0804: .setTags(new Tag[] {
0805: //
0806: new Tag(
0807: null,
0808: I18n
0809: .getString(
0810: "styleDialog.sheetProperty.rotation.default",
0811: "Default")),
0812: new Tag(
0813: "None",
0814: I18n
0815: .getString(
0816: "styleDialog.sheetProperty.rotation.none",
0817: "None")),
0818: new Tag(
0819: "Left",
0820: I18n
0821: .getString(
0822: "styleDialog.sheetProperty.rotation.left",
0823: "Left")),
0824: new Tag(
0825: "Right",
0826: I18n
0827: .getString(
0828: "styleDialog.sheetProperty.rotation.right",
0829: "Right")),
0830: new Tag(
0831: "UpsideDown",
0832: I18n
0833: .getString(
0834: "styleDialog.sheetProperty.rotation.upsideDown",
0835: "UpsideDown")) });
0836: //new Tag(null,"Default"),
0837: //new Tag("None","None"),
0838: //new Tag("Left","Left"),
0839: //new Tag("Right","Right"),
0840: //new Tag("UpsideDown","UpsideDown")});
0841: //
0842: sheetPanel.addSheetProperty(category_name, rotationProperty);
0843:
0844: PatternSheetProperty patternProperty = new PatternSheetProperty(
0845: Style.ATTRIBUTE_pattern, I18n.getString(
0846: "styleDialog.sheetProperty.pattern", "Pattern"));
0847: sheetPanel.addSheetProperty(category_name, patternProperty);
0848:
0849: SheetProperty isBlankWhenNullProperty = new SheetProperty(
0850: Style.ATTRIBUTE_isBlankWhenNull, I18n.getString(
0851: "styleDialog.sheetProperty.isBlankWhenNull",
0852: "Is Blank when Null"),
0853: //"Is Blank when Null",
0854: SheetProperty.BOOLEAN);
0855: sheetPanel.addSheetProperty(category_name,
0856: isBlankWhenNullProperty);
0857:
0858: // FONT...
0859: FontSheetProperty theFontSpacingProperty = new FontSheetProperty(
0860: "style.font", I18n.getString(
0861: "styleDialog.sheetProperty.theFontSpacing",
0862: "Font"));
0863: //"Font");
0864: theFontSpacingProperty.setFontMode(3);
0865: sheetPanel.addSheetProperty(category_name,
0866: theFontSpacingProperty);
0867:
0868: SheetProperty lineSpacingProperty = new SheetProperty(
0869: Style.ATTRIBUTE_lineSpacing, I18n.getString(
0870: "styleDialog.sheetProperty.lineSpacing",
0871: "Line spacing"),
0872: //"Line spacing",
0873: SheetProperty.COMBOBOX);
0874: lineSpacingProperty
0875: .setTags(new Tag[] {
0876: //
0877: new Tag(
0878: null,
0879: I18n
0880: .getString(
0881: "styleDialog.sheetProperty.lineSpacing.default",
0882: "Default")),
0883: new Tag(
0884: "Single",
0885: I18n
0886: .getString(
0887: "styleDialog.sheetProperty.lineSpacing.single",
0888: "Single")),
0889: new Tag(
0890: "1_1_2",
0891: I18n
0892: .getString(
0893: "styleDialog.sheetProperty.lineSpacing.1_1_2",
0894: "1_1_2")),
0895: new Tag(
0896: "Double",
0897: I18n
0898: .getString(
0899: "styleDialog.sheetProperty.lineSpacing.double",
0900: "Double")) });
0901: //new Tag(null,"Default"),
0902: //new Tag("Single","Single"),
0903: //new Tag("1_1_2","1_1_2"),
0904: //new Tag("Double","Double")});
0905: //
0906: sheetPanel.addSheetProperty(category_name, lineSpacingProperty);
0907:
0908: /*
0909: SheetProperty fontNameProperty = new SheetProperty("style.fontName","Font", SheetProperty.COMBOBOX);
0910: fontNameProperty.setTags( new Tag[]{ });
0911: sheetPanel.addSheetProperty("Text properties", fontNameProperty);
0912: */
0913: SheetProperty isBoldProperty = new SheetProperty(
0914: Style.ATTRIBUTE_isBold, I18n.getString(
0915: "styleDialog.sheetProperty.isBold", "Bold"),
0916: //"Bold",
0917: SheetProperty.BOOLEAN);
0918: sheetPanel.addSheetProperty(category_name, isBoldProperty);
0919:
0920: SheetProperty isItalicProperty = new SheetProperty(
0921: Style.ATTRIBUTE_isItalic,
0922: I18n.getString("styleDialog.sheetProperty.isItalic",
0923: "Italic"),
0924: //"Italic",
0925: SheetProperty.BOOLEAN);
0926: sheetPanel.addSheetProperty(category_name, isItalicProperty);
0927:
0928: SheetProperty isUnderlineProperty = new SheetProperty(
0929: Style.ATTRIBUTE_isUnderline, I18n.getString(
0930: "styleDialog.sheetProperty.isUnderline",
0931: "Underline"),
0932: //"Underline",
0933: SheetProperty.BOOLEAN);
0934: sheetPanel.addSheetProperty(category_name, isUnderlineProperty);
0935:
0936: SheetProperty isStrikeThroughProperty = new SheetProperty(
0937: Style.ATTRIBUTE_isStrikeThrough, I18n.getString(
0938: "styleDialog.sheetProperty.isStrikeThrough",
0939: "StrikeThrough"),
0940: //"StrikeThrough",
0941: SheetProperty.BOOLEAN);
0942: sheetPanel.addSheetProperty(category_name,
0943: isStrikeThroughProperty);
0944:
0945: //SheetProperty fontSizeProperty = new SheetProperty(Style.ATTRIBUTE_,"Font size", SheetProperty.INTEGER);
0946: //sheetPanel.addSheetProperty("Text properties", fontSizeProperty);
0947:
0948: /*
0949: SheetProperty pdfFontNameProperty = new SheetProperty("style.pdfFontName","PDF Font name", SheetProperty.COMBOBOX);
0950: pdfFontNameProperty.setTags( new Tag[]{ });
0951: sheetPanel.addSheetProperty("Text properties", pdfFontNameProperty);
0952:
0953: SheetProperty pdfEncodingProperty = new SheetProperty("style.pdfEncoding","PDF Encoding", SheetProperty.STRING);
0954: sheetPanel.addSheetProperty("Text properties", pdfEncodingProperty);
0955:
0956: SheetProperty isPdfEmbeddedProperty = new SheetProperty("style.isPdfEmbedded","Embed PDF fonts", SheetProperty.STRING);
0957: sheetPanel.addSheetProperty("Text properties", isPdfEmbeddedProperty);
0958: */
0959:
0960: gridBagConstraints.gridx = 0;
0961: gridBagConstraints.gridy = 0;
0962: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0963: gridBagConstraints.weightx = 1.0;
0964: gridBagConstraints.weighty = 1.0;
0965: gridBagConstraints.fill = gridBagConstraints.BOTH;
0966: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 0);
0967:
0968: this .jPanelSample.add(panelSample, gridBagConstraints);
0969:
0970: SheetProperty isStyledTextProperty = new SheetProperty(
0971: Style.ATTRIBUTE_isStyledText, I18n.getString(
0972: "styleDialog.sheetProperty.isStyledText",
0973: "Is Styled Text"),
0974: //"Is Styled Text",
0975: SheetProperty.BOOLEAN);
0976: sheetPanel
0977: .addSheetProperty(category_name, isStyledTextProperty);
0978:
0979: SheetProperty markupProperty = new SheetProperty(
0980: Style.ATTRIBUTE_markup, I18n.getString(
0981: "styleDialog.sheetProperty.markup", "Markup"),
0982: SheetProperty.COMBOBOX);
0983: markupProperty
0984: .setTags(new Tag[] {
0985: new Tag(
0986: null,
0987: I18n
0988: .getString(
0989: "styleDialog.sheetProperty.markup.default",
0990: "Default")),
0991: new Tag(
0992: "html",
0993: I18n
0994: .getString(
0995: "styleDialog.sheetProperty.markup.html",
0996: "HTML")),
0997: new Tag("rtf", I18n.getString(
0998: "styleDialog.sheetProperty.markup.rtf",
0999: "RTF")) });
1000:
1001: sheetPanel.addSheetProperty(category_name, markupProperty);
1002:
1003: // FINE FONT...
1004: sheetPanel.recreateSheet();
1005:
1006: //sheetPanel.collapseCategory("Border and padding");
1007: sheetPanel.collapseCategory(I18n
1008: .getString("styleDialog.tabBorderAndPadding",
1009: "Border and padding"));
1010:
1011: this .updateStyleValues();
1012:
1013: this .jConditionsList.setModel(new DefaultListModel());
1014: this .jConditionsList
1015: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1016:
1017: //
1018: ((DefaultListModel) this .jConditionsList.getModel())
1019: .addElement(I18n
1020: .getString(
1021: "styleDialog.conditionsList.default",
1022: "Default"));
1023: //((DefaultListModel)this.jConditionsList.getModel()).addElement("Default");
1024: //
1025:
1026: this .jConditionsList.setSelectedIndex(0);
1027:
1028: javax.swing.KeyStroke escape = javax.swing.KeyStroke
1029: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
1030: false);
1031: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
1032: public void actionPerformed(java.awt.event.ActionEvent e) {
1033: jButtonCancelActionPerformed(e);
1034: }
1035: };
1036:
1037: getRootPane().getInputMap(
1038: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
1039: escape, "ESCAPE");
1040: getRootPane().getActionMap().put("ESCAPE", escapeAction);
1041:
1042: //to make the default button ...
1043: this .getRootPane().setDefaultButton(this .jButtonOK);
1044:
1045: setInit(false);
1046:
1047: style.setBox(new Box());
1048: boxPanel.setBox(style.getBox());
1049: panelSample.setStyle(style);
1050:
1051: }
1052:
1053: /** This method is called from within the constructor to
1054: * initialize the form.
1055: * WARNING: Do NOT modify this code. The content of this method is
1056: * always regenerated by the Form Editor.
1057: */
1058: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
1059: private void initComponents() {
1060: java.awt.GridBagConstraints gridBagConstraints;
1061:
1062: jSplitPane1 = new javax.swing.JSplitPane();
1063: jPanel3 = new javax.swing.JPanel();
1064: jPanelProperties = new javax.swing.JPanel();
1065: jPanelBoxEditorContainer = new javax.swing.JPanel();
1066: jPanelConditions = new javax.swing.JPanel();
1067: jLabelStyleConditions = new javax.swing.JLabel();
1068: jScrollPane1 = new javax.swing.JScrollPane();
1069: jConditionsList = new javax.swing.JList();
1070: jPanel2 = new javax.swing.JPanel();
1071: jButtonAddCondition = new javax.swing.JButton();
1072: jButtonModifyCondition = new javax.swing.JButton();
1073: jButtonRemoveCondition = new javax.swing.JButton();
1074: jButtonUpCondition = new javax.swing.JButton();
1075: jButtonDownCondition = new javax.swing.JButton();
1076: jLabelSample = new javax.swing.JLabel();
1077: jPanelSample = new javax.swing.JPanel();
1078: jPanel1 = new javax.swing.JPanel();
1079: jButtonOK = new javax.swing.JButton();
1080: jButtonCancel = new javax.swing.JButton();
1081:
1082: setTitle("Add/modify Style");
1083: setModal(true);
1084: addWindowListener(new java.awt.event.WindowAdapter() {
1085: public void windowClosing(java.awt.event.WindowEvent evt) {
1086: closeDialog(evt);
1087: }
1088:
1089: public void windowOpened(java.awt.event.WindowEvent evt) {
1090: formWindowOpened(evt);
1091: }
1092: });
1093: getContentPane().setLayout(new java.awt.GridBagLayout());
1094:
1095: jSplitPane1.setResizeWeight(0.5);
1096:
1097: jPanel3.setLayout(new java.awt.GridBagLayout());
1098:
1099: jPanelProperties
1100: .setBorder(javax.swing.BorderFactory
1101: .createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
1102: jPanelProperties.setMinimumSize(new java.awt.Dimension(100, 4));
1103: jPanelProperties.setPreferredSize(new java.awt.Dimension(320,
1104: 470));
1105: jPanelProperties.setLayout(new java.awt.GridBagLayout());
1106: gridBagConstraints = new java.awt.GridBagConstraints();
1107: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1108: gridBagConstraints.weightx = 1.0;
1109: gridBagConstraints.weighty = 1.0;
1110: jPanel3.add(jPanelProperties, gridBagConstraints);
1111:
1112: jPanelBoxEditorContainer.setMinimumSize(new java.awt.Dimension(
1113: 130, 270));
1114: jPanelBoxEditorContainer
1115: .setPreferredSize(new java.awt.Dimension(130, 270));
1116: jPanelBoxEditorContainer.setLayout(new java.awt.BorderLayout());
1117: gridBagConstraints = new java.awt.GridBagConstraints();
1118: gridBagConstraints.gridx = 0;
1119: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1120: gridBagConstraints.weightx = 1.0;
1121: jPanel3.add(jPanelBoxEditorContainer, gridBagConstraints);
1122:
1123: jSplitPane1.setLeftComponent(jPanel3);
1124:
1125: jPanelConditions
1126: .setMinimumSize(new java.awt.Dimension(100, 10));
1127: jPanelConditions.setPreferredSize(new java.awt.Dimension(200,
1128: 10));
1129: jPanelConditions.setLayout(new java.awt.GridBagLayout());
1130:
1131: jLabelStyleConditions.setText("Style conditions");
1132: gridBagConstraints = new java.awt.GridBagConstraints();
1133: gridBagConstraints.gridx = 0;
1134: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1135: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
1136: gridBagConstraints.weightx = 1.0;
1137: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
1138: jPanelConditions.add(jLabelStyleConditions, gridBagConstraints);
1139:
1140: jConditionsList
1141: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
1142: public void valueChanged(
1143: javax.swing.event.ListSelectionEvent evt) {
1144: jConditionsListValueChanged(evt);
1145: }
1146: });
1147: jConditionsList
1148: .addMouseListener(new java.awt.event.MouseAdapter() {
1149: public void mouseClicked(
1150: java.awt.event.MouseEvent evt) {
1151: jConditionsListMouseClicked(evt);
1152: }
1153: });
1154: jScrollPane1.setViewportView(jConditionsList);
1155:
1156: gridBagConstraints = new java.awt.GridBagConstraints();
1157: gridBagConstraints.gridx = 0;
1158: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1159: gridBagConstraints.weightx = 1.0;
1160: gridBagConstraints.weighty = 1.0;
1161: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
1162: jPanelConditions.add(jScrollPane1, gridBagConstraints);
1163:
1164: jPanel2.setLayout(new java.awt.GridBagLayout());
1165:
1166: jButtonAddCondition.setText("Add");
1167: jButtonAddCondition.setMargin(new java.awt.Insets(2, 2, 2, 2));
1168: jButtonAddCondition
1169: .addActionListener(new java.awt.event.ActionListener() {
1170: public void actionPerformed(
1171: java.awt.event.ActionEvent evt) {
1172: jButtonAddConditionActionPerformed(evt);
1173: }
1174: });
1175: gridBagConstraints = new java.awt.GridBagConstraints();
1176: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1177: gridBagConstraints.weightx = 1.0;
1178: jPanel2.add(jButtonAddCondition, gridBagConstraints);
1179:
1180: jButtonModifyCondition.setText("Modify");
1181: jButtonModifyCondition.setEnabled(false);
1182: jButtonModifyCondition
1183: .setMargin(new java.awt.Insets(2, 2, 2, 2));
1184: jButtonModifyCondition
1185: .addActionListener(new java.awt.event.ActionListener() {
1186: public void actionPerformed(
1187: java.awt.event.ActionEvent evt) {
1188: jButtonModifyConditionActionPerformed(evt);
1189: }
1190: });
1191: gridBagConstraints = new java.awt.GridBagConstraints();
1192: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1193: gridBagConstraints.weightx = 1.0;
1194: jPanel2.add(jButtonModifyCondition, gridBagConstraints);
1195:
1196: jButtonRemoveCondition.setText("Remove");
1197: jButtonRemoveCondition.setEnabled(false);
1198: jButtonRemoveCondition
1199: .setMargin(new java.awt.Insets(2, 2, 2, 2));
1200: jButtonRemoveCondition
1201: .addActionListener(new java.awt.event.ActionListener() {
1202: public void actionPerformed(
1203: java.awt.event.ActionEvent evt) {
1204: jButtonRemoveConditionActionPerformed(evt);
1205: }
1206: });
1207: gridBagConstraints = new java.awt.GridBagConstraints();
1208: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1209: gridBagConstraints.weightx = 1.0;
1210: jPanel2.add(jButtonRemoveCondition, gridBagConstraints);
1211:
1212: jButtonUpCondition.setText("up");
1213: jButtonUpCondition.setEnabled(false);
1214: jButtonUpCondition.setMargin(new java.awt.Insets(2, 2, 2, 2));
1215: jButtonUpCondition
1216: .addActionListener(new java.awt.event.ActionListener() {
1217: public void actionPerformed(
1218: java.awt.event.ActionEvent evt) {
1219: jButtonUpConditionActionPerformed(evt);
1220: }
1221: });
1222: gridBagConstraints = new java.awt.GridBagConstraints();
1223: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1224: gridBagConstraints.weightx = 1.0;
1225: jPanel2.add(jButtonUpCondition, gridBagConstraints);
1226:
1227: jButtonDownCondition.setText("Down");
1228: jButtonDownCondition.setEnabled(false);
1229: jButtonDownCondition.setMargin(new java.awt.Insets(2, 2, 2, 2));
1230: jButtonDownCondition
1231: .addActionListener(new java.awt.event.ActionListener() {
1232: public void actionPerformed(
1233: java.awt.event.ActionEvent evt) {
1234: jButtonDownConditionActionPerformed(evt);
1235: }
1236: });
1237: gridBagConstraints = new java.awt.GridBagConstraints();
1238: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1239: gridBagConstraints.weightx = 1.0;
1240: jPanel2.add(jButtonDownCondition, gridBagConstraints);
1241:
1242: gridBagConstraints = new java.awt.GridBagConstraints();
1243: gridBagConstraints.gridx = 0;
1244: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1245: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
1246: jPanelConditions.add(jPanel2, gridBagConstraints);
1247:
1248: jLabelSample.setText("Sample");
1249: gridBagConstraints = new java.awt.GridBagConstraints();
1250: gridBagConstraints.gridx = 0;
1251: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1252: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
1253: gridBagConstraints.weightx = 1.0;
1254: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
1255: jPanelConditions.add(jLabelSample, gridBagConstraints);
1256:
1257: jPanelSample.setBorder(javax.swing.BorderFactory
1258: .createEtchedBorder());
1259: jPanelSample.setMinimumSize(new java.awt.Dimension(100, 80));
1260: jPanelSample.setPreferredSize(new java.awt.Dimension(14, 80));
1261: jPanelSample.setLayout(new java.awt.GridBagLayout());
1262: gridBagConstraints = new java.awt.GridBagConstraints();
1263: gridBagConstraints.gridx = 0;
1264: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1265: gridBagConstraints.ipadx = 4;
1266: gridBagConstraints.ipady = 4;
1267: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
1268: jPanelConditions.add(jPanelSample, gridBagConstraints);
1269:
1270: jSplitPane1.setRightComponent(jPanelConditions);
1271:
1272: gridBagConstraints = new java.awt.GridBagConstraints();
1273: gridBagConstraints.gridx = 0;
1274: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
1275: gridBagConstraints.ipadx = 4;
1276: gridBagConstraints.ipady = 4;
1277: gridBagConstraints.weightx = 1.0;
1278: gridBagConstraints.weighty = 1.0;
1279: getContentPane().add(jSplitPane1, gridBagConstraints);
1280:
1281: jPanel1.setLayout(new java.awt.FlowLayout(
1282: java.awt.FlowLayout.RIGHT));
1283:
1284: jButtonOK.setMnemonic('o');
1285: jButtonOK.setText("OK");
1286: jButtonOK
1287: .addActionListener(new java.awt.event.ActionListener() {
1288: public void actionPerformed(
1289: java.awt.event.ActionEvent evt) {
1290: jButtonOKActionPerformed(evt);
1291: }
1292: });
1293: jPanel1.add(jButtonOK);
1294:
1295: jButtonCancel.setMnemonic('c');
1296: jButtonCancel.setText("Cancel");
1297: jButtonCancel
1298: .addActionListener(new java.awt.event.ActionListener() {
1299: public void actionPerformed(
1300: java.awt.event.ActionEvent evt) {
1301: jButtonCancelActionPerformed(evt);
1302: }
1303: });
1304: jPanel1.add(jButtonCancel);
1305:
1306: gridBagConstraints = new java.awt.GridBagConstraints();
1307: gridBagConstraints.gridx = 0;
1308: gridBagConstraints.gridy = 9;
1309: gridBagConstraints.gridwidth = 2;
1310: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
1311: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
1312: gridBagConstraints.weightx = 1.0;
1313: gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
1314: getContentPane().add(jPanel1, gridBagConstraints);
1315:
1316: pack();
1317: java.awt.Dimension screenSize = java.awt.Toolkit
1318: .getDefaultToolkit().getScreenSize();
1319: java.awt.Dimension dialogSize = getSize();
1320: setLocation((screenSize.width - dialogSize.width) / 2,
1321: (screenSize.height - dialogSize.height) / 2);
1322: }// </editor-fold>//GEN-END:initComponents
1323:
1324: private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
1325:
1326: if (openCondition >= 0) {
1327: try {
1328: if (jConditionsList.getModel().getSize() > openCondition + 1) {
1329: this .jConditionsList
1330: .setSelectedIndex(openCondition + 1);
1331: jButtonModifyConditionActionPerformed(new ActionEvent(
1332: jButtonModifyCondition, 0, ""));
1333: }
1334: } catch (Exception ex) {
1335: ex.printStackTrace();
1336: }
1337: }
1338:
1339: }//GEN-LAST:event_formWindowOpened
1340:
1341: private void jButtonDownConditionActionPerformed(
1342: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDownConditionActionPerformed
1343: DefaultListModel dlm = (DefaultListModel) this .jConditionsList
1344: .getModel();
1345: boolean oldInit = isInit();
1346: setInit(true);
1347: int i = jConditionsList.getSelectedIndex();
1348: Object cs = jConditionsList.getSelectedValue();
1349: dlm.removeElementAt(i);
1350: dlm.insertElementAt(cs, i + 1);
1351: jConditionsList.setSelectedIndex(i + 1);
1352:
1353: jButtonUpCondition.setEnabled(true);
1354: if (i == dlm.size() - 2)
1355: jButtonDownCondition.setEnabled(false);
1356: setInit(oldInit);
1357: }//GEN-LAST:event_jButtonDownConditionActionPerformed
1358:
1359: private void jButtonUpConditionActionPerformed(
1360: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonUpConditionActionPerformed
1361:
1362: DefaultListModel dlm = (DefaultListModel) this .jConditionsList
1363: .getModel();
1364: boolean oldInit = isInit();
1365: setInit(true);
1366: int i = jConditionsList.getSelectedIndex();
1367: Object cs = jConditionsList.getSelectedValue();
1368: dlm.removeElementAt(i);
1369: dlm.insertElementAt(cs, i - 1);
1370: jConditionsList.setSelectedIndex(i - 1);
1371:
1372: if (i == 2)
1373: jButtonUpCondition.setEnabled(false);
1374: jButtonDownCondition.setEnabled(true);
1375: setInit(oldInit);
1376:
1377: }//GEN-LAST:event_jButtonUpConditionActionPerformed
1378:
1379: private void jButtonRemoveConditionActionPerformed(
1380: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveConditionActionPerformed
1381:
1382: if (jConditionsList.getSelectedIndex() == 0)
1383: return;
1384: int i = jConditionsList.getSelectedIndex();
1385: jConditionsList.setSelectedIndex(i - 1);
1386: ((DefaultListModel) this .jConditionsList.getModel()).remove(i);
1387:
1388: }//GEN-LAST:event_jButtonRemoveConditionActionPerformed
1389:
1390: private void jButtonModifyConditionActionPerformed(
1391: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonModifyConditionActionPerformed
1392:
1393: if (jConditionsList.getSelectedIndex() == 0)
1394: return;
1395:
1396: ConditionedStyle s = (ConditionedStyle) jConditionsList
1397: .getSelectedValue();
1398: String expression = s.getCondition();
1399:
1400: ExpressionEditor ed = new ExpressionEditor();
1401: if (MainFrame.getMainInstance().getActiveReportFrame() != null) {
1402: Report report = MainFrame.getMainInstance()
1403: .getActiveReportFrame().getReport();
1404: ed.setSubDataset(report);
1405: Vector v = report.getElements();
1406: for (int i = 0; i < v.size(); ++i) {
1407: ReportElement re = (ReportElement) v.elementAt(i);
1408: if (re instanceof CrosstabReportElement) {
1409: ed
1410: .addCrosstabReportElement((CrosstabReportElement) re);
1411: }
1412: }
1413: } else {
1414: ed.setSubDataset(new SubDataset());
1415: }
1416:
1417: ed.setExpression(expression);
1418: ed.setVisible(true);
1419: if (ed.getDialogResult() == JOptionPane.OK_OPTION) {
1420: String exp = ed.getExpression();
1421: if (exp.trim().length() > 0) {
1422: s.setCondition(exp.trim());
1423: jConditionsList.updateUI();
1424: }
1425: }
1426:
1427: }//GEN-LAST:event_jButtonModifyConditionActionPerformed
1428:
1429: private void jConditionsListMouseClicked(
1430: java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jConditionsListMouseClicked
1431:
1432: if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) {
1433: jButtonModifyConditionActionPerformed(null);
1434: }
1435:
1436: }//GEN-LAST:event_jConditionsListMouseClicked
1437:
1438: private void jButtonAddConditionActionPerformed(
1439: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddConditionActionPerformed
1440:
1441: ExpressionEditor ed = new ExpressionEditor();
1442: if (MainFrame.getMainInstance().getActiveReportFrame() != null) {
1443: Report report = MainFrame.getMainInstance()
1444: .getActiveReportFrame().getReport();
1445: ed.setSubDataset(report);
1446: Vector v = report.getElements();
1447: for (int i = 0; i < v.size(); ++i) {
1448: ReportElement re = (ReportElement) v.elementAt(i);
1449: if (re instanceof CrosstabReportElement) {
1450: ed
1451: .addCrosstabReportElement((CrosstabReportElement) re);
1452: }
1453: }
1454: } else {
1455: ed.setSubDataset(new SubDataset());
1456: }
1457:
1458: ed.setVisible(true);
1459:
1460: if (ed.getDialogResult() == JOptionPane.OK_OPTION) {
1461: String exp = ed.getExpression();
1462: if (exp.trim().length() > 0) {
1463: saveCurrentStyle();
1464: ConditionedStyle s = new ConditionedStyle(
1465: getMasterStyle());
1466: s.setConditionedStyles(new Vector());
1467: s.setCondition(exp.trim());
1468: DefaultListModel dlm = (DefaultListModel) jConditionsList
1469: .getModel();
1470: dlm.addElement(s);
1471: jConditionsList.setSelectedValue(s, true);
1472: }
1473: }
1474: }//GEN-LAST:event_jButtonAddConditionActionPerformed
1475:
1476: private void jConditionsListValueChanged(
1477: javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jConditionsListValueChanged
1478:
1479: if (isInit())
1480: return;
1481: if (evt.getValueIsAdjusting())
1482: return;
1483:
1484: //System.out.println(" style selected!");
1485: // Save the current style if needed
1486: saveCurrentStyle();
1487:
1488: if (jConditionsList.getSelectedIndex() == 0) {
1489: jButtonModifyCondition.setEnabled(false);
1490: jButtonRemoveCondition.setEnabled(false);
1491: jButtonUpCondition.setEnabled(false);
1492: jButtonDownCondition.setEnabled(false);
1493:
1494: setStyle(getMasterStyle(), false);
1495: } else {
1496: jButtonModifyCondition.setEnabled(true);
1497: jButtonRemoveCondition.setEnabled(true);
1498: jButtonUpCondition.setEnabled(jConditionsList
1499: .getSelectedIndex() > 1);
1500: jButtonDownCondition
1501: .setEnabled(jConditionsList.getSelectedIndex() < ((DefaultListModel) jConditionsList
1502: .getModel()).size() - 1);
1503:
1504: setStyle((Style) jConditionsList.getSelectedValue(), true);
1505: }
1506:
1507: }//GEN-LAST:event_jConditionsListValueChanged
1508:
1509: private void jButtonCancelActionPerformed(
1510: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
1511: setVisible(false);
1512: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
1513: dispose();
1514: }//GEN-LAST:event_jButtonCancelActionPerformed
1515:
1516: private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
1517:
1518: saveCurrentStyle();
1519:
1520: String newName = getMasterStyle().getAttributeString(
1521: Style.ATTRIBUTE_name, "");
1522:
1523: if (newName.trim().length() <= 0) {
1524: javax.swing.JOptionPane
1525: .showMessageDialog(
1526: this ,
1527: I18n
1528: .getString(
1529: "messages.styleDialog.notValidName",
1530: "Please insert a valid name for the style!"),
1531: I18n
1532: .getString(
1533: "messages.styleDialog.notValidNameCaption",
1534: "Invalid name!"),
1535: javax.swing.JOptionPane.WARNING_MESSAGE);
1536: jConditionsList.setSelectedIndex(0);
1537: return;
1538: }
1539:
1540: // check for duplicate name....
1541: Enumeration e = null;
1542:
1543: if (jasperTemplate != null) {
1544: e = new Vector(jasperTemplate.getStyles()).elements();
1545: } else if (isLibraryStyle()) {
1546: e = it.businesslogic.ireport.gui.MainFrame
1547: .getMainInstance().getStyleLibrarySet().elements();
1548: } else {
1549: e = it.businesslogic.ireport.gui.MainFrame
1550: .getMainInstance().getActiveReportFrame()
1551: .getReport().getStyles().elements();
1552: }
1553:
1554: while (e.hasMoreElements()) {
1555: Style st = (Style) e.nextElement();
1556: if (st.getAttributeString(st.ATTRIBUTE_name, "").equals(
1557: newName)
1558: && st != getEditingStyle()) {
1559: javax.swing.JOptionPane
1560: .showMessageDialog(
1561: this ,
1562: "The name \""
1563: + newName
1564: + "\" is already in use!\nPlease change it.",
1565: "Invalid name!",
1566: javax.swing.JOptionPane.WARNING_MESSAGE);
1567: return;
1568: }
1569: }
1570:
1571: DefaultListModel dlm = (DefaultListModel) jConditionsList
1572: .getModel();
1573: Vector conditionedStyles = new Vector();
1574: for (int k = 1; k < dlm.size(); ++k) {
1575: conditionedStyles.add(dlm.getElementAt(k));
1576: }
1577: getMasterStyle().setConditionedStyles(conditionedStyles);
1578:
1579: String oldName = "";
1580: boolean newStyle = false;
1581:
1582: if (getEditingStyle() == null) {
1583: newStyle = true;
1584: setEditingStyle(getMasterStyle());
1585:
1586: if (!isLibraryStyle() && jasperTemplate == null) {
1587: MainFrame.getMainInstance().getActiveReportFrame()
1588: .getReport().getStyles().add(getMasterStyle());
1589: } else if (jasperTemplate == null) {
1590: it.businesslogic.ireport.gui.MainFrame
1591: .getMainInstance().getStyleLibrarySet().add(
1592: getMasterStyle());
1593: }
1594: } else {
1595: oldName = getEditingStyle().getAttributeString(
1596: Style.ATTRIBUTE_name, "");
1597: getEditingStyle().getAttributes().clear();
1598: getEditingStyle().copyStyleFrom(getMasterStyle());
1599: }
1600:
1601: if (!isLibraryStyle() || jasperTemplate == null) {
1602: MainFrame
1603: .getMainInstance()
1604: .getActiveReportFrame()
1605: .getReport()
1606: .fireStyleChangedListenerStyleChanged(
1607: new StyleChangedEvent(
1608: MainFrame.getMainInstance()
1609: .getActiveReportFrame()
1610: .getReport(),
1611: (newStyle) ? StyleChangedEvent.ADDED
1612: : StyleChangedEvent.CHANGED,
1613: getEditingStyle(),
1614: getEditingStyle()));
1615: }
1616:
1617: this .style = getEditingStyle();
1618:
1619: // Dump style...
1620: //System.out.println("Save style:............");
1621: //HashMap hm = getStyle().getAttributes();
1622: //Iterator i_keys = hm.keySet().iterator();
1623: //while (i_keys.hasNext())
1624: // {
1625: // Object key = i_keys.next();
1626: // System.out.println( key + ": " +hm.get(key) );
1627: // }
1628:
1629: setVisible(false);
1630: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
1631: dispose();
1632: }//GEN-LAST:event_jButtonOKActionPerformed
1633:
1634: /** Closes the dialog */
1635: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
1636: setVisible(false);
1637: this .setDialogResult(javax.swing.JOptionPane.CLOSED_OPTION);
1638: dispose();
1639: }//GEN-LAST:event_closeDialog
1640:
1641: /**
1642: * @param args the command line arguments
1643: */
1644: public static void main(String args[]) {
1645: new JRParameterDialog(new javax.swing.JFrame(), true)
1646: .setVisible(true);
1647: }
1648:
1649: /** Getter for property dialogResult.
1650: * @return Value of property dialogResult.
1651: *
1652: */
1653: public int getDialogResult() {
1654: return dialogResult;
1655: }
1656:
1657: /** Setter for property dialogResult.
1658: * @param dialogResult New value of property dialogResult.
1659: *
1660: */
1661: public void setDialogResult(int dialogResult) {
1662: this .dialogResult = dialogResult;
1663: }
1664:
1665: // Variables declaration - do not modify//GEN-BEGIN:variables
1666: private javax.swing.JButton jButtonAddCondition;
1667: private javax.swing.JButton jButtonCancel;
1668: private javax.swing.JButton jButtonDownCondition;
1669: private javax.swing.JButton jButtonModifyCondition;
1670: private javax.swing.JButton jButtonOK;
1671: private javax.swing.JButton jButtonRemoveCondition;
1672: private javax.swing.JButton jButtonUpCondition;
1673: private javax.swing.JList jConditionsList;
1674: private javax.swing.JLabel jLabelSample;
1675: private javax.swing.JLabel jLabelStyleConditions;
1676: private javax.swing.JPanel jPanel1;
1677: private javax.swing.JPanel jPanel2;
1678: private javax.swing.JPanel jPanel3;
1679: private javax.swing.JPanel jPanelBoxEditorContainer;
1680: private javax.swing.JPanel jPanelConditions;
1681: private javax.swing.JPanel jPanelProperties;
1682: private javax.swing.JPanel jPanelSample;
1683: private javax.swing.JScrollPane jScrollPane1;
1684: private javax.swing.JSplitPane jSplitPane1;
1685: // End of variables declaration//GEN-END:variables
1686:
1687: private int dialogResult;
1688:
1689: public CategorySheetPanel getSheetPanel() {
1690: return sheetPanel;
1691: }
1692:
1693: public void setSheetPanel(CategorySheetPanel sheetPanel) {
1694: this .sheetPanel = sheetPanel;
1695: }
1696:
1697: public void sheetPropertyValueChanged(
1698: it.businesslogic.ireport.gui.event.SheetPropertyValueChangedEvent evt) {
1699:
1700: //System.out.println("Changed proprty " + evt.getPropertyName());
1701:
1702: if (isInit())
1703: return;
1704: if (evt.getPropertyName() != null
1705: && evt.getPropertyName().equals("style.font")) {
1706: setIreportFont((IReportFont) evt.getNewValue());
1707:
1708: boolean oldInit = isInit();
1709: setInit(true);
1710: if (getIreportFont() != null) {
1711: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold,
1712: getIreportFont().getBeanProperties().get(
1713: getIreportFont().IS_BOLD));
1714: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic,
1715: getIreportFont().getBeanProperties().get(
1716: getIreportFont().IS_ITALIC));
1717: sheetPanel.setPropertyValue(
1718: Style.ATTRIBUTE_isStrikeThrough,
1719: getIreportFont().getBeanProperties().get(
1720: getIreportFont().IS_STRIKETROUGHT));
1721: sheetPanel.setPropertyValue(
1722: Style.ATTRIBUTE_isUnderline, getIreportFont()
1723: .getBeanProperties().get(
1724: getIreportFont().IS_UNDERLINE));
1725: } else {
1726: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold,
1727: null);
1728: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic,
1729: null);
1730: sheetPanel.setPropertyValue(
1731: Style.ATTRIBUTE_isStrikeThrough, null);
1732: sheetPanel.setPropertyValue(
1733: Style.ATTRIBUTE_isUnderline, null);
1734: }
1735: setInit(oldInit);
1736:
1737: } else if (evt.getPropertyName() != null
1738: && evt.getPropertyName().equals(Style.ATTRIBUTE_isBold)) {
1739: IReportFont ifont = getIreportFont();
1740: ifont.getBeanProperties().put(ifont.IS_BOLD,
1741: evt.getNewValue());
1742: sheetPanel.setPropertyValue("style.font", ifont);
1743: } else if (evt.getPropertyName() != null
1744: && evt.getPropertyName().equals(
1745: Style.ATTRIBUTE_isItalic)) {
1746: IReportFont ifont = getIreportFont();
1747: ifont.getBeanProperties().put(ifont.IS_ITALIC,
1748: evt.getNewValue());
1749: sheetPanel.setPropertyValue("style.font", ifont);
1750: } else if (evt.getPropertyName() != null
1751: && evt.getPropertyName().equals(
1752: Style.ATTRIBUTE_isUnderline)) {
1753: IReportFont ifont = getIreportFont();
1754: ifont.getBeanProperties().put(ifont.IS_UNDERLINE,
1755: evt.getNewValue());
1756: sheetPanel.setPropertyValue("style.font", ifont);
1757: } else if (evt.getPropertyName() != null
1758: && evt.getPropertyName().equals(
1759: Style.ATTRIBUTE_isStrikeThrough)) {
1760: IReportFont ifont = getIreportFont();
1761: ifont.getBeanProperties().put(ifont.IS_STRIKETROUGHT,
1762: evt.getNewValue());
1763: sheetPanel.setPropertyValue("style.font", ifont);
1764: }
1765:
1766: //saveCurrentStyle();
1767: if (!isInit() && panelSample != null
1768: && panelSample.getStyle() != null) {
1769: Vector properties = this .sheetPanel.getProperties();
1770: for (int i = 0; i < properties.size(); ++i) {
1771: SheetProperty sp = (SheetProperty) properties.get(i);
1772: //if ( sp.getValue() != null)
1773: {
1774: panelSample.getStyle().getAttributes().put(
1775: sp.getKeyName(), sp.getValue());
1776: }
1777: }
1778: panelSample.invalidate();
1779: panelSample.repaint();
1780: }
1781: }
1782:
1783: public Style getStyle() {
1784: return style;
1785: }
1786:
1787: public void updateStyleValues() {
1788: boolean oldInit = isInit();
1789: setInit(true);
1790: //System.out.println("Updating style values...");
1791:
1792: sheetPanel.setPropertyValue(Style.ATTRIBUTE_name, getStyle()
1793: .getAttribute(style.ATTRIBUTE_name));
1794: sheetPanel.setPropertyValue(Style.ATTRIBUTE_backcolor,
1795: getStyle().getAttribute(style.ATTRIBUTE_backcolor));
1796: sheetPanel.setPropertyValue(Style.ATTRIBUTE_borderColor,
1797: getStyle().getAttribute(style.ATTRIBUTE_borderColor));
1798: sheetPanel.setPropertyValue(Style.ATTRIBUTE_border, getStyle()
1799: .getAttribute(style.ATTRIBUTE_border));
1800: sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomBorderColor,
1801: getStyle().getAttribute(
1802: style.ATTRIBUTE_bottomBorderColor));
1803: sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomBorder,
1804: getStyle().getAttribute(style.ATTRIBUTE_bottomBorder));
1805: sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomPadding,
1806: getStyle().getAttribute(style.ATTRIBUTE_bottomPadding));
1807: sheetPanel.setPropertyValue(Style.ATTRIBUTE_fill, getStyle()
1808: .getAttribute(style.ATTRIBUTE_fill));
1809: sheetPanel.setPropertyValue(Style.ATTRIBUTE_forecolor,
1810: getStyle().getAttribute(style.ATTRIBUTE_forecolor));
1811: sheetPanel.setPropertyValue(Style.ATTRIBUTE_hAlign, getStyle()
1812: .getAttribute(style.ATTRIBUTE_hAlign));
1813: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBlankWhenNull,
1814: getStyle()
1815: .getAttribute(style.ATTRIBUTE_isBlankWhenNull));
1816: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isDefault,
1817: getStyle().getAttribute(style.ATTRIBUTE_isDefault));
1818: sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftBorderColor,
1819: getStyle()
1820: .getAttribute(style.ATTRIBUTE_leftBorderColor));
1821: sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftBorder,
1822: getStyle().getAttribute(style.ATTRIBUTE_leftBorder));
1823: sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftPadding,
1824: getStyle().getAttribute(style.ATTRIBUTE_leftPadding));
1825: sheetPanel.setPropertyValue(Style.ATTRIBUTE_lineSpacing,
1826: getStyle().getAttribute(style.ATTRIBUTE_lineSpacing));
1827: sheetPanel.setPropertyValue(Style.ATTRIBUTE_mode, getStyle()
1828: .getAttribute(style.ATTRIBUTE_mode));
1829: sheetPanel.setPropertyValue(Style.ATTRIBUTE_padding, getStyle()
1830: .getAttribute(style.ATTRIBUTE_padding));
1831: sheetPanel.setPropertyValue(Style.ATTRIBUTE_pattern, getStyle()
1832: .getAttribute(style.ATTRIBUTE_pattern));
1833: sheetPanel.setPropertyValue(Style.ATTRIBUTE_pen, getStyle()
1834: .getAttribute(style.ATTRIBUTE_pen));
1835: sheetPanel.setPropertyValue(Style.ATTRIBUTE_radius, getStyle()
1836: .getAttribute(style.ATTRIBUTE_radius));
1837: sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightBorderColor,
1838: getStyle().getAttribute(
1839: style.ATTRIBUTE_rightBorderColor));
1840: sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightBorder,
1841: getStyle().getAttribute(style.ATTRIBUTE_rightBorder));
1842: sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightPadding,
1843: getStyle().getAttribute(style.ATTRIBUTE_rightPadding));
1844: sheetPanel.setPropertyValue(Style.ATTRIBUTE_rotation,
1845: getStyle().getAttribute(style.ATTRIBUTE_rotation));
1846: sheetPanel.setPropertyValue(Style.ATTRIBUTE_scaleImage,
1847: getStyle().getAttribute(style.ATTRIBUTE_scaleImage));
1848: sheetPanel.setPropertyValue(Style.ATTRIBUTE_style, getStyle()
1849: .getAttribute(style.ATTRIBUTE_style));
1850: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStyledText,
1851: getStyle().getAttribute(style.ATTRIBUTE_isStyledText));
1852: sheetPanel.setPropertyValue(Style.ATTRIBUTE_markup, getStyle()
1853: .getAttribute(style.ATTRIBUTE_markup));
1854:
1855: sheetPanel.setPropertyValue("style.font", getIreportFont());
1856: sheetPanel
1857: .setPropertyValue(Style.ATTRIBUTE_topBorderColor,
1858: getStyle().getAttribute(
1859: style.ATTRIBUTE_topBorderColor));
1860: sheetPanel.setPropertyValue(Style.ATTRIBUTE_topBorder,
1861: getStyle().getAttribute(style.ATTRIBUTE_topBorder));
1862: sheetPanel.setPropertyValue(Style.ATTRIBUTE_topPadding,
1863: getStyle().getAttribute(style.ATTRIBUTE_topPadding));
1864: sheetPanel.setPropertyValue(Style.ATTRIBUTE_vAlign, getStyle()
1865: .getAttribute(style.ATTRIBUTE_vAlign));
1866:
1867: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold, getStyle()
1868: .getAttribute(style.ATTRIBUTE_isBold));
1869: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isUnderline,
1870: getStyle().getAttribute(style.ATTRIBUTE_isUnderline));
1871: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic,
1872: getStyle().getAttribute(style.ATTRIBUTE_isItalic));
1873: sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStrikeThrough,
1874: getStyle()
1875: .getAttribute(style.ATTRIBUTE_isStrikeThrough));
1876: setInit(oldInit);
1877:
1878: }
1879:
1880: public void setJasperTemplate(JasperTemplate jt) {
1881: this .jasperTemplate = jt;
1882: this .jButtonAddCondition.setEnabled(false);
1883: }
1884:
1885: /**
1886: * Set the style to edit. A temporary copy of the style will be created. That
1887: * modified values will be copied into the original style if modified.
1888: * All substyles will be replaced at the end of the editing (eventually with exact copies).
1889: */
1890: public void setStyle(Style myStyle) {
1891:
1892: Style copyStyle = new Style(myStyle);
1893: copyStyle.setName(myStyle.getName());
1894: this .setMasterStyle(copyStyle);
1895:
1896: if (myStyle instanceof TemplateStyle) {
1897: setJasperTemplate(((TemplateStyle) myStyle)
1898: .getJasperTemplate());
1899: } else if (myStyle instanceof UndefinedStyle) {
1900: this .jButtonAddCondition.setEnabled(false);
1901: }
1902:
1903: if (myStyle.getAttributeBoolean(myStyle.ATTRIBUTE_isDefault,
1904: false)) {
1905: this .getMasterStyle().getAttributes().put(
1906: myStyle.ATTRIBUTE_isDefault, new Boolean(true));
1907: }
1908:
1909: setStyle(getMasterStyle(), false);
1910:
1911: this .setEditingStyle(myStyle);
1912:
1913: boolean oldInit = isInit();
1914: setInit(true);
1915:
1916: //updateParentStylesList();
1917:
1918: ((DefaultListModel) jConditionsList.getModel())
1919: .removeAllElements();
1920: //
1921: ((DefaultListModel) jConditionsList.getModel()).addElement(I18n
1922: .getString("styleDialog.conditionsList.default",
1923: "Default"));
1924: //((DefaultListModel)jConditionsList.getModel()).addElement("Default");
1925: //
1926:
1927: for (int i = 0; i < getMasterStyle().getConditionedStyles()
1928: .size(); ++i) {
1929: ((DefaultListModel) jConditionsList.getModel())
1930: .addElement(getMasterStyle().getConditionedStyles()
1931: .elementAt(i));
1932: }
1933:
1934: this .jConditionsList.setSelectedIndex(0);
1935:
1936: setInit(oldInit);
1937: }
1938:
1939: public void updateParentStylesList() {
1940: // currentReport
1941: if (it.businesslogic.ireport.gui.MainFrame.getMainInstance()
1942: .getActiveReportFrame() != null) {
1943: currentReport = it.businesslogic.ireport.gui.MainFrame
1944: .getMainInstance().getActiveReportFrame()
1945: .getReport();
1946: Enumeration enum_styles = currentReport.getStyles()
1947: .elements();
1948:
1949: Vector tags = new Vector();
1950: while (enum_styles.hasMoreElements()) {
1951: Style s = (Style) enum_styles.nextElement();
1952: if (s != this .getMasterStyle()
1953: && !s.getName().equals(
1954: this .getMasterStyle().getName())) {
1955: tags.add(s); //new Tag(s)
1956: }
1957: }
1958: ComboBoxSheetProperty sp = (ComboBoxSheetProperty) getSheetPanel()
1959: .getSheetProperty(Style.ATTRIBUTE_style);
1960: Object s = sp.getValue();
1961: sp.updateValues(tags, true);
1962: ((JComboBox) sp.getEditor()).setSelectedItem(s);
1963: }
1964: }
1965:
1966: /**
1967: * Set the style to edit. Remember to call saveCurrentStyle() if needed before change the displayed
1968: * style.
1969: * if conditionalStyle == true, the common fields are set disabled.
1970: */
1971: private void setStyle(Style myStyle, boolean conditionalStyle) {
1972: this .style = myStyle;
1973:
1974: ((SheetProperty) sheetPanel
1975: .getSheetProperty(Style.ATTRIBUTE_name))
1976: .setReadOnly(conditionalStyle);
1977: ((SheetProperty) sheetPanel
1978: .getSheetProperty(Style.ATTRIBUTE_isDefault))
1979: .setReadOnly(conditionalStyle);
1980: ((SheetProperty) sheetPanel
1981: .getSheetProperty(Style.ATTRIBUTE_style))
1982: .setReadOnly(conditionalStyle);
1983:
1984: setIreportFont(new IReportFont());
1985:
1986: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_isBold) != null)
1987: getIreportFont().setBold(
1988: myStyle.getAttributeBoolean(
1989: myStyle.ATTRIBUTE_isBold, false));
1990:
1991: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_fontName) != null)
1992: getIreportFont().setFontName(
1993: myStyle.getAttributeString(
1994: myStyle.ATTRIBUTE_fontName,
1995: getIreportFont().getFontName()));
1996:
1997: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_fontSize) != null)
1998: getIreportFont().setFontSize(
1999: myStyle.getAttributeInteger(
2000: myStyle.ATTRIBUTE_fontSize,
2001: getIreportFont().getFontSize()));
2002:
2003: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_isItalic) != null)
2004: getIreportFont().setItalic(
2005: myStyle.getAttributeBoolean(
2006: myStyle.ATTRIBUTE_isItalic, false));
2007:
2008: if (myStyle.getAttributes()
2009: .get(myStyle.ATTRIBUTE_isPdfEmbedded) != null)
2010: getIreportFont().setPdfEmbedded(
2011: myStyle.getAttributeBoolean(
2012: myStyle.ATTRIBUTE_isPdfEmbedded, false));
2013:
2014: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_pdfEncoding) != null)
2015: getIreportFont().setPdfEncoding(
2016: myStyle.getAttributeString(
2017: myStyle.ATTRIBUTE_pdfEncoding,
2018: getIreportFont().getPdfEncoding()));
2019:
2020: if (myStyle.getAttributes().get(
2021: myStyle.ATTRIBUTE_isStrikeThrough) != null)
2022: getIreportFont().setStrikeTrought(
2023: myStyle.getAttributeBoolean(
2024: myStyle.ATTRIBUTE_isStrikeThrough, false));
2025:
2026: // TODO = We have to understand what kind of font is this...
2027: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_pdfFontName) != null)
2028: getIreportFont().setPDFFontName(
2029: myStyle.getAttributeString(
2030: myStyle.ATTRIBUTE_pdfFontName,
2031: getIreportFont().getPDFFontName()));
2032:
2033: if (myStyle.getAttributes().get(myStyle.ATTRIBUTE_isUnderline) != null)
2034: getIreportFont().setUnderline(
2035: myStyle.getAttributeBoolean(
2036: myStyle.ATTRIBUTE_isUnderline, false));
2037:
2038: updateParentStylesList();
2039: updateStyleValues();
2040:
2041: Box tmpBox = new Box();
2042: if (style.getBox() != null) {
2043: tmpBox = style.getBox();
2044: } else {
2045: style.setBox(tmpBox);
2046: }
2047:
2048: boxPanel.setBox(tmpBox);
2049: panelSample.setStyle(myStyle);
2050: }
2051:
2052: public IReportFont getIreportFont() {
2053: if (ireportFont == null)
2054: ireportFont = new IReportFont();
2055: return ireportFont;
2056: }
2057:
2058: public void setIreportFont(IReportFont ireportFont) {
2059: this .ireportFont = ireportFont;
2060: }
2061:
2062: private Style getMasterStyle() {
2063: return masterStyle;
2064: }
2065:
2066: private void setMasterStyle(Style masterStyle) {
2067: this .masterStyle = masterStyle;
2068: }
2069:
2070: /**
2071: * This method save all the propeties present in the sheet into the
2072: * current style (pointed by the variable style)
2073: */
2074: private void saveCurrentStyle() {
2075: if (getStyle() == null)
2076: return;
2077: // Store all values...
2078: Vector properties = this .sheetPanel.getProperties();
2079:
2080: if (getStyle() instanceof ConditionedStyle) {
2081: String condition = ((ConditionedStyle) getStyle())
2082: .getCondition();
2083: getStyle().getAttributes().clear();
2084: ((ConditionedStyle) getStyle()).setCondition(condition);
2085: } else {
2086: getStyle().getAttributes().clear();
2087: }
2088:
2089: for (int i = 0; i < properties.size(); ++i) {
2090: SheetProperty sp = (SheetProperty) properties.get(i);
2091: if (sp.getValue() != null) {
2092: getStyle().getAttributes().put(sp.getKeyName(),
2093: sp.getValue());
2094: //System.out.println(sp.getKeyName() + " " + sp.getValue());
2095: }
2096: }
2097:
2098: if (getStyle().getAttributes().get(getStyle().ATTRIBUTE_style) != null
2099: && !(getStyle().getAttributes().get(
2100: getStyle().ATTRIBUTE_style) instanceof Style)) {
2101: String sname = ""
2102: + getStyle().getAttributes().get(
2103: getStyle().ATTRIBUTE_style);
2104: if (sname.trim().length() == 0) {
2105: getStyle().getAttributes().remove(
2106: getStyle().ATTRIBUTE_style);
2107: } else if (currentReport != null) {
2108: for (int j = 0; j < currentReport.getStyles().size(); ++j) {
2109: Style sparent = (Style) currentReport.getStyles()
2110: .elementAt(j);
2111: if (sparent.getName().equals(sname)) {
2112: getStyle().getAttributes().put(
2113: getStyle().ATTRIBUTE_style, sparent);
2114: }
2115: }
2116: }
2117: }
2118:
2119: if (getStyle().getAttributeBoolean(
2120: getStyle().ATTRIBUTE_isDefault, false)) {
2121: if (!isLibraryStyle() && !isReadOnly()
2122: && jasperTemplate != null) {
2123: Enumeration enum_s = MainFrame.getMainInstance()
2124: .getActiveReportFrame().getReport().getStyles()
2125: .elements();
2126: while (enum_s.hasMoreElements()) {
2127: Style tmp_s = (Style) enum_s.nextElement();
2128: if (tmp_s != getStyle()) {
2129: tmp_s.getAttributes().remove(
2130: getStyle().ATTRIBUTE_isDefault);
2131: }
2132: }
2133: }
2134: }
2135:
2136: if (ireportFont != null) {
2137: getStyle().getAttributes().put(
2138: Style.ATTRIBUTE_fontName,
2139: ireportFont.getBeanProperties().get(
2140: ireportFont.FONT_NAME));
2141:
2142: if (ireportFont.getBeanProperties().get(
2143: ireportFont.FONT_SIZE) != null)
2144: getStyle().getAttributes().put(
2145: Style.ATTRIBUTE_fontSize,
2146: new Integer(ireportFont.getFontSize()));
2147:
2148: if (ireportFont.getBeanProperties()
2149: .get(ireportFont.IS_BOLD) != null)
2150: getStyle().getAttributes().put(style.ATTRIBUTE_isBold,
2151: new Boolean(ireportFont.isBold()));
2152:
2153: if (ireportFont.getBeanProperties().get(
2154: ireportFont.IS_ITALIC) != null)
2155: getStyle().getAttributes().put(
2156: style.ATTRIBUTE_isItalic,
2157: new Boolean(ireportFont.isItalic()));
2158:
2159: if (ireportFont.getBeanProperties().get(
2160: ireportFont.IS_UNDERLINE) != null)
2161: getStyle().getAttributes().put(
2162: style.ATTRIBUTE_isUnderline,
2163: new Boolean(ireportFont.isUnderline()));
2164:
2165: if (ireportFont.getBeanProperties().get(
2166: ireportFont.IS_STRIKETROUGHT) != null)
2167: getStyle().getAttributes().put(
2168: style.ATTRIBUTE_isStrikeThrough,
2169: new Boolean(ireportFont.isStrikeTrought()));
2170:
2171: if (ireportFont.getBeanProperties().get(
2172: ireportFont.IS_PDF_EMBEDDED) != null)
2173: getStyle().getAttributes().put(
2174: style.ATTRIBUTE_isPdfEmbedded,
2175: new Boolean(ireportFont.isPdfEmbedded()));
2176:
2177: if (ireportFont.getBeanProperties().get(
2178: ireportFont.PDF_FONT_NAME) != null)
2179: getStyle().getAttributes().put(
2180: Style.ATTRIBUTE_pdfFontName,
2181: ireportFont.getPDFFontName());
2182:
2183: if (ireportFont.getBeanProperties().get(
2184: ireportFont.PDF_ENCODING) != null)
2185: getStyle().getAttributes().put(
2186: Style.ATTRIBUTE_pdfEncoding,
2187: ireportFont.getPdfEncoding());
2188:
2189: }
2190:
2191: Box box = boxPanel.getBox();
2192:
2193: if (box == null
2194: || (box.getPen() == null && box.getTopPen() == null
2195: && box.getLeftPen() == null
2196: && box.getBottomPen() == null && box
2197: .getRightPen() == null)) {
2198: getStyle().setBox(null);
2199: } else {
2200: getStyle().setBox(box);
2201: }
2202:
2203: /*
2204: HashMap hm = getStyle().getAttributes();
2205: Iterator i_keys = hm.keySet().iterator();
2206:
2207: while (i_keys.hasNext())
2208: {
2209: Object key = i_keys.next();
2210: System.out.println( key + ": " +hm.get(key) );
2211: }
2212: */
2213: }
2214:
2215: public boolean isInit() {
2216: return init;
2217: }
2218:
2219: public void setInit(boolean init) {
2220: this .init = init;
2221: }
2222:
2223: public Style getEditingStyle() {
2224: return editingStyle;
2225: }
2226:
2227: public void setEditingStyle(Style editingStyle) {
2228: this .editingStyle = editingStyle;
2229: }
2230:
2231: public boolean isLibraryStyle() {
2232: return libraryStyle;
2233: }
2234:
2235: public void setLibraryStyle(boolean libraryStyle) {
2236: this .libraryStyle = libraryStyle;
2237: }
2238:
2239: public void applyI18n() {
2240: // Start autogenerated code ----------------------
2241: jButtonAddCondition.setText(I18n.getString(
2242: "styleDialog.buttonAddCondition", "Add"));
2243: jButtonCancel.setText(I18n.getString(
2244: "styleDialog.buttonCancel", "Cancel"));
2245: jButtonDownCondition.setText(I18n.getString(
2246: "styleDialog.buttonDownCondition", "Down"));
2247: jButtonModifyCondition.setText(I18n.getString(
2248: "styleDialog.buttonModifyCondition", "Modify"));
2249: jButtonOK.setText(I18n.getString("styleDialog.buttonOK", "OK"));
2250: jButtonRemoveCondition.setText(I18n.getString(
2251: "styleDialog.buttonRemoveCondition", "Remove"));
2252: jButtonUpCondition.setText(I18n.getString(
2253: "styleDialog.buttonUpCondition", "up"));
2254: jLabelSample.setText(I18n.getString("styleDialog.labelSample",
2255: "Sample"));
2256: jLabelStyleConditions
2257: .setText(I18n.getString(
2258: "styleDialog.labelStyleConditions",
2259: "Style conditions"));
2260: // End autogenerated code ----------------------
2261:
2262: //
2263: this .setTitle(I18n.getString("styleDialog.title",
2264: "Add/modify style"));
2265: jButtonCancel.setMnemonic(I18n.getString(
2266: "styleDialog.buttonCancelMnemonic", "c").charAt(0));
2267: jButtonOK.setMnemonic(I18n.getString(
2268: "styleDialog.buttonOKMnemonic", "o").charAt(0));
2269: //
2270: }
2271:
2272: private int openCondition = -1;
2273:
2274: /**
2275: * Open the condition numbered itemIndex, once this window becomes visible...
2276: */
2277: public void setOpenCondition(int itemIndex) {
2278: this.openCondition = itemIndex;
2279: }
2280: }
|