Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive wrapper property editors should use valueOf #7864

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbien
Copy link
Member

@mbien mbien commented Oct 10, 2024

  • the wrapper class constructors are all deprecated for removal -> lets use valueOf
  • this will also allow setting wrapper properties to null. The only exception is Character, since CharEditor (for primitives) maps null to a char before it is passed to the CharacterEditor which never sees null.
  • affects code generation in GUI forms

fixes #7049

test:
1)

public class TextField extends JTextField {
    
    private Long valLong = 123L;
    private Double valDouble = 123.0;
    private Float valFloat = 123.0f;
    private Integer valInteger = 123;
    private Character valCharacter = 'a';
    private Short valShort = 123;
    private Byte valByte = 123;
    private Boolean valBoolean = true;
    
    private long primLong = 123;
    private int primInt = 123;
    
    // generate getter/setters
}
  1. create JPanel form and drag TextField into form via design view.
  2. click on the component in design view, edit the properties via Properties window, check generated code which should now look like:
        textField1.setText("textField1");
        textField1.setValBoolean(java.lang.Boolean.FALSE);
        textField1.setValByte(Byte.valueOf((byte)111));
        textField1.setValCharacter(Character.valueOf('b'));
        textField1.setValDouble(Double.valueOf(111.0D));
        textField1.setValFloat(Float.valueOf(111.0F));
        textField1.setValInteger(Integer.valueOf(111));
        textField1.setValLong(Long.valueOf(111L));
        textField1.setValShort(Short.valueOf((short)111));

 - the wrapper class constructors are all deprecated for removal
 - this will also allow setting wrapper properties to null.
   The only exception is Character, since CharEditor (for primitives)
   maps null to a char before it is passed to the CharacterEditor which
   never sees null.
 - affects code generation in GUI forms
@mbien mbien added Code cleanup Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Platform [ci] enable platform tests (platform/*) FormDesigner GUI builder, also known as Matisse ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) ci:all-tests [ci] enable all tests labels Oct 10, 2024
@apache apache locked and limited conversation to collaborators Oct 10, 2024
@apache apache unlocked this conversation Oct 10, 2024
@mbien mbien removed the ci:all-tests [ci] enable all tests label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Code cleanup FormDesigner GUI builder, also known as Matisse Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Platform [ci] enable platform tests (platform/*)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The GUI Builder produces code for boxed primitive properties that is deprecated for removal
1 participant