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: * TranslationOptionsDialog.java
028: *
029: * Created on 22 maggio 2005, 0.39
030: *
031: */
032:
033: package it.businesslogic.ireport.plugin.locale;
034:
035: import it.businesslogic.ireport.util.I18n;
036: import javax.swing.border.TitledBorder;
037:
038: /**
039: *
040: * @author Administrator
041: */
042: public class TranslationOptionsDialog extends javax.swing.JDialog {
043:
044: /**
045: * Creates new form TranslationOptionsDialog
046: */
047: public TranslationOptionsDialog(java.awt.Frame parent, boolean modal) {
048: super (parent, modal);
049: initComponents();
050: applyI18n();
051:
052: this .jTextField1.setText(it.businesslogic.ireport.gui.MainFrame
053: .getMainInstance().getProperties().getProperty(
054: "jasperBabylonURL",
055: "http://www.jasperforge.org/jasperbabylon"));
056: this .jTextField2.setText(it.businesslogic.ireport.gui.MainFrame
057: .getMainInstance().getProperties().getProperty(
058: "jasperBabylonUsername", ""));
059: this .jPasswordField1
060: .setText(it.businesslogic.ireport.gui.MainFrame
061: .getMainInstance().getProperties().getProperty(
062: "jasperBabylonPassword", ""));
063:
064: it.businesslogic.ireport.util.Misc.centerFrame(this );
065:
066: javax.swing.KeyStroke escape = javax.swing.KeyStroke
067: .getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0,
068: false);
069: javax.swing.Action escapeAction = new javax.swing.AbstractAction() {
070: public void actionPerformed(java.awt.event.ActionEvent e) {
071: jButton2ActionPerformed(e);
072: }
073: };
074:
075: getRootPane().getInputMap(
076: javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(
077: escape, "ESCAPE");
078: getRootPane().getActionMap().put("ESCAPE", escapeAction);
079:
080: //to make the default button ...
081: this .getRootPane().setDefaultButton(this .jButton1);
082: }
083:
084: /** This method is called from within the constructor to
085: * initialize the form.
086: * WARNING: Do NOT modify this code. The content of this method is
087: * always regenerated by the Form Editor.
088: */
089: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
090: private void initComponents() {
091: java.awt.GridBagConstraints gridBagConstraints;
092:
093: jLabelJasperBabylon = new javax.swing.JLabel();
094: jTextField1 = new javax.swing.JTextField();
095: jPanel3 = new javax.swing.JPanel();
096: jLabelUsername = new javax.swing.JLabel();
097: jTextField2 = new javax.swing.JTextField();
098: jLabelPassword = new javax.swing.JLabel();
099: jPasswordField1 = new javax.swing.JPasswordField();
100: jSeparator1 = new javax.swing.JSeparator();
101: jPanel1 = new javax.swing.JPanel();
102: jPanel2 = new javax.swing.JPanel();
103: jButton1 = new javax.swing.JButton();
104: jButton2 = new javax.swing.JButton();
105:
106: getContentPane().setLayout(new java.awt.GridBagLayout());
107:
108: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
109: addWindowListener(new java.awt.event.WindowAdapter() {
110: public void windowOpened(java.awt.event.WindowEvent evt) {
111: formWindowOpened(evt);
112: }
113: });
114:
115: jLabelJasperBabylon.setText("JasperBabylon URL");
116: gridBagConstraints = new java.awt.GridBagConstraints();
117: gridBagConstraints.gridx = 0;
118: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
119: gridBagConstraints.weightx = 1.0;
120: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
121: getContentPane().add(jLabelJasperBabylon, gridBagConstraints);
122:
123: jTextField1.setMinimumSize(new java.awt.Dimension(300, 19));
124: jTextField1.setPreferredSize(new java.awt.Dimension(300, 19));
125: gridBagConstraints = new java.awt.GridBagConstraints();
126: gridBagConstraints.gridx = 0;
127: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
128: gridBagConstraints.weightx = 1.0;
129: gridBagConstraints.insets = new java.awt.Insets(0, 4, 8, 4);
130: getContentPane().add(jTextField1, gridBagConstraints);
131:
132: jPanel3.setLayout(new java.awt.GridBagLayout());
133:
134: jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
135: javax.swing.BorderFactory.createEtchedBorder(),
136: "Contributor account"));
137: jLabelUsername.setText("Username");
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.gridx = 0;
140: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
141: gridBagConstraints.weightx = 1.0;
142: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
143: jPanel3.add(jLabelUsername, gridBagConstraints);
144:
145: jTextField2.setMinimumSize(new java.awt.Dimension(300, 19));
146: jTextField2.setPreferredSize(new java.awt.Dimension(300, 19));
147: gridBagConstraints = new java.awt.GridBagConstraints();
148: gridBagConstraints.gridx = 0;
149: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
150: gridBagConstraints.weightx = 1.0;
151: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
152: jPanel3.add(jTextField2, gridBagConstraints);
153:
154: jLabelPassword.setText("Password");
155: gridBagConstraints = new java.awt.GridBagConstraints();
156: gridBagConstraints.gridx = 0;
157: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
158: gridBagConstraints.weightx = 1.0;
159: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
160: jPanel3.add(jLabelPassword, gridBagConstraints);
161:
162: jPasswordField1.setText("jPasswordField1");
163: gridBagConstraints = new java.awt.GridBagConstraints();
164: gridBagConstraints.gridx = 0;
165: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
166: gridBagConstraints.insets = new java.awt.Insets(0, 4, 8, 4);
167: jPanel3.add(jPasswordField1, gridBagConstraints);
168:
169: gridBagConstraints = new java.awt.GridBagConstraints();
170: gridBagConstraints.gridx = 0;
171: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172: gridBagConstraints.weightx = 1.0;
173: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
174: getContentPane().add(jPanel3, gridBagConstraints);
175:
176: jSeparator1.setMinimumSize(new java.awt.Dimension(0, 4));
177: jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4));
178: gridBagConstraints = new java.awt.GridBagConstraints();
179: gridBagConstraints.gridx = 0;
180: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
182: gridBagConstraints.weightx = 1.0;
183: gridBagConstraints.weighty = 1.0;
184: gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
185: getContentPane().add(jSeparator1, gridBagConstraints);
186:
187: jPanel1.setLayout(new java.awt.GridBagLayout());
188:
189: gridBagConstraints = new java.awt.GridBagConstraints();
190: gridBagConstraints.weightx = 1.0;
191: jPanel1.add(jPanel2, gridBagConstraints);
192:
193: jButton1.setText("Save");
194: jButton1.addActionListener(new java.awt.event.ActionListener() {
195: public void actionPerformed(java.awt.event.ActionEvent evt) {
196: jButton1ActionPerformed(evt);
197: }
198: });
199:
200: gridBagConstraints = new java.awt.GridBagConstraints();
201: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 4);
202: jPanel1.add(jButton1, gridBagConstraints);
203:
204: jButton2.setText("Cancel");
205: jButton2.addActionListener(new java.awt.event.ActionListener() {
206: public void actionPerformed(java.awt.event.ActionEvent evt) {
207: jButton2ActionPerformed(evt);
208: }
209: });
210:
211: gridBagConstraints = new java.awt.GridBagConstraints();
212: gridBagConstraints.insets = new java.awt.Insets(4, 0, 4, 10);
213: jPanel1.add(jButton2, gridBagConstraints);
214:
215: gridBagConstraints = new java.awt.GridBagConstraints();
216: gridBagConstraints.gridx = 0;
217: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
218: gridBagConstraints.weightx = 1.0;
219: getContentPane().add(jPanel1, gridBagConstraints);
220:
221: pack();
222: }// </editor-fold>//GEN-END:initComponents
223:
224: private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
225: setVisible(false);
226: dispose();
227: }//GEN-LAST:event_jButton2ActionPerformed
228:
229: private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
230:
231: }//GEN-LAST:event_formWindowOpened
232:
233: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
234:
235: it.businesslogic.ireport.gui.MainFrame.getMainInstance()
236: .getProperties().setProperty("jasperBabylonURL",
237: "" + jTextField1.getText());
238: it.businesslogic.ireport.gui.MainFrame.getMainInstance()
239: .getProperties().setProperty("jasperBabylonUsername",
240: "" + jTextField2.getText());
241: it.businesslogic.ireport.gui.MainFrame.getMainInstance()
242: .getProperties().setProperty("jasperBabylonPassword",
243: new String(jPasswordField1.getPassword()));
244: it.businesslogic.ireport.gui.MainFrame.getMainInstance()
245: .saveiReportConfiguration();
246: setVisible(false);
247: dispose();
248:
249: }//GEN-LAST:event_jButton1ActionPerformed
250:
251: // Variables declaration - do not modify//GEN-BEGIN:variables
252: private javax.swing.JButton jButton1;
253: private javax.swing.JButton jButton2;
254: private javax.swing.JLabel jLabelJasperBabylon;
255: private javax.swing.JLabel jLabelPassword;
256: private javax.swing.JLabel jLabelUsername;
257: private javax.swing.JPanel jPanel1;
258: private javax.swing.JPanel jPanel2;
259: private javax.swing.JPanel jPanel3;
260: private javax.swing.JPasswordField jPasswordField1;
261: private javax.swing.JSeparator jSeparator1;
262: private javax.swing.JTextField jTextField1;
263: private javax.swing.JTextField jTextField2;
264:
265: // End of variables declaration//GEN-END:variables
266:
267: public void applyI18n() {
268: // Start autogenerated code ----------------------
269: jLabelJasperBabylon.setText(I18n.getString(
270: "translationStatusDialog.jasperBabylonURL",
271: "JasperBabylon URL"));
272: // End autogenerated code ----------------------
273: // Start autogenerated code ----------------------
274: jButton1.setText(I18n.getString(
275: "translationStatusDialog.buttonSave", "Save"));
276: jButton2.setText(I18n.getString(
277: "translationStatusDialog.buttonCancel", "Cancel"));
278: // End autogenerated code ----------------------
279:
280: jLabelUsername.setText(I18n.getString(
281: "translationOptionsDialog.labelUsername", "Username"));
282: jLabelPassword.setText(I18n.getString(
283: "translationOptionsDialog.labelPassword", "Password"));
284:
285: ((TitledBorder) jPanel3.getBorder()).setTitle(I18n.getString(
286: "translationOptionsDialog.labelContributorAccount",
287: "Contributor account"));
288: }
289: }
|