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: * PieDatasetPanel.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 PieDatasetPanel extends javax.swing.JPanel implements
044: ChartDatasetPanel {
045:
046: private PieDataset pieDataset = null;
047:
048: /** Creates new form PieDatasetPanel */
049: public PieDatasetPanel() {
050: initComponents();
051:
052: applyI18n();
053:
054: this .jRTextExpressionKey.getDocument().addDocumentListener(
055: new javax.swing.event.DocumentListener() {
056: public void changedUpdate(
057: javax.swing.event.DocumentEvent evt) {
058: jRTextExpressionKeyTextChanged();
059: }
060:
061: public void insertUpdate(
062: javax.swing.event.DocumentEvent evt) {
063: jRTextExpressionKeyTextChanged();
064: }
065:
066: public void removeUpdate(
067: javax.swing.event.DocumentEvent evt) {
068: jRTextExpressionKeyTextChanged();
069: }
070: });
071:
072: this .jRTextExpressionValue.getDocument().addDocumentListener(
073: new javax.swing.event.DocumentListener() {
074: public void changedUpdate(
075: javax.swing.event.DocumentEvent evt) {
076: jRTextExpressionValueTextChanged();
077: }
078:
079: public void insertUpdate(
080: javax.swing.event.DocumentEvent evt) {
081: jRTextExpressionValueTextChanged();
082: }
083:
084: public void removeUpdate(
085: javax.swing.event.DocumentEvent evt) {
086: jRTextExpressionValueTextChanged();
087: }
088: });
089:
090: this .jRTextExpressionLabel.getDocument().addDocumentListener(
091: new javax.swing.event.DocumentListener() {
092: public void changedUpdate(
093: javax.swing.event.DocumentEvent evt) {
094: jRTextExpressionLabelTextChanged();
095: }
096:
097: public void insertUpdate(
098: javax.swing.event.DocumentEvent evt) {
099: jRTextExpressionLabelTextChanged();
100: }
101:
102: public void removeUpdate(
103: javax.swing.event.DocumentEvent evt) {
104: jRTextExpressionLabelTextChanged();
105: }
106: });
107: }
108:
109: public PieDataset getPieDataset() {
110: return pieDataset;
111: }
112:
113: /**
114: * this method is used to pass the correct subdataset to the expression editor
115: */
116: public void setSubDataset(SubDataset sds) {
117: jRTextExpressionKey.setSubDataset(sds);
118: jRTextExpressionValue.setSubDataset(sds);
119: jRTextExpressionLabel.setSubDataset(sds);
120: sectionItemHyperlinkPanel1.setSubDataset(sds);
121: }
122:
123: public void setPieDataset(PieDataset pieDataset) {
124: this .pieDataset = pieDataset;
125: jRTextExpressionKey.setText(pieDataset.getKeyExpression());
126: jRTextExpressionValue.setText(pieDataset.getValueExpression());
127: jRTextExpressionLabel.setText(pieDataset.getLabelExpression());
128:
129: sectionItemHyperlinkPanel1.setSectionItemHyperlink(pieDataset
130: .getSectionHyperLink());
131:
132: }
133:
134: public void jRTextExpressionKeyTextChanged() {
135: pieDataset.setKeyExpression(jRTextExpressionKey.getText());
136: }
137:
138: public void jRTextExpressionValueTextChanged() {
139: pieDataset.setValueExpression(jRTextExpressionValue.getText());
140: }
141:
142: public void jRTextExpressionLabelTextChanged() {
143: pieDataset.setLabelExpression(jRTextExpressionLabel.getText());
144: }
145:
146: /** This method is called from within the constructor to
147: * initialize the form.
148: * WARNING: Do NOT modify this code. The content of this method is
149: * always regenerated by the Form Editor.
150: */
151: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
152: private void initComponents() {
153: java.awt.GridBagConstraints gridBagConstraints;
154:
155: jTabbedPane1 = new javax.swing.JTabbedPane();
156: jPanel1 = new javax.swing.JPanel();
157: jLabelKeyExpression = new javax.swing.JLabel();
158: jRTextExpressionKey = new it.businesslogic.ireport.gui.JRTextExpressionArea();
159: jLabelValueExpression = new javax.swing.JLabel();
160: jRTextExpressionValue = new it.businesslogic.ireport.gui.JRTextExpressionArea();
161: jLabelLabelExpression = new javax.swing.JLabel();
162: jRTextExpressionLabel = new it.businesslogic.ireport.gui.JRTextExpressionArea();
163: jPanel2 = new javax.swing.JPanel();
164: sectionItemHyperlinkPanel1 = new it.businesslogic.ireport.chart.gui.SectionItemHyperlinkPanel();
165:
166: setLayout(new java.awt.GridBagLayout());
167:
168: jPanel1.setLayout(new java.awt.GridBagLayout());
169:
170: jLabelKeyExpression.setText("Key expression");
171: gridBagConstraints = new java.awt.GridBagConstraints();
172: gridBagConstraints.gridx = 0;
173: gridBagConstraints.gridy = 0;
174: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
175: gridBagConstraints.weightx = 1.0;
176: jPanel1.add(jLabelKeyExpression, gridBagConstraints);
177:
178: jRTextExpressionKey.setBorder(javax.swing.BorderFactory
179: .createEtchedBorder());
180: jRTextExpressionKey.setElectricScroll(0);
181: jRTextExpressionKey.setMinimumSize(new java.awt.Dimension(10,
182: 10));
183: jRTextExpressionKey.setPreferredSize(new java.awt.Dimension(10,
184: 10));
185: gridBagConstraints = new java.awt.GridBagConstraints();
186: gridBagConstraints.gridx = 0;
187: gridBagConstraints.gridy = 1;
188: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
189: gridBagConstraints.weightx = 1.0;
190: gridBagConstraints.weighty = 1.0;
191: jPanel1.add(jRTextExpressionKey, gridBagConstraints);
192:
193: jLabelValueExpression.setText("Value expression");
194: gridBagConstraints = new java.awt.GridBagConstraints();
195: gridBagConstraints.gridx = 0;
196: gridBagConstraints.gridy = 2;
197: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
198: gridBagConstraints.weightx = 1.0;
199: gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
200: jPanel1.add(jLabelValueExpression, gridBagConstraints);
201:
202: jRTextExpressionValue.setBorder(javax.swing.BorderFactory
203: .createEtchedBorder());
204: jRTextExpressionValue.setElectricScroll(0);
205: jRTextExpressionValue.setMinimumSize(new java.awt.Dimension(10,
206: 10));
207: jRTextExpressionValue.setPreferredSize(new java.awt.Dimension(
208: 10, 10));
209: gridBagConstraints = new java.awt.GridBagConstraints();
210: gridBagConstraints.gridx = 0;
211: gridBagConstraints.gridy = 3;
212: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
213: gridBagConstraints.weightx = 1.0;
214: gridBagConstraints.weighty = 1.0;
215: jPanel1.add(jRTextExpressionValue, gridBagConstraints);
216:
217: jLabelLabelExpression.setText("Label expression");
218: gridBagConstraints = new java.awt.GridBagConstraints();
219: gridBagConstraints.gridx = 0;
220: gridBagConstraints.gridy = 4;
221: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
222: gridBagConstraints.weightx = 1.0;
223: gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0);
224: jPanel1.add(jLabelLabelExpression, gridBagConstraints);
225:
226: jRTextExpressionLabel.setBorder(javax.swing.BorderFactory
227: .createEtchedBorder());
228: jRTextExpressionLabel.setElectricScroll(0);
229: jRTextExpressionLabel.setMinimumSize(new java.awt.Dimension(10,
230: 10));
231: jRTextExpressionLabel.setPreferredSize(new java.awt.Dimension(
232: 10, 10));
233: gridBagConstraints = new java.awt.GridBagConstraints();
234: gridBagConstraints.gridx = 0;
235: gridBagConstraints.gridy = 5;
236: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
237: gridBagConstraints.weightx = 1.0;
238: gridBagConstraints.weighty = 1.0;
239: jPanel1.add(jRTextExpressionLabel, gridBagConstraints);
240:
241: jTabbedPane1.addTab("Section value", jPanel1);
242:
243: jPanel2.setLayout(new java.awt.GridBagLayout());
244:
245: gridBagConstraints = new java.awt.GridBagConstraints();
246: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
247: gridBagConstraints.weightx = 1.0;
248: gridBagConstraints.weighty = 1.0;
249: jPanel2.add(sectionItemHyperlinkPanel1, gridBagConstraints);
250:
251: jTabbedPane1.addTab("Section hyperlink", jPanel2);
252:
253: gridBagConstraints = new java.awt.GridBagConstraints();
254: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
255: gridBagConstraints.weightx = 1.0;
256: gridBagConstraints.weighty = 1.0;
257: add(jTabbedPane1, gridBagConstraints);
258:
259: }// </editor-fold>//GEN-END:initComponents
260:
261: // Variables declaration - do not modify//GEN-BEGIN:variables
262: private javax.swing.JLabel jLabelKeyExpression;
263: private javax.swing.JLabel jLabelLabelExpression;
264: private javax.swing.JLabel jLabelValueExpression;
265: private javax.swing.JPanel jPanel1;
266: private javax.swing.JPanel jPanel2;
267: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionKey;
268: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionLabel;
269: private it.businesslogic.ireport.gui.JRTextExpressionArea jRTextExpressionValue;
270: private javax.swing.JTabbedPane jTabbedPane1;
271: private it.businesslogic.ireport.chart.gui.SectionItemHyperlinkPanel sectionItemHyperlinkPanel1;
272:
273: // End of variables declaration//GEN-END:variables
274:
275: public void applyI18n() {
276: // Start autogenerated code ----------------------
277: jLabelKeyExpression
278: .setText(I18n.getString(
279: "pieDatasetPanel.labelKeyExpression",
280: "Key expression"));
281: jLabelLabelExpression.setText(I18n.getString(
282: "pieDatasetPanel.labelLabelExpression",
283: "Label expression"));
284: jLabelValueExpression.setText(I18n.getString(
285: "pieDatasetPanel.labelValueExpression",
286: "Value expression"));
287: // End autogenerated code ----------------------
288:
289: jTabbedPane1.setTitleAt(0, I18n.getString(
290: "chartSeries.tab.SectionValue", "Section value"));
291: jTabbedPane1.setTitleAt(1, I18n
292: .getString("chartSeries.tab.SectionHyperlink",
293: "Section hyperlink"));
294: }
295:
296: public static final int COMPONENT_NONE = 0;
297: public static final int COMPONENT_KEY_EXPRESSION = 1;
298: public static final int COMPONENT_VALUE_EXPRESSION = 2;
299: public static final int COMPONENT_LABEL_EXPRESSION = 3;
300: public static final int COMPONENT_HYPERLINK = 100;
301:
302: /**
303: * This method set the focus on a specific component.
304: * Valid constants are something like:
305: * COMPONENT_KEY_EXPRESSION, COMPONENT_VALUE_EXPRESSION, ...
306: * otherInfo is used here only for COMPONENT_HYPERLINK
307: * otherInfo[0] = expression ID
308: * otherInfo[1] = parameter #
309: * otherInfo[2] = parameter expression ID
310: */
311: public void setFocusedExpression(Object[] expressionInfo) {
312: int expID = ((Integer) expressionInfo[0]).intValue();
313: switch (expID) {
314: case COMPONENT_KEY_EXPRESSION:
315: Misc.selectTextAndFocusArea(jRTextExpressionKey);
316: break;
317: case COMPONENT_VALUE_EXPRESSION:
318: Misc.selectTextAndFocusArea(jRTextExpressionValue);
319: break;
320: case COMPONENT_LABEL_EXPRESSION:
321: Misc.selectTextAndFocusArea(jRTextExpressionLabel);
322: break;
323: case COMPONENT_HYPERLINK:
324: jTabbedPane1.setSelectedComponent(jPanel2);
325: Object newInfo[] = new Object[expressionInfo.length - 1];
326: for (int i = 1; i < expressionInfo.length; ++i)
327: newInfo[i - 1] = expressionInfo[i];
328: sectionItemHyperlinkPanel1.setFocusedExpression(newInfo);
329: break;
330: }
331: }
332:
333: public void containerWindowOpened() {
334: sectionItemHyperlinkPanel1.openExtraWindows();
335: }
336: }
|