blob: ed00f4cf18610a8034b42561ea3a73f30566164b (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*******************************************************************************
* Copyright (c) 2007, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
import javax.swing.ListCellRenderer;
import org.eclipse.jpt.common.utility.internal.model.value.ExtendedListValueModelWrapper;
import org.eclipse.jpt.common.utility.internal.swing.SimpleListCellRenderer;
import org.eclipse.jpt.common.utility.model.value.ListValueModel;
/**
*
*/
@SuppressWarnings("nls")
public class ComboBoxModelAdapterUITest2 extends ComboBoxModelAdapterUITest {
public static void main(String[] args) throws Exception {
new ComboBoxModelAdapterUITest2().exec();
}
public ComboBoxModelAdapterUITest2() {
super();
}
/**
* use a different model that allows the color to be set to null
*/
@Override
protected TestModel buildTestModel() {
return new TestModel2();
}
/**
* add a null to the front of the list
*/
@Override
protected ListValueModel<String> uiColorListHolder() {
// the default is to prepend the wrapped list with a null item
return new ExtendedListValueModelWrapper<String>(super.uiColorListHolder());
}
/**
* convert null to some text
*/
@Override
protected ListCellRenderer buildComboBoxRenderer() {
return new SimpleListCellRenderer() {
@Override
protected String buildText(Object value) {
return (value == null) ? "<none selected>" : super.buildText(value);
}
};
}
protected static class TestModel2 extends TestModel {
/**
* null is OK here
*/
@Override
public void checkColor(String color) {
if (color == null) {
return;
}
super.checkColor(color);
}
}
}
|