From 1275647971a5eeb2a3509d6be791e88cbca32349 Mon Sep 17 00:00:00 2001 From: "hyunsik.noh" Date: Thu, 2 Feb 2012 10:41:29 +0900 Subject: [PATCH] [Title] fix again - Add error dialog message occurred when do file operation on real device Change-Id: I64aa28923d664724266aff7c6ae8ba79ce8dd932 --- .../explorer/ConnectionExplorerPanel.java | 51 ++++++++++++---------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java index d8fc68f..9b41c4b 100644 --- a/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java +++ b/com.samsung.tizen.common.connection/src/com/samsung/tizen/common/connection/explorer/ConnectionExplorerPanel.java @@ -83,7 +83,6 @@ import com.samsung.tizen.common.log.Logger; import com.samsung.tizen.sdblib.FileListingService; import com.samsung.tizen.sdblib.FileListingService.FileEntry; import com.samsung.tizen.sdblib.IDevice; -import com.samsung.tizen.sdblib.IShellOutputReceiver; import com.samsung.tizen.sdblib.MultiLineReceiver; import com.samsung.tizen.sdblib.SmartDevelopmentBridge; import com.samsung.tizen.sdblib.SmartDevelopmentBridge.IDebugBridgeChangeListener; @@ -102,6 +101,7 @@ public class ConnectionExplorerPanel extends Panel private static final String INVALID_FOR_FILENAME = ";"; private static final String COLUMN_NAME = "name"; //$NON-NLS-1S + private static final String CMD_RESULT_CHECK = "; echo $?"; private Composite parent; private TreeViewer treeViewer; @@ -442,16 +442,18 @@ public class ConnectionExplorerPanel extends Panel final FileEntry parentEntry = ((FileEntry) items[0].getData()) .getParent(); // create the touch command - String command = "touch " + fullPath + PATH_SEPARATOR + addNewDialog.getValue(); //$NON-NLS-1$ + String command = "touch " + fullPath + PATH_SEPARATOR + addNewDialog.getValue() + CMD_RESULT_CHECK; //$NON-NLS-1$ try { mCurrentDevice.executeShellCommand(command, new MultiLineReceiver() { @Override - public void processNewLines(String[] arg0) { + public void processNewLines(String[] lines) { + if(!lines[lines.length - 1].contains("0")) + { StringBuilder sb = new StringBuilder(); - for (String line : arg0) { + for (String line : lines) { line = AnsicodeAdapter.getStripAnsiString(line); sb.append(line); @@ -462,6 +464,7 @@ public class ConnectionExplorerPanel extends Panel } + } }); } catch (IOException e) { Logger.error("failed to do add new file", e); @@ -487,15 +490,17 @@ public class ConnectionExplorerPanel extends Panel final FileEntry parentEntry = ((FileEntry) items[0].getData()) .getParent(); // create the mkdir command - String command = "mkdir " + fullPath + PATH_SEPARATOR + addNewDialog.getValue(); //$NON-NLS-1$ + String command = "mkdir " + fullPath + PATH_SEPARATOR + addNewDialog.getValue() + CMD_RESULT_CHECK; //$NON-NLS-1$ try { mCurrentDevice.executeShellCommand(command, new MultiLineReceiver() { @Override - public void processNewLines(String[] arg0) { + public void processNewLines(String[] lines) { + if(!lines[lines.length - 1].contains("0")) + { StringBuilder sb = new StringBuilder(); - for (String line : arg0) { + for (String line : lines) { line = AnsicodeAdapter.getStripAnsiString(line); sb.append(line); @@ -503,8 +508,7 @@ public class ConnectionExplorerPanel extends Panel Status status = new Status(IStatus.ERROR, "Add Folder Failed", 0, sb.toString() , null); ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Add Folder Failed", "A folder failed to be added", status); - - + } } }); } catch (IOException e) { @@ -534,16 +538,18 @@ public class ConnectionExplorerPanel extends Panel final FileEntry parentEntry = ((FileEntry) items[0].getData()) .getParent(); // create the mv command - String command = "mv " + fullPath + " " + newPath; //$NON-NLS-1$ + String command = "mv " + fullPath + " " + newPath + CMD_RESULT_CHECK; //$NON-NLS-1$ try { mCurrentDevice.executeShellCommand(command, new MultiLineReceiver() { @Override - public void processNewLines(String[] arg0) { + public void processNewLines(String[] lines) { + if(!lines[lines.length - 1].contains("0")) + { StringBuilder sb = new StringBuilder(); - for (String line : arg0) { + for (String line : lines) { line = AnsicodeAdapter.getStripAnsiString(line); sb.append(line); @@ -551,8 +557,7 @@ public class ConnectionExplorerPanel extends Panel Status status = new Status(IStatus.ERROR, "Rename failed", 0, sb.toString() , null); ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Rename failed", "A selection failed to be renamed",status); - - + } } }); } catch (IOException e) { @@ -575,9 +580,9 @@ public class ConnectionExplorerPanel extends Panel String command = null; // create the delete command if (entry.isDirectory()) { - command = "rm -rf " + entry.getFullEscapedPath(); //$NON-NLS-1$ + command = "rm -rf " + entry.getFullEscapedPath() + CMD_RESULT_CHECK; //$NON-NLS-1$ } else { - command = "rm " + entry.getFullEscapedPath(); //$NON-NLS-1$ + command = "rm " + entry.getFullEscapedPath() + CMD_RESULT_CHECK; //$NON-NLS-1$ } try { @@ -585,18 +590,18 @@ public class ConnectionExplorerPanel extends Panel new MultiLineReceiver() { @Override - public void processNewLines(String[] arg0) { + public void processNewLines(String[] lines) { + if(!lines[lines.length - 1].contains("0")) + { StringBuilder sb = new StringBuilder(); - for (String line : arg0) { + for (String line : lines) { line = AnsicodeAdapter.getStripAnsiString(line); - sb.append(line); - - } + sb.append(line); + } Status status = new Status(IStatus.ERROR, "Delete Failed", 0, sb.toString() , null); ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Delete failed", "A selection failed to be deleted", status); - - + } } }); } catch (IOException e) { -- 2.7.4