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

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ui/shared/target/messages.properties (-1 / +1 lines)
Lines 73-79 Link Here
73
EditFeatureContainerPage_3=Feature Version:
73
EditFeatureContainerPage_3=Feature Version:
74
EditFeatureContainerPage_4=Unspecified
74
EditFeatureContainerPage_4=Unspecified
75
EditFeatureContainerPage_5=Location:
75
EditFeatureContainerPage_5=Location:
76
EditIUContainerPage_0=At least one item must be selected
76
EditIUContainerPage_0=No items have been selected
77
EditIUContainerPage_1=Included Software
77
EditIUContainerPage_1=Included Software
78
EditIUContainerPage_10=Select a site or enter the location of a site.
78
EditIUContainerPage_10=Select a site or enter the location of a site.
79
EditIUContainerPage_11=Check the content that you wish to add to your target platform
79
EditIUContainerPage_11=Check the content that you wish to add to your target platform
(-)src/org/eclipse/pde/internal/ui/shared/target/EditIUContainerPage.java (-3 / +7 lines)
Lines 45-51 Link Here
45
public class EditIUContainerPage extends WizardPage implements IEditBundleContainerPage {
45
public class EditIUContainerPage extends WizardPage implements IEditBundleContainerPage {
46
46
47
	// Status for any errors on the page
47
	// Status for any errors on the page
48
	private static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.EditIUContainerPage_0);
48
	private static final IStatus BAD_IU_SELECTION = new Status(IStatus.WARNING, PDEPlugin.getPluginId(), Messages.EditIUContainerPage_0);
49
	private IStatus fSelectedIUStatus = Status.OK_STATUS;
49
	private IStatus fSelectedIUStatus = Status.OK_STATUS;
50
50
51
	// Dialog settings
51
	// Dialog settings
Lines 150-159 Link Here
150
		createDetailsArea(composite);
150
		createDetailsArea(composite);
151
		createCheckboxArea(composite);
151
		createCheckboxArea(composite);
152
152
153
		setPageComplete(false);
154
		restoreWidgetState();
153
		restoreWidgetState();
155
		setControl(composite);
154
		setControl(composite);
156
		setPageComplete(false);
155
		setPageComplete(true);
157
		if (fEditContainer == null) {
156
		if (fEditContainer == null) {
158
			PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.LOCATION_ADD_SITE_WIZARD);
157
			PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.LOCATION_ADD_SITE_WIZARD);
159
		} else {
158
		} else {
Lines 379-384 Link Here
379
			setPageComplete(false);
378
			setPageComplete(false);
380
		} else {
379
		} else {
381
			setErrorMessage(null);
380
			setErrorMessage(null);
381
			if (fSelectedIUStatus.getSeverity() == IStatus.WARNING) {
382
				setMessage(fSelectedIUStatus.getMessage(), IStatus.WARNING);
383
			} else {
384
				setMessage(Messages.EditIUContainerPage_6);
385
			}
382
			setPageComplete(true);
386
			setPageComplete(true);
383
		}
387
		}
384
	}
388
	}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java (-20 / +80 lines)
Lines 13-18 Link Here
13
import java.util.*;
13
import java.util.*;
14
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
15
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
16
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
16
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.wizard.WizardDialog;
19
import org.eclipse.jface.wizard.WizardDialog;
Lines 311-337 Link Here
311
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
312
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
312
		IBundleContainer[] containers = fTarget.getBundleContainers();
313
		IBundleContainer[] containers = fTarget.getBundleContainers();
