Lines 40-61
Link Here
|
40 |
package org.netbeans.modules.projectimport.eclipse.core.spi; |
40 |
package org.netbeans.modules.projectimport.eclipse.core.spi; |
41 |
|
41 |
|
42 |
import org.netbeans.api.project.Project; |
42 |
import org.netbeans.api.project.Project; |
|
|
43 |
import org.netbeans.api.project.ProjectUtils; |
43 |
import org.netbeans.modules.projectimport.eclipse.core.ProjectOpenHookImpl; |
44 |
import org.netbeans.modules.projectimport.eclipse.core.ProjectOpenHookImpl; |
44 |
import org.netbeans.modules.projectimport.eclipse.core.UpgradableProject; |
45 |
import org.netbeans.modules.projectimport.eclipse.core.UpgradableProject; |
45 |
import org.netbeans.spi.project.LookupProvider; |
46 |
import org.netbeans.spi.project.LookupProvider; |
46 |
import org.openide.util.Lookup; |
47 |
import org.openide.util.Lookup; |
47 |
import org.openide.util.lookup.Lookups; |
48 |
import org.openide.util.lookup.Lookups; |
48 |
|
49 |
|
49 |
// registered separately in j2se and web modules, but could use @LookupProvider.Registration |
50 |
// registered separately in j2se and web modules, otherwise could use @LookupProvider.Registration |
50 |
final public class UpgradableProjectLookupProvider implements LookupProvider { |
51 |
final public class UpgradableProjectLookupProvider implements LookupProvider { |
51 |
|
52 |
|
52 |
public Lookup createAdditionalLookup(Lookup baseContext) { |
53 |
public Lookup createAdditionalLookup(Lookup baseContext) { |
53 |
Project p = baseContext.lookup(Project.class); |
54 |
Project p = baseContext.lookup(Project.class); |
54 |
assert p != null; |
55 |
assert p != null; |
55 |
UpgradableProject up = new UpgradableProject(p); |
56 |
if (ProjectUtils.getPreferences(p, UpgradableProjectLookupProvider.class, true). |
|
|
57 |
get("project", null) == null) { // NOI18N |
58 |
// Shortcut, the normal case: |
59 |
return Lookup.EMPTY; |
60 |
} else { |
61 |
// Keep as separate method to try to delay class initialization: |
62 |
return upgradeLookup(p); |
63 |
} |
64 |
} |
65 |
|
66 |
private static Lookup upgradeLookup(Project p) { |
56 |
return Lookups.fixed( |
67 |
return Lookups.fixed( |
57 |
up, |
68 |
new UpgradableProject(p), |
58 |
new ProjectOpenHookImpl(p, up)); |
69 |
new ProjectOpenHookImpl()); |
59 |
} |
70 |
} |
60 |
|
71 |
|
61 |
} |
72 |
} |