LAUNCH: Aligned messages with web and native 47/12047/1
authorkh5325.kim <kh5325.kim@samsung.com>
Tue, 12 Nov 2013 04:22:05 +0000 (13:22 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Tue, 12 Nov 2013 04:22:05 +0000 (13:22 +0900)
Aligns messages between web and native launch.
Removes user-unfriendly messages.

Change-Id: Ifbb5c21e17871e4beb72a21fcd61ad8e01084088
Signed-off-by: kh5325.kim <kh5325.kim@samsung.com>
org.tizen.common/src/org/tizen/common/launch/LaunchMessages.java
org.tizen.common/src/org/tizen/common/launch/LaunchMessages.properties
org.tizen.common/src/org/tizen/common/sdb/command/SdbCommand.java

index a89a5ea..d380555 100644 (file)
@@ -47,9 +47,11 @@ public class LaunchMessages extends NLS {
     public static String UPDATE_MODE_LABEL;
     public static String UPDATE_MODE_TOOLTIP;
 
+    public static String CREATED_PACKAGE;
     public static String INSTALL_PACKAGE;
     public static String UNINSTALL_PACKAGE;
     public static String TRANSFER_PACKAGE;
+    public static String TRANSFERRED_PACKAGE;
     public static String RUN_PACKAGE;
 
     public static String LAUNCH_START;
@@ -72,7 +74,11 @@ public class LaunchMessages extends NLS {
         return "(" + getTimeInterval(start, end) + " sec)";
     }
 
-    public static String getStepMessage(String step) {
+    public static String getStepTitle(String step) {
         return "[" + step + "]";
     }
+
+    public static String getStepMessage(String message) {
+        return "    " + message;
+    }
 }
index d21aaca..2304d12 100644 (file)
@@ -15,12 +15,15 @@ PROJECT_NOT_USABLE = Project is closed or does not exist.
 UPDATE_MODE_LABEL = Enable update mode\r
 UPDATE_MODE_TOOLTIP = If you want to set update mode you should turn off RDS option first of all.\r
 \r
+CREATED_PACKAGE = Created the package: {0}\r
+\r
 # Install/Uninstall\r
 INSTALL_PACKAGE = Installing the package...\r
 UNINSTALL_PACKAGE = Uninstalling the package...\r
 \r
 # Transfer\r
 TRANSFER_PACKAGE = Transferring the package...\r
+TRANSFERRED_PACKAGE = Transferred the package: {0} -> {1}\r
 \r
 # Run\r
 RUN_PACKAGE = Running the application...\r
index 3a7fd79..caa046d 100644 (file)
@@ -28,6 +28,8 @@ package org.tizen.common.sdb.command;
 
 import java.io.IOException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.common.sdb.command.message.CommandErrorException;
@@ -42,137 +44,125 @@ import org.tizen.sdblib.exception.SdbCommandRejectedException;
 import org.tizen.sdblib.exception.ShellCommandUnresponsiveException;
 import org.tizen.sdblib.exception.TimeoutException;
 
-
 public class SdbCommand {
+    protected final Logger logger = LoggerFactory.getLogger(getClass());
+
     public static final int DEFAULT_TIMEOUT = 60000;
+    private final String SEPARATOR = System.getProperty("line.separator");
+
     private IDevice device = null;
     private ITizenConsoleManager console = null;
     private String endLine = "";
     private String commandOutput = "";
     private CommandOutputReceiver receiver = null;
     private String sdbPath;
-    
+    private boolean showCommand = false;
+
     public SdbCommand(IDevice device) {
         this(device, null);
     }
-    
+
     public SdbCommand(IDevice device, ITizenConsoleManager console) {
         this(device, console, new CommandOutputReceiver(console));
     }
-    
+
     public SdbCommand(IDevice device, ITizenConsoleManager console, CommandOutputReceiver receiver) {
         this.device = device;
         this.console = console;
         this.receiver = receiver;
-        
+
         sdbPath = InstallPathConfig.getSDBPath();
     }
-    
-    public void runCommand(String command ) throws Exception {
-        if (console != null) {
-            console.println("$ " + command);
-        }
+
+    public void runCommand(String command) throws Exception {
+        print("$ " + command);
 
         device.executeShellCommand(command, receiver);
 
         this.endLine = receiver.getEndLine();
         this.commandOutput = receiver.getCommandOutput();
     }
-    
+
     public void runLaunchCommand(String command) throws IOException {
         runLaunchCommand(command, true);
     }
-    
+
     private Process runHostCommandImpl(String command, String sdbCommand, boolean isBlock, IShellOutputReceiver userReceiver, boolean isLaunch) throws IOException {
+        print("$ " + sdbCommand);
+
         Process process = null;
-        
-        if (console != null) {
-            console.println(String.format("$ %s", sdbCommand));
-        }
-        
         IShellOutputReceiver r = (userReceiver != null) ? userReceiver : this.receiver;
         if ( isBlock ) {
-            if (isLaunch) {
+            if ( isLaunch ) {
                 device.executeLaunchCommand( command, r );
             } else {
                 device.executeHostCommand( command, r );
             }
-            if (userReceiver == null) {
+            if ( userReceiver == null ) {
                 this.endLine = this.receiver.getEndLine();
                 this.commandOutput = this.receiver.getCommandOutput();
             }
-        }
-        else {
+        } else {
             process = Runtime.getRuntime().exec(sdbCommand);
         }
-        
+
         return process;
     }
-    
+
     public Process runLaunchCommand(String command, boolean isBlock) throws IOException {
         final String sdbCommand = String.format("%s -s %s launch %s", sdbPath, device.getSerialNumber(), command);
-        
         return runHostCommandImpl(command, sdbCommand, isBlock, null, true);
     }
-    
+
     public Process runHostCommand(String command, boolean isBlock) throws IOException {
         return runHostCommand(command, isBlock, null);
     }
-    
+
     public Process runHostCommand(String command, boolean isBlock, IShellOutputReceiver receiver) throws IOException {
         final String sdbCommand = String.format("%s -s %s %s", sdbPath, device.getSerialNumber(), command);
-        
         return runHostCommandImpl(command, sdbCommand, isBlock, receiver, false);
     }
-    
+
     public String returnExecuteCommand(String command) {
-        
         final String sdbCommand = String.format("%s -s %s shell %s", sdbPath, device.getSerialNumber(), command);
-        
         return HostUtil.returnExecute(sdbCommand);
     }
 
-    public CommandErrorType runCommand(String command, CommandErrorType messages ) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
+    public CommandErrorType runCommand(String command, CommandErrorType messages) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
         return runCommand(command, messages, DEFAULT_TIMEOUT);
     }
 
-    public CommandErrorType runCommand(String command, CommandErrorType errorMessages, int timeout ) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException{
-        if (console != null) {
-            console.println("$ " + command);
-        }
+    public CommandErrorType runCommand(String command, CommandErrorType errorMessages, int timeout) throws CommandErrorException, TimeoutException, SdbCommandRejectedException, ShellCommandUnresponsiveException, IOException{
+        print("$ " + command);
 
         device.executeShellCommand( makeCommandWithExitcode(command), receiver, timeout);
         this.endLine = receiver.getEndLine();
         this.commandOutput = receiver.getCommandOutput();
-        
         String endLine = receiver.getEndLine();
         int exitcode = parseExitcode(endLine);
-
         errorMessages.findErrorType(exitcode, command);
         errorMessages.setCommandOutput(receiver.getCommandOutput());
         errorMessages.makeException();
-
         return errorMessages;
     }
-    
+
     public String getEndLine() {
         return endLine;
     }
-    
+
     public String getCommandOutput() {
         return commandOutput;
     }
-    
+
     public String[] getResultLineStrings() {
         String strs = commandOutput.toString();
         if ( StringUtil.isEmpty(strs) ) {
             return new String[0];
         }
-        String [] str = StringUtil.split( strs, System.getProperty("line.separator") );
-        
+        String[] str = StringUtil.split( strs, SEPARATOR );
         return str;
     }
-    
+
     private int parseExitcode(String line) {
         int exitcode = -1;
         if ( line.startsWith(TizenPlatformConstants.CMD_RESULT_PREFIX) ) {
@@ -180,8 +170,23 @@ public class SdbCommand {
         }
         return exitcode;
     }
-    
+
     private String makeCommandWithExitcode(String command) {
         return command + TizenPlatformConstants.CMD_SUFFIX;
     }
+
+    public boolean isShowCommand() {
+        return showCommand;
+    }
+
+    public void setShowCommand(boolean showCommand) {
+        this.showCommand = showCommand;
+    }
+
+    private void print(String message) {
+        logger.debug(message);
+        if ( isShowCommand() && console != null ) {
+            console.println(message);
+        }
+    }
 }