Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 309795 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/ExternalModelManager.java (-44 / +43 lines)
Lines 11-20 Link Here
11
package org.eclipse.pde.internal.core;
11
package org.eclipse.pde.internal.core;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.net.MalformedURLException;
14
import java.net.URL;
15
import java.net.URL;
15
import java.util.*;
16
import java.util.*;
16
import org.eclipse.core.runtime.Path;
17
import org.eclipse.core.runtime.Path;
17
import org.eclipse.pde.core.plugin.IPluginBase;
18
import org.eclipse.pde.core.plugin.IPluginModelBase;
18
import org.eclipse.pde.core.plugin.IPluginModelBase;
19
import org.eclipse.pde.internal.core.target.AbstractTargetHandle;
19
import org.eclipse.pde.internal.core.target.AbstractTargetHandle;
20
import org.eclipse.pde.internal.core.target.provisional.NameVersionDescriptor;
20
import org.eclipse.pde.internal.core.target.provisional.NameVersionDescriptor;
Lines 63-100 Link Here
63
				}
63
				}
64
			}
64
			}
65
		}
65
		}
66
		// enable pooled bundles properly (only if part of the profile)
67
		String pooled = pref.getString(ICoreConstants.POOLED_BUNDLES);
68
		if (pooled != null && pooled.trim().length() > 0) {
69
			if (ICoreConstants.VALUE_SAVED_NONE.equals(pooled)) {
70
				// all pooled bundles are disabled
71
				for (int i = 0; i < fModels.length; i++) {
72
					if (AbstractTargetHandle.BUNDLE_POOL.isPrefixOf(new Path(fModels[i].getInstallLocation()))) {
73
						fModels[i].setEnabled(false);
74
					}
75
				}
76
			} else {
77
				StringTokenizer tokenizer = new StringTokenizer(pooled, ","); //$NON-NLS-1$
78
				Set enabled = new HashSet();
79
				while (tokenizer.hasMoreTokens()) {
80
					String id = tokenizer.nextToken();
81
					if (tokenizer.hasMoreTokens()) {
82
						String ver = tokenizer.nextToken();
83
						if (ICoreConstants.VALUE_SAVED_NONE.equals(ver)) { // indicates null version
84
							ver = null;
85
						}
86
						enabled.add(new NameVersionDescriptor(id, ver));
87
					}
88
				}
89
				for (int i = 0; i < fModels.length; i++) {
90
					if (AbstractTargetHandle.BUNDLE_POOL.isPrefixOf(new Path(fModels[i].getInstallLocation()))) {
91
						IPluginBase base = fModels[i].getPluginBase();
92
						NameVersionDescriptor desc = new NameVersionDescriptor(base.getId(), base.getVersion());
93
						fModels[i].setEnabled(enabled.contains(desc));
94
					}
95
				}
96
			}
97
		}
98
	}
66
	}
