View | Details | Raw Unified | Return to bug 339857 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/editor/plugin/ImportPackageSection.java (+30 lines)
Lines 482-487 Link Here
482
482
483
		for (int i = 0; i < models.length; i++) {
483
		for (int i = 0; i < models.length; i++) {
484
			BundleDescription desc = models[i].getBundleDescription();
484
			BundleDescription desc = models[i].getBundleDescription();
485
486
			if (models[i].isFragmentModel() && !canFragmentExportPackages(models[i]))
487
				continue;
488
485
			String id = desc == null ? null : desc.getSymbolicName();
489
			String id = desc == null ? null : desc.getSymbolicName();
486
			if (id == null || forbidden.contains(id))
490
			if (id == null || forbidden.contains(id))
487
				continue;
491
				continue;
Lines 517-522 Link Here
517
			try {
521
			try {
518
				// add un-exported packages in workspace non-binary plug-ins
522
				// add un-exported packages in workspace non-binary plug-ins
519
				IResource resource = models[i].getUnderlyingResource();
523
				IResource resource = models[i].getUnderlyingResource();
524
				if (models[i].isFragmentModel() && !canFragmentExportPackages(models[i]))
525
					continue;
520
				IProject project = resource != null ? resource.getProject() : null;
526
				IProject project = resource != null ? resource.getProject() : null;
521
				if (project == null || !project.hasNature(JavaCore.NATURE_ID) || WorkspaceModelManager.isBinaryProject(project) || !PDEProject.getManifest(project).exists())
527
				if (project == null || !project.hasNature(JavaCore.NATURE_ID) || WorkspaceModelManager.isBinaryProject(project) || !PDEProject.getManifest(project).exists())
522
					continue;
528
					continue;
Lines 543-548 Link Here
543
		dialog.setConditionalElements(conditional.toArray());
549
		dialog.setConditionalElements(conditional.toArray());
544
	}
550
	}
545
551
552
	private boolean canFragmentExportPackages(IPluginModelBase fragment) {
553
		if (!fragment.isFragmentModel()) {
554
			//not a fragment
555
			return true;
556
		}
557
		if (fragment.getBundleDescription() == null) {
558
			//classic plugin, do not change the behavior
559
			return true;
560
		}
561
		BundleDescription ds = fragment.getBundleDescription();
562
		HostSpecification hs = ds.getHost();
563
		if (hs == null) {
564
			//not a fragment
565
			return true;
566
		}
567
		BundleDescription[] hosts = hs.getHosts();
568
		for (int i = 0; i < hosts.length; i++) {
569
			//hosts have extensible API so they packages can be exported 
570
			if (ClasspathUtilCore.hasExtensibleAPI(PluginRegistry.findModel(hosts[i])))
571
				return true;
572
		}
573
		return false;
574
	}
575
546
	public void modelChanged(IModelChangedEvent event) {
576
	public void modelChanged(IModelChangedEvent event) {
547
		if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
577
		if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
548
			fHeader = null;
578
			fHeader = null;

Return to bug 339857