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: * FontSheetPropertyComponent.java
028: *
029: * Created on 15 agosto 2005, 13.32
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.sheet;
034:
035: import it.businesslogic.ireport.gui.MainFrame;
036: import it.businesslogic.ireport.gui.PropertiesDialog;
037: import it.businesslogic.ireport.util.I18n;
038: import it.businesslogic.ireport.util.LanguageChangedEvent;
039: import it.businesslogic.ireport.util.LanguageChangedListener;
040: import javax.swing.JOptionPane;
041:
042: /**
043: *
044: * @author Administrator
045: */
046: public class PropertiesSheetPropertyComponent extends
047: javax.swing.JPanel {
048:
049: private java.util.List propertiesList = null;
050:
051: public java.util.List getPropertiesList() {
052: return propertiesList;
053: }
054:
055: public void setPropertiesList(java.util.List propertiesList) {
056: this .propertiesList = propertiesList;
057: updateLabel();
058: }
059:
060: /** Creates new form ExpressionSheetPanel */
061: public PropertiesSheetPropertyComponent() {
062: initComponents();
063:
064: I18n
065: .addOnLanguageChangedListener(new LanguageChangedListener() {
066:
067: public void languageChanged(LanguageChangedEvent evt) {
068: applyI18n();
069: }
070: });
071:
072: applyI18n();
073: }
074:
075: public void listChanged() {
076: java.awt.event.ActionEvent event = new java.awt.event.ActionEvent(
077: this , 0, "");
078: fireActionListenerActionPerformed(event);
079: }
080:
081: /** This method is called from within the constructor to
082: * initialize the form.
083: * WARNING: Do NOT modify this code. The content of this method is
084: * always regenerated by the Form Editor.
085: */
086: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
087: private void initComponents() {
088: java.awt.GridBagConstraints gridBagConstraints;
089:
090: jLabelList = new javax.swing.JLabel();
091: jButton1 = new javax.swing.JButton();
092:
093: setBackground(new java.awt.Color(255, 255, 255));
094: setLayout(new java.awt.GridBagLayout());
095:
096: jLabelList.setBackground(new java.awt.Color(255, 255, 255));
097: jLabelList.setOpaque(true);
098: gridBagConstraints = new java.awt.GridBagConstraints();
099: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
100: gridBagConstraints.weightx = 1.0;
101: gridBagConstraints.weighty = 1.0;
102: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 0);
103: add(jLabelList, gridBagConstraints);
104:
105: jButton1.setText("...");
106: jButton1.setMaximumSize(new java.awt.Dimension(19, 10));
107: jButton1.setMinimumSize(new java.awt.Dimension(19, 10));
108: jButton1.setPreferredSize(new java.awt.Dimension(19, 10));
109: jButton1.addActionListener(new java.awt.event.ActionListener() {
110: public void actionPerformed(java.awt.event.ActionEvent evt) {
111: jButton1ActionPerformed(evt);
112: }
113: });
114: gridBagConstraints = new java.awt.GridBagConstraints();
115: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
116: gridBagConstraints.weighty = 1.0;
117: add(jButton1, gridBagConstraints);
118: }// </editor-fold>//GEN-END:initComponents
119:
120: private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
121:
122: PropertiesDialog pd = new PropertiesDialog(MainFrame
123: .getMainInstance(), true);
124: pd.setProperties(getPropertiesList());
125: pd.setVisible(true);
126:
127: if (pd.getDialogResult() == JOptionPane.OK_OPTION) {
128: this .setPropertiesList(pd.getProperties());
129: listChanged();
130: }
131:
132: }//GEN-LAST:event_jButton1ActionPerformed
133:
134: // Variables declaration - do not modify//GEN-BEGIN:variables
135: private javax.swing.JButton jButton1;
136: private javax.swing.JLabel jLabelList;
137: // End of variables declaration//GEN-END:variables
138:
139: /**
140: * Utility field used by event firing mechanism.
141: */
142: private javax.swing.event.EventListenerList listenerList = null;
143:
144: /**
145: * Registers ActionListener to receive events.
146: * @param listener The listener to register.
147: */
148: public synchronized void addActionListener(
149: java.awt.event.ActionListener listener) {
150:
151: if (listenerList == null) {
152: listenerList = new javax.swing.event.EventListenerList();
153: }
154: listenerList.add(java.awt.event.ActionListener.class, listener);
155: }
156:
157: /**
158: * Removes ActionListener from the list of listeners.
159: * @param listener The listener to remove.
160: */
161: public synchronized void removeActionListener(
162: java.awt.event.ActionListener listener) {
163:
164: listenerList.remove(java.awt.event.ActionListener.class,
165: listener);
166: }
167:
168: /**
169: * Notifies all registered listeners about the event.
170: *
171: * @param event The event to be fired
172: */
173: private void fireActionListenerActionPerformed(
174: java.awt.event.ActionEvent event) {
175:
176: if (listenerList == null)
177: return;
178: Object[] listeners = listenerList.getListenerList();
179: for (int i = listeners.length - 2; i >= 0; i -= 2) {
180: if (listeners[i] == java.awt.event.ActionListener.class) {
181: ((java.awt.event.ActionListener) listeners[i + 1])
182: .actionPerformed(event);
183: }
184: }
185: }
186:
187: public void applyI18n() {
188: // Start autogenerated code ----------------------
189: // jButton1.setText(I18n.getString("fontSheetPropertyComponent.button1","..."));
190: // End autogenerated code ----------------------
191: updateLabel();
192: }
193:
194: public void updateLabel() {
195: try {
196: java.util.List list = getPropertiesList();
197: if (list == null) {
198: jLabelList.setText("<null>");
199: } else {
200: jLabelList.setText(I18n.getFormattedString(
201: "listSheetPropertyComponent.label",
202: "{0} item(s)", new Object[] { new Integer(list
203: .size()) }));
204: }
205:
206: jLabelList.updateUI();
207:
208: } catch (Exception ex) {
209:
210: }
211: }
212: }
|