fr.ird.observe.client.util.list.DataReferenceListCellRenderer Maven / Gradle / Ivy
package fr.ird.observe.client.util.list;
/*-
* #%L
* ObServe Toolkit :: Common Client
* %%
* Copyright (C) 2008 - 2017 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import fr.ird.observe.dto.reference.DataDtoReference;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
/**
* Un renderer de liste d'entites d'un referentiel dans le quel on veut
* differencier les entites qui sont desactivees.
*
* @author Tony Chemit - [email protected]
* @since 1.2
*/
public class DataReferenceListCellRenderer implements ListCellRenderer {
/** la couleur normal pour les entites non desactivees */
private Color normalColor;
private ListCellRenderer super R> delegate;
public DataReferenceListCellRenderer(ListCellRenderer super R> delegate) {
this.delegate = delegate;
}
@Override
public Component getListCellRendererComponent(JList extends R> list, R value, int index, boolean isSelected, boolean cellHasFocus) {
JComponent comp;
comp = (JComponent) delegate.getListCellRendererComponent(
list,
value,
index,
isSelected,
cellHasFocus);
if (normalColor == null) {
// premiere fois, on intialise la couleur dite normale
normalColor = comp.getForeground();
}
// par defaut, on utilise la couleur normale
Color col = normalColor;
comp.setForeground(col);
return comp;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy