Revision 2846 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/DropDownLabel.java
DropDownLabel.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.BorderLayout; |
4 | 4 |
import java.awt.Color; |
5 |
import java.awt.Component; |
|
5 | 6 |
import java.awt.Cursor; |
6 | 7 |
import java.awt.Point; |
7 | 8 |
import java.awt.event.ActionEvent; |
8 | 9 |
import java.awt.event.ActionListener; |
10 |
import java.awt.event.FocusEvent; |
|
11 |
import java.awt.event.FocusListener; |
|
9 | 12 |
import java.awt.event.ItemEvent; |
10 | 13 |
import java.awt.event.ItemListener; |
11 | 14 |
import java.awt.event.MouseAdapter; |
... | ... | |
23 | 26 |
import javax.swing.JMenuItem; |
24 | 27 |
import javax.swing.JPopupMenu; |
25 | 28 |
import javax.swing.UIManager; |
29 |
import org.apache.commons.lang3.ArrayUtils; |
|
26 | 30 |
import org.apache.commons.lang3.StringUtils; |
27 | 31 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
28 | 32 |
import org.gvsig.tools.swing.api.DropDown; |
29 | 33 |
import org.gvsig.tools.util.LabeledValue; |
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
30 | 36 |
|
31 | 37 |
/** |
32 | 38 |
* |
... | ... | |
35 | 41 |
@SuppressWarnings("UseSpecificCatch") |
36 | 42 |
public class DropDownLabel implements DropDown { |
37 | 43 |
|
44 |
protected static final Logger LOGGER = LoggerFactory.getLogger(DropDownLabel.class); |
|
45 |
|
|
38 | 46 |
private final JComponent component; |
39 | 47 |
private final Set<ItemListener> itemListeners; |
40 | 48 |
private ComboBoxModel model; |
... | ... | |
131 | 139 |
this.arrow.setEnabled(enabled); |
132 | 140 |
} |
133 | 141 |
|
142 |
|
|
134 | 143 |
private void doShowPopup() { |
144 |
Utils.fireFocusEvent(this.component, FocusEvent.FOCUS_GAINED); |
|
135 | 145 |
ActionEvent ev = new ActionEvent(this, 0, null); |
136 | 146 |
dropdownListsnersHelper.fireActionEvent(ev); |
137 | 147 |
if (model == null) { |
... | ... | |
212 | 222 |
|
213 | 223 |
@Override |
214 | 224 |
public void setValue(Object value) { |
215 |
ComboBoxModel model = this.getModel();
|
|
216 |
if (model == null) {
|
|
225 |
ComboBoxModel theModel = this.getModel();
|
|
226 |
if (theModel == null) {
|
|
217 | 227 |
throw new IllegalStateException("Can't set value when model is null"); |
218 | 228 |
} |
219 |
for (int i = 0; i < model.getSize(); i++) {
|
|
220 |
Object item = model.getElementAt(i);
|
|
229 |
for (int i = 0; i < theModel.getSize(); i++) {
|
|
230 |
Object item = theModel.getElementAt(i);
|
|
221 | 231 |
if (item instanceof LabeledValue) { |
222 | 232 |
item = ((LabeledValue) item).getValue(); |
223 | 233 |
} |
Also available in: Unified diff