KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > ToolbarConnectionPanel


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * ToolbarConnectionPanel.java
28  *
29  * Created on 7 mei 2005, 13:27
30  *
31  */

32
33 package it.businesslogic.ireport.gui;
34 //import it.businesslogic.ireport.gui.event.*;
35
//import it.businesslogic.ireport.undo.*;
36
//import it.businesslogic.ireport.util.*;
37
import javax.swing.JToolBar JavaDoc;
38
39
40
41 /**
42  *
43  * @Author: Robert Lamping
44  */

45 public class ToolbarConnectionPanel extends javax.swing.JPanel JavaDoc {
46     
47     private boolean updating = false;
48     private MainFrame mf = null; // MainFrame.getMainInstance();;
49
private StringBuffer JavaDoc outputBuffer;
50     
51     
52     /** Creates new form ToolbarFormatPanel */
53     // Pass the workspace to this toolbar
54
public ToolbarConnectionPanel(MainFrame mf ) {
55         this.mf = mf;
56         initComponents();
57     }
58     
59     public JToolBar JavaDoc getToolBar() {
60         // Make toolbar available to e.g. MainFrame
61
return jToolBarConnections;
62     }
63     
64     /** This method is called from within the constructor to
65      * initialize the form.
66      * WARNING: Do NOT modify this code. The content of this method is
67      * always regenerated by the Form Editor.
68      */

69     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
70
private void initComponents() {
71         jToolBarConnections = new javax.swing.JToolBar JavaDoc();
72         jComboBoxConnections = new javax.swing.JComboBox JavaDoc();
73
74         setLayout(new java.awt.BorderLayout JavaDoc());
75
76         setName("ToolbarConnectionPanel");
77         getAccessibleContext().setAccessibleName("ToolbarConnectionPanel");
78         jComboBoxConnections.setMaximumSize(new java.awt.Dimension JavaDoc(250, 32767));
79         jComboBoxConnections.addActionListener(new java.awt.event.ActionListener JavaDoc() {
80             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
81                 jComboBoxConnectionsActionPerformed(evt);
82             }
83         });
84
85         jToolBarConnections.add(jComboBoxConnections);
86         jComboBoxConnections.getAccessibleContext().setAccessibleName("ToolbarConnections");
87
88         add(jToolBarConnections, java.awt.BorderLayout.NORTH);
89         jToolBarConnections.getAccessibleContext().setAccessibleName("ToolbarConnections");
90
91     }// </editor-fold>//GEN-END:initComponents
92

93     private void jComboBoxConnectionsActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jComboBoxConnectionsActionPerformed
94

95         if (!updating && jComboBoxConnections.getSelectedItem() != null)
96         {
97             this.getMainFrame().getProperties().put("DefaultConnection",jComboBoxConnections.getSelectedItem());
98             this.getMainFrame().saveiReportConfiguration();
99         }
100     }//GEN-LAST:event_jComboBoxConnectionsActionPerformed
101

102     
103     // Variables declaration - do not modify//GEN-BEGIN:variables
104
private javax.swing.JComboBox JavaDoc jComboBoxConnections;
105     private javax.swing.JToolBar JavaDoc jToolBarConnections;
106     // End of variables declaration//GEN-END:variables
107

108     public javax.swing.JComboBox JavaDoc getJComboBoxConnextions()
109     {
110         return jComboBoxConnections;
111     }
112     
113     public synchronized void updateConnections()
114     {
115         this.updating = true;
116         
117         try {
118             it.businesslogic.ireport.util.Misc.updateComboBox(jComboBoxConnections,getMainFrame().getConnections());
119             if (getMainFrame().getProperties().get("DefaultConnection") != null )
120                 jComboBoxConnections.setSelectedItem( getMainFrame().getProperties().get("DefaultConnection"));
121         } catch (Exception JavaDoc ex)
122         {
123             ex.printStackTrace();
124         }
125         this.updating = false;
126     }
127     
128     private MainFrame getMainFrame() {
129         return mf;
130     }
131     
132     
133     
134     
135 }
136
Popular Tags