aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sdkmanager/app/src/com/android/sdkmanager/Main.java9
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AboutDialog.java (renamed from sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java)97
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SettingsDialog.java (renamed from sdkmanager/app/src/com/android/sdkmanager/internal/repository/SettingsPage.java)81
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterBaseDialog.java107
-rw-r--r--sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/sdkman_logo_128.png (renamed from sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png)bin2381 -> 2381 bytes
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AddonSitesDialog.java77
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java108
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/SdkUpdaterWindow.java37
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/GridDataBuilder.java18
9 files changed, 226 insertions, 308 deletions
diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java
index 79dc5a7..6fcc804 100644
--- a/sdkmanager/app/src/com/android/sdkmanager/Main.java
+++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java
@@ -41,11 +41,7 @@ import com.android.sdklib.internal.repository.ToolPackage;
import com.android.sdklib.repository.SdkAddonConstants;
import com.android.sdklib.repository.SdkRepoConstants;
import com.android.sdklib.xml.AndroidXPathFactory;
-import com.android.sdkmanager.internal.repository.AboutPage;
-import com.android.sdkmanager.internal.repository.SettingsPage;
import com.android.sdkuilib.internal.repository.SdkUpdaterNoWindow;
-import com.android.sdkuilib.internal.repository.UpdaterPage;
-import com.android.sdkuilib.internal.repository.sdkman2.PackagesPage;
import com.android.sdkuilib.internal.widgets.MessageBoxLog;
import com.android.sdkuilib.repository.AvdManagerWindow;
import com.android.sdkuilib.repository.AvdManagerWindow.AvdInvocationContext;
@@ -330,8 +326,6 @@ public class Main {
errorLogger,
mOsSdkFolder,
SdkInvocationContext.STANDALONE);
- window.registerPage(SettingsPage.class, UpdaterPage.Purpose.SETTINGS);
- window.registerPage(AboutPage.class, UpdaterPage.Purpose.ABOUT_BOX);
window.open();
errorLogger.displayResult(true);
@@ -357,9 +351,6 @@ public class Main {
mOsSdkFolder,
AvdInvocationContext.STANDALONE);
- window.registerPage(SettingsPage.class, UpdaterPage.Purpose.SETTINGS);
- window.registerPage(AboutPage.class, UpdaterPage.Purpose.ABOUT_BOX);
-
window.open();
errorLogger.displayResult(true);
diff --git a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AboutDialog.java
index a12268c..ba87300 100755
--- a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/AboutPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/AboutDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2012 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.
@@ -14,73 +14,67 @@
* limitations under the License.
*/
-package com.android.sdkmanager.internal.repository;
+package com.android.sdkuilib.internal.repository;
import com.android.sdklib.SdkConstants;
+import com.android.sdklib.io.FileOp;
import com.android.sdklib.repository.PkgProps;
import com.android.sdklib.repository.SdkAddonConstants;
import com.android.sdklib.repository.SdkRepoConstants;
-import com.android.sdkmanager.Main;
-import com.android.sdkuilib.internal.repository.UpdaterPage;
+import com.android.sdkuilib.internal.repository.icons.ImageFactory;
+import com.android.sdkuilib.ui.GridDataBuilder;
+import com.android.sdkuilib.ui.GridLayoutBuilder;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Properties;
-public class AboutPage extends UpdaterPage {
+public class AboutDialog extends UpdaterBaseDialog {
- private Label mLabel;
-
- /**
- * Create the composite.
- * @param parent The parent of the composite.
- */
- public AboutPage(Composite parent, int swtStyle) {
- super(parent, swtStyle);
-
- createContents(this);
-
- postCreate(); //$hide$
+ public AboutDialog(Shell parentShell, UpdaterData updaterData) {
+ super(parentShell, updaterData, "About" /*title*/);
+ assert updaterData != null;
}
@Override
- public String getPageTitle() {
- return "About";
- }
-
- private void createContents(Composite parent) {
- parent.setLayout(new GridLayout(2, false));
-
- Label logo = new Label(parent, SWT.NONE);
- InputStream imageStream = this.getClass().getResourceAsStream("logo.png"); //$NON-NLS-1$
-
- if (imageStream != null) {
- Image img = new Image(parent.getShell().getDisplay(), imageStream);
- logo.setImage(img);
- }
-
- mLabel = new Label(parent, SWT.NONE);
- mLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
- mLabel.setText(String.format(
- "Android SDK Updater.\n" +
+ protected void createContents() {
+ super.createContents();
+ Shell shell = getShell();
+ shell.setMinimumSize(new Point(450, 150));
+ shell.setSize(450, 150);
+
+ GridLayoutBuilder.create(shell).columns(3);
+
+ Label logo = new Label(shell, SWT.NONE);
+ ImageFactory imgf = getUpdaterData() == null ? null : getUpdaterData().getImageFactory();
+ Image image = imgf == null ? null : imgf.getImageByName("sdkman_logo_128.png");
+ if (image != null) logo.setImage(image);
+
+ Label label = new Label(shell, SWT.NONE);
+ GridDataBuilder.create(label).hFill().hGrab().hSpan(2);;
+ label.setText(String.format(
+ "Android SDK Manager.\n" +
"Revision %1$s\n" +
"Add-on XML Schema #%2$d\n" +
"Repository XML Schema #%3$d\n" +
- "Copyright (C) 2009-2011 The Android Open Source Project.",
+ "Copyright (C) 2009-2012 The Android Open Source Project.",
getRevision(),
SdkAddonConstants.NS_LATEST_VERSION,
SdkRepoConstants.NS_LATEST_VERSION));
+
+
+ Label filler = new Label(shell, SWT.NONE);
+ GridDataBuilder.create(filler).fill().grab().hSpan(2);
+
+ createCloseButton();
}
@Override
@@ -92,25 +86,15 @@ public class AboutPage extends UpdaterPage {
// Hide everything down-below from SWT designer
//$hide>>$
- /**
- * Called by the constructor right after {@link #createContents(Composite)}.
- */
- private void postCreate() {
- }
-
// End of hiding from SWT Designer
//$hide<<$
private String getRevision() {
Properties p = new Properties();
try{
- String toolsdir = System.getProperty(Main.TOOLSDIR);
- File sourceProp;
- if (toolsdir == null || toolsdir.length() == 0) {
- sourceProp = new File(SdkConstants.FN_SOURCE_PROP);
- } else {
- sourceProp = new File(toolsdir, SdkConstants.FN_SOURCE_PROP);
- }
+ File sourceProp = FileOp.append(getUpdaterData().getOsSdkRoot(),
+ SdkConstants.FD_TOOLS,
+ SdkConstants.FN_SOURCE_PROP);
FileInputStream fis = null;
try {
fis = new FileInputStream(sourceProp);
@@ -128,10 +112,7 @@ public class AboutPage extends UpdaterPage {
if (revision != null) {
return revision;
}
- } catch (FileNotFoundException e) {
- // couldn't find the file? don't ping.
} catch (IOException e) {
- // couldn't find the file? don't ping.
}
return "?";
diff --git a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/SettingsPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SettingsDialog.java
index f567d8b..f145453 100755
--- a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/SettingsPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SettingsDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2012 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.
@@ -14,30 +14,29 @@
* limitations under the License.
*/
-package com.android.sdkmanager.internal.repository;
+package com.android.sdkuilib.internal.repository;
-import com.android.sdkuilib.internal.repository.ISettingsPage;
-import com.android.sdkuilib.internal.repository.UpdaterPage;
+import com.android.sdkuilib.ui.GridDataBuilder;
+import com.android.sdkuilib.ui.GridLayoutBuilder;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
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.Shell;
import org.eclipse.swt.widgets.Text;
import java.util.Properties;
-public class SettingsPage extends UpdaterPage implements ISettingsPage {
+public class SettingsDialog extends UpdaterBaseDialog implements ISettingsPage {
// data members
+ private final SettingsController mSettingsController;
private SettingsChangedCallback mSettingsChangedCallback;
// UI widgets
@@ -64,91 +63,87 @@ public class SettingsPage extends UpdaterPage implements ISettingsPage {
}
};
- /**
- * Create the composite.
- * @param parent The parent of the composite.
- */
- public SettingsPage(Composite parent, int swtStyle) {
- super(parent, swtStyle);
-
- createContents(this);
- postCreate(); //$hide$
+ public SettingsDialog(Shell parentShell, UpdaterData updaterData) {
+ super(parentShell, updaterData, "Settings" /*title*/);
+ assert updaterData != null;
+ mSettingsController = updaterData.getSettingsController();
}
@Override
- public String getPageTitle() {
- return "Settings";
- }
-
- private void createContents(Composite parent) {
- parent.setLayout(new GridLayout(1, false));
+ protected void createContents() {
+ super.createContents();
+ Shell shell = getShell();
- mProxySettingsGroup = new Group(this, SWT.NONE);
+ mProxySettingsGroup = new Group(shell, SWT.NONE);
mProxySettingsGroup.setText("Proxy Settings");
- mProxySettingsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- mProxySettingsGroup.setLayout(new GridLayout(2, false));
+ GridDataBuilder.create(mProxySettingsGroup).fill().grab().hSpan(2);
+ GridLayoutBuilder.create(mProxySettingsGroup).columns(2);
mProxyServerLabel = new Label(mProxySettingsGroup, SWT.NONE);
- mProxyServerLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ GridDataBuilder.create(mProxyServerLabel).hRight().vCenter();
mProxyServerLabel.setText("HTTP Proxy Server");
String tooltip = "The DNS name or IP of the HTTP proxy server to use. " +
"When empty, no HTTP proxy is used.";
mProxyServerLabel.setToolTipText(tooltip);
mProxyServerText = new Text(mProxySettingsGroup, SWT.BORDER);
- mProxyServerText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ GridDataBuilder.create(mProxyServerText).hFill().hGrab().vCenter();
mProxyServerText.addModifyListener(mApplyOnModified);
mProxyServerText.setToolTipText(tooltip);
mProxyPortLabel = new Label(mProxySettingsGroup, SWT.NONE);
- mProxyPortLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ GridDataBuilder.create(mProxyPortLabel).hRight().vCenter();
mProxyPortLabel.setText("HTTP Proxy Port");
tooltip = "The port of the HTTP proxy server to use. " +
"When empty, the default for HTTP or HTTPS is used.";
mProxyPortLabel.setToolTipText(tooltip);
mProxyPortText = new Text(mProxySettingsGroup, SWT.BORDER);
- mProxyPortText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+ GridDataBuilder.create(mProxyPortText).hFill().hGrab().vCenter();
mProxyPortText.addModifyListener(mApplyOnModified);
mProxyPortText.setToolTipText(tooltip);
- mMiscGroup = new Group(this, SWT.NONE);
- mMiscGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ mMiscGroup = new Group(shell, SWT.NONE);
mMiscGroup.setText("Misc");
- mMiscGroup.setLayout(new GridLayout(2, false));
+ GridDataBuilder.create(mMiscGroup).fill().grab().hSpan(2);
+ GridLayoutBuilder.create(mMiscGroup).columns(2);
mForceHttpCheck = new Button(mMiscGroup, SWT.CHECK);
- mForceHttpCheck.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ GridDataBuilder.create(mForceHttpCheck).hFill().hGrab().vCenter().hSpan(2);
mForceHttpCheck.setText("Force https://... sources to be fetched using http://...");
mForceHttpCheck.setToolTipText("If you are not able to connect to the official Android repository " +
"using HTTPS, enable this setting to force accessing it via HTTP.");
mForceHttpCheck.addSelectionListener(mApplyOnSelected);
mAskAdbRestartCheck = new Button(mMiscGroup, SWT.CHECK);
- mAskAdbRestartCheck.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+ GridDataBuilder.create(mAskAdbRestartCheck).hFill().hGrab().vCenter().hSpan(2);
mAskAdbRestartCheck.setText("Ask before restarting ADB");
mAskAdbRestartCheck.setToolTipText("When checked, the user will be asked for permission " +
"to restart ADB after updating an addon-on package or a tool package.");
mAskAdbRestartCheck.addSelectionListener(mApplyOnSelected);
+
+ createCloseButton();
}
@Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
+ protected void postCreate() {
+ super.postCreate();
+ // This tells the controller to load the settings into the page UI.
+ mSettingsController.setSettingsPage(this);
}
+ @Override
+ protected void close() {
+ // Dissociate this page from the controller
+ mSettingsController.setSettingsPage(null);
+ super.close();
+ }
// -- Start of internal part ----------
// Hide everything down-below from SWT designer
//$hide>>$
- /**
- * Called by the constructor right after {@link #createContents(Composite)}.
- */
- private void postCreate() {
- }
-
/** Loads settings from the given {@link Properties} container and update the page UI. */
@Override
public void loadSettings(Properties in_settings) {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterBaseDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterBaseDialog.java
new file mode 100755
index 0000000..b8b1e19
--- /dev/null
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterBaseDialog.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package com.android.sdkuilib.internal.repository;
+
+import com.android.sdklib.SdkConstants;
+import com.android.sdkuilib.internal.repository.icons.ImageFactory;
+import com.android.sdkuilib.internal.repository.sdkman2.SdkUpdaterWindowImpl2;
+import com.android.sdkuilib.ui.GridDataBuilder;
+import com.android.sdkuilib.ui.GridLayoutBuilder;
+import com.android.sdkuilib.ui.SwtBaseDialog;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Shell;
+
+
+
+/**
+ * Base class for auxiliary dialogs shown in the updater (for example settings,
+ * about box or add-on site.)
+ */
+public abstract class UpdaterBaseDialog extends SwtBaseDialog {
+
+ private final UpdaterData mUpdaterData;
+
+ protected UpdaterBaseDialog(Shell parentShell, UpdaterData updaterData, String title) {
+ super(parentShell,
+ SWT.APPLICATION_MODAL,
+ String.format("%1$s - %2$s", SdkUpdaterWindowImpl2.APP_NAME, title)); //$NON-NLS-1$
+ mUpdaterData = updaterData;
+ }
+
+ public UpdaterData getUpdaterData() {
+ return mUpdaterData;
+ }
+
+ /**
+ * Initializes the shell with a 2-column Grid layout.
+ * Caller should use {@link #createCloseButton()} to inject the
+ * close button at the bottom of the dialog.
+ */
+ @Override
+ protected void createContents() {
+ Shell shell = getShell();
+ setWindowImage(shell);
+
+ GridLayoutBuilder.create(shell).columns(2);
+
+ }
+
+ protected void createCloseButton() {
+ Button close = new Button(getShell(), SWT.PUSH);
+ close.setText("Close");
+ GridDataBuilder.create(close).hFill().vBottom();
+ close.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ close();
+ }
+ });
+ }
+
+ @Override
+ protected void postCreate() {
+ // pass
+ }
+
+ @Override
+ protected void close() {
+ super.close();
+ }
+
+ /**
+ * Creates the icon of the window shell.
+ *
+ * @param shell The shell on which to put the icon
+ */
+ private void setWindowImage(Shell shell) {
+ String imageName = "android_icon_16.png"; //$NON-NLS-1$
+ if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_DARWIN) {
+ imageName = "android_icon_128.png"; //$NON-NLS-1$
+ }
+
+ if (mUpdaterData != null) {
+ ImageFactory imgFactory = mUpdaterData.getImageFactory();
+ if (imgFactory != null) {
+ shell.setImage(imgFactory.getImageByName(imageName));
+ }
+ }
+ }
+}
diff --git a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/sdkman_logo_128.png
index 0f1670d..0f1670d 100644
--- a/sdkmanager/app/src/com/android/sdkmanager/internal/repository/logo.png
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/icons/sdkman_logo_128.png
Binary files differ
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AddonSitesDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AddonSitesDialog.java
index a600ad3..28a065a 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AddonSitesDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AddonSitesDialog.java
@@ -16,14 +16,13 @@
package com.android.sdkuilib.internal.repository.sdkman2;
-import com.android.sdklib.SdkConstants;
import com.android.sdklib.internal.repository.SdkAddonSource;
import com.android.sdklib.internal.repository.SdkSource;
import com.android.sdklib.internal.repository.SdkSourceCategory;
import com.android.sdklib.internal.repository.SdkSources;
+import com.android.sdkuilib.internal.repository.UpdaterBaseDialog;
import com.android.sdkuilib.internal.repository.UpdaterData;
-import com.android.sdkuilib.internal.repository.icons.ImageFactory;
-import com.android.sdkuilib.ui.SwtBaseDialog;
+import com.android.sdkuilib.ui.GridDataBuilder;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -47,8 +46,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
@@ -58,16 +55,12 @@ import org.eclipse.swt.widgets.TableColumn;
import java.util.Arrays;
-public class AddonSitesDialog extends SwtBaseDialog {
-
- private final UpdaterData mUpdaterData;
+public class AddonSitesDialog extends UpdaterBaseDialog {
private Table mTable;
private TableViewer mTableViewer;
private Button mButtonNew;
private Button mButtonDelete;
- private Button mButtonClose;
- private Label mlabel;
private Button mButtonEdit;
private TableColumn mColumnUrl;
@@ -77,8 +70,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
* @param parent The parent's shell
*/
public AddonSitesDialog(Shell parent, UpdaterData updaterData) {
- super(parent, SWT.APPLICATION_MODAL, "Add-on Sites");
- mUpdaterData = updaterData;
+ super(parent, updaterData, "Add-on Sites");
}
/**
@@ -87,18 +79,14 @@ public class AddonSitesDialog extends SwtBaseDialog {
@SuppressWarnings("unused")
@Override
protected void createContents() {
+ super.createContents();
Shell shell = getShell();
shell.setMinimumSize(new Point(450, 300));
shell.setSize(450, 300);
- setWindowImage(shell);
-
- GridLayout glShell = new GridLayout();
- glShell.numColumns = 2;
- shell.setLayout(glShell);
- mlabel = new Label(shell, SWT.NONE);
- mlabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
- mlabel.setText(
+ Label label = new Label(shell, SWT.NONE);
+ GridDataBuilder.create(label).hLeft().vCenter().hSpan(2);
+ label.setText(
"This dialog lets you manage the URLs of external add-on sites to be used.\n" +
"\n" +
"Add-on sites can provide new add-ons or \"user\" packages.\n" +
@@ -121,7 +109,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
on_Table_mouseUp(e);
}
});
- mTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 5));
+ GridDataBuilder.create(mTable).fill().grab().vSpan(5);
TableViewerColumn tableViewerColumn = new TableViewerColumn(mTableViewer, SWT.NONE);
mColumnUrl = tableViewerColumn.getColumn();
@@ -135,7 +123,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
newOrEdit(false /*isEdit*/);
}
});
- mButtonNew.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ GridDataBuilder.create(mButtonNew).hFill().vCenter();
mButtonNew.setText("New...");
mButtonEdit = new Button(shell, SWT.NONE);
@@ -145,7 +133,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
newOrEdit(true /*isEdit*/);
}
});
- mButtonEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ GridDataBuilder.create(mButtonEdit).hFill().vCenter();
mButtonEdit.setText("Edit...");
mButtonDelete = new Button(shell, SWT.NONE);
@@ -155,43 +143,16 @@ public class AddonSitesDialog extends SwtBaseDialog {
on_ButtonDelete_widgetSelected(e);
}
});
- mButtonDelete.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ GridDataBuilder.create(mButtonDelete).hFill().vCenter();
mButtonDelete.setText("Delete...");
new Label(shell, SWT.NONE);
- mButtonClose = new Button(shell, SWT.NONE);
- mButtonClose.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- on_ButtonClose_widgetSelected(e);
- }
- });
- mButtonClose.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
- mButtonClose.setText("Close");
+ createCloseButton();
adjustColumnsWidth(mTable, mColumnUrl);
}
/**
- * Creates the icon of the window shell.
- *
- * @param shell The shell on which to put the icon
- */
- private void setWindowImage(Shell shell) {
- String imageName = "android_icon_16.png"; //$NON-NLS-1$
- if (SdkConstants.currentPlatform() == SdkConstants.PLATFORM_DARWIN) {
- imageName = "android_icon_128.png"; //$NON-NLS-1$
- }
-
- if (mUpdaterData != null) {
- ImageFactory imgFactory = mUpdaterData.getImageFactory();
- if (imgFactory != null) {
- shell.setImage(imgFactory.getImageByName(imageName));
- }
- }
- }
-
- /**
* Adds a listener to adjust the column width when the parent is resized.
*/
private void adjustColumnsWidth(final Table table, final TableColumn column0) {
@@ -206,7 +167,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
}
private void newOrEdit(final boolean isEdit) {
- SdkSources sources = mUpdaterData.getSources();
+ SdkSources sources = getUpdaterData().getSources();
final SdkSource[] knownSources = sources.getAllSources();
String title = isEdit ? "Edit Add-on Site URL" : "Add Add-on Site URL";
String msg = "Please enter the URL of the addon.xml:";
@@ -304,7 +265,7 @@ public class AddonSitesDialog extends SwtBaseDialog {
mb.setText("Delete add-on site");
mb.setMessage(String.format("Do you want to delete the URL %1$s?", selectedUrl));
if (mb.open() == SWT.YES) {
- SdkSources sources = mUpdaterData.getSources();
+ SdkSources sources = getUpdaterData().getSources();
for (SdkSource source : sources.getSources(SdkSourceCategory.USER_ADDONS)) {
if (selectedUrl.equals(source.getUrl())) {
sources.remove(source);
@@ -315,10 +276,6 @@ public class AddonSitesDialog extends SwtBaseDialog {
}
}
- private void on_ButtonClose_widgetSelected(SelectionEvent e) {
- close();
- }
-
private void on_Table_mouseUp(MouseEvent e) {
Point p = new Point(e.x, e.y);
if (mTable.getItem(p) == null) {
@@ -342,9 +299,9 @@ public class AddonSitesDialog extends SwtBaseDialog {
}
private void loadList() {
- if (mUpdaterData != null) {
+ if (getUpdaterData() != null) {
SdkSource[] knownSources =
- mUpdaterData.getSources().getSources(SdkSourceCategory.USER_ADDONS);
+ getUpdaterData().getSources().getSources(SdkSourceCategory.USER_ADDONS);
Arrays.sort(knownSources);
ISelection oldSelection = mTableViewer.getSelection();
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java
index 9cf96f3..135c6bd 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/SdkUpdaterWindowImpl2.java
@@ -20,10 +20,11 @@ package com.android.sdkuilib.internal.repository.sdkman2;
import com.android.sdklib.ISdkLog;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.internal.repository.ITaskFactory;
+import com.android.sdkuilib.internal.repository.AboutDialog;
import com.android.sdkuilib.internal.repository.ISdkUpdaterWindow;
-import com.android.sdkuilib.internal.repository.ISettingsPage;
import com.android.sdkuilib.internal.repository.MenuBarWrapper;
import com.android.sdkuilib.internal.repository.SettingsController;
+import com.android.sdkuilib.internal.repository.SettingsDialog;
import com.android.sdkuilib.internal.repository.UpdaterData;
import com.android.sdkuilib.internal.repository.UpdaterPage;
import com.android.sdkuilib.internal.repository.UpdaterPage.Purpose;
@@ -37,9 +38,6 @@ import com.android.sdkuilib.internal.widgets.ToggleButton;
import com.android.sdkuilib.repository.AvdManagerWindow.AvdInvocationContext;
import com.android.sdkuilib.repository.ISdkChangeListener;
import com.android.sdkuilib.repository.SdkUpdaterWindow.SdkInvocationContext;
-import com.android.sdkuilib.ui.GridDataBuilder;
-import com.android.sdkuilib.ui.GridLayoutBuilder;
-import com.android.sdkuilib.ui.SwtBaseDialog;
import com.android.util.Pair;
import org.eclipse.swt.SWT;
@@ -51,7 +49,6 @@ import org.eclipse.swt.graphics.Image;
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.Event;
@@ -72,7 +69,7 @@ import java.util.ArrayList;
*/
public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow {
- private static final String APP_NAME = "Android SDK Manager";
+ public static final String APP_NAME = "Android SDK Manager";
private static final String SIZE_POS_PREFIX = "sdkman2"; //$NON-NLS-1$
private final Shell mParentShell;
@@ -340,12 +337,14 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow {
new MenuBarWrapper(APP_NAME, menuTools) {
@Override
public void onPreferencesMenuSelected() {
- showRegisteredPage(Purpose.SETTINGS);
+ SettingsDialog sd = new SettingsDialog(mShell, mUpdaterData);
+ sd.open();
}
@Override
public void onAboutMenuSelected() {
- showRegisteredPage(Purpose.ABOUT_BOX);
+ AboutDialog ad = new AboutDialog(mShell, mUpdaterData);
+ ad.open();
}
@Override
@@ -618,26 +617,6 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow {
// TODO
}
- private void showRegisteredPage(Purpose purpose) {
- if (mExtraPages == null) {
- return;
- }
-
- Class<? extends UpdaterPage> clazz = null;
-
- for (Pair<Class<? extends UpdaterPage>, Purpose> extraPage : mExtraPages) {
- if (extraPage.getSecond() == purpose) {
- clazz = extraPage.getFirst();
- break;
- }
- }
-
- if (clazz != null) {
- PageDialog d = new PageDialog(mShell, clazz, purpose == Purpose.SETTINGS);
- d.open();
- }
- }
-
private void onAvdManager() {
ITaskFactory oldFactory = mUpdaterData.getTaskFactory();
@@ -661,77 +640,4 @@ public class SdkUpdaterWindowImpl2 implements ISdkUpdaterWindow {
// End of hiding from SWT Designer
//$hide<<$
-
- // -----
-
- /**
- * Dialog used to display either the About page or the Settings (aka Options) page
- * with a "close" button.
- */
- private class PageDialog extends SwtBaseDialog {
-
- private final Class<? extends UpdaterPage> mPageClass;
- private final boolean mIsSettingsPage;
-
- protected PageDialog(
- Shell parentShell,
- Class<? extends UpdaterPage> pageClass,
- boolean isSettingsPage) {
- super(parentShell, SWT.APPLICATION_MODAL, null /*title*/);
- mPageClass = pageClass;
- mIsSettingsPage = isSettingsPage;
- }
-
- @Override
- protected void createContents() {
- Shell shell = getShell();
- setWindowImage(shell);
-
- GridLayoutBuilder.create(shell).columns(2);
-
- UpdaterPage content = UpdaterPage.newInstance(
- mPageClass,
- shell,
- SWT.NONE,
- mUpdaterData.getSdkLog());
- GridDataBuilder.create(content).fill().grab().hSpan(2);
- if (content.getLayout() instanceof GridLayout) {
- GridLayout gl = (GridLayout) content.getLayout();
- gl.marginHeight = gl.marginWidth = 0;
- }
-
- if (mIsSettingsPage && content instanceof ISettingsPage) {
- mSettingsController.setSettingsPage((ISettingsPage) content);
- }
-
- getShell().setText(
- String.format("%1$s - %2$s", APP_NAME, content.getPageTitle()));
-
- Label filler = new Label(shell, SWT.NONE);
- GridDataBuilder.create(filler).hFill().hGrab();
-
- Button close = new Button(shell, SWT.PUSH);
- close.setText("Close");
- GridDataBuilder.create(close);
- close.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- close();
- }
- });
- }
-
- @Override
- protected void postCreate() {
- // pass
- }
-
- @Override
- protected void close() {
- if (mIsSettingsPage) {
- mSettingsController.setSettingsPage(null);
- }
- super.close();
- }
- }
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/SdkUpdaterWindow.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/SdkUpdaterWindow.java
index 59da350..06fc387 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/SdkUpdaterWindow.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/SdkUpdaterWindow.java
@@ -18,10 +18,8 @@ package com.android.sdkuilib.repository;
import com.android.sdklib.ISdkLog;
import com.android.sdkuilib.internal.repository.ISdkUpdaterWindow;
-import com.android.sdkuilib.internal.repository.UpdaterPage;
import com.android.sdkuilib.internal.repository.sdkman2.SdkUpdaterWindowImpl2;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
/**
@@ -90,41 +88,6 @@ public class SdkUpdaterWindow {
}
/**
- * Registers an extra page for the updater window.
- * <p/>
- * Pages must derive from {@link Composite} and implement a constructor that takes
- * a single parent {@link Composite} argument.
- * <p/>
- * All pages must be registered before the call to {@link #open()}.
- *
- * @param pageClass The {@link Composite}-derived class that will implement the page.
- * @param purpose The purpose of this page, e.g. an about box, settings page or generic.
- */
- public void registerPage(Class<? extends UpdaterPage> pageClass,
- UpdaterPage.Purpose purpose) {
- mWindow.registerPage(pageClass, purpose);
- }
-
- /**
- * Indicate the initial page that should be selected when the window opens.
- * <p/>
- * This must be called before the call to {@link #open()}.
- * If null or if the page class is not found, the first page will be selected.
- */
- public void setInitialPage(Class<? extends Composite> pageClass) {
- mWindow.setInitialPage(pageClass);
- }
-
- /**
- * Sets whether the auto-update wizard will be shown when opening the window.
- * <p/>
- * This must be called before the call to {@link #open()}.
- */
- public void setRequestAutoUpdate(boolean requestAutoUpdate) {
- mWindow.setRequestAutoUpdate(requestAutoUpdate);
- }
-
- /**
* Adds a new listener to be notified when a change is made to the content of the SDK.
* This should be called before {@link #open()}.
*/
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/GridDataBuilder.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/GridDataBuilder.java
index 2e7367a..381dea0 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/GridDataBuilder.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/ui/GridDataBuilder.java
@@ -93,6 +93,24 @@ public final class GridDataBuilder {
return this;
}
+ /** Sets <code>verticalAlignment</code> to {@link SWT#BOTTOM}. */
+ public GridDataBuilder vBottom() {
+ mGD.verticalAlignment = SWT.BOTTOM;
+ return this;
+ }
+
+ /** Sets <code>horizontalAlignment</code> to {@link SWT#LEFT}. */
+ public GridDataBuilder hLeft() {
+ mGD.horizontalAlignment = SWT.LEFT;
+ return this;
+ }
+
+ /** Sets <code>horizontalAlignment</code> to {@link SWT#RIGHT}. */
+ public GridDataBuilder hRight() {
+ mGD.horizontalAlignment = SWT.RIGHT;
+ return this;
+ }
+
/** Sets <code>horizontalAlignment</code> to {@link GridData#FILL}. */
public GridDataBuilder hFill() {
mGD.horizontalAlignment = GridData.FILL;