4518N/A/*
4518N/A * CDDL HEADER START
4518N/A *
4518N/A * The contents of this file are subject to the terms of the
4518N/A * Common Development and Distribution License, Version 1.0 only
4518N/A * (the "License"). You may not use this file except in compliance
4518N/A * with the License.
4518N/A *
4518N/A * You can obtain a copy of the license at
4518N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
4518N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
4518N/A * See the License for the specific language governing permissions
4518N/A * and limitations under the License.
4518N/A *
4518N/A * When distributing Covered Code, include this CDDL HEADER in each
4518N/A * file and include the License file at
4518N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
4518N/A * add the following below this CDDL HEADER, with the fields enclosed
4518N/A * by brackets "[]" replaced with your own identifying information:
4518N/A * Portions Copyright [yyyy] [name of copyright owner]
4518N/A *
4518N/A * CDDL HEADER END
4518N/A *
4518N/A *
4518N/A * Copyright 2009 Sun Microsystems, Inc.
4518N/A */
4518N/Apackage org.opends.guitools.controlpanel.ui.renderer;
4518N/A
4518N/Aimport java.awt.Component;
4518N/A
4518N/Aimport javax.swing.JComboBox;
4518N/Aimport javax.swing.JLabel;
4518N/Aimport javax.swing.JList;
4518N/A
4518N/Aimport org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
4518N/A/**
4518N/A * This class is used simply to avoid an inset on the left for the
4518N/A * elements of the combo box.
4518N/A * Since this item is a CategorizedComboBoxElement of type
4518N/A * CategorizedComboBoxElement.Type.REGULAR, it has by default an inset on
4518N/A * the left.
4518N/A */
4518N/Apublic class NoLeftInsetCategoryComboBoxRenderer extends CustomListCellRenderer
4518N/A{
4518N/A /**
4518N/A * The constructor.
4518N/A * @param combo the combo box to be rendered.
4518N/A */
4518N/A public NoLeftInsetCategoryComboBoxRenderer(JComboBox combo)
4518N/A {
4518N/A super(combo);
4518N/A }
4518N/A
4518N/A /**
4518N/A * {@inheritDoc}
4518N/A */
4518N/A public Component getListCellRendererComponent(JList list, Object value,
4518N/A int index, boolean isSelected, boolean cellHasFocus)
4518N/A {
4518N/A Component comp = super.getListCellRendererComponent(list, value, index,
4518N/A isSelected, cellHasFocus);
4518N/A if (value instanceof CategorizedComboBoxElement)
4518N/A {
4518N/A CategorizedComboBoxElement element = (CategorizedComboBoxElement)value;
4518N/A String name = getStringValue(element);
4518N/A ((JLabel)comp).setText(name);
4518N/A }
4518N/A comp.setFont(defaultFont);
4518N/A return comp;
4518N/A }
4518N/A}