Removed some more warnings and cleaned more SWT listeners
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / tables / RadixSelector.java
1 package net.mograsim.plugin.tables;
2
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.widgets.Combo;
5 import org.eclipse.swt.widgets.Composite;
6 import org.eclipse.swt.widgets.Label;
7
8 import net.mograsim.plugin.asm.AsmNumberUtil.NumberType;
9
10 public class RadixSelector
11 {
12         private final Composite parent;
13         private final DisplaySettings target;
14         private Label label;
15         private Combo combo;
16
17         public RadixSelector(Composite parent, DisplaySettings target)
18         {
19                 this.parent = parent;
20                 this.target = target;
21                 setupRadixSelector();
22         }
23
24         private void setupRadixSelector()
25         {
26                 label = new Label(parent, SWT.NONE);
27                 label.setText("Radix: ");
28                 combo = new Combo(parent, SWT.READ_ONLY);
29
30                 String entries[] = new String[] { "Binary", "Octal", "Decimal", "Hexadecimal" };
31                 NumberType corTypes[] = new NumberType[] { NumberType.BINARY, NumberType.OCTAL, NumberType.DECIMAL, NumberType.HEXADECIMAL };
32                 combo.setItems(entries);
33                 combo.select(3);
34                 combo.addListener(SWT.Selection, e ->
35                 {
36                         int index = combo.getSelectionIndex();
37                         if (index == -1)
38                                 target.setDataNumberType(NumberType.HEXADECIMAL);
39                         else
40                                 target.setDataNumberType(corTypes[index]);
41                 });
42         }
43
44         public Label getLabel()
45         {
46                 return label;
47         }
48
49         public Combo getCombo()
50         {
51                 return combo;
52         }
53 }