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 38065 - NPE: Selecting INHERIT for the background color of the DEFAULT color
Summary: NPE: Selecting INHERIT for the background color of the DEFAULT color
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Dusan Balek
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2003-12-12 17:41 UTC by _ gtzabari
Modified: 2007-11-05 13:44 UTC (History)
2 users (show)

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 _ gtzabari 2003-12-12 17:41:48 UTC
dev build 200312111900

   Under Java fonts & colors | DEFAULT font |
Background color, click on INHERIT and the
following exception is thrown:

java.lang.NullPointerException
	at
org.netbeans.editor.DrawGraphics$GraphicsDG.setBackColor(DrawGraphics.java:362)
	at
org.netbeans.editor.DrawEngine.drawFragment(DrawEngine.java:561)
	at
org.netbeans.editor.DrawEngine.drawCurrentTokenFragment(DrawEngine.java:767)
	at
org.netbeans.editor.DrawEngine.drawCurrentToken(DrawEngine.java:861)
	at
org.netbeans.editor.DrawEngine.draw(DrawEngine.java:1072)
	at
org.netbeans.editor.LeafView.paintAreas(LeafView.java:154)
	at
org.netbeans.editor.BaseView.paint(BaseView.java:129)
	at
org.netbeans.editor.BaseTextUI$RootView.paint(BaseTextUI.java:595)
	at
org.netbeans.editor.BaseTextUI.paintRegion(BaseTextUI.java:237)
	at
org.netbeans.editor.EditorUI.paint(EditorUI.java:1522)
	at
org.netbeans.editor.BaseTextUI.paint(BaseTextUI.java:215)
	at
javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
	at
javax.swing.JComponent.paintComponent(JComponent.java:541)
	at javax.swing.JComponent.paint(JComponent.java:808)
	at
javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
	at
javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
	at
javax.swing.JComponent._paintImmediately(JComponent.java:4685)
	at
javax.swing.JComponent.paintImmediately(JComponent.java:4488)
	at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
[catch] at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
	at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
	at
java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
	at java.awt.Dialog$1.run(Dialog.java:540)
	at java.awt.Dialog.show(Dialog.java:561)
	at
org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:715)
	at
org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:758)
	at
org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:746)
	at
org.openide.util.Mutex.doEventAccess(Mutex.java:920)
	at org.openide.util.Mutex.readAccess(Mutex.java:157)
	at
org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:731)
	at
org.openide.explorer.propertysheet.CustomEditorAction.actionPerformed(CustomEditorAction.java:222)
	at
org.openide.explorer.propertysheet.SheetTable.editCellAt(SheetTable.java:732)
	at
javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.adjustFocusAndSelection(BasicTableUI.java:510)
	at
javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(BasicTableUI.java:494)
	at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
	at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:221)
	at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:221)
	at
java.awt.Component.processMouseEvent(Component.java:5097)
	at
org.openide.explorer.propertysheet.SheetTable.processMouseEvent(SheetTable.java:546)
	at
java.awt.Component.processEvent(Component.java:4897)
	at
java.awt.Container.processEvent(Container.java:1569)
	at
java.awt.Component.dispatchEventImpl(Component.java:3615)
	at
java.awt.Container.dispatchEventImpl(Container.java:1627)
	at
java.awt.Component.dispatchEvent(Component.java:3477)
	at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
	at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
	at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
	at
java.awt.Container.dispatchEventImpl(Container.java:1613)
	at
java.awt.Window.dispatchEventImpl(Window.java:1606)
	at
java.awt.Component.dispatchEvent(Component.java:3477)
	at
java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
	at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Comment 1 _ tboudreau 2003-12-12 17:59:23 UTC
Could you try this with today's build?  I checked in a bunch of stuff
yesterday evening to fix problems with this dialog's rather peculiar
use of PropertyPanel.  

I just tried it and wasn't able to reproduce the problem you're having.

Closing as WORKSFORME - I think my work yesterday fixed this.  Reopen
if you see the problem on today's build.
Comment 2 _ gtzabari 2003-12-12 18:49:15 UTC
dev build 200312111900 is the latest release as of today. Which dev
build are you referring to?
Comment 3 _ tboudreau 2003-12-12 19:30:57 UTC
200312111900
      ^^
I'm referring to it having been built on the 11th, today being the
12th - but I'm always building my own build, so I don't know exactly
what time it would have been built, and therefore, whether it contains
my fixes or not.  The next one should, though.  My last checkins last
night were around midnight Prague time, I believe.

Anyway, the next one will definitely contain the work I did yesterday.
Comment 4 _ gtzabari 2003-12-15 21:49:17 UTC
Still reproducible under dev build 200312141900.
Comment 5 _ tboudreau 2003-12-21 14:51:12 UTC
Reassigning to editor.
Comment 6 Martin Roskanin 2004-01-23 13:56:41 UTC
Inherit checkbox should be disabled by default for DEFAULT syntax. It
is regression. We should fix it to NB 3.6
Comment 7 Dusan Balek 2004-01-29 13:31:59 UTC
When constructing ColoringEditorPanel, Inherit checkboxes are
initially disabled for the DEFAULT syntax. However, just a few moments
later, these checkboxes are again enabled as a consequence of
setEnabled(true) invocation on ProperyPanel's CustomEditorDisplayer. Tim
Comment 8 Dusan Balek 2004-01-29 13:42:51 UTC
When constructing ColoringEditorPanel, Inherit checkboxes are
initially disabled for the DEFAULT syntax. However, just a few moments
later, these checkboxes are again enabled as a consequence of
setEnabled(true) invocation on ProperyPanel's CustomEditorDisplayer.

