Revision 2076

View differences:

branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FCellEditor.java
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;
46

  
47
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
48

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

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

  
62

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
144
		// button.setBackground(currentSymbol.m_Color);
145
		return button;
146
	}
147
}
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FCellRenderer.java
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;
46

  
47
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
48

  
49
import java.awt.Component;
50

  
51
import javax.swing.BorderFactory;
52
import javax.swing.JPanel;
53
import javax.swing.JTable;
54
import javax.swing.border.Border;
55
import javax.swing.table.TableCellRenderer;
56

  
57

  
58
/**
59
 * Renderer de la edici?n de un registro de la tabla de s?mbolos.
60
 *
61
 * @author fjp
62
 */
63
public class FCellRenderer extends JPanel implements TableCellRenderer {
64
	Border unselectedBorder = null;
65
	Border selectedBorder = null;
66
	boolean isBordered = true;
67
	protected FPreviewSymbol m_previewPanel = new FPreviewSymbol();
68

  
69
	/**
70
	 * Crea un nuevo FCellRenderer.
71
	 *
72
	 * @param isBordered DOCUMENT ME!
73
	 */
74
	public FCellRenderer(boolean isBordered) {
75
		this.isBordered = isBordered;
76
		setOpaque(true); //MUST do this for background to show up.
77
	}
78

  
79
	/**
80
	 * DOCUMENT ME!
81
	 *
82
	 * @param table DOCUMENT ME!
83
	 * @param value DOCUMENT ME!
84
	 * @param isSelected DOCUMENT ME!
85
	 * @param hasFocus DOCUMENT ME!
86
	 * @param row DOCUMENT ME!
87
	 * @param column DOCUMENT ME!
88
	 *
89
	 * @return DOCUMENT ME!
90
	 */
91
	public Component getTableCellRendererComponent(JTable table, Object value,
92
		boolean isSelected, boolean hasFocus, int row, int column) {
93
		// System.out.println(value.getClass().toString());								
94
		m_previewPanel.setSymbol((FSymbol) value);
95

  
96
		// Color newColor = m_FSymbol.m_Color;
97
		// setBackground(newColor);
98
		if (isBordered) {
99
			if (isSelected) {
100
				if (selectedBorder == null) {
101
					selectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
102
							5, table.getSelectionBackground());
103
				}
104

  
105
				setBorder(selectedBorder);
106
			} else {
107
				if (unselectedBorder == null) {
108
					unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
109
							5, table.getBackground());
110
				}
111

  
112
				setBorder(unselectedBorder);
113
			}
114
		}
115

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

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

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

  
62
import com.iver.cit.gvsig.fmap.rendering.FInterval;
63

  
64
/**
65
 * @author fjp
66
 *
67
 * To change the template for this generated type comment go to
68
 * Window>Preferences>Java>Code Generation>Code and Comments
69
 */
70
public class FIntervalCellEditor  extends AbstractCellEditor
71
						 implements TableCellEditor,
72
									ActionListener {
73
	FInterval currentInterval;
74
	PanelEditInterval m_panelDefault;
75
	JButton button;
76
	JDialog m_dlgEditor;
77
	protected static final String EDIT = "edit";
78

  
79
	public FIntervalCellEditor() {
80
		button = new JButton();
81
		button.setActionCommand(EDIT);
82
		button.addActionListener(this);
83
		button.setBorderPainted(false);
84

  
85
		//Set up the dialog that the button brings up.
86
		m_dlgEditor = new JDialog();
87
		m_panelDefault = new PanelEditInterval();
88
		m_dlgEditor.getContentPane().add(m_panelDefault, BorderLayout.NORTH);
89
		
90
		// Botones
91
		JPanel pButtons = new JPanel();
92
		JButton btnOk = new JButton("Aceptar");
93
		btnOk.addActionListener(this);
94
		btnOk.setActionCommand("OK");
95
		pButtons.add(btnOk);
96
		m_dlgEditor.getContentPane().add(pButtons,BorderLayout.SOUTH);
97
		m_dlgEditor.setSize(new Dimension(500,400));
98
		m_dlgEditor.setModal(true);
99
	}
100

  
101
	public void actionPerformed(ActionEvent e) {
102
		if (EDIT.equals(e.getActionCommand())) {
103
			//The user has clicked the cell, so
104
			//bring up the dialog.
105
			m_panelDefault.setFInterval(currentInterval);
106
			m_dlgEditor.setVisible(true);
107

  
108
			fireEditingStopped(); //Make the renderer reappear.
109

  
110
		} else { //User pressed dialog's "OK" button.
111
			currentInterval = m_panelDefault.getFInterval();
112
			m_dlgEditor.dispose();
113
		}
114
	}
115

  
116
	//Implement the one CellEditor method that AbstractCellEditor doesn't.
117
	public Object getCellEditorValue() {
118
		
119
		return currentInterval;
120
	}
121

  
122
	//Implement the one method defined by TableCellEditor.
123
	public Component getTableCellEditorComponent(JTable table,
124
												 Object value,
125
												 boolean isSelected,
126
												 int row,
127
												 int column) {
128
												 	
129
		System.out.println(value.toString());												 	
130
		currentInterval = (FInterval )value;
131
		// button.setBackground(currentSymbol.m_Color);
132
		return button;
133
	}
134
}
135

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

  
49
import java.awt.GridLayout;
50

  
51
import javax.swing.JLabel;
52
import javax.swing.JPanel;
53
import javax.swing.JTextField;
54

  
55
import com.iver.cit.gvsig.fmap.rendering.FInterval;
56

  
57

  
58
/**
59
 * DOCUMENT ME!
60
 *
61
 * @author fjp To change the template for this generated type comment go to
62
 *         Window>Preferences>Java>Code Generation>Code and
63
 *         Comments
64
*/
65
public class PanelEditInterval extends JPanel {
66
	JTextField m_txtMin = new JTextField(10);
67
	JTextField m_txtMax = new JTextField(10);
68
	
69
	
70
	
71
    /**
72
     * This is the default constructor
73
     */
74
    public PanelEditInterval() {
75
        super();
76
        initialize();
77
    }
78

  
79
    /**
80
     * DOCUMENT ME!
81
     *
82
     * @param i DOCUMENT ME!
83
     */
84
    public void setFInterval(FInterval i) {
85
    }
86

  
87
    /**
88
     * DOCUMENT ME!
89
     *
90
     * @return DOCUMENT ME!
91
     */
92
    public FInterval getFInterval() {
93
        double from = 0;
94
        double to = 0;
95
        FInterval i = new FInterval(from, to);
96

  
97
        return i;
98
    }
99

  
100
    /**
101
     * This method initializes this
102
     */
103
    private void initialize() {
104
        this.setSize(300, 200);
105
        GridLayout grid = new GridLayout(2,2);
106
        JLabel lblMin = new JLabel("Valor m?nimo:");
107
		JLabel lblMax = new JLabel("Valor m?ximo:");
108
		this.add(lblMin);
109
		this.add(m_txtMin);
110
		this.add(lblMax);
111
		this.add(m_txtMax);
112
		
113
        
114
    }
115
}
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FSymbolTable.java
46 46
 */
47 47
package com.iver.cit.gvsig.gui.thememanager.legendmanager.panels;
48 48

  
49
/**
50
 * @author fjp
51
 *
52
 * To change the template for this generated type comment go to
53
 * Window>Preferences>Java>Code Generation>Code and Comments
54
 */
55

  
56
/*
57
 * TableRenderDemo.java is a 1.4 application that requires no other files.
58
 */
59

  
60 49
import java.awt.Component;
61 50
import java.awt.Dimension;
62 51
import java.awt.GridLayout;
......
69 58
import javax.swing.table.TableColumn;
70 59

  
71 60
import com.iver.andami.PluginServices;
72
import com.iver.andami.Utilities;
73 61
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
62
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FCellIntervalRenderer;
63
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FCellSymbolRenderer;
64
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FIntervalCellEditor;
65
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FLabelCellEditor;
66
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FSymbolCellEditor;
67
import com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition.FValueCellEditor;
74 68

  
75 69

  
76

  
70
/**
71
 * JPanel que contiene la tabla con los s?mbolos intervalos o valores y
72
 * etiquetado de estos valores.
73
 *
74
 * @author Vicente Caballero Navarro
75
 */
77 76
public class FSymbolTable extends JPanel {
77
	private static final long serialVersionUID = 1L;
78 78

  
79
	private boolean DEBUG = true;
80
	
79
//	private boolean DEBUG = true;
80

  
81 81
	// private  MyTableModel m_TableModel;
82
	
83 82
	private JTable table;
84
	
85
	
86
	public void addRow(Object[] vector)
87
	{
83
	private String type;
84

  
85
	/**
86
	 * Crea un nuevo FSymbolTable.
87
	 *
88
	 * @param type tipo de valor si es intervalo: "intervals" y si es por valores: "values".
89
	 */
90
	public FSymbolTable(String type) {
91
		super(new GridLayout(1, 0));
92
		this.type = type;
93
		table = new JTable(new MyTableModel());
94
		table.setPreferredScrollableViewportSize(new Dimension(500, 70));
95

  
96
		//Create the scroll pane and add the table to it.
97
		JScrollPane scrollPane = new JScrollPane(table);
98

  
99
		//Set up column sizes.
100
		initColumnSizes(table);
101
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
102
		setUpValueColumn(table, table.getColumnModel().getColumn(1));
103
		setUpLabelColumn(table, table.getColumnModel().getColumn(2));
104
		//Add the scroll pane to this panel.
105
		add(scrollPane);
106
		table.setRowSelectionAllowed(false);
107
	}
108

  
109
	public void addRow(Object[] vector) {
88 110
		MyTableModel m = (MyTableModel) table.getModel();
89
		m.addRow(vector); 
111
		m.addRow(vector);
90 112
	}
91
	public void removeSelectedRows()
92
	{
113

  
114
	public void removeSelectedRows() {
93 115
		MyTableModel m = (MyTableModel) table.getModel();
94
		int [] selectedRows = table.getSelectedRows();
95
		for (int i=selectedRows.length-1; i >= 0; i--)
96
		{
116
		int[] selectedRows = table.getSelectedRows();
117

  
118
		for (int i = selectedRows.length - 1; i >= 0; i--) {
97 119
			m.removeRow(selectedRows[i]);
98 120
		}
99 121
	}
100
	
101
	public void fillTableFromSymbolList(FSymbol[] symbols, Object[] values, String[] descriptions)
102
	{	
103
		// Object clave;
104
		FSymbol theSymbol; 
105 122

  
106
		for (int i=0; i < symbols.length; i++)
107
		{ 
123
	/**
124
	 * Rellena la tabla con los s?mbolos valores y descripciones que se pasan como par?metro.
125
	 *
126
	 * @param symbols Array de s?mbolos
127
	 * @param values Array de valores.
128
	 * @param descriptions Array de descripciones.
129
	 */
130
	public void fillTableFromSymbolList(FSymbol[] symbols, Object[] values,
131
		String[] descriptions) {
132
		FSymbol theSymbol;
133

  
134
		for (int i = 0; i < symbols.length; i++) {
108 135
			theSymbol = symbols[i];
136

  
109 137
			Object[] theRow = new Object[3];
110 138
			theRow[0] = theSymbol;
111 139
			theRow[1] = values[i];
112 140
			theRow[2] = descriptions[i];
113 141
			addRow(theRow);
114 142
		}
115
		
116 143
	}
117
	
118
	
119
	public Object getFieldValue(int row, int col)
120
	{
144

  
145
	public Object getFieldValue(int row, int col) {
121 146
		MyTableModel m = (MyTableModel) table.getModel();
122
		return m.getValueAt(row, col); 
147

  
148
		return m.getValueAt(row, col);
123 149
	}
124
	public int getRowCount()
125
	{
150

  
151
	public int getRowCount() {
126 152
		MyTableModel m = (MyTableModel) table.getModel();
127
		return m.getRowCount(); 
153

  
154
		return m.getRowCount();
128 155
	}
129
	
130
	public void removeAllItems()
131
	{
156

  
157
	public void removeAllItems() {
132 158
		table.setModel(new MyTableModel());
133
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));		
159
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
160
		setUpValueColumn(table, table.getColumnModel().getColumn(1));
161
		setUpLabelColumn(table, table.getColumnModel().getColumn(2));
134 162
	}
135 163

  
136
	public FSymbolTable() {
137
		super(new GridLayout(1,0));
138
		
164
	/**
165
	 * Inicializa el cell editor de tipo descripci?n de la columna que se pasa como par?metro.
166
	 *
167
	 * @param table2 Tabla.
168
	 * @param column Columna.
169
	 */
170
	public void setUpLabelColumn(JTable table2, TableColumn column) {
171
		FLabelCellEditor labeleditor = new FLabelCellEditor();
172
		column.setCellEditor(labeleditor);
173
	}
139 174

  
140
		table = new JTable(new MyTableModel());
141
		table.setPreferredScrollableViewportSize(new Dimension(500, 70));
175
	/**
176
	 * Inicializa el cell editor de tipo valor de la columna que se pasa como par?metro.
177
	 *
178
	 * @param table2 Tabla.
179
	 * @param column Columna.
180
	 */
181
	public void setUpValueColumn(JTable table2, TableColumn column) {
182
		if (type.equals("intervals")) {
183
			FIntervalCellEditor intervaleditor = new FIntervalCellEditor();
184
			column.setCellEditor(intervaleditor);
142 185

  
143
		//Create the scroll pane and add the table to it.
144
		JScrollPane scrollPane = new JScrollPane(table);
145

  
146
		//Set up column sizes.
147
		initColumnSizes(table);
148
		
149
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
150

  
151
		//Add the scroll pane to this panel.
152
		add(scrollPane);
153
		
154
		table.setRowSelectionAllowed(true);
186
			FCellIntervalRenderer renderer = new FCellIntervalRenderer(true);
187
			column.setCellRenderer(renderer);
188
		} else {
189
			FValueCellEditor valueeditor = new FValueCellEditor();
190
			column.setCellEditor(valueeditor);
191
		}
155 192
	}
156 193

  
157 194
	/*
......
160 197
	 * contents, then you can just use column.sizeWidthToFit().
161 198
	 */
162 199
	private void initColumnSizes(JTable table) {
163
		MyTableModel model = (MyTableModel)table.getModel();
200
		MyTableModel model = (MyTableModel) table.getModel();
164 201
		TableColumn column = null;
165 202
		Component comp = null;
166 203
		int headerWidth = 0;
167 204
		int cellWidth = 0;
168
		TableCellRenderer headerRenderer =
169
			table.getTableHeader().getDefaultRenderer();
170

  
171
		/* for (int i = 0; i < table.getColumnCount(); i++) {
172
			column = table.getColumnModel().getColumn(i);
173

  
174
			comp = headerRenderer.getTableCellRendererComponent(
175
								 null, column.getHeaderValue(),
176
								 false, false, 0, 0);
177
			headerWidth = comp.getPreferredSize().width;
178

  
179
			comp = table.getDefaultRenderer(model.getColumnClass(i)).
180
							 getTableCellRendererComponent(
181
								 table, longValues[i],
182
								 false, false, 0, i);
183
			cellWidth = comp.getPreferredSize().width;
184

  
185
			if (DEBUG) {
186
				System.out.println("Initializing width of column "
187
								   + i + ". "
188
								   + "headerWidth = " + headerWidth
189
								   + "; cellWidth = " + cellWidth);
190
			}
191

  
192
			//XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
193
			column.setPreferredWidth(Math.max(headerWidth, cellWidth));
194
		} */
205
		TableCellRenderer headerRenderer = table.getTableHeader()
206
												.getDefaultRenderer();
195 207
	}
196 208

  
197
	public void setUpSymbolColumn(JTable table,
198
								 TableColumn m_FSymbolComlumn) {
209
	/**
210
	 * Inicializa el cell editor de tipo s?mbolo de la columna que se pasa como par?metro.
211
	 *
212
	 * @param table2 Tabla.
213
	 * @param column Columna.
214
	 */	
215
	public void setUpSymbolColumn(JTable table, TableColumn m_FSymbolComlumn) {
199 216
		//Set up the editor 
200
		/* JComboBox comboBox = new JComboBox();
201
		comboBox.addItem("Snowboarding");
202
		comboBox.addItem("Rowing");
203
		comboBox.addItem("Knitting");
204
		comboBox.addItem("Speed reading");
205
		comboBox.addItem("Pool");
206
		comboBox.addItem("None of the above");
207
		sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
208

  
209
		//Set up tool tips 
210
		DefaultTableCellRenderer renderer =
211
				new DefaultTableCellRenderer();
212
		renderer.setToolTipText("Click for combo box"); */
213
		
214
		
215 217
		m_FSymbolComlumn.setMaxWidth(100);
216 218
		m_FSymbolComlumn.setWidth(60);
217 219
		m_FSymbolComlumn.setPreferredWidth(60);
218 220
		m_FSymbolComlumn.setMinWidth(50);
219
		
220
		FCellEditor editor = new FCellEditor();
221
		m_FSymbolComlumn.setCellEditor(editor);
222
		
223
		FCellRenderer renderer = new FCellRenderer(true);
221

  
222
		FSymbolCellEditor symboleditor = new FSymbolCellEditor();
223

  
224
		m_FSymbolComlumn.setCellEditor(symboleditor);
225

  
226
		FCellSymbolRenderer renderer = new FCellSymbolRenderer(true);
224 227
		m_FSymbolComlumn.setCellRenderer(renderer);
225 228
	}
226 229

  
227
	class MyTableModel extends DefaultTableModel { //  AbstractTableModel {
228
	
229
		private String[] columnNames = {PluginServices.getText(this,"Simbolo"),
230
				PluginServices.getText(this,"Valor"),
231
				PluginServices.getText(this,"Etiqueta") };
230
	/**
231
	 * Modelo que propio que se aplica a la tabla.
232
	 *
233
	 * @author Vicente Caballero Navarro
234
	 */
235
	class MyTableModel extends DefaultTableModel { /**
236
		 * 
237
		 */
238
		private static final long serialVersionUID = 1L;
239
	//  AbstractTableModel {
232 240

  
241
		private String[] columnNames = {
242
				PluginServices.getText(this, "Simbolo"),
243
				PluginServices.getText(this, "Valor"),
244
				PluginServices.getText(this, "Etiqueta")
245
			};
246

  
247
		/**
248
		 * DOCUMENT ME!
249
		 *
250
		 * @return DOCUMENT ME!
251
		 */
233 252
		public int getColumnCount() {
234 253
			return columnNames.length;
235 254
		}
236 255

  
256
		/**
257
		 * DOCUMENT ME!
258
		 *
259
		 * @param col DOCUMENT ME!
260
		 *
261
		 * @return DOCUMENT ME!
262
		 */
237 263
		public String getColumnName(int col) {
238 264
			return columnNames[col];
239 265
		}
......
256 282
			//Note that the data/cell address is constant,
257 283
			//no matter where the cell appears onscreen.
258 284
			//if (col > 0) {
259
				return true;
285
			return true;
286

  
260 287
			/* } else {
261
				return false;
262
			} */
288
			   return false;
289
			   } */
263 290
		}
264 291

  
265 292
		/*
......
267 294
		 * data can change.
268 295
		 */
269 296
		/* public void setValueAt(Object value, int row, int col) {
270
			if (DEBUG) {
271
				System.out.println("Setting value at " + row + "," + col
272
								   + " to " + value
273
								   + " (an instance of "
274
								   + value.getClass() + ")");
275
			}
276
			// FSymbol theSymbol;
277
			switch (col)
278
			{
279
				case 0: // Simbolo
280
					// m_FRenderer.setValueSymbol(row,(FSymbol) value);
281
					break;
282
				case 1: // Clave
283
					FInterval newInterval = FInterval.parseString((String) value);
284
					this.setValueAt(newInterval,row,col);
285
					break;
286
				case 2: // Etiqueta
287
					// theSymbol = m_FRenderer.getSymbolByID(row);
288
					// theSymbol.m_Descrip = (String) value;
289
					
290
			}
291
			// data[row][col] = value;
292
			fireTableCellUpdated(row, col); 
293

  
294
		}  */
295

  
297
		   if (DEBUG) {
298
		           System.out.println("Setting value at " + row + "," + col
299
		                                              + " to " + value
300
		                                              + " (an instance of "
301
		                                              + value.getClass() + ")");
302
		   }
303
		   // FSymbol theSymbol;
304
		   switch (col)
305
		   {
306
		           case 0: // Simbolo
307
		                   // m_FRenderer.setValueSymbol(row,(FSymbol) value);
308
		                   break;
309
		           case 1: // Clave
310
		                   FInterval newInterval = FInterval.parseString((String) value);
311
		                   this.setValueAt(newInterval,row,col);
312
		                   break;
313
		           case 2: // Etiqueta
314
		                   // theSymbol = m_FRenderer.getSymbolByID(row);
315
		                   // theSymbol.m_Descrip = (String) value;
316
		
317
		   }
318
		   // data[row][col] = value;
319
		   fireTableCellUpdated(row, col);
320
		   }  */
296 321
		/* private void printDebugData() {
297
			int numRows = getRowCount();
298
			int numCols = getColumnCount();
299

  
300
			for (int i=0; i < numRows; i++) {
301
				System.out.print("    row " + i + ":");
302
				for (int j=0; j < numCols; j++) {
303
					System.out.print("  " + data[i][j]);
304
				}
305
				System.out.println();
306
			}
307
			System.out.println("--------------------------");
308
		} */
322
		   int numRows = getRowCount();
323
		   int numCols = getColumnCount();
324
		   for (int i=0; i < numRows; i++) {
325
		           System.out.print("    row " + i + ":");
326
		           for (int j=0; j < numCols; j++) {
327
		                   System.out.print("  " + data[i][j]);
328
		           }
329
		           System.out.println();
330
		   }
331
		   System.out.println("--------------------------");
332
		   } */
309 333
	}
310

  
311 334
}
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FPanelLegendValues.java
86 86
	private ClassifiableVectorial m_lyr;
87 87
	private boolean m_bCacheDirty = true;
88 88
	
89
	private FSymbolTable m_symbolTable = new FSymbolTable();
89
	private FSymbolTable m_symbolTable = new FSymbolTable("values");
90 90

  
91 91
	private JComboBox m_cboFields;
92 92
	
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FPanelLegendDefault.java
84 84
import javax.swing.plaf.basic.BasicComboBoxEditor;
85 85

  
86 86
import com.iver.andami.PluginServices;
87
import com.iver.andami.Utilities;
88 87
import com.iver.cit.gvsig.fmap.core.FPoint2D;
89 88
import com.iver.cit.gvsig.fmap.core.FShape;
90 89
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/edition/FCellSymbolRenderer.java
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.FPreviewSymbol;
49

  
50
import java.awt.Component;
51

  
52
import javax.swing.BorderFactory;
53
import javax.swing.JPanel;
54
import javax.swing.JTable;
55
import javax.swing.border.Border;
56
import javax.swing.table.TableCellRenderer;
57

  
58

  
59
/**
60
 * Renderer de la edici?n de un registro de la tabla de s?mbolos.
61
 *
62
 * @author fjp
63
 */
64
public class FCellSymbolRenderer extends JPanel implements TableCellRenderer {
65
	Border unselectedBorder = null;
66
	Border selectedBorder = null;
67
	boolean isBordered = true;
68
	protected FPreviewSymbol m_previewPanel = new FPreviewSymbol();
69

  
70
	/**
71
	 * Crea un nuevo FCellRenderer.
72
	 *
73
	 * @param isBordered DOCUMENT ME!
74
	 */
75
	public FCellSymbolRenderer(boolean isBordered) {
76
		this.isBordered = isBordered;
77
		setOpaque(true); //MUST do this for background to show up.
78
	}
79

  
80
	/**
81
	 * DOCUMENT ME!
82
	 *
83
	 * @param table DOCUMENT ME!
84
	 * @param value DOCUMENT ME!
85
	 * @param isSelected DOCUMENT ME!
86
	 * @param hasFocus DOCUMENT ME!
87
	 * @param row DOCUMENT ME!
88
	 * @param column DOCUMENT ME!
89
	 *
90
	 * @return DOCUMENT ME!
91
	 */
92
	public Component getTableCellRendererComponent(JTable table, Object value,
93
		boolean isSelected, boolean hasFocus, int row, int column) {
94
		// System.out.println(value.getClass().toString());								
95
		m_previewPanel.setSymbol((FSymbol) value);
96

  
97
		// Color newColor = m_FSymbol.m_Color;
98
		// setBackground(newColor);
99
		if (isBordered) {
100
			if (isSelected) {
101
				if (selectedBorder == null) {
102
					selectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
103
							5, table.getSelectionBackground());
104
				}
105

  
106
				setBorder(selectedBorder);
107
			} else {
108
				if (unselectedBorder == null) {
109
					unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
110
							5, table.getBackground());
111
				}
112

  
113
				setBorder(unselectedBorder);
114
			}
115
		}
116

  
117
		// setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
118
		return m_previewPanel;
119
	}
120
}
0 121

  
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/edition/FSymbolCellEditor.java
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
}
0 149

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

  
47
import javax.swing.AbstractCellEditor;
48
import javax.swing.JOptionPane;
49
import javax.swing.JTable;
50
import javax.swing.JTextField;
51
import javax.swing.table.TableCellEditor;
52

  
53
import com.hardcode.gdbms.engine.values.BooleanValue;
54
import com.hardcode.gdbms.engine.values.DateValue;
55
import com.hardcode.gdbms.engine.values.DoubleValue;
56
import com.hardcode.gdbms.engine.values.FloatValue;
57
import com.hardcode.gdbms.engine.values.IntValue;
58
import com.hardcode.gdbms.engine.values.LongValue;
59
import com.hardcode.gdbms.engine.values.ShortValue;
60
import com.hardcode.gdbms.engine.values.StringValue;
61
import com.hardcode.gdbms.engine.values.Value;
62
import com.hardcode.gdbms.engine.values.ValueFactory;
63
import com.iver.andami.PluginServices;
64

  
65

  
66
/**
67
 * Cell Editor sobre los valores ?nicos.
68
 *
69
 * @author Vicente Caballero Navarro
70
 */
71
public class FValueCellEditor extends AbstractCellEditor
72
	implements TableCellEditor, KeyListener {
73
	protected static final String EDIT = "edit";
74
	private Value value;
75
	private JTextField button;
76

  
77
	/**
78
	 * Crea un nuevo FLabelCellEditor.
79
	 */
80
	public FValueCellEditor() {
81
		button = new JTextField();
82
		button.setActionCommand(EDIT);
83
		button.addKeyListener(this);
84
	}
85

  
86
	//Implement the one CellEditor method that AbstractCellEditor doesn't.
87
	public Object getCellEditorValue() {
88
		return value;
89
	}
90

  
91
	//Implement the one method defined by TableCellEditor.
92
	public Component getTableCellEditorComponent(JTable table, Object value,
93
		boolean isSelected, int row, int column) {
94
		System.out.println(value.toString());
95
		this.value = (Value)value;
96
		button.setText(value.toString());
97
		return button;
98
	}
99

  
100
	public void keyPressed(KeyEvent e) {
101
	}
102
	public void keyReleased(KeyEvent e) {
103
		value = getValue(value,button.getText());
104
	}
105
	public void keyTyped(KeyEvent e) {
106
	}
107
	private Value getValue(Value v,String s) {
108
		Value val=null;
109
			try{	
110
				if (v instanceof DoubleValue) {
111
					val = ValueFactory.createValue(Double.parseDouble(s));
112
				} else if (v instanceof StringValue) {
113
					val = ValueFactory.createValue(s);
114
				} else if (v instanceof LongValue) {
115
					val = ValueFactory.createValue(Long.parseLong(s));
116
				} else if (v instanceof IntValue) {
117
					val = ValueFactory.createValue(Integer.parseInt(s));
118
				} else if (v instanceof FloatValue) {
119
					val = ValueFactory.createValue(Float.parseFloat(s));
120
				} else if (v instanceof ShortValue) {
121
					val = ValueFactory.createValue(Short.parseShort(s));
122
				} else if (v instanceof BooleanValue) {
123
					val = ValueFactory.createValue(Boolean.getBoolean(s));
124
				} else if (v instanceof DateValue) {
125
					val = ValueFactory.createValue(Date.parse(s));
126
				}
127
			}catch (NumberFormatException e) {
128
				JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Formato de n?mero erroneo")+".");
129
			}
130
		return val;
131
	}
132
}
0 133

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

  
49

  
50
import javax.swing.JLabel;
51
import javax.swing.JOptionPane;
52
import javax.swing.JPanel;
53
import javax.swing.JTextField;
54

  
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.ui.mdiManager.View;
57
import com.iver.andami.ui.mdiManager.ViewInfo;
58
import com.iver.cit.gvsig.fmap.rendering.FInterval;
59
import javax.swing.JButton;
60

  
61

  
62
/**
63
 * DOCUMENT ME!
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff