76a1a8f2d9ee1e777220996489e9d5f4c130d4bb
[debian/openrocket] / core / src / net / sf / openrocket / gui / customexpression / OperatorTableModel.java
1 package net.sf.openrocket.gui.customexpression;
2
3 import javax.swing.table.AbstractTableModel;
4
5 import net.sf.openrocket.l10n.Translator;
6 import net.sf.openrocket.simulation.CustomExpression;
7 import net.sf.openrocket.startup.Application;
8
9 public class OperatorTableModel extends AbstractTableModel {
10
11         private static final Translator trans = Application.getTranslator();
12         
13         private static final String[] columnNames = {trans.get("customExpression.Operator"), trans.get("customExpression.Description")};
14         
15         private final Object[] operators = CustomExpression.AVAILABLE_OPERATORS.keySet().toArray();
16         private final Object[] descriptions = CustomExpression.AVAILABLE_OPERATORS.values().toArray();
17         
18         public OperatorTableModel(){
19                 
20         }
21         
22         @Override
23         public int getColumnCount() {
24                 return 2;
25         }
26
27         @Override
28         public int getRowCount() {
29                 return CustomExpression.AVAILABLE_OPERATORS.size();
30         }
31
32         @Override
33         public Object getValueAt(int row, int col) {
34                 if (col == 0){
35                         return operators[row].toString();
36                 }
37                 else if (col == 1){
38                         return descriptions[row].toString();
39                 }
40                 return null;
41         }
42         
43         @Override
44         public String getColumnName(int col) {
45         return columnNames[col];
46     }
47         
48         public String getOperatorAt(int row) {
49                 return operators[row].toString();
50         }
51
52 }