Sdk Updater: Split UI in window and independant composites.

This commit is contained in:
Raphael
2009-05-21 15:22:50 -07:00
parent 1a0b3ffd5e
commit cbfa85a410
5 changed files with 431 additions and 225 deletions

View File

@@ -0,0 +1,116 @@
package com.android.sdkuilib.repository;
import com.android.sdkuilib.repository.UpdaterWindow.UpdaterData;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.swt.SWT;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
class AvailablePackagesPage extends Composite {
private final UpdaterData mUpdaterData;
private CheckboxTreeViewer mTreeViewAvailPkg;
private Tree mTreeAvailPkg;
private TreeColumn mColumnAvailSummary;
private TreeColumn mColumnAvailApiLevel;
private TreeColumn mColumnAvailRevision;
private TreeColumn mColumnAvailOs;
private TreeColumn mColumnAvailInstalled;
private Group mAvailDescription;
private Button mAvailAddSite;
private Button mAvailRemoveSite;
private Label mPlaceholder3;
private Button mAvailRefresh;
private Button mAvailInstallSelected;
/**
* Create the composite.
* @param parent The parent of the composite.
* @param updaterData An instance of {@link UpdaterWindow.UpdaterData}. If null, a local
* one will be allocated just to help with the SWT Designer.
*/
public AvailablePackagesPage(Composite parent, UpdaterData updaterData) {
super(parent, SWT.BORDER);
mUpdaterData = updaterData != null ? updaterData : new UpdaterWindow.UpdaterData();
createContents(this);
}
private void createContents(Composite parent) {
parent.setLayout(new GridLayout(5, false));
mTreeViewAvailPkg = new CheckboxTreeViewer(parent, SWT.BORDER);
mTreeViewAvailPkg.setContentProvider(mUpdaterData.getSources().getContentProvider());
mTreeViewAvailPkg.setLabelProvider(mUpdaterData.getSources().getLabelProvider());
mTreeAvailPkg = mTreeViewAvailPkg.getTree();
mTreeAvailPkg.setHeaderVisible(true);
mTreeAvailPkg.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
mColumnAvailSummary = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailSummary.setWidth(289);
mColumnAvailSummary.setText("Summary");
mColumnAvailApiLevel = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailApiLevel.setWidth(66);
mColumnAvailApiLevel.setText("API Level");
mColumnAvailRevision = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailRevision.setWidth(63);
mColumnAvailRevision.setText("Revision");
mColumnAvailOs = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailOs.setWidth(100);
mColumnAvailOs.setText("OS/Arch");
mColumnAvailInstalled = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailInstalled.setWidth(59);
mColumnAvailInstalled.setText("Installed");
mAvailDescription = new Group(parent, SWT.NONE);
mAvailDescription.setText("Description");
mAvailDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1));
mAvailAddSite = new Button(parent, SWT.NONE);
mAvailAddSite.setText("Add Site...");
mAvailRemoveSite = new Button(parent, SWT.NONE);
mAvailRemoveSite.setText("Delete Site...");
mPlaceholder3 = new Label(parent, SWT.NONE);
mPlaceholder3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
mAvailRefresh = new Button(parent, SWT.NONE);
mAvailRefresh.setText("Refresh");
mAvailInstallSelected = new Button(parent, SWT.NONE);
mAvailInstallSelected.setText("Install Selected");
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
// -- Start of internal part ----------
// Hide everything down-below from SWT designer
//$hide>>$
public void setInput(RepoSources sources) {
mTreeViewAvailPkg.setInput(sources);
}
// End of hiding from SWT Designer
//$hide<<$
}

View File

