Added address column to instruction editor
[Mograsim.git] / net.mograsim.plugin.core / src / net / mograsim / plugin / tables / mi / IntegerEditingSupport.java
1 package net.mograsim.plugin.tables.mi;
2
3 import java.math.BigInteger;
4
5 import org.eclipse.jface.viewers.TableViewer;
6
7 import net.mograsim.machine.mi.MicroInstructionDefinition;
8 import net.mograsim.machine.mi.parameters.IntegerClassification;
9 import net.mograsim.machine.mi.parameters.IntegerImmediate;
10 import net.mograsim.plugin.tables.DisplaySettings;
11 import net.mograsim.plugin.tables.NumberCellEditingSupport;
12
13 public class IntegerEditingSupport extends NumberCellEditingSupport
14 {
15         private IntegerClassification classification;
16         private int index;
17
18         public IntegerEditingSupport(TableViewer viewer, MicroInstructionDefinition miDef, int index, DisplaySettings displaySettings)
19         {
20                 super(viewer, displaySettings);
21                 classification = (IntegerClassification) miDef.getParameterClassifications()[index];
22                 this.index = index;
23         }
24
25         @Override
26         protected void setAsBigInteger(Object element, BigInteger value)
27         {
28                 ((InstructionTableRow) element).data.setParameter(index, new IntegerImmediate(value, classification.getExpectedBits()));
29         }
30
31         @Override
32         protected BigInteger getAsBigInteger(Object element)
33         {
34                 return ((IntegerImmediate) ((InstructionTableRow) element).data.getParameter(index)).getValueAsBigInteger();
35         }
36
37 }