Skeleton App Windows for Sdk Updater built using SWT Designer.
The window is shown when the "android" tool is invoked with no parameter.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ import org.eclipse.swt.widgets.TableItem;
|
||||
* and finally use {@link #getSelected()} to retrieve the selection.
|
||||
*/
|
||||
public final class AvdSelector {
|
||||
|
||||
|
||||
private AvdInfo[] mAvds;
|
||||
private SelectionListener mSelectionListener;
|
||||
private Table mTable;
|
||||
@@ -84,28 +84,28 @@ public final class AvdSelector {
|
||||
* This is invoked once when the button is created and cannot be changed later.
|
||||
*/
|
||||
public String label();
|
||||
|
||||
|
||||
/**
|
||||
* This is invoked just after the selection has changed to update the "enabled"
|
||||
* state of the action. Implementation should use {@link AvdSelector#getSelected()}.
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Run the action, invoked when the button is clicked.
|
||||
*
|
||||
*
|
||||
* The caller's action is responsible for reloading the AVD list
|
||||
* using {@link AvdSelector#setAvds(AvdInfo[], IAndroidTarget)}.
|
||||
*/
|
||||
public void run();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}, filtered
|
||||
* by a {@link IAndroidTarget}.
|
||||
* <p/>Only the {@link AvdInfo} able to run application developed for the given
|
||||
* {@link IAndroidTarget} will be displayed.
|
||||
*
|
||||
*
|
||||
* @param parent The parent composite where the selector will be added.
|
||||
* @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify.
|
||||
* It can be null.
|
||||
@@ -149,10 +149,10 @@ public final class AvdSelector {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
super.widgetSelected(e);
|
||||
mExtraAction.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// create the table columns
|
||||
final TableColumn column0 = new TableColumn(mTable, SWT.NONE);
|
||||
column0.setText("AVD Name");
|
||||
@@ -171,7 +171,7 @@ public final class AvdSelector {
|
||||
|
||||
/**
|
||||
* Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}.
|
||||
*
|
||||
*
|
||||
* @param parent The parent composite where the selector will be added.
|
||||
* @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify.
|
||||
* It can be null.
|
||||
@@ -187,7 +187,7 @@ public final class AvdSelector {
|
||||
|
||||
/**
|
||||
* Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}.
|
||||
*
|
||||
*
|
||||
* @param parent The parent composite where the selector will be added.
|
||||
* @param extraAction When non-null, displays an extra action button.
|
||||
* @param selectionMode One of {@link SelectionMode#SELECT} or {@link SelectionMode#CHECK}
|
||||
@@ -200,7 +200,7 @@ public final class AvdSelector {
|
||||
|
||||
/**
|
||||
* Sets the table grid layout data.
|
||||
*
|
||||
*
|
||||
* @param heightHint If > 0, the height hint is set to the requested value.
|
||||
*/
|
||||
public void setTableHeightHint(int heightHint) {
|
||||
@@ -215,26 +215,26 @@ public final class AvdSelector {
|
||||
data.verticalAlignment = GridData.FILL;
|
||||
mTable.setLayoutData(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a new set of AVD, with an optional filter.
|
||||
* Tries to keep the selection.
|
||||
* <p/>
|
||||
* This must be called from the UI thread.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify.
|
||||
* It can be null.
|
||||
* @param filter An IAndroidTarget. If non-null, only AVD whose target are compatible with the
|
||||
* filter target will displayed an available for selection.
|
||||
*/
|
||||
public void setAvds(AvdInfo[] avds, IAndroidTarget filter) {
|
||||
|
||||
|
||||
AvdInfo selected = getSelected();
|
||||
|
||||
|
||||
mAvds = avds;
|
||||
fillTable(mTable, filter);
|
||||
|
||||
|
||||
setSelection(selected);
|
||||
}
|
||||
|
||||
@@ -256,19 +256,19 @@ public final class AvdSelector {
|
||||
* The {@link TableItem#getData()} contains an {@link IAndroidTarget}.
|
||||
* <p/>
|
||||
* It is recommended that the caller uses the {@link #getSelected()} method instead.
|
||||
*
|
||||
*
|
||||
* @param selectionListener The new listener or null to remove it.
|
||||
*/
|
||||
public void setSelectionListener(SelectionListener selectionListener) {
|
||||
mSelectionListener = selectionListener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current target selection.
|
||||
* <p/>
|
||||
* If the selection is actually changed, this will invoke the selection listener
|
||||
* (if any) with a null event.
|
||||
*
|
||||
*
|
||||
* @param target the target to be selected. Use null to deselect everything.
|
||||
* @return true if the target could be selected, false otherwise.
|
||||
*/
|
||||
@@ -288,7 +288,7 @@ public final class AvdSelector {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
index++;
|
||||
|
||||
} else if (mSelectionMode == SelectionMode.CHECK){
|
||||
@@ -304,21 +304,21 @@ public final class AvdSelector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (modified && mSelectionListener != null) {
|
||||
mSelectionListener.widgetSelected(null);
|
||||
}
|
||||
|
||||
|
||||
if (mExtraAction != null && mExtraActionButton != null) {
|
||||
mExtraActionButton.setEnabled(mExtraAction.isEnabled());
|
||||
}
|
||||
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently selected item.
|
||||
*
|
||||
*
|
||||
* @return The currently selected item or null.
|
||||
*/
|
||||
public AvdInfo getSelected() {
|
||||
@@ -342,7 +342,7 @@ public final class AvdSelector {
|
||||
* Enables the receiver if the argument is true, and disables it otherwise.
|
||||
* A disabled control is typically not selectable from the user interface
|
||||
* and draws with an inactive or "grayed" look.
|
||||
*
|
||||
*
|
||||
* @param enabled the new enabled state.
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
@@ -366,7 +366,7 @@ public final class AvdSelector {
|
||||
@Override
|
||||
public void controlResized(ControlEvent e) {
|
||||
Rectangle r = table.getClientArea();
|
||||
column0.setWidth(r.width * 30 / 100); // 30%
|
||||
column0.setWidth(r.width * 30 / 100); // 30%
|
||||
column1.setWidth(r.width * 45 / 100); // 45%
|
||||
column2.setWidth(r.width * 10 / 100); // 10%
|
||||
column3.setWidth(r.width * 15 / 100); // 15%
|
||||
@@ -382,7 +382,7 @@ public final class AvdSelector {
|
||||
private void setupSelectionListener(final Table table) {
|
||||
// Add a selection listener that will check/uncheck items when they are double-clicked
|
||||
table.addSelectionListener(new SelectionListener() {
|
||||
|
||||
|
||||
/**
|
||||
* Handles single-click selection on the table.
|
||||
* {@inheritDoc}
|
||||
@@ -397,7 +397,7 @@ public final class AvdSelector {
|
||||
if (mSelectionListener != null) {
|
||||
mSelectionListener.widgetSelected(e);
|
||||
}
|
||||
|
||||
|
||||
if (mExtraAction != null && mExtraActionButton != null) {
|
||||
mExtraActionButton.setEnabled(mExtraAction.isEnabled());
|
||||
}
|
||||
@@ -406,9 +406,9 @@ public final class AvdSelector {
|
||||
/**
|
||||
* Handles double-click selection on the table.
|
||||
* Note that the single-click handler will probably already have been called.
|
||||
*
|
||||
*
|
||||
* On double-click, <em>always</em> check the table item.
|
||||
*
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
@@ -424,7 +424,7 @@ public final class AvdSelector {
|
||||
if (mSelectionListener != null) {
|
||||
mSelectionListener.widgetDefaultSelected(e);
|
||||
}
|
||||
|
||||
|
||||
if (mExtraAction != null && mExtraActionButton != null) {
|
||||
mExtraActionButton.setEnabled(mExtraAction.isEnabled());
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public final class AvdSelector {
|
||||
private void enforceSingleSelection(TableItem item) {
|
||||
if (mSelectionMode == SelectionMode.SELECT) {
|
||||
// pass
|
||||
|
||||
|
||||
} else if (mSelectionMode == SelectionMode.CHECK) {
|
||||
if (item.getChecked()) {
|
||||
Table parentTable = item.getParent();
|
||||
@@ -478,7 +478,7 @@ public final class AvdSelector {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (table.getItemCount() == 0) {
|
||||
table.setEnabled(false);
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
@@ -498,36 +498,36 @@ public final class AvdSelector {
|
||||
*/
|
||||
private void setupTooltip(final Table table) {
|
||||
/*
|
||||
* Reference:
|
||||
* Reference:
|
||||
* http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet125.java?view=markup
|
||||
*/
|
||||
|
||||
|
||||
final Listener listener = new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
|
||||
|
||||
switch(event.type) {
|
||||
case SWT.KeyDown:
|
||||
case SWT.MouseExit:
|
||||
case SWT.MouseDown:
|
||||
return;
|
||||
|
||||
|
||||
case SWT.MouseHover:
|
||||
updateDescription(table.getItem(new Point(event.x, event.y)));
|
||||
break;
|
||||
|
||||
|
||||
case SWT.Selection:
|
||||
if (event.item instanceof TableItem) {
|
||||
updateDescription((TableItem) event.item);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
table.addListener(SWT.Dispose, listener);
|
||||
table.addListener(SWT.KeyDown, listener);
|
||||
table.addListener(SWT.MouseMove, listener);
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.sdkuilib.repository;
|
||||
|
||||
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.graphics.Point;
|
||||
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.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
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;
|
||||
|
||||
public class UpdaterWindow {
|
||||
|
||||
protected Shell mshlAndroidSdkUpdater;
|
||||
private TabFolder tabFolder;
|
||||
private TabItem mtbtmInstalledPackages;
|
||||
private Composite compositeInst;
|
||||
private TabItem mtbtmAvailablePackages;
|
||||
private Composite compositeAvail;
|
||||
private Text text;
|
||||
private Button mbtnBrowse;
|
||||
private Label mlblSdkLocation;
|
||||
private Group mgrpDescription;
|
||||
private Composite composite_3;
|
||||
private Button mbtnUpdate;
|
||||
private Button mbtnDelete;
|
||||
private Button mbtnHomePage;
|
||||
private Label placeholder1;
|
||||
private Label placeholder2;
|
||||
private Label mlblInstalledPackages;
|
||||
private TableTree tableTree;
|
||||
private Tree tree;
|
||||
private Button mbtnRemoveSite;
|
||||
private Button mbtnAddSite;
|
||||
private Label placeholder3;
|
||||
private Button mbtnRefresh;
|
||||
private Button mbtnInstallSelected;
|
||||
private Group mgrpDescription_1;
|
||||
private Table table;
|
||||
private TableColumn mtblclmnSummary;
|
||||
private TableColumn mtblclmnApiLevel;
|
||||
private TableColumn mtblclmnRevision;
|
||||
private TreeColumn mtrclmnSummary;
|
||||
private TreeColumn mtrclmnApiLevel;
|
||||
private TreeColumn mtrclmnRevision;
|
||||
private TreeColumn mtrclmnOs;
|
||||
private TreeColumn mtrclmnInstalled;
|
||||
|
||||
/**
|
||||
* Open the window.
|
||||
* @wbp.parser.entryPoint
|
||||
*/
|
||||
public void open() {
|
||||
Display display = Display.getDefault();
|
||||
createContents();
|
||||
mshlAndroidSdkUpdater.open();
|
||||
mshlAndroidSdkUpdater.layout();
|
||||
while (!mshlAndroidSdkUpdater.isDisposed()) {
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the window.
|
||||
*/
|
||||
protected void createContents() {
|
||||
mshlAndroidSdkUpdater = new Shell();
|
||||
mshlAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
|
||||
mshlAndroidSdkUpdater.setLayout(new GridLayout(1, false));
|
||||
mshlAndroidSdkUpdater.setSize(633, 433);
|
||||
mshlAndroidSdkUpdater.setText("Android SDK Updater");
|
||||
|
||||
tabFolder = new TabFolder(mshlAndroidSdkUpdater, SWT.NONE);
|
||||
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
|
||||
|
||||
mtbtmInstalledPackages = new TabItem(tabFolder, SWT.NONE);
|
||||
mtbtmInstalledPackages.setText("Installed Packages");
|
||||
|
||||
compositeInst = new Composite(tabFolder, SWT.NONE);
|
||||
compositeInst.setLayout(new GridLayout(3, false));
|
||||
mtbtmInstalledPackages.setControl(compositeInst);
|
||||
|
||||
mlblSdkLocation = new Label(compositeInst, SWT.NONE);
|
||||
mlblSdkLocation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
mlblSdkLocation.setText("SDK Location:");
|
||||
|
||||
text = new Text(compositeInst, SWT.BORDER);
|
||||
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
mbtnBrowse = new Button(compositeInst, SWT.NONE);
|
||||
mbtnBrowse.setText("Browse...");
|
||||
|
||||
mlblInstalledPackages = new Label(compositeInst, SWT.NONE);
|
||||
mlblInstalledPackages.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
|
||||
mlblInstalledPackages.setText("Installed Packages:");
|
||||
|
||||
TableViewer tableInstalledPackage = new TableViewer(compositeInst, SWT.BORDER | SWT.FULL_SELECTION);
|
||||
table = tableInstalledPackage.getTable();
|
||||
table.setHeaderVisible(true);
|
||||
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
|
||||
|
||||
mtblclmnSummary = new TableColumn(table, SWT.NONE);
|
||||
mtblclmnSummary.setWidth(377);
|
||||
mtblclmnSummary.setText("Summary");
|
||||
|
||||
mtblclmnApiLevel = new TableColumn(table, SWT.NONE);
|
||||
mtblclmnApiLevel.setWidth(100);
|
||||
mtblclmnApiLevel.setText("API Level");
|
||||
|
||||
mtblclmnRevision = new TableColumn(table, SWT.NONE);
|
||||
mtblclmnRevision.setWidth(100);
|
||||
mtblclmnRevision.setText("Revision");
|
||||
|
||||
mgrpDescription = new Group(compositeInst, SWT.NONE);
|
||||
mgrpDescription.setText("Description");
|
||||
mgrpDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
|
||||
|
||||
composite_3 = new Composite(compositeInst, SWT.NONE);
|
||||
composite_3.setLayout(new GridLayout(5, false));
|
||||
composite_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
|
||||
|
||||
mbtnUpdate = new Button(composite_3, SWT.NONE);
|
||||
mbtnUpdate.setText("Update...");
|
||||
|
||||
placeholder1 = new Label(composite_3, SWT.NONE);
|
||||
placeholder1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
mbtnDelete = new Button(composite_3, SWT.NONE);
|
||||
mbtnDelete.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
|
||||
mbtnDelete.setText("Delete...");
|
||||
|
||||
placeholder2 = new Label(composite_3, SWT.NONE);
|
||||
placeholder2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
mbtnHomePage = new Button(composite_3, SWT.NONE);
|
||||
mbtnHomePage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
mbtnHomePage.setText("Home Page...");
|
||||
|
||||
mtbtmAvailablePackages = new TabItem(tabFolder, SWT.NONE);
|
||||
mtbtmAvailablePackages.setText("Available Packages");
|
||||
|
||||
compositeAvail = new Composite(tabFolder, SWT.NONE);
|
||||
compositeAvail.setLayout(new GridLayout(5, false));
|
||||
mtbtmAvailablePackages.setControl(compositeAvail);
|
||||
|
||||
CheckboxTreeViewer checkboxTreeAvailablePackages = new CheckboxTreeViewer(compositeAvail, SWT.BORDER);
|
||||
tree = checkboxTreeAvailablePackages.getTree();
|
||||
tree.setHeaderVisible(true);
|
||||
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
|
||||
|
||||
mtrclmnSummary = new TreeColumn(tree, SWT.NONE);
|
||||
mtrclmnSummary.setWidth(289);
|
||||
mtrclmnSummary.setText("Summary");
|
||||
|
||||
mtrclmnApiLevel = new TreeColumn(tree, SWT.NONE);
|
||||
mtrclmnApiLevel.setWidth(66);
|
||||
mtrclmnApiLevel.setText("API Level");
|
||||
|
||||
mtrclmnRevision = new TreeColumn(tree, SWT.NONE);
|
||||
mtrclmnRevision.setWidth(63);
|
||||
mtrclmnRevision.setText("Revision");
|
||||
|
||||
mtrclmnOs = new TreeColumn(tree, SWT.NONE);
|
||||
mtrclmnOs.setWidth(100);
|
||||
mtrclmnOs.setText("OS/Arch");
|
||||
|
||||
mtrclmnInstalled = new TreeColumn(tree, SWT.NONE);
|
||||
mtrclmnInstalled.setWidth(59);
|
||||
mtrclmnInstalled.setText("Installed");
|
||||
|
||||
mgrpDescription_1 = new Group(compositeAvail, SWT.NONE);
|
||||
mgrpDescription_1.setText("Description");
|
||||
mgrpDescription_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1));
|
||||
|
||||
mbtnAddSite = new Button(compositeAvail, SWT.NONE);
|
||||
mbtnAddSite.setText("Add Site...");
|
||||
|
||||
mbtnRemoveSite = new Button(compositeAvail, SWT.NONE);
|
||||
mbtnRemoveSite.setText("Delete Site...");
|
||||
|
||||
placeholder3 = new Label(compositeAvail, SWT.NONE);
|
||||
placeholder3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
mbtnRefresh = new Button(compositeAvail, SWT.NONE);
|
||||
mbtnRefresh.setText("Refresh");
|
||||
|
||||
mbtnInstallSelected = new Button(compositeAvail, SWT.NONE);
|
||||
mbtnInstallSelected.setText("Install Selected");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user