001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * ValueDatasetPanel.java
028: *
029: * Created on 15 agosto 2005, 17.55
030: *
031: */
032:
033: package it.businesslogic.ireport.chart;
034:
035: import it.businesslogic.ireport.SubDataset;
036: import it.businesslogic.ireport.util.I18n;
037: import it.businesslogic.ireport.util.Misc;
038:
039: /**
040: *
041: * @author Administrator
042: */
043: public class ValueDatasetPanel extends javax.swing.JPanel implements
044: ChartDatasetPanel {
045:
046: private ValueDataset valueDataset = null;
047:
048: /** Creates new form PieDatasetPanel */
049: public ValueDatasetPanel() {
050: initComponents();
051:
052: applyI18n();
053:
054: this .jRTextExpressionValue.getDocument().addDocumentListener(
055: new javax.swing.event.DocumentListener() {
056: public void changedUpdate(
057: javax.swing.event.DocumentEvent evt) {
058: jRTextExpressionValueTextChanged();
059: }
060:
061: public void insertUpdate(
062: javax.swing.event.DocumentEvent evt) {
063: jRTextExpressionValueTextChanged();
064: }
065:
066: public void removeUpdate(
067: javax.swing.event.DocumentEvent evt) {
068: jRTextExpressionValueTextChanged();
069: }
070: });
071:
072: }
073:
074: public ValueDataset getValueDataset() {
075: return valueDataset;
076: }
077:
078: /**
079: * this method is used to pass the correct subdataset to the expression editor
080: */
081: public void setSubDataset(SubDataset sds) {
082: jRTextExpressionValue.setSubDataset(sds);
083: }
084:
085: public void setValueDataset(ValueDataset valueDataset) {
086: this .valueDataset = valueDataset;
087: jRTextExpressionValue
088: .setText(valueDataset.getValueExpression());
089: }
090:
091: public void jRTextExpressionValueTextChanged() {
092: valueDataset
093: .setValueExpression(jRTextExpressionValue.getText());
094: }
095:
096: /** This method is called from within the constructor to
097: * initialize the form.
098: * WARNING: Do NOT modify this code. The content of this method is
099: * always regenerated by the Form Editor.
100: */
101: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
102: private void initComponents() {
103: java.awt.GridBagConstraints gridBagConstraints;
104:
105: jPanel1 = new javax.swing.JPanel();
106: jLabelValueExpression = new javax.swing.JLabel();
107: jRTextExpressionValue = new it.businesslogic.ireport.gui.JRTextExpressionArea();
108:
109: setLayout(new java.awt.GridBagLayout());
110:
111: jPanel1.setLayout(new java.awt.GridBagLayout());
112:
113: jLabelValueExpression.setText("Value expression");
114: gridBagConstraints = new java.awt.GridBagConstraints();
115: gridBagConstraints.gridx = 0;
116: gridBagConstraints.gridy = 2;
117: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
118: gridBagConstraints.weightx = 1.0;
119: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
120: jPanel1.add(jLabelValueExpression, gridBagConstraints);
121:
122: jRTextExpressionValue.setBorder(javax.swing.BorderFactory
123: .createEtchedBorder());
124: jRTextExpressionValue.setElectricScroll(0);
125: jRTextExpressionValue.setMinimumSize(new java.awt.Dimension(10,
126: 10));
127: jRTextExpressionValue.setPreferredSize(new java.awt.Dimension(
128: 10, 10));
129: gridBagConstraints = new java.awt.GridBagConstraints();
130: gridBagConstraints.gridx = 0;
131: gridBagConstraints.gridy = 3;
132: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
133: gridBagConstraints.weightx = 1.0;
134: gridBagConstraints.weighty = 1.0;
135: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
136: jPanel1.add(jRTextExpressionValue, gridBagConstraints);
137:
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
140: gridBagConstraints.weightx = 1.0;
141: gridBagConstraints.weighty = 1.0;
142: add(jPanel1, gridBagConstraints);
143:
144: }// </editor-fold>//GEN-END:initComponents
145:
146: // Variables declaration - do not modify//GEN-BEGIN:variables
147: private javax.swing.JLabel jLabelValueExpression;
148: private javax.swing.JPanel jPanel1;
149: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionValue;
150:
151: // End of variables declaration//GEN-END:variables
152:
153: public void applyI18n() {
154: // Start autogenerated code ----------------------
155: jLabelValueExpression.setText(I18n.getString(
156: "valueDatasetPanel.labelValueExpression",
157: "Value expression"));
158: // End autogenerated code ----------------------
159: }
160:
161: public static final int COMPONENT_NONE = 0;
162: public static final int COMPONENT_VALUE_EXPRESSION = 1;
163:
164: /**
165: * This method set the focus on a specific component.
166: *
167: */
168: public void setFocusedExpression(Object[] expressionInfo) {
169: if (expressionInfo == null)
170: return;
171: int expID = ((Integer) expressionInfo[0]).intValue();
172: switch (expID) {
173: case COMPONENT_VALUE_EXPRESSION:
174: Misc.selectTextAndFocusArea(jRTextExpressionValue);
175: }
176: }
177:
178: public void containerWindowOpened() {
179:
180: }
181: }
|