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 233141

Summary: Patch for: [dark] Cannot read some fields of database records in dark theme
Product: db Reporter: Lou Dasaro <mr_lou_d>
Component: Show DataAssignee: Libor Fischmeistr <lfischmeistr>
Status: RESOLVED FIXED    
Severity: normal CC: jhavlin, tboudreau, twolf2919
Priority: P3 Keywords: NO74, PATCH_AVAILABLE, SIMPLEFIX
Version: 7.4   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Cannot read some fields of database table
proposed patch part1 v1 (o.n.swing.plaf)
proposed patch part2 v1 (dataview)
proposed patch part1 v2 (o.n.swing.plaf)
proposed patch part2 v2 (dataview)
expander icon for use with nimbus LAF (needed for patch part1)

Description Lou Dasaro 2013-07-22 06:33:42 UTC
Created attachment 137522 [details]
Cannot read some fields of database table

In dark themes, it is impossible to read certain fields of database tables.

See the "image_file" field of the table in the attachment. There's data on nearly every row.

Norway Today / Dark Metal

Product Version: NetBeans IDE Dev (Build 201307192300)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b15
System: Linux version 2.6.32-300.3.1.el6uek.x86_64 running on amd64; UTF-8; en_US (nb)

Identical behavior in Windows 7 / 32-bit
Comment 1 matthias42 2013-07-23 19:57:34 UTC
*** Bug 233212 has been marked as a duplicate of this bug. ***
Comment 2 matthias42 2013-07-23 19:58:17 UTC
<NULL> Value display is also affected (reported in bug 233212)
Comment 3 matthias42 2013-07-23 20:50:16 UTC
Created attachment 137644 [details]
proposed patch part1  v1 (o.n.swing.plaf)
Comment 4 matthias42 2013-07-23 20:50:47 UTC
Created attachment 137645 [details]
proposed patch part2  v1 (dataview)
Comment 5 Jaroslav Havlin 2013-07-24 14:17:12 UTC
Thank you for the patch, Matthias.

Removing the code from SQLConstantsCellRenderer.getTableCellRendererComponent is intentional? So only <NULL> values in edited cells should have different color? But aren't newly deleted cells simply empty?

After the patch, all <NULL> cells have the same color as cells with some value (in case or Dark Metal it's white, in Windows L&F it's black). Is it OK? Thanks.
Comment 6 matthias42 2013-07-24 21:06:08 UTC
Hey Jaroslav,

(In reply to comment #5)
> Removing the code from SQLConstantsCellRenderer.getTableCellRendererComponent
> is intentional? So only <NULL> values in edited cells should have different
> color? But aren't newly deleted cells simply empty?

It depends on your definition of empty. If I recall correctly, setting a NULL value on a cell marks this cell as edited. Which triggers the green/orange mark. The dark gray one was only used in 'normal' display. And my thought was: Less colors -> less problems with regards to changing LAFs. In this case the cell is set in an italic font, which should be enougth for a value, that is already visually set apart by the brackets: "<>".

So readding the code is an option, but then you'd need to introduce another UIManager property, that needs to be set. I'm ok with both approaches :-)

