From 5ea49e4084c9894259fb2c40c542f38985847e44 Mon Sep 17 00:00:00 2001 From: "hyunsik.noh" Date: Fri, 30 Nov 2012 14:32:11 +0900 Subject: [PATCH] [Title] Supprot to get already connected device notification when add listener on SmartDevelopmentBridge additionally. [Type] [Module] [Priority] [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase Change-Id: Ieb13761d63f44cfacd1abe7e2191e4a5f46458a3 --- .../explorer/ConnectionExplorerPanel.java | 16 +-------------- .../org/tizen/common/connection/log/LogPanel.java | 18 +---------------- .../org/tizen/sdblib/SmartDevelopmentBridge.java | 23 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java index 501286f..99a0729 100755 --- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java @@ -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); } /** diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java index 733337a..ec25e95 100755 --- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java @@ -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 diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java index 1d30a74..4eebe00 100644 --- a/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java +++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java @@ -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); + } + } + } } } } -- 2.7.4