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 ForgeRock AS. 016 */ 017 018package org.opends.guitools.controlpanel.ui.renderer; 019 020import java.awt.Component; 021 022import javax.swing.JTable; 023 024import org.opends.guitools.controlpanel.datamodel.BaseDNTableModel; 025import org.opends.guitools.controlpanel.util.Utilities; 026 027/** 028 * Class used to render the base DN table cells. 029 */ 030public class BaseDNCellRenderer extends CustomCellRenderer 031{ 032 private static final long serialVersionUID = -256719167426289735L; 033 034 /** 035 * Default constructor. 036 */ 037 public BaseDNCellRenderer() 038 { 039 super(); 040 } 041 042 /** {@inheritDoc} */ 043 public Component getTableCellRendererComponent(JTable table, Object value, 044 boolean isSelected, boolean hasFocus, int row, int column) { 045 String text = (String)value; 046 if (text == BaseDNTableModel.NOT_AVAILABLE) 047 { 048 Utilities.setNotAvailable(this); 049 } 050 else if (text == BaseDNTableModel.NOT_AVAILABLE_AUTHENTICATION_REQUIRED) 051 { 052 Utilities.setNotAvailableBecauseAuthenticationIsRequired(this); 053 } 054 else if (text == BaseDNTableModel.NOT_AVAILABLE_SERVER_DOWN) 055 { 056 Utilities.setNotAvailableBecauseServerIsDown(this); 057 } 058 else 059 { 060 Utilities.setTextValue(this, text); 061 } 062 return super.getTableCellRendererComponent(table, getText(), 063 isSelected, hasFocus, row, column); 064 } 065}