[Title] Supprot to get already connected device notification when add
authorhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 30 Nov 2012 05:32:11 +0000 (14:32 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 30 Nov 2012 07:11:33 +0000 (16:11 +0900)
listener on SmartDevelopmentBridge additionally.
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase

Change-Id: Ieb13761d63f44cfacd1abe7e2191e4a5f46458a3

org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java
org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java

index 501286f..99a0729 100755 (executable)
@@ -326,22 +326,8 @@ public class ConnectionExplorerPanel extends Panel implements IDeviceChangeListe
     protected void postCreation()
     {
         ConnectionPlugin.getDefault().addSelectionListener(this);
-        SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge();
         SmartDevelopmentBridge.addDebugBridgeChangeListener(this);
-        SmartDevelopmentBridge.addDeviceChangeListener(this);
-
-        IDevice[] devices = null;
-        if (sdbBridge != null)
-        {
-            devices = sdbBridge.getDevices();
-        }
-        if (devices != null && devices.length != 0)
-        {
-            for (IDevice device : devices)
-            {
-                this.deviceConnected(device);
-            }
-        }
+        SmartDevelopmentBridge.addDeviceChangeListener(this, true);
     }
 
     /**
index 733337a..ec25e95 100755 (executable)
@@ -184,9 +184,7 @@ public class LogPanel extends Panel implements IDeviceChangeListener
             }
         });
 
-        SmartDevelopmentBridge.addDeviceChangeListener(this);
-        // Create default device tab if device(s) is connected
-         createDefaultTabs();
+        SmartDevelopmentBridge.addDeviceChangeListener(this, true);
         return null;
     }
 
@@ -279,20 +277,6 @@ public class LogPanel extends Panel implements IDeviceChangeListener
         getSelectionLogTab().setLevelMode(levelMode);
     }
 
-    // create the logtab with default devices
-    private void createDefaultTabs()
-    {
-        for (IDevice device : getDevices())
-        {
-            if (device.isOffline())
-            {
-                continue;
-            }
-            LogTab dTab = createLogTab(ConnectionExplorerLabelProvider.getDeviceSerialWithName(device), device, true);
-            dTab.start();
-        }
-    }
-    
     /**
      * Create LogTab and TabItem and
      * set action and icon status
index 1d30a74..4eebe00 100644 (file)
@@ -332,9 +332,32 @@ public final class SmartDevelopmentBridge {
      * @param listener The listener which should be notified.
      */
     public static void addDeviceChangeListener(IDeviceChangeListener listener) {
+        addDeviceChangeListener(listener, false);
+    }
+    
+    /**
+     * Adds the listener to the collection of listeners who will be notified when a {@link IDevice}
+     * is connected, disconnected, or when its properties or its {@link Client} list changed,
+     * by sending it one of the messages defined in the {@link IDeviceChangeListener} interface.
+     * 
+     * @param listener The listener which should be notified.
+     * @param getPreviousNoti Provides connected device notification which not notified before adding listener.
+     */
+    public static void addDeviceChangeListener(IDeviceChangeListener listener, boolean getPreviousNoti) {
         synchronized (sLock) {
             if (sDeviceListeners.contains(listener) == false) {
                 sDeviceListeners.add(listener);
+                if(getPreviousNoti)
+                {
+                    IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+                    for(IDevice device : devices)
+                    {
+                        if(device.isOnline())
+                        {
+                            listener.deviceConnected(device);
+                        }
+                    }
+                }
             }
         }
     }