001/**
002 * Copyright (c) 2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: crawl $'
006 * '$Date: 2010-06-03 16:45:10 -0700 (Thu, 03 Jun 2010) $' 
007 * '$Revision: 24730 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029package org.kepler.workflowscheduler.gui.configurationwizard;
030
031import javax.swing.table.AbstractTableModel;
032
033import org.kepler.workflowscheduler.gui.WorkflowRunEngine;
034
035/**
036 * A table model represents the data model for display a known workflow run engines.
037 * @author tao
038 *
039 */
040public class KnownWorkflowRunEngineTableModel extends AbstractTableModel
041{
042  
043  private static final String[] COLUMNNAMES = {"Workflow Run Engines" }; 
044  private static final int NAMECOL =  0;
045  private static final String UNKNOWN = "Unknown";
046  private WorkflowRunEngine[] engineList = null; 
047 
048  
049  /**
050   * Constructor
051   * @param engineList
052   */
053  public KnownWorkflowRunEngineTableModel(WorkflowRunEngine[] engineList)
054  {
055    this.engineList = engineList;
056  }
057  /**
058   * Get the number of row 
059   */
060  public int getRowCount()
061  {
062    if(engineList == null)
063    {
064      return 0;
065    }
066    else
067    {
068      return engineList.length;
069    }
070  }
071  
072  /**
073   * Get the number of column
074   */
075  public int getColumnCount()
076  {
077    return COLUMNNAMES.length;
078  }
079  
080  /**
081   * Get the value of the cell at row and column.
082   */
083  public Object getValueAt(int row, int column)
084  {
085    String returnValue = UNKNOWN;
086    if(engineList != null)
087    {
088      WorkflowRunEngine engine = engineList[row];
089      if(engine != null)
090      {
091       
092        switch(column)
093        {
094          case NAMECOL:
095                  returnValue = engine.getName();
096                  break;
097          default:
098                 break;
099         
100        }
101      }
102    }
103    return returnValue;
104  }
105  
106  /**
107   * Get the column name
108   */
109  public String getColumnName(int columnIndex)
110  {
111    return COLUMNNAMES[columnIndex];
112  }
113
114}