001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008 Sun Microsystems, Inc.
015 * Portions Copyright 2015-2016 ForgeRock AS.
016 */
017package org.opends.guitools.controlpanel.ui.renderer;
018
019import java.awt.Component;
020
021import javax.swing.JTable;
022
023import org.opends.guitools.controlpanel.datamodel.BaseDNTableModel;
024import org.opends.guitools.controlpanel.util.Utilities;
025
026/** Class used to render the base DN table cells. */
027public class BaseDNCellRenderer extends CustomCellRenderer
028{
029  private static final long serialVersionUID = -256719167426289735L;
030
031  /** Default constructor. */
032  public BaseDNCellRenderer()
033  {
034    super();
035  }
036
037  @Override
038  public Component getTableCellRendererComponent(JTable table, Object value,
039      boolean isSelected, boolean hasFocus, int row, int column) {
040    String text = (String)value;
041    if (text == BaseDNTableModel.NOT_AVAILABLE)
042    {
043      Utilities.setNotAvailable(this);
044    }
045    else if (text == BaseDNTableModel.NOT_AVAILABLE_AUTHENTICATION_REQUIRED)
046    {
047      Utilities.setNotAvailableBecauseAuthenticationIsRequired(this);
048    }
049    else if (text == BaseDNTableModel.NOT_AVAILABLE_SERVER_DOWN)
050    {
051      Utilities.setNotAvailableBecauseServerIsDown(this);
052    }
053    else
054    {
055      Utilities.setTextValue(this, text);
056    }
057    return super.getTableCellRendererComponent(table, getText(),
058        isSelected, hasFocus, row, column);
059  }
060}