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: * ProjectDialog.java
028: *
029: * Created on 4 giugno 2003, 1.34
030: *
031: */
032:
033: package it.businesslogic.ireport.gui;
034:
035: import it.businesslogic.ireport.util.*;
036:
037: /**
038: *
039: * @author Administrator
040: */
041: public class ProjectDialog extends javax.swing.JDialog {
042:
043: /** Creates new form ProjectDialog */
044: public ProjectDialog(java.awt.Frame parent, boolean modal) {
045: super (parent, modal);
046: initComponents();
047: this .setSize(400, 260);
048: applyI18n();
049: Misc.centerFrame(this );
050: }
051:
052: /** This method is called from within the constructor to
053: * initialize the form.
054: * WARNING: Do NOT modify this code. The content of this method is
055: * always regenerated by the Form Editor.
056: */
057: private void initComponents() {//GEN-BEGIN:initComponents
058: java.awt.GridBagConstraints gridBagConstraints;
059:
060: jPanel1 = new javax.swing.JPanel();
061: jButtonSave = new javax.swing.JButton();
062: jButtonCancel = new javax.swing.JButton();
063: jPanel2 = new javax.swing.JPanel();
064: jComboBoxConnection = new javax.swing.JComboBox();
065: jLabel4 = new javax.swing.JLabel();
066: jTextFieldOutputDir = new javax.swing.JTextField();
067: jButton2 = new javax.swing.JButton();
068: jLabel3 = new javax.swing.JLabel();
069: jTextFieldSourcesDir = new javax.swing.JTextField();
070: jButton1 = new javax.swing.JButton();
071: jLabel2 = new javax.swing.JLabel();
072: jTextFieldProjectName = new javax.swing.JTextField();
073: jLabel1 = new javax.swing.JLabel();
074:
075: addWindowListener(new java.awt.event.WindowAdapter() {
076: public void windowClosing(java.awt.event.WindowEvent evt) {
077: closeDialog(evt);
078: }
079: });
080:
081: jPanel1.setLayout(new java.awt.FlowLayout(
082: java.awt.FlowLayout.RIGHT));
083:
084: jButtonSave.setText("Save");
085: jButtonSave.setMnemonic('s');
086: jButtonSave
087: .addActionListener(new java.awt.event.ActionListener() {
088: public void actionPerformed(
089: java.awt.event.ActionEvent evt) {
090: jButtonSaveActionPerformed(evt);
091: }
092: });
093:
094: jPanel1.add(jButtonSave);
095:
096: jButtonCancel.setText("Cancel");
097: jButtonCancel.setMnemonic('c');
098: jButtonCancel
099: .addActionListener(new java.awt.event.ActionListener() {
100: public void actionPerformed(
101: java.awt.event.ActionEvent evt) {
102: jButtonCancelActionPerformed(evt);
103: }
104: });
105:
106: jPanel1.add(jButtonCancel);
107:
108: getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
109:
110: jPanel2.setLayout(new java.awt.GridBagLayout());
111:
112: gridBagConstraints = new java.awt.GridBagConstraints();
113: gridBagConstraints.gridx = 0;
114: gridBagConstraints.gridy = 7;
115: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
116: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
117: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
118: gridBagConstraints.weightx = 1.0;
119: gridBagConstraints.weighty = 1.0;
120: jPanel2.add(jComboBoxConnection, gridBagConstraints);
121:
122: jLabel4.setText("Default connection");
123: gridBagConstraints = new java.awt.GridBagConstraints();
124: gridBagConstraints.gridx = 0;
125: gridBagConstraints.gridy = 6;
126: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
127: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
128: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
129: jPanel2.add(jLabel4, gridBagConstraints);
130:
131: gridBagConstraints = new java.awt.GridBagConstraints();
132: gridBagConstraints.gridx = 0;
133: gridBagConstraints.gridy = 1;
134: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
136: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137: jPanel2.add(jTextFieldOutputDir, gridBagConstraints);
138:
139: jButton2.setText("Browse");
140: gridBagConstraints = new java.awt.GridBagConstraints();
141: gridBagConstraints.gridx = 1;
142: gridBagConstraints.gridy = 5;
143: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
144: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145: jPanel2.add(jButton2, gridBagConstraints);
146:
147: jLabel3.setText("Output directory");
148: gridBagConstraints = new java.awt.GridBagConstraints();
149: gridBagConstraints.gridx = 0;
150: gridBagConstraints.gridy = 4;
151: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
153: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
154: jPanel2.add(jLabel3, gridBagConstraints);
155:
156: gridBagConstraints = new java.awt.GridBagConstraints();
157: gridBagConstraints.gridx = 0;
158: gridBagConstraints.gridy = 3;
159: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
160: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
161: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162: jPanel2.add(jTextFieldSourcesDir, gridBagConstraints);
163:
164: jButton1.setText("Browse");
165: gridBagConstraints = new java.awt.GridBagConstraints();
166: gridBagConstraints.gridx = 1;
167: gridBagConstraints.gridy = 3;
168: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
169: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
170: jPanel2.add(jButton1, gridBagConstraints);
171:
172: jLabel2.setText("Sources directory");
173: gridBagConstraints = new java.awt.GridBagConstraints();
174: gridBagConstraints.gridx = 0;
175: gridBagConstraints.gridy = 2;
176: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
177: gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 3);
178: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
179: jPanel2.add(jLabel2, gridBagConstraints);
180:
181: gridBagConstraints = new java.awt.GridBagConstraints();
182: gridBagConstraints.gridx = 0;
183: gridBagConstraints.gridy = 5;
184: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
185: gridBagConstraints.insets = new java.awt.Insets(0, 3, 5, 3);
186: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
187: jPanel2.add(jTextFieldProjectName, gridBagConstraints);
188:
189: jLabel1.setText("Project name");
190: gridBagConstraints = new java.awt.GridBagConstraints();
191: gridBagConstraints.gridx = 0;
192: gridBagConstraints.gridy = 0;
193: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
194: gridBagConstraints.insets = new java.awt.Insets(3, 3, 0, 3);
195: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
196: jPanel2.add(jLabel1, gridBagConstraints);
197:
198: getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
199:
200: java.awt.Dimension screenSize = java.awt.Toolkit
201: .getDefaultToolkit().getScreenSize();
202: setBounds((screenSize.width - 390) / 2,
203: (screenSize.height - 260) / 2, 390, 260);
204: }//GEN-END:initComponents
205:
206: private void jButtonCancelActionPerformed(
207: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
208:
209: this .setDialogResult(javax.swing.JOptionPane.CANCEL_OPTION);
210: setVisible(false);
211: dispose();
212: }//GEN-LAST:event_jButtonCancelActionPerformed
213:
214: private void jButtonSaveActionPerformed(
215: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSaveActionPerformed
216:
217: /* TODO: Check user inputs */
218: this .setProjectName(this .jTextFieldProjectName.getText());
219: this .setSourcesDir(this .jTextFieldSourcesDir.getText());
220: this .setOutputDir(this .jTextFieldOutputDir.getText());
221: this .setConnection(this .jComboBoxConnection.getSelectedItem()
222: + "");
223: this .setDialogResult(javax.swing.JOptionPane.OK_OPTION);
224: setVisible(false);
225: dispose();
226: }//GEN-LAST:event_jButtonSaveActionPerformed
227:
228: /** Closes the dialog */
229: private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
230: this .setDialogResult(javax.swing.JOptionPane.CLOSED_OPTION);
231: setVisible(false);
232: dispose();
233: }//GEN-LAST:event_closeDialog
234:
235: /**
236: * @param args the command line arguments
237: */
238: public static void main(String args[]) {
239: new ProjectDialog(new javax.swing.JFrame(), true)
240: .setVisible(true);
241: }
242:
243: /** Getter for property connection.
244: * @return Value of property connection.
245: *
246: */
247: public java.lang.String getConnection() {
248: return connection;
249: }
250:
251: /** Setter for property connection.
252: * @param connection New value of property connection.
253: *
254: */
255: public void setConnection(java.lang.String connection) {
256: this .connection = connection;
257: }
258:
259: /** Getter for property dialogResult.
260: * @return Value of property dialogResult.
261: *
262: */
263: public int getDialogResult() {
264: return dialogResult;
265: }
266:
267: /** Setter for property dialogResult.
268: * @param dialogResult New value of property dialogResult.
269: *
270: */
271: public void setDialogResult(int dialogResult) {
272: this .dialogResult = dialogResult;
273: }
274:
275: /** Getter for property outputDir.
276: * @return Value of property outputDir.
277: *
278: */
279: public java.lang.String getOutputDir() {
280: return outputDir;
281: }
282:
283: /** Setter for property outputDir.
284: * @param outputDir New value of property outputDir.
285: *
286: */
287: public void setOutputDir(java.lang.String outputDir) {
288: this .outputDir = outputDir;
289: }
290:
291: /** Getter for property projectName.
292: * @return Value of property projectName.
293: *
294: */
295: public java.lang.String getProjectName() {
296: return projectName;
297: }
298:
299: /** Setter for property projectName.
300: * @param projectName New value of property projectName.
301: *
302: */
303: public void setProjectName(java.lang.String projectName) {
304: this .projectName = projectName;
305: }
306:
307: /** Getter for property sourcesDir.
308: * @return Value of property sourcesDir.
309: *
310: */
311: public java.lang.String getSourcesDir() {
312: return sourcesDir;
313: }
314:
315: /** Setter for property sourcesDir.
316: * @param sourcesDir New value of property sourcesDir.
317: *
318: */
319: public void setSourcesDir(java.lang.String sourcesDir) {
320: this .sourcesDir = sourcesDir;
321: }
322:
323: // Variables declaration - do not modify//GEN-BEGIN:variables
324: private javax.swing.JButton jButton1;
325: private javax.swing.JButton jButton2;
326: private javax.swing.JButton jButtonCancel;
327: private javax.swing.JButton jButtonSave;
328: private javax.swing.JComboBox jComboBoxConnection;
329: private javax.swing.JLabel jLabel1;
330: private javax.swing.JLabel jLabel2;
331: private javax.swing.JLabel jLabel3;
332: private javax.swing.JLabel jLabel4;
333: private javax.swing.JPanel jPanel1;
334: private javax.swing.JPanel jPanel2;
335: private javax.swing.JTextField jTextFieldOutputDir;
336: private javax.swing.JTextField jTextFieldProjectName;
337: private javax.swing.JTextField jTextFieldSourcesDir;
338: // End of variables declaration//GEN-END:variables
339:
340: private int dialogResult;
341:
342: private String projectName;
343:
344: private String sourcesDir;
345:
346: private String outputDir;
347:
348: private String connection;
349:
350: public void applyI18n() {
351: // Start autogenerated code ----------------------
352: jButton1.setText(I18n.getString("projectDialog.button1",
353: "Browse"));
354: jButton2.setText(I18n.getString("projectDialog.button2",
355: "Browse"));
356: jButtonCancel.setText(I18n.getString(
357: "projectDialog.buttonCancel", "Cancel"));
358: jButtonSave.setText(I18n.getString("projectDialog.buttonSave",
359: "Save"));
360: jLabel1.setText(I18n.getString("projectDialog.label1",
361: "Project name"));
362: jLabel2.setText(I18n.getString("projectDialog.label2",
363: "Sources directory"));
364: jLabel3.setText(I18n.getString("projectDialog.label3",
365: "Output directory"));
366: jLabel4.setText(I18n.getString("projectDialog.label4",
367: "Default connection"));
368: // End autogenerated code ----------------------
369: jButtonCancel.setMnemonic(I18n.getString(
370: "projectDialog.buttonCancelMnemonic", "c").charAt(0));
371: jButtonSave.setMnemonic(I18n.getString(
372: "projectDialog.buttonSaveMnemonic", "s").charAt(0));
373: }
374: }
|