This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 194052 - Code generation that messes up the application when viewing a table content in the design mode.
Summary: Code generation that messes up the application when viewing a table content i...
Status: RESOLVED FIXED
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: issues@guibuilder
URL:
Keywords: UI
Depends on:
Blocks:
 
Reported: 2011-01-05 13:34 UTC by ccunarro
Modified: 2011-11-16 16:47 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ccunarro 2011-01-05 13:34:49 UTC
Product Version = NetBeans IDE 6.9.1 (Build 201007282301)
Operating System = Linux version 2.6.32-27-generic running on amd64
Java; VM; Vendor = 1.6.0_22
Runtime = Java HotSpot(TM) 64-Bit Server VM 17.1-b03

We have an application with internationalized gui, available in spanish, english, separated from the code. The problem starts  when viewing a table in the design mode (right click on the table, then click on "Table Contents" , options "User Specified".

If you close the archive you are viewing it tells you that you have made changes, which of course you did not (you only viewed the table contents). The code that generates the problem is this:

  jTableX.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "\" + principal.RB.getString(\"Header.Nro\") + \"", "\" + principal.RB.getString(\"Header.Estaciones\") + \""
            }
        ) {

Those backslashes with doble quotes added are the problem.

Hope this information helps.
Comment 1 Tomas Pavek 2011-01-19 16:20:29 UTC
I was not able to reproduce this exactly, but I think the problem is in entering something like principal.RB.getString("Header.Nro") as column title either directly in the columns table, or into the Title editing field for selected column. It is interpreted as String that should appear in the title, not as a code. So it must be escaped. It's the same as with any other property in the GUI builder, not only in the table customizer.

To enter java code, you must switch to custom code property editor. On the Columns page in the customizer select a column (i.e. a row in the table), then press [...] button next to the Title editing field, switch to Custom code editor, and here enter the code.

As a result, the GUI builder will generate additional code like:
jTable1.getColumnModel().getColumn(0).setHeaderValue(principal.RB.getString("Header.Nro"));

Unfortunately, it will also generate something like "java.lang.Object@78143e" on the original place of the DefaultTableModel property initialization. It does not matter in runtime because it then gets overridden by the setHeaderValue code, but still a bug.
Comment 2 Tomas Pavek 2011-01-19 16:22:58 UTC
I've fixed the mentioned problem: if Title is entered as user code, the user code object should not be converted to String, only empty "" should be used as the default title.

http://hg.netbeans.org/core-main/rev/275e8cf3221a