Modify

Opened 15 years ago

Closed 15 years ago

#3018 closed defect (fixed)

[PATCH] Make sure tools menu entries (and actions) are deactivated when no layer

Reported by: avarab@… Owned by: avarab@…
Priority: major Milestone:
Component: Core Version: latest
Keywords: Cc: Gubaer

Description

  1. Start JOSM
  2. Press "c" (combine way)
java.lang.NullPointerException
	at org.openstreetmap.josm.actions.CombineWayAction.actionPerformed(CombineWayAction.java:59)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2851)
	at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:267)
	at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:216)
	at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2928)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2920)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2814)
	at java.awt.Component.processEvent(Component.java:6040)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:704)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:969)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:841)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:668)
	at java.awt.Component.dispatchEventImpl(Component.java:4502)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Window.dispatchEventImpl(Window.java:2475)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Attachments (1)

JOSM.patch (31.5 KB ) - added by Landwirt 15 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Gubaer, 15 years ago

Cc: Gubaer added
Resolution: fixed
Status: newclosed

fixed in r1817

comment:2 by Landwirt, 15 years ago

Resolution: fixed
Status: closedreopened
Summary: NullPointerException when starting JOSM & pressing "C"NullPointerException when starting JOSM & using one of the tools

I have to say that this problem affects perhaps all tools - UnGlueAction, MergeNodesAction etc. Just load JOSM and start an action from the Tools menu.

comment:3 by Gubaer, 15 years ago

Summary: NullPointerException when starting JOSM & using one of the toolsMake sure tools menu entries (and actions) are deactivated when no layer

comment:4 by Gubaer, 15 years ago

Resolution: fixed
Status: reopenedclosed

fixed in r1820

comment:5 by Landwirt, 15 years ago

Resolution: fixed
Status: closedreopened

I reopen the ticket once again, because the tools/actions are not immediately activated after a layer has been created or opened. Even after drawing selected objects have to be re-selected to enable the actions.

comment:6 by anonymous, 15 years ago

Ticket #2948 has been marked as a duplicate of this ticket.

comment:7 by Landwirt, 15 years ago

Summary: Make sure tools menu entries (and actions) are deactivated when no layer[PATCH] Make sure tools menu entries (and actions) are deactivated when no layer

I made a patch to update the updateEnabledState function of most actions.

comment:8 by Landwirt, 15 years ago

Ticket #3038 has been marked as a duplicate of this ticket.

comment:9 by Gubaer, 15 years ago

Owner: changed from team to avarab@…
Status: reopenedneedinfo

The patch mainly replaces

setEnabled(getCurrentDataSet() != null && ! getCurrentDataSet().getSelected().isEmpty()); 

by

setEnabled(getEditLayer() != null); 
	 
if (this.enabled) { 
   setEnabled(getCurrentDataSet() != null && !getCurrentDataSet().getSelected().isEmpty()); 
} 

in actions.

The replacement is logically equivalent with the orignal, though, it looks only more elaborated.

Am I missing something?

comment:10 by Landwirt, 15 years ago

I believe I mixed up the patches - the this.enabled part shouldn't be there as I replaced all that lines by just the getEditLayer line. Nonetheless both is wrong, and best example why I haven't asked for svn access :-D

But I have another patch for a possible solution. As I couldn't find out why getCurrentDataSet().getSelected() seems to be always empty, I simply extended the updateEnabledState.

by Landwirt, 15 years ago

Attachment: JOSM.patch added

comment:11 by Gubaer, 15 years ago

Nonetheless both is wrong, and best example why I haven't asked for svn access :-D

I won't apply this patch either, at least not entirely.

Most of the stuff you added is redundant. It's already working exactly the way you try to fix it. I'm therefore wondering with what JOSM version you are working. Can you explain again what you try to fix?

The patch for ReverseWayAction.java is ok, though. This OK was forgotten in the last update so your cleanup is welcome.

comment:12 by Landwirt, 15 years ago

In eclipse I currently have 1826, but you can also try today's josm-latest: draw a way, switch to select mode - though the way is selected the actions in the Tools menu are still disabled. That's because in updateEnableState the result of !getCurrentDataSet().getSelected().isEmpty() is incorrectly "false".

The patch for ReverseWayAction.java is ok

Parts in PasteAction.java should also work - currently Pasting is disabled when nothing is selected.

comment:13 by Gubaer, 15 years ago

Resolution: fixed
Status: needinfoclosed

fixed in r1844

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain avarab@….
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.