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 2009 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.BorderFactory; 023import javax.swing.JTable; 024import javax.swing.border.Border; 025import javax.swing.table.DefaultTableCellRenderer; 026 027import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; 028 029/** 030 * Class used to render the task tables. 031 */ 032public class TaskCellRenderer extends DefaultTableCellRenderer 033{ 034 private static final long serialVersionUID = -84332267021523835L; 035 /** 036 * The border of the first column. 037 * TODO: modify CustomCellRenderer to make this public. 038 */ 039 protected static final Border column0Border = 040 BorderFactory.createCompoundBorder( 041 BorderFactory.createMatteBorder(0, 1, 0, 0, 042 ColorAndFontConstants.gridColor), 043 BorderFactory.createEmptyBorder(4, 4, 4, 4)); 044 /** 045 * The default border. 046 */ 047 public static final Border defaultBorder = CustomCellRenderer.defaultBorder; 048 049 /** 050 * Default constructor. 051 */ 052 public TaskCellRenderer() 053 { 054 setFont(ColorAndFontConstants.tableFont); 055 setOpaque(true); 056 setBackground(ColorAndFontConstants.treeBackground); 057 setForeground(ColorAndFontConstants.treeForeground); 058 } 059 060 /** {@inheritDoc} */ 061 public Component getTableCellRendererComponent(JTable table, Object value, 062 boolean isSelected, boolean hasFocus, int row, int column) { 063 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, 064 row, column); 065 066 if (hasFocus) 067 { 068 setBorder( 069 CustomCellRenderer.getDefaultFocusBorder(table, value, isSelected, 070 row, column)); 071 } 072 else if (column == 0) 073 { 074 setBorder(column0Border); 075 } 076 else 077 { 078 setBorder(defaultBorder); 079 } 080 return this; 081 } 082} 083