components/visual-panels/smf/src/java/vpanels/app/svcs/com/oracle/solaris/vp/panels/svcs/client/swing/StatePropInfo.java
changeset 3553 f1d133b09a8c
parent 3552 077ebe3d0d24
child 3554 ef58713bafc4
equal deleted inserted replaced
3552:077ebe3d0d24 3553:f1d133b09a8c
     1 /*
       
     2  * CDDL HEADER START
       
     3  *
       
     4  * The contents of this file are subject to the terms of the
       
     5  * Common Development and Distribution License (the "License").
       
     6  * You may not use this file except in compliance with the License.
       
     7  *
       
     8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9  * or http://www.opensolaris.org/os/licensing.
       
    10  * See the License for the specific language governing permissions
       
    11  * and limitations under the License.
       
    12  *
       
    13  * When distributing Covered Code, include this CDDL HEADER in each
       
    14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15  * If applicable, add the following below this CDDL HEADER, with the
       
    16  * fields enclosed by brackets "[]" replaced with your own identifying
       
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
       
    18  *
       
    19  * CDDL HEADER END
       
    20  */
       
    21 
       
    22 /*
       
    23  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.panels.svcs.client.swing;
       
    27 
       
    28 import java.awt.Component;
       
    29 import java.util.Comparator;
       
    30 import javax.swing.*;
       
    31 import javax.swing.table.*;
       
    32 import com.oracle.solaris.vp.panel.common.api.smf_old.SmfState;
       
    33 import com.oracle.solaris.vp.panel.common.smf.*;
       
    34 import com.oracle.solaris.vp.util.misc.finder.Finder;
       
    35 
       
    36 public class StatePropInfo extends SMOPropInfo<InstanceManagedObject, SmfState>
       
    37 {
       
    38     /*
       
    39      * Static data
       
    40      */
       
    41 
       
    42     @SuppressWarnings({"serial"})
       
    43     private static final TableCellRenderer renderer =
       
    44 	new DefaultTableCellRenderer() {
       
    45 	    @Override
       
    46 	    public Component getTableCellRendererComponent(
       
    47 		JTable table, Object value, boolean isSelected,
       
    48 		boolean hasFocus, int row, int column)
       
    49 	    {
       
    50 		SmfState state = (SmfState)value;
       
    51 		String statestr = ServiceUtil.getStateString(state);
       
    52 		JLabel label = (JLabel)super.getTableCellRendererComponent(
       
    53 		    table, statestr, isSelected, hasFocus, row, column);
       
    54 
       
    55 		return (label);
       
    56 	    }
       
    57 	};
       
    58 
       
    59     private static final Comparator<SmfState> comparator =
       
    60 	new Comparator<SmfState>() {
       
    61 	    @Override
       
    62 	    public int compare(SmfState o1, SmfState o2)
       
    63 	    {
       
    64 		return (o1.compareTo(o2));
       
    65 	    }
       
    66 	};
       
    67 
       
    68     /**
       
    69      * Available instance to mitigate object creation
       
    70      */
       
    71     public static final StatePropInfo instance = new StatePropInfo();
       
    72 
       
    73     /*
       
    74      * Constructors
       
    75      */
       
    76 
       
    77     public StatePropInfo() {
       
    78 	super(Finder.getString("smf.objects.label.state"),
       
    79 	    Finder.getString("smf.objects.description.state"),
       
    80 	    renderer, comparator);
       
    81     }
       
    82 
       
    83     public SmfState getValue(InstanceManagedObject o) {
       
    84 	return (o.getSMFState());
       
    85     }
       
    86 }