Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / mapcontrol / dal / feature / swing / table / TextAreaCellEditor.java @ 38564

History | View | Annotate | Download (2.33 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * 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, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontrol.dal.feature.swing.table;
28

    
29
import javax.swing.DefaultCellEditor;
30
import javax.swing.JScrollPane;
31
import javax.swing.JTextArea;
32
import javax.swing.JTextField;
33

    
34
/**
35
 * <p>
36
 * Taken and adapted from the Article <strong>"Multi-line cells in JTable in JDK
37
 * 1.4+"</strong> by Dr. Heinz M. Kabutz:
38
 * </p>
39
 * <p>
40
 * http://www.javaspecialists.eu/archive/Issue106.html
41
 * </p>
42
 * 
43
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
44
 */
45
public class TextAreaCellEditor extends DefaultCellEditor {
46

    
47
    private static final long serialVersionUID = -5614806192749314509L;
48

    
49
    private final JTextArea textArea;
50

    
51
    @SuppressWarnings("serial")
52
    public TextAreaCellEditor() {
53
        super(new JTextField());
54
        textArea = new JTextArea();
55
        textArea.setWrapStyleWord(true);
56
        textArea.setLineWrap(true);
57
        JScrollPane scrollPane = new JScrollPane(textArea);
58
        scrollPane.setBorder(null);
59
        editorComponent = scrollPane;
60

    
61
        delegate = new DefaultCellEditor.EditorDelegate() {
62
            public void setValue(Object value) {
63
                textArea.setText((value != null) ? value.toString() : "");
64
            }
65

    
66
            public Object getCellEditorValue() {
67
                return textArea.getText();
68
            }
69
        };
70
    }
71
    
72
    public JTextArea getTextArea() {
73
        return textArea;
74
    }
75
}