[Title] modified pkgcmd's output message.
authorTaeyoung Son <taeyoung2.son@samsung.com>
Wed, 10 Apr 2013 12:26:25 +0000 (21:26 +0900)
committerTaeyoung Son <taeyoung2.son@samsung.com>
Wed, 10 Apr 2013 12:44:37 +0000 (21:44 +0900)
[Desc.]
[Issue]

Change-Id: I3d7632d2998db731a4e9502107958afa6a7a1f11

org.tizen.common/src/org/tizen/common/rds/RdsDeployer.java
org.tizen.common/src/org/tizen/common/sdb/command/receiver/PkgCmdReceiver.java
org.tizen.common/src/org/tizen/common/ui/view/console/ConsoleManager.java
org.tizen.common/src/org/tizen/common/ui/view/console/ConsoleManager2.java
org.tizen.common/src/org/tizen/common/ui/view/console/ITizenConsoleManager.java

index 6d68d4b..f5a9b0b 100644 (file)
@@ -41,7 +41,8 @@ import org.tizen.common.CommonPlugin;
 import org.tizen.common.TizenPlatformConstants;
 import org.tizen.common.sdb.command.SdbCommand;
 import org.tizen.common.sdb.command.message.PkgcmdErrorType;
-import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.sdb.command.receiver.PkgCmdReceiver;
+import org.tizen.common.ui.view.console.ITizenConsoleManager;
 import org.tizen.common.util.ISdbCommandHelper;
 import org.tizen.common.util.log.Logger;
 import org.tizen.sdblib.IDevice;
