package org.tizen.dynamicanalyzer.listeners;\r
\r
import java.io.BufferedReader;\r
+import java.io.File;\r
import java.io.FileNotFoundException;\r
import java.io.FileReader;\r
import java.io.IOException;\r
String filePath = null;\r
String libName = getLibPath(item);\r
\r
- if (!isLibrary(libName)) {\r
- filePath = sourceLine.getFilePath();\r
+ BinarySettingData binData = BinarySettingManager.getInstance()\r
+ .getRealBinarySetting(libName);\r
+ String fileName = getSourceFileName(sourceLine.getFilePath());\r
+\r
+ if (null != binData && null != binData.getUserSourcePath()\r
+ && !binData.getUserSourcePath().isEmpty()) {\r
+ filePath = binData.getUserSourcePath() + File.separator + fileName;\r
} else {\r
- BinarySettingData binData = BinarySettingManager.getInstance()\r
- .getRealBinarySetting(libName);\r
- filePath = binData.getSourcePath() + sourceLine.getFilePath();\r
+ if (!isLibrary(libName)) {\r
+ filePath = sourceLine.getFilePath();\r
+ } else {\r
+ filePath = binData.getDebugSourcePath()\r
+ + sourceLine.getFilePath();\r
+ }\r
}\r
-\r
return filePath;\r
}\r
\r
+ private String getSourceFileName(String sourcePath) {\r
+ String[] splitPath = sourcePath.split(CommonConstants.SLASH);\r
+ if (splitPath.length > 0) {\r
+ return new String(splitPath[splitPath.length - 1]);\r
+ }\r
+ return null;\r
+ }\r
+\r
private void createTooltip(Event event) {\r
GridItem item = grid.getItem(new Point(event.x, event.y));\r
if (null != item) {\r
public class BinarySettingData {
private String binaryPath = null;
- private String sourcePath = null;
+ private String debugSourcePath = null;
private String debugPath = null;
private String debugFilePath = null;
- private String rpmSourcePath = null;
+ private String userSourcePath = null;
public String getBinaryPath() {
return binaryPath;
this.binaryPath = binaryPath;
}
- public String getSourcePath() {
- return sourcePath;
+ public String getDebugSourcePath() {
+ return debugSourcePath;
}
- public void setSourcePath(String sourcePath) {
- this.sourcePath = sourcePath;
+ public void setDebugSourcePath(String sourcePath) {
+ this.debugSourcePath = sourcePath;
}
public String getSaveData() {
StringBuffer strBuffer = new StringBuffer();
strBuffer.append(binaryPath).append(CommonConstants.COMMA);
- if (null == sourcePath) {
+ if (null == debugSourcePath) {
strBuffer.append(CommonConstants.SPACE);
} else {
- strBuffer.append(sourcePath);
+ strBuffer.append(debugSourcePath);
}
return strBuffer.toString();
}
this.debugPath = debugPath;
}
- public String getRpmSourcePath() {
- return rpmSourcePath;
- }
-
- public void setRpmSourcePath(String rpmSourcePath) {
- this.rpmSourcePath = rpmSourcePath;
- }
-
public String getDebugFilePath() {
return debugFilePath;
}
this.debugFilePath = debugFilePath;
}
+ public String getUserSourcePath() {
+ return userSourcePath;
+ }
+
+ public void setUserSourcePath(String userSourcePath) {
+ this.userSourcePath = userSourcePath;
+ }
+
}
import java.util.HashMap;
import java.util.List;
+import org.eclipse.cdt.utils.debug.DebugField;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
if (null != binData.getDebugPath()
&& !binData.getDebugPath().isEmpty()) {
// check dir exists.
- String sourcePath = binData.getDebugPath();
- File sourceDir = new File(sourcePath);
- String[] files = sourceDir.list();
+ String debugPath = binData.getDebugPath();
+ File debugInfoFile = new File(debugPath);
- if (!sourceDir.exists() || !sourceDir.isDirectory()) {
- continue;
- }
- if (files.length == 0) {
+ if (!debugInfoFile.exists() || debugInfoFile.isDirectory()) {
continue;
}
// check rpm file exists
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[] files = debugInfoFile.getParentFile().list();
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;
rpms.mkdirs();
}
- String from = sourcePath + File.separator + debugInfoRpmName;
- String to = rpmPath + File.separator + debugInfoRpmName;
+ String from = debugPath;
+ String to = rpmPath + File.separator + debugInfoFile.getName();
String debugRpmPath = null;
String debugRpmSourcePath = null;
if (AnalyzerUtil.copyFile(from, to)) {
if (null != debugInfoSourceRpmName
&& !debugInfoSourceRpmName.isEmpty()) {
- from = sourcePath + File.separator + debugInfoSourceRpmName;
+ from = debugInfoFile.getParent() + File.separator + debugInfoSourceRpmName;
to = rpmPath + File.separator + debugInfoSourceRpmName;
if (AnalyzerUtil.copyFile(from, to)) {
debugRpmSourcePath = to;
BufferedReader error = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
String errorStr = error.readLine();
- System.out.println("host md5sum get failed : "
+ System.out.println("source file path get failed.. : "
+ errorStr);
continue;
}
e.printStackTrace();
continue;
}
- binData.setSourcePath(sourceFilePath);
+ binData.setDebugSourcePath(sourceFilePath);
}
}
package org.tizen.dynamicanalyzer.swap.platform.ui;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
import org.tizen.dynamicanalyzer.common.CommonConstants;
import org.tizen.dynamicanalyzer.common.DesignConstants;
+import org.tizen.dynamicanalyzer.common.PathManager;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.swap.platform.ui.DeviceExplorer.DeviceExplorerDilaog;
-import org.tizen.dynamicanalyzer.swap.platform.ui.FileExplorer.FileExplorerCasvalDialog;
+import org.tizen.dynamicanalyzer.swap.platform.ui.FileExplorer.FileExplorerDialog;
import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
public class BinaryAddDialog extends DAMessageBox {
- private Text binary = null;
- // private Text source = null;
- private Text debugPackage = null;
+ private Text binaryText = null;
+ private Text sourceText = null;
+ private Text debugPackageText = null;
private DAButton findButton = null;
private DAButton findPackageButton = null;
+ private DAButton findSourceButton = null;
private DAButton okButton = null;
private DAButton cancelButton = null;
@Override
public void handleClickEvent(DACustomButton button) {
DeviceExplorerDilaog dialog = new DeviceExplorerDilaog(shell);
+ if (!binaryText.getText().isEmpty()) {
+ dialog.getExplorer().setCurrent(binaryText.getText());
+ }
Object result = dialog.open();
if (result != null) {
FileEntry entry = (FileEntry) result;
- binary.setText(entry.getFullPath());
+ binaryText.setText(entry.getFullPath());
okButton.setButtonEnabled(true);
+ debugPackageText.setEnabled(true);
+ findPackageButton.setButtonEnabled(true);
+ if (!debugPackageText.getText().isEmpty()) {
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+
+ String debugPath = getDebugInfoPath(binaryText.getText());
+ if (null != debugPath) {
+ debugPackageText.setText(debugPath);
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
}
}
};
@Override
public void handleClickEvent(DACustomButton button) {
- FileExplorerCasvalDialog dialog = new FileExplorerCasvalDialog(shell);
+ FileExplorerDialog dialog = new FileExplorerDialog(shell);
+ dialog.getExplorer().setRoot(PathManager.getRootStrapsPath());
+ if (!debugPackageText.getText().isEmpty()) {
+ dialog.getExplorer().setCurrent(debugPackageText.getText());
+ }
+ Object result = dialog.open();
+ if (result != null) {
+ File file = (File) result;
+ debugPackageText.setText(file.getAbsolutePath());
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+ }
+ };
+
+ private DACustomButtonClickEventListener findSourceButtonListener = new DACustomButtonClickEventListener() {
+
+ @Override
+ public void handleClickEvent(DACustomButton button) {
+ FileExplorerDialog dialog = new FileExplorerDialog(shell);
+ dialog.getExplorer().setReturnDirectory(true);
+ dialog.getExplorer().setRoot("/home/");
+ if (!sourceText.getText().isEmpty()) {
+ dialog.getExplorer().setCurrent(sourceText.getText());
+ }
Object result = dialog.open();
if (result != null) {
File file = (File) result;
- debugPackage.setText(file.getAbsolutePath());
+ sourceText.setText(file.getAbsolutePath());
}
}
};
+
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());
+ paths.add(binaryText.getText());
+ paths.add(debugPackageText.getText());
+ paths.add(sourceText.getText());
result = paths;
shell.dispose();
}
@Override
public void keyReleased(KeyEvent e) {
- if (binary.getText().isEmpty()) {
+ if (binaryText.getText().isEmpty()) {
okButton.setButtonEnabled(false);
+ debugPackageText.setEnabled(false);
+ findPackageButton.setButtonEnabled(false);
+ sourceText.setEnabled(false);
+ findSourceButton.setButtonEnabled(false);
} else {
okButton.setButtonEnabled(true);
+ debugPackageText.setEnabled(true);
+ findPackageButton.setButtonEnabled(true);
+ if (!debugPackageText.getText().isEmpty()) {
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+ }
+ System.out.println("key " + e.keyCode);
+ if (!binaryText.getText().isEmpty() && e.keyCode == 13) // enter
+ {
+ String debugPath = getDebugInfoPath(binaryText.getText());
+ if (null != debugPath) {
+ debugPackageText.setText(debugPath);
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+ }
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ }
+ };
+
+ private KeyListener debugKeyListener = new KeyListener() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ if (debugPackageText.getText().isEmpty()) {
+ sourceText.setEnabled(false);
+ findSourceButton.setButtonEnabled(false);
+ } else {
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
}
}
protected boolean run() {
shell.setLayout(new FormLayout());
- shell.setSize(446, 225);
+ shell.setSize(446, 300);
shell.setBackground(ColorResources.DIALOG_BG_UPPER);
shell.setText("Add Binary Setting");
AnalyzerUtil.setCenter(shell);
label.setText("Binary Path");
label.setBackground(ColorResources.DIALOG_BG_UPPER);
- binary = new Text(shell, SWT.SINGLE);
+ binaryText = new Text(shell, SWT.SINGLE);
data = new FormData();
data.top = new FormAttachment(label, 5);
data.left = new FormAttachment(0, 12);
data.height = 24;
data.width = 330;
- binary.setLayoutData(data);
- binary.setBackground(ColorResources.WHITE);
- binary.addKeyListener(binaryKeyListener);
- binary.setText(binaryStr);
- binary.addPaintListener(new PaintListener() {
+ binaryText.setLayoutData(data);
+ binaryText.setBackground(ColorResources.WHITE);
+ binaryText.addKeyListener(binaryKeyListener);
+ binaryText.setText(binaryStr);
+ binaryText.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
findButton = new DAButton(shell, SWT.NONE);
data = new FormData();
data.top = new FormAttachment(label, 4);
- data.left = new FormAttachment(binary, 5);
+ data.left = new FormAttachment(binaryText, 5);
data.height = 30;
data.width = 80;
findButton.setLayoutData(data);
findButton.setText("Find file");
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.top = new FormAttachment(binaryText, 15);
data.left = new FormAttachment(0, 12);
data.height = 15;
data.width = 150;
debugLabel.setText("Debug directory path");
debugLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
- debugPackage = new Text(shell, SWT.SINGLE);
+ debugPackageText = new Text(shell, SWT.SINGLE);
data = new FormData();
data.top = new FormAttachment(debugLabel, 5);
data.left = new FormAttachment(0, 12);
data.height = 26;
data.width = 330;
- debugPackage.setLayoutData(data);
- debugPackage.setBackground(ColorResources.WHITE);
- debugPackage.setText(debutStr);
+ debugPackageText.setLayoutData(data);
+ debugPackageText.setBackground(ColorResources.WHITE);
+ debugPackageText.addKeyListener(debugKeyListener);
+ debugPackageText.setText(debutStr);
- debugPackage.addPaintListener(new PaintListener() {
+ debugPackageText.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
findPackageButton = new DAButton(shell, SWT.NONE);
data = new FormData();
data.top = new FormAttachment(debugLabel, 4);
- data.left = new FormAttachment(debugPackage, 5);
+ data.left = new FormAttachment(debugPackageText, 5);
data.height = 30;
data.width = 80;
findPackageButton.setLayoutData(data);
findPackageButton.setText("Find dir");
findPackageButton.addClickListener(findDebugButtonListener);
-
+
+ Label sourceLabel = new Label(shell, SWT.TRANSPARENT);
+ data = new FormData();
+ data.top = new FormAttachment(debugPackageText, 15);
+ data.left = new FormAttachment(0, 12);
+ data.height = 15;
+ data.width = 200;
+ sourceLabel.setLayoutData(data);
+ sourceLabel.setForeground(ColorResources.BLACK);
+ sourceLabel.setText("User defined source directory");
+ sourceLabel.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+ sourceText = new Text(shell, SWT.SINGLE);
+ data = new FormData();
+ data.top = new FormAttachment(sourceLabel, 5);
+ data.left = new FormAttachment(0, 12);
+ data.height = 26;
+ data.width = 330;
+ sourceText.setLayoutData(data);
+ sourceText.setBackground(ColorResources.WHITE);
+ sourceText.addPaintListener(new PaintListener() {
+
+ @Override
+ public void paintControl(PaintEvent e) {
+ e.gc.setForeground(ColorResources.BUTTON_OUTLINE_HOVER_IN_COLOR);
+ Text text = (Text) e.widget;
+ Rectangle rect = text.getClientArea();
+ e.gc.drawRectangle(rect.x, rect.y, rect.width - 1,
+ rect.height - 1);
+ }
+ });
+
+ findSourceButton = new DAButton(shell, SWT.NONE);
+ data = new FormData();
+ data.top = new FormAttachment(sourceLabel, 4);
+ data.left = new FormAttachment(debugPackageText, 5);
+ data.height = 30;
+ data.width = 80;
+ findSourceButton.setLayoutData(data);
+ findSourceButton.setText("Find Dir");
+ findSourceButton.addClickListener(findSourceButtonListener);
+
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new FormLayout());
buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
});
FormData compData = new FormData();
- compData.top = new FormAttachment(debugPackage, 20);
+ compData.top = new FormAttachment(sourceText, 20);
compData.left = new FormAttachment(0, 0);
compData.right = new FormAttachment(100, 0);
compData.bottom = new FormAttachment(100, 0);
okButton.setLayoutData(data);
okButton.setText(AnalyzerLabels.OK);
okButton.addClickListener(okButtonListener);
- if (binary.getText().isEmpty()) {
+ if (binaryText.getText().isEmpty()) {
okButton.setButtonEnabled(false);
}
cancelButton.setText(AnalyzerLabels.CANCEL);
cancelButton.addClickListener(cancelButtonListener);
+ shell.addControlListener(new ControlListener() {
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ if (binaryText.getText().isEmpty()) {
+ debugPackageText.setEnabled(false);
+ findPackageButton.setButtonEnabled(false);
+ sourceText.setEnabled(false);
+ findSourceButton.setButtonEnabled(false);
+ } else {
+ debugPackageText.setEnabled(true);
+ findPackageButton.setButtonEnabled(true);
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+
+ if (debugPackageText.getText().isEmpty()) {
+ sourceText.setEnabled(false);
+ findSourceButton.setButtonEnabled(false);
+ } else {
+ sourceText.setEnabled(true);
+ findSourceButton.setButtonEnabled(true);
+ }
+ }
+
+ @Override
+ public void controlMoved(ControlEvent e) {
+ }
+ });
+
return true;
}
+ private String getDebugInfoPath(String libPath) {
+ String[] splitTargetLib = libPath.split(CommonConstants.SLASH);
+ String libFullName = splitTargetLib[splitTargetLib.length - 1];
+ int index = libFullName.indexOf(".so");
+ if (index < 0) {
+ return null;
+ }
+ // 3 means remove "lib" string
+ String debugInfoToken = "*" + libFullName.substring(3, index)
+ + "-debuginfo*.rpm";
+ String rootstrapPath = PathManager.getRootStrapsPath();
+ List<String> lines = new ArrayList<String>();
+ String toolPath = AnalyzerPaths.TOOL_FOLDER_PATH + File.separator
+ + "debuginfo.sh";
+ String[] command = new String[] { toolPath, "-f", rootstrapPath,
+ debugInfoToken };
+ try {
+ Runtime rt = Runtime.getRuntime();
+ Process process = rt.exec(command);
+ process.waitFor();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ process.getInputStream()));
+ int lineCount = 0;
+ String line = null;
+ while (null != (line = reader.readLine())) {
+ lineCount++;
+ System.out.println("LINE (" + lineCount + ") : " + line);
+ lines.add(line);
+ }
+ if (lineCount == 0) {
+ BufferedReader error = new BufferedReader(
+ new InputStreamReader(process.getErrorStream()));
+ String errorStr = error.readLine();
+ System.out.println("find debug info path fail.. " + errorStr);
+ return null;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ String select = null;
+ for (String line : lines) {
+ if (null == select) {
+ select = line;
+ } else if (select.length() > line.length()) {
+ select = line;
+ }
+ }
+
+ String debugPath = null;
+ if (null == select) {
+ return null;
+ } else {
+ select = select.substring(1, select.length());
+ debugPath = rootstrapPath + select;
+ }
+ return debugPath;
+ }
}
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.receiver.FileEntryFactory;
import org.tizen.sdblib.service.FileEntry;
import org.tizen.sdblib.service.FileEntryType;
-import org.tizen.sdblib.util.FileEntryUtil;
-public class DAFileExplorer extends Composite {
+public class DAFileTreeExplorer extends Composite {
protected Grid table;
private HashMap<String, Boolean> checkedChild = new HashMap<String, Boolean>();
- public DAFileExplorer(Composite parent) {
+ public DAFileTreeExplorer(Composite parent) {
super(parent, SWT.NONE);
this.setLayout(new FillLayout());
table = new DAGrid(this, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL
public void setColumns() {
GridColumn column = new GridColumn(table, SWT.NONE);
- column.setCellRenderer(new DAFileExplorerRenderer());
+ column.setCellRenderer(new DAFileTreeExplorerRenderer());
column.setHeaderRenderer(new DATableHeaderRenderer());
column.setText("Node");
column.setWidth(500);
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableCellRenderer;
import org.tizen.sdblib.service.FileEntry;
-public class DAFileExplorerRenderer extends DATableCellRenderer {
+public class DAFileTreeExplorerRenderer extends DATableCellRenderer {
@Override
public void setTree(boolean tree) {
super.setTree(tree);
if (tree) {
- toggleRenderer = new DAFileExplorerToggleRenderer();
+ toggleRenderer = new DAFileTreeExplorerToggleRenderer();
toggleRenderer.setDisplay(getDisplay());
}
}
import org.tizen.dynamicanalyzer.ui.widgets.table.DATableToggleRenderer;
import org.tizen.sdblib.service.FileEntry;
-public class DAFileExplorerToggleRenderer extends DATableToggleRenderer {
+public class DAFileTreeExplorerToggleRenderer extends DATableToggleRenderer {
public void paint(GC gc, Object value) {
GridItem item = (GridItem) value;
import org.tizen.sdblib.service.FileEntry;
public class DeviceExplorer extends Composite {
+ private static int FAIL = -1;
+ private static int FILE = 1;
+ private static int DIRECTORY = 2;
+
protected Grid table = null;
protected Text inputText = null;
protected DACustomButton goButton = null;
protected Label info = null;
+ private boolean getDirectory = false;
private IDevice device = null;
private FileEntry root = null;
private FileEntry current = null;
private FileEntry selected = null;
+ private String selectionStr = null;
+
private SelectionListener tableSelectionListener = new SelectionListener() {
@Override
return;
}
- FileEntry file = device.getFileEntry(path);
- if (null == file || (!file.isDirectory() && !file.isRoot())) {
- System.out.println("target path is invalid");
+ int ret = setCurrent(path);
+ if (ret != FAIL) {
+ inputText.setBackground(ColorResources.WHITE);
+ } else {
inputText.setBackground(ColorResources.RED);
info.setText("Invalid path");
- return;
}
- inputText.setBackground(ColorResources.WHITE);
- current = file;
- updateData();
+
+ // FileEntry file = device.getFileEntry(path);
+ // if (null == file || (!file.isDirectory() && !file.isRoot())) {
+ // System.out.println("target path is invalid");
+ // inputText.setBackground(ColorResources.RED);
+ // info.setText("Invalid path");
+ // return;
+ // }
+ // inputText.setBackground(ColorResources.WHITE);
+ // current = file;
+ // updateData();
}
};
goButton.setText("Go");
goButton.addClickListener(goButtonClickListener);
- // Label label = new Label(this, SWT.TRANSPARENT);
- // data = new FormData();
- // data.top = new FormAttachment(inputText, 5);
- // data.left = new FormAttachment(0, 20);
- // data.height = 18;
- // data.width = 70;
- // label.setLayoutData(data);
- // label.setText(CommonConstants.EMPTY);
- // label.setBackground(ColorResources.DIALOG_BG_UPPER);
- // label.setFont(FontResources.TABLE_CELL_FONT);
-
info = new Label(this, SWT.TRANSPARENT);
data = new FormData();
data.top = new FormAttachment(inputText, 10);
parentItem.setData(ExplorerUtil.DATA_FIEL_KEY, current.getParent());
}
FileEntry[] children = current.getChildren();
+ int selectionIndex = -1;
if (null != children) {
int size = children.length;
for (int i = 0; i < size; i++) {
GridItem item = new GridItem(table, SWT.NONE);
item.setText(1, child.getName());
item.setData(ExplorerUtil.DATA_FIEL_KEY, child);
+ if (null != selectionStr
+ && selectionStr.equals(child.getFullPath())) {
+ int index = table.indexOf(item);
+ // table.getVerticalBar().setSelection(index);
+ table.setSelection(index);
+ selected = child;
+ inputText.setText(child.getFullPath());
+ selectionIndex = index;
+ }
}
+ table.getVerticalBar().setMaximum(size);
+ table.getVerticalBar().setSelection(selectionIndex);
}
-
table.update();
}
}
FileEntry entry = (FileEntry) selection
.getData(ExplorerUtil.DATA_FIEL_KEY);
- if (!entry.isDirectory() && !entry.isRoot()) {
- return entry;
+ if (entry.isDirectory() || entry.isRoot()) {
+ if (getDirectory) {
+ return entry;
+ } else {
+ return null;
+ }
} else {
- return null;
+ if (getDirectory) {
+ return entry.getParent();
+ } else {
+ return entry;
+ }
}
} else {
return null;
}
}
+ public void setReturnDirectory(boolean getDir) {
+ getDirectory = getDir;
+ }
+
public void setDevice(IDevice dev) {
this.device = dev;
}
+
+ public int setCurrent(String path) {
+ int result = FAIL;
+ if (null != path && !path.isEmpty()) {
+ FileEntry file = device.getFileEntry(path);
+ if (file == null) {
+ System.out.println("invalid path");
+ return result;
+ } else if (!file.isDirectory() || !file.isRoot()) {
+ current = file.getParent();
+ selectionStr = file.getFullPath();
+ result = FILE;
+ } else {
+ current = file;
+ selectionStr = CommonConstants.EMPTY;
+ result = DIRECTORY;
+ }
+ updateData();
+ return result;
+ }
+ return result;
+ }
+
}
}
});
}
+
+ public DeviceExplorer getExplorer() {
+ return explorer;
+ }
}
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-public class DAFileExplorerCasval extends Composite {
+public class DAFileExplorer extends Composite {
+
+ private static int FAIL = -1;
+ private static int FILE = 1;
+ private static int DIRECTORY = 2;
protected Grid table = null;
protected Text inputText = null;
protected DACustomButton goButton = null;
protected Label info = null;
+ private boolean getDirectory = false;
private File root = null;
private File current = null;
private File selected = null;
+ private String selectionStr = null;
+
private SelectionListener tableSelectionListener = new SelectionListener() {
@Override
return;
}
- File file = new File(path);
- if (!file.exists() || !file.isDirectory()) {
- System.out.println("target path is invalid");
+ int ret = setCurrent(path);
+ if (ret != FAIL) {
+ inputText.setBackground(ColorResources.WHITE);
+ } else {
inputText.setBackground(ColorResources.RED);
info.setText("Invalid path");
- return;
}
- inputText.setBackground(ColorResources.WHITE);
- current = file;
- updateData();
+ // File file = new File(path);
+ // if (!file.exists() || !file.isDirectory()) {
+ // System.out.println("target path is invalid");
+ // inputText.setBackground(ColorResources.RED);
+ // info.setText("Invalid path");
+ // return;
+ // }
+ // inputText.setBackground(ColorResources.WHITE);
+ // current = file;
+ // updateData();
}
};
- public DAFileExplorerCasval(Composite parent) {
+ public DAFileExplorer(Composite parent) {
super(parent, SWT.NONE);
this.setLayout(new FormLayout());
this.setBackground(ColorResources.DIALOG_BG_UPPER);
goButton.setText("Go");
goButton.addClickListener(goButtonClickListener);
-// Label label = new Label(this, SWT.TRANSPARENT);
-// data = new FormData();
-// data.top = new FormAttachment(inputText, 5);
-// data.left = new FormAttachment(0, 20);
-// data.height = 18;
-// data.width = 70;
-// label.setLayoutData(data);
-// label.setText(CommonConstants.EMPTY);
-// label.setBackground(ColorResources.DIALOG_BG_UPPER);
-// label.setFont(FontResources.TABLE_CELL_FONT);
-
info = new Label(this, SWT.TRANSPARENT);
data = new FormData();
data.top = new FormAttachment(inputText, 10);
GridItem item = new GridItem(table, SWT.NONE);
item.setText(1, child.getName());
item.setData(ExplorerUtil.DATA_FIEL_KEY, child);
+ if (null != selectionStr
+ && selectionStr.equals(child.getAbsolutePath())) {
+ int index = table.indexOf(item);
+ table.setSelection(index);
+ selected = child;
+ inputText.setText(child.getAbsolutePath());
+ }
}
}
}
File entry = (File) selection.getData(ExplorerUtil.DATA_FIEL_KEY);
if (entry.isDirectory()) {
- return entry;
+ if (getDirectory) {
+ return entry;
+ } else {
+ return null;
+ }
} else {
- return entry.getParentFile();
+ if (getDirectory) {
+ return entry.getParentFile();
+ } else {
+ return entry;
+ }
}
} else {
return null;
}
}
+ public void setReturnDirectory(boolean getDir) {
+ getDirectory = getDir;
+ }
+
+ public int setCurrent(String path) {
+ int result = FAIL;
+ if (null != path && !path.isEmpty()) {
+ File file = new File(path);
+ if (!file.exists()) {
+ System.out.println("invalid path");
+ return result;
+ } else if (!file.isDirectory()) {
+ current = file.getParentFile();
+ selectionStr = file.getAbsolutePath();
+ result = FILE;
+ } else {
+ current = file;
+ selectionStr = CommonConstants.EMPTY;
+ result = DIRECTORY;
+ }
+ updateData();
+ return result;
+ }
+ return result;
+ }
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.DesignConstants;
-import org.tizen.dynamicanalyzer.common.PathManager;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
import org.tizen.dynamicanalyzer.resources.ColorResources;
import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-public class FileExplorerCasvalDialog extends DAMessageBox {
- private DAFileExplorerCasval explorer = null;
+public class FileExplorerDialog extends DAMessageBox {
+ private DAFileExplorer explorer = null;
private DACustomButton okButton = null;
private DACustomButton cancelButton = null;
- public FileExplorerCasvalDialog(Shell parentShell) {
+ public FileExplorerDialog(Shell parentShell) {
super(parentShell);
+
shell.setLayout(new FormLayout());
shell.setSize(446, 600);
shell.setBackground(ColorResources.DIALOG_BG_UPPER);
shell.setText("Select binary");
- explorer = new DAFileExplorerCasval(shell);
+ explorer = new DAFileExplorer(shell);
FormData data = new FormData();
data.top = new FormAttachment(0, 17);
data.left = new FormAttachment(0, 6);
data.height = 476;
data.width = 434;
explorer.setLayoutData(data);
- explorer.setRoot(PathManager.getRootStrapsPath());
- explorer.updateData();
Composite buttonComp = new Composite(shell, SWT.NONE);
buttonComp.setLayout(new FormLayout());
shell.dispose();
}
});
+ }
+ protected boolean run() {
+ explorer.updateData();
// explorer.getTable().addMouseListener(new MouseListener() {
//
// @Override
// }
// }
// });
+ return true;
}
+
+ public DAFileExplorer getExplorer() {
+ return explorer;
+ }
+
}
import org.tizen.sdblib.service.FileEntry;
public class FileExplorerDialog extends DAMessageBox {
- private DAFileExplorer explorerTree = null;
+ private DAFileTreeExplorer explorerTree = null;
private DACustomButton okButton = null;
private DACustomButton cancelButton = null;
shell.setBackground(ColorResources.DIALOG_BG_UPPER);
shell.setText("Select binary");
- explorerTree = new DAFileExplorer(shell);
+ explorerTree = new DAFileTreeExplorer(shell);
FormData data = new FormData();
data.top = new FormAttachment(0, 15);
data.left = new FormAttachment(0, 20);
public class InputRow extends Composite {
private final static int ROW_HEIGHT = 18;
private Text binaryPathText = null;
+ private Text debugPathText = null;
private Text sourcePathText = null;
- // private DACustomCombo sourceCombo = null;
+
private DACustomButton editButton = null;
- private DACustomButton minusButton = null;
+ private DACustomButton removeButton = null;
private int index = -1;
private DACustomButtonClickEventListener minusButtonListener = new DACustomButtonClickEventListener() {
public void handleClickEvent(DACustomButton button) {
BinaryAddDialog dialog = new BinaryAddDialog(
getParent().getShell(), binaryPathText.getText(),
- sourcePathText.getText());
+ debugPathText.getText());
Object result = dialog.open();
if (null != result) {
@SuppressWarnings("unchecked")
List<String> paths = (List<String>) result;
binaryPathText.setText(paths.get(0));
- sourcePathText.setText(paths.get(1));
+ debugPathText.setText(paths.get(1));
+ sourcePathText.setText(paths.get(2));
}
- // BinarySettingManager.getInstance().removeInputRow(
- // binaryPathText.getText());
- // button.getParent().dispose();
-
}
};
binaryPathText.setEditable(false);
binaryPathText.setBackground(ColorResources.GRAY_170);
- sourcePathText = new Text(this, SWT.SINGLE);
- sourcePathText.setEditable(false);
- sourcePathText.setBackground(ColorResources.GRAY_170);
- // sourceCombo = new DACustomCombo(this, SWT.NONE);
+ debugPathText = new Text(this, SWT.SINGLE);
+ debugPathText.setEditable(false);
+ debugPathText.setBackground(ColorResources.GRAY_170);
editButton = new DAButton(this, SWT.NONE);
- minusButton = new DAButton(this, SWT.NONE);
+ removeButton = new DAButton(this, SWT.NONE);
+
+ sourcePathText = new Text(this, SWT.SINGLE);
data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(37, 5);
data.right = new FormAttachment(74, 0);
data.height = ROW_HEIGHT;
- sourcePathText.setLayoutData(data);
+ debugPathText.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 = 0;
+ data.width = 0;
+ sourcePathText.setLayoutData(data);
data = new FormData();
data.top = new FormAttachment(0, 0);
- // data.left = new FormAttachment(60, 5);
- data.left = new FormAttachment(sourcePathText, 3);
+ data.left = new FormAttachment(debugPathText, 3);
data.width = 65;
data.height = ROW_HEIGHT;
editButton.setLayoutData(data);
data.left = new FormAttachment(editButton, 3);
data.width = 65;
data.height = ROW_HEIGHT;
- minusButton.setLayoutData(data);
- minusButton.setText("remove");
- minusButton.addClickListener(minusButtonListener);
+ removeButton.setLayoutData(data);
+ removeButton.setText("remove");
+ removeButton.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();
- // }
- // }
- // }
- // });
}
public int getIndex() {
return binaryPathText.getText();
}
+ public void setDebugText(String text) {
+ debugPathText.setText(text);
+ }
+
+ public String getDebugText() {
+ return debugPathText.getText();
+ }
+
public void setSourceText(String text) {
sourcePathText.setText(text);
}
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 == debugPathText.getText()) {
+ strBuffer.append(CommonConstants.SPACE).append(
+ CommonConstants.COMMA);
+ ;
+ } else {
+ strBuffer.append(debugPathText.getText()).append(
+ CommonConstants.COMMA);
+ ;
+ }
+
if (null == sourcePathText.getText()) {
strBuffer.append(CommonConstants.SPACE);
} else {
public void setDisable() {
editButton.setButtonEnabled(false);
- minusButton.setButtonEnabled(false);
+ removeButton.setButtonEnabled(false);
}
}
cleanButtonListener.handleClickEvent(null);
initInputRows();
addButton.setButtonEnabled(false);
- saveButton.setButtonEnabled(false);
+ saveButton.setButtonEnabled(true);
loadButton.setButtonEnabled(false);
cleanButton.setButtonEnabled(false);
}
List<String> paths = (List<String>) result;
InputRow inputRow = new InputRow(inputComposite);
inputRow.setBinaryText(paths.get(0));
- inputRow.setSourceText(paths.get(1));
+ inputRow.setDebugText(paths.get(1));
+ inputRow.setSourceText(paths.get(2));
inputRowHash.put(paths.get(0), inputRow);
inputRowList.add(inputRow);
BinarySettingData binaryData = new BinarySettingData();
binaryData.setBinaryPath(inputRow.getBinaryText());
- binaryData.setDebugPath(inputRow.getSourceText());
+ binaryData.setDebugPath(inputRow.getDebugText());
+ binaryData.setUserSourcePath(inputRow.getSourceText());
if (addRadioButton.isSelected()) {
BinarySettingManager.getInstance().getAddBinarySettings()
String[] splitContent = content
.split(CommonConstants.COMMA);
inputRow.setBinaryText(new String(splitContent[0]));
- inputRow.setSourceText(new String(splitContent[1]));
+ inputRow.setDebugText(new String(splitContent[1]));
+ inputRow.setSourceText(new String(splitContent[2]));
inputRowList.add(inputRow);
inputRowHash.put(inputRow.getBinaryText(), inputRow);
BinarySettingData binaryData = new BinarySettingData();
binaryData.setBinaryPath(inputRow.getBinaryText());
- binaryData.setDebugPath(inputRow.getSourceText());
+ binaryData.setDebugPath(inputRow.getDebugText());
+ binaryData.setUserSourcePath(inputRow.getSourceText());
tempBinarySettings.add(binaryData);
}
if (addRadioButton.isSelected()) {
public void handleEvent(Event event) {
if (currentRadioButton.isSelected()) {
addButton.setButtonEnabled(false);
- saveButton.setButtonEnabled(false);
+ saveButton.setButtonEnabled(true);
loadButton.setButtonEnabled(false);
cleanButton.setButtonEnabled(false);
} else if (addRadioButton.isSelected()) {
for (InputRow input : inputRowList) {
BinarySettingData binaryData = new BinarySettingData();
binaryData.setBinaryPath(input.getBinaryText());
- binaryData.setDebugPath(input.getSourceText());
+ binaryData.setDebugPath(input.getDebugText());
+ binaryData.setUserSourcePath(input.getSourceText());
tempBinarySettings.add(binaryData);
}
// BinarySettingManager.getInstance().putBinarySettingData(
BinarySettingData binaryData = new BinarySettingData();
binaryData.setBinaryPath(input.getBinaryText());
- binaryData.setDebugPath(input.getSourceText());
+ binaryData.setDebugPath(input.getDebugText());
+ binaryData.setUserSourcePath(input.getSourceText());
tempBinarySettings.add(binaryData);
}
DACommunicator.sendSWAPMessage(
inputRow.setBinaryText(binData.get(i).getBinaryPath());
String source = binData.get(i).getDebugPath();
if (null != source && !source.isEmpty()) {
- inputRow.setSourceText(source);
+ inputRow.setDebugText(source);
// String[] splitSource =
// source.split(CommonConstants.SLASH);
// String comboSel = new String(