Lines 44-49
Link Here
|
44 |
import java.lang.reflect.InvocationTargetException; |
44 |
import java.lang.reflect.InvocationTargetException; |
45 |
import javax.swing.JCheckBox; |
45 |
import javax.swing.JCheckBox; |
46 |
import org.netbeans.junit.NbTestCase; |
46 |
import org.netbeans.junit.NbTestCase; |
|
|
47 |
import org.openide.awt.Mnemonics; |
47 |
import org.openide.nodes.Node; |
48 |
import org.openide.nodes.Node; |
48 |
|
49 |
|
49 |
/* |
50 |
/* |
Lines 113-118
Link Here
|
113 |
} |
114 |
} |
114 |
|
115 |
|
115 |
|
116 |
|
|
|
117 |
public void testGetDisplayNameWithMnemonic() { |
118 |
MyNodeTableModel model = new MyNodeTableModel( 0 ); |
119 |
|
120 |
MyProperty p; |
121 |
JCheckBox checkBox; |
122 |
|
123 |
p = new MyProperty(); |
124 |
p.setDisplayName( "displayName1" ); |
125 |
p.setShortDescription( "shortDescription1" ); |
126 |
p.setValue( "ColumnMnemonicCharTTV", "" ); |
127 |
|
128 |
assertEquals( "Invalid display name:", model.getDisplayNameWithMnemonic(p), p.getDisplayName() ); |
129 |
|
130 |
|
131 |
p = new MyProperty(); |
132 |
p.setDisplayName( "displayName1" ); |
133 |
p.setShortDescription( "shortDescription1" ); |
134 |
p.setValue( "ColumnDisplayNameWithMnemonicTTV", "otherDisplayName" ); |
135 |
p.setValue( "ColumnMnemonicCharTTV", "" ); |
136 |
checkBox = new JCheckBox( model.getDisplayNameWithMnemonic(p) ); |
137 |
Mnemonics.setLocalizedText(checkBox, checkBox.getText()); |
138 |
model.makeAccessibleCheckBox( checkBox, p ); |
139 |
|
140 |
assertEquals( "Invalid display name:", |
141 |
p.getValue("ColumnDisplayNameWithMnemonicTTV"), |
142 |
model.getDisplayNameWithMnemonic(p) ); |
143 |
assertEquals( "Invalid mnemonic", 0, checkBox.getMnemonic() ); |
144 |
|
145 |
|
146 |
p = new MyProperty(); |
147 |
p.setDisplayName( "displayName1" ); |
148 |
p.setShortDescription( "shortDescription1" ); |
149 |
p.setValue( "ColumnDisplayNameWithMnemonicTTV", "otherDisplayName" ); |
150 |
p.setValue( "ColumnMnemonicCharTTV", "t" ); |
151 |
checkBox = new JCheckBox( model.getDisplayNameWithMnemonic(p) ); |
152 |
Mnemonics.setLocalizedText(checkBox, checkBox.getText()); |
153 |
model.makeAccessibleCheckBox( checkBox, p ); |
154 |
|
155 |
assertEquals( "Invalid display name:", |
156 |
p.getValue("ColumnDisplayNameWithMnemonicTTV"), |
157 |
model.getDisplayNameWithMnemonic(p) ); |
158 |
assertEquals( "Invalid mnemonic", 'T', checkBox.getMnemonic() ); |
159 |
|
160 |
|
161 |
p = new MyProperty(); |
162 |
p.setDisplayName( "displayName1" ); |
163 |
p.setShortDescription( "shortDescription1" ); |
164 |
p.setValue( "ColumnDisplayNameWithMnemonicTTV", "other&DisplayName" ); |
165 |
p.setValue( "ColumnMnemonicCharTTV", "" ); |
166 |
checkBox = new JCheckBox( model.getDisplayNameWithMnemonic(p) ); |
167 |
Mnemonics.setLocalizedText(checkBox, checkBox.getText()); |
168 |
model.makeAccessibleCheckBox( checkBox, p ); |
169 |
|
170 |
assertEquals( "Invalid display name:", |
171 |
p.getValue("ColumnDisplayNameWithMnemonicTTV"), |
172 |
model.getDisplayNameWithMnemonic(p) ); |
173 |
assertEquals( "Invalid mnemonic", 'D', checkBox.getMnemonic() ); |
174 |
} |
175 |
|
116 |
private static class MyNodeTableModel extends NodeTableModel { |
176 |
private static class MyNodeTableModel extends NodeTableModel { |
117 |
public MyNodeTableModel( int columnCount ) { |
177 |
public MyNodeTableModel( int columnCount ) { |
118 |
this.allPropertyColumns = new NodeTableModel.ArrayColumn[columnCount]; |
178 |
this.allPropertyColumns = new NodeTableModel.ArrayColumn[columnCount]; |