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 161120 - Refactorings are disabled
Summary: Refactorings are disabled
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Features On Demand (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW_FAST, ERGONOMICS
Depends on:
Blocks:
 
Reported: 2009-03-25 11:39 UTC by Jiri Prox
Modified: 2009-06-21 13:43 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
OpenProjects.isProjectOpen (25.27 KB, patch)
2009-04-01 16:53 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2009-03-25 11:39:58 UTC
Product Version: NetBeans IDE Dev (Build 20090325053257)
Java: 1.6.0_13; Java HotSpot(TM) Client VM 11.3-b02
System: Linux version 2.6.24-23-generic running on i386; UTF-8; en_US (nb)

Several refactorings are disabled after java cluster have been activated.

Steps to reproduce:
1) start full IDE with fresh iserdir
2) open Java project
-> java is activated, but refactorigns like rename, copy ... are disabled

the step 2) can be replaced by "create new j2se project", in such case only 'change parameters' and 'move inner to
outer' are disabled
Comment 1 Jan Pokorsky 2009-03-25 13:06:48 UTC
An ergonomics issue. With active java cluster actions work as expected. Reassigning.
Comment 2 Jaroslav Tulach 2009-03-27 08:41:19 UTC
Jesse, this is unexpected attack caused by duality of projects after open. Not a problem with casting to particular 
instance, but problem is identity check. The project in OpenProjects may not be the same as the one returned by 
FileOwnerQuery. I inspected all refactorings modules and changed them to deal with this situation. But:

1. maybe we could have boolean OpenProjects.isProjectOpen(Project p) method.
2. also boolean OpenProjects.isFromOpenProject(FileObject fo) 

both these methods would simplify the copy pasted routines spread along all refactoring modules.

Comment 3 Jaroslav Tulach 2009-03-27 08:44:57 UTC
ergonomics#55cd0ce718c6
Comment 4 Jesse Glick 2009-03-27 13:54:43 UTC
OpenProjects.isProjectOpen(Project) sounds fine to me, feel free to file API_REVIEW_FAST for it.

I still recommend not replacing projects with the "real" impls after opening - if you are going to create a proxy
ProjectFactory, the same Project instance should be used for the entire IDE session. While this would require code which
casts a Project to a particular type to be fixed, this was always documented to be illegal; I believe such code could be
more easily and safely fixed than code which assumes (as was always true in the past) that == is well-defined on Project.
Comment 5 Quality Engineering 2009-03-28 20:48:23 UTC
Integrated into 'main-golden', will be available in build *200903281400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/55cd0ce718c6
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #161120: Using double equals instead of identity check to deal with fake projects in OpenProjects
Comment 6 David Konecny 2009-03-31 20:44:05 UTC
As discussed offline the fix is wrong and error prone. Anybody who sees a code like

  if (p.equals(opened[i]) || opened[i].equals(p)) {

should feel free to remove second equals because as Javadoc for equals says "[equals] is symmetric: for any non-null
reference values x and y, x.equals(y)  should return true if and only if y.equals(x) returns true.".

If you are hacking something then please at least add comments explaining what and why. Even better just do not hack it
and fix it properly.
Comment 7 Jaroslav Tulach 2009-04-01 16:53:14 UTC
Created attachment 79235 [details]
OpenProjects.isProjectOpen
Comment 8 Jesse Glick 2009-04-01 17:00:39 UTC
[JG01] Patch to FeatureProjectFactory.java is likely unrelated and should be omitted.


[JG02] If null is a legal param value for iPO it must be documented as such; else use Params.notNull.
Comment 9 Jaroslav Tulach 2009-04-09 11:56:22 UTC
I'll apply Jesse's comments and integrate tomorrow.
Comment 10 Jaroslav Tulach 2009-04-10 10:15:07 UTC
Integrated into ergonomics#860b3b8f4181
Comment 11 Quality Engineering 2009-04-11 06:55:03 UTC
Integrated into 'main-golden', will be available in build *200904110201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/860b3b8f4181
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #161120: Beautification of the code. Hidding double equals into its own API method