Feel free to change the patches if you see the need - I'm in no way biased into either direction.
Comment 7 Jaroslav Havlin 2013-07-25 08:32:48 UTC
(In reply to comment #6)
> Less colors -> less problems with regards to changing LAFs. In this case the
> cell is set in an italic font, which should be enougth for a value, that is
> already visually set apart by the brackets: "<>".
Thank you. It's reasonable.

I was just confused by the code. There is property nb.dataview.tablecell.edited.selected.emptyNull.foreground, but there's no special color for <NULL> values in not-edited cells.

But it seems that in fact the ...emptyNull.foreground is never used, because lines 210 and 216 cannot be reached (model.hasUpdates is never false in UpdatedResultSetCellRenderer).

Probably the ...emptyNull.foreground can be deleted, as well as related code in UpdatedResultSetCellRenderer. Can I do it, or am I missing something? Thanks.
Comment 8 matthias42 2013-07-27 10:34:28 UTC
Created attachment 137891 [details]
proposed patch part1 v2 (o.n.swing.plaf)
Comment 9 matthias42 2013-07-27 10:35:31 UTC
Created attachment 137892 [details]
proposed patch part2 v2 (dataview)
Comment 10 matthias42 2013-07-27 10:37:11 UTC
Created attachment 137893 [details]
expander icon for use with nimbus LAF (needed for patch part1)
Comment 11 matthias42 2013-07-27 10:37:36 UTC
(In reply to comment #7)
> I was just confused by the code. There is property
> nb.dataview.tablecell.edited.selected.emptyNull.foreground, but there's no
> special color for <NULL> values in not-edited cells.
> 
> But it seems that in fact the ...emptyNull.foreground is never used, because
> lines 210 and 216 cannot be reached (model.hasUpdates is never false in
> UpdatedResultSetCellRenderer).
> 
> Probably the ...emptyNull.foreground can be deleted, as well as related code in
> UpdatedResultSetCellRenderer. Can I do it, or am I missing something? Thanks.

You can - or have a look at the attaches patches. I tried your suggestion and indeed
the UpdatedResultSetCellRenderer and DataViewTableUI#getCellRenderer can be simplified.
While doing this and testing I noticed, that the datepicker also needs to be adjusted
for dark usage. So the changeset is a bit bigger.

The patch for o.n.swing.plaf contains:
- Customizations for DarkNimbus and DarkMetal specific for dataview and it's components
- An override in nimbus LAF customizations for the Dropdown arrow for the datepicker (the nimbus one as approx. 10px transparent padding)

The patch for db.dataview contains:
- Simplification for DataViewtableUI#getCellRenderer (dropped the specialcasing for having updates vs. not having updates, your suggestion)
- increased border size for checkbox rendering in UpdatedResultSetRenderer, to make it more prominent
- removed emptyNullForeground and used table.getForeground instead -- the case was not hit before, so this is no regression
- Fixed Control0KeyListener#keyPressed => the KeyEvent needs to be consumed when the custom actions are invoked (noticed while testing, only reproducible on dev-build)
- DateTimePickerCellEditor#getValueAsTimestamp prepare for usage as DatePicker by accepting more input formats
- CellFocusCustomRenderer: make background color customizable and fix the foreground color to the default foreground color
- SQLConstantsCellRenderer: remove special case for 'unselected' rendering
- ResultSetJXTable: Use JXDateTimePicker also to pick dates => simplifies adjustments for dark themes
- JXDateTimePicker: Map UIManager property names to correct component property
Comment 12 Marian Mirilovic 2013-08-23 13:53:16 UTC
Dark themes were moved to the NetBeans Update Center for NB 7.4
Comment 13 Jaroslav Havlin 2013-08-30 12:12:31 UTC
Thank you for updated patch, Matthias.

It's very close to code freeze, and already after UI freeze, so I created
a safe subset of the patch and integrated it, so that users of the dark theme
plugin can enjoy dark DB support in 7.4.

> - An override in nimbus LAF customizations for the Dropdown arrow for
>   the datepicker (the nimbus one as approx. 10px transparent padding)
This should wait for the next version.

> The patch for db.dataview contains:
> - Simplification for DataViewtableUI#getCellRenderer
I've chosen a less optimal, but safer fix. Still use special cell renderer
for updated cells, but keep catching of the Exception. Also create new
instance of the renderer only for updated cells.

> - increased border size for checkbox rendering in UpdatedResultSetRenderer,
> to make it more prominent.
Next version.

> - SQLConstantsCellRenderer: remove special case for 'unselected' rendering
I've somehow changed my mind, I've added another color constant instead.
It's too late to change it for 7.4. If we really want to change this,
let's do it in early days of development of the next version and wait for
some feedback.

http://hg.netbeans.org/core-main/rev/dc1d8e4fa7fc (Dark L&F)
http://hg.netbeans.org/core-main/rev/1a29c30eb6d3 (DB Dataview)

Libor, Matthias, if you find any (risk of) problems in the changesets,
please let me know. Thanks.
Comment 14 Quality Engineering 2013-09-01 01:24:35 UTC
Integrated into 'main-silver', will be available in build *201309010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/dc1d8e4fa7fc
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #233141: Adding color constants for Database Dataview

Patch by Matthias42
Comment 15 Jaroslav Havlin 2013-09-03 17:16:58 UTC
> - An override in nimbus LAF customizations for the Dropdown arrow for the
> datepicker (the nimbus one as approx. 10px transparent padding)
Reported as separate bug 235465.
Comment 16 Libor Fischmeistr 2013-11-18 10:06:46 UTC
It seems fixed but not closed -> closing as fixed.
Comment 17 matthias42 2013-11-18 21:10:25 UTC
Actually only a subset of the patches is merged. 

Of the o.n.swing.plaf none was merged, as the DarkNimbus and DarkMetal modifications were removed and my last info is, that they should be added in this iteration. This is relevant for that work.

For the dataview itself - remaining is a subset of which I would like to see the increase of the borderThickness for the CheckBox case  pdatedResultSetCellRenderer#borderThickness. The current border width is very small and not very visible.
Comment 18 _ tboudreau 2014-09-11 01:23:02 UTC
Any plans to fix this?

BTW, while the attached patch looks basically ok, you could also use existing UIManager keys such as "white" and "black" and get the right result quite simply.
Comment 19 matthias42 2015-02-15 21:26:14 UTC
I reread the changes - and checked with the netbeans modules - there are really small parts missing, but they should be taken when the CellRenderers are generally changed (there is cleanup potential).

For now I will mark this bug as RESOLVED again. Sorry for the noise.