communication: added some error popup message
authorMunkyu Im <munkyu.im@samsung.com>
Wed, 20 May 2015 05:02:40 +0000 (14:02 +0900)
committerMunkyu Im <munkyu.im@samsung.com>
Wed, 20 May 2015 05:36:40 +0000 (14:36 +0900)
shows message when fail to create socket.

Change-Id: I58077c28ae053d62e6006937d7df2ef4ad4a8049
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java

index 3aa3237..14aafe9 100755 (executable)
@@ -34,7 +34,6 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.net.Socket;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -44,8 +43,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.tizen.emulator.skin.EmulatorSkin;
+import org.tizen.emulator.skin.EmulatorSkinMain;
 import org.tizen.emulator.skin.comm.ICommunicator;
 import org.tizen.emulator.skin.comm.ICommunicator.SendCommand;
 import org.tizen.emulator.skin.comm.sock.data.BooleanData;
@@ -56,6 +57,8 @@ import org.tizen.emulator.skin.config.EmulatorConfig.ArgsConstants;
 import org.tizen.emulator.skin.image.ImageRegistry.ResourceImageName;
 import org.tizen.emulator.skin.log.SkinLogger;
 import org.tizen.emulator.skin.util.IOUtil;
+import org.tizen.emulator.skin.util.SkinUtil;
+import org.tizen.emulator.skin.util.SwtUtil;
 
 /**
  * 
@@ -156,10 +159,21 @@ public class SocketCommunicator implements ICommunicator {
                        int port = config.getArgInt(ArgsConstants.VM_SKIN_PORT);
                        socket = new Socket("127.0.0.1", port);
                        logger.info("socket.isConnected() : " + socket.isConnected());
-               } catch (UnknownHostException e) {
-                       logger.log(Level.SEVERE, e.getMessage(), e);
                } catch (IOException e) {
                        logger.log(Level.SEVERE, e.getMessage(), e);
+                       StringBuilder message = new StringBuilder("Error message: "
+                                       + e.getMessage());
+                       if (SwtUtil.isMacPlatform()) {
+                               message.append(System.getProperty("line.separator")).append(
+                                               "Make sure that SOCKS proxy setting is correct.");
+                       }
+                       SkinUtil.openMessage(
+                                       skin.getShell(),
+                                       null,
+                                       "Emulator UI fails to connect."
+                                                       + System.getProperty("line.separator")
+                                                       + message.toString(), SWT.ICON_ERROR, config);
+                       EmulatorSkinMain.terminateImmediately(-1);
                }
 
                this.bao = new ByteArrayOutputStream();