Commits

Christian Fischer committed 448fda7

LogCat: multiple devices support: added lookup listener

  • Participants
  • Parent commits 45bc3bb

Comments (0)

Files changed (1)

File logcat_multiple_devices.patch

 # HG changeset patch
 # Date 1309392817 -7200
-# Parent df9ed72bb18c1d1d3e282d8a181f48065135f50b
+# Parent 10794bc93b5baec24a9163429fed2daa2370e6b4
 LogCat: Added support for multiple devices
 
-diff -r df9ed72bb18c logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java
+diff -r 10794bc93b5b logcat/nbproject/project.xml
+--- a/logcat/nbproject/project.xml	Sun Jul 03 00:19:14 2011 +0200
++++ b/logcat/nbproject/project.xml	Sun Jul 03 01:01:20 2011 +0200
+@@ -98,6 +98,14 @@
+                     </run-dependency>
+                 </dependency>
+                 <dependency>
++                    <code-name-base>org.openide.util.lookup</code-name-base>
++                    <build-prerequisite/>
++                    <compile-dependency/>
++                    <run-dependency>
++                        <specification-version>8.3.1</specification-version>
++                    </run-dependency>
++                </dependency>
++                <dependency>
+                     <code-name-base>org.openide.windows</code-name-base>
+                     <build-prerequisite/>
+                     <compile-dependency/>
+diff -r 10794bc93b5b logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java	Sun Jul 03 00:15:57 2011 +0200
-@@ -0,0 +1,325 @@
++++ b/logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java	Sun Jul 03 01:01:20 2011 +0200
+@@ -0,0 +1,354 @@
 +/*
 + * Licensed under the Apache License, Version 2.0 (the "License");
 + * you may not use this file except in compliance with the License.
 +import java.beans.PropertyChangeEvent;
 +import java.beans.PropertyChangeListener;
 +import java.util.ArrayList;
++import java.util.Collection;
 +import java.util.HashMap;
 +import java.util.HashSet;
 +import java.util.List;
 +import javax.swing.event.ListDataEvent;
 +import javax.swing.event.ListDataListener;
 +import org.netbeans.modules.android.core.ddm.AndroidDebugBridgeFactory;
++import org.openide.util.Lookup;
++import org.openide.util.LookupEvent;
++import org.openide.util.LookupListener;
++import org.openide.util.Utilities;
 +import org.openide.util.WeakListeners;
 +
 +
 +public class LogDevicesComboBoxSupport
 +    implements  ComboBoxModel,
 +                ListCellRenderer,
++                LookupListener,
 +                PropertyChangeListener,
 +                AndroidDebugBridge.IDeviceChangeListener
 +{
 +    private Set<ListDataListener>   dataListeners   = new HashSet<ListDataListener>();
 +    private List<String>            devices         = new ArrayList<String>();
 +    private Map<String,String>      deviceLabels    = new HashMap<String,String>();
++    private Lookup.Result<IDevice>  deviceLookup;
 +    private LogReader               reader;
 +    private JComboBox               cmb;
 +
 +        // get notifications for attached and detached devices
 +        AndroidDebugBridge.addDeviceChangeListener(this);
 +        
++        Lookup lookup = Utilities.actionsGlobalContext();
++        deviceLookup = lookup.lookupResult(IDevice.class);
++        deviceLookup.addLookupListener(this);
++        
 +        update();
 +    }
 +    
 +        
 +        reader.removePropertyChangeListener(this);
 +        
++        deviceLookup.removeLookupListener(this);
++        
 +        return;
 +    }
 +
 +        return;
 +    }
 +
++    @Override
++    public void resultChanged(LookupEvent ev) {
++        // set the first item in the result as "active" device
++        for(IDevice device : deviceLookup.allInstances()) {
++            if (cmb != null) {
++                cmb.setSelectedItem(device.getSerialNumber());
++            }
++            else {
++                setSelectedItem(device.getSerialNumber());
++            }
++
++            break;
++        }
++        
++        return;
++    }
 +
 +    @Override
 +    public void deviceConnected(IDevice id) {
 +        // do nothing
 +    }
 +}
-diff -r df9ed72bb18c logcat/src/org/nyerel/nbandroid/logcat/LogReader.java
---- a/logcat/src/org/nyerel/nbandroid/logcat/LogReader.java	Fri Jul 01 03:56:43 2011 +0200
-+++ b/logcat/src/org/nyerel/nbandroid/logcat/LogReader.java	Sun Jul 03 00:15:57 2011 +0200
+diff -r 10794bc93b5b logcat/src/org/nyerel/nbandroid/logcat/LogReader.java
+--- a/logcat/src/org/nyerel/nbandroid/logcat/LogReader.java	Sun Jul 03 00:19:14 2011 +0200
++++ b/logcat/src/org/nyerel/nbandroid/logcat/LogReader.java	Sun Jul 03 01:01:20 2011 +0200
 @@ -22,6 +22,8 @@
  import com.android.ddmlib.MultiLineReceiver;
  import com.android.ddmlib.ShellCommandUnresponsiveException;
 -        loggedEvents.clear();
 -    }
  }
-diff -r df9ed72bb18c logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form
---- a/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form	Fri Jul 01 03:56:43 2011 +0200
-+++ b/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form	Sun Jul 03 00:15:57 2011 +0200
+diff -r 10794bc93b5b logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form
+--- a/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form	Sun Jul 03 00:19:14 2011 +0200
++++ b/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.form	Sun Jul 03 01:01:20 2011 +0200
 @@ -171,12 +171,7 @@
  
        <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
            <Constraints>
              <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
                <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
-diff -r df9ed72bb18c logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java
---- a/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java	Fri Jul 01 03:56:43 2011 +0200
-+++ b/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java	Sun Jul 03 00:15:57 2011 +0200
+diff -r 10794bc93b5b logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java
+--- a/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java	Sun Jul 03 00:19:14 2011 +0200
++++ b/logcat/src/org/nyerel/nbandroid/logcat/LogTopComponent.java	Sun Jul 03 01:01:20 2011 +0200
 @@ -84,7 +84,9 @@
      
      private List<LogTableManager> tabManagers;