Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.gui / src / main / java / es / unex / sextante / gui / algorithm / FieldComboBoxRenderer.java @ 315

History | View | Annotate | Download (1.19 KB)

1
package es.unex.sextante.gui.algorithm;
2

    
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
import java.awt.Component;
9

    
10
import javax.swing.DefaultListCellRenderer;
11
import javax.swing.Icon;
12
import javax.swing.JLabel;
13
import javax.swing.JList;
14
import javax.swing.ListCellRenderer;
15

    
16
public class FieldComboBoxRenderer implements ListCellRenderer {
17
  protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
18

    
19
  @Override
20
  public Component getListCellRendererComponent(JList list, Object value, int index,
21
      boolean isSelected, boolean cellHasFocus) {
22
    
23
    JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
24
        isSelected, cellHasFocus);
25

    
26
    if (value instanceof FieldDescriptionComboBox) {
27
        FieldDescriptionComboBox v = (FieldDescriptionComboBox) value;
28
        Icon theIcon = new IconFieldComboBoxRenderer(v.getFieldType());
29
        String name = v.getDescription() + " ["+v.getFieldType()+"]";
30

    
31
        renderer.setIcon(theIcon);
32
        renderer.setText(name);
33
    }
34
    return renderer;
35
  }
36
}