Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / src / net / sf / openrocket / gui / customexpression / OperatorTableModel.java
diff --git a/core/src/net/sf/openrocket/gui/customexpression/OperatorTableModel.java b/core/src/net/sf/openrocket/gui/customexpression/OperatorTableModel.java
new file mode 100644 (file)
index 0000000..3b084da
--- /dev/null
@@ -0,0 +1,52 @@
+package net.sf.openrocket.gui.customexpression;
+
+import javax.swing.table.AbstractTableModel;
+
+import net.sf.openrocket.l10n.Translator;
+import net.sf.openrocket.simulation.customexpression.Functions;
+import net.sf.openrocket.startup.Application;
+
+public class OperatorTableModel extends AbstractTableModel {
+
+       private static final Translator trans = Application.getTranslator();
+       
+       private static final String[] columnNames = {trans.get("customExpression.Operator"), trans.get("customExpression.Description")};
+       
+       private final Object[] operators = Functions.AVAILABLE_OPERATORS.keySet().toArray();
+       private final Object[] descriptions = Functions.AVAILABLE_OPERATORS.values().toArray();
+       
+       public OperatorTableModel(){
+               
+       }
+       
+       @Override
+       public int getColumnCount() {
+               return 2;
+       }
+
+       @Override
+       public int getRowCount() {
+               return Functions.AVAILABLE_OPERATORS.size();
+       }
+
+       @Override
+       public Object getValueAt(int row, int col) {
+               if (col == 0){
+                       return operators[row].toString();
+               }
+               else if (col == 1){
+                       return descriptions[row].toString();
+               }
+               return null;
+       }
+       
+       @Override
+       public String getColumnName(int col) {
+        return columnNames[col];
+    }
+       
+       public String getOperatorAt(int row) {
+               return operators[row].toString();
+       }
+
+}