BUG 2040986 : SDK Updater, platform dependency on tools
This commit is contained in:
@@ -33,10 +33,29 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class ExtraPackage extends Package {
|
public class ExtraPackage extends Package {
|
||||||
|
|
||||||
private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
|
private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
|
||||||
|
private static final String PROP_MIN_TOOLS_REV = "Extra.MinToolsRev"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The install folder name. It must be a single-segment path.
|
||||||
|
* The paths "add-ons", "platforms", "tools" and "docs" are reserved and cannot be used.
|
||||||
|
* This limitation cannot be written in the XML Schema and must be enforced here by using
|
||||||
|
* the method {@link #isPathValid()} *before* installing the package.
|
||||||
|
*/
|
||||||
private final String mPath;
|
private final String mPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimal revision of the tools package required by this extra package, if > 0,
|
||||||
|
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
|
||||||
|
*/
|
||||||
|
private final int mMinToolsRevision;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
|
||||||
|
* was not specified in the XML source.
|
||||||
|
*/
|
||||||
|
public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new tool package from the attributes and elements of the given XML node.
|
* Creates a new tool package from the attributes and elements of the given XML node.
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -45,6 +64,8 @@ public class ExtraPackage extends Package {
|
|||||||
ExtraPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
|
ExtraPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
|
||||||
super(source, packageNode, licenses);
|
super(source, packageNode, licenses);
|
||||||
mPath = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_PATH);
|
mPath = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_PATH);
|
||||||
|
mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
|
||||||
|
MIN_TOOLS_REV_NOT_SPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +94,9 @@ public class ExtraPackage extends Package {
|
|||||||
archiveOsPath);
|
archiveOsPath);
|
||||||
// The path argument comes before whatever could be in the properties
|
// The path argument comes before whatever could be in the properties
|
||||||
mPath = path != null ? path : getProperty(props, PROP_PATH, path);
|
mPath = path != null ? path : getProperty(props, PROP_PATH, path);
|
||||||
|
|
||||||
|
mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
|
||||||
|
Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,6 +108,10 @@ public class ExtraPackage extends Package {
|
|||||||
super.saveProperties(props);
|
super.saveProperties(props);
|
||||||
|
|
||||||
props.setProperty(PROP_PATH, mPath);
|
props.setProperty(PROP_PATH, mPath);
|
||||||
|
|
||||||
|
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||||
|
props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,6 +137,14 @@ public class ExtraPackage extends Package {
|
|||||||
return mPath;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimal revision of the tools package required by this extra package, if > 0,
|
||||||
|
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
|
||||||
|
*/
|
||||||
|
public int getMinToolsRevision() {
|
||||||
|
return mMinToolsRevision;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a short description for an {@link IDescription}. */
|
/** Returns a short description for an {@link IDescription}. */
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
@@ -134,18 +170,32 @@ public class ExtraPackage extends Package {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return String.format("%1$s package, revision %2$d",
|
String s = String.format("%1$s package, revision %2$d",
|
||||||
name,
|
name,
|
||||||
getRevision());
|
getRevision());
|
||||||
|
|
||||||
|
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||||
|
s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a long description for an {@link IDescription}. */
|
/** Returns a long description for an {@link IDescription}. */
|
||||||
@Override
|
@Override
|
||||||
public String getLongDescription() {
|
public String getLongDescription() {
|
||||||
return String.format("Extra %1$s package, revision %2$d.\n%3$s",
|
String s = String.format("Extra %1$s package, revision %2$d",
|
||||||
getPath(),
|
getPath(),
|
||||||
getRevision(),
|
getRevision());
|
||||||
super.getLongDescription());
|
|
||||||
|
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||||
|
s += String.format(" (min tools rev.: %1$d)", mMinToolsRevision);
|
||||||
|
}
|
||||||
|
|
||||||
|
s += ".\n";
|
||||||
|
s += super.getLongDescription();
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,11 +35,27 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class PlatformPackage extends Package {
|
public class PlatformPackage extends Package {
|
||||||
|
|
||||||
private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
|
private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
|
||||||
|
private static final String PROP_MIN_TOOLS_REV = "Platform.MinToolsRev"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/** The package version, for platform, add-on and doc packages. */
|
||||||
private final AndroidVersion mVersion;
|
private final AndroidVersion mVersion;
|
||||||
|
|
||||||
|
/** The version, a string, for platform packages. */
|
||||||
private final String mVersionName;
|
private final String mVersionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimal revision of the tools package required by this extra package, if > 0,
|
||||||
|
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
|
||||||
|
*/
|
||||||
|
private final int mMinToolsRevision;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
|
||||||
|
* was not specified in the XML source.
|
||||||
|
*/
|
||||||
|
public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new platform package from the attributes and elements of the given XML node.
|
* Creates a new platform package from the attributes and elements of the given XML node.
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -54,6 +70,9 @@ public class PlatformPackage extends Package {
|
|||||||
codeName = null;
|
codeName = null;
|
||||||
}
|
}
|
||||||
mVersion = new AndroidVersion(apiLevel, codeName);
|
mVersion = new AndroidVersion(apiLevel, codeName);
|
||||||
|
|
||||||
|
mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
|
||||||
|
MIN_TOOLS_REV_NOT_SPECIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +95,9 @@ public class PlatformPackage extends Package {
|
|||||||
|
|
||||||
mVersion = target.getVersion();
|
mVersion = target.getVersion();
|
||||||
mVersionName = target.getVersionName();
|
mVersionName = target.getVersionName();
|
||||||
|
|
||||||
|
mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
|
||||||
|
Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,9 +109,14 @@ public class PlatformPackage extends Package {
|
|||||||
super.saveProperties(props);
|
super.saveProperties(props);
|
||||||
|
|
||||||
mVersion.saveProperties(props);
|
mVersion.saveProperties(props);
|
||||||
|
|
||||||
if (mVersionName != null) {
|
if (mVersionName != null) {
|
||||||
props.setProperty(PROP_VERSION, mVersionName);
|
props.setProperty(PROP_VERSION, mVersionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||||
|
props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the version, a string, for platform packages. */
|
/** Returns the version, a string, for platform packages. */
|
||||||
@@ -102,17 +129,32 @@ public class PlatformPackage extends Package {
|
|||||||
return mVersion;
|
return mVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimal revision of the tools package required by this extra package, if > 0,
|
||||||
|
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
|
||||||
|
*/
|
||||||
|
public int getMinToolsRevision() {
|
||||||
|
return mMinToolsRevision;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a short description for an {@link IDescription}. */
|
/** Returns a short description for an {@link IDescription}. */
|
||||||
@Override
|
@Override
|
||||||
public String getShortDescription() {
|
public String getShortDescription() {
|
||||||
if (mVersion.isPreview()) {
|
String s;
|
||||||
return String.format("SDK Platform Android %1$s (Preview)",
|
|
||||||
getVersionName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.format("SDK Platform Android %1$s, API %2$d",
|
if (mVersion.isPreview()) {
|
||||||
|
s = String.format("SDK Platform Android %1$s (Preview)", getVersionName());
|
||||||
|
} else {
|
||||||
|
s = String.format("SDK Platform Android %1$s, API %2$d",
|
||||||
getVersionName(),
|
getVersionName(),
|
||||||
mVersion.getApiLevel());
|
mVersion.getApiLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
|
||||||
|
s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a long description for an {@link IDescription}. */
|
/** Returns a long description for an {@link IDescription}. */
|
||||||
|
|||||||
@@ -49,19 +49,21 @@ public class SdkRepository {
|
|||||||
public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
|
public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The license definition. */
|
/** The license definition. */
|
||||||
public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
|
public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
|
||||||
/** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */
|
/** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */
|
||||||
public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
|
public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
|
||||||
/** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */
|
/** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */
|
||||||
public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
|
public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
|
||||||
/** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */
|
/** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */
|
||||||
public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
|
public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||||
/** The optional description URL for all packages (platform, add-on, tool, doc). */
|
/** The optional description URL for all packages (platform, add-on, tool, doc). */
|
||||||
public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
|
public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
|
||||||
/** The optional release note for all packages (platform, add-on, tool, doc). */
|
/** The optional release note for all packages (platform, add-on, tool, doc). */
|
||||||
public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
|
public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
|
||||||
/** The optional release note URL for all packages (platform, add-on, tool, doc). */
|
/** The optional release note URL for all packages (platform, add-on, tool, doc). */
|
||||||
public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
|
public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
|
||||||
|
/** The optional minimal tools revision required by platform & extra packages. */
|
||||||
|
public static final String NODE_MIN_TOOLS_REV = "min-tools-rev"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** The version, a string, for platform packages. */
|
/** The version, a string, for platform packages. */
|
||||||
public static final String NODE_VERSION = "version"; //$NON-NLS-1$
|
public static final String NODE_VERSION = "version"; //$NON-NLS-1$
|
||||||
|
|||||||
@@ -71,6 +71,9 @@
|
|||||||
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
|
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
|
||||||
<!-- A list of file archives for this package. -->
|
<!-- A list of file archives for this package. -->
|
||||||
<xsd:element name="archives" type="sdk:archivesType" />
|
<xsd:element name="archives" type="sdk:archivesType" />
|
||||||
|
<!-- The minimal revision of tools required by this package.
|
||||||
|
Optional. If present, must be an int > 0. -->
|
||||||
|
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
|
||||||
</xsd:all>
|
</xsd:all>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
@@ -241,6 +244,9 @@
|
|||||||
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
|
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
|
||||||
<!-- A list of file archives for this package. -->
|
<!-- A list of file archives for this package. -->
|
||||||
<xsd:element name="archives" type="sdk:archivesType" />
|
<xsd:element name="archives" type="sdk:archivesType" />
|
||||||
|
<!-- The minimal revision of tools required by this package.
|
||||||
|
Optional. If present, must be an int > 0. -->
|
||||||
|
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
|
||||||
</xsd:all>
|
</xsd:all>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
for this package. It's a free multi-line text.
|
for this package. It's a free multi-line text.
|
||||||
</sdk:release-note>
|
</sdk:release-note>
|
||||||
<sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url>
|
<sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url>
|
||||||
|
<sdk:min-tools-rev>2</sdk:min-tools-rev>
|
||||||
<!-- The archives node is mandatory and it cannot be empty. -->
|
<!-- The archives node is mandatory and it cannot be empty. -->
|
||||||
<sdk:archives>
|
<sdk:archives>
|
||||||
<sdk:archive os="any">
|
<sdk:archive os="any">
|
||||||
@@ -268,6 +269,7 @@
|
|||||||
</sdk:archives>
|
</sdk:archives>
|
||||||
<sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description>
|
<sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description>
|
||||||
<sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
|
<sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
|
||||||
|
<sdk:min-tools-rev>3</sdk:min-tools-rev>
|
||||||
</sdk:extra>
|
</sdk:extra>
|
||||||
|
|
||||||
</sdk:sdk-repository>
|
</sdk:sdk-repository>
|
||||||
|
|||||||
@@ -38,11 +38,13 @@ import org.eclipse.swt.events.ControlAdapter;
|
|||||||
import org.eclipse.swt.events.ControlEvent;
|
import org.eclipse.swt.events.ControlEvent;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Rectangle;
|
import org.eclipse.swt.graphics.Rectangle;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Group;
|
import org.eclipse.swt.widgets.Group;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
@@ -105,18 +107,6 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
|
|||||||
mColumnSource.setWidth(289);
|
mColumnSource.setWidth(289);
|
||||||
mColumnSource.setText("Sources, Packages and Archives");
|
mColumnSource.setText("Sources, Packages and Archives");
|
||||||
|
|
||||||
Composite composite = new Composite(parent, SWT.NONE);
|
|
||||||
composite.setLayoutData(
|
|
||||||
new GridData(SWT.FILL, SWT.BEGINNING, false, false, 5, 1));
|
|
||||||
GridLayout gl;
|
|
||||||
composite.setLayout(gl = new GridLayout(2, false));
|
|
||||||
gl.marginHeight = gl.marginWidth = 0;
|
|
||||||
// add an empty composite
|
|
||||||
Composite spacer = new Composite(composite, SWT.NONE);
|
|
||||||
GridData gd;
|
|
||||||
spacer.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
|
|
||||||
gd.heightHint = 0;
|
|
||||||
|
|
||||||
mDescriptionContainer = new Group(parent, SWT.NONE);
|
mDescriptionContainer = new Group(parent, SWT.NONE);
|
||||||
mDescriptionContainer.setLayout(new GridLayout(1, false));
|
mDescriptionContainer.setLayout(new GridLayout(1, false));
|
||||||
mDescriptionContainer.setText("Description");
|
mDescriptionContainer.setText("Description");
|
||||||
|
|||||||
Reference in New Issue
Block a user