Commits

Christian Fischer committed 0e93b0b

LogCat: multiple devices support: device status icon update

  • Participants
  • Parent commits e1819f8

Comments (0)

Files changed (1)

File logcat_multiple_devices.patch

 # HG changeset patch
 # Date 1309392817 -7200
-# Parent c54ea20aa966af9635809dac3c1b118e96d55f07
+# Parent 43df6f2d3cbf89e690cf561bbac2e9370411bd44
 LogCat: Added support for multiple devices
 
 diff --git a/logcat/nbproject/project.xml b/logcat/nbproject/project.xml
 diff --git a/logcat/src/org/nyerel/nbandroid/logcat/Bundle.properties b/logcat/src/org/nyerel/nbandroid/logcat/Bundle.properties
 --- a/logcat/src/org/nyerel/nbandroid/logcat/Bundle.properties
 +++ b/logcat/src/org/nyerel/nbandroid/logcat/Bundle.properties
-@@ -40,3 +40,4 @@
+@@ -40,3 +40,8 @@
  LogTopComponent.btLogLevelWarn.actionCommand=WARN
  LogTopComponent.btLogLevelError.actionCommand=ERROR
  LogTopComponent.btLogLevelAssert.actionCommand=ASSERT
 +LogTopComponent.lDeviceStatusIcon.text_1=
++DeviceStatus.ATTACHED_AND_LOGGING=Receiving logfiles from device.
++DeviceStatus.ATTACHED=Device is attached.
++DeviceStatus.DETACHED=Device is detached.
++DeviceStatus.UNKNOWN=No devices are connected.
+\ No newline at end of file
 diff --git a/logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java b/logcat/src/org/nyerel/nbandroid/logcat/LogDevicesComboBoxSupport.java
 new file mode 100644
 --- /dev/null
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
-@@ -42,9 +46,19 @@
+@@ -42,9 +46,20 @@
   */
  public class LogReader {
      
      private static final Set<String> ignoredLines;
  
 +    public static enum CurrentDeviceState {
-+        ONLINE,
-+        OFFLINE,
-+        DISCONNECTED,
++        ATTACHED_AND_LOGGING,
++        ATTACHED,
++        DETACHED,
++        UNKNOWN,
 +    }
 +    
      static {
  
         // These messages will not be added to log as events
-@@ -54,7 +68,9 @@
+@@ -54,7 +69,9 @@
      }
  
      private Set<LogListener> listeners;
      private LogCatOutputReceiver receiver;
      private LogEventInfo lastLogEventInfo;
      private static Pattern sLogPattern = Pattern.compile(
-@@ -66,17 +82,17 @@
+@@ -66,17 +83,17 @@
      private Timer checkReadingStatusTimer;
      private int checkingPeriod = 10000;
      
          
          adb = AndroidDebugBridgeFactory.getDefault();
          checkReadingStatusTimer = new Timer();
-@@ -94,17 +110,80 @@
+@@ -84,27 +101,95 @@
+ 
+             @Override
+             public void run() {
+-                if (!shouldBeReading) {
+-                    return;
++                try {
++                    if (!shouldBeReading) {
++                        return;
++                    }
++                    if (!deviceReallyConnected()) {
++                        infoMessage("Trying to reconnect to the device in " + checkingPeriod / 1000 + " seconds.");
++                        startReading();
++                    }
+                 }
+-                if (!deviceReallyConnected()) {
+-                    infoMessage("Trying to reconnect to the device in " + checkingPeriod / 1000 + " seconds.");
+-                    startReading();
++                catch(Exception e) {
++                    LOG.log(Level.SEVERE, "Unexpected exception on reconnecting the device.", e);
+                 }
              }
          }, checkingPeriod, checkingPeriod);
      }
 +    public CurrentDeviceState getCurrentDeviceState() {
 +        // device is currently unavailable
 +        if (currentDevice == null) {
-+            return CurrentDeviceState.DISCONNECTED;
++            return CurrentDeviceState.UNKNOWN;
 +        }
 +        
 +        // device is offline
 +        if (!deviceReallyConnected()) {
-+            return CurrentDeviceState.OFFLINE;
++            return CurrentDeviceState.DETACHED;
 +        }
 +        
 +        // is currently receiving events?
-+        if (receiver == null) {
-+            return CurrentDeviceState.OFFLINE;
++        if (receiver == null || !reading) {
++            return CurrentDeviceState.ATTACHED;
 +        }
 +        
 +        // device is ready!
-+        return CurrentDeviceState.ONLINE;
++        return CurrentDeviceState.ATTACHED_AND_LOGGING;
 +    }
  
      private boolean deviceReallyConnected() {
                  gotIt = true;
              }
          }
-@@ -114,6 +193,19 @@
+@@ -114,6 +199,19 @@
          }
          return true;
      }
  
      public void addLogListener(LogListener listener) {
          listeners.add(listener);
-@@ -151,17 +243,19 @@
+@@ -151,17 +249,19 @@
  
      private final class LogCatOutputReceiver extends MultiLineReceiver {
  
              }
          }
  
