com.android.ide.eclipse.monitor_23.0.2.1259578

16:34:18.647 INFO  jd.cli.Main - Decompiling com.android.ide.eclipse.monitor_23.0.2.1259578.jar
package com.android.ide.eclipse.monitor;

import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class MonitorWorkbenchWindowAdvisor
  extends WorkbenchWindowAdvisor
{
  public MonitorWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
  {
    super(configurer);
  }
  
  public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
  {
    return new MonitorActionBarAdvisor(configurer);
  }
  
  public void preWindowOpen()
  {
    IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
    configurer.setShowStatusLine(true);
    configurer.setShowPerspectiveBar(true);
    configurer.setTitle("Android Device Monitor");
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.MonitorWorkbenchWindowAdvisor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor;

import com.android.ide.eclipse.ddms.Perspective;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class MonitorWorkbenchAdvisor
  extends WorkbenchAdvisor
{
  public String getInitialWindowPerspectiveId()
  {
    return Perspective.ID;
  }
  
  public void initialize(IWorkbenchConfigurer configurer)
  {
    super.initialize(configurer);
    configurer.setSaveAndRestore(true);
  }
  
  public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer)
  {
    return new MonitorWorkbenchWindowAdvisor(configurer);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.MonitorWorkbenchAdvisor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor;

import com.android.sdkstats.SdkStatsService;
import java.io.File;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.IStartup;

public class MonitorStartup
  implements IStartup
{
  public void earlyStartup()
  {
    Job pingJob = new Job("Android SDK Ping")
    {
      protected IStatus run(IProgressMonitor monitor)
      {
        SdkStatsService stats = new SdkStatsService();
        File sdkFolder = MonitorPlugin.getDefault().getSdkFolder();
        if (sdkFolder == null) {
          return Status.OK_STATUS;
        }
        String toolsPath = new File(sdkFolder, "tools").getAbsolutePath();
        MonitorStartup.ping(stats, toolsPath);
        return Status.OK_STATUS;
      }
    };
    pingJob.setPriority(50);
    pingJob.schedule();
  }
  
  /* Error */
  private static void ping(SdkStatsService stats, String toolsLocation)
  {
    // Byte code:
    //   0: new 37	java/util/Properties
    //   3: dup
    //   4: invokespecial 39	java/util/Properties:<init>	()V
    //   7: astore_2
    //   8: aload_1
    //   9: ifnull +24 -> 33
    //   12: aload_1
    //   13: invokevirtual 40	java/lang/String:length	()I
    //   16: ifle +17 -> 33
    //   19: new 46	java/io/File
    //   22: dup
    //   23: aload_1
    //   24: ldc 48
    //   26: invokespecial 50	java/io/File:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   29: astore_3
    //   30: goto +13 -> 43
    //   33: new 46	java/io/File
    //   36: dup
    //   37: ldc 48
    //   39: invokespecial 53	java/io/File:<init>	(Ljava/lang/String;)V
    //   42: astore_3
    //   43: aconst_null
    //   44: astore 4
    //   46: new 56	java/io/FileInputStream
    //   49: dup
    //   50: aload_3
    //   51: invokespecial 58	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   54: astore 4
    //   56: aload_2
    //   57: aload 4
    //   59: invokevirtual 61	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   62: goto +22 -> 84
    //   65: astore 5
    //   67: aload 4
    //   69: ifnull +12 -> 81
    //   72: aload 4
    //   74: invokevirtual 65	java/io/FileInputStream:close	()V
    //   77: goto +4 -> 81
    //   80: pop
    //   81: aload 5
    //   83: athrow
    //   84: aload 4
    //   86: ifnull +12 -> 98
    //   89: aload 4
    //   91: invokevirtual 65	java/io/FileInputStream:close	()V
    //   94: goto +4 -> 98
    //   97: pop
    //   98: aload_2
    //   99: ldc 68
    //   101: invokevirtual 70	java/util/Properties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   104: astore 5
    //   106: aload 5
    //   108: ifnull +27 -> 135
    //   111: aload 5
    //   113: invokevirtual 40	java/lang/String:length	()I
    //   116: ifle +19 -> 135
    //   119: aload_0
    //   120: ldc 74
    //   122: aload 5
    //   124: invokevirtual 76	com/android/sdkstats/SdkStatsService:ping	(Ljava/lang/String;Ljava/lang/String;)V
    //   127: goto +8 -> 135
    //   130: pop
    //   131: goto +4 -> 135
    //   134: pop
    //   135: return
    // Line number table:
    //   Java source line #56	-> byte code offset #0
    //   Java source line #59	-> byte code offset #8
    //   Java source line #60	-> byte code offset #19
    //   Java source line #61	-> byte code offset #30
    //   Java source line #62	-> byte code offset #33
    //   Java source line #64	-> byte code offset #43
    //   Java source line #66	-> byte code offset #46
    //   Java source line #67	-> byte code offset #56
    //   Java source line #68	-> byte code offset #62
    //   Java source line #69	-> byte code offset #67
    //   Java source line #71	-> byte code offset #72
    //   Java source line #72	-> byte code offset #77
    //   Java source line #75	-> byte code offset #81
    //   Java source line #69	-> byte code offset #84
    //   Java source line #71	-> byte code offset #89
    //   Java source line #72	-> byte code offset #94
    //   Java source line #77	-> byte code offset #98
    //   Java source line #78	-> byte code offset #106
    //   Java source line #79	-> byte code offset #119
    //   Java source line #81	-> byte code offset #127
    //   Java source line #83	-> byte code offset #134
    //   Java source line #86	-> byte code offset #135
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	136	0	stats	SdkStatsService
    //   0	136	1	toolsLocation	String
    //   7	92	2	p	java.util.Properties
    //   29	2	3	sourceProp	File
    //   42	9	3	sourceProp	File
    //   44	46	4	fis	java.io.FileInputStream
    //   65	17	5	localObject	Object
    //   104	19	5	revision	String
    //   80	1	8	localIOException1	java.io.IOException
    //   97	1	9	localIOException2	java.io.IOException
    //   130	1	10	localFileNotFoundException	java.io.FileNotFoundException
    //   134	1	11	localIOException3	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   46	65	65	finally
    //   72	77	80	java/io/IOException
    //   89	94	97	java/io/IOException
    //   8	127	130	java/io/FileNotFoundException
    //   8	127	134	java/io/IOException
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.MonitorStartup
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Table;

class StaticPortConfigDialog$4
  extends SelectionAdapter
{
  StaticPortConfigDialog$4(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    int index = StaticPortConfigDialog.access$3(this$0).getSelectionIndex();
    StaticPortConfigDialog.access$8(this$0, index);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class StaticPortEditDialog$2
  implements ModifyListener
{
  StaticPortEditDialog$2(StaticPortEditDialog paramStaticPortEditDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    StaticPortEditDialog.access$0(this$0, val$deviceSNText.getText().trim());
    StaticPortEditDialog.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;

class StaticPortEditDialog$5
  extends SelectionAdapter
{
  StaticPortEditDialog$5(StaticPortEditDialog paramStaticPortEditDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StaticPortEditDialog.access$4(this$0, true);
    StaticPortEditDialog.access$5(this$0).close();
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class StaticPortEditDialog$4
  implements ModifyListener
{
  StaticPortEditDialog$4(StaticPortEditDialog paramStaticPortEditDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    StaticPortEditDialog.access$3(this$0, val$debugPortText.getText().trim());
    StaticPortEditDialog.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.4
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class StaticPortConfigDialog$2
  extends SelectionAdapter
{
  StaticPortConfigDialog$2(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StaticPortEditDialog dlg = new StaticPortEditDialog(StaticPortConfigDialog.access$0(this$0), 
      StaticPortConfigDialog.access$1(this$0));
    if (dlg.open())
    {
      String device = dlg.getDeviceSN();
      String app = dlg.getAppName();
      int port = dlg.getPortNumber();
      
      StaticPortConfigDialog.access$2(this$0, device, app, port);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class StaticPortEditDialog$1
  implements Listener
{
  StaticPortEditDialog$1(StaticPortEditDialog paramStaticPortEditDialog) {}
  
  public void handleEvent(Event event) {}
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;

class StaticPortEditDialog$6
  extends SelectionAdapter
{
  StaticPortEditDialog$6(StaticPortEditDialog paramStaticPortEditDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StaticPortEditDialog.access$5(this$0).close();
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import com.android.ddmuilib.TableHelper;
import com.android.ide.eclipse.ddms.DdmsPlugin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

public class StaticPortConfigDialog
  extends Dialog
{
  private static final String PREFS_DEVICE_COL = "spcd.deviceColumn";
  private static final String PREFS_APP_COL = "spcd.AppColumn";
  private static final String PREFS_PORT_COL = "spcd.PortColumn";
  private static final int COL_DEVICE = 0;
  private static final int COL_APPLICATION = 1;
  private static final int COL_PORT = 2;
  private static final int DLG_WIDTH = 500;
  private static final int DLG_HEIGHT = 300;
  private Shell mShell;
  private Shell mParent;
  private Table mPortTable;
  private ArrayList<Integer> mPorts = new ArrayList();
  
  public StaticPortConfigDialog(Shell parent)
  {
    super(parent, 67680);
  }
  
  public void open()
  {
    createUI();
    if ((mParent == null) || (mShell == null)) {
      return;
    }
    updateFromStore();
    
    mShell.setMinimumSize(500, 300);
    Rectangle r = mParent.getBounds();
    
    int cx = x + width / 2;
    int x = cx - 250;
    int cy = y + height / 2;
    int y = cy - 150;
    mShell.setBounds(x, y, 500, 300);
    
    mShell.pack();
    
    mShell.open();
    
    Display display = mParent.getDisplay();
    while (!mShell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
  
  private void createUI()
  {
    mParent = getParent();
    mShell = new Shell(mParent, getStyle());
    mShell.setText("Static Port Configuration");
    
    mShell.setLayout(new GridLayout(1, true));
    
    mShell.addListener(21, new Listener()
    {
      public void handleEvent(Event event)
      {
        doit = true;
      }
    });
    Composite main = new Composite(mShell, 0);
    main.setLayoutData(new GridData(1808));
    main.setLayout(new GridLayout(2, false));
    
    mPortTable = new Table(main, 65540);
    mPortTable.setLayoutData(new GridData(1808));
    mPortTable.setHeaderVisible(true);
    mPortTable.setLinesVisible(true);
    
    TableHelper.createTableColumn(mPortTable, "Device Serial Number", 
      16384, "emulator-5554", 
      "spcd.deviceColumn", DdmsPlugin.getDefault().getPreferenceStore());
    
    TableHelper.createTableColumn(mPortTable, "Application Package", 
      16384, "com.android.samples.phone", 
      "spcd.AppColumn", DdmsPlugin.getDefault().getPreferenceStore());
    
    TableHelper.createTableColumn(mPortTable, "Debug Port", 
      131072, "Debug Port", 
      "spcd.PortColumn", DdmsPlugin.getDefault().getPreferenceStore());
    
    Composite buttons = new Composite(main, 0);
    buttons.setLayoutData(new GridData(1040));
    buttons.setLayout(new GridLayout(1, true));
    
    Button newButton = new Button(buttons, 0);
    newButton.setText("New...");
    newButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        StaticPortEditDialog dlg = new StaticPortEditDialog(mShell, 
          mPorts);
        if (dlg.open())
        {
          String device = dlg.getDeviceSN();
          String app = dlg.getAppName();
          int port = dlg.getPortNumber();
          
          StaticPortConfigDialog.this.addEntry(device, app, port);
        }
      }
    });
    final Button editButton = new Button(buttons, 0);
    editButton.setText("Edit...");
    editButton.setEnabled(false);
    editButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        int index = mPortTable.getSelectionIndex();
        String oldDeviceName = StaticPortConfigDialog.this.getDeviceName(index);
        String oldAppName = StaticPortConfigDialog.this.getAppName(index);
        String oldPortNumber = StaticPortConfigDialog.this.getPortNumber(index);
        StaticPortEditDialog dlg = new StaticPortEditDialog(mShell, 
          mPorts, oldDeviceName, oldAppName, oldPortNumber);
        if (dlg.open())
        {
          String deviceName = dlg.getDeviceSN();
          String app = dlg.getAppName();
          int port = dlg.getPortNumber();
          
          StaticPortConfigDialog.this.replaceEntry(index, deviceName, app, port);
        }
      }
    });
    final Button deleteButton = new Button(buttons, 0);
    deleteButton.setText("Delete");
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        int index = mPortTable.getSelectionIndex();
        StaticPortConfigDialog.this.removeEntry(index);
      }
    });
    Composite bottomComp = new Composite(mShell, 0);
    bottomComp.setLayoutData(new GridData(
      64));
    bottomComp.setLayout(new GridLayout(2, true));
    
    Button okButton = new Button(bottomComp, 0);
    okButton.setText("OK");
    okButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        StaticPortConfigDialog.this.updateStore();
        mShell.close();
      }
    });
    Button cancelButton = new Button(bottomComp, 0);
    cancelButton.setText("Cancel");
    cancelButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        mShell.close();
      }
    });
    mPortTable.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        int index = mPortTable.getSelectionIndex();
        
        boolean enabled = index != -1;
        editButton.setEnabled(enabled);
        deleteButton.setEnabled(enabled);
      }
    });
    mShell.pack();
  }
  
  private void addEntry(String deviceName, String appName, int portNumber)
  {
    TableItem item = new TableItem(mPortTable, 0);
    
    item.setText(0, deviceName);
    item.setText(1, appName);
    item.setText(2, Integer.toString(portNumber));
    
    mPorts.add(Integer.valueOf(portNumber));
  }
  
  private void removeEntry(int index)
  {
    mPortTable.remove(index);
    
    mPorts.remove(index);
  }
  
  private void replaceEntry(int index, String deviceName, String appName, int portNumber)
  {
    TableItem item = mPortTable.getItem(index);
    
    item.setText(0, deviceName);
    item.setText(1, appName);
    item.setText(2, Integer.toString(portNumber));
    
    mPorts.set(index, Integer.valueOf(portNumber));
  }
  
  private String getDeviceName(int index)
  {
    TableItem item = mPortTable.getItem(index);
    return item.getText(0);
  }
  
  private String getAppName(int index)
  {
    TableItem item = mPortTable.getItem(index);
    return item.getText(1);
  }
  
  private String getPortNumber(int index)
  {
    TableItem item = mPortTable.getItem(index);
    return item.getText(2);
  }
  
  private void updateFromStore()
  {
    DebugPortProvider provider = DebugPortProvider.getInstance();
    Map<String, Map<String, Integer>> map = provider.getPortList();
    
    Set<String> deviceKeys = map.keySet();
    for (String deviceKey : deviceKeys)
    {
      Map<String, Integer> deviceMap = (Map)map.get(deviceKey);
      if (deviceMap != null)
      {
        Set<String> appKeys = deviceMap.keySet();
        for (String appKey : appKeys)
        {
          Integer port = (Integer)deviceMap.get(appKey);
          if (port != null) {
            addEntry(deviceKey, appKey, port.intValue());
          }
        }
      }
    }
  }
  
  private void updateStore()
  {
    HashMap<String, Map<String, Integer>> map = new HashMap();
    
    int count = mPortTable.getItemCount();
    for (int i = 0; i < count; i++)
    {
      TableItem item = mPortTable.getItem(i);
      String deviceName = item.getText(0);
      
      Map<String, Integer> deviceMap = (Map)map.get(deviceName);
      if (deviceMap == null)
      {
        deviceMap = new HashMap();
        map.put(deviceName, deviceMap);
      }
      deviceMap.put(item.getText(1), Integer.valueOf(item.getText(2)));
    }
    DebugPortProvider provider = DebugPortProvider.getInstance();
    provider.setPortList(map);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Table;

class StaticPortConfigDialog$3
  extends SelectionAdapter
{
  StaticPortConfigDialog$3(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    int index = StaticPortConfigDialog.access$3(this$0).getSelectionIndex();
    String oldDeviceName = StaticPortConfigDialog.access$4(this$0, index);
    String oldAppName = StaticPortConfigDialog.access$5(this$0, index);
    String oldPortNumber = StaticPortConfigDialog.access$6(this$0, index);
    StaticPortEditDialog dlg = new StaticPortEditDialog(StaticPortConfigDialog.access$0(this$0), 
      StaticPortConfigDialog.access$1(this$0), oldDeviceName, oldAppName, oldPortNumber);
    if (dlg.open())
    {
      String deviceName = dlg.getDeviceSN();
      String app = dlg.getAppName();
      int port = dlg.getPortNumber();
      
      StaticPortConfigDialog.access$7(this$0, index, deviceName, app, port);
    }
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class StaticPortConfigDialog$1
  implements Listener
{
  StaticPortConfigDialog$1(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void handleEvent(Event event)
  {
    doit = true;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Table;

class StaticPortConfigDialog$7
  extends SelectionAdapter
{
  StaticPortConfigDialog$7(StaticPortConfigDialog paramStaticPortConfigDialog, Button paramButton1, Button paramButton2) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    int index = StaticPortConfigDialog.access$3(this$0).getSelectionIndex();
    
    boolean enabled = index != -1;
    val$editButton.setEnabled(enabled);
    val$deleteButton.setEnabled(enabled);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;

class StaticPortConfigDialog$6
  extends SelectionAdapter
{
  StaticPortConfigDialog$6(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StaticPortConfigDialog.access$0(this$0).close();
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.6
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
import com.android.ddmlib.IDevice;
import com.android.ide.eclipse.ddms.DdmsPlugin;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.preference.IPreferenceStore;

public class DebugPortProvider
  implements DebugPortManager.IDebugPortProvider
{
  private static DebugPortProvider sThis = new DebugPortProvider();
  public static final String PREFS_STATIC_PORT_LIST = "android.staticPortList";
  private Map<String, Map<String, Integer>> mMap;
  
  public static DebugPortProvider getInstance()
  {
    return sThis;
  }
  
  private DebugPortProvider()
  {
    computePortList();
  }
  
  public int getPort(IDevice device, String appName)
  {
    if (mMap != null)
    {
      Map<String, Integer> deviceMap = (Map)mMap.get(device.getSerialNumber());
      if (deviceMap != null)
      {
        Integer i = (Integer)deviceMap.get(appName);
        if (i != null) {
          return i.intValue();
        }
      }
    }
    return -1;
  }
  
  public Map<String, Map<String, Integer>> getPortList()
  {
    return mMap;
  }
  
  private void computePortList()
  {
    mMap = new HashMap();
    
    IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore();
    String value = store.getString("android.staticPortList");
    if ((value != null) && (value.length() > 0))
    {
      String[] portSegments = value.split("\\|");
      String[] arrayOfString1;
      int j = (arrayOfString1 = portSegments).length;
      for (int i = 0; i < j; i++)
      {
        String seg = arrayOfString1[i];
        String[] entry = seg.split(":");
        
        String deviceName = null;
        if (entry.length == 3) {
          deviceName = entry[2];
        } else {
          deviceName = "emulator-5554";
        }
        Map<String, Integer> deviceMap = (Map)mMap.get(deviceName);
        if (deviceMap == null)
        {
          deviceMap = new HashMap();
          mMap.put(deviceName, deviceMap);
        }
        deviceMap.put(entry[0], Integer.valueOf(entry[1]));
      }
    }
  }
  
  public void setPortList(Map<String, Map<String, Integer>> map)
  {
    mMap.clear();
    mMap.putAll(map);
    
    StringBuilder sb = new StringBuilder();
    
    Set<String> deviceKeys = map.keySet();
    for (String deviceKey : deviceKeys)
    {
      Map<String, Integer> deviceMap = (Map)map.get(deviceKey);
      if (deviceMap != null)
      {
        Set<String> appKeys = deviceMap.keySet();
        for (String appKey : appKeys)
        {
          Integer port = (Integer)deviceMap.get(appKey);
          if (port != null) {
            sb.append(appKey).append(':').append(port.intValue()).append(':').append(deviceKey).append('|');
          }
        }
      }
    }
    String value = sb.toString();
    
    IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore();
    
    store.setValue("android.staticPortList", value);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.DebugPortProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class StaticPortEditDialog$3
  implements ModifyListener
{
  StaticPortEditDialog$3(StaticPortEditDialog paramStaticPortEditDialog, Text paramText) {}
  
  public void modifyText(ModifyEvent e)
  {
    StaticPortEditDialog.access$2(this$0, val$appNameText.getText().trim());
    StaticPortEditDialog.access$1(this$0);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import java.util.ArrayList;
import java.util.Iterator;
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.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.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class StaticPortEditDialog
  extends Dialog
{
  private static final int DLG_WIDTH = 400;
  private static final int DLG_HEIGHT = 200;
  private Shell mParent;
  private Shell mShell;
  private boolean mOk = false;
  private String mAppName;
  private String mPortNumber;
  private Button mOkButton;
  private Label mWarning;
  private ArrayList<Integer> mPorts;
  private int mEditPort = -1;
  private String mDeviceSn;
  
  public StaticPortEditDialog(Shell parent, ArrayList<Integer> ports)
  {
    super(parent, 67680);
    mPorts = ports;
    mDeviceSn = "emulator-5554";
  }
  
  public StaticPortEditDialog(Shell shell, ArrayList<Integer> ports, String oldDeviceSN, String oldAppName, String oldPortNumber)
  {
    this(shell, ports);
    
    mDeviceSn = oldDeviceSN;
    mAppName = oldAppName;
    mPortNumber = oldPortNumber;
    mEditPort = Integer.valueOf(mPortNumber).intValue();
  }
  
  public boolean open()
  {
    createUI();
    if ((mParent == null) || (mShell == null)) {
      return false;
    }
    mShell.setMinimumSize(400, 200);
    Rectangle r = mParent.getBounds();
    
    int cx = x + width / 2;
    int x = cx - 200;
    int cy = y + height / 2;
    int y = cy - 100;
    mShell.setBounds(x, y, 400, 200);
    
    mShell.open();
    
    Display display = mParent.getDisplay();
    while (!mShell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return mOk;
  }
  
  public String getDeviceSN()
  {
    return mDeviceSn;
  }
  
  public String getAppName()
  {
    return mAppName;
  }
  
  public int getPortNumber()
  {
    return Integer.valueOf(mPortNumber).intValue();
  }
  
  private void createUI()
  {
    mParent = getParent();
    mShell = new Shell(mParent, getStyle());
    mShell.setText("Static Port");
    
    mShell.setLayout(new GridLayout(1, false));
    
    mShell.addListener(21, new Listener()
    {
      public void handleEvent(Event event) {}
    });
    Composite main = new Composite(mShell, 0);
    main.setLayoutData(new GridData(1808));
    main.setLayout(new GridLayout(2, false));
    
    Label l0 = new Label(main, 0);
    l0.setText("Device Name:");
    
    final Text deviceSNText = new Text(main, 2052);
    deviceSNText.setLayoutData(new GridData(768));
    if (mDeviceSn != null) {
      deviceSNText.setText(mDeviceSn);
    }
    deviceSNText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        mDeviceSn = deviceSNText.getText().trim();
        StaticPortEditDialog.this.validate();
      }
    });
    Label l = new Label(main, 0);
    l.setText("Application Name:");
    
    final Text appNameText = new Text(main, 2052);
    if (mAppName != null) {
      appNameText.setText(mAppName);
    }
    appNameText.setLayoutData(new GridData(768));
    appNameText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        mAppName = appNameText.getText().trim();
        StaticPortEditDialog.this.validate();
      }
    });
    Label l2 = new Label(main, 0);
    l2.setText("Debug Port:");
    
    final Text debugPortText = new Text(main, 2052);
    if (mPortNumber != null) {
      debugPortText.setText(mPortNumber);
    }
    debugPortText.setLayoutData(new GridData(768));
    debugPortText.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        mPortNumber = debugPortText.getText().trim();
        StaticPortEditDialog.this.validate();
      }
    });
    Composite warningComp = new Composite(mShell, 0);
    warningComp.setLayoutData(new GridData(768));
    warningComp.setLayout(new GridLayout(1, true));
    
    mWarning = new Label(warningComp, 0);
    mWarning.setText("");
    mWarning.setLayoutData(new GridData(768));
    
    Composite bottomComp = new Composite(mShell, 0);
    bottomComp
      .setLayoutData(new GridData(64));
    bottomComp.setLayout(new GridLayout(2, true));
    
    mOkButton = new Button(bottomComp, 0);
    mOkButton.setText("OK");
    mOkButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        mOk = true;
        mShell.close();
      }
    });
    mOkButton.setEnabled(false);
    mShell.setDefaultButton(mOkButton);
    
    Button cancelButton = new Button(bottomComp, 0);
    cancelButton.setText("Cancel");
    cancelButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        mShell.close();
      }
    });
    validate();
  }
  
  private void validate()
  {
    mWarning.setText("");
    if ((mDeviceSn == null) || (mDeviceSn.length() == 0))
    {
      mWarning.setText("Device name missing.");
      mOkButton.setEnabled(false);
      return;
    }
    if ((mAppName == null) || (mAppName.length() == 0))
    {
      mWarning.setText("Application name missing.");
      mOkButton.setEnabled(false);
      return;
    }
    String packageError = "Application name must be a valid Java package name.";
    
    String[] packageSegments = mAppName.split("\\.");
    Object localObject;
    int j = (localObject = packageSegments).length;
    for (int i = 0; i < j; i++)
    {
      String p = localObject[i];
      if (!p.matches("^[a-zA-Z][a-zA-Z0-9]*"))
      {
        mWarning.setText(packageError);
        mOkButton.setEnabled(false);
        return;
      }
      if (!p.matches("^[a-z][a-z0-9]*")) {
        mWarning.setText("Lower case is recommended for Java packages.");
      }
    }
    if (mAppName.charAt(mAppName.length() - 1) == '.')
    {
      mWarning.setText(packageError);
      mOkButton.setEnabled(false);
      return;
    }
    if ((mPortNumber == null) || (mPortNumber.length() == 0))
    {
      mWarning.setText("Port Number missing.");
      mOkButton.setEnabled(false);
      return;
    }
    if (!mPortNumber.matches("[0-9]*"))
    {
      mWarning.setText("Port Number invalid.");
      mOkButton.setEnabled(false);
      return;
    }
    long port = Long.valueOf(mPortNumber).longValue();
    if (port >= 32767L)
    {
      mOkButton.setEnabled(false);
      return;
    }
    if (port != mEditPort) {
      for (localObject = mPorts.iterator(); ((Iterator)localObject).hasNext();)
      {
        Integer i = (Integer)((Iterator)localObject).next();
        if (port == i.intValue())
        {
          mWarning.setText("Port already in use.");
          mOkButton.setEnabled(false);
          return;
        }
      }
    }
    mOkButton.setEnabled(true);
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortEditDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor.ddms;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Shell;

class StaticPortConfigDialog$5
  extends SelectionAdapter
{
  StaticPortConfigDialog$5(StaticPortConfigDialog paramStaticPortConfigDialog) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    StaticPortConfigDialog.access$9(this$0);
    StaticPortConfigDialog.access$0(this$0).close();
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.ddms.StaticPortConfigDialog.5
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor;

import java.io.File;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
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.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class SdkLocationChooserDialog
  extends Dialog
{
  private static final String TITLE = "Android Device Monitor";
  private static final String DEFAULT_MESSAGE = "Provide the path to the Android SDK";
  private Label mStatusLabel;
  private Text mTextBox;
  private String mPath;
  
  public SdkLocationChooserDialog(Shell parentShell)
  {
    super(parentShell);
  }
  
  protected Control createDialogArea(Composite parent)
  {
    getShell().setText("Android Device Monitor");
    
    Composite c = new Composite((Composite)super.createDialogArea(parent), 0);
    c.setLayout(new GridLayout(2, false));
    c.setLayoutData(new GridData(1808));
    
    Label l = new Label(c, 0);
    l.setText("Provide the path to the Android SDK");
    GridDataFactory.fillDefaults().span(2, 1).applyTo(l);
    
    mTextBox = new Text(c, 2048);
    mTextBox.setLayoutData(new GridData(768));
    GridDataFactory.fillDefaults()
      .hint(SwtUtils.getFontWidth(mTextBox) * 80, -1)
      .applyTo(mTextBox);
    mTextBox.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        SdkLocationChooserDialog.this.validateInstall();
      }
    });
    Button browse = new Button(c, 8);
    browse.setText("Browse");
    browse.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        DirectoryDialog dlg = new DirectoryDialog(getShell(), 4096);
        dlg.setText("Android SDK location");
        String dir = dlg.open();
        if (dir != null)
        {
          mTextBox.setText(dir);
          SdkLocationChooserDialog.this.validateInstall();
        }
      }
    });
    mStatusLabel = new Label(c, 64);
    mStatusLabel.setText("");
    mStatusLabel.setForeground(getShell().getDisplay().getSystemColor(3));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(mStatusLabel);
    
    return super.createDialogArea(parent);
  }
  
  private void validateInstall()
  {
    SdkToolsLocator locator = new SdkToolsLocator(new File(mTextBox.getText()));
    SdkToolsLocator.SdkInstallStatus status = locator.isValidInstallation();
    if (status.isValid())
    {
      mStatusLabel.setText("");
      getButton(0).setEnabled(true);
    }
    else
    {
      mStatusLabel.setText(status.getErrorMessage());
      mStatusLabel.pack();
      getButton(0).setEnabled(false);
    }
  }
  
  public boolean close()
  {
    mPath = mTextBox.getText();
    return super.close();
  }
  
  public String getPath()
  {
    return mPath;
  }
}

/* Location:
 * Qualified Name:     com.android.ide.eclipse.monitor.SdkLocationChooserDialog
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.android.ide.eclipse.monitor;

import com.android.prefs.AndroidLocation;
import com.android.sdklib.SdkManager;
import com.android.sdkstats.DdmsPreferenceStore;
import com.android.sdkstats.SdkStatsService;
import com.android.sdkuilib.internal.repository.ui.AdtUpdateDialog;
import com.android.utils.ILogger;
import com.android.utils.NullLogger;
import java.io.File;
import java.net.URI;
import java.net.URL;
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd