Revision 44893

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/SymbolTable.java
27 27
import java.awt.Component;
28 28
import java.awt.Dimension;
29 29
import java.awt.GridLayout;
30
import java.util.Hashtable;
30
import java.util.HashMap;
31
import java.util.Map;
31 32

  
32 33
import javax.swing.JPanel;
33 34
import javax.swing.JScrollPane;
......
53 54
 */
54 55
public class SymbolTable extends JPanel {
55 56
	private static final long serialVersionUID = -8694846716328735113L;
56
	private static Hashtable<String,TableCellEditor> cellEditors = new Hashtable<String,TableCellEditor>();
57

  
57
  
58 58
	public static final String VALUES_TYPE = "values";
59 59
	public static final String INTERVALS_TYPE = "intervals";
60
	private JTable table;
61
	private String type;
62
	private int shapeType;
63 60

  
61
  private static final Map<String,TableCellEditor> CELL_EDITORS = new HashMap<>();
62
	
63
  private final JTable table;
64
	private final String type;
65
	private final int shapeType;
66

  
64 67
	public SymbolTable(Component ownerComponent, String type, int shapeType) {
65 68
    this(new org.gvsig.utils.swing.jtable.JTable(), ownerComponent, type, shapeType);
66 69
  }
......
91 94
		// initColumnSizes(table);
92 95
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
93 96

  
94
		if(cellEditors.get(type) == null)
97
		if(CELL_EDITORS.get(type) == null)
95 98
			throw new Error("Symbol table type not set!");
96 99

  
97
		setUpValueColumn(table, table.getColumnModel().getColumn(1),cellEditors.get(this.type));
100
		setUpValueColumn(table, table.getColumnModel().getColumn(1),CELL_EDITORS.get(this.type));
98 101
		setUpLabelColumn(table, table.getColumnModel().getColumn(2));
99 102

  
100 103
		// Add the scroll pane to this panel.
......
113 116
	 * Inicializa los valores de los CellEditors que la SymbolTable poseer? por defecto
114 117
	 */
115 118
	private void initializeCellEditors() {
116
		this.cellEditors.put(this.INTERVALS_TYPE,new IntervalCellEditor());
117
		this.cellEditors.put(this.VALUES_TYPE, new ValueCellEditor());
119
		this.CELL_EDITORS.put(this.INTERVALS_TYPE,new IntervalCellEditor());
120
		this.CELL_EDITORS.put(this.VALUES_TYPE, new ValueCellEditor());
118 121
	}
119 122
	/**
120 123
	 * A?ade un nuevo CellEditor a la lista de disponibles
......
123 126
	 * @param cellEditor CellEditor que va a ser a?adido
124 127
	 */
125 128
	public static void addNewCellEditor(String key,TableCellEditor cellEditor ) {
126
		cellEditors.put(key, cellEditor);
129
		CELL_EDITORS.put(key, cellEditor);
127 130
	}
128 131
	/**
129 132
	 * Obtiene el valor de los elementos de una fila seleccionada
......
269 272
	public void removeAllItems() {
270 273
		table.setModel(new MyTableModel());
271 274
		setUpSymbolColumn(table, table.getColumnModel().getColumn(0));
272
		setUpValueColumn(table, table.getColumnModel().getColumn(1),cellEditors.get(this.type));
275
		setUpValueColumn(table, table.getColumnModel().getColumn(1),CELL_EDITORS.get(this.type));
273 276
		setUpLabelColumn(table, table.getColumnModel().getColumn(2));
274 277
	}
275 278

  
......
324 327
		column.setCellRenderer(renderer);
325 328
	}
326 329

  
327
	/**
328
	 * Modelo que propio que se aplica a la tabla.
329
	 *
330
	 * @author Vicente Caballero Navarro
331
	 */
332 330
	class MyTableModel extends DefaultTableModel {
333
		private static final long serialVersionUID = 1L;
334 331

  
335
		// AbstractTableModel {
336
		private String[] columnNames = {
332
		private final String[] columnNames = {
337 333
				PluginServices.getText(this, "Simbolo"),
338 334
				PluginServices.getText(this, "Valor"),
339 335
				PluginServices.getText(this, "Etiqueta") };
340 336

  
341
		/**
342
		 * Devuelve el n?mero de columnas.
343
		 *
344
		 * @return N?mero de columnas.
345
		 */
337
    @Override
346 338
		public int getColumnCount() {
347 339
			return columnNames.length;
348 340
		}
349 341

  
350
		/**
351
		 * Devuelve el String del valor de la columna.
352
		 *
353
		 * @param col
354
		 *            N?mero de columna.
355
		 *
356
		 * @return Nombre de la columna.
357
		 */
342
    @Override
358 343
		public String getColumnName(int col) {
359 344
			return columnNames[col];
360 345
		}
361 346

  
347
    @Override
362 348
		public Class getColumnClass(int c) {
363 349
            switch (c) {
364 350
            case 0:
......
374 360
            }
375 361
		}
376 362

  
377
		/*
378
		 * Don't need to implement this method unless your table's editable.
379
		 */
363
    @Override
380 364
		public boolean isCellEditable(int row, int col) {
381
			// Note that the data/cell address is constant,
382
			// no matter where the cell appears onscreen.
383
			// if (col > 0) {
384 365
			return true;
385 366
		}
386 367

  

Also available in: Unified diff