001: package com.calipso.reportgenerator.userinterface.dinamicchart;
002:
003: import com.calipso.reportgenerator.userinterface.ChartCustomizer;
004: import com.calipso.reportgenerator.userinterface.IReportFrame;
005:
006: import javax.swing.*;
007: import java.awt.*;
008: import java.awt.event.ActionListener;
009: import java.awt.event.ActionEvent;
010: import java.awt.event.ItemListener;
011: import java.awt.event.ItemEvent;
012: import java.util.Vector;
013:
014: /**
015: *
016: * User: soliveri
017: * Date: Aug 7, 2003
018: * Time: 5:42:31 PM
019: *
020: */
021:
022: public class ChartPivotTableSelection extends JPanel implements
023: ActionListener, ItemListener {
024:
025: private JComboBox cbChartType;
026: private JRadioButton btRow, btColumn;
027: private int currentChartType;
028: private ChartPivotTableManager manager = ChartPivotTableManager
029: .getManager();
030: private JButton btChartCustomizer;
031: private ChartCustomizer chartCustomizer;
032: private IReportFrame owner;
033:
034: public ChartPivotTableSelection(IReportFrame ownerPa) {
035: owner = ownerPa;
036: initialize();
037: }
038:
039: private void initialize() {
040: setLayout(new BorderLayout());
041: cbChartType = new JComboBox(getChartTypesDescription());
042: cbChartType.setFont(new Font("Arial", Font.ROMAN_BASELINE, 11));
043: cbChartType.addItemListener(this );
044: ButtonGroup btGroup = new ButtonGroup();
045: btRow = new JRadioButton(
046: com.calipso.reportgenerator.common.LanguageTraslator
047: .traslate("110"));
048: btRow.setFont(new Font("Arial", Font.ROMAN_BASELINE, 11));
049: btRow.addActionListener(this );
050: btRow.setSelected(true);
051: btColumn = new JRadioButton(
052: com.calipso.reportgenerator.common.LanguageTraslator
053: .traslate("111"));
054: btColumn.setFont(new Font("Arial", Font.ROMAN_BASELINE, 11));
055: btColumn.addActionListener(this );
056: btGroup.add(btRow);
057: btGroup.add(btColumn);
058: JPanel southPanel = new JPanel(new FlowLayout());
059: southPanel.add(btRow);
060: southPanel.add(btColumn);
061:
062: btChartCustomizer = new JButton(
063: com.calipso.reportgenerator.common.LanguageTraslator
064: .traslate("239"));
065: btChartCustomizer.addActionListener(this );
066:
067: add(cbChartType, BorderLayout.CENTER);
068: add(southPanel, BorderLayout.SOUTH);
069: add(btChartCustomizer, BorderLayout.EAST);
070: }
071:
072: private Vector getChartTypesDescription() {
073: Vector chartTypes = new Vector();
074: chartTypes
075: .add(com.calipso.reportgenerator.common.LanguageTraslator
076: .traslate("244"));
077: chartTypes
078: .add(com.calipso.reportgenerator.common.LanguageTraslator
079: .traslate("115"));
080: chartTypes
081: .add(com.calipso.reportgenerator.common.LanguageTraslator
082: .traslate("245"));
083: chartTypes
084: .add(com.calipso.reportgenerator.common.LanguageTraslator
085: .traslate("242"));
086: chartTypes
087: .add(com.calipso.reportgenerator.common.LanguageTraslator
088: .traslate("243"));
089: chartTypes
090: .add(com.calipso.reportgenerator.common.LanguageTraslator
091: .traslate("114"));
092: return chartTypes;
093: }
094:
095: public boolean getCurrentValue() {
096: if (btRow.isSelected()) {
097: return false;
098: }
099: return true;
100: }
101:
102: public int getCurrentChartType() {
103: return currentChartType;
104: }
105:
106: public void actionPerformed(ActionEvent e) {
107: if (e.getSource() == btRow) {
108: manager.chartTypeChanged(currentChartType, false);
109: } else if (e.getSource() == btColumn) {
110: manager.chartTypeChanged(currentChartType, true);
111: }
112: if (e.getSource() == btChartCustomizer) {
113: getChartCustomizer().setVisible(true);
114: manager.chartCustomizerChanged(currentChartType, (!btRow
115: .isSelected()));
116: }
117: }
118:
119: public void itemStateChanged(ItemEvent e) {
120: if (e.getSource() == cbChartType) {
121: currentChartType = cbChartType.getSelectedIndex();
122: manager.chartChanged(currentChartType, getCurrentValue());
123: }
124: }
125:
126: public ChartCustomizer getChartCustomizer() {
127: if (chartCustomizer == null) {
128: chartCustomizer = new ChartCustomizer(owner.owner(), true);
129: }
130: return chartCustomizer;
131: }
132: }
|