Statistics
| Revision:

root / branches / gvSIG_03_SLD / applications / appgvSIG / src / com / iver / cit / gvsig / gui / thememanager / legendmanager / panels / edition / FSymbolCellEditor.java @ 2076

History | View | Annotate | Download (4.12 KB)

1
/*
2
 * Created on 27-abr-2004
3
 *
4
 */
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
package com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition;
46

    
47
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
48
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.FPanelLegendDefault;
49

    
50
import java.awt.BorderLayout;
51
import java.awt.Component;
52
import java.awt.Dimension;
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
55

    
56
import javax.swing.AbstractCellEditor;
57
import javax.swing.JButton;
58
import javax.swing.JDialog;
59
import javax.swing.JPanel;
60
import javax.swing.JTable;
61
import javax.swing.table.TableCellEditor;
62

    
63

    
64
/**
65
 * Clase utilizada para editar un registro.
66
 *
67
 * @author fjp
68
 */
69
public class FSymbolCellEditor extends AbstractCellEditor implements TableCellEditor,
70
        ActionListener {
71
        protected static final String EDIT = "edit";
72
        FSymbol currentSymbol;
73
        JButton button;
74

    
75
        // JColorChooser colorChooser;
76
        FPanelLegendDefault m_panelDefault;
77
        JDialog dialog;
78

    
79
        /**
80
         * Crea un nuevo FCellEditor.
81
         */
82
        public FSymbolCellEditor() {
83
                button = new JButton();
84
                button.setActionCommand(EDIT);
85
                button.addActionListener(this);
86
                button.setBorderPainted(false);
87

    
88
                //Set up the dialog that the button brings up.
89
                dialog = new JDialog();
90
                m_panelDefault = new FPanelLegendDefault();
91

    
92
                // m_panelDefault.setMinimumSize(new Dimension(300,20));
93
                m_panelDefault.setPreferredSize(new Dimension(500, 300));
94

    
95
                // m_panelDefault.setBounds(0,0,400,260);
96
                dialog.getContentPane().setLayout(new BorderLayout());
97

    
98
                // m_panelDefault.setBackground(Color.YELLOW);
99
                dialog.getContentPane().add(m_panelDefault, BorderLayout.NORTH);
100

    
101
                // Botones
102
                JPanel pButtons = new JPanel();
103
                JButton btnOk = new JButton("Aceptar");
104
                btnOk.addActionListener(this);
105
                btnOk.setActionCommand("OK");
106
                pButtons.add(btnOk);
107
                dialog.getContentPane().add(pButtons, BorderLayout.SOUTH);
108

    
109
                // dialog.setSize(new Dimension(500,400));
110
                dialog.setModal(true);
111
                dialog.pack();
112
        }
113

    
114
        public void actionPerformed(ActionEvent e) {
115
                if (EDIT.equals(e.getActionCommand())) {
116
                        //The user has clicked the cell, so
117
                        //bring up the dialog.
118
                        button.setBackground(currentSymbol.getColor());
119
                        m_panelDefault.setVisible(true);
120
                        m_panelDefault.setFSymbol(currentSymbol);
121

    
122
                        // colorChooser.setColor(currentSymbol.m_Color);
123
                        dialog.setVisible(true);
124

    
125
                        fireEditingStopped(); //Make the renderer reappear.
126
                } else { //User pressed dialog's "OK" button.
127

    
128
                        // currentSymbol.m_Color = colorChooser.getColor();
129
                        currentSymbol = m_panelDefault.getFSymbol();
130
                        dialog.dispose();
131
                }
132
        }
133

    
134
        //Implement the one CellEditor method that AbstractCellEditor doesn't.
135
        public Object getCellEditorValue() {
136
                return currentSymbol;
137
        }
138

    
139
        //Implement the one method defined by TableCellEditor.
140
        public Component getTableCellEditorComponent(JTable table, Object value,
141
                boolean isSelected, int row, int column) {
142
                System.out.println(value.toString());
143
                currentSymbol = (FSymbol) value;
144

    
145
                // button.setBackground(currentSymbol.m_Color);
146
                return button;
147
        }
148
}