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;
*/
public abstract class RdsDeployer implements Closeable{
protected IProgressMonitor monitor;
- protected ConsoleManager console;
+ protected ITizenConsoleManager console;
protected String pkgType;
protected String strAppInstallPath;
protected IProject project;
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.
*/
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;
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;
}
}
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());
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);
}
@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);
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) {
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);
+ }
+ }
}
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;
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);
+ }
+ }
}
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);