svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / FCellEditor.java @ 312
History | View | Annotate | Download (3.08 KB)
1 |
/*
|
---|---|
2 |
* Created on 27-abr-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
package com.iver.cit.gvsig.gui.Panels; |
8 |
|
9 |
import java.awt.BorderLayout; |
10 |
import java.awt.Color; |
11 |
import java.awt.Component; |
12 |
import java.awt.Dimension; |
13 |
import java.awt.event.ActionEvent; |
14 |
import java.awt.event.ActionListener; |
15 |
|
16 |
import javax.swing.AbstractCellEditor; |
17 |
import javax.swing.JButton; |
18 |
import javax.swing.JDialog; |
19 |
import javax.swing.JPanel; |
20 |
import javax.swing.JTable; |
21 |
import javax.swing.table.TableCellEditor; |
22 |
|
23 |
import com.iver.cit.gvsig.fmap.FSymbol; |
24 |
|
25 |
/**
|
26 |
* @author fjp
|
27 |
*
|
28 |
* To change the template for this generated type comment go to
|
29 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
30 |
*/
|
31 |
public class FCellEditor extends AbstractCellEditor |
32 |
implements TableCellEditor, |
33 |
ActionListener {
|
34 |
FSymbol currentSymbol; |
35 |
JButton button;
|
36 |
// JColorChooser colorChooser;
|
37 |
FPanelLegendDefault m_panelDefault; |
38 |
JDialog dialog;
|
39 |
protected static final String EDIT = "edit"; |
40 |
|
41 |
public FCellEditor() {
|
42 |
button = new JButton(); |
43 |
button.setActionCommand(EDIT); |
44 |
button.addActionListener(this);
|
45 |
button.setBorderPainted(false);
|
46 |
|
47 |
//Set up the dialog that the button brings up.
|
48 |
dialog = new JDialog(); |
49 |
m_panelDefault = new FPanelLegendDefault();
|
50 |
// m_panelDefault.setMinimumSize(new Dimension(300,20));
|
51 |
m_panelDefault.setPreferredSize(new Dimension(500,300)); |
52 |
// m_panelDefault.setBounds(0,0,400,260);
|
53 |
dialog.getContentPane().setLayout(new BorderLayout()); |
54 |
// m_panelDefault.setBackground(Color.YELLOW);
|
55 |
dialog.getContentPane().add(m_panelDefault, BorderLayout.NORTH);
|
56 |
|
57 |
// Botones
|
58 |
JPanel pButtons = new JPanel(); |
59 |
JButton btnOk = new JButton("Aceptar"); |
60 |
btnOk.addActionListener(this);
|
61 |
btnOk.setActionCommand("OK");
|
62 |
pButtons.add(btnOk); |
63 |
dialog.getContentPane().add(pButtons,BorderLayout.SOUTH);
|
64 |
// dialog.setSize(new Dimension(500,400));
|
65 |
dialog.setModal(true);
|
66 |
dialog.pack(); |
67 |
|
68 |
} |
69 |
|
70 |
public void actionPerformed(ActionEvent e) { |
71 |
if (EDIT.equals(e.getActionCommand())) {
|
72 |
//The user has clicked the cell, so
|
73 |
//bring up the dialog.
|
74 |
|
75 |
button.setBackground(currentSymbol.m_Color); |
76 |
m_panelDefault.setVisible(true);
|
77 |
m_panelDefault.setFSymbol(currentSymbol); |
78 |
// colorChooser.setColor(currentSymbol.m_Color);
|
79 |
dialog.setVisible(true);
|
80 |
|
81 |
fireEditingStopped(); //Make the renderer reappear.
|
82 |
|
83 |
} else { //User pressed dialog's "OK" button. |
84 |
// currentSymbol.m_Color = colorChooser.getColor();
|
85 |
currentSymbol = m_panelDefault.getFSymbol(); |
86 |
dialog.dispose(); |
87 |
} |
88 |
} |
89 |
|
90 |
//Implement the one CellEditor method that AbstractCellEditor doesn't.
|
91 |
public Object getCellEditorValue() { |
92 |
|
93 |
return currentSymbol;
|
94 |
} |
95 |
|
96 |
//Implement the one method defined by TableCellEditor.
|
97 |
public Component getTableCellEditorComponent(JTable table, |
98 |
Object value,
|
99 |
boolean isSelected,
|
100 |
int row,
|
101 |
int column) {
|
102 |
|
103 |
System.out.println(value.toString());
|
104 |
currentSymbol = (FSymbol )value; |
105 |
// button.setBackground(currentSymbol.m_Color);
|
106 |
return button;
|
107 |
} |
108 |
} |
109 |
|