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