aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
Diffstat (limited to 'sdkmanager')
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/repository/TestSdkRepository.java7
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample.xml275
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java25
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java235
-rw-r--r--sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java2
5 files changed, 116 insertions, 428 deletions
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/TestSdkRepository.java b/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/TestSdkRepository.java
index 5d639ec..7f1d967 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/TestSdkRepository.java
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/TestSdkRepository.java
@@ -16,6 +16,8 @@
package com.android.sdklib.repository;
+import com.android.ide.eclipse.tests.AdtTestData;
+
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -123,9 +125,8 @@ public class TestSdkRepository extends TestCase {
/** Validate a valid sample using an InputStream */
public void testValidateLocalRepositoryFile() throws Exception {
- InputStream xmlStream =
- TestSdkRepository.class.getResourceAsStream(
- "/com/android/sdklib/testdata/repository_sample.xml");
+ InputStream xmlStream = AdtTestData.getInstance().getTestFileStream(
+ "repository_sample.xml");
Source source = new StreamSource(xmlStream);
CaptureErrorHandler handler = new CaptureErrorHandler();
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample.xml b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample.xml
deleted file mode 100755
index c90e18d..0000000
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample.xml
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version="1.0"?>
-<!--
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
--->
-<sdk:sdk-repository
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:sdk="http://schemas.android.com/sdk/android/repository/1">
-
- <!-- Define a couple of licenses. These will be referenced by uses-license later. -->
-
- <sdk:license type="text" id="license1">
- This is the license
- for this platform.
- </sdk:license>
-
- <sdk:license id="license2">
- Licenses are only of type 'text' right now, so this is implied.
- </sdk:license>
-
- <!-- Inner elements must be either platform, add-on, doc or tool.
- There can be 0 or more of each, in any order. -->
-
- <sdk:platform>
- <sdk:version>1.0</sdk:version>
- <sdk:api-level>1</sdk:api-level>
- <sdk:revision>3</sdk:revision>
- <sdk:uses-license ref="license1" />
- <sdk:description>Some optional description</sdk:description>
- <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url>
- <sdk:release-note>This is an optional release note
- for this package. It's a free multi-line text.
- </sdk:release-note>
- <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. -->
- <sdk:archives>
- <sdk:archive os="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>http://www.example.com/files/plat1.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:platform>
-
- <sdk:doc>
- <sdk:api-level>1</sdk:api-level>
- <sdk:revision>1</sdk:revision>
- <!-- the license element is not mandatory. -->
- <sdk:description>Some optional description</sdk:description>
- <sdk:desc-url>http://www.example.com/docs.html</sdk:desc-url>
- <sdk:archives>
- <sdk:archive os="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>http://www.example.com/docs/docs1.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:doc>
-
- <sdk:add-on>
- <sdk:name>My First add-on</sdk:name>
- <sdk:api-level>1</sdk:api-level>
- <sdk:vendor>John Doe</sdk:vendor>
- <sdk:revision>1</sdk:revision>
- <sdk:uses-license ref="license2" />
- <sdk:description>Some optional description</sdk:description>
- <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url>
- <sdk:archives>
- <sdk:archive os="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- <!-- The libs node is mandatory, however it can be empty. -->
- <sdk:libs>
- <sdk:lib>
- <sdk:name>android.blah.somelib</sdk:name>
- <sdk:description>The description for this library.</sdk:description>
- </sdk:lib>
- <sdk:lib>
- <!-- sdk:description is optional, name is not -->
- <sdk:name>com.android.mymaps</sdk:name>
- </sdk:lib>
- </sdk:libs>
- </sdk:add-on>
-
- <sdk:platform>
- <sdk:version>1.1</sdk:version>
- <sdk:api-level>2</sdk:api-level>
- <sdk:revision>12</sdk:revision>
- <sdk:uses-license ref="license1" />
- <!-- sdk:description and sdk:desc-url are optional -->
- <sdk:archives>
- <sdk:archive os="windows">
- <!-- arch attribute is optional -->
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/platform-2-12-win.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="macosx" arch="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/platform-2-12-mac.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="macosx" arch="ppc">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/platform-2-12-mac.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="linux" arch="x86">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url>
- </sdk:archive>
- <sdk:archive os="linux" arch="x86_64">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/platform-2-12-linux.tar.bz2</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:platform>
-
- <sdk:add-on>
- <sdk:name>My Second add-on</sdk:name>
- <sdk:api-level>2</sdk:api-level>
- <sdk:vendor>John Deer</sdk:vendor>
- <sdk:revision>42</sdk:revision>
- <sdk:archives>
- <sdk:archive os="windows">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/second-42-win.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="linux">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url>
- </sdk:archive>
- </sdk:archives>
- <sdk:libs>
- <sdk:lib>
- <sdk:name>android.blah.somelib</sdk:name>
- <sdk:description>The description for this library.</sdk:description>
- </sdk:lib>
- <sdk:lib>
- <sdk:name>com.android.mymaps</sdk:name>
- </sdk:lib>
- </sdk:libs>
- <sdk:uses-license ref="license2" />
- </sdk:add-on>
-
- <sdk:platform>
- <sdk:version>Pastry</sdk:version>
- <sdk:api-level>5</sdk:api-level>
- <sdk:codename>Pastry</sdk:codename>
- <sdk:revision>3</sdk:revision>
- <sdk:uses-license ref="license1" />
- <sdk:description>Preview version for Pastry</sdk:description>
- <sdk:desc-url>http://www.example.com/platform1.html</sdk:desc-url>
- <!-- The archives node is mandatory and it cannot be empty. -->
- <sdk:archives>
- <sdk:archive os="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>http://www.example.com/files/plat1.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:platform>
-
- <sdk:tool>
- <sdk:revision>1</sdk:revision>
- <sdk:description>Some optional description</sdk:description>
- <sdk:desc-url>http://www.example.com/tools.html</sdk:desc-url>
- <sdk:uses-license ref="license1" />
- <sdk:archives>
- <sdk:archive os="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>http://www.example.com/files/tools1.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:tool>
-
- <sdk:doc>
- <sdk:api-level>2</sdk:api-level>
- <sdk:revision>42</sdk:revision>
- <sdk:uses-license ref="license2" />
- <sdk:archives>
- <sdk:archive os="windows">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/docs/2.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="linux">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/docs2-linux.tar.bz2</sdk:url>
- </sdk:archive>
- <sdk:archive os="macosx">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/docs2-mac.tar.bz2</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:doc>
-
- <sdk:tool>
- <sdk:revision>42</sdk:revision>
- <sdk:uses-license ref="license1" />
- <sdk:archives>
- <sdk:archive os="windows">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/tools/2.zip</sdk:url>
- </sdk:archive>
- <sdk:archive os="linux">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/tools2-linux.tar.bz2</sdk:url>
- </sdk:archive>
- <sdk:archive os="macosx">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/tools2-mac.tar.bz2</sdk:url>
- </sdk:archive>
- </sdk:archives>
- </sdk:tool>
-
- <sdk:add-on>
- <sdk:uses-license ref="license2" />
- <sdk:name>This add-on has no libraries</sdk:name>
- <sdk:api-level>4</sdk:api-level>
- <sdk:vendor>Joe Bar</sdk:vendor>
- <sdk:revision>3</sdk:revision>
- <sdk:archives>
- <sdk:archive os="any" arch="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- <!-- The libs node is mandatory, however it can be empty. -->
- <sdk:libs />
- </sdk:add-on>
-
- <sdk:extra>
- <sdk:path>usb_driver</sdk:path>
- <sdk:uses-license ref="license2" />
- <sdk:revision>43</sdk:revision>
- <sdk:archives>
- <sdk:archive os="any" arch="any">
- <sdk:size>65536</sdk:size>
- <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
- <sdk:url>distrib/extraduff.zip</sdk:url>
- </sdk:archive>
- </sdk:archives>
- <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:min-tools-rev>3</sdk:min-tools-rev>
- </sdk:extra>
-
-</sdk:sdk-repository>
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
index 8757e66..861389f 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
@@ -283,7 +283,32 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
SettingsController controller = mUpdaterData.getSettingsController();
controller.setShowUpdateOnly(mUpdateOnlyCheckBox.getSelection());
controller.saveSettings();
+
+ // Get the list of selected archives
+ ArrayList<Archive> archives = new ArrayList<Archive>();
+ for (Object element : mTreeViewerSources.getCheckedElements()) {
+ if (element instanceof Archive) {
+ archives.add((Archive) element);
+ }
+ // Deselect them all
+ mTreeViewerSources.setChecked(element, false);
+ }
+
mTreeViewerSources.refresh();
+
+ // Now reselect those that still exist in the tree but only if they
+ // are compatible archives
+ for (Archive a : archives) {
+ if (a.isCompatible() && mTreeViewerSources.setChecked(a, true)) {
+ // If we managed to select the archive, also select the parent package.
+ // Technically we should only select the parent package if *all* the
+ // compatible archives children are selected. In practice we'll rarely
+ // have more than one compatible archive per package.
+ mTreeViewerSources.setChecked(a.getParentPackage(), true);
+ }
+ }
+
+ updateButtonsState();
}
private void onInstallSelectedArchives() {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java
index 11919a0..6a139de 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdateChooserDialog.java
@@ -22,13 +22,16 @@ import com.android.sdklib.internal.repository.Archive;
import com.android.sdklib.internal.repository.IPackageVersion;
import com.android.sdklib.internal.repository.Package;
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
+import com.android.sdkuilib.ui.GridDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyleRange;
@@ -37,8 +40,6 @@ import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -46,8 +47,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
@@ -60,25 +60,16 @@ import java.util.ArrayList;
/**
* Implements an {@link UpdateChooserDialog}.
*/
-final class UpdateChooserDialog extends Dialog {
-
- /** Min Y location for dialog. Need to deal with the menu bar on mac os. */
- private final static int MIN_Y =
- SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN ? 20 : 0;
+final class UpdateChooserDialog extends GridDialog {
/** Last dialog size for this session. */
private static Point sLastSize;
- private boolean mCancelled = true;
- private boolean mCompleted;
private boolean mLicenseAcceptAll;
private boolean mInternalLicenseRadioUpdate;
// UI fields
- private Shell mDialogShell;
private SashForm mSashForm;
private Composite mPackageRootComposite;
- private Button mCancelButton;
- private Button mInstallButton;
private TableViewer mTableViewPackage;
private Table mTablePackage;
private TableColumn mTableColum;
@@ -114,12 +105,16 @@ final class UpdateChooserDialog extends Dialog {
public UpdateChooserDialog(Shell parentShell,
UpdaterData updaterData,
ArrayList<ArchiveInfo> archives) {
- super(parentShell,
- SWT.APPLICATION_MODAL);
+ super(parentShell, 3, false/*makeColumnsEqual*/);
mUpdaterData = updaterData;
mArchives = archives;
}
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
/**
* Returns the results, i.e. the list of selected new archives to install.
* This is similar to the {@link ArchiveInfo} list instance given to the constructor
@@ -130,7 +125,7 @@ final class UpdateChooserDialog extends Dialog {
public ArrayList<ArchiveInfo> getResult() {
ArrayList<ArchiveInfo> ais = new ArrayList<ArchiveInfo>();
- if (!mCancelled) {
+ if (getReturnCode() == Window.OK) {
for (ArchiveInfo ai : mArchives) {
if (ai.isAccepted()) {
ais.add(ai);
@@ -142,45 +137,13 @@ final class UpdateChooserDialog extends Dialog {
}
/**
- * Open the dialog and blocks till it gets closed
- */
- public void open() {
- createContents();
- positionShell(); //$hide$ (hide from SWT designer)
- mDialogShell.open();
- mDialogShell.layout();
-
- postCreate(); //$hide$ (hide from SWT designer)
-
- Display display = getParent().getDisplay();
- while (!mDialogShell.isDisposed() && !mCompleted) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
-
- if (!mDialogShell.isDisposed()) {
- mDialogShell.close();
- }
- }
-
- /**
- * Create contents of the dialog.
+ * Create the main content of the dialog.
+ * See also {@link #createButtonBar(Composite)} below.
*/
- private void createContents() {
- mDialogShell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
- mDialogShell.addShellListener(new ShellAdapter() {
- @Override
- public void shellClosed(ShellEvent e) {
- onShellClosed(e);
- }
- });
- mDialogShell.setLayout(new GridLayout(3, false/*makeColumnsEqual*/));
- mDialogShell.setSize(600, 400);
- mDialogShell.setText("Choose Packages to Install");
-
+ @Override
+ public void createDialogContent(Composite parent) {
// Sash form
- mSashForm = new SashForm(mDialogShell, SWT.NONE);
+ mSashForm = new SashForm(parent, SWT.NONE);
mSashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
@@ -223,7 +186,7 @@ final class UpdateChooserDialog extends Dialog {
mPackageText = new StyledText(mPackageTextGroup, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
mPackageText.setBackground(
- getParent().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ getParentShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
mPackageText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
mLicenseRadioAccept = new Button(mPackageRootComposite, SWT.RADIO);
@@ -257,58 +220,67 @@ final class UpdateChooserDialog extends Dialog {
});
mSashForm.setWeights(new int[] {200, 300});
+ }
- // Error message area
+ /**
+ * Creates and returns the contents of this dialog's button bar.
+ * <p/>
+ * This reimplements most of the code from the base class with a few exceptions:
+ * <ul>
+ * <li>Enforces 3 columns.
+ * <li>Inserts a full-width error label.
+ * <li>Inserts a help label on the left of the first button.
+ * <li>Renames the OK button into "Install"
+ * </ul>
+ */
+ @Override
+ protected Control createButtonBar(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 0; // this is incremented by createButton
+ layout.makeColumnsEqualWidth = false;
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ composite.setLayout(layout);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
+ composite.setLayoutData(data);
+ composite.setFont(parent.getFont());
- mErrorLabel = new Label(mDialogShell, SWT.NONE);
+ // Error message area
+ mErrorLabel = new Label(composite, SWT.NONE);
mErrorLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+ // Label at the left of the install/cancel buttons
+ Label label = new Label(composite, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ label.setText("[*] Something depends on this package");
+ label.setEnabled(false);
+ layout.numColumns++;
- // Bottom buttons area
+ // Add the ok/cancel to the button bar.
+ createButtonsForButtonBar(composite);
- placeholder = new Label(mDialogShell, SWT.NONE);
- placeholder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- placeholder.setText("[*] Something depends on this package");
- placeholder.setEnabled(false);
+ // the ok button should be an "install" button
+ Button button = getButton(IDialogConstants.OK_ID);
+ button.setText("Install");
- // for MacOS, the Cancel button should be left.
- if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_DARWIN) {
- mCancelButton = new Button(mDialogShell, SWT.PUSH);
- }
-
- mInstallButton = new Button(mDialogShell, SWT.PUSH);
- mInstallButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- mInstallButton.setText("Install Accepted");
- mInstallButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- onInstallSelected();
- }
- });
-
- // if we haven't created the cancel button yet (macos?), create it now.
- if (mCancelButton == null) {
- mCancelButton = new Button(mDialogShell, SWT.PUSH);
- }
- mCancelButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- mCancelButton.setText("Cancel");
- mCancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- onCancelSelected();
- }
- });
+ return composite;
}
// -- End of UI, Start of internal logic ----------
// Hide everything down-below from SWT designer
//$hide>>$
- /**
- * Starts the thread that runs the task.
- * This is deferred till the UI is created.
- */
- private void postCreate() {
+ @Override
+ public void create() {
+ super.create();
+
+ // set window title
+ getShell().setText("Choose Packages to Install");
+
setWindowImage();
// Automatically accept those with an empty license or no license
@@ -344,7 +316,7 @@ final class UpdateChooserDialog extends Dialog {
if (mUpdaterData != null) {
ImageFactory imgFactory = mUpdaterData.getImageFactory();
if (imgFactory != null) {
- mDialogShell.setImage(imgFactory.getImageByName(imageName));
+ getShell().setImage(imgFactory.getImageByName(imageName));
}
}
}
@@ -369,69 +341,33 @@ final class UpdateChooserDialog extends Dialog {
}
/**
- * Callback invoked when the shell is closed either by clicking the close button
- * on by calling shell.close().
* Captures the window size before closing this.
+ * @see #getInitialSize()
*/
- private void onShellClosed(ShellEvent e) {
- sLastSize = mDialogShell.getSize();
+ @Override
+ public boolean close() {
+ sLastSize = getShell().getSize();
+ return super.close();
}
/**
- * Centers the dialog in its parent shell.
+ * Tries to reuse the last window size during this session.
+ * <p/>
+ * Note: the alternative would be to implement {@link #getDialogBoundsSettings()}
+ * since the default {@link #getDialogBoundsStrategy()} is to persist both location
+ * and size.
*/
- private void positionShell() {
- // Centers the dialog in its parent shell
- Shell child = mDialogShell;
- Shell parent = getParent();
- if (child != null && parent != null) {
-
- // get the parent client area with a location relative to the display
- Rectangle parentArea = parent.getClientArea();
- Point parentLoc = parent.getLocation();
- int px = parentLoc.x;
- int py = parentLoc.y;
- int pw = parentArea.width;
- int ph = parentArea.height;
-
- // Reuse the last size if there's one, otherwise use the default
- Point childSize = sLastSize != null ? sLastSize : child.getSize();
- int cw = childSize.x;
- int ch = childSize.y;
-
- int x = px + (pw - cw) / 2;
- int y = py + (ph - ch) / 2;
-
- if (x < 0) {
- x = 0;
- }
-
- if (y < MIN_Y) {
- y = MIN_Y;
- }
-
- child.setLocation(x, y);
- child.setSize(cw, ch);
+ @Override
+ protected Point getInitialSize() {
+ if (sLastSize != null) {
+ return sLastSize;
+ } else {
+ // Arbitrary values that look good on my screen and fit on 800x600
+ return new Point(740, 370);
}
}
/**
- * Callback invoked when the Install button is selected. Completes the dialog.
- */
- private void onInstallSelected() {
- mCancelled = false;
- mCompleted = true;
- }
-
- /**
- * Callback invoked when the Cancel button is selected.
- */
- private void onCancelSelected() {
- mCancelled = true;
- mCompleted = true;
- }
-
- /**
* Callback invoked when a package item is selected in the list.
*/
private void onPackageSelected() {
@@ -634,7 +570,8 @@ final class UpdateChooserDialog extends Dialog {
}
}
}
- mInstallButton.setEnabled(!missing && oneAccepted);
+
+ getButton(IDialogConstants.OK_ID).setEnabled(!missing && oneAccepted);
mInternalLicenseRadioUpdate = false;
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java
index 720ee12..a2a9218 100644
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/widgets/AvdStartDialog.java
@@ -374,7 +374,7 @@ final class AvdStartDialog extends GridDialog {
}
if (sMonitorDpi == -1) { // first time? try to get a value
- sMonitorDpi = Toolkit.getDefaultToolkit().getScreenResolution();
+ sMonitorDpi = Toolkit.getDefaultToolkit().getScreenResolution();
}
return sMonitorDpi;