Blame view

src/mior/controler/ConfigureRandomAction.java 932 Bytes
1b1e928cc   glaville   initial import of...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  package mior.controler;
  
  import java.awt.event.ActionEvent;
  
  import javax.swing.AbstractButton;
  import javax.swing.Action;
  
  import mior.model.IMiorModel;
  
  public class ConfigureRandomAction extends AbstractMiorAction<IMiorModel> {
  
  	private static final long serialVersionUID = 1L;
  
  	public ConfigureRandomAction(IMiorModel data) {
  		super(data, "Enable randomization");
  	}
  
  	@Override
  	public void actionPerformed(ActionEvent e) {
  		AbstractButton src = (AbstractButton) e.getSource();
  		getData().setRandomEnabled(src.isSelected());
  	}
  	
  	@Override
  	public Object getValue(String key) {
  		if (Action.SELECTED_KEY.equals(key)) {
  			return getData().isRandomEnabled();
  		} else {
  			return super.getValue(key);
  		}
  	}
  	
  	@Override
  	public void putValue(String key, Object newValue) {
  		if (Action.SELECTED_KEY.equals(key)) {
  			getData().setRandomEnabled((Boolean) newValue);
  		} else {
  			super.putValue(key, newValue);
  		}
  	}
  	
  }