313
		if (!selection.isEmpty() && containers != null && containers.length > 0) {
314
		if (!selection.isEmpty() && containers != null && containers.length > 0) {
314
			Set newContainers = new HashSet();
315
315
			newContainers.addAll(Arrays.asList(fTarget.getBundleContainers()));
316
			// Check if we are removing containers or IUs
316
			Iterator iterator = selection.iterator();
317
			Iterator iterator = selection.iterator();
317
			boolean removedSite = false;
318
			boolean removingIUs = true;
318
			while (iterator.hasNext()) {
319
			while (iterator.hasNext()) {
319
				Object currentSelection = iterator.next();
320
				if (!(iterator.next() instanceof IInstallableUnit)) {
320
				if (currentSelection instanceof IBundleContainer) {
321
					removingIUs = false;
321
					if (currentSelection instanceof IUBundleContainer) {
322
					break;
322
						removedSite = true;
323
					}
324
					newContainers.remove(currentSelection);
325
				}
323
				}
326
			}
324
			}
327
			if (newContainers.size() > 0) {
325
328
				fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
326
			boolean forceResolve = false;
327
328
			if (removingIUs) {
329
//				forceResolve = true;
330
//				Map newContainers
331
//				iterator = selection.iterator();
332
//				while (iterator.hasNext()) {
333
//					IInstallableUnit toRemove = (IInstallableUnit) iterator.next();
334
//					IUBundleContainer container = (IUBundleContainer) ((ITreeContentProvider) fTreeViewer.getContentProvider()).getParent(toRemove);
335
//					if (container != null) {
336
//						try {
337
//							// TODO Can we use API instead of internal to get the profile?
338
//							IInstallableUnit[] units = container.getInstallableUnits(null);
339
//							List unitList = new ArrayList(units.length);
340
//							for (int i = 0; i < units.length; i++) {
341
//								if (!toRemove.equals(units[i])) {
342
//									unitList.add(units[i]);
343
//								}
344
//							}
345
//							container.setInstallableUnits((IInstallableUnit[]) unitList.toArray(new IInstallableUnit[units.length]));
346
//						} catch (CoreException e) {
347
//							PDEPlugin.log(e);
348
//						}
349
//					}
350
//				}
351
329
			} else {
352
			} else {
330
				fTarget.setBundleContainers(null);
353
				Set newContainers = new HashSet();
354
				newContainers.addAll(Arrays.asList(fTarget.getBundleContainers()));
355
				iterator = selection.iterator();
356
				while (iterator.hasNext()) {
357
					Object currentSelection = iterator.next();
358
					if (currentSelection instanceof IBundleContainer) {
359
						if (currentSelection instanceof IUBundleContainer) {
360
							forceResolve = true;
361
						}
362
						newContainers.remove(currentSelection);
363
					}
364
				}
365
				if (newContainers.size() > 0) {
366
					fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
367
				} else {
368
					fTarget.setBundleContainers(null);
369
				}
331
			}
370
			}
332
371
333
			// If we remove a site container, the content change update must force a re-resolve bug 275458 / bug 275401
372
			// If we remove a site container, the content change update must force a re-resolve bug 275458 / bug 275401
334
			contentsChanged(removedSite);
373
			contentsChanged(forceResolve);
335
			fTreeViewer.refresh(false);
374
			fTreeViewer.refresh(false);
336
			updateButtons();
375
			updateButtons();
337
		}
376
		}
Lines 340-355 Link Here
340
	private void updateButtons() {
379
	private void updateButtons() {
341
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
380
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
342
		fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
381
		fEditButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
343
		// If any container is selected, allow the remove (the remove ignores non-container entries)
382
		// If any container is selected, or only installable units, allow the remove (the remove ignores non-container entries)
344
		boolean removeAllowed = false;
383
		boolean removeContainers = false;
384
		boolean removeUnits = true;
345
		Iterator iter = selection.iterator();
385
		Iterator iter = selection.iterator();
346
		while (iter.hasNext()) {
386
		while (iter.hasNext()) {
347
			if (iter.next() instanceof IBundleContainer) {
387
			Object next = iter.next();
348
				removeAllowed = true;
388
			if (next instanceof IBundleContainer) {
389
				removeContainers = true;
390
				// If one or more containers are selected just remove the containers ignoring everything else 
349
				break;
391
				break;
350
			}
392
			}
393
			if (!(next instanceof IInstallableUnit)) {
394
				// Only allow removal of IUs if only IUs are selected
395
				removeUnits = false;
396
			}
351
		}
397
		}
352
		fRemoveButton.setEnabled(removeAllowed);
398
		fRemoveButton.setEnabled(removeContainers || removeUnits);
353
	}
399
	}
354
400
355
	/**
401
	/**
Lines 368-373 Link Here
368
	 */
414
	 */
369
	class BundleContainerContentProvider implements ITreeContentProvider {
415
	class BundleContainerContentProvider implements ITreeContentProvider {
370
416
417
		/**
418
		 * Maps installable units to their parent container
419
		 * TODO Could cause problems if multiple site containers have the same IUs
420
		 */
421
		private Map iuParents = new HashMap();
422
371
		public Object[] getChildren(Object parentElement) {
423
		public Object[] getChildren(Object parentElement) {
372
			if (parentElement instanceof ITargetDefinition) {
424
			if (parentElement instanceof ITargetDefinition) {
373
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
425
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
Lines 388-397 Link Here
388
						}
440
						}
389
					} else if (parentElement instanceof IUBundleContainer) {
441
					} else if (parentElement instanceof IUBundleContainer) {
390
						// Show the IUs as children
442
						// Show the IUs as children
391
						// TODO See if we can get the profile using API
443
						// TODO See if we can get the profile using API instead of internal
392
						try {
444
						try {
393
							IProfile profile = ((TargetDefinition) fTarget).getProfile();
445
							IProfile profile = ((TargetDefinition) fTarget).getProfile();
394
							return ((IUBundleContainer) parentElement).getInstallableUnits(profile);
446
							IInstallableUnit[] units = ((IUBundleContainer) parentElement).getInstallableUnits(profile);
447
							// Store the unit parents so we can support removal
448
							for (int i = 0; i < units.length; i++) {
449
								iuParents.put(units[i], parentElement);
450
							}
451
							return units;
395
						} catch (CoreException e) {
452
						} catch (CoreException e) {
396
							return new Object[] {e.getStatus()};
453
							return new Object[] {e.getStatus()};
397
						}
454
						}
Lines 402-407 Link Here
402
		}
459
		}
403
460
404
		public Object getParent(Object element) {
461
		public Object getParent(Object element) {
462
			if (element instanceof IInstallableUnit) {
463
				return iuParents.get(element);
464
			}
405
			return null;
465
			return null;
406
		}
466
		}
407
467

Return to bug 276214