001: /*
002: * Copyright (C) 2004 Giuseppe MANNA
003: *
004: * This file is part of FreeReportBuilder
005: *
006: * FreeReportBuilder is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * 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, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package it.frb.action;
023:
024: import it.frb.*;
025: import java.awt.*;
026: import javax.swing.*;
027: import javax.swing.JOptionPane;
028: import javax.swing.JTextField;
029: import javax.swing.plaf.*;
030:
031: public class ActionControl_T extends ActionDataPanel {
032: public ActionControl_T(String action) {
033: super (action);
034: }
035:
036: public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
037: drg.ctrlPress = false;
038:
039: int countObjSelected = drg.getCountVectorComponentSelected();
040:
041: if (countObjSelected == 1) {
042: Component jcomp = (Component) drg
043: .getVectorComponentSelected().get(0);
044:
045: if (jcomp.getClass() == javax.swing.JLabel.class) {
046: javax.swing.JLabel jlab = (javax.swing.JLabel) jcomp;
047: String string = jlab.getText();
048:
049: Object obj;
050:
051: if (jlab.getIcon() != null) {
052: obj = WindowText.showInputDialog("Condition",
053: string, SwingUtilities
054: .getRootPane(dataPanel));
055: } else {
056: obj = WindowText.showInputDialog("Label", string,
057: SwingUtilities.getRootPane(dataPanel));
058: }
059:
060: if (obj != null) {
061: jlab.setText(((JTextArea) obj).getText());
062: }
063: }
064:
065: if (jcomp.getClass() == JTextField.class) {
066: JTextField jtxt = (JTextField) jcomp;
067: String string = jtxt.getText();
068:
069: Object obj = null;
070:
071: if (jtxt.getName() != null) {
072: obj = WindowText.showInputDialog(
073: "Calculated field", string, SwingUtilities
074: .getRootPane(dataPanel));
075: } else {
076: obj = WindowText.showInputDialog("Column name",
077: string, SwingUtilities
078: .getRootPane(dataPanel));
079: }
080:
081: if (obj != null) {
082: jtxt.setText(((JTextArea) obj).getText());
083: }
084: }
085:
086: if (jcomp.getClass() == javax.swing.JTextArea.class) {
087: JTextArea jta = (JTextArea) jcomp;
088: String string = jta.getText();
089:
090: Object obj = WindowText.showInputDialog("Column name",
091: string, SwingUtilities.getRootPane(dataPanel));
092:
093: if (obj != null) {
094: jta.setText(((JTextArea) obj).getText());
095: }
096: }
097:
098: if (jcomp.getClass() == javax.swing.JPanel.class) {
099: javax.swing.JFileChooser chooser = new javax.swing.JFileChooser();
100: chooser.setSelectedFile(new java.io.File(jcomp
101: .getName()));
102: int returnVal = chooser.showOpenDialog(dataPanel);
103:
104: if (returnVal == javax.swing.JFileChooser.APPROVE_OPTION) {
105: jcomp.setName(chooser.getSelectedFile()
106: .getAbsolutePath());
107: dataPanel.repaint();
108: }
109: }
110: } else {
111: int countComponentSelected = drg
112: .getCountVectorComponentSelected();
113:
114: if (countComponentSelected > 1) {
115: String label;
116: Object obj = JOptionPane
117: .showInputDialog(
118: SwingUtilities.getRoot(dataPanel),
119: null,
120: "Done establish by to insert before to every column ?",
121: JOptionPane.QUESTION_MESSAGE, null,
122: null, null);
123: label = (String) obj;
124:
125: if (label != null) {
126: if (label.indexOf(".") == -1 && !label.equals("")) {
127: label = label + ".";
128: }
129:
130: java.util.Vector vec = drg
131: .getVectorComponentSelected();
132:
133: for (int i = 0; i < countComponentSelected; i++) {
134: javax.swing.JComponent jComp = (javax.swing.JComponent) vec
135: .get(i);
136: java.awt.Container parentCont = jComp
137: .getParent();
138:
139: if (jComp.getClass() == JTextField.class) {
140: if (parentCont != null) {
141: JTextField jtxt = (JTextField) jComp;
142: String sTxt = jtxt.getText();
143: int index = sTxt.indexOf(".");
144:
145: String substring = "";
146:
147: if (index != -1) {
148: substring = sTxt
149: .substring(index + 1);
150: } else {
151: substring = sTxt;
152: }
153:
154: jtxt.setText(label + substring);
155: }
156: }
157: }
158: }
159: }
160: }
161: }
162: }
|