gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / script / ScriptListPickerController.java @ 1772
History | View | Annotate | Download (2.14 KB)
1 |
package org.gvsig.tools.swing.impl.script; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
import javax.swing.JButton; |
5 |
import javax.swing.JComboBox; |
6 |
import javax.swing.JList; |
7 |
import org.gvsig.tools.script.Script; |
8 |
import org.gvsig.tools.swing.api.pickercontroller.AbstractPickerController; |
9 |
|
10 |
/**
|
11 |
*
|
12 |
* @author jjdelcerro
|
13 |
*/
|
14 |
public class ScriptListPickerController extends AbstractPickerController<List<Script>> { |
15 |
private List<Script> scripts; |
16 |
private final JComboBox combo; |
17 |
private final JList list; |
18 |
private final JButton btnRemove; |
19 |
private final JButton btnChooser; |
20 |
|
21 |
public ScriptListPickerController(JComboBox combo, JButton remove, JButton chooser) { |
22 |
this.combo = combo;
|
23 |
this.list = null; |
24 |
this.btnChooser = chooser;
|
25 |
this.btnRemove = remove;
|
26 |
|
27 |
this.combo.setEnabled(false); |
28 |
|
29 |
this.initComponents();
|
30 |
} |
31 |
|
32 |
public ScriptListPickerController(JList list, JButton remove, JButton chooser) { |
33 |
this.combo = null; |
34 |
this.list = list;
|
35 |
this.btnChooser = chooser;
|
36 |
this.btnRemove = remove;
|
37 |
|
38 |
this.list.setEnabled(false); |
39 |
|
40 |
this.initComponents();
|
41 |
} |
42 |
|
43 |
private void initComponents() { |
44 |
this.btnRemove.setEnabled(false); |
45 |
this.btnRemove.setIcon(this.getIcon("picker-script-remove")); |
46 |
this.btnRemove.setText(""); |
47 |
this.btnChooser.setEnabled(false); |
48 |
this.btnChooser.setIcon(this.getIcon("picker-script")); |
49 |
this.btnChooser.setText(""); |
50 |
} |
51 |
|
52 |
@Override
|
53 |
public List<Script> get() { |
54 |
return this.scripts; |
55 |
} |
56 |
|
57 |
@Override
|
58 |
public void set(List<Script> value) { |
59 |
this.scripts = value;
|
60 |
} |
61 |
|
62 |
@Override
|
63 |
public void coerceAndSet(Object value) { |
64 |
if( value instanceof List ) { |
65 |
this.scripts = (List<Script>) value; |
66 |
return;
|
67 |
} |
68 |
String s = "null"; |
69 |
if( value != null ) { |
70 |
s = value.getClass().getName(); |
71 |
} |
72 |
throw new IllegalArgumentException("Can't coerce '"+s+"' to List of scripts."); |
73 |
} |
74 |
|
75 |
@Override
|
76 |
public void setEnabled(boolean enabled) { |
77 |
} |
78 |
|
79 |
@Override
|
80 |
public boolean isEnabled() { |
81 |
return false; |
82 |
} |
83 |
|
84 |
} |