001/** A tab pane to display properties of a server workflow. 002 * 003 * Copyright (c) 2010 The Regents of the University of California. 004 * All rights reserved. 005 * 006 * '$Author: crawl $' 007 * '$Date: 2010-06-03 16:45:10 -0700 (Thu, 03 Jun 2010) $' 008 * '$Revision: 24730 $' 009 * 010 * Permission is hereby granted, without written agreement and without 011 * license or royalty fees, to use, copy, modify, and distribute this 012 * software and its documentation for any purpose, provided that the above 013 * copyright notice and the following two paragraphs appear in all copies 014 * of this software. 015 * 016 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 017 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 018 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 019 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 020 * SUCH DAMAGE. 021 * 022 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 023 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 025 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 026 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 027 * ENHANCEMENTS, OR MODIFICATIONS. 028 * 029 */ 030package org.kepler.workflowscheduler.gui; 031 032import java.awt.Component; 033 034import javax.swing.JLabel; 035import javax.swing.JList; 036import javax.swing.ListCellRenderer; 037 038import org.kepler.objectmanager.repository.Repository; 039 040/** 041 * A new rendered class to transform display WorkflowRunEngine/Repository object to 042 * workflow run engine/repository name 043 */ 044public class RepositoryAndRunEngineComboBoxRenderer extends JLabel implements ListCellRenderer 045{ 046 047 048 049 private String type = null; 050 /** 051 *Constructor 052 */ 053 public RepositoryAndRunEngineComboBoxRenderer(String type) 054 { 055 this.type = type; 056 setOpaque(true); 057 } 058 059 /** 060 *Display workflow run engine name 061 */ 062 public Component getListCellRendererComponent( 063 JList list, 064 Object value, 065 int index, 066 boolean isSelected, 067 boolean cellHasFocus) 068 { 069 if (isSelected) 070 { 071 setBackground(list.getSelectionBackground()); 072 setForeground(list.getSelectionForeground()); 073 } 074 else 075 { 076 setBackground(list.getBackground()); 077 setForeground(list.getForeground()); 078 } 079 080 if(type != null && type.equals(WorkflowSchedulerPanel.WORKFLOWRUNENGINECOMBOBOX)) 081 { 082 WorkflowRunEngine engine = (WorkflowRunEngine)value; 083 if(engine != null) 084 { 085 setText(engine.getName()); 086 } 087 088 } 089 else if(type != null && type.equals(WorkflowSchedulerPanel.DESTINATIONSERVERCOMBOBOX)) 090 { 091 Repository repository = (Repository)value; 092 if(repository != null) 093 { 094 setText(repository.getName()); 095 } 096 097 } 098 else 099 { 100 setText(value.toString()); 101 } 102 103 return this; 104 } 105 106 107}