@@ -0,0 +1,168 @@
package com.android.sdkuilib.repository;
import com.android.sdkuilib.repository.ProgressTask.ThreadTask;
import com.android.sdkuilib.repository.UpdaterWindow.UpdaterData;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
public class InstalledPackagesPage extends Composite {
private UpdaterData mUpdaterData;
private Label mSdkLocLabel;
private Text mSdkLocText;
private Button mSdkLocBrowse;
private Label mInstalledPkgLabel;
private TableViewer mTableViewerInstPkg;
private Table mTableInstPkg;
private TableColumn mColumnInstSummary;
private TableColumn mColumnInstApiLevel;
private TableColumn mColumnInstRevision;
private Group mInstDescription;
private Composite mInstButtons;
private Button mInstUpdate;
private Label mPlaceholder1;
private Button mInstDelete;
private Label mPlaceholder2;
private Button mInstHomePage;
/**
* Create the composite.
* @param parent The parent of the composite.
* @param updaterData An instance of {@link UpdaterWindow.UpdaterData}. If null, a local
* one will be allocated just to help with the SWT Designer.
*/
public InstalledPackagesPage(Composite parent, UpdaterData updaterData) {
super(parent, SWT.BORDER);
mUpdaterData = updaterData != null ? updaterData : new UpdaterWindow.UpdaterData();
createContents(this);
}
private void createContents(Composite parent) {
parent.setLayout(new GridLayout(3, false));
createSdkLocation(parent);
mInstalledPkgLabel = new Label(parent, SWT.NONE);
mInstalledPkgLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
mInstalledPkgLabel.setText("Installed Packages:");
mTableViewerInstPkg = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
mTableInstPkg = mTableViewerInstPkg.getTable();
mTableInstPkg.setHeaderVisible(true);
mTableInstPkg.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
mColumnInstSummary = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstSummary.setWidth(377);
mColumnInstSummary.setText("Summary");
mColumnInstApiLevel = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstApiLevel.setWidth(100);
mColumnInstApiLevel.setText("API Level");
mColumnInstRevision = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstRevision.setWidth(100);
mColumnInstRevision.setText("Revision");
mInstDescription = new Group(parent, SWT.NONE);
mInstDescription.setText("Description");
mInstDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
mInstButtons = new Composite(parent, SWT.NONE);
mInstButtons.setLayout(new GridLayout(5, false));
mInstButtons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
mInstUpdate = new Button(mInstButtons, SWT.NONE);
mInstUpdate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
onUpdateInstalledPackage(); //$hide$ (hide from SWT designer)
}
});
mInstUpdate.setText("Update...");
mPlaceholder1 = new Label(mInstButtons, SWT.NONE);
mPlaceholder1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
mInstDelete = new Button(mInstButtons, SWT.NONE);
mInstDelete.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
mInstDelete.setText("Delete...");
mPlaceholder2 = new Label(mInstButtons, SWT.NONE);
mPlaceholder2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
mInstHomePage = new Button(mInstButtons, SWT.NONE);
mInstHomePage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
mInstHomePage.setText("Home Page...");
}
private void createSdkLocation(Composite parent) {
mSdkLocLabel = new Label(parent, SWT.NONE);
mSdkLocLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
mSdkLocLabel.setText("SDK Location:");
// If the sdk path is not user-customizable, do not create
// the browse button and use horizSpan=2 on the text field.
mSdkLocText = new Text(parent, SWT.BORDER);
mSdkLocText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
if (mUpdaterData.canUserChangeSdkRoot()) {
mSdkLocBrowse = new Button(parent, SWT.NONE);
mSdkLocBrowse.setText("Browse...");
} else {
mSdkLocText.setEditable(false);
((GridData)mSdkLocText.getLayoutData()).horizontalSpan++;
}
if (mUpdaterData.getOsSdkRoot() != null) {
mSdkLocText.setText(mUpdaterData.getOsSdkRoot());
}
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
// -- Start of internal part ----------
// Hide everything down-below from SWT designer
//$hide>>$
protected void onUpdateInstalledPackage() {
ProgressTask.start(getShell(), "Test", new ThreadTask() {
public void PerformTask(ITaskMonitor monitor) {
monitor.setDescription("Test");
monitor.setProgressMax(100);
int n = 0;
int d = 1;
while(!monitor.cancelRequested()) {
monitor.incProgress(d);
n += d;
if (n == 0 || n == 100) d = -d;
try {
Thread.sleep(5);
} catch (InterruptedException e) {
}
}
}
});
}
// End of hiding from SWT Designer
//$hide<<$
}

View File

@@ -231,5 +231,6 @@ class ProgressTask extends Dialog
}
}
// End of hiding from SWT Designer
//$hide<<$
}

View File

