4 package net.sf.openrocket.gui.customexpression;
6 import java.awt.event.MouseAdapter;
7 import java.awt.event.MouseEvent;
8 import java.util.ArrayList;
9 import java.util.Collections;
10 import java.util.Vector;
12 import javax.swing.JTable;
13 import javax.swing.table.AbstractTableModel;
14 import javax.swing.table.TableColumn;
15 import javax.swing.table.TableColumnModel;
17 import net.sf.openrocket.document.OpenRocketDocument;
18 import net.sf.openrocket.l10n.Translator;
19 import net.sf.openrocket.simulation.customexpression.CustomExpression;
20 import net.sf.openrocket.simulation.FlightDataType;
21 import net.sf.openrocket.startup.Application;
24 * @author Richard Graham
27 public class VariableTableModel extends AbstractTableModel {
29 private static final Translator trans = Application.getTranslator();
31 private ArrayList<FlightDataType> types = new ArrayList<FlightDataType>();
32 private static final String[] columnNames = {trans.get("customExpression.Name"), trans.get("customExpression.Symbol"), trans.get("customExpression.Units")};
35 * Table model will be constructed with all the built in variables and any custom variables defined
37 public VariableTableModel(OpenRocketDocument doc){
39 Collections.addAll(types, FlightDataType.ALL_TYPES);
41 for (CustomExpression expression : doc.getCustomExpressions()){
42 types.add(expression.getType());
47 public int getColumnCount() {
52 public int getRowCount() {
57 public Object getValueAt(int row, int col) {
59 return types.get(row).getName();
61 return types.get(row).getSymbol();
63 return types.get(row).getUnitGroup().getSIUnit().toString();
69 public String getColumnName(int col) {
70 return columnNames[col];
73 public String getSymbolAt(int row) {
74 if (row < 0 || row > types.size()){
78 return types.get(row).getSymbol();