Bug 20926 - Plugins from workspace not picked up by runtime workbench.
Summary: Plugins from workspace not picked up by runtime workbench.
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P1 critical (vote)
Target Milestone: ---   Edit
Assignee: Dejan Glozic CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-24 18:07 EDT by Konrad Kolosowski CLA
Modified: 2002-06-25 17:19 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konrad Kolosowski CLA 2002-06-24 18:07:05 EDT
20020624 integration build.

Steps to reproduce:
1.Start Eclipse
2.File->New->Project... , Plug-in Development, Plug-in Project, Next, 
Type "Test" in project name, Next, Next, Choose Hello World, Next, Next, Finish.
3.Dialog titled: "New Hello World plug-in project" saying: "Plug-ins required 
to compile Java classes in this plug-in are currently disabled. The wizard must 
enable them to avoid compile errors" apears.  Click OK.
4.Click RunningMan drop downV->Run As->Run-time workbench.
5.Close runtime workbench.
6.Open CVS perspective, create Anonymous repository location to eclipse.org, 
select org.eclipse.help project from HEAD, right click->Check out as project.
7.File->Import, External plug-ins and Fragments, Next, Next, click Existing 
Project, click Invert Selection, click Finish.
8.Open Java perspective, expand org.eclipse.help->src-
>org.eclipse.help.internal.  Double click HelpPlugin.java.
9.Insert line
 		System.out.println("Help system startup");
before line
		HelpSystem.startup();
Save HelpPlugin.java in the editor.
10.Click RunningMan drop downV -> Runtime-Workbench
11.Dialog titled "Runtime-Workbench Launcher" appears, saying: "The list of 
plug-ins to run contains duplicates. Plug-ins from the workspace will be used. 
To fix the problem, uncheck offending external plugins in the Launch 
Configuration.
12.Click OK.
13.Runtime-workbench will come up.  __Problem 1 - I did not get a chance to 
change the change the Launch Configuration.__
14.Launch help in runtime workbench.  __ Problem 2 - The console stays empty 
meaning the edited HelpPlugins.java does not get picked up.__
Comment 1 Dejan Glozic CLA 2002-06-24 19:10:20 EDT
This is a valid problem. Non-duplicate external plug-ins are added to the list 
too many times:

	private void mergeWithoutDuplicates(ArrayList wsmodels, ArrayList 
exmodels, ArrayList result) {
		boolean duplicates=false;
		
		for (int i=0; i<wsmodels.size(); i++) {
			result.add(wsmodels.get(i));
		}
		for (int i=0; i<exmodels.size(); i++) {
			IPluginModelBase exmodel = (IPluginModelBase)
exmodels.get(i);
			for (int j=0; j<wsmodels.size(); j++) {
				IPluginModelBase wsmodel = (IPluginModelBase)
wsmodels.get(j);
				if (isDuplicate(wsmodel, exmodel)) {
					duplicates=true;
				}
				else
					result.add(exmodel);
			}
		}
		if (duplicates) {
			showWarningDialog("The list of plug-ins to run contains 
duplicates. Plug-ins from the workspace will be used. To fix the problem, 
uncheck offending external plug-ins in the Launch Configurations");
		}
	}

In the code above, the problem is in the inner 'for' loop. If duplicate is 
detected, 'duplicate' boolean flag is set to true. Otherwise, external plug-in
is added to the list. The problem is that it is added in the INNER for loop.
This means that if there are M workspace plug-ins and N external ones, external
plug-ins will be added M*N times unless there are duplicates. In case of 
duplicates, each external plug-in will be added M-1 times. This results in a
huge list of plug-ins with many duplicates even though the routine should 
produce a duplicate-free list.

Another minor problem of this method is that the warning message somehow
escaped translation.

This is a serious problem that is worth fixing for 2.0. The solution is
to use inner loop for duplicate detection only and add external plug-ins
to the list in the outer loop as follows:

	private void mergeWithoutDuplicates(ArrayList wsmodels, ArrayList 
exmodels, ArrayList result) {
		boolean duplicates=false;
		
		for (int i=0; i<wsmodels.size(); i++) {
			result.add(wsmodels.get(i));
		}
		for (int i=0; i<exmodels.size(); i++) {
			IPluginModelBase exmodel = (IPluginModelBase)
exmodels.get(i);
			boolean localDuplicate = false;
			for (int j=0; j<wsmodels.size(); j++) {
				IPluginModelBase wsmodel = (IPluginModelBase)
wsmodels.get(j);
				if (isDuplicate(wsmodel, exmodel)) {
					localDuplicate=true;
					break;
				}
			}
			if (localDuplicate) duplicates=true;
			else
				result.add(exmodel);
		}
		if (duplicates) {
			showWarningDialog("The list of plug-ins to run contains 
duplicates. Plug-ins from the workspace will be used. To fix the problem, 
uncheck offending external plug-ins in the Launch Configurations");
		}
	}

In the fix above, we are setting local variable 'localDuplicate' to true if
duplicate is detected and exit the inner loop. In the outer loop, we are 
setting the main 'duplicates' variable or add the external plug-in to the list.

The fix has no effect on binary self-hosting because there are no external
plug-ins to deal with. It only affects simple and mixed self-hosting i.e.
whenever external plug-ins are used exlusively or mixed with binary workspace
plug-ins.

Value: High - the current code is plain wrong and will cause a lot of confusion
Risk: Low - we will simply do what the implementation should have been in 
the first place. I cannot see how we can make things worse than they are now -
the current code just makes no sense.
Comment 2 Dejan Glozic CLA 2002-06-25 09:19:08 EDT
Risk: Small, code is in hand
Effort: Small, code is in hand
Comment 3 Dejan Glozic CLA 2002-06-25 17:11:25 EDT
Fixed in GM3
Comment 4 Dejan Glozic CLA 2002-06-25 17:19:25 EDT
Fixed in G3