Tim, why does CustomEditorDisplayer enable CustomEditor component
together with ALL ITS NESTED SUBCOMPONENTS (including Inherit checkbox
in case of ColoringEditorPanel)????

Isn't it responsibility of each CustomEditor to correctly
enable/disable its subcomponents???
Comment 9 _ tboudreau 2004-01-29 14:27:16 UTC
It's a fix for an old bug - enabling and disabling JFileChooser doesn't work right - you 
disable it and its components are still active.  So the requirement was that the 
property panel drill through the entire subtree and disable/enable everything.  Maybe 
I could make it do something less extreme, but not for 3.6.

Suggestion:  The entire design of this dialog is barely sane, and required a bunch of 
hacks to make it work with the new property panel (primarily because changing a 
property causes the parent of the PropertyPanel to replace it while it's setting the 
property).  Wouldn't a more normal Swing implementation have a lot less problems 
than three layers of nested property panels replacing each other on the fly?  Consider 
also that it is *completely* impossible to preserve focus after the user presses enter 
on a color field, because the parent of the color field is replaced with a new 
component that doesn't know about the old one.

Note, you should be able to call setEnabled(false) on the checkbox *after* it is shown 
- the inner component is not created until addNotify(), so that's when the enablement 
is checked.

See also contrib/editorthemes for a much simpler UI for this sort of thing.
Comment 10 _ tboudreau 2004-01-29 14:35:59 UTC
One thing I could give you quickly - the ability to do something like
putClientProperty("dontEnableMe", Boolean.TRUE) to get the code that walks the tree 
to not enable your checkbox.  Let me know if you want that, it's a five minute fix.  I 
don't think I can restrict the enabling code to just JFileChoosers because other code 
depends on this working the way it always has (it *has* worked this way since 3.2 or 
so - the difference is the timing of when the inner component is created and installed 
- it was not always created lazily, so the ordering of the enablement calls is different 
now).

Let me know if you want me to take care of it with a client property, and I'll let you 
know when it's ready.
Comment 11 _ tboudreau 2004-01-29 14:47:18 UTC
It seemed pretty likely that you'd end up needing it, so I've committed the client 
property code to the trunk.  When you create your checkbox, call

myCheckbox.putClientProperty ("dontEnableMe", Boolean.TRUE)

and the code that walks the component tree will ignore it and its subtree if any.  So 
you should be able to get this fixed and closed quickly.
Comment 12 Dusan Balek 2004-01-29 15:18:45 UTC
Tim, I agree that this dialog definitely deserves a deep redesign but
not for 3.6. Anyway, thanks for the info.

Fixed in [maintrunk].

/cvs/editor/src/org/netbeans/modules/editor/options/ColoringEditorPanel.java,v
 <--  ColoringEditorPanel.java
new revision: 1.31; previous revision: 1.30
done
Comment 13 Martin Roskanin 2004-02-05 12:34:51 UTC
*** Issue 39635 has been marked as a duplicate of this issue. ***
Comment 14 Jan Pokorsky 2004-02-10 20:21:54 UTC
FYI, I am not sure who and when introduced code changing the enable
property in the component tree but it definitely breaks functionality
of almost all customizers of source hierarchy elements (eg issue #39891).

I can reuse the "dontEnableMe" property but from my point of view its
a regression.
Comment 15 _ gtzabari 2004-02-10 20:47:14 UTC
Jan,

   I recommend someone open up a TASK for the Netbeans team to clean
up this dialog if things are as bad as Tim reported. This
"dontEnableMe" hack gives me a bad feeling about the sanity of this
entire thing.
Comment 16 _ tboudreau 2004-02-10 23:16:10 UTC
FYI, the enablement hack has been around since 3.3.  What changed (and what I just fixed) 
is that PropertyPanel would sync the embedded component's state on initialization.  It will 
now only do that if it has been disabled.  So unless you disable and reenable a 
PropertyPanel in custom editor mode, you won't encounter the problem.

Re the sanity of the whole thing:  The core problem is PropertyPanel - it is a magical class 
that tries to do way too much, with multiple states and modes that have lots of possible 
combinations.  As far as I know, Jarda wrote it so he'd never have to write another line of 
GUI code again.  It's a nice idea - you just pass a Property or a BeanDescriptor to the 
constructor of a component and say "I want an inline editor" or "I want a custom editor", 
"make it read only", "make it write the property when x happens" and the PropertyPanel 
magically fulfils your every wish.  The root problem is that the semantics and behavior of 
inline editors, custom property editors are very different, and trying to shoehorn them into 
the gui component to end all gui components that will just anticipate "the right thing" is 
going to produce reams of corner cases.  Add into that mix the various historical 
permutations of NetBeans property editor extensions and the supremely enigmatic 
PropertyEnv, which can also impact behavior, plus various client properties and non-
normative property hints, and, well...rewriting this thing to use the new PropertySheet's 
infrastructure and be backward compatible has to be one of the hardest things I've ever 
done.

There now are sane, non-public, *separate* classes the new PropertyPanel embeds that 
could make a manageable replacement API for it which could make a reasonable 
replacement for its functionality - they are what the rewritten PropertyPanel embeds to do 
what it does.

End rant.
Comment 17 Jiri Prox 2006-04-07 09:08:26 UTC
Verified