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 48201 - [40cat] Run runs wrong class (or displays wrong class to run)
Summary: [40cat] Run runs wrong class (or displays wrong class to run)
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: PC Windows XP
: P4 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks: 41535
  Show dependency tree
 
Reported: 2004-08-31 00:40 UTC by thunderjon
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 thunderjon 2004-08-31 00:40:34 UTC
[ BUILD # : 200408271257 ]
[ JDK VERSION : J2SE 1.4.2_04 ]

Try this generic case.

1. Open a project with two main classes call them A and B.

2. Open both in the editor.

3. Click on the tab for class A.

4. Click on the tab for class B (brings focus to edit B).

5. Now right click on the editor window for class B, the context menu says run "A.java". However if you select this, it actually runs B.java (which makes sense, you run the class you right click on). In any event someone could mistakenly run the wrong class, ouch!
Comment 1 thunderjon 2004-08-31 00:43:11 UTC
NOTE: The first right-click is wrong. If you exit out of the context 
menu and then right click again the Run "X.java" appears correctly.
Comment 2 Martin Roskanin 2004-08-31 08:18:05 UTC
Yes, I can reproduce it. 
Comment 3 Martin Roskanin 2004-08-31 09:30:38 UTC
fixed in [maintrunk] in editor module.

/cvs/editor/src/org/netbeans/modules/editor/NbEditorKit.java,v  <-- 
NbEditorKit.java
new revision: 1.69; previous revision: 1.68


invoking action.isEnabled (which causes FileCommandAction refresh)
before action.getValue(Action.NAME);

Anyway, more appropriate solution would be to refresh displayName of
the action just after the editor has receive the focus.

The action itself is implemented in project module. Lowering priority
to P4 and reassigning to project module for further considering...
Comment 4 Jesse Glick 2004-08-31 13:58:03 UTC
Not sure what this is about. Petr can you evaluate?
Comment 5 Petr Hrebejk 2004-08-31 16:59:43 UTC
I'll file another bug against me to improve the LookupSensitiveAction.

Anyway, back to you, because the way you are building the popup menu
is not correct. Notice that if the action being added into popup
imlements ContextAwareAction you should use
org.openide.util.Utilities.actionsToPopup().
Comment 6 Petr Hrebejk 2004-08-31 17:05:51 UTC
Filled the bug against LookupSensitiveAction in projects: issue #48262
Comment 7 Miloslav Metelka 2004-08-31 17:25:10 UTC
For ContextAwareAction-based actions we properly call
createContextAwareInstance() in NbEditorKit.NbBuildPopupMenuAction if
you've meant this.
Comment 8 Martin Roskanin 2004-09-01 09:00:18 UTC
fixed in [maintrunk]

/cvs/editor/src/org/netbeans/modules/editor/NbEditorKit.java,v  <-- 
NbEditorKit.java
new revision: 1.70; previous revision: 1.69

Thanks Petr. You are right. In the case of FileCommandAction a
ContextAwareAction instance was not created. 
I modified my previous fix. Now, it is not necessary to do mentioned
workaround.