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.JRCustomDataSourceConnection;
012: import it.businesslogic.ireport.util.I18n;
013:
014: /**
015: *
016: * @author gtoffoli
017: */
018: public class JRCustomDataSourceConnectionEditor 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 JRCustomDataSourceConnectionEditor() {
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: jPanelCustomDataSourceFactory = new javax.swing.JPanel();
040: jLabel10 = new javax.swing.JLabel();
041: jTextFieldJRCustomDataSourceFactoryClass = new javax.swing.JTextField();
042: jLabel11 = new javax.swing.JLabel();
043: jTextFieldJRCustomDataSourceMethod = new javax.swing.JTextField();
044:
045: setLayout(new java.awt.BorderLayout());
046:
047: jPanelCustomDataSourceFactory
048: .setLayout(new java.awt.GridBagLayout());
049:
050: jLabel10.setText("Factory class");
051: gridBagConstraints = new java.awt.GridBagConstraints();
052: gridBagConstraints.gridx = 0;
053: gridBagConstraints.gridy = 0;
054: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
055: gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
056: jPanelCustomDataSourceFactory.add(jLabel10, gridBagConstraints);
057:
058: jTextFieldJRCustomDataSourceFactoryClass
059: .setText("it.businesslogic.ireport.connection.SampleJRDataSourceFactory");
060: gridBagConstraints = new java.awt.GridBagConstraints();
061: gridBagConstraints.gridx = 0;
062: gridBagConstraints.gridy = 1;
063: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
064: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
065: gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
066: jPanelCustomDataSourceFactory.add(
067: jTextFieldJRCustomDataSourceFactoryClass,
068: gridBagConstraints);
069:
070: jLabel11
071: .setText("The static method to call to retrive the JRDataSource");
072: gridBagConstraints = new java.awt.GridBagConstraints();
073: gridBagConstraints.gridx = 0;
074: gridBagConstraints.gridy = 2;
075: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
076: gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
077: jPanelCustomDataSourceFactory.add(jLabel11, gridBagConstraints);
078:
079: jTextFieldJRCustomDataSourceMethod.setText("createDatasource");
080: jTextFieldJRCustomDataSourceMethod
081: .setPreferredSize(new java.awt.Dimension(314, 21));
082: gridBagConstraints = new java.awt.GridBagConstraints();
083: gridBagConstraints.gridx = 0;
084: gridBagConstraints.gridy = 3;
085: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
086: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
087: gridBagConstraints.weightx = 1.0;
088: gridBagConstraints.weighty = 1.0;
089: gridBagConstraints.insets = new java.awt.Insets(3, 5, 3, 3);
090: jPanelCustomDataSourceFactory.add(
091: jTextFieldJRCustomDataSourceMethod, gridBagConstraints);
092:
093: add(jPanelCustomDataSourceFactory, java.awt.BorderLayout.CENTER);
094:
095: }// </editor-fold>//GEN-END:initComponents
096:
097: // Variables declaration - do not modify//GEN-BEGIN:variables
098: private javax.swing.JLabel jLabel10;
099: private javax.swing.JLabel jLabel11;
100: private javax.swing.JPanel jPanelCustomDataSourceFactory;
101: private javax.swing.JTextField jTextFieldJRCustomDataSourceFactoryClass;
102: private javax.swing.JTextField jTextFieldJRCustomDataSourceMethod;
103:
104: // End of variables declaration//GEN-END:variables
105:
106: public void setIReportConnection(IReportConnection c) {
107:
108: this .iReportConnection = c;
109: if (iReportConnection instanceof JRCustomDataSourceConnection) {
110: JRCustomDataSourceConnection con = (JRCustomDataSourceConnection) iReportConnection;
111: this .jTextFieldJRCustomDataSourceFactoryClass.setText(con
112: .getFactoryClass());
113: this .jTextFieldJRCustomDataSourceMethod.setText(con
114: .getMethodToCall());
115: }
116: }
117:
118: public IReportConnection getIReportConnection() {
119:
120: IReportConnection irConn = new JRCustomDataSourceConnection();
121: ((JRCustomDataSourceConnection) irConn)
122: .setFactoryClass(this .jTextFieldJRCustomDataSourceFactoryClass
123: .getText().trim());
124: ((JRCustomDataSourceConnection) irConn)
125: .setMethodToCall(this .jTextFieldJRCustomDataSourceMethod
126: .getText().trim());
127: iReportConnection = irConn;
128: return iReportConnection;
129: }
130:
131: public void applyI18n() {
132: // Start autogenerated code ----------------------
133: jLabel10.setText(I18n.getString("connectionDialog.label10",
134: "Factory class"));
135: jLabel11
136: .setText(I18n
137: .getString("connectionDialog.label11",
138: "The static method to call to retrive the JRDataSource"));
139:
140: }
141:
142: }
|