@@ -16,80 +16,76 @@
package com.android.sdkuilib.repository;
import com.android.sdkuilib.repository.ProgressTask.ThreadTask;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.TableTree;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import java.io.InputStream;
import java.util.ArrayList;
public class UpdaterWindow {
private final String mOsSdkRoot;
private final boolean mUserCanChangeSdkRoot;
static class UpdaterData {
private String mOsSdkRoot;
private boolean mUserCanChangeSdkRoot;
private RepoSources mSources = new RepoSources();
private RepoSources mSources = new RepoSources();
public void setOsSdkRoot(String osSdkRoot) {
mOsSdkRoot = osSdkRoot;
}
public String getOsSdkRoot() {
return mOsSdkRoot;
}
public void setUserCanChangeSdkRoot(boolean userCanChangeSdkRoot) {
mUserCanChangeSdkRoot = userCanChangeSdkRoot;
}
public boolean canUserChangeSdkRoot() {
return mUserCanChangeSdkRoot;
}
public void setSources(RepoSources sources) {
mSources = sources;
}
public RepoSources getSources() {
return mSources;
}
}
private final UpdaterData mUpdaterData = new UpdaterData();
private ArrayList<Composite> mPages = new ArrayList<Composite>();
private boolean mInternalPageChange;
// --- UI members ---
protected Shell mAndroidSdkUpdater;
private TabFolder mTabFolder;
private TabItem mTabInstalledPkg;
private Composite mRootInst;
private TabItem mTabAvailPkg;
private Composite mRootAvail;
private Text mSdkLocText;
private Button mSdkLocBrowse;
private Label mSdkLocLabel;
private Group mInstDescription;
private Composite mInstButtons;
private Button mInstUpdate;
private Button mInstDelete;
private Button mInstHomePage;
private Label mPlaceholder1;
private Label mPlaceholder2;
private Label mInstalledPkgLabel;
private TableTree tableTree;
private Tree mTreeAvailPkg;
private Button mAvailRemoveSite;
private Button mAvailAddSite;
private Label mPlaceholder3;
private Button mAvailRefresh;
private Button mAvailInstallSelected;
private Group mAvailDescription;
private Table mTableInstPkg;
private TableColumn mColumnInstSummary;
private TableColumn mColumnInstApiLevel;
private TableColumn mColumnInstRevision;
private TreeColumn mColumnAvailSummary;
private TreeColumn mColumnAvailApiLevel;
private TreeColumn mColumnAvailRevision;
private TreeColumn mColumnAvailOs;
private TreeColumn mColumnAvailInstalled;
private CheckboxTreeViewer mTreeViewAvailPkg;
private TableViewer mTableViewerInstPkg;
private SashForm mSashForm;
private List mPageList;
private Composite mPagesRootComposite;
private InstalledPackagesPage mInstalledPackagePage;
private AvailablePackagesPage mAvailablePackagesPage;
private StackLayout mStackLayout;
private Image mIconImage;
public UpdaterWindow(String osSdkRoot, boolean userCanChangeSdkRoot) {
mOsSdkRoot = osSdkRoot;
mUserCanChangeSdkRoot = userCanChangeSdkRoot;
mUpdaterData.setOsSdkRoot(osSdkRoot);
mUpdaterData.setUserCanChangeSdkRoot(userCanChangeSdkRoot);
}
/**
@@ -101,7 +97,9 @@ public class UpdaterWindow {
createContents();
mAndroidSdkUpdater.open();
mAndroidSdkUpdater.layout();
firstInit();
firstInit(); //$hide$ (hide from SWT designer)
while (!mAndroidSdkUpdater.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
@@ -114,182 +112,67 @@ public class UpdaterWindow {
*/
protected void createContents() {
mAndroidSdkUpdater = new Shell();
mAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
mAndroidSdkUpdater.setLayout(new GridLayout(1, false));
mAndroidSdkUpdater.setSize(633, 433);
mAndroidSdkUpdater.setText("Android SDK Updater");
mTabFolder = new TabFolder(mAndroidSdkUpdater, SWT.NONE);
mTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
createInstalledPackagesTab();
createAvailablePackagesTab();
}
private void createInstalledPackagesTab() {
mTabInstalledPkg = new TabItem(mTabFolder, SWT.NONE);
mTabInstalledPkg.setText("Installed Packages");
mRootInst = new Composite(mTabFolder, SWT.NONE);
mRootInst.setLayout(new GridLayout(3, false));
mTabInstalledPkg.setControl(mRootInst);
createSdkLocation();
mInstalledPkgLabel = new Label(mRootInst, SWT.NONE);
mInstalledPkgLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
mInstalledPkgLabel.setText("Installed Packages:");
mTableViewerInstPkg = new TableViewer(mRootInst, SWT.BORDER | SWT.FULL_SELECTION);
mTableInstPkg = mTableViewerInstPkg.getTable();
mTableInstPkg.setHeaderVisible(true);
mTableInstPkg.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
mColumnInstSummary = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstSummary.setWidth(377);
mColumnInstSummary.setText("Summary");
mColumnInstApiLevel = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstApiLevel.setWidth(100);
mColumnInstApiLevel.setText("API Level");
mColumnInstRevision = new TableColumn(mTableInstPkg, SWT.NONE);
mColumnInstRevision.setWidth(100);
mColumnInstRevision.setText("Revision");
mInstDescription = new Group(mRootInst, SWT.NONE);
mInstDescription.setText("Description");
mInstDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
mInstButtons = new Composite(mRootInst, SWT.NONE);
mInstButtons.setLayout(new GridLayout(5, false));
mInstButtons.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
mInstUpdate = new Button(mInstButtons, SWT.NONE);
mInstUpdate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
onUpdateInstalledPackage();
setWindowImage(mAndroidSdkUpdater);
mAndroidSdkUpdater.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
onAndroidSdkUpdaterDispose(); //$hide$ (hide from SWT designer)
}
});
mInstUpdate.setText("Update...");
mPlaceholder1 = new Label(mInstButtons, SWT.NONE);
mPlaceholder1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
mAndroidSdkUpdater.setLayout(new FillLayout(SWT.HORIZONTAL));
mAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
mAndroidSdkUpdater.setSize(745, 433);
mAndroidSdkUpdater.setText("Android SDK Updater");
mInstDelete = new Button(mInstButtons, SWT.NONE);
mInstDelete.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
mInstDelete.setText("Delete...");
mSashForm = new SashForm(mAndroidSdkUpdater, SWT.NONE);
mPlaceholder2 = new Label(mInstButtons, SWT.NONE);
mPlaceholder2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
mPageList = new List(mSashForm, SWT.BORDER);
mPageList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
onPageListSelected(e); //$hide$ (hide from SWT designer)
}
});
mInstHomePage = new Button(mInstButtons, SWT.NONE);
mInstHomePage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
mInstHomePage.setText("Home Page...");
mPagesRootComposite = new Composite(mSashForm, SWT.NONE);
mStackLayout = new StackLayout();
mPagesRootComposite.setLayout(mStackLayout);
mInstalledPackagePage = new InstalledPackagesPage(mPagesRootComposite, mUpdaterData);
mAvailablePackagesPage = new AvailablePackagesPage(mPagesRootComposite, mUpdaterData);
mSashForm.setWeights(new int[] {150, 576});
}
private void createSdkLocation() {
mSdkLocLabel = new Label(mRootInst, SWT.NONE);
mSdkLocLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
mSdkLocLabel.setText("SDK Location:");
// If the sdk path is not user-customizable, do not create
// the browse button and use horizSpan=2 on the text field.
mSdkLocText = new Text(mRootInst, SWT.BORDER);
mSdkLocText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
if (mUserCanChangeSdkRoot) {
mSdkLocBrowse = new Button(mRootInst, SWT.NONE);
mSdkLocBrowse.setText("Browse...");
} else {
mSdkLocText.setEditable(false);
((GridData)mSdkLocText.getLayoutData()).horizontalSpan++;
}
mSdkLocText.setText(mOsSdkRoot);
}
private void createAvailablePackagesTab() {
mTabAvailPkg = new TabItem(mTabFolder, SWT.NONE);
mTabAvailPkg.setText("Available Packages");
mRootAvail = new Composite(mTabFolder, SWT.NONE);
mRootAvail.setLayout(new GridLayout(5, false));
mTabAvailPkg.setControl(mRootAvail);
mTreeViewAvailPkg = new CheckboxTreeViewer(mRootAvail, SWT.BORDER);
mTreeViewAvailPkg.setContentProvider(mSources.getContentProvider());
mTreeViewAvailPkg.setLabelProvider(mSources.getLabelProvider());
mTreeAvailPkg = mTreeViewAvailPkg.getTree();
mTreeAvailPkg.setHeaderVisible(true);
mTreeAvailPkg.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
mColumnAvailSummary = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailSummary.setWidth(289);
mColumnAvailSummary.setText("Summary");
mColumnAvailApiLevel = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailApiLevel.setWidth(66);
mColumnAvailApiLevel.setText("API Level");
mColumnAvailRevision = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailRevision.setWidth(63);
mColumnAvailRevision.setText("Revision");
mColumnAvailOs = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailOs.setWidth(100);
mColumnAvailOs.setText("OS/Arch");
mColumnAvailInstalled = new TreeColumn(mTreeAvailPkg, SWT.NONE);
mColumnAvailInstalled.setWidth(59);
mColumnAvailInstalled.setText("Installed");
mAvailDescription = new Group(mRootAvail, SWT.NONE);
mAvailDescription.setText("Description");
mAvailDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1));
mAvailAddSite = new Button(mRootAvail, SWT.NONE);
mAvailAddSite.setText("Add Site...");
mAvailRemoveSite = new Button(mRootAvail, SWT.NONE);
mAvailRemoveSite.setText("Delete Site...");
mPlaceholder3 = new Label(mRootAvail, SWT.NONE);
mPlaceholder3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
mAvailRefresh = new Button(mRootAvail, SWT.NONE);
mAvailRefresh.setText("Refresh");
mAvailInstallSelected = new Button(mRootAvail, SWT.NONE);
mAvailInstallSelected.setText("Install Selected");
}
// -- Start of internal part ----------
// Hide everything down-below from SWT designer
//$hide>>$
// --- UI Callbacks -----------
protected void onUpdateInstalledPackage() {
ProgressTask.start(getShell(), "Test", new ThreadTask() {
public void PerformTask(ITaskMonitor monitor) {
monitor.setDescription("Test");
monitor.setProgressMax(100);
int n = 0;
int d = 1;
while(!monitor.cancelRequested()) {
monitor.incProgress(d);
n += d;
if (n == 0 || n == 100) d = -d;
try {
Thread.sleep(5);
} catch (InterruptedException e) {
}
}
}
});
private void onAndroidSdkUpdaterDispose() {
if (mIconImage != null) {
mIconImage.dispose();
mIconImage = null;
}
}
// --------------
private void setWindowImage(Shell androidSdkUpdater) {
InputStream stream = getClass().getResourceAsStream("android_icon_16.png"); //$NON-NLS-1$
if (stream != null) {
try {
ImageData imgData = new ImageData(stream);
mIconImage = new Image(mAndroidSdkUpdater.getDisplay(),
imgData,
imgData.getTransparencyMask());
mAndroidSdkUpdater.setImage(mIconImage);
} catch (SWTException e) {
// ignore
} catch (IllegalArgumentException e) {
// ignore
}
}
}
private Shell getShell() {
return mAndroidSdkUpdater;
@@ -299,26 +182,64 @@ public class UpdaterWindow {
* Once the UI has been created, initialize the content
*/
private void firstInit() {
addPage(mInstalledPackagePage, "Installed Packages");
addPage(mAvailablePackagesPage, "Available Packages");
displayPage(0);
mPageList.setSelection(0);
setupSources();
scanLocalSdkFolders();
}
private void setupSources() {
mSources.setShell(getShell());
// --- page switching ---
mSources.add(new RepoSource(
private void addPage(Composite page, String title) {
page.setData(title);
mPages.add(page);
mPageList.add(title);
}
private void onPageListSelected(SelectionEvent e) {
if (mInternalPageChange == false) {
int index = mPageList.getSelectionIndex();
if (index >= 0) {
displayPage(index);
}
}
}
private void displayPage(int index) {
Composite page = mPages.get(index);
if (page != null) {
mStackLayout.topControl = page;
mPagesRootComposite.layout(true);
if (!mInternalPageChange) {
mInternalPageChange = true;
mPageList.setSelection(index);
mInternalPageChange = false;
}
}
}
private void setupSources() {
mUpdaterData.getSources().setShell(getShell());
mUpdaterData.getSources().add(new RepoSource(
"https://dl.google.com/android/eclipse/repository/index.xml", //$NON-NLS-1$
false /* addonOnly */));
mSources.add(new RepoSource(
mUpdaterData.getSources().add(new RepoSource(
"http://www.corp.google.com/~raphael/android/sdk-repo/repository.xml", //$NON-NLS-1$
false /* addonOnly */));
mTreeViewAvailPkg.setInput(mSources);
mAvailablePackagesPage.setInput(mUpdaterData.getSources());
}
private void scanLocalSdkFolders() {
// TODO Auto-generated method stub
}
// End of hiding from SWT Designer
//$hide<<$
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B