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