99
67
100
	public void setModels(IPluginModelBase[] models) {
68
	public void setModels(IPluginModelBase[] models) {
Lines 111-134 Link Here
111
		if (tokenizer.countTokens() == 0)
79
		if (tokenizer.countTokens() == 0)
112
			return base;
80
			return base;
113
81
114
		File[] extraLocations = new File[tokenizer.countTokens()];
82
		List extraLocations = new ArrayList(tokenizer.countTokens());
115
		for (int i = 0; i < extraLocations.length; i++) {
83
		boolean addPool = false;
84
		while (tokenizer.hasMoreTokens()) {
116
			String location = tokenizer.nextToken();
85
			String location = tokenizer.nextToken();
117
			File dir = new File(location, "plugins"); //$NON-NLS-1$
86
			if (AbstractTargetHandle.BUNDLE_POOL.isPrefixOf(new Path(location))) {
118
			if (!dir.exists() || !dir.isDirectory())
87
				addPool = true;
119
				dir = new File(location);
88
			} else {
120
			extraLocations[i] = dir;
89
				File dir = new File(location, "plugins"); //$NON-NLS-1$
90
				if (!dir.exists() || !dir.isDirectory())
91
					dir = new File(location);
92
				extraLocations.add(dir);
93
			}
121
		}
94
		}
122
		URL[] additional = PluginPathFinder.scanLocations(extraLocations);
95
		URL[] additional = PluginPathFinder.scanLocations((File[]) extraLocations.toArray(new File[extraLocations.size()]));
96
		URL[] result = append(base, additional);
123
97
124
		if (additional.length == 0)
98
		// add pooled bundles (only if part of the profile)
125
			return base;
99
		if (addPool) {
100
			String pooled = pref.getString(ICoreConstants.POOLED_URLS);
101
			if (pooled != null && pooled.trim().length() > 0) {
102
				if (ICoreConstants.VALUE_SAVED_NONE.equals(pooled)) {
103
					// none
104
				} else {
105
					tokenizer = new StringTokenizer(pooled, ","); //$NON-NLS-1$
106
					List urls = new ArrayList(tokenizer.countTokens());
107
					while (tokenizer.hasMoreTokens()) {
108
						String extForm = tokenizer.nextToken();
109
						try {
110
							urls.add(new URL(extForm));
111
						} catch (MalformedURLException e) {
112
							// TODO Auto-generated catch block
113
						}
114
					}
115
					additional = (URL[]) urls.toArray(new URL[urls.size()]);
116
					result = append(result, additional);
117
				}
118
			}
119
		}
126
120
121
		return result;
122
	}
123
124
	private URL[] append(URL[] base, URL[] additional) {
125
		if (additional.length == 0) {
126
			return base;
127
		}
127
		URL[] result = new URL[base.length + additional.length];
128
		URL[] result = new URL[base.length + additional.length];
128
		System.arraycopy(base, 0, result, 0, base.length);
129
		System.arraycopy(base, 0, result, 0, base.length);
129
		System.arraycopy(additional, 0, result, base.length, additional.length);
130
		System.arraycopy(additional, 0, result, base.length, additional.length);
130
131
		return result;
131
		return result;
132
	}
132
	}
133
134
}
133
}
(-)src/org/eclipse/pde/internal/core/ICoreConstants.java (+1 lines)
Lines 38-43 Link Here
38
	String ADDITIONAL_LOCATIONS = "additional_locations"; //$NON-NLS-1$
38
	String ADDITIONAL_LOCATIONS = "additional_locations"; //$NON-NLS-1$
39
	String TARGET_PLATFORM_REALIZATION = "target_platform_realization"; //$NON-NLS-1$
39
	String TARGET_PLATFORM_REALIZATION = "target_platform_realization"; //$NON-NLS-1$
40
	String POOLED_BUNDLES = "pooled_bundles"; //$NON-NLS-1$
40
	String POOLED_BUNDLES = "pooled_bundles"; //$NON-NLS-1$
41
	String POOLED_URLS = "pooled_urls"; //$NON-NLS-1$