@@ -55,7 +56,7 @@ import org.tizen.sdblib.SyncService.SyncResult;
  */
 public abstract class RdsDeployer implements Closeable{
     protected IProgressMonitor monitor;
-    protected ConsoleManager console;
+    protected ITizenConsoleManager console;
     protected String pkgType;
     protected String strAppInstallPath;
     protected IProject project;
@@ -66,7 +67,7 @@ public abstract class RdsDeployer implements Closeable{
     protected List<DeltaResourceInfo> ignoreList = new ArrayList<DeltaResourceInfo>();
     protected List<DeltaResourceInfo> interestList = new ArrayList<DeltaResourceInfo>();
     private SyncService syncService;
-    private final static String[] needAppOwnerArray = new String[] {"/data", "/shared/data", "/shared/trusted", "/setting"};
+//    private final static String[] needAppOwnerArray = new String[] {"/data", "/shared/data", "/shared/trusted", "/setting"};
     // deltaInfoList should be set only once.
     private List<DeltaResourceInfo> deltaInfoList = null;
     // strDeltaInfoFile should be set when deltaInfoList is set.
@@ -95,7 +96,7 @@ public abstract class RdsDeployer implements Closeable{
      */
     public abstract boolean deploy() throws CoreException;
     
-    public RdsDeployer( IProject project, IDevice device, ISdbCommandHelper tizenCommand, ConsoleManager console, String pkgType, IProgressMonitor monitor) {
+    public RdsDeployer( IProject project, IDevice device, ISdbCommandHelper tizenCommand, ITizenConsoleManager console, String pkgType, IProgressMonitor monitor) {
         this.project = project;
         this.device = device;
         this.tizenCommand = tizenCommand;
@@ -242,10 +243,8 @@ public abstract class RdsDeployer implements Closeable{
         List<DeltaResourceInfo> delta = new ArrayList<DeltaResourceInfo>();
         String strProjectPath = project.getLocation().toString();
         String strRemotePath = "";
-        DeltaResourceInfo interestNode = null;
         
         for ( DeltaResourceInfo node : deltaInfoList ) {
-            interestNode = null;
             if ( containsNode(node, ignoreList, strProjectPath) != null ) {
                 continue;
             }
@@ -286,7 +285,7 @@ public abstract class RdsDeployer implements Closeable{
     }
     
     protected void postInstall() throws CoreException {
-        SdbCommand sdbCommand = new SdbCommand(device, console);
+        SdbCommand sdbCommand = new SdbCommand(device, console, new PkgCmdReceiver(console));
 
         try {
             String installCommand = String.format(TizenPlatformConstants.PKG_TOOL_REINSTALL_COMMAND, pkgType.toLowerCase(), getPkgId());
index 267d6b2..c999011 100644 (file)
@@ -8,8 +8,18 @@ import org.tizen.common.util.StringUtil;
 public class PkgCmdReceiver extends CommandOutputReceiver {
     private String PKGCMD_CB_KEY_ABOUT_KEY = "key";
     private String PKGCMD_CB_KEY_ABOUT_VALUE = "val";
-    private String lastOutput = null;
+    private String oldOutput = "";
+
+    private static String RETURN_CB_PREFIX = "__return_cb";
+    private static String RETURN_CB_START = "start";
+    private static String RETURN_CB_END = "end";
+    private static String RETURN_CB_INSTALL_PERCENT = "install_percent";
+    private static String RETURN_CB_UNINSTALL_PERCENT = "uninstall_percent";
+    private static String OUTPUT_INSTALL_START = "installing...";
+    private static String OUTPUT_UNINSTALL_START = "uninstalling...";
+    private static String OUTPUT_ING = ".";
     
+
     public PkgCmdReceiver(ITizenConsoleManager console) {
         super(console);
     }
@@ -17,14 +27,12 @@ public class PkgCmdReceiver extends CommandOutputReceiver {
     @Override
     public void processNewLines(String[] lines) {
         for( String line: lines ) {
-            String output = getMeaningfulOutput(line);
+            String output = getMeaningfulOutput(line, oldOutput);
             if (console != null 
                     && output != null
-                    && !output.isEmpty()
-                    && !output.equals(lastOutput)) {
-                //FIXME: below white space should be removed.
-                console.println("     " + output);
-                lastOutput=output;
+                    && !output.isEmpty()) {
+                console.print(output);
+                oldOutput=output;
             }
             
             commandOutput.append(line);
@@ -33,28 +41,46 @@ public class PkgCmdReceiver extends CommandOutputReceiver {
         endLine = lines[lines.length - 1];
     }
 
-    private String getMeaningfulOutput(String line) {
-        String result = null;
-        String[] elements = StringUtil.split(line, " ");
-
-        if (line.startsWith("__return_cb")) {
+    private String getMeaningfulOutput(String output, String lastMeaningfulOutput) {
+        String meaningfulOutput = null;
+        String[] elements = StringUtil.split(output, " ");
 
+        if (output.startsWith(RETURN_CB_PREFIX)) {
             String key = getValue(elements, PKGCMD_CB_KEY_ABOUT_KEY);
             String value = getValue(elements, PKGCMD_CB_KEY_ABOUT_VALUE);
 
-            if ("start".equals(key)||"end".equals(key)) {
-                result = key + " process ("
+            if (RETURN_CB_START.equals(key)) {
+                meaningfulOutput = key + " process ("
+                        + getValue(elements, PKGCMD_CB_KEY_ABOUT_VALUE)
+                        + ")\n";
+            } else if (RETURN_CB_END.equals(key)) {
+                meaningfulOutput = "\n" + key + " process ("
                              + getValue(elements, PKGCMD_CB_KEY_ABOUT_VALUE)
-                             + ")";
+                             + ")\n";
+            } else if(RETURN_CB_INSTALL_PERCENT.equals(key)) {
+                if (lastMeaningfulOutput.startsWith(OUTPUT_INSTALL_START)
+                        || lastMeaningfulOutput.startsWith(OUTPUT_ING)) {
+                    meaningfulOutput = OUTPUT_ING;
+                } else {
+                    meaningfulOutput = OUTPUT_INSTALL_START;
+                }
+            } else if (RETURN_CB_UNINSTALL_PERCENT.equals(key)) {
+                if (lastMeaningfulOutput.startsWith(OUTPUT_UNINSTALL_START)
+                        || lastMeaningfulOutput.startsWith(OUTPUT_ING)) {
+                    meaningfulOutput = OUTPUT_ING;
+                } else {
+                    meaningfulOutput = OUTPUT_UNINSTALL_START;
+                }
             } else {
-                result = key
+                meaningfulOutput = "\n" + key
                         + " : "
-                        + value;
+                        + value
+                        + "\n";
             }
         } else {
-            result = line;
+            meaningfulOutput = output + "\n";
         }
-        return result;
+        return meaningfulOutput;
     }
 
     private String getValue(String[] elements, String key) {
index ddf6a95..a9b0429 100755 (executable)
@@ -312,5 +312,16 @@ implements ITizenConsoleManager
             setStringStyle(this.fontStyle, this.color);
         }
     }
+
+    @Override
+    public void print(String line) {
+        MessageConsoleStream output = this.console.newMessageStream();
+        output.print(line);
+        try {
+            output.close();
+        } catch (IOException e) {
+             ConsolePlugin.log(e);
+        }
+    }
 }
 
index 5a810f0..ebdecc7 100755 (executable)
@@ -31,6 +31,8 @@ import static org.tizen.common.util.SWTUtil.getActivePage;
 import static org.tizen.common.util.SWTUtil.syncExec;
 import static org.tizen.common.util.IOUtil.tryClose;
 
+import java.io.IOException;
+
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.ui.IWorkbenchPage;
@@ -406,5 +408,15 @@ implements ITizenConsoleManager, IHyperlinkManager
                hyperlinkManager.addLinker( link );
        }
 
+    @Override
+    public void print(String line) {
+        MessageConsoleStream output = this.console.newMessageStream();
+        output.print(line);
+        try {
+            output.close();
+        } catch (IOException e) {
+             ConsolePlugin.log(e);
+        }
+    }
 }
 
index 66741b7..4e7ad83 100644 (file)
@@ -5,6 +5,7 @@ import org.eclipse.ui.console.IConsole;
 
 public interface ITizenConsoleManager extends IConsolePrinter {
     public IConsole getConsole();
+    public void print(String line);
     public void println(String line);
     public void println(String message, int fontStyle, Color color);
     public void printProcessStreams(Process process);