1 package com.github.celldynamics.quimp.plugin.protanalysis;
2
3 import java.awt.event.ActionEvent;
4
5 import javax.swing.JComboBox;
6
7 import org.apache.commons.lang3.mutable.MutableInt;
8
9
10
11
12
13
14
15
16
17 @SuppressWarnings("serial")
18 public class ActionUpdateOptionsNumber extends ProtAnalysisAbstractAction {
19
20 private MutableInt val;
21
22
23
24
25
26
27
28
29
30 public ActionUpdateOptionsNumber(String name, String desc, ProtAnalysisUi ui,
31 MutableInt option) {
32 super(name, desc, ui);
33 this.val = option;
34 }
35
36
37
38
39
40
41
42
43 @Override
44 public void actionPerformed(ActionEvent e) {
45 JComboBox<?> cmp = ((JComboBox<?>) e.getSource());
46 Object item = cmp.getSelectedItem();
47 if (item instanceof Number) {
48 Number num = (Number) item;
49 val.setValue(num);
50 } else {
51 if (item instanceof String) {
52 int num = cmp.getSelectedIndex();
53 val.setValue(num);
54 } else {
55 throw new RuntimeException("This JComboBox is not supported");
56 }
57 }
58
59 logger.trace(ui.getModel().getOptions().serialize());
60
61 }
62
63 }