-@@ -190,30 +284,51 @@
+@@ -190,30 +290,51 @@
      }
  
      private void reallyStartReading() {
                      } catch (TimeoutException e) {
                        LOG.log(Level.FINE, null, e);
                        reading = false;
-@@ -228,16 +343,25 @@
+@@ -228,16 +349,25 @@
                        reading = false;
                      } finally {
                          receiver = null;
          shouldBeReading = false;
      }
  
-@@ -248,7 +372,7 @@
+@@ -248,7 +378,7 @@
          return false;
      }
  
          for (String line : lines) {
              // ignore empty lines.
              if (line.length() > 0) {
-@@ -286,6 +410,16 @@
+@@ -286,6 +416,16 @@
                      }
                      
                      LogEvent event = new LogEvent(lastLogEventInfo, message);
                      if(!loggedEvents.contains(event)) {
                          loggedEvents.add(event);
                          sendNewLogEvent(event);
-@@ -306,10 +440,10 @@
+@@ -306,10 +446,10 @@
       *               or {@code null}, if the process couldn't be retrieved yet.
       */
      private String[] getProcessName(IDevice device, int pid) {
          }
  
          String[] nameref = cache.get(pid);
-@@ -330,13 +464,4 @@
+@@ -330,13 +470,4 @@
  
          return nameref;
      }
 -            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
 -              <StringArray count="0"/>
 +            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-+              <Image iconType="3" name="/org/nyerel/nbandroid/logcat/resources/device_status_disconnected.png"/>
++              <Image iconType="3" name="/org/nyerel/nbandroid/logcat/resources/device_status_unknown.png"/>
 +            </Property>
 +            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
 +              <ComponentRef name="cmbLogDevices"/>
  
  /**
   * Top component which displays something.
-@@ -84,7 +88,53 @@
+@@ -84,7 +88,59 @@
      
      private List<LogTableManager> tabManagers;
      private LogLineRowFilter rowFilter = new LogLineRowFilter();
 +            }
 +            
 +            if (LogReader.PROPERTY_CURRENT_DEVICE_STATE.equals(evt.getPropertyName())) {
++                String tooltip = NbBundle.getMessage(this.getClass(), "DeviceStatus." + evt.getNewValue());
 +                String res;
 +                
 +                switch((LogReader.CurrentDeviceState)evt.getNewValue()) {
-+                case ONLINE:
-+                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_online.png";
++                case ATTACHED_AND_LOGGING:
++                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_logging.png";
 +                    break;
 +
-+                case OFFLINE:
-+                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_offline.png";
++                case DETACHED:
++                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_detached.png";
++                    break;
++
++                case ATTACHED:
++                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_attached.png";
 +                    break;
 +
 +                default:
-+                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_disconnected.png";
++                    res = "/org/nyerel/nbandroid/logcat/resources/device_status_unknown.png";
 +                    break;
 +                }
 +                
 +                lDeviceStatusIcon.setIcon(new ImageIcon(getClass().getResource(res)));
++                lDeviceStatusIcon.setToolTipText(tooltip);
 +            }
 +
 +            return;
      public LogTopComponent() {
          initComponents();
          setName(NbBundle.getMessage(LogTopComponent.class, "CTL_LogTopComponent"));
-@@ -151,6 +201,11 @@
+@@ -151,6 +207,11 @@
        if (reader != null) {
          stopReading();
        }
        super.componentClosed();
      }
  
-@@ -270,6 +325,11 @@
+@@ -270,6 +331,11 @@
                  for (LogTableManager manager : tabManagers) {
                      reader.addLogListener(manager);
                  }
              }
              
              timer.schedule(new TimerTask() {
-@@ -316,7 +376,8 @@
+@@ -316,7 +382,8 @@
          autoScrollToggleButton = new javax.swing.JToggleButton();
          clearButton = new javax.swing.JButton();
          panFilterTools = new javax.swing.JPanel();
          txtFilterText = new javax.swing.JTextField();
          tbLogLevelSelect = new javax.swing.JToolBar();
          btLogLevelVerbose = new javax.swing.JToggleButton();
-@@ -413,7 +474,11 @@
+@@ -413,7 +480,11 @@
  
          panFilterTools.setLayout(new java.awt.GridBagLayout());
  
 -        panFilterTools.add(cmbSelectDevice, new java.awt.GridBagConstraints());
-+        lDeviceStatusIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nyerel/nbandroid/logcat/resources/device_status_disconnected.png"))); // NOI18N
++        lDeviceStatusIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/nyerel/nbandroid/logcat/resources/device_status_unknown.png"))); // NOI18N
 +        lDeviceStatusIcon.setLabelFor(cmbLogDevices);
 +        org.openide.awt.Mnemonics.setLocalizedText(lDeviceStatusIcon, org.openide.util.NbBundle.getMessage(LogTopComponent.class, "LogTopComponent.lDeviceStatusIcon.text_1")); // NOI18N
 +        panFilterTools.add(lDeviceStatusIcon, new java.awt.GridBagConstraints());
  
          txtFilterText.setText(org.openide.util.NbBundle.getMessage(LogTopComponent.class, "LogTopComponent.txtFilterText.text")); // NOI18N
          txtFilterText.addKeyListener(new java.awt.event.KeyAdapter() {
-@@ -624,9 +689,10 @@
+@@ -624,9 +695,10 @@
      private javax.swing.JToggleButton btLogLevelVerbose;
      private javax.swing.JToggleButton btLogLevelWarn;
      private javax.swing.JButton clearButton;
      private javax.swing.JPanel panCenter;
      private javax.swing.JPanel panFilterTools;
      private javax.swing.JButton removeTabButton;
-@@ -692,6 +758,9 @@
+@@ -692,6 +764,9 @@
                public void rowsInserted(int firstRow, int endRow) {
                  try {
                    super.rowsInserted(firstRow, endRow);
  
      @Override
      public void newLogEvent(LogEvent logEvent) {
-diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_disconnected.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_disconnected.png
+diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_attached.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_attached.png
 new file mode 100644
-index 0000000000000000000000000000000000000000..b41933d0290a3cfd795d04b3e3a1c9874e2b6e0f
+index 0000000000000000000000000000000000000000..1a60bf6c2cfe63515f310232238e4fed493348b9
 GIT binary patch
-literal 506
-zc$@+H0R{evP)<h;3K|L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5Htg_wWZRK
+z0K8a?F;O(3Tzbg{%L~3^Qy_{anAtp{a`23#*jFLw0vex53*rP6n9UVqm*Aad=#m&D
+zRSS8n+9eok!TYRpFY`P`fYl0&b<lr>!=rFfcS7zl85@QlK`%5L$jX9uArtRm?SFK)
+z4twkKF8Hm5Mw2j!&OxsS$H%`<!?qL^cz?_JOzk!*ao0~yemb6JV9*bO0<9L3*E8-P
+j!pvkyNPVW8>+G9v#Wb_u)ya;X00000NkvXXu0mjfgSXDw
 
-diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_offline.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_offline.png
+diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_detached.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_detached.png
 new file mode 100644
-index 0000000000000000000000000000000000000000..f76f54a1fee900a1f8000172be7dbff1729dc83c
+index 0000000000000000000000000000000000000000..77f513583e1b7fafe1ba4c17a66727dd292c938d
 GIT binary patch
-literal 402
-zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^LpY
-zSqz7-*mwXb&H|6fVg?3oVGw3ym^DWND9B#o>FdgVo1IxqTd4C^S|HFAAx{^_5R21u
-zC;NIaI|{V!pJeGCrj(*D<-&0<#esi<Yv02|+GjLlQWPC0xZLp+o8(ZZmpDUCQ@re`
-z*KJ`H{<e2j#_L~)UY|1I0q+!M3-*s6^=4Q+JetP5O5tPao&9B2)`|LAtPdnZ8tzq`
-zsW*7}opHxD5&s3@p;Q0gn)5@nLeo3Xp-V7>x#g)*eS`4NNm2<cTKx;Ar{0{mlXsQR
-z>MkXQ=;^V0JVblvta`VWfl)&$VRuv^57QruA2I8{&(i<%?aH4Ok8}STv75@gKfw3l
-z`clt3$4tWxSzl<iPo1E7bVvUV`<={&;s<R@4_%dfC$_{u+xWqohTQtf&vy)LcX0V#
-ro^Qw{-Y5Md@zW0fW0tx14KCI&|G8Wys$JT?02G>@u6{1-oD!M<<2#vr
+literal 439
+zc$@*Z0Z9IdP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00001b5ch_0Itp)
+z=>Px#24YJ`L;wH)ssI2jtYgUl000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipe)
+z6*MW*reJOW00B2iL_t(I%Z-!IPQpMC#(zU<ATjak!HYfsC!T;_2^{q$IGOMiB%XK@
+z2v_?a5~3V1=%GmsqHV$P&~06|mGny{GdtaH{%!>aI-4mcApO1^opU3dObTM7+XYn+
+z^V!%xK~NCShC?X=e2qpbfY<9~_p35n{=<9@Kx;e}4<KEyX$}S)HXG_dIvwKaG_&7*
+zUjfcd_PheA&^A6z6|!o#^}_edY3vzPL6wgnz}tl(&E@j1Pn)D!*CK+d78(%**o7h9
+zHi~F17Nzp*U>ilqBj}}^rl_-t{PvqFUJRtFN2?Qu_}@BX$O0rzHmTW840s9f3|!Ty
+z!1liy-M9sbfjy8KNsOeH>@D9O_y+DEdx;6~1YFk~<O|Snf2Ij&KA@WlBEZTz4-L08
+hqX(yTae~}CoL_m&fIqER!x;bo002ovPDHLkV1i+Hs(Jtb
 
-diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_online.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_online.png
+diff --git a/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_logging.png b/logcat/src/org/nyerel/nbandroid/logcat/resources/device_status_logging.png
 new file mode 100644
-index 0000000000000000000000000000000000000000..5a1c5c57bfc79a6425ffb41fd39758461c0ac8ff
+index 0000000000000000000000000000000000000000..897c3ba5886417f51fd74084030e5c9ce70969db
 GIT binary patch
-literal 407
-zc%17D@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6U4Zl|
-z1_s?V$tQs<&H|6fVg?3oVGw3ym^DWND9B#o>FdgVo1IzAT=GZ#qZXhk;+`&!Ar_~5
-zCp&sEI|{hQpPZv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bandroid/logcat/resources/device_status_unknown.png
+new file mode 100644
+index 0000000000000000000000000000000000000000..ed405c596960fbcc9d367c8f75b884c4af302ad8
+GIT binary patch
+literal 523
+zc$@(X0`&cfP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00001b5ch_0Itp)
+z=>Px#24YJ`L;wH)ssI2jtYgUl000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipe)
+z6*U@kZ7?|i00E0hL_t(I%axKbPXa*@g})*99|#FF<d9GhvA~9g-^wr1f<_A^L<t^J
+zVUT1Ouc2ViI2OCN92Q2Wo1K}r^WGcbM{G75<(FtSn^MhVvREwi>kDc%Xfzt2p{js*
+z%(v}3wb0b-^&|pJr&9%Jx7++B*6TF@qtQqbfIQFXcDo!7hd%+->vfjPrKd2NOcbEs
+z@AIFS&*uOn`@QAzazOr(2hM?fmB0F2(IAJ=YPFcnW+c{HthHq~stO`O;b2Gwz`y&7
+zv6jRb!)~|peWmoOu}MTx1X1-k0Spvl42iLOw%d2#sDf0@RlnC6qgW93#*%zGM^U&6
+z^%BVc2vVLwyd1w1xKBso3dhkM5fwk6{s$2`ql6FzEQNKhAaO^>)BK6f#l=aqN)vM0
+z2$AT_%kl-4KzTeKYnpcaXxO)uG3rtY709xT+nXDIiACXfUOdxD)5tHLK*&T+#;&p~
+z3LU|R!)q;BrvZrQx<_2CU!y(uclT$8#TX2(wDg{ERPhFYhlj_rnQsTE+(i;)d*A>7
+N002ovPDHLkV1gj(-WUJ?
+