mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use Boolean.TRUE and Boolean.FALSE values when generating boolean client properties to bytecode (IDEA-46372)
This commit is contained in:
+13
-7
@@ -618,20 +618,26 @@ public class AsmCodeGenerator {
|
||||
if (value instanceof StringDescriptor) {
|
||||
generator.push(((StringDescriptor) value).getValue());
|
||||
}
|
||||
else if (value instanceof Boolean) {
|
||||
boolean boolValue = ((Boolean) value).booleanValue();
|
||||
Type booleanType = Type.getType(Boolean.class);
|
||||
if (boolValue) {
|
||||
generator.getStatic(booleanType, "TRUE", booleanType);
|
||||
}
|
||||
else {
|
||||
generator.getStatic(booleanType, "FALSE", booleanType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Type valueType = Type.getType(value.getClass());
|
||||
generator.newInstance(valueType);
|
||||
generator.dup();
|
||||
if (value instanceof Boolean) {
|
||||
generator.push(((Boolean) value).booleanValue());
|
||||
generator.invokeConstructor(valueType, Method.getMethod("void <init>(boolean)"));
|
||||
}
|
||||
else if (value instanceof Integer) {
|
||||
generator.push(((Integer) value).intValue());
|
||||
if (value instanceof Integer) {
|
||||
generator.push(((Integer)value).intValue());
|
||||
generator.invokeConstructor(valueType, Method.getMethod("void <init>(int)"));
|
||||
}
|
||||
else if (value instanceof Double) {
|
||||
generator.push(((Double) value).doubleValue());
|
||||
generator.push(((Double)value).doubleValue());
|
||||
generator.invokeConstructor(valueType, Method.getMethod("void <init>(double)"));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="BindingTest">
|
||||
<grid id="27dc6" binding="myRootComponent" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2e11e" class="javax.swing.JTable" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<terminateEditOnFocusLost class="java.lang.Boolean" value="true"/>
|
||||
</clientProperties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -308,6 +308,13 @@ public class AsmCodeGeneratorTest extends TestCase {
|
||||
assertEquals(1, instance.getContentPane().getComponentCount());
|
||||
}
|
||||
|
||||
public void testClientProp() throws Exception { // IDEA-46372
|
||||
JComponent rootComponent = getInstrumentedRootComponent("TestClientProp.form", "BindingTest");
|
||||
assertEquals(1, rootComponent.getComponentCount());
|
||||
JTable table = (JTable) rootComponent.getComponent(0);
|
||||
assertSame(Boolean.TRUE, table.getClientProperty("terminateEditOnFocusLost"));
|
||||
}
|
||||
|
||||
public void testIdeadev14081() throws Exception {
|
||||
// NOTE: That doesn't really reproduce the bug as it's dependent on a particular instrumentation sequence used during form preview
|
||||
// (the nested form is instrumented with a new AsmCodeGenerator instance directly in the middle of instrumentation of the current form)
|
||||
|
||||
Reference in New Issue
Block a user