public static String getOldSdkDataVmsPath() {
return oldSdkDataVmsPath;
}
+
+ public static String getEmulatorPath() {
+ return emulatorPath;
+ }
}
protected Image INPUTBOX_ON_IMAGE = null;
protected static int COMBO_WIDTH = 105;
+ private boolean useDefaultOnCreate = false;
+ private String defaultOnCreate = null;
+
public ComboSubViewItem(LabelViewItem parentItem, Composite comp, Item template) {
super(parentItem, comp, template);
parseOption(template.getOption());
comboOptions.add(s.trim());
}
}
+
+ if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
+ useDefaultOnCreate = true;
+ defaultOnCreate = option.getValue();
+ }
}
}
@Override
public boolean settingModifyItem(VMPropertyValue value) {
- newValue = value.getAdvancedOptionSubValue(parentItem.getName(), name);
+ if (parentItem.isCreateMode() && useDefaultOnCreate) {
+ newValue = defaultOnCreate;
+ } else {
+ newValue = value.getAdvancedOptionSubValue(parentItem.getName(), name);
+ }
// make combo box list
combo.removeAll();
protected Image INPUTBOX_OFF_IMAGE = null;
protected int COMBOBOX_WIDTH = 175;
+ private boolean useDefaultOnCreate = false;
+ private String defaultOnCreate = null;
+
public ComboViewItem(Item template, LineLabelViewItem lineLabelViewItem) {
super(lineLabelViewItem);
if (lineLabelViewItem == null) {
comboOptions.add(s.trim());
}
}
+
+ if (option.getName().equals(OptionType.DEFAULT_ON_CREATE.getName())) {
+ useDefaultOnCreate = true;
+ defaultOnCreate = option.getValue();
+ }
}
}
@Override
public boolean settingModifyItem(VMPropertyValue value) {
+ if (isCreateMode() && useDefaultOnCreate) {
+ newValue = defaultOnCreate;
+ } else {
+ newValue = getItemValue(value);
+ }
- newValue = getItemValue(value);
// makeComboBox
combo.removeAll();
protected ArrayList<Font> fonts = null;
private String text = "";
- private boolean selected = false;
+ protected boolean selected = false;
private boolean defaultPush = true;
private int RADIO_IMAGE_SIZE = 16;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.platform.BaseImage;
import org.tizen.emulator.manager.plugin.ExtensionItem;
import org.tizen.emulator.manager.ui.VMsMainView;
import org.tizen.emulator.manager.ui.list.VMButtonFactory;
import org.tizen.emulator.manager.vms.VMProperty;
+import org.tizen.emulator.manager.vms.helper.CheckingRunningEmulator;
+import org.tizen.emulator.manager.vms.helper.HelperClass;
+import org.tizen.emulator.manager.vms.helper.VMSocket;
public class VMButton extends ImageButton {
private VMButton button = null;
settingImage();
settingLaunchButton();
+ addListener(SWT.MouseEnter, mouseListener);
+
}
private void settingImage() {
// TODO Auto-generated method stub
}
});
+
}
public void clickLaunchButton() {
}
};
+
+
+ private Listener mouseListener = new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ if (state == WSTATE.DISABLE) {
+ return;
+ }
+
+ VMButton button = (VMButton) event.widget;
+ if (event.type == SWT.MouseDown) {
+ button.setFocus();
+ if (state != WSTATE.PUSH) {
+ if (state == WSTATE.SELECTED
+ || state == WSTATE.SELECTED_HOVER ) {
+ state = WSTATE.SELECTED_PUSH;
+ } else {
+ state = WSTATE.PUSH;
+ }
+ }
+ redraw();
+ } else if (event.type == SWT.MouseUp) {
+ Rectangle rect = button.getClientArea();
+ if (rect.contains(event.x, event.y)) {
+ notifyListeners(SWT.Selection, new Event());
+ //notifyListeners(SWT.DefaultSelection, new Event());
+ }
+ } else if (event.type == SWT.MouseEnter) {
+ if ((state != WSTATE.HOVER) && (state != WSTATE.SELECTED_HOVER)) {
+ if (selected) {
+ state = WSTATE.SELECTED_HOVER;
+ } else {
+ state = WSTATE.HOVER;
+ }
+ }
+ // Check tooltip text.
+ checkToolTipText(button);
+ redraw();
+ } else if (event.type == SWT.MouseExit) {
+ button.setSelection(selected);
+ }
+ }
+ };
+
+ private void checkToolTipText(VMButton button) {
+ VMProperty prop = button.getProperty();
+ if (prop != null) {
+ if (CheckingRunningEmulator.isRemote(prop) && prop.isRunning()) {
+ int webVMPort = 0;
+ synchronized (VMSocket.list) {
+ for (VMSocket s : VMSocket.list) {
+ if (s.getProperty() != null && s.getProperty().getName().equals(prop.getName())) {
+ webVMPort = s.getEcs_port() + 3;
+ }
+ }
+ }
+ if (webVMPort > 0) {
+ String ip = HelperClass.getLocalIPAddress(webVMPort-3);
+ button.setToolTipText(prop.getName() + "(web client)" + "\n" +
+ "url : " + ip + ":8080\n" +
+ "vm port : " + webVMPort);
+ }
+ } else {
+ button.setToolTipText(prop.getName());
+ }
+ }
+ }
}
\ No newline at end of file
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.swt.widgets.Display;
import org.tizen.ecp.msg.genmsg.ecs.Ecs.DeviceAns;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
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;
import org.tizen.emulator.manager.vms.helper.VMSocketQueue.QueueObject;
private static CheckingThread thread = null;
+ // Decide whether popup-message display or not.
+ private static List<String> LAUNCHED_VM_LIST = new ArrayList<String>();
+
+ public static void addLaunchedVMList(String vmName) {
+ synchronized(LAUNCHED_VM_LIST) {
+ LAUNCHED_VM_LIST.add(vmName);
+ }
+ }
+
+ private static void removeLaunchedVMList(String vmName) {
+ synchronized(LAUNCHED_VM_LIST) {
+ LAUNCHED_VM_LIST.remove(vmName);
+ }
+ }
+
+ public static boolean needPopupMessage(VMSocket vms) {
+ if (vms.getProperty() != null) {
+ String vmName = vms.getProperty().getName();
+ String launched = null;
+ synchronized(LAUNCHED_VM_LIST) {
+ for (String s : LAUNCHED_VM_LIST) {
+ if (s.equals(vmName)) {
+ launched = s;
+ }
+ }
+ if (launched != null) {
+ removeLaunchedVMList(launched);
+ return true;
+ }
+ }
+ }
+ return false;
+
+ }
+
public static synchronized void startCheckingThread() {
if (EmulatorManager.isConsoleMode()) {
return;
if (!isSuccess) {
prop.setRunning(false);
} else {
+ addLaunchedVMList(prop.getName());
connectToECS(prop);
if (prop.getWorker() != null) {
prop.getWorker().getLauncher().sendRemoteLog("start");
}
boolean isHeartBeat = false;
boolean isImagePathSame = false;
+ VMSocket currentVms = null;
synchronized (VMSocket.list) {
for (VMSocket s : VMSocket.list) {
switch(type){
case PATH_SAME:
isImagePathSame = true;
+ currentVms = s;
break;
case SOCK_CLOSED:
if (isImagePathSame) {
vm.setRunning(true);
CheckingRunningEmulator.removeEmulator(vm);
+ // Check remote option.
+ if (isRemote(vm)) {
+// runServer(currentVms);
+ showInfoDialog(currentVms);
+ }
} else {
vm.setRunning(false);
}
if (vms.getProperty() != null && vms.getProperty().getWorker() != null) {
vms.getProperty().getWorker().getLauncher().sendRemoteLog("stop");
}
+ // Check remote.
+// if (isRemote(vms.getProperty())) {
+// killServer(vms);
+// }
}
disconnect(vms);
}
prop.setRunning(true);
CheckingRunningEmulator.removeEmulator(prop);
+ // Check remote option.
+ if (isRemote(prop)) {
+// runServer(vms);
+ showInfoDialog(vms);
+ }
+
// this is not need for console mode
Display.getDefault().asyncExec(new Runnable() {
public void run() {
}
}
+
+ public static String OPTION_VIEWER = "viewer";
+ public static String OPTION_TYPE = "type";
+ public static String VAL_WEB = "Web";
+
+ public static boolean isRemote(VMProperty prop) {
+ if (EmulatorManager.isLinux() && prop.getPropertyValue().getAdvancedOptionSubValue(
+ OPTION_VIEWER, OPTION_TYPE).equals(VAL_WEB)) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ public static void runServer(VMSocket vms) {
+ // Run web(Node) server (if not running)
+ boolean nodeResult = WebEmulator.runWebServer();
+
+ // Run emulator(spice) server (if not running)
+ boolean spiceResult = WebEmulator.runEmulatorServer(vms);
+
+ showInfoDialog(nodeResult, spiceResult, vms);
+ }
+ */
+
+ public static void showInfoDialog(VMSocket vms) {
+ if(needPopupMessage(vms)) {
+ final int clientPort = vms.getEcs_port() + 3;
+ final String vmName = (vms.getProperty() != null) ? vms.getProperty().getName() : "";
+ final String ip = HelperClass.getLocalIPAddress(vms.getEcs_port());
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog msgDialog = new MessageDialog();
+ String title = "Web viewer Information (" + vmName + ")";
+ String msg = "\nURL : http://" + ip + ":8080\n" +
+ "VM Port : " + clientPort + "\n\n" +
+ "You can connect to emulator via web-browser.";
+ msgDialog.openInfoDialog(title, msg);
+ }
+ });
+ }
+ }
+
+ /*
+ public static void killServer(VMSocket vms) {
+ WebEmulator.killEmulatorServer(vms);
+
+ // Kill web server if no remote VM runs.
+ WebEmulator.killWebServer();
+ }
+ */
+
}
package org.tizen.emulator.manager.vms.helper;
import java.io.File;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.ServerSocket;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.nio.channels.SocketChannel;
+import java.nio.channels.UnresolvedAddressException;
+import java.util.Enumeration;
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.logging.EMLogger;
return layout;
}
*/
+
+// public static String loaclIPAddress = null;
+ public static String loaclIPAddress = "(your IP)"; // TODO
+ public static String getLocalIPAddress(int ecsPort) {
+ if (loaclIPAddress == null) {
+ Enumeration<NetworkInterface> interfaces;
+ try {
+ interfaces = NetworkInterface.getNetworkInterfaces();
+ while (interfaces.hasMoreElements()){
+ NetworkInterface current = interfaces.nextElement();
+
+ if (!current.isUp() || current.isLoopback() || current.isVirtual()) continue;
+ Enumeration<InetAddress> addresses = current.getInetAddresses();
+ while (addresses.hasMoreElements()){
+ InetAddress current_addr = addresses.nextElement();
+ if (current_addr.isLoopbackAddress()) continue;
+ if (current_addr instanceof Inet6Address) continue;
+
+ loaclIPAddress = current_addr.getHostAddress();
+ }
+ }
+ } catch (SocketException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+ }
+ return loaclIPAddress;
+ }
+
}
+