Merge change 4510 into donut
* changes: SDK Updater: display icons for local packages.
This commit is contained in:
@@ -20,6 +20,7 @@ import com.android.sdklib.internal.repository.IDescription;
|
|||||||
import com.android.sdklib.internal.repository.LocalSdkParser;
|
import com.android.sdklib.internal.repository.LocalSdkParser;
|
||||||
import com.android.sdklib.internal.repository.Package;
|
import com.android.sdklib.internal.repository.Package;
|
||||||
import com.android.sdklib.internal.repository.RepoSource;
|
import com.android.sdklib.internal.repository.RepoSource;
|
||||||
|
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
@@ -50,10 +51,16 @@ class LocalSdkAdapter {
|
|||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
public static class ViewerLabelProvider extends LabelProvider {
|
public class ViewerLabelProvider extends LabelProvider {
|
||||||
/** Returns null by default */
|
/** Returns an image appropriate for this element. */
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
|
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
||||||
|
|
||||||
|
if (imgFactory != null) {
|
||||||
|
return imgFactory.getImageForObject(element);
|
||||||
|
}
|
||||||
|
|
||||||
return super.getImage(element);
|
return super.getImage(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +76,7 @@ class LocalSdkAdapter {
|
|||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
private static class TableContentProvider implements IStructuredContentProvider {
|
private class TableContentProvider implements IStructuredContentProvider {
|
||||||
|
|
||||||
// Called when the viewer is disposed
|
// Called when the viewer is disposed
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
@@ -78,7 +85,7 @@ class LocalSdkAdapter {
|
|||||||
|
|
||||||
// Called when the input is set or changed on the provider
|
// Called when the input is set or changed on the provider
|
||||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
// pass
|
assert newInput == LocalSdkAdapter.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,15 +94,14 @@ class LocalSdkAdapter {
|
|||||||
* of {@link RepoSource}.
|
* of {@link RepoSource}.
|
||||||
*/
|
*/
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
if (inputElement instanceof LocalSdkAdapter) {
|
if (inputElement == LocalSdkAdapter.this) {
|
||||||
LocalSdkAdapter adapter = (LocalSdkAdapter) inputElement;
|
LocalSdkParser parser = mUpdaterData.getLocalSdkParser();
|
||||||
LocalSdkParser parser = adapter.mUpdaterData.getLocalSdkParser();
|
|
||||||
|
|
||||||
Package[] packages = parser.getPackages();
|
Package[] packages = parser.getPackages();
|
||||||
|
|
||||||
if (packages == null) {
|
if (packages == null) {
|
||||||
// load on demand the first time
|
// load on demand the first time
|
||||||
packages = parser.parseSdk(adapter.mUpdaterData.getOsSdkRoot());
|
packages = parser.parseSdk(mUpdaterData.getOsSdkRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packages != null) {
|
if (packages != null) {
|
||||||
|
|||||||
@@ -16,16 +16,12 @@
|
|||||||
|
|
||||||
package com.android.sdkuilib.internal.repository;
|
package com.android.sdkuilib.internal.repository;
|
||||||
|
|
||||||
import com.android.sdklib.internal.repository.AddonPackage;
|
|
||||||
import com.android.sdklib.internal.repository.Archive;
|
import com.android.sdklib.internal.repository.Archive;
|
||||||
import com.android.sdklib.internal.repository.DocPackage;
|
|
||||||
import com.android.sdklib.internal.repository.IDescription;
|
import com.android.sdklib.internal.repository.IDescription;
|
||||||
import com.android.sdklib.internal.repository.ITask;
|
import com.android.sdklib.internal.repository.ITask;
|
||||||
import com.android.sdklib.internal.repository.ITaskMonitor;
|
import com.android.sdklib.internal.repository.ITaskMonitor;
|
||||||
import com.android.sdklib.internal.repository.Package;
|
import com.android.sdklib.internal.repository.Package;
|
||||||
import com.android.sdklib.internal.repository.PlatformPackage;
|
|
||||||
import com.android.sdklib.internal.repository.RepoSource;
|
import com.android.sdklib.internal.repository.RepoSource;
|
||||||
import com.android.sdklib.internal.repository.ToolPackage;
|
|
||||||
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
|
import com.android.sdkuilib.internal.repository.icons.ImageFactory;
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.IContentProvider;
|
import org.eclipse.jface.viewers.IContentProvider;
|
||||||
@@ -61,38 +57,14 @@ class RepoSourcesAdapter {
|
|||||||
|
|
||||||
public class ViewerLabelProvider extends LabelProvider {
|
public class ViewerLabelProvider extends LabelProvider {
|
||||||
|
|
||||||
/** Returns null by default */
|
/** Returns an image appropriate for this element. */
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(Object element) {
|
public Image getImage(Object element) {
|
||||||
|
|
||||||
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
||||||
|
|
||||||
if (imgFactory != null) {
|
if (imgFactory != null) {
|
||||||
if (element instanceof RepoSource) {
|
return imgFactory.getImageForObject(element);
|
||||||
return imgFactory.getImage("source_icon16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof PlatformPackage) {
|
|
||||||
return imgFactory.getImage("android_icon_16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof AddonPackage) {
|
|
||||||
return imgFactory.getImage("addon_icon16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof ToolPackage) {
|
|
||||||
return imgFactory.getImage("tool_icon16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof DocPackage) {
|
|
||||||
return imgFactory.getImage("doc_icon16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof Package) {
|
|
||||||
return imgFactory.getImage("extra_pkg_icon16.png");
|
|
||||||
|
|
||||||
} else if (element instanceof Archive) {
|
|
||||||
if (((Archive) element).isCompatible()) {
|
|
||||||
return imgFactory.getImage("archive_icon16.png");
|
|
||||||
} else {
|
|
||||||
return imgFactory.getImage("incompat_icon16.png");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getImage(element);
|
return super.getImage(element);
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ final class UpdateChooserDialog extends Dialog {
|
|||||||
if (mUpdaterData != null) {
|
if (mUpdaterData != null) {
|
||||||
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
||||||
if (imgFactory != null) {
|
if (imgFactory != null) {
|
||||||
mDialogShell.setImage(imgFactory.getImage(imageName));
|
mDialogShell.setImage(imgFactory.getImageByName(imageName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -533,11 +533,11 @@ final class UpdateChooserDialog extends Dialog {
|
|||||||
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
||||||
if (imgFactory != null) {
|
if (imgFactory != null) {
|
||||||
if (mAccepted.contains(element)) {
|
if (mAccepted.contains(element)) {
|
||||||
return imgFactory.getImage("accept_icon16.png");
|
return imgFactory.getImageByName("accept_icon16.png");
|
||||||
} else if (mRejected.contains(element)) {
|
} else if (mRejected.contains(element)) {
|
||||||
return imgFactory.getImage("reject_icon16.png");
|
return imgFactory.getImageByName("reject_icon16.png");
|
||||||
}
|
}
|
||||||
return imgFactory.getImage("unknown_icon16.png");
|
return imgFactory.getImageByName("unknown_icon16.png");
|
||||||
}
|
}
|
||||||
return super.getImage(element);
|
return super.getImage(element);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ public class UpdaterWindowImpl {
|
|||||||
if (mUpdaterData != null) {
|
if (mUpdaterData != null) {
|
||||||
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
ImageFactory imgFactory = mUpdaterData.getImageFactory();
|
||||||
if (imgFactory != null) {
|
if (imgFactory != null) {
|
||||||
mAndroidSdkUpdater.setImage(imgFactory.getImage(imageName));
|
mAndroidSdkUpdater.setImage(imgFactory.getImageByName(imageName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,14 @@
|
|||||||
|
|
||||||
package com.android.sdkuilib.internal.repository.icons;
|
package com.android.sdkuilib.internal.repository.icons;
|
||||||
|
|
||||||
|
import com.android.sdklib.internal.repository.AddonPackage;
|
||||||
|
import com.android.sdklib.internal.repository.Archive;
|
||||||
|
import com.android.sdklib.internal.repository.DocPackage;
|
||||||
|
import com.android.sdklib.internal.repository.Package;
|
||||||
|
import com.android.sdklib.internal.repository.PlatformPackage;
|
||||||
|
import com.android.sdklib.internal.repository.RepoSource;
|
||||||
|
import com.android.sdklib.internal.repository.ToolPackage;
|
||||||
|
|
||||||
import org.eclipse.swt.SWTException;
|
import org.eclipse.swt.SWTException;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
@@ -41,8 +49,13 @@ public class ImageFactory {
|
|||||||
/**
|
/**
|
||||||
* Loads an image given its filename (with its extension).
|
* Loads an image given its filename (with its extension).
|
||||||
* Might return null if the image cannot be loaded.
|
* Might return null if the image cannot be loaded.
|
||||||
|
*
|
||||||
|
* @param imageName The filename (with extension) of the image to load.
|
||||||
|
* @return A new or existing {@link Image}. The caller must NOT dispose the image (the
|
||||||
|
* image will disposed by {@link #dispose()}). The returned image can be null if the
|
||||||
|
* expected file is missing.
|
||||||
*/
|
*/
|
||||||
public Image getImage(String imageName) {
|
public Image getImageByName(String imageName) {
|
||||||
|
|
||||||
Image image = mImages.get(imageName);
|
Image image = mImages.get(imageName);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
@@ -66,6 +79,43 @@ public class ImageFactory {
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads and returns the appropriate image for a given package, archive or source object.
|
||||||
|
*
|
||||||
|
* @param object A {@link RepoSource} or {@link Package} or {@link Archive}.
|
||||||
|
* @return A new or existing {@link Image}. The caller must NOT dispose the image (the
|
||||||
|
* image will disposed by {@link #dispose()}). The returned image can be null if the
|
||||||
|
* expected file is missing.
|
||||||
|
*/
|
||||||
|
public Image getImageForObject(Object object) {
|
||||||
|
if (object instanceof RepoSource) {
|
||||||
|
return getImageByName("source_icon16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof PlatformPackage) {
|
||||||
|
return getImageByName("android_icon_16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof AddonPackage) {
|
||||||
|
return getImageByName("addon_icon16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof ToolPackage) {
|
||||||
|
return getImageByName("tool_icon16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof DocPackage) {
|
||||||
|
return getImageByName("doc_icon16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof Package) {
|
||||||
|
return getImageByName("extra_pkg_icon16.png");
|
||||||
|
|
||||||
|
} else if (object instanceof Archive) {
|
||||||
|
if (((Archive) object).isCompatible()) {
|
||||||
|
return getImageByName("archive_icon16.png");
|
||||||
|
} else {
|
||||||
|
return getImageByName("incompat_icon16.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispose all the images created by this factory so far.
|
* Dispose all the images created by this factory so far.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -243,8 +243,8 @@ public final class AvdSelector {
|
|||||||
|
|
||||||
// get some bitmaps.
|
// get some bitmaps.
|
||||||
mIconFactory = new ImageFactory(parent.getDisplay());
|
mIconFactory = new ImageFactory(parent.getDisplay());
|
||||||
mOkImage = mIconFactory.getImage("accept_icon16.png");
|
mOkImage = mIconFactory.getImageByName("accept_icon16.png");
|
||||||
mBrokenImage = mIconFactory.getImage("reject_icon16.png");
|
mBrokenImage = mIconFactory.getImageByName("reject_icon16.png");
|
||||||
|
|
||||||
adjustColumnsWidth(mTable, column0, column1, column2, column3);
|
adjustColumnsWidth(mTable, column0, column1, column2, column3);
|
||||||
setupSelectionListener(mTable);
|
setupSelectionListener(mTable);
|
||||||
|
|||||||
Reference in New Issue
Block a user