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: * ImportDialog.java
028: *
029: * Created on 12 novembre 2004, 0.06
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.style;
034:
035: import it.businesslogic.ireport.gui.*;
036: import it.businesslogic.ireport.util.I18n;
037:
038: /**
039: *
040: * @author Administrator
041: */
042: public class TemplateDataDialog extends javax.swing.JDialog {
043:
044: private String template;
045: private int dialogResult = javax.swing.JOptionPane.CANCEL_OPTION;
046:
047: /** Creates new form ImportDialog */
048: public TemplateDataDialog(java.awt.Frame parent, boolean modal) {
049: super (parent, modal);
050: initComponents();
051: initFrame();
052: }
053:
054: public void initFrame() {
055: this .setSize(400, 100);
056: applyI18n();
057: it.businesslogic.ireport.util.Misc.centerFrame(this );
058:
059: javax.swing.KeyStroke escape = javax.swing.KeyStroke
060: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
061: false);
062: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
063: public void actionPerformed(java.awt.event.ActionEvent e) {
064: jButtonCancelActionPerformed(e);
065: }
066: };
067:
068: getRootPane().getInputMap(
069: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
070: escape, "ESCAPE");
071: getRootPane().getActionMap().put("ESCAPE", escapeAction);
072:
073: //to make the default button ...
074: this .getRootPane().setDefaultButton(this .jButtonOK);
075: }
076:
077: /** This method is called from within the constructor to
078: * initialize the form.
079: * WARNING: Do NOT modify this code. The content of this method is
080: * always regenerated by the Form Editor.
081: */
082: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
083: private void initComponents() {
084: java.awt.GridBagConstraints gridBagConstraints;
085:
086: jLabel1 = new javax.swing.JLabel();
087: jTextField1 = new javax.swing.JTextField();
088: jPanel1 = new javax.swing.JPanel();
089: jPanel2 = new javax.swing.JPanel();
090: jButtonOK = new javax.swing.JButton();
091: jButtonCancel = new javax.swing.JButton();
092:
093: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
094: setTitle("Import");
095: setModal(true);
096: setResizable(false);
097: getContentPane().setLayout(new java.awt.GridBagLayout());
098:
099: jLabel1.setText("Template");
100: gridBagConstraints = new java.awt.GridBagConstraints();
101: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
102: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
103: getContentPane().add(jLabel1, gridBagConstraints);
104: gridBagConstraints = new java.awt.GridBagConstraints();
105: gridBagConstraints.gridx = 0;
106: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
107: gridBagConstraints.weightx = 1.0;
108: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
109: getContentPane().add(jTextField1, gridBagConstraints);
110:
111: jPanel1.setLayout(new java.awt.GridBagLayout());
112: gridBagConstraints = new java.awt.GridBagConstraints();
113: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114: gridBagConstraints.weightx = 1.0;
115: jPanel1.add(jPanel2, gridBagConstraints);
116:
117: jButtonOK.setText("Ok");
118: jButtonOK
119: .addActionListener(new java.awt.event.ActionListener() {
120: public void actionPerformed(
121: java.awt.event.ActionEvent evt) {
122: jButtonOKActionPerformed(evt);
123: }
124: });
125: gridBagConstraints = new java.awt.GridBagConstraints();
126: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
127: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
128: jPanel1.add(jButtonOK, gridBagConstraints);
129:
130: jButtonCancel.setText("Cancel");
131: jButtonCancel
132: .addActionListener(new java.awt.event.ActionListener() {
133: public void actionPerformed(
134: java.awt.event.ActionEvent evt) {
135: jButtonCancelActionPerformed(evt);
136: }
137: });
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
140: jPanel1.add(jButtonCancel, gridBagConstraints);
141:
142: gridBagConstraints = new java.awt.GridBagConstraints();
143: gridBagConstraints.gridx = 0;
144: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
145: gridBagConstraints.weightx = 1.0;
146: gridBagConstraints.weighty = 1.0;
147: getContentPane().add(jPanel1, gridBagConstraints);
148:
149: pack();
150: }// </editor-fold>//GEN-END:initComponents
151:
152: private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
153: if (jTextField1.getText().trim().length() == 0) {
154: javax.swing.JOptionPane
155: .showMessageDialog(
156: null,
157: I18n
158: .getString(
159: "messages.templateDataDialog.notValidTemplate",
160: "Please insert a valid template name"));
161: return;
162: }
163:
164: this .setTemplate(jTextField1.getText().trim());
165: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
166: this .setVisible(false);
167: }//GEN-LAST:event_jButtonOKActionPerformed
168:
169: private void jButtonCancelActionPerformed(
170: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
171: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
172: this .setVisible(false);
173:
174: }//GEN-LAST:event_jButtonCancelActionPerformed
175:
176: public String getTemplate() {
177: return template;
178: }
179:
180: public void setTemplate(String template) {
181: this .template = template;
182: jTextField1.setText(template);
183: }
184:
185: public int getDialogResult() {
186: return dialogResult;
187: }
188:
189: public void setDialogResult(int dialogResult) {
190: this .dialogResult = dialogResult;
191: }
192:
193: // Variables declaration - do not modify//GEN-BEGIN:variables
194: private javax.swing.JButton jButtonCancel;
195: private javax.swing.JButton jButtonOK;
196: private javax.swing.JLabel jLabel1;
197: private javax.swing.JPanel jPanel1;
198: private javax.swing.JPanel jPanel2;
199: private javax.swing.JTextField jTextField1;
200:
201: // End of variables declaration//GEN-END:variables
202:
203: public void applyI18n() {
204: // Start autogenerated code ----------------------
205: jButtonCancel.setText(I18n.getString(
206: "templateDataDialog.buttonCancel", "Cancel"));
207: jButtonOK.setText(I18n.getString("templateDataDialog.buttonOK",
208: "Ok"));
209: jLabel1.setText(I18n.getString("templateDataDialog.label1",
210: "Template"));
211: // End autogenerated code ----------------------
212:
213: this .setTitle(I18n.getString("templateDataDialog.title",
214: "Template"));
215: jButtonCancel.setMnemonic(I18n.getString(
216: "templateDataDialog.buttonCancelMnemonic", "c").charAt(
217: 0));
218: jButtonOK.setMnemonic(I18n.getString(
219: "templateDataDialog.buttonOKMnemonic", "o").charAt(0));
220:
221: }
222: }
|