--- /dev/null
+#!/bin/bash
+
+cd $1
+find . -name $2
--- /dev/null
+#!/bin/bash
+
+echo $1
+echo $2
+echo $3
+
+cd $1
+rpm2cpio $2 | cpio -imd
+rpm2cpio $3 | cpio -imd
+
+
\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
.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
}
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() {
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,
});
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;
}
}
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
\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
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;
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;
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++) {
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++;
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;
}
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;
+ }
+
}
*/
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 {
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;
}
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;
+ }
}
--- /dev/null
+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;
+ }
+
+}
*/
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;
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;
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;
inputRowHash = BinarySettingManager.getInstance().getInputRowHash();
inputRowList = BinarySettingManager.getInstance().getInputRowList();
- tempBinarySettings = BinarySettingManager.getInstance()
- .getTempBinarySettings();
String settingPath = AnalyzerPaths.DYNAMIC_ANALYZER_SETTING_PATH;
File settingFolder = new File(settingPath);
@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();
}
}
};
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();
}
};
@Override
public void handleClickEvent(DACustomButton button) {
- SaveSettingDialog dialog = new SaveSettingDialog(shell);
+ SaveSettingDialog dialog = new SaveSettingDialog(shell,
+ inputRowList);
dialog.open();
// save dialog
// filename.setting
}
inputRowList.clear();
inputRowHash.clear();
- tempBinarySettings.clear();
}
};
@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()) {
inputRowList.clear();
inputRowHash.clear();
- tempBinarySettings.clear();
return true;
}
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
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;
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);
@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;
}
}
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;
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;
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();
+
}
};
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() {
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();
}
}
}
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) {
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;
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;
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() {
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;
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()
// 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);
while ((readCount = fi.read(buffer)) != -1) {
fo.write(buffer, 0, readCount);
}
+ success = true;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
} finally {
tryClose(fi, fo);
}
+ return success;
}
public static void copyDirectory(File sourceLocation, File targetLocation) {