41
	/**
42
	/**
42
	 * List of feature ids and versions that are available in the target platform.  Features
43
	 * List of feature ids and versions that are available in the target platform.  Features
43
	 * are comma separated, with each entry taking the form of [id]@[version]
44
	 * are comma separated, with each entry taking the form of [id]@[version]
(-)src/org/eclipse/pde/internal/core/PluginModelManager.java (+15 lines)
Lines 525-530 Link Here
525
525
526
		// Create default target platform definition if required
526
		// Create default target platform definition if required
527
		initDefaultTargetPlatformDefinition();
527
		initDefaultTargetPlatformDefinition();
528
529
		// re-load the target if the corrupt POOLED_BUNDLES preference was being used
530
		PDEPreferencesManager pref = PDECore.getDefault().getPreferencesManager();
531
		String pooled = pref.getString(ICoreConstants.POOLED_BUNDLES);
532
		if (pooled != null && pooled.trim().length() > 0) {
533
			ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName());
534
			if (service != null) {
535
				try {
536
					ITargetHandle handle = service.getWorkspaceTargetHandle();
537
					LoadTargetDefinitionJob.load(handle.getTargetDefinition());
538
				} catch (CoreException e) {
539
					PDECore.log(e);
540
				}
541
			}
542
		}
528
	}
543
	}
529
544
530
	/**
545
	/**
(-)src/org/eclipse/pde/internal/core/TargetPreferenceModifyListener.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
2
 * Copyright (c) 2009, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 37-42 Link Here
37
				node.remove(ICoreConstants.NL);
37
				node.remove(ICoreConstants.NL);
38
				node.remove(ICoreConstants.PLATFORM_PATH);
38
				node.remove(ICoreConstants.PLATFORM_PATH);
39
				node.remove(ICoreConstants.POOLED_BUNDLES);
39
				node.remove(ICoreConstants.POOLED_BUNDLES);
40
				node.remove(ICoreConstants.POOLED_URLS);
40
				node.remove(ICoreConstants.PROGRAM_ARGS);
41
				node.remove(ICoreConstants.PROGRAM_ARGS);
41
				node.remove(ICoreConstants.OS);
42
				node.remove(ICoreConstants.OS);
42
				for (int i = 0; i < 4; i++) {
43
				for (int i = 0; i < 4; i++) {
(-)src/org/eclipse/pde/internal/core/target/provisional/LoadTargetDefinitionJob.java (-12 / +10 lines)
Lines 376-382 Link Here
376
					considerPool = considerPool || inPool;
376
					considerPool = considerPool || inPool;
377
					if (!duplicates.contains(desc)) {
377
					if (!duplicates.contains(desc)) {
378
						if (inPool) {
378
						if (inPool) {
379
							pooled.add(desc);
379
							pooled.add(file);
380
						}
380
						}
381
						infos.add(bundleInfo);
381
						infos.add(bundleInfo);
382
						included.add(bundleInfo);
382
						included.add(bundleInfo);
Lines 466-494 Link Here
466
			if (pooled.isEmpty()) {
466
			if (pooled.isEmpty()) {
467
				if (considerPool) {
467
				if (considerPool) {
468
					// all pooled bundles are excluded
468
					// all pooled bundles are excluded
469
					pref.setValue(ICoreConstants.POOLED_BUNDLES, ICoreConstants.VALUE_SAVED_NONE);
469
					pref.setValue(ICoreConstants.POOLED_URLS, ICoreConstants.VALUE_SAVED_NONE);
470
				} else {
470
				} else {
471
					// nothing in the pool
471
					// nothing in the pool
472
					pref.setValue(ICoreConstants.POOLED_BUNDLES, ""); //$NON-NLS-1$
472
					pref.setValue(ICoreConstants.POOLED_URLS, ""); //$NON-NLS-1$
473
				}
473
				}
474
			} else {
474
			} else {
475
				StringBuffer buf = new StringBuffer();
475
				StringBuffer buf = new StringBuffer();
476
				Iterator iterator2 = pooled.iterator();
476
				Iterator iterator2 = pooled.iterator();
477
				while (iterator2.hasNext()) {
477
				while (iterator2.hasNext()) {
478
					NameVersionDescriptor desc = (NameVersionDescriptor) iterator2.next();
478
					File bundle = (File) iterator2.next();
479
					buf.append(desc.getId());
479
					try {
480
					buf.append(',');
480
						buf.append(bundle.toURL().toExternalForm());
481
					String version = desc.getVersion();
481
					} catch (MalformedURLException e) {
482
					if (version == null) {
482
						// TODO:
483
						buf.append(ICoreConstants.VALUE_SAVED_NONE); // indicates null version
484
					} else {
485
						buf.append(version);
486
					}
483
					}
487
					if (iterator2.hasNext()) {
484
					if (iterator2.hasNext()) {
488
						buf.append(',');
485
						buf.append(',');
489
					}
486
					}
490
				}
487
				}
491
				pref.setValue(ICoreConstants.POOLED_BUNDLES, buf.toString());
488
				pref.setValue(ICoreConstants.POOLED_URLS, buf.toString());
489
				pref.setValue(ICoreConstants.POOLED_BUNDLES, ""); // NO LONGER USED //$NON-NLS-1$
492
			}
490
			}
493
491
494
			// Save the feature list for the external feature model manager to EXTERNAL_FEATURES
492
			// Save the feature list for the external feature model manager to EXTERNAL_FEATURES

Return to bug 309795