[Title] binary analysis fixed
authorjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 7 Nov 2013 10:39:37 +0000 (19:39 +0900)
committerjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 7 Nov 2013 10:39:37 +0000 (19:39 +0900)
[Desc.]
[Issue]

19 files changed:
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.sh [new file with mode: 0644]
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm_extractor.sh [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerPaths.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/PathManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/communicator/CommunicatorUtils.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingData.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinaryAddDialog.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinaryAnalyzingConfigDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DAFileExplorer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/DAFileExplorerRenderer.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/InputRow.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/LoadSettingDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/SaveSettingDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/utils/AnalyzerUtil.java

diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.sh b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/find.sh
new file mode 100644 (file)
index 0000000..0d384b0
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cd $1
+find . -name $2
diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm_extractor.sh b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/rpm_extractor.sh
new file mode 100644 (file)
index 0000000..abe7c61
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+echo $1
+echo $2
+echo $3
+
+cd $1
+rpm2cpio $2 | cpio -imd
+rpm2cpio $3 | cpio -imd
+
+
index b614202..05573c7 100644 (file)
@@ -38,10 +38,12 @@ public class AnalyzerConstants {
 \r
        /* folder names */\r
        public static final String TOOLS_FOLDER_NAME = "tools"; //$NON-NLS-1$\r
+       public static final String TOOL_FOLDER_NAME = "tool"; //$NON-NLS-1$\r
        public static final String TARGET_FOLDER_NAME = "target"; //$NON-NLS-1$\r
        public static final String DYNAMIC_ANALYZER_FOLDER_NAME = "dynamic-analyzer"; //$NON-NLS-1$\r
        public static final String SAVE_FOLDER_NAME = "save"; //$NON-NLS-1$\r
        public static final String SETTING_FOLDER_NAME = "setting"; //$NON-NLS-1$\r
+       public static final String RPM_FOLDER_NAME = "rpms"; //$NON-NLS-1$\r
        public static final String PLATFORM_FOLDER_NAME = "platforms"; //$NON-NLS-1$\r
        public static final String LOGS_FOLDER_NAME = "logs"; //$NON-NLS-1$\r
        public static final String TEMP_FOLDER_NAME = "temp"; //$NON-NLS-1$\r
index dcc546f..81020b1 100644 (file)
@@ -38,13 +38,15 @@ public class AnalyzerPaths {
                        .getSavePath();
        public static final String DYNAMIC_ANALYZER_SETTING_PATH = PathManager
                        .getBinarySettingPath();
+       public static final String DYNAMIC_ANALYZER_RPM_PATH = PathManager
+                       .getRPMPath();
        public static final String DYNAMIC_ANALYZER_AUTOTEST_PATH = TIZEN_SDK_DATA_PATH
                        + File.separator
                        + "test"
                        + File.separator
                        + AnalyzerConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
        public static final String TOOL_FOLDER_PATH = DYNAMIC_ANALYZER_INSTALL_PATH
-                       + File.separator + AnalyzerConstants.TOOLS_FOLDER_NAME;
+                       + File.separator + AnalyzerConstants.TOOL_FOLDER_NAME;
        public static final String TEMP_FOLDER_PATH = DYNAMIC_ANALYZER_SAVE_PATH
                        + File.separator + AnalyzerConstants.TEMP_FOLDER_NAME;
        public static final String CONFIG_FOLDER_PATH = PathManager
index 17f1e86..bf43310 100755 (executable)
@@ -199,13 +199,23 @@ public class PathManager {
        }
 
        public static String getBinarySettingPath() {
-               String savePath = AnalyzerPaths.TIZEN_SDK_DATA_PATH;
-               if (null != savePath) {
-                       savePath += File.separator
+               String settingPath = AnalyzerPaths.TIZEN_SDK_DATA_PATH;
+               if (null != settingPath) {
+                       settingPath += File.separator
                                        + AnalyzerConstants.DYNAMIC_ANALYZER_FOLDER_NAME
                                        + File.separator + AnalyzerConstants.SETTING_FOLDER_NAME;
                }
-               return savePath;
+               return settingPath;
+       }
+       
+       public static String getRPMPath() {
+               String rpmPath = AnalyzerPaths.TIZEN_SDK_DATA_PATH;
+               if (null != rpmPath) {
+                       rpmPath += File.separator
+                                       + AnalyzerConstants.DYNAMIC_ANALYZER_FOLDER_NAME
+                                       + File.separator + AnalyzerConstants.RPM_FOLDER_NAME;
+               }
+               return rpmPath;
        }
        
        public static String getLogPath() {
index dec13c3..418090a 100755 (executable)
@@ -299,6 +299,8 @@ public class CommunicatorUtils {
                int count = 0;
                int remotePort = -1;
                // add error check
+               System.out.print("Getting Port Progress \n ");
+               int ii = 0;
                while (count < PORT_WAIT_TIME) {
                        try {
                                execShellCommand(device,
@@ -314,21 +316,20 @@ public class CommunicatorUtils {
                                                });
                                if (!portLines.isEmpty()) {
                                        String line = portLines.get(0);
-                                       System.out.println("port : " + line);
                                        try {
                                                remotePort = Integer.parseInt(line);
-                                               System.out
-                                                               .println("port get success!! : " + remotePort);
+                                               System.out.println(" !! \nport get success!! : "
+                                                               + remotePort);
                                                break;
                                        } catch (NumberFormatException e) {
-                                               System.out.print("port is invalid...");
+                                                System.out.print("=");
                                        }
                                }
                                count++;
-                               System.out.print("wait for port..");
-                               Thread.sleep(1);
+                               Thread.sleep(10);
                        } catch (InterruptedException e) {
-                               e.printStackTrace();
+                               // e.printStackTrace();
+                               System.out.println("Interrupt occurred - Getting port number");
                                break;
                        }
                }
index 7b67836..4b0afa6 100644 (file)
@@ -392,9 +392,9 @@ public class TableTooltipListener implements Listener {
                        if (data instanceof UserFunctionData) {\r
                                addr = ((UserFunctionData) data).getCallerPcAddr();\r
                        } else if (data instanceof ProfileData) {\r
-//                             addr = ((ProfileData) data).getPcAddr();\r
+                               // addr = ((ProfileData) data).getPcAddr();\r
                                // config\r
-                                addr = ((ProfileData) data).getCallerPcAddr();\r
+                               addr = ((ProfileData) data).getCallerPcAddr();\r
                        }\r
                        pid = data.getPid();\r
                        time = data.getTime();\r
@@ -420,7 +420,19 @@ public class TableTooltipListener implements Listener {
 \r
                String baseAddr = Long.toString(AnalyzerManager.getProject()\r
                                .getBaseAddress(pid, time));\r
-               String path = binInfo.getSourceBinaryPath();\r
+               String path = null;\r
+               BinarySettingData binData = BinarySettingManager.getInstance()\r
+                               .getBinarySetting(binInfo.getTargetBinaryPath());\r
+               if (null != binData) {\r
+                       String debugPath = binData.getDebugFilePath();\r
+                       if (null != debugPath && !debugPath.isEmpty()) {\r
+                               path = debugPath;\r
+                       } else {\r
+                               path = binInfo.getSourceBinaryPath();\r
+                       }\r
+               } else {\r
+                       path = binInfo.getSourceBinaryPath();\r
+               }\r
                SourceLine sl = SymbolManager.addr2line(path, addr, isPieBuild,\r
                                baseAddr);\r
                return sl;\r
index 23ea503..57fe9f9 100755 (executable)
@@ -617,7 +617,6 @@ public class Communicator30 extends BaseCommunicator {
                HostResult result = handleControlMessage(device,
                                ByteUtils.getByte(AnalyzerConstants.MSG_TARGET_INFO, 0));
                if (result.isSuccess()) {
-                       System.out.println("target info message ack :" + result.getRet());
                        // FIXME : log parsing
                        byte[] data = result.getRet();
                        int index = INT_SIZE * 3;
index 25270a2..65d01b8 100755 (executable)
@@ -55,6 +55,7 @@ import org.tizen.dynamicanalyzer.swap.model.DATime;
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;
 import org.tizen.dynamicanalyzer.swap.model.data.LogDataFactory;
 import org.tizen.dynamicanalyzer.swap.model.data.LogDataUtils;
+import org.tizen.dynamicanalyzer.swap.model.data.ProbeCommonData;
 import org.tizen.dynamicanalyzer.ui.toolbar.StopLogProcessor;
 import org.tizen.dynamicanalyzer.ui.toolbar.StopProcessManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
@@ -313,12 +314,16 @@ public class MessageParser {
                        System.out.println("MAP CHANGED    ADD  "
                                        + AnalyzerUtil.toHexdecimal(id) + "  libPath : " + libPath
                                        + "    low : " + AnalyzerUtil.toHexdecimal(lowAddr)
-                                       + "    high: " + AnalyzerUtil.toHexdecimal(highAddr) + "  chage time : " + changeTime.getSaveFormat() + "  total count : " + pInfo.getLibObjs().size());
+                                       + "    high: " + AnalyzerUtil.toHexdecimal(highAddr)
+                                       + "  chage time : " + changeTime.getSaveFormat()
+                                       + "  total count : " + pInfo.getLibObjs().size());
                } else {
                        System.out.println("MAP CHANGED REMOVE  "
                                        + AnalyzerUtil.toHexdecimal(id) + "  libPath : " + libPath
                                        + "  low : " + AnalyzerUtil.toHexdecimal(lowAddr)
-                                       + "    high: " + AnalyzerUtil.toHexdecimal(highAddr) + "  chage time : " + changeTime.getSaveFormat()+ "  total count : " + pInfo.getDepLibCount());
+                                       + "    high: " + AnalyzerUtil.toHexdecimal(highAddr)
+                                       + "  chage time : " + changeTime.getSaveFormat()
+                                       + "  total count : " + pInfo.getDepLibCount());
 
                        int size = libObjs.size();
                        for (int i = 0; i < size; i++) {
@@ -525,6 +530,12 @@ public class MessageParser {
                        if (AnalyzerManager.isProcessInfoArrived() && id > 0x0100
                                        && id < 0x0200) {
                                log = LogDataFactory.createInstance(data);
+
+                               if (log.getId() == DataChannelConstants.MSG_PROBE_MEMORY) {
+                                       ProbeCommonData pdata = (ProbeCommonData) log;
+                                       System.out.println("memory log : " + pdata.getApiName()
+                                                       + " internal type : " + pdata.getInternalCall());
+                               }
                                if (null != log) {
                                        buffer.add(log);
                                        messageCount++;
index 46c29d8..f35bb50 100644 (file)
@@ -30,6 +30,9 @@ import org.tizen.dynamicanalyzer.common.CommonConstants;
 public class BinarySettingData {
        private String binaryPath = null;
        private String sourcePath = null;
+       private String debugPath = null;
+       private String debugFilePath = null;
+       private String rpmSourcePath = null;
 
        public String getBinaryPath() {
                return binaryPath;
@@ -64,4 +67,29 @@ public class BinarySettingData {
                }
                return false;
        }
+
+       public String getDebugPath() {
+               return debugPath;
+       }
+
+       public void setDebugPath(String debugPath) {
+               this.debugPath = debugPath;
+       }
+
+       public String getRpmSourcePath() {
+               return rpmSourcePath;
+       }
+
+       public void setRpmSourcePath(String rpmSourcePath) {
+               this.rpmSourcePath = rpmSourcePath;
+       }
+
+       public String getDebugFilePath() {
+               return debugFilePath;
+       }
+
+       public void setDebugFilePath(String debugFilePath) {
+               this.debugFilePath = debugFilePath;
+       }
+
 }
index 09c6a42..56f82aa 100644 (file)
  */
 package org.tizen.dynamicanalyzer.swap.platform;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+import org.tizen.dynamicanalyzer.common.PathManager;
 import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo;
 import org.tizen.dynamicanalyzer.swap.platform.ui.InputRow;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 
 public class BinarySettingManager {
 
@@ -75,6 +83,191 @@ public class BinarySettingManager {
                binarySettings.addAll(data);
        }
 
+       public void checkSourcePath() {
+               int size = binarySettings.size();
+               for (int i = 0; i < size; i++) {
+                       BinarySettingData binData = binarySettings.get(i);
+                       if (null != binData.getDebugPath()
+                                       && !binData.getDebugPath().isEmpty()) {
+                               // check dir exists.
+                               String sourcePath = binData.getDebugPath();
+                               File sourceDir = new File(sourcePath);
+                               String[] files = sourceDir.list();
+
+                               if (!sourceDir.exists() || !sourceDir.isDirectory()) {
+                                       continue;
+                               }
+                               if (files.length == 0) {
+                                       continue;
+                               }
+                               // check rpm file exists
+                               String targetLibPath = binData.getBinaryPath();
+                               String[] splitTargetLib = targetLibPath
+                                               .split(CommonConstants.SLASH);
+                               String libFullName = splitTargetLib[splitTargetLib.length - 1];
+                               int index = libFullName.indexOf(".so");
+                               // 3 means remove "lib" string
+                               String debugInfoToken = libFullName.substring(3, index)
+                                               + "-debuginfo";
+                               String debugSourceToken = libFullName.substring(3, index)
+                                               + "-debugsource";
+
+                               String debugInfoRpmName = null;
+                               String debugInfoSourceRpmName = null;
+                               for (int j = 0; j < files.length; j++) {
+                                       if (files[j].contains(debugInfoToken)) {
+                                               debugInfoRpmName = files[j];
+                                               break;
+                                       }
+                               }
+
+                               if (null == binData.getDebugPath()
+                                               || binData.getDebugPath().isEmpty()) {
+                                       continue;
+                               }
+
+                               for (int j = 0; j < files.length; j++) {
+                                       if (files[j].contains(debugSourceToken)) {
+                                               debugInfoSourceRpmName = files[j];
+                                               break;
+                                       }
+                               }
+
+                               // copy rpm file
+                               String rpmPath = PathManager.getRPMPath() + File.separator
+                                               + libFullName;
+                               File rpms = new File(rpmPath);
+                               if (!rpms.exists()) {
+                                       rpms.mkdirs();
+                               }
+
+                               String from = sourcePath + File.separator + debugInfoRpmName;
+                               String to = rpmPath + File.separator + debugInfoRpmName;
+                               String debugRpmPath = null;
+                               String debugRpmSourcePath = null;
+                               if (AnalyzerUtil.copyFile(from, to)) {
+                                       debugRpmPath = to;
+                               }
+
+                               if (null != debugInfoSourceRpmName
+                                               && !debugInfoSourceRpmName.isEmpty()) {
+                                       from = sourcePath + File.separator + debugInfoSourceRpmName;
+                                       to = rpmPath + File.separator + debugInfoSourceRpmName;
+                                       if (AnalyzerUtil.copyFile(from, to)) {
+                                               debugRpmSourcePath = to;
+                                       }
+                               }
+
+                               // extract rpm file
+                               if (null != debugRpmPath) {
+                                       String toolPath = AnalyzerPaths.TOOL_FOLDER_PATH
+                                                       + File.separator + "rpm_extractor.sh";
+                                       String[] command = new String[] { toolPath, rpmPath,
+                                                       debugRpmPath, debugRpmSourcePath };
+                                       try {
+                                               Runtime rt = Runtime.getRuntime();
+                                               Process process = rt.exec(command);
+                                               process.waitFor();
+                                               BufferedReader reader = new BufferedReader(
+                                                               new InputStreamReader(process.getInputStream()));
+                                               String line = null;
+                                               int lineCount = 0;
+                                               while (null != (line = reader.readLine())) {
+                                                       lineCount++;
+                                                       if (lineCount == 1) {
+                                                               System.out.println("CHANGE DIR : " + line);
+                                                       } else {
+                                                               System.out.println("EXTRACE RPM : " + line);
+                                                       }
+                                               }
+                                               if (lineCount == 0) {
+                                                       BufferedReader error = new BufferedReader(
+                                                                       new InputStreamReader(
+                                                                                       process.getErrorStream()));
+                                                       String errorStr = error.readLine();
+                                                       System.out.println("host md5sum get failed : "
+                                                                       + errorStr);
+                                                       continue;
+                                               }
+                                       } catch (IOException e) {
+                                               e.printStackTrace();
+                                               continue;
+                                       } catch (InterruptedException e) {
+                                               e.printStackTrace();
+                                               continue;
+                                       }
+                               }
+
+                               // check real debug file path
+                               String libPostFix = libFullName.substring(index,
+                                               libFullName.length());
+                               String libVersion = libPostFix
+                                               .substring(4, libPostFix.length());
+                               String debugCmd = AnalyzerPaths.TOOL_FOLDER_PATH
+                                               + File.separator + "find.sh " + rpmPath + " " + "*"
+                                               + libPostFix + ".debug";
+                               String debugFilePath = null;
+                               try {
+                                       Runtime rt = Runtime.getRuntime();
+                                       Process process = rt.exec(debugCmd);
+                                       process.waitFor();
+                                       BufferedReader reader = new BufferedReader(
+                                                       new InputStreamReader(process.getInputStream()));
+                                       String line = reader.readLine();
+                                       if (null == line) {
+                                               BufferedReader error = new BufferedReader(
+                                                               new InputStreamReader(process.getErrorStream()));
+                                               String errorStr = error.readLine();
+                                               System.out.println("host md5sum get failed : "
+                                                               + errorStr);
+                                               continue;
+                                       }
+                                       debugFilePath = rpmPath + line.substring(1, line.length());
+                                       System.out.println("DEBUG PATH : " + debugFilePath);
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                                       continue;
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                                       continue;
+                               }
+                               binData.setDebugFilePath(debugFilePath);
+
+                               // check real source file path
+                               String sourceFilePath = null;
+                               String sourceCmd = AnalyzerPaths.TOOL_FOLDER_PATH
+                                               + File.separator + "find.sh " + rpmPath + " " + "*"
+                                               + libVersion;
+                               try {
+                                       Runtime rt = Runtime.getRuntime();
+                                       Process process = rt.exec(sourceCmd);
+                                       process.waitFor();
+                                       BufferedReader reader = new BufferedReader(
+                                                       new InputStreamReader(process.getInputStream()));
+                                       String line = reader.readLine();
+                                       if (null == line) {
+                                               BufferedReader error = new BufferedReader(
+                                                               new InputStreamReader(process.getErrorStream()));
+                                               String errorStr = error.readLine();
+                                               System.out.println("host md5sum get failed : "
+                                                               + errorStr);
+                                               continue;
+                                       }
+                                       sourceFilePath = rpmPath + line.substring(1, line.length());
+                                       System.out.println("SOURCE PATH : " + sourceFilePath);
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                                       continue;
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                                       continue;
+                               }
+                               binData.setSourcePath(sourceFilePath);
+                       }
+               }
+
+       }
+
        public HashMap<String, InputRow> getInputRowHash() {
                return inputRowHash;
        }
@@ -165,4 +358,17 @@ public class BinarySettingManager {
                return localBinInfoMap;
        }
 
+       public BinarySettingData getBinarySetting(String targetBinaryPath) {
+               List<BinarySettingData> binaries = getBinarySettings();
+               int size = binaries.size();
+
+               BinarySettingData binData = null;
+               for (int i = 0; i < size; i++) {
+                       if (targetBinaryPath.equals(binaries.get(i).getBinaryPath())) {
+                               binData = binaries.get(i);
+                               break;
+                       }
+               }
+               return binData;
+       }
 }
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinaryAddDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/BinaryAddDialog.java
new file mode 100644 (file)
index 0000000..e2cc709
--- /dev/null
@@ -0,0 +1,233 @@
+package org.tizen.dynamicanalyzer.swap.platform.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+import org.tizen.dynamicanalyzer.common.DesignConstants;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
+import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.sdblib.service.FileEntry;
+
+public class BinaryAddDialog extends DAMessageBox {
+
+       private Text binary = null;
+       // private Text source = null;
+       private Text debugPackage = null;
+
+       private DAButton findButton = null;
+       private DAButton okButton = null;
+       private DAButton cancelButton = null;
+
+       private String binaryStr = CommonConstants.EMPTY;
+       private String debutStr = CommonConstants.EMPTY;
+
+       public BinaryAddDialog(Shell parentShell) {
+               super(parentShell);
+       }
+
+       public BinaryAddDialog(Shell parentShell, String binary, String debug) {
+               super(parentShell);
+
+               binaryStr = binary;
+               debutStr = debug;
+       }
+
+       private DACustomButtonClickEventListener findButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       FileExplorerDialog dialog = new FileExplorerDialog(shell);
+                       Object result = dialog.open();
+                       if (result != null) {
+                               FileEntry entry = (FileEntry) result;
+                               binary.setText(entry.getFullPath());
+                       }
+               }
+       };
+
+       private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       List<String> paths = new ArrayList<String>();
+                       paths.add(binary.getText());
+                       paths.add(debugPackage.getText());
+                       result = paths;
+                       shell.dispose();
+               }
+       };
+
+       private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       shell.dispose();
+               }
+       };
+
+       private KeyListener binaryKeyListener = new KeyListener() {
+
+               @Override
+               public void keyReleased(KeyEvent e) {
+                       if (binary.getText().isEmpty()) {
+                               okButton.setButtonEnabled(false);
+                       } else {
+                               okButton.setButtonEnabled(true);
+                       }
+               }
+
+               @Override
+               public void keyPressed(KeyEvent e) {
+
+               }
+       };
+
+       protected boolean run() {
+               shell.setLayout(new FormLayout());
+               shell.setSize(446, 240);
+               shell.setBackground(ColorResources.DIALOG_BG_UPPER);
+               shell.setText("Add Binary Setting");
+
+               Label label = new Label(shell, SWT.TRANSPARENT);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(0, 12);
+               data.height = 15;
+               data.width = 150;
+               label.setLayoutData(data);
+               label.setForeground(ColorResources.BLACK);
+               label.setText("Binary Path");
+               label.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+               binary = new Text(shell, SWT.SINGLE);
+               data = new FormData();
+               data.top = new FormAttachment(label, 10);
+               data.left = new FormAttachment(0, 12);
+               data.height = 26;
+               data.width = 350;
+               binary.setLayoutData(data);
+               binary.setBackground(ColorResources.VIEW_BG_COLOR);
+               binary.addKeyListener(binaryKeyListener);
+               binary.setText(binaryStr);
+
+               findButton = new DAButton(shell, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(label, 10);
+               data.left = new FormAttachment(binary, 5);
+               data.height = 30;
+               data.width = 50;
+               findButton.setLayoutData(data);
+               findButton.setText("Find");
+               findButton.addClickListener(findButtonListener);
+
+               // Label sourceLabel = new Label(shell, SWT.TRANSPARENT);
+               // data = new FormData();
+               // data.top = new FormAttachment(binary, 15);
+               // data.left = new FormAttachment(0, 12);
+               // data.height = 15;
+               // data.width = 150;
+               // sourceLabel.setLayoutData(data);
+               // sourceLabel.setForeground(ColorResources.BLACK);
+               // sourceLabel.setText("Source Path");
+               // sourceLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+               //
+               // source = new Text(shell, SWT.SINGLE);
+               // data = new FormData();
+               // data.top = new FormAttachment(sourceLabel, 10);
+               // data.left = new FormAttachment(0, 12);
+               // data.height = 26;
+               // data.width = 350;
+               // source.setLayoutData(data);
+               // source.setBackground(ColorResources.VIEW_BG_COLOR);
+
+               Label debugLabel = new Label(shell, SWT.TRANSPARENT);
+               data = new FormData();
+               data.top = new FormAttachment(binary, 15);
+               data.left = new FormAttachment(0, 12);
+               data.height = 15;
+               data.width = 150;
+               debugLabel.setLayoutData(data);
+               debugLabel.setForeground(ColorResources.BLACK);
+               debugLabel.setText("Debug package Path");
+               debugLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+               debugPackage = new Text(shell, SWT.SINGLE);
+               data = new FormData();
+               data.top = new FormAttachment(debugLabel, 10);
+               data.left = new FormAttachment(0, 12);
+               data.height = 26;
+               data.width = 350;
+               debugPackage.setLayoutData(data);
+               debugPackage.setBackground(ColorResources.VIEW_BG_COLOR);
+               debugPackage.setText(debutStr);
+
+               Composite buttonComp = new Composite(shell, SWT.NONE);
+               buttonComp.setLayout(new FormLayout());
+               buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
+
+               buttonComp.addPaintListener(new PaintListener() {
+
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               Composite comp = (Composite) e.widget;
+                               Rectangle rect = comp.getClientArea();
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
+                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
+                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
+                                               rect.y + 1);
+                       }
+               });
+
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(debugPackage, 20);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.bottom = new FormAttachment(100, 0);
+               buttonComp.setLayoutData(compData);
+
+               okButton = new DAButton(buttonComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(50, -DesignConstants.DA_BUTTON_WIDTH - 4);
+               data.height = DesignConstants.DA_BUTTON_HEIGHT;
+               data.width = DesignConstants.DA_BUTTON_WIDTH;
+               okButton.setLayoutData(data);
+               okButton.setText(AnalyzerLabels.OK);
+               okButton.addClickListener(okButtonListener);
+               if (binary.getText().isEmpty()) {
+                       okButton.setButtonEnabled(false);
+               }
+
+               cancelButton = new DAButton(buttonComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(50, 4);
+               data.height = DesignConstants.DA_BUTTON_HEIGHT;
+               data.width = DesignConstants.DA_BUTTON_WIDTH;
+               cancelButton.setLayoutData(data);
+               cancelButton.setText(AnalyzerLabels.CANCEL);
+               cancelButton.addClickListener(cancelButtonListener);
+
+               return true;
+       }
+
+}
index 064492a..9159126 100644 (file)
  */
 package org.tizen.dynamicanalyzer.swap.platform.ui;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -46,10 +51,10 @@ import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
 import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
 import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
 import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton;
-import org.tizen.sdblib.service.FileEntry;
 
 public class BinaryAnalyzingConfigDialog extends DAMessageBox {
        private static final int WIDTH = 800;
@@ -58,8 +63,6 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
        private HashMap<String, InputRow> inputRowHash = null;
        private List<InputRow> inputRowList = null;
 
-       private List<BinarySettingData> tempBinarySettings = null;
-
        private ScrolledComposite scrolledComposite = null;
        private Composite inputComposite = null;
        private DACustomToggleButton enableButton = null;
@@ -83,8 +86,6 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
 
                inputRowHash = BinarySettingManager.getInstance().getInputRowHash();
                inputRowList = BinarySettingManager.getInstance().getInputRowList();
-               tempBinarySettings = BinarySettingManager.getInstance()
-                               .getTempBinarySettings();
 
                String settingPath = AnalyzerPaths.DYNAMIC_ANALYZER_SETTING_PATH;
                File settingFolder = new File(settingPath);
@@ -97,21 +98,17 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
-                       FileExplorerDialog dialog = new FileExplorerDialog(shell);
+                       BinaryAddDialog dialog = new BinaryAddDialog(shell);
                        Object result = dialog.open();
-                       if (result != null) {
-                               FileEntry entry = (FileEntry) result;
-                               if (null == inputRowHash.get(entry.getFullPath())) {
-                                       InputRow inputRow = new InputRow(inputComposite);
-                                       inputRow.setBinaryText(entry.getFullPath());
-                                       inputRowHash.put(entry.getFullPath(), inputRow);
-                                       inputRowList.add(inputRow);
-                                       inputComposite.layout();
 
-                                       BinarySettingData binSetData = new BinarySettingData();
-                                       binSetData.setBinaryPath(entry.getFullPath());
-                                       tempBinarySettings.add(binSetData);
-                               }
+                       if (result != null) {
+                               List<String> paths = (List<String>) result;
+                               InputRow inputRow = new InputRow(inputComposite);
+                               inputRow.setBinaryText(paths.get(0));
+                               inputRow.setSourceText(paths.get(1));
+                               inputRowHash.put(paths.get(0), inputRow);
+                               inputRowList.add(inputRow);
+                               inputComposite.layout();
                        }
                }
        };
@@ -122,7 +119,42 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
                public void handleClickEvent(DACustomButton button) {
                        LoadSettingDialog dialog = new LoadSettingDialog(shell);
                        dialog.setParentDialog(me);
-                       dialog.open();
+                       Object result = dialog.open();
+                       if (result == null) {
+                               return;
+                       }
+
+                       cleanButtonListener.handleClickEvent(null);
+
+                       String path = (String) result;
+                       File saveFile = new File(path);
+                       BufferedReader br = null;
+                       String content = null;
+                       boolean success = false;
+                       // List<BinarySettingData> binData = new
+                       // ArrayList<BinarySettingData>();
+                       // List<InputRow> inputRows = new ArrayList<InputRow>();
+                       try {
+                               br = new BufferedReader(new FileReader(saveFile));
+                               while (null != (content = br.readLine())) {
+                                       // BinarySettingData data = new BinarySettingData();
+                                       InputRow inputRow = new InputRow(inputComposite);
+                                       String[] splitContent = content
+                                                       .split(CommonConstants.COMMA);
+                                       inputRow.setBinaryText(new String(splitContent[0]));
+                                       inputRow.setSourceText(new String(splitContent[1]));
+                                       inputRowList.add(inputRow);
+                                       inputRowHash.put(inputRow.getBinaryText(), inputRow);
+                               }
+                               success = true;
+                       } catch (FileNotFoundException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       } finally {
+                               AnalyzerUtil.tryClose(br);
+                       }
+                       inputComposite.layout();
                }
        };
 
@@ -130,7 +162,8 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
-                       SaveSettingDialog dialog = new SaveSettingDialog(shell);
+                       SaveSettingDialog dialog = new SaveSettingDialog(shell,
+                                       inputRowList);
                        dialog.open();
                        // save dialog
                        // filename.setting
@@ -146,7 +179,6 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
                        }
                        inputRowList.clear();
                        inputRowHash.clear();
-                       tempBinarySettings.clear();
                }
        };
 
@@ -154,8 +186,17 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
+                       List<BinarySettingData> tempBinarySettings = new ArrayList<BinarySettingData>();
+                       for (InputRow input : inputRowList) {
+                               BinarySettingData binaryData = new BinarySettingData();
+                               binaryData.setBinaryPath(input.getBinaryText());
+                               binaryData.setDebugPath(input.getSourceText());
+                               tempBinarySettings.add(binaryData);
+                       }
                        BinarySettingManager.getInstance().putBinarySettingData(
                                        tempBinarySettings);
+                       BinarySettingManager.getInstance().checkSourcePath();
+
                        DACommunicator.sendBinaryInfoMessageForLib();
                        int swapMsg = AnalyzerConstants.MSG_SWAP_INST_ADD;
                        if (enableButton.isToggled()) {
@@ -353,7 +394,6 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
 
                inputRowList.clear();
                inputRowHash.clear();
-               tempBinarySettings.clear();
 
                return true;
        }
@@ -371,35 +411,14 @@ public class BinaryAnalyzingConfigDialog extends DAMessageBox {
                                        String[] splitSource = source.split(CommonConstants.SLASH);
                                        String comboSel = new String(
                                                        splitSource[splitSource.length - 1]);
-                                       inputRow.setSourceComboText(comboSel);
+                                       // inputRow.setSourceComboText(comboSel);
                                }
                                inputRowHash.put(binData.get(i).getBinaryPath(), inputRow);
                                inputRowList.add(inputRow);
                        }
-                       tempBinarySettings.addAll(binData);
                        inputComposite.layout();
                        isLoaded = true;
                }
        }
 
-       public void loadBinarySetting(List<BinarySettingData> binData) {
-               cleanButtonListener.handleClickEvent(null);
-
-               for (int i = 0; i < binData.size(); i++) {
-                       InputRow inputRow = new InputRow(inputComposite);
-                       inputRow.setBinaryText(binData.get(i).getBinaryPath());
-                       String source = binData.get(i).getSourcePath();
-                       if (null != source && !source.isEmpty()) {
-                               inputRow.setSourceText(source);
-                               String[] splitSource = source.split(CommonConstants.SLASH);
-                               String comboSel = new String(
-                                               splitSource[splitSource.length - 1]);
-                               inputRow.setSourceComboText(comboSel);
-                       }
-                       inputRowHash.put(binData.get(i).getBinaryPath(), inputRow);
-                       inputRowList.add(inputRow);
-               }
-               tempBinarySettings.addAll(binData);
-               inputComposite.layout();
-       }
 }
