- receive event when emulator launched or terminated.
- CheckingRunningEmulator send event
Change-Id: Ideba358f5fa7a4e97dc35f717cbaf86ed60940e5
Signed-off-by: jihye424.kim <jihye424.kim@samsung.com>
import org.eclipse.swt.widgets.Shell;
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.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.resources.StringResources;
import org.tizen.emulator.manager.ui.renewal.tableviewer.AbstractTableViewer;
import org.tizen.emulator.manager.ui.renewal.tableviewer.VMListTableViewer;
+import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
public class MainDialog {
private static final String ICON_FILE_NAME = "res/em.ico"; //$NON-NLS-1$
}
public void open() {
- // TODO
- //CheckingRunningEmulator.startCheckingThread();
+ CheckingRunningEmulator.startCheckingThread();
shell.open();
while(!shell.isDisposed()) {
import org.tizen.emulator.manager.renewal.resources.ImageResources;
import org.tizen.emulator.manager.ui.renewal.widgets.ImageButton;
-public class ProfileButtonList {
+public class ProfileButtonMaker {
private final static int WIDTH = 32;
private final static int HEIGHT = 26;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.tizen.emulator.manager.platform.Profile;
import org.tizen.emulator.manager.vms.VMPropertyValue;
import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
import org.tizen.emulator.manager.vms.helper.RefreshWorker;
+import org.tizen.emulator.manager.vms.helper.EmulatorStatusListener;
import org.tizen.emulator.manager.vms.helper.VMWorkerException;
public class VMListTable {
return;
}
+ CheckingRunningEmulator.addRunningEmulatorListener(new EmulatorStatusListener () {
+ @Override
+ public void changeEmulatorRunningStatus(final VMProperty prop) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ redrawProperty(prop);
+ }
+ });
+
+ }
+ });
+
makeTable();
+ makeCreateVMCombo();
makeProfileButton();
makeVMButton();
setLayout();
column.setText(t);
column.setAlignment(SWT.CENTER);
}
+
table.getColumn(0).setResizable(false);
table.getColumn(1).setResizable(false);
table.addListener(SWT.Selection, new Listener(){
});
}
+ private void makeCreateVMCombo() {
+ createVM = new CreateVMCombo(comp, SWT.None);
+ createVM.addSelectionListener(createVMComboSelectionListener);
+ }
+
private void makeProfileButton() {
profileButtonList = new ArrayList<ProfileButton>();
- profileButtonList.add(ProfileButtonList.getProfileButton("mobile", comp));
- profileButtonList.add(ProfileButtonList.getProfileButton("tv", comp));
- profileButtonList.add(ProfileButtonList.getProfileButton("wearable", comp));
+ profileButtonList.add(ProfileButtonMaker.getProfileButton("mobile", comp));
+ profileButtonList.add(ProfileButtonMaker.getProfileButton("tv", comp));
+ profileButtonList.add(ProfileButtonMaker.getProfileButton("wearable", comp));
for (Profile profile : ProfileList.getProfileList()) {
for (ProfileButton pButton : profileButtonList) {
}
}
}
-
- createVM = new CreateVMCombo(comp, SWT.None);
- createVM.addSelectionListener(createVMComboSelectionListener);
}
- private ProfileButton findProfileButton(String profile) {
- for (ProfileButton pButton : profileButtonList) {
- if (pButton.getProfileName().equals(profile)) {
- return pButton;
- }
- }
- return null;
- }
+// private ProfileButton findProfileButton(String profile) {
+// for (ProfileButton pButton : profileButtonList) {
+// if (pButton.getProfileName().equals(profile)) {
+// return pButton;
+// }
+// }
+// return null;
+// }
private final SelectionListener createVMComboSelectionListener = new SelectionListener() {
addTableItem(pButton, property);
}
}
+
private void addTableItem (ProfileButton pButton, VMProperty property) {
addTableItem(pButton, property, -1);
}
VMPropertyValue value = property.getPropertyValue();
if (property.isRunning()) {
item.setImage(0, ImageResources.ICON_RUNNING.getImage());
+ } else {
+ item.setImage(0, null);
}
item.setText(2, value.vmsName);
item.setText(3, "Samsung Z3");
}
item.setData(property);
}
+
private void makeVMButton() {
resetButton = new ImageButton(comp, SWT.PUSH);
resetButton.setBackground(null);
VMProperty property = (VMProperty)table.getSelection()[0].getData();
try {
if (MenuHandling.launchEmulator(property)) {
- reloadProperty();
+ reloadSelectedProperty();
}
} catch (VMWorkerException e) {
if (e.isNeedRefresh()) {
VMProperty property = (VMProperty)table.getSelection()[0].getData();
try {
if (MenuHandling.createBaseImage(property)) {
- reloadProperty();
+ reloadSelectedProperty();
}
} catch (VMWorkerException e) {
if (e.isNeedRefresh()) {
try {
if (MenuHandling.resetEmulator(properties)) {
- reloadProperty();
+ reloadSelectedProperty();
}
} catch (VMWorkerException e) {
if (e.isNeedRefresh()) {
}
}
- private void reloadProperty() {
+ private void reloadSelectedProperty() {
if (table.getSelectionCount() == 0) {
return;
}
}
}
+ private TableItem findTableItem(VMProperty property) {
+ for (TableItem item : table.getItems()) {
+ if (item.getData() == property) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ private void redrawProperty(VMProperty property) {
+ TableItem item = findTableItem(property);
+ if (item == null) {
+ return;
+ }
+
+ setTableItemProperty(item, property);
+ item.redraw();
+ tableSelected();
+ }
+
private void setLayout() {
// composite is form layout
FormData createButtonData;
import org.tizen.ecp.msg.genmsg.ecs.Ecs.Master;
import org.tizen.ecp.msg.genmsg.ecs.EcsIds.Master_Type;
import org.tizen.emulator.manager.EmulatorManager;
-import org.tizen.emulator.manager.Messages;
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;
// Decide whether popup-message display or not.
private static List<String> LAUNCHED_VM_LIST = new ArrayList<String>();
+ private static List<EmulatorStatusListener> listenerList = new ArrayList<EmulatorStatusListener>();
public static void addLaunchedVMList(String vmName) {
synchronized(LAUNCHED_VM_LIST) {
}
}
+ 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();
emList.add(prop.getName());
}
}
- prop.setRunning(true);
+ setRunning(prop, true);
}
public static void removeEmulator(VMProperty prop, boolean isSuccess) {
emList.remove(prop.getName());
}
if (!isSuccess) {
- prop.setRunning(false);
+ setRunning(prop, false);
} else {
addLaunchedVMList(prop.getName());
boolean checkFinished;
}
} 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();
- }
- });
- }
}
-
}
}
}
if (isVMFound) {
- setRunning(vm.getName(), true);
+ setRunning(vm, true);
CheckingRunningEmulator.removeEmulator(vm);
result = VMSocket.ResultType.LAUNCHED_VM_DETECTED;
// Check remote option.
}
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;
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);
}
}
// 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) {
vms.setProperty(prop);
RefreshWorker.addToFinishedSet(vms.getEcs_port());
}
- CheckingRunningEmulator.setRunning(prop.getName(), true);
+ CheckingRunningEmulator.setRunning(prop, true);
CheckingRunningEmulator.removeEmulator(prop);
// Check remote option.
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;
}
}
--- /dev/null
+package org.tizen.emulator.manager.vms.helper;
+
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public interface EmulatorStatusListener {
+ void changeEmulatorRunningStatus(VMProperty prop);
+}