aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdkuilib/src
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-02-09 18:52:30 -0800
committerRaphael <raphael@google.com>2012-02-09 18:52:30 -0800
commitcb9b055bbcaeae59e55cd9f165845520a2fd5212 (patch)
treee460f41e43f6722abd64ec23e8428c9508fb13f0 /sdkmanager/libs/sdkuilib/src
parent4dca141833f4699d8305d42c4149645bddd6c5b4 (diff)
downloadsdk-cb9b055bbcaeae59e55cd9f165845520a2fd5212.zip
sdk-cb9b055bbcaeae59e55cd9f165845520a2fd5212.tar.gz
sdk-cb9b055bbcaeae59e55cd9f165845520a2fd5212.tar.bz2
SDK Manager: fix duplicate when installing new package.
This is a simple refresh issue on the display table. The internal diff properly detects that an uninstalled package is being replaced by a freshly installed package however it wasn't updating the table view to remove the obsolete uninstalled entry. Change-Id: I6ecb7be55848046d9843df2333a09013a2a551c1
Diffstat (limited to 'sdkmanager/libs/sdkuilib/src')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java14
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgItem.java4
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java6
3 files changed, 18 insertions, 6 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
index fde9b90..49395ef 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
@@ -328,9 +328,11 @@ class PackagesDiffLogic {
PkgItem item = itemIt.next();
if (mItemsToRemove.contains(item)) {
itemIt.remove();
+ hasChanged = true;
} else if (item.hasUpdatePkg() &&
mUpdatesToRemove.containsKey(item.getUpdatePkg())) {
item.removeUpdate();
+ hasChanged = true;
}
}
}
@@ -471,6 +473,14 @@ class PackagesDiffLogic {
return hasChanged;
}
+ /**
+ * {@link PkgState}s to check in {@link #processSource(UpdateOp, SdkSource, Package[])}.
+ * The order matters.
+ * When installing the diff will have both the new and the installed item and we
+ * need to merge with the installed one before the new one.
+ */
+ private final static PkgState[] PKG_STATES = { PkgState.INSTALLED, PkgState.NEW };
+
/** Process all remote packages. Returns true if something changed. */
private boolean processSource(UpdateOp op, SdkSource source, Package[] packages) {
boolean hasChanged = false;
@@ -478,7 +488,7 @@ class PackagesDiffLogic {
nextPkg: for (Package newPkg : packages) {
for (PkgCategory cat : cats) {
- for (PkgState state : PkgState.values()) {
+ for (PkgState state : PKG_STATES) {
for (Iterator<PkgItem> currItemIt = cat.getItems().iterator();
currItemIt.hasNext(); ) {
PkgItem currItem = currItemIt.next();
@@ -528,7 +538,7 @@ class PackagesDiffLogic {
}
break;
case INSTALLED:
- // if newPkg.revision <= mainPkg.revision: it's already installed, ignore.
+ // if newPkg.revision<=mainPkg.revision: it's already installed, ignore.
if (newPkg.getRevision() > mainPkg.getRevision()) {
// This is a new update for the main package.
if (currItem.mergeUpdate(newPkg)) {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgItem.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgItem.java
index 2c8b2d2..e943819 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgItem.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PkgItem.java
@@ -40,8 +40,8 @@ public class PkgItem implements Comparable<PkgItem> {
* a given remote package and the local repository.
*/
public enum PkgState {
- // Implementation detail: order matters. Installed items must be dealt with before
- // new items and the order of PkgState.values() matters.
+ // Implementation detail: if this is changed then PackageDiffLogic#STATES
+ // and PackageDiffLogic#processSource() need to be changed accordingly.
/**
* Package is locally installed and may or may not have an update.
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java
index 3090884..8444f9f 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/tasks/ProgressView.java
@@ -25,6 +25,7 @@ import com.android.sdkuilib.ui.GridDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
@@ -160,8 +161,9 @@ public final class ProgressView implements IProgressUiProvider {
// Process the app's event loop whilst we wait for the thread to finish
while (!mProgressBar.isDisposed() && t.isAlive()) {
- if (!mProgressBar.getDisplay().readAndDispatch()) {
- mProgressBar.getDisplay().sleep();
+ Display display = mProgressBar.getDisplay();
+ if (!mProgressBar.isDisposed() && !display.readAndDispatch()) {
+ display.sleep();
}
}
}