From 050b10a2ce4661b1d47e921bd5a826a64fd780c9 Mon Sep 17 00:00:00 2001 From: "jihye424.kim" Date: Thu, 3 Sep 2015 14:59:49 +0900 Subject: [PATCH] Emulator Status: add 'EmulatorStatusListener' - receive event when emulator launched or terminated. - CheckingRunningEmulator send event Conflicts: src/org/tizen/emulator/manager/ui/renewal/MainDialog.java src/org/tizen/emulator/manager/ui/renewal/tableviewer/ProfileButtonMaker.java src/org/tizen/emulator/manager/ui/renewal/tableviewer/VMListTable.java Change-Id: Ideba358f5fa7a4e97dc35f717cbaf86ed60940e5 Signed-off-by: jihye424.kim (cherry picked from commit 69cf10df5e297d390c2bb2a947e12bc9334b15b0) --- .../vms/helper/CheckingRunningEmulator.java | 75 ++++++++-------------- .../manager/vms/helper/EmulatorStatusListener.java | 7 ++ 2 files changed, 35 insertions(+), 47 deletions(-) create mode 100644 src/org/tizen/emulator/manager/vms/helper/EmulatorStatusListener.java diff --git a/src/org/tizen/emulator/manager/vms/helper/CheckingRunningEmulator.java b/src/org/tizen/emulator/manager/vms/helper/CheckingRunningEmulator.java index d9f3a64..4eb7e85 100644 --- a/src/org/tizen/emulator/manager/vms/helper/CheckingRunningEmulator.java +++ b/src/org/tizen/emulator/manager/vms/helper/CheckingRunningEmulator.java @@ -50,7 +50,6 @@ import org.tizen.emulator.manager.EmulatorManager.ManagerModeType; import org.tizen.emulator.manager.Messages; import org.tizen.emulator.manager.logging.EMLogger; import org.tizen.emulator.manager.resources.StringResources; -import org.tizen.emulator.manager.ui.VMsMainView; import org.tizen.emulator.manager.ui.dialog.MessageDialog; import org.tizen.emulator.manager.vms.EmulatorVMList; import org.tizen.emulator.manager.vms.VMProperty; @@ -64,6 +63,7 @@ public class CheckingRunningEmulator { // Decide whether popup-message display or not. private static List LAUNCHED_VM_LIST = new ArrayList(); + private static List listenerList = new ArrayList(); public static void addLaunchedVMList(String vmName) { synchronized(LAUNCHED_VM_LIST) { @@ -77,6 +77,14 @@ public class CheckingRunningEmulator { } } + public static void addRunningEmulatorListener(EmulatorStatusListener listener) { + listenerList.add(listener); + } + + public static void removeRunnignEmulatorListener(EmulatorStatusListener listener) { + listenerList.remove(listener); + } + public static boolean needPopupMessage(VMSocket vms) { if (vms.getProperty() != null) { String vmName = vms.getProperty().getName(); @@ -133,7 +141,7 @@ public class CheckingRunningEmulator { emList.add(prop.getName()); } } - prop.setRunning(true); + setRunning(prop, true); } public static void removeEmulator(VMProperty prop, boolean isSuccess) { @@ -141,7 +149,7 @@ public class CheckingRunningEmulator { emList.remove(prop.getName()); } if (!isSuccess) { - prop.setRunning(false); + setRunning(prop, false); } else { addLaunchedVMList(prop.getName()); boolean checkFinished; @@ -182,18 +190,9 @@ public class CheckingRunningEmulator { } } else { - setRunning(prop.getName(), false); + setRunning(prop, false); EMLogger.getLogger().info("No response from VM (" + prop.getName() + ")."); //$NON-NLS-1$ //$NON-NLS-2$ - if (!EmulatorManager.isConsoleMode()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - VMsMainView.getInstance().redraw(); - } - }); - } } - } } @@ -276,7 +275,7 @@ public class CheckingRunningEmulator { } if (isVMFound) { - setRunning(vm.getName(), true); + setRunning(vm, true); CheckingRunningEmulator.removeEmulator(vm); result = VMSocket.ResultType.LAUNCHED_VM_DETECTED; // Check remote option. @@ -293,15 +292,7 @@ public class CheckingRunningEmulator { } if (!isHeartBeat){ - // this is not need for console mode - if (!EmulatorManager.isConsoleMode()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - VMsMainView.getInstance().redraw(); - } - }); - } + // TODO } return result; @@ -309,8 +300,18 @@ public class CheckingRunningEmulator { public static void setRunning(String vmName, boolean isRunning) { VMProperty prop = EmulatorVMList.getInstance().getProperty(vmName); - if (prop != null) { - prop.setRunning(isRunning); + setRunning(prop, isRunning); + } + + public static void setRunning(VMProperty prop, boolean isRunning) { + if (prop == null) { + return; + } + + prop.setRunning(isRunning); + + for (EmulatorStatusListener listener : listenerList ) { + listener.changeEmulatorRunningStatus(prop); } } @@ -529,20 +530,10 @@ public class CheckingRunningEmulator { // disconnect if (vms != null) { if (vms.getProperty() != null) { - CheckingRunningEmulator.setRunning(vms.getProperty().getName(), false); + CheckingRunningEmulator.setRunning(vms.getProperty(), false); } vms.disconnect(); } - - // this is not need for console mode - if (!EmulatorManager.isConsoleMode()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - VMsMainView.getInstance().redraw(); - } - }); - } } private void settingProperty(String path, VMSocket vms) { @@ -556,7 +547,7 @@ public class CheckingRunningEmulator { vms.setProperty(prop); RefreshWorker.addToFinishedSet(vms.getEcs_port()); } - CheckingRunningEmulator.setRunning(prop.getName(), true); + CheckingRunningEmulator.setRunning(prop, true); CheckingRunningEmulator.removeEmulator(prop); // Check remote option. @@ -565,16 +556,6 @@ public class CheckingRunningEmulator { showInfoDialog(vms); } - // this is not need for console mode - if (!EmulatorManager.isConsoleMode()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - VMsMainView.getInstance().redraw(); - } - }); - } - break; } } diff --git a/src/org/tizen/emulator/manager/vms/helper/EmulatorStatusListener.java b/src/org/tizen/emulator/manager/vms/helper/EmulatorStatusListener.java new file mode 100644 index 0000000..22f9b3d --- /dev/null +++ b/src/org/tizen/emulator/manager/vms/helper/EmulatorStatusListener.java @@ -0,0 +1,7 @@ +package org.tizen.emulator.manager.vms.helper; + +import org.tizen.emulator.manager.vms.VMProperty; + +public interface EmulatorStatusListener { + void changeEmulatorRunningStatus(VMProperty prop); +} -- 2.7.4