001: /*
002: * EJBQLConnectionEditor.java
003: *
004: * Created on March 27, 2007, 1:18 PM
005: */
006:
007: package it.businesslogic.ireport.connection.gui;
008:
009: import it.businesslogic.ireport.IReportConnection;
010: import it.businesslogic.ireport.IReportConnectionEditor;
011: import it.businesslogic.ireport.connection.JavaBeanDataSourceConnection;
012: import it.businesslogic.ireport.util.I18n;
013:
014: /**
015: *
016: * @author gtoffoli
017: */
018: public class JavaBeanDataSourceConnectionEditor extends
019: javax.swing.JPanel implements IReportConnectionEditor {
020:
021: private IReportConnection iReportConnection = null;
022: private boolean init = false;
023:
024: /** Creates new form EJBQLConnectionEditor */
025: public JavaBeanDataSourceConnectionEditor() {
026: initComponents();
027: applyI18n();
028: }
029:
030: /** This method is called from within the constructor to
031: * initialize the form.
032: * WARNING: Do NOT modify this code. The content of this method is
033: * always regenerated by the Form Editor.
034: */
035: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
036: private void initComponents() {
037: java.awt.GridBagConstraints gridBagConstraints;
038:
039: buttonGroup1 = new javax.swing.ButtonGroup();
040: jPanelBeansSet = new javax.swing.JPanel();
041: jLabel12 = new javax.swing.JLabel();
042: jTextFieldJBSetFactoryClass = new javax.swing.JTextField();
043: jRadioButtonJBSetCollection = new javax.swing.JRadioButton();
044: jRadioButtonJBSetArray = new javax.swing.JRadioButton();
045: jLabel13 = new javax.swing.JLabel();
046: jTextFieldJBSetMethodToCall = new javax.swing.JTextField();
047: jCheckBoxisUseFieldDescription = new javax.swing.JCheckBox();
048:
049: setLayout(new java.awt.BorderLayout());
050:
051: jPanelBeansSet.setLayout(new java.awt.GridBagLayout());
052:
053: jLabel12
054: .setText("Factory class (the class that will produce the set)");
055: gridBagConstraints = new java.awt.GridBagConstraints();
056: gridBagConstraints.gridx = 0;
057: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
058: gridBagConstraints.weightx = 1.0;
059: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
060: jPanelBeansSet.add(jLabel12, gridBagConstraints);
061:
062: jTextFieldJBSetFactoryClass
063: .setText("it.businesslogic.ireport.connection.SampleJRDataSourceFactory");
064: gridBagConstraints = new java.awt.GridBagConstraints();
065: gridBagConstraints.gridx = 0;
066: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
067: gridBagConstraints.weightx = 1.0;
068: gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);
069: jPanelBeansSet.add(jTextFieldJBSetFactoryClass,
070: gridBagConstraints);
071:
072: buttonGroup1.add(jRadioButtonJBSetCollection);
073: jRadioButtonJBSetCollection.setSelected(true);
074: jRadioButtonJBSetCollection.setText(" Collection of javaBeans");
075: gridBagConstraints = new java.awt.GridBagConstraints();
076: gridBagConstraints.gridx = 0;
077: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
078: gridBagConstraints.weightx = 1.0;
079: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
080: jPanelBeansSet.add(jRadioButtonJBSetCollection,
081: gridBagConstraints);
082:
083: buttonGroup1.add(jRadioButtonJBSetArray);
084: jRadioButtonJBSetArray.setText("Array of javaBeans");
085: jRadioButtonJBSetArray
086: .addActionListener(new java.awt.event.ActionListener() {
087: public void actionPerformed(
088: java.awt.event.ActionEvent evt) {
089: jRadioButtonJBSetArrayActionPerformed(evt);
090: }
091: });
092:
093: gridBagConstraints = new java.awt.GridBagConstraints();
094: gridBagConstraints.gridx = 0;
095: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
096: gridBagConstraints.weightx = 1.0;
097: gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 4);
098: jPanelBeansSet.add(jRadioButtonJBSetArray, gridBagConstraints);
099:
100: jLabel13
101: .setText("The static method to call to retrive the array or the the collection of javaBeans");
102: gridBagConstraints = new java.awt.GridBagConstraints();
103: gridBagConstraints.gridx = 0;
104: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
105: gridBagConstraints.weightx = 1.0;
106: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
107: jPanelBeansSet.add(jLabel13, gridBagConstraints);
108:
109: jTextFieldJBSetMethodToCall.setText("createBeanCollection");
110: gridBagConstraints = new java.awt.GridBagConstraints();
111: gridBagConstraints.gridx = 0;
112: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
113: gridBagConstraints.weightx = 1.0;
114: gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);
115: jPanelBeansSet.add(jTextFieldJBSetMethodToCall,
116: gridBagConstraints);
117:
118: jCheckBoxisUseFieldDescription.setText("Use field description");
119: jCheckBoxisUseFieldDescription
120: .setBorder(javax.swing.BorderFactory.createEmptyBorder(
121: 0, 0, 0, 0));
122: jCheckBoxisUseFieldDescription.setMargin(new java.awt.Insets(0,
123: 0, 0, 0));
124: gridBagConstraints = new java.awt.GridBagConstraints();
125: gridBagConstraints.gridx = 0;
126: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
127: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
128: gridBagConstraints.weightx = 1.0;
129: gridBagConstraints.weighty = 1.0;
130: gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
131: jPanelBeansSet.add(jCheckBoxisUseFieldDescription,
132: gridBagConstraints);
133:
134: add(jPanelBeansSet, java.awt.BorderLayout.CENTER);
135:
136: }// </editor-fold>//GEN-END:initComponents
137:
138: // Variables declaration - do not modify//GEN-BEGIN:variables
139: private javax.swing.ButtonGroup buttonGroup1;
140: private javax.swing.JCheckBox jCheckBoxisUseFieldDescription;
141: private javax.swing.JLabel jLabel12;
142: private javax.swing.JLabel jLabel13;
143: private javax.swing.JPanel jPanelBeansSet;
144: private javax.swing.JRadioButton jRadioButtonJBSetArray;
145: private javax.swing.JRadioButton jRadioButtonJBSetCollection;
146: private javax.swing.JTextField jTextFieldJBSetFactoryClass;
147: private javax.swing.JTextField jTextFieldJBSetMethodToCall;
148:
149: // End of variables declaration//GEN-END:variables
150:
151: public void setIReportConnection(IReportConnection c) {
152:
153: this .iReportConnection = c;
154: if (iReportConnection instanceof JavaBeanDataSourceConnection) {
155: JavaBeanDataSourceConnection con = (JavaBeanDataSourceConnection) iReportConnection;
156: this .jTextFieldJBSetFactoryClass.setText(con
157: .getFactoryClass());
158: this .jTextFieldJBSetMethodToCall.setText(con
159: .getMethodToCall());
160: this .jCheckBoxisUseFieldDescription.setSelected(con
161: .isUseFieldDescription());
162: if (con.getType().equals(con.BEAN_ARRAY)) {
163: jRadioButtonJBSetArray.setSelected(true);
164: jRadioButtonJBSetCollection.setSelected(false);
165: } else {
166: jRadioButtonJBSetArray.setSelected(false);
167: jRadioButtonJBSetCollection.setSelected(true);
168: }
169: }
170: }
171:
172: public IReportConnection getIReportConnection() {
173:
174: IReportConnection irConn = irConn = new JavaBeanDataSourceConnection();
175:
176: ((JavaBeanDataSourceConnection) irConn)
177: .setFactoryClass(this .jTextFieldJBSetFactoryClass
178: .getText().trim());
179: ((JavaBeanDataSourceConnection) irConn)
180: .setMethodToCall(this .jTextFieldJBSetMethodToCall
181: .getText().trim());
182: ((JavaBeanDataSourceConnection) irConn)
183: .setUseFieldDescription(this .jCheckBoxisUseFieldDescription
184: .isSelected());
185: if (jRadioButtonJBSetArray.isSelected()) {
186: ((JavaBeanDataSourceConnection) irConn)
187: .setType(JavaBeanDataSourceConnection.BEAN_ARRAY);
188: } else {
189: ((JavaBeanDataSourceConnection) irConn)
190: .setType(JavaBeanDataSourceConnection.BEAN_COLLECTION);
191: }
192:
193: iReportConnection = irConn;
194: return iReportConnection;
195: }
196:
197: private void jRadioButtonJBSetArrayActionPerformed(
198: java.awt.event.ActionEvent evt) {
199:
200: }
201:
202: public void applyI18n() {
203: jCheckBoxisUseFieldDescription.setText(I18n.getString(
204: "connectionDialog.checkBoxisUseFieldDescription",
205: "Use field description"));
206: jRadioButtonJBSetArray.setText(I18n.getString(
207: "connectionDialog.radioButtonJBSetArray",
208: "Array of javaBeans"));
209: jRadioButtonJBSetCollection.setText(I18n.getString(
210: "connectionDialog.radioButtonJBSetCollection",
211: " Collection of javaBeans"));
212:
213: jLabel12.setText(I18n.getString("connectionDialog.label12",
214: "Factory class (the class that will produce the set)"));
215: jLabel13
216: .setText("<html>"
217: + I18n
218: .getString(
219: "connectionDialog.label13",
220: "The static method to call to retrive the array or the the collection of javaBeans"));
221: }
222:
223: }
|