View Javadoc

1   // %827897234:hoplugins.trainingExperience.ui%
2   package hoplugins.trainingExperience.ui;
3   
4   import hoplugins.commons.ui.BaseTableModel;
5   
6   import plugins.ISkillup;
7   
8   import java.awt.event.MouseEvent;
9   
10  import javax.swing.JTable;
11  import javax.swing.table.TableModel;
12  
13  
14  /***
15   * Table for players past and future skillups
16   *
17   * @author <a href=mailto:draghetto@users.sourceforge.net>Massimiliano Amato</a>
18   */
19  public class SkillupTable extends JTable {
20      //~ Constructors -------------------------------------------------------------------------------
21  
22      /***
23       * Creates a new SkillupTable object.
24       *
25       * @param tableModel The table model to be used
26       */
27      public SkillupTable(BaseTableModel tableModel) {
28          super(tableModel);
29      }
30  
31      //~ Methods ------------------------------------------------------------------------------------
32  
33      /***
34       * Return string toolTip for the skillup
35       *
36       * @param e MouseEvent of being over the cell
37       *
38       * @return String toolTip for active skillup
39       */
40      public String getToolTipText(MouseEvent e) {
41          TableModel tableModel = (TableModel) getModel();
42          java.awt.Point p = e.getPoint();
43          int rowIndex = rowAtPoint(p);
44          int type = ISkillup.SKILLUP_FUTURE;
45  
46          try {
47              type = Integer.parseInt((String) tableModel.getValueAt(rowIndex, 3));
48          } catch (NumberFormatException ex) {
49          }
50  
51          if (type == ISkillup.SKILLUP_REAL) {
52              Object obj = tableModel.getValueAt(rowIndex, 4);
53  
54              return obj.toString();
55          }
56  
57          return ""; //$NON-NLS-1$
58      }
59  }