Android Open Source - PreCTS Edit Sdk Path Dialog






From Project

Back to project page PreCTS.

License

The source code is released under:

Apache License

If you think the Android project PreCTS listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.androidhuman.ctsprepare.dialog;
//from  www.  j a  v  a  2s.  c o  m
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.Dialog;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.androidhuman.ctsprepare.util.Utils;

public class EditSdkPathDialog extends Dialog {

  protected Object result;
  protected Shell shell;
  private Text txtSdkPath;

  /**
   * Create the dialog.
   * @param parent
   * @param style
   */
  public EditSdkPathDialog(Shell parent, int style) {
    super(parent, style);
    setText("Android SDK Path selection");
  }

  /**
   * Open the dialog.
   * @return the result
   */
  public Object open() {
    createContents();
    shell.open();
    shell.layout();
    Display display = getParent().getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return result;
  }

  /**
   * Create contents of the dialog.
   */
  private void createContents() {
    shell = new Shell(getParent(), SWT.CLOSE | SWT.MIN | SWT.TITLE);
    shell.setSize(450, 151);
    shell.setText(getText());
    
    txtSdkPath = new Text(shell, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI);
    txtSdkPath.setEnabled(false);
    txtSdkPath.setEditable(false);
    txtSdkPath.setBounds(10, 10, 430, 65);
    
    Button btnBrowse = new Button(shell, SWT.NONE);
    btnBrowse.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent arg0) {
        DirectoryDialog dlg = new DirectoryDialog(shell, SWT.NONE);
        dlg.setText("Select Android SDK directory");
        String path = dlg.open();
        if(path!=null){
          try{
            Utils.setAdbPath(path);
            txtSdkPath.setText(path);
          }catch(Exception e){
            Utils.showErrorMessage(shell, e.getMessage());
            return;
          }
        }
      }
    });
    btnBrowse.setBounds(10, 81, 107, 27);
    btnBrowse.setText("Browse...");
    
    Button btnApply = new Button(shell, SWT.NONE);
    btnApply.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent arg0) {
        shell.close();
      }
    });
    btnApply.setBounds(351, 81, 89, 27);
    btnApply.setText("Close");
    
    // Load data
    String adbPath = Utils.getAdbPath();
    txtSdkPath.setText(adbPath==null ? "Not set" : adbPath);

  }
}




Java Source Code List

com.androidhuman.ctsprepare.automator.GoogleAccount.java
com.androidhuman.ctsprepare.automator.PreCTSAutomate.java
com.androidhuman.ctsprepare.automator.WifiAp.java
com.androidhuman.ctsprepare.data.BasicDeviceInfo.java
com.androidhuman.ctsprepare.data.Event.java
com.androidhuman.ctsprepare.data.GoogleAccount.java
com.androidhuman.ctsprepare.data.Model.java
com.androidhuman.ctsprepare.data.ProxySettings.java
com.androidhuman.ctsprepare.data.Task.java
com.androidhuman.ctsprepare.data.Waiver.java
com.androidhuman.ctsprepare.data.WifiAp.java
com.androidhuman.ctsprepare.dialog.CtsMediaDownloadDialog.java
com.androidhuman.ctsprepare.dialog.EditGoogleAccountDialog.java
com.androidhuman.ctsprepare.dialog.EditMacroDialog.java
com.androidhuman.ctsprepare.dialog.EditProxyDialog.java
com.androidhuman.ctsprepare.dialog.EditSdkPathDialog.java
com.androidhuman.ctsprepare.dialog.EditWifiApDialog.java
com.androidhuman.ctsprepare.dialog.TargetSelectionDialog.java
com.androidhuman.ctsprepare.shell.ConfigureMacroShell.java
com.androidhuman.ctsprepare.shell.Main.java
com.androidhuman.ctsprepare.util.AdbCommand.java
com.androidhuman.ctsprepare.util.AdbWrapper.java
com.androidhuman.ctsprepare.util.AsyncTask.java
com.androidhuman.ctsprepare.util.Download.java
com.androidhuman.ctsprepare.util.Utils.java
com.androidhuman.ctsprepare.util.Worker.java
com.androidhuman.prectsandroidsettingsapp.EnableSyncActivity.java
com.androidhuman.prectsandroidsettingsapp.FinishHandler.java
com.androidhuman.prectsandroidsettingsapp.MainActivity.java