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: * ValuesDialog.java
028: *
029: * Created on 7 maggio 2003, 23.43
030: *
031: */
032:
033: package it.businesslogic.ireport.gui;
034:
035: import it.businesslogic.ireport.*;
036: import it.businesslogic.ireport.gui.event.*;
037: import it.businesslogic.ireport.util.*;
038:
039: import java.util.*;
040:
041: import javax.swing.*;
042: import javax.swing.event.*;
043: import javax.swing.table.*;
044:
045: /**
046: * @author Administrator
047: */
048: public class ValuesDialog extends javax.swing.JDialog implements
049: SubDatasetObjectChangedListener {
050:
051: private ValuesPanel valuesPanel = null;
052:
053: /**
054: * Creates new form ValuesDialog
055: * @param parent DOCUMENT ME!
056: * @param modal DOCUMENT ME!
057: */
058: public ValuesDialog(java.awt.Frame parent, boolean modal) {
059: super (parent, modal);
060: initComponents();
061: initAll();
062: }
063:
064: public ValuesDialog(java.awt.Dialog parent, boolean modal) {
065: super (parent, modal);
066: initComponents();
067: initAll();
068: }
069:
070: public void initAll() {
071: valuesPanel = new ValuesPanel();
072: this .getContentPane().add("Center", valuesPanel);
073:
074: applyI18n();
075:
076: I18n
077: .addOnLanguageChangedListener(new LanguageChangedListener() {
078: public void languageChanged(LanguageChangedEvent evt) {
079: applyI18n();
080: }
081: });
082:
083: this .setSize(500, 300);
084:
085: // Open in center...
086: it.businesslogic.ireport.util.Misc.centerFrame(this );
087:
088: javax.swing.KeyStroke escape = javax.swing.KeyStroke
089: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
090: false);
091: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
092: public void actionPerformed(java.awt.event.ActionEvent e) {
093: setVisible(false);
094: }
095: };
096:
097: getRootPane().getInputMap(
098: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
099: escape, "ESCAPE");
100: getRootPane().getActionMap().put("ESCAPE", escapeAction);
101:
102: }
103:
104: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
105: private void initComponents() {
106:
107: setTitle("Values");
108: addWindowListener(new java.awt.event.WindowAdapter() {
109: public void windowClosing(java.awt.event.WindowEvent evt) {
110: closeDialog(evt);
111: }
112: });
113:
114: pack();
115: }
116:
117: // </editor-fold>//GEN-END:initComponents
118:
119: /**
120: * Closes the dialog
121: * @param evt DOCUMENT ME!
122: */
123: private void closeDialog(java.awt.event.WindowEvent evt)//GEN-FIRST:event_closeDialog
124: {
125: setVisible(false);
126: }//GEN-LAST:event_closeDialog
127:
128: /**
129: * @param args the command line arguments
130: */
131: public static void main(String[] args) {
132: new ValuesDialog(new javax.swing.JFrame(), true)
133: .setVisible(true);
134: }
135:
136: /**
137: * Getter for property jReportFrame.
138: *
139: * @return Value of property jReportFrame.
140: */
141: public it.businesslogic.ireport.gui.JReportFrame getJReportFrame() {
142: return jReportFrame;
143: }
144:
145: /**
146: * Setter for property jReportFrame.
147: *
148: * @param jReportFrame New value of property jReportFrame.
149: */
150: public void setJReportFrame(
151: it.businesslogic.ireport.gui.JReportFrame jReportFrame) {
152: this .jReportFrame = jReportFrame;
153:
154: // Update all...
155: if (jReportFrame == null) {
156: setVisible(false);
157: } else if (isVisible()) {
158: this .setTitle(jReportFrame.getReport().getName()
159: + " values...");
160: this .getValuesPanel().setSubDataset(
161: getJReportFrame().getReport());
162: }
163: if (jReportFrame != null) {
164: this .getValuesPanel().setSubDataset(
165: getJReportFrame().getReport());
166: }
167: }
168:
169: /**
170: * DOCUMENT ME!
171: */
172: public void applyI18n() {
173: this .getValuesPanel().applyI18n();
174: }
175:
176: /**
177: * DOCUMENT ME!
178: *
179: * @param evt DOCUMENT ME!
180: */
181: public void languageChanged(LanguageChangedEvent evt) {
182: this .applyI18n();
183: }
184:
185: // Variables declaration - do not modify//GEN-BEGIN:variables
186: // End of variables declaration//GEN-END:variables
187: private JReportFrame jReportFrame;
188:
189: /**
190: * DOCUMENT ME!
191: *
192: * @param visible DOCUMENT ME!
193: */
194: public void setVisible(boolean visible) {
195:
196: if (visible == isVisible()) {
197:
198: return;
199: }
200:
201: super .setVisible(visible);
202:
203: if (visible == true) {
204: this .setJReportFrame(jReportFrame);
205: }
206: }
207:
208: /**
209: * DOCUMENT ME!
210: *
211: * @param p DOCUMENT ME!
212: */
213: public void modifyErrorParameter(
214: it.businesslogic.ireport.JRParameter p) {
215:
216: this .getValuesPanel().modifyErrorParameter(p);
217: }
218:
219: /**
220: * DOCUMENT ME!
221: *
222: * @param tab DOCUMENT ME!
223: */
224: public void gotoTab(String tab) {
225:
226: this .getValuesPanel().gotoTab(tab);
227: }
228:
229: /**
230: * DOCUMENT ME!
231: *
232: * @return DOCUMENT ME!
233: */
234: public Vector getClipboardFields() {
235: return getValuesPanel().getClipboardFields();
236: }
237:
238: /**
239: * DOCUMENT ME!
240: *
241: * @param clipboardFields DOCUMENT ME!
242: */
243: public void setClipboardFields(Vector clipboardFields) {
244: getValuesPanel().setClipboardFields(clipboardFields);
245: }
246:
247: /**
248: * DOCUMENT ME!
249: *
250: * @return DOCUMENT ME!
251: */
252: public Vector getClipboardVariables() {
253:
254: return getValuesPanel().getClipboardVariables();
255: }
256:
257: /**
258: * DOCUMENT ME!
259: *
260: * @param clipboardVariables DOCUMENT ME!
261: */
262: public void setClipboardVariables(Vector clipboardVariables) {
263: getValuesPanel().setClipboardVariables(clipboardVariables);
264: }
265:
266: /**
267: * DOCUMENT ME!
268: *
269: * @return DOCUMENT ME!
270: */
271: public Vector getClipboardParameters() {
272:
273: return getValuesPanel().getClipboardParameters();
274: }
275:
276: /**
277: * DOCUMENT ME!
278: *
279: * @param clipboardParameters DOCUMENT ME!
280: */
281: public void setClipboardParameters(Vector clipboardParameters) {
282: getValuesPanel().setClipboardParameters(clipboardParameters);
283: }
284:
285: /**
286: * DOCUMENT ME!
287: *
288: * @param evt DOCUMENT ME!
289: */
290: public void subDatasetObjectChanged(SubDatasetObjectChangedEvent evt) {
291: if (evt.getSource() == getValuesPanel().getSubDataset()) {
292: if (evt.getType() == evt.PARAMETER) {
293: getValuesPanel().updateParameters();
294: } else if (evt.getType() == evt.VARIABLE) {
295: getValuesPanel().updateVariables();
296: } else if (evt.getType() == evt.FIELD) {
297: getValuesPanel().updateFields();
298: }
299: }
300: }
301:
302: public ValuesPanel getValuesPanel() {
303: return valuesPanel;
304: }
305:
306: public void setValuesPanel(ValuesPanel valuesPanel) {
307: this.valuesPanel = valuesPanel;
308: }
309: }
|