diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java index f66eec1b096..9c61ab98bf1 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java @@ -80,15 +80,15 @@ */ public class IUBundleContainer extends AbstractBundleContainer { - record UnitDeclaration(String id, VersionRange version) { + record UnitDeclaration(String id, VersionRange version, boolean hasVersion) { private static final String EMPTY_VERSION = Version.emptyVersion.toString(); static UnitDeclaration parse(String id, String version) { version = version.strip(); if (version.isEmpty() || version.equals(EMPTY_VERSION)) { - return new UnitDeclaration(id, VersionRange.emptyRange); + return new UnitDeclaration(id, VersionRange.emptyRange, !version.isEmpty()); } else if (version.contains(",")) { //$NON-NLS-1$ - return new UnitDeclaration(id, VersionRange.create(version)); + return new UnitDeclaration(id, VersionRange.create(version), true); } else { return create(id, Version.parseVersion(version)); } @@ -96,7 +96,7 @@ static UnitDeclaration parse(String id, String version) { static UnitDeclaration create(String id, Version version) { VersionRange range = new VersionRange(version, true, version, true); - return new UnitDeclaration(id, range); + return new UnitDeclaration(id, range, true); } UnitDeclaration { @@ -746,7 +746,7 @@ public String serialize() { fIUs.stream().sorted(BY_ID_THEN_VERSION).forEach(iu -> { Element unit = document.createElement(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT); unit.setAttribute(TargetDefinitionPersistenceHelper.ATTR_ID, iu.id()); - if (!iu.hasEmptyVersion()) { + if (iu.hasVersion()) { unit.setAttribute(TargetDefinitionPersistenceHelper.ATTR_VERSION, iu.versionString()); } containerElement.appendChild(unit); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditIUContainerPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditIUContainerPage.java index 0a19acd55b4..edee2d89290 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditIUContainerPage.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/EditIUContainerPage.java @@ -93,6 +93,9 @@ public class EditIUContainerPage extends WizardPage implements IEditBundleContai private static final int REFRESH_INTERVAL = 4000; private static final int REFRESH_TRIES = 10; + private static final String EMPTY_VERSION = Version.emptyVersion.toString(); + private static final String LATEST_LABEL = Messages.EditIUContainerPage_Latest_Label; + /** * If the user is only downloading from a specific repository location, we store it here so it can be persisted in the target */ @@ -337,9 +340,6 @@ protected CellEditor getCellEditor(Object element) { return treeViewer; } - private static final String EMPTY_VERSION = Version.emptyVersion.toString(); - private static final String LATEST_LABEL = Messages.EditIUContainerPage_Latest_Label; - private static String sanitizeVersionSpecification(String spec) { spec = spec.strip(); return LATEST_LABEL.equals(spec) ? EMPTY_VERSION : spec;