\ No newline at end of file
index 2481bb6..67b595d 100644 (file)
@@ -44,6 +44,7 @@ import org.tizen.dynamicanalyzer.ui.widgets.table.DATableEmptyCellRenderer;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableHeaderRenderer;
 import org.tizen.sdblib.IDevice;
 import org.tizen.sdblib.service.FileEntry;
+import org.tizen.sdblib.service.FileEntryType;
 
 public class DAFileExplorer extends Composite {
        protected Grid table;
@@ -78,9 +79,13 @@ public class DAFileExplorer extends Composite {
                                        if (children.length > 0) {
                                                for (int i = 0; i < children.length; i++) {
                                                        FileEntry child = children[i];
-                                                       GridItem childItem = new GridItem(item, SWT.NONE);
-                                                       childItem.setText(child.getName());
-                                                       childItem.setData(child);
+                                                       if (child.getType() != FileEntryType.Link
+                                                                       && child.getType() != FileEntryType.DirectoryLink) {
+                                                               GridItem childItem = new GridItem(item,
+                                                                               SWT.NONE);
+                                                               childItem.setText(child.getName());
+                                                               childItem.setData(child);
+                                                       }
                                                }
                                        }
                                        checkedChild.put(path, true);
index 9351966..7d632bf 100644 (file)
@@ -44,9 +44,24 @@ public class DAFileExplorerRenderer extends DATableCellRenderer {
        @Override
        protected boolean hasChildren(GridItem item) {
                FileEntry entry = (FileEntry) item.getData();
+               boolean ret = false;
                if (entry != null && entry.getChildren().length > 0) {
-                       return true;
+                       FileEntry[] children = entry.getChildren();
+                       for (FileEntry child : children) {
+                               switch (child.getType()) {
+                               case File:
+                               case Directory:
+                               case RootEmulator:
+                               case RootDevice:
+                                       ret = true;
+                                       break;
+                               default:
+                               } // switch
+                               if (ret) {
+                                       break;
+                               }
+                       }
                }
-               return false;
+               return ret;
        }
 }
index be8e27a..6e33602 100644 (file)
@@ -42,6 +42,7 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
@@ -58,7 +59,8 @@ public class InputRow extends Composite {
        private final static int ROW_HEIGHT = 18;
        private Text binaryPathText = null;
        private Text sourcePathText = null;
-       private DACustomCombo sourceCombo = null;
+       // private DACustomCombo sourceCombo = null;
+       private DACustomButton editButton = null;
        private DACustomButton minusButton = null;
        private int index = -1;
 
@@ -69,7 +71,29 @@ public class InputRow extends Composite {
                public void handleClickEvent(DACustomButton button) {
                        BinarySettingManager.getInstance().removeInputRow(
                                        binaryPathText.getText());
+                       Composite pp = button.getParent().getParent();
                        button.getParent().dispose();
+                       pp.layout();
+               }
+       };
+
+       private DACustomButtonClickEventListener editButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       BinaryAddDialog dialog = new BinaryAddDialog(
+                                       getParent().getShell(), binaryPathText.getText(),
+                                       sourcePathText.getText());
+                       Object result = dialog.open();
+                       if (null != result) {
+                               List<String> paths = (List<String>) result;
+                               binaryPathText.setText(paths.get(0));
+                               sourcePathText.setText(paths.get(1));
+                       }
+                       // BinarySettingManager.getInstance().removeInputRow(
+                       // binaryPathText.getText());
+                       // button.getParent().dispose();
+
                }
        };
 
@@ -97,137 +121,155 @@ public class InputRow extends Composite {
                this.setLayout(new FormLayout());
 
                binaryPathText = new Text(this, SWT.SINGLE);
+               binaryPathText.setEditable(false);
+               binaryPathText.setBackground(ColorResources.GRAY_170);
+
                sourcePathText = new Text(this, SWT.SINGLE);
-               sourceCombo = new DACustomCombo(this, SWT.NONE);
+               sourcePathText.setEditable(false);
+               sourcePathText.setBackground(ColorResources.GRAY_170);
+               // sourceCombo = new DACustomCombo(this, SWT.NONE);
+               editButton = new DAButton(this, SWT.NONE);
                minusButton = new DAButton(this, SWT.NONE);
 
                data = new FormData();
                data.top = new FormAttachment(0, 0);
                data.left = new FormAttachment(0, 0);
-               data.right = new FormAttachment(30, 0);
+               data.right = new FormAttachment(37, 0);
                data.height = ROW_HEIGHT;
                binaryPathText.setLayoutData(data);
 
                data = new FormData();
                data.top = new FormAttachment(0, 0);
-               data.left = new FormAttachment(30, 5);
-               data.right = new FormAttachment(60, 0);
+               data.left = new FormAttachment(37, 5);
+               data.right = new FormAttachment(74, 0);
                data.height = ROW_HEIGHT;
                sourcePathText.setLayoutData(data);
 
-               data = new FormData();
-               data.top = new FormAttachment(0, 0);
-               data.left = new FormAttachment(60, 5);
-               data.right = new FormAttachment(85, 0);
-               data.height = ROW_HEIGHT;
-               sourceCombo.setLayoutData(data);
+               // data = new FormData();
+               // data.top = new FormAttachment(0, 0);
+               // data.left = new FormAttachment(60, 5);
+               // data.right = new FormAttachment(85, 0);
+               // data.height = ROW_HEIGHT;
+               // sourceCombo.setLayoutData(data);
 
                data = new FormData();
                data.top = new FormAttachment(0, 0);
-               data.left = new FormAttachment(85, 3);
+               // data.left = new FormAttachment(85, 3);
                data.right = new FormAttachment(100, -25);
+               data.width = 80;
                data.height = ROW_HEIGHT;
                minusButton.setLayoutData(data);
                minusButton.setText("remove");
                minusButton.addClickListener(minusButtonListener);
 
-               sourceCombo.setComboButtonGradation(
-                               ColorResources.DEVICE_APPLICATION_BUTTON_NORMAL_START,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_NORMAL_END,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_PUSH_START,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_PUSH_END,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_HOVER_START,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_HOVER_END,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_DISABLE_START,
-                               ColorResources.DEVICE_APPLICATION_BUTTON_DISABLE_END);
-               sourceCombo.setButtonImages(ImageResources.COMBO_DROPDOWN_UP,
-                               ImageResources.COMBO_DROPDOWN_DOWN);
-               sourceCombo.setItemHeight(ROW_HEIGHT);
-               sourceCombo.setComboRender(new TitleComboRenderer());
-               sourceCombo.setComboPopupRender(new TitleComboPopupRenderer());
-               sourceCombo.setButtonRenderer(new DACustomButtonRenderer());
-               sourceCombo.setText("select list");
-               sourceCombo.addListener(SWT.MouseDown, new Listener() {
-
-                       @Override
-                       public void handleEvent(Event event) {
-                               if (!sourceCombo.isChildShellOpened()) {
-                                       try {
-                                               Runtime rt = Runtime.getRuntime();
-                                               Process process = rt.exec(new String[] {
-                                                               AnalyzerPaths.SBI_COMMAND, "list", "root" });
-                                               process.waitFor();
-                                               BufferedReader reader = new BufferedReader(
-                                                               new InputStreamReader(process.getInputStream()));
-                                               BufferedReader error = new BufferedReader(
-                                                               new InputStreamReader(process.getErrorStream()));
-                                               String line = null;
-                                               sbiList.clear();
-                                               while (null != (line = reader.readLine())) {
-                                                       sbiList.add(line);
-                                               }
-
-                                               if (!sbiList.isEmpty()) {
-                                                       sourceCombo.initCombo();
-                                                       for (String item : sbiList) {
-                                                               sourceCombo.add(item);
-                                                       }
-                                               } else {
-                                                       String errStr = error.readLine();
-                                                       System.out.println("Error : " + errStr);
-                                               }
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                       } catch (InterruptedException e) {
-                                               e.printStackTrace();
-                                       }
-                               }
-                       }
-               });
-
-               sourceCombo.addSelectionListener(new DACustomComboSelectionListener() {
-
-                       @Override
-                       public void selectionEvent(DACustomCombo combo) {
-                               String rootName = combo.getText();
-                               if (null != rootName && !rootName.isEmpty()) {
-                                       try {
-                                               Runtime rt = Runtime.getRuntime();
-                                               Process process = rt.exec(new String[] {
-                                                               AnalyzerPaths.SBI_COMMAND, "show", "root",
-                                                               rootName });
-                                               process.waitFor();
-                                               BufferedReader reader = new BufferedReader(
-                                                               new InputStreamReader(process.getInputStream()));
-                                               BufferedReader error = new BufferedReader(
-                                                               new InputStreamReader(process.getErrorStream()));
-                                               String line = null;
-                                               // sbiList.clear();
-                                               String sysRootPath = null;
-                                               while (null != (line = reader.readLine())) {
-                                                       // sbiList.add(line);
-                                                       if (line.contains("SYSROOT_PATH")) {
-                                                               int index = line.indexOf("=");
-                                                               sysRootPath = line.substring(index + 1);
-                                                       }
-                                               }
-
-                                               if (null == sysRootPath) {
-                                                       String errStr = error.readLine();
-                                                       System.out.println("Error : " + errStr);
-                                               }
-                                               System.out.println(sysRootPath);
-                                               sourcePathText.setText(sysRootPath);
-                                               BinarySettingManager.getInstance().updateInputRow(
-                                                               binaryPathText.getText(), sysRootPath);
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                       } catch (InterruptedException e) {
-                                               e.printStackTrace();
-                                       }
-                               }
-                       }
-               });
+               data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               // data.left = new FormAttachment(60, 5);
+               data.right = new FormAttachment(minusButton, -3);
+               data.width = 80;
+               data.height = ROW_HEIGHT;
+               editButton.setLayoutData(data);
+               editButton.setText("Edit");
+               editButton.addClickListener(editButtonListener);
+
+               // sourceCombo.setComboButtonGradation(
+               // ColorResources.DEVICE_APPLICATION_BUTTON_NORMAL_START,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_NORMAL_END,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_PUSH_START,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_PUSH_END,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_HOVER_START,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_HOVER_END,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_DISABLE_START,
+               // ColorResources.DEVICE_APPLICATION_BUTTON_DISABLE_END);
+               // sourceCombo.setButtonImages(ImageResources.COMBO_DROPDOWN_UP,
+               // ImageResources.COMBO_DROPDOWN_DOWN);
+               // sourceCombo.setItemHeight(ROW_HEIGHT);
+               // sourceCombo.setComboRender(new TitleComboRenderer());
+               // sourceCombo.setComboPopupRender(new TitleComboPopupRenderer());
+               // sourceCombo.setButtonRenderer(new DACustomButtonRenderer());
+               // sourceCombo.setText("select list");
+               // sourceCombo.addListener(SWT.MouseDown, new Listener() {
+               //
+               // @Override
+               // public void handleEvent(Event event) {
+               // if (!sourceCombo.isChildShellOpened()) {
+               // try {
+               // Runtime rt = Runtime.getRuntime();
+               // Process process = rt.exec(new String[] {
+               // AnalyzerPaths.SBI_COMMAND, "list", "root" });
+               // process.waitFor();
+               // BufferedReader reader = new BufferedReader(
+               // new InputStreamReader(process.getInputStream()));
+               // BufferedReader error = new BufferedReader(
+               // new InputStreamReader(process.getErrorStream()));
+               // String line = null;
+               // sbiList.clear();
+               // while (null != (line = reader.readLine())) {
+               // sbiList.add(line);
+               // }
+               //
+               // if (!sbiList.isEmpty()) {
+               // sourceCombo.initCombo();
+               // for (String item : sbiList) {
+               // sourceCombo.add(item);
+               // }
+               // } else {
+               // String errStr = error.readLine();
+               // System.out.println("Error : " + errStr);
+               // }
+               // } catch (IOException e) {
+               // e.printStackTrace();
+               // } catch (InterruptedException e) {
+               // e.printStackTrace();
+               // }
+               // }
+               // }
+               // });
+               //
+               // sourceCombo.addSelectionListener(new DACustomComboSelectionListener()
+               // {
+               //
+               // @Override
+               // public void selectionEvent(DACustomCombo combo) {
+               // String rootName = combo.getText();
+               // if (null != rootName && !rootName.isEmpty()) {
+               // try {
+               // Runtime rt = Runtime.getRuntime();
+               // Process process = rt.exec(new String[] {
+               // AnalyzerPaths.SBI_COMMAND, "show", "root",
+               // rootName });
+               // process.waitFor();
+               // BufferedReader reader = new BufferedReader(
+               // new InputStreamReader(process.getInputStream()));
+               // BufferedReader error = new BufferedReader(
+               // new InputStreamReader(process.getErrorStream()));
+               // String line = null;
+               // // sbiList.clear();
+               // String sysRootPath = null;
+               // while (null != (line = reader.readLine())) {
+               // // sbiList.add(line);
+               // if (line.contains("SYSROOT_PATH")) {
+               // int index = line.indexOf("=");
+               // sysRootPath = line.substring(index + 1);
+               // }
+               // }
+               //
+               // if (null == sysRootPath) {
+               // String errStr = error.readLine();
+               // System.out.println("Error : " + errStr);
+               // }
+               // System.out.println(sysRootPath);
+               // sourcePathText.setText(sysRootPath);
+               // BinarySettingManager.getInstance().updateInputRow(
+               // binaryPathText.getText(), sysRootPath);
+               // } catch (IOException e) {
+               // e.printStackTrace();
+               // } catch (InterruptedException e) {
+               // e.printStackTrace();
+               // }
+               // }
+               // }
+               // });
        }
 
        public int getIndex() {
@@ -242,11 +284,31 @@ public class InputRow extends Composite {
                binaryPathText.setText(text);
        }
 
+       public String getBinaryText() {
+               return binaryPathText.getText();
+       }
+
        public void setSourceText(String text) {
                sourcePathText.setText(text);
        }
 
-       public void setSourceComboText(String text) {
-               sourceCombo.setText(text);
+       public String getSourceText() {
+               return sourcePathText.getText();
+       }
+
+       // public void setSourceComboText(String text) {
+       // sourceCombo.setText(text);
+       // }
+
+       public String getSaveData() {
+               StringBuffer strBuffer = new StringBuffer();
+               strBuffer.append(binaryPathText.getText())
+                               .append(CommonConstants.COMMA);
+               if (null == sourcePathText.getText()) {
+                       strBuffer.append(CommonConstants.SPACE);
+               } else {
+                       strBuffer.append(sourcePathText.getText());
+               }
+               return strBuffer.toString();
        }
 }
index 6b6b1a6..a4bd611 100644 (file)
@@ -287,36 +287,42 @@ public class LoadSettingDialog extends DAMessageBox {
                }
                File saveFile = new File(path);
                if (!saveFile.exists() || !saveFile.isFile()) {
+                       result = null;
                        return;
-               }
-
-               BufferedReader br = null;
-               String content = null;
-               boolean success = false;
-               List<BinarySettingData> binData = new ArrayList<BinarySettingData>();
-               try {
-                       br = new BufferedReader(new FileReader(saveFile));
-                       while (null != (content = br.readLine())) {
-                               BinarySettingData data = new BinarySettingData();
-                               String[] splitContent = content.split(CommonConstants.COMMA);
-                               data.setBinaryPath(new String(splitContent[0]));
-                               data.setSourcePath(new String(splitContent[1]));
-                               binData.add(data);
-                       }
-                       success = true;
-               } catch (FileNotFoundException e) {
-                       e.printStackTrace();
-               } catch (IOException e) {
-                       e.printStackTrace();
-               } finally {
-                       AnalyzerUtil.tryClose(br);
-               }
-
-               if (success) {
-                       parentDialog.loadBinarySetting(binData);
                } else {
-                       System.out.println("load binary setting failed...");
+                       result = path;
+                       return;
                }
+//             
+//             
+//             BufferedReader br = null;
+//             String content = null;
+//             boolean success = false;
+//             // List<BinarySettingData> binData = new ArrayList<BinarySettingData>();
+//             List<InputRow> inputRows = new ArrayList<InputRow>();
+//             try {
+//                     br = new BufferedReader(new FileReader(saveFile));
+//                     while (null != (content = br.readLine())) {
+//                             BinarySettingData data = new BinarySettingData();
+//                             String[] splitContent = content.split(CommonConstants.COMMA);
+//                             data.setBinaryPath(new String(splitContent[0]));
+//                             data.setSourcePath(new String(splitContent[1]));
+//                             binData.add(data);
+//                     }
+//                     success = true;
+//             } catch (FileNotFoundException e) {
+//                     e.printStackTrace();
+//             } catch (IOException e) {
+//                     e.printStackTrace();
+//             } finally {
+//                     AnalyzerUtil.tryClose(br);
+//             }
+//
+//             if (success) {
+//                     parentDialog.loadBinarySetting(binData);
+//             } else {
+//                     System.out.println("load binary setting failed...");
+//             }
        }
 
        public void setParentDialog(BinaryAnalyzingConfigDialog pDlg) {
index 5cc6c57..724b6d7 100644 (file)
@@ -30,6 +30,7 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
@@ -53,8 +54,6 @@ import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.common.DesignConstants;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingData;
-import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
 import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
@@ -70,95 +69,12 @@ public class SaveSettingDialog extends DAMessageBox {
        private String saveFileName = null;
        private DAButton okButton = null;
        private DAButton cancelButton = null;
+       private List<InputRow> inputRows = null;
 
-       public SaveSettingDialog(Shell parentShell) {
+       public SaveSettingDialog(Shell parentShell, List<InputRow> inputs) {
                super(parentShell);
-       }
-
-       protected boolean run() {
-               shell.setLayout(new FormLayout());
-               shell.setSize(446, 127 + 22);
-               shell.setBackground(ColorResources.DIALOG_BG_UPPER);
-               shell.setText("Save Binary Settings");
-
-               Label label = new Label(shell, SWT.TRANSPARENT);
-               FormData data = new FormData();
-               data.top = new FormAttachment(0, 11);
-               data.left = new FormAttachment(0, 12);
-               data.height = 15;
-               data.width = 150;
-               label.setLayoutData(data);
-               label.setForeground(ColorResources.BLACK);
-               label.setText(AnalyzerLabels.SAVE_TRACE_DLG_SAVE_FILE_NAME);
-               label.setBackground(ColorResources.DIALOG_BG_UPPER);
-
-               textBox = new Text(shell, SWT.SINGLE);
-               data = new FormData();
-               data.top = new FormAttachment(label, 10);
-               data.left = new FormAttachment(0, 9);
-               data.height = 26;
-               data.width = 410;
-               textBox.setLayoutData(data);
-               textBox.setBackground(ColorResources.VIEW_BG_COLOR);
-               textBox.addKeyListener(keyListener);
-
-               Composite buttonComp = new Composite(shell, SWT.NONE);
-               buttonComp.setLayout(new FormLayout());
-               buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
-
-               buttonComp.addPaintListener(new PaintListener() {
-
-                       @Override
-                       public void paintControl(PaintEvent e) {
-                               Composite comp = (Composite) e.widget;
-                               Rectangle rect = comp.getClientArea();
-                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
-                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
-                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
-                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
-                                               rect.y + 1);
-                       }
-               });
-
-               FormData compData = new FormData();
-               compData.top = new FormAttachment(0, 76);
-               compData.left = new FormAttachment(0, 0);
-               compData.right = new FormAttachment(100, 0);
-               compData.bottom = new FormAttachment(100, 0);
-               buttonComp.setLayoutData(compData);
-
-               okButton = new DAButton(buttonComp, SWT.NONE);
-               data = new FormData();
-               data.top = new FormAttachment(0, 11);
-               data.left = new FormAttachment(50, -DesignConstants.DA_BUTTON_WIDTH - 4);
-               data.height = DesignConstants.DA_BUTTON_HEIGHT;
-               data.width = DesignConstants.DA_BUTTON_WIDTH;
-               okButton.setLayoutData(data);
-               okButton.setText(AnalyzerLabels.OK);
-               okButton.addClickListener(okButtonListener);
-
-               cancelButton = new DAButton(buttonComp, SWT.NONE);
-               data = new FormData();
-               data.top = new FormAttachment(0, 11);
-               data.left = new FormAttachment(50, 4);
-               data.height = DesignConstants.DA_BUTTON_HEIGHT;
-               data.width = DesignConstants.DA_BUTTON_WIDTH;
-               cancelButton.setLayoutData(data);
-               cancelButton.setText(AnalyzerLabels.CANCEL);
-               cancelButton.addClickListener(cancelButtonListener);
-
-               saveFileName = getSaveFileName();
-               if (null == saveFileName) {
-                       // create warning message box
-                       System.out.println("save file name is null");
-                       return false;
-               } else {
-                       textBox.setText(saveFileName);
-                       String textString = textBox.getText();
-                       textBox.setSelection(0, textString.length());
-               }
-
-               return true;
+               inputRows = new ArrayList<InputRow>();
+               inputRows.addAll(inputs);
        }
 
        private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
@@ -225,14 +141,14 @@ public class SaveSettingDialog extends DAMessageBox {
                File saveFile = new File(targetPath);
                FileWriter fileWriter = null;
                BufferedWriter bufWriter = null;
-               List<BinarySettingData> binaryData = BinarySettingManager.getInstance()
-                               .getTempBinarySettings();
+//             List<BinarySettingData> binaryData = BinarySettingManager.getInstance()
+//                             .getTempBinarySettings();
                boolean success = false;
                try {
                        fileWriter = new FileWriter(saveFile);
                        bufWriter = new BufferedWriter(fileWriter);
-                       for (int i = 0; i < binaryData.size(); i++) {
-                               bufWriter.write(binaryData.get(i).getSaveData());
+                       for (int i = 0; i < inputRows.size(); i++) {
+                               bufWriter.write(inputRows.get(i).getSaveData());
                                bufWriter.newLine();
                        }
                        success = true;
@@ -253,6 +169,92 @@ public class SaveSettingDialog extends DAMessageBox {
                return true;
        }
 
+       protected boolean run() {
+               shell.setLayout(new FormLayout());
+               shell.setSize(446, 127 + 22);
+               shell.setBackground(ColorResources.DIALOG_BG_UPPER);
+               shell.setText("Save Binary Settings");
+
+               Label label = new Label(shell, SWT.TRANSPARENT);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(0, 12);
+               data.height = 15;
+               data.width = 150;
+               label.setLayoutData(data);
+               label.setForeground(ColorResources.BLACK);
+               label.setText(AnalyzerLabels.SAVE_TRACE_DLG_SAVE_FILE_NAME);
+               label.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+               textBox = new Text(shell, SWT.SINGLE);
+               data = new FormData();
+               data.top = new FormAttachment(label, 10);
+               data.left = new FormAttachment(0, 9);
+               data.height = 26;
+               data.width = 410;
+               textBox.setLayoutData(data);
+               textBox.setBackground(ColorResources.VIEW_BG_COLOR);
+               textBox.addKeyListener(keyListener);
+
+               Composite buttonComp = new Composite(shell, SWT.NONE);
+               buttonComp.setLayout(new FormLayout());
+               buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
+
+               buttonComp.addPaintListener(new PaintListener() {
+
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               Composite comp = (Composite) e.widget;
+                               Rectangle rect = comp.getClientArea();
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
+                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
+                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
+                                               rect.y + 1);
+                       }
+               });
+
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(0, 76);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.bottom = new FormAttachment(100, 0);
+               buttonComp.setLayoutData(compData);
+
+               okButton = new DAButton(buttonComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(50, -DesignConstants.DA_BUTTON_WIDTH - 4);
+               data.height = DesignConstants.DA_BUTTON_HEIGHT;
+               data.width = DesignConstants.DA_BUTTON_WIDTH;
+               okButton.setLayoutData(data);
+               okButton.setText(AnalyzerLabels.OK);
+               okButton.addClickListener(okButtonListener);
+
+               cancelButton = new DAButton(buttonComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(0, 11);
+               data.left = new FormAttachment(50, 4);
+               data.height = DesignConstants.DA_BUTTON_HEIGHT;
+               data.width = DesignConstants.DA_BUTTON_WIDTH;
+               cancelButton.setLayoutData(data);
+               cancelButton.setText(AnalyzerLabels.CANCEL);
+               cancelButton.addClickListener(cancelButtonListener);
+
+               saveFileName = getSaveFileName();
+               if (null == saveFileName) {
+                       // create warning message box
+                       System.out.println("save file name is null");
+                       return false;
+               } else {
+                       textBox.setText(saveFileName);
+                       String textString = textBox.getText();
+                       textBox.setSelection(0, textString.length());
+               }
+
+               return true;
+       }
+
        private boolean checkValidFileName(String str) {
                if (str == null
                                || str.isEmpty()
index 122d147..40dcbc3 100755 (executable)
@@ -114,11 +114,12 @@ public class AnalyzerUtil {
 
        // FIXME end
 
-       public static void copyFile(String srcPath, String destPath) {
+       public static boolean copyFile(String srcPath, String destPath) {
                File src = new File(srcPath);
                File dest = new File(destPath);
                FileInputStream fi = null;
                FileOutputStream fo = null;
+               boolean success = false;
                try {
                        fi = new FileInputStream(src);
                        fo = new FileOutputStream(dest);
@@ -127,6 +128,7 @@ public class AnalyzerUtil {
                        while ((readCount = fi.read(buffer)) != -1) {
                                fo.write(buffer, 0, readCount);
                        }
+                       success = true;
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                } catch (IOException e) {
@@ -134,6 +136,7 @@ public class AnalyzerUtil {
                } finally {
                        tryClose(fi, fo);
                }
+               return success;
        }
 
        public static void copyDirectory(File sourceLocation, File targetLocation) {