Skip to content

Primitive wrapper property editors should use valueOf - #7864

Merged
mbien merged 1 commit into
apache:masterfrom
mbien:valueof-for-wrapper-property-editors
Oct 11, 2024
Merged

mbien merged 1 commit into
apache:masterfrom
mbien:valueof-for-wrapper-property-editors

Conversation

@mbien

@mbien mbien commented Oct 10, 2024 •

Copy link
Copy Markdown
Member
  • 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 Label for cleanup done on the Netbeans IDE 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

@matthiasblaesing matthiasblaesing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only eyeballed, but looks sane to me.

@mbien
mbien marked this pull request as ready for review October 10, 2024 21:58
@mbien
mbien merged commit 3597256 into apache:master Oct 11, 2024
@ebarboni

ebarboni commented Oct 18, 2024 •

Copy link
Copy Markdown
Contributor

marked nb24

@ebarboni ebarboni added this to the NB24 milestone Oct 18, 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 Label for cleanup done on the Netbeans IDE 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

3 participants