import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.Platform;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+
public class WorkbenchUtils {
public static final String WIN_INSTALL_NODE = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders";//$NON-NLS-1$
+ "/tools/dynamic-analyzer/tool/windowactivator.bat";//$NON-NLS-1$
public static final String WINDOW_ACTIVATOR_MACOS_PATH = TIZEN_ROOT_PATH
+ "/tools/dynamic-analyzer/tool/macoswindowactivator.sh";//$NON-NLS-1$
-
+
private static String logPostFix = null;
public static String getLogPostFix() {
public static String getTizenSdkDataPath() {
String defaultPath = null;
- if (isWin()) {
- defaultPath = getRegistryValue(WIN_INSTALL_NODE, WIN_INSTALL_KEY)
- + File.separator + TIZEN_SDK_DATA;
- } else if (isMac()) {
- defaultPath = System.getenv(LINUX_INSTALL_ENV) + File.separator
- + TIZEN_SDK_DATA;
- } else if (isLinux()) {
- defaultPath = System.getenv(LINUX_INSTALL_ENV) + File.separator
- + TIZEN_SDK_DATA;
- } else {
- System.out.println("Please check OS and install the Tizen SDK"); //$NON-NLS-1$
- System.exit(-1);
+
+ // case 1 : sdk.info
+ defaultPath = getPathFromSdkInfoFile(true);
+
+ if (null == defaultPath) {
+ if (isWin()) {
+ defaultPath = getRegistryValue(WIN_INSTALL_NODE,
+ WIN_INSTALL_KEY) + File.separator + TIZEN_SDK_DATA;
+ } else if (isMac()) {
+ defaultPath = System.getenv(LINUX_INSTALL_ENV) + File.separator
+ + TIZEN_SDK_DATA;
+ } else if (isLinux()) {
+ defaultPath = System.getenv(LINUX_INSTALL_ENV) + File.separator
+ + TIZEN_SDK_DATA;
+ } else {
+ System.out.println("Please check OS and install the Tizen SDK"); //$NON-NLS-1$
+ System.exit(-1);
+ }
}
return defaultPath;
}
String rootPath = null;
BufferedReader br = null;
String line = null;
- try {
- rootPath = TIZEN_SDK_DATA_PATH + File.separator + INSTALL;
- File file = new File(rootPath);
- if (!file.isFile()) {
- return null;
- }
- br = new BufferedReader(new InputStreamReader(new FileInputStream(
- file)));
- line = br.readLine();
- if (null == line) {
- return null;
- } else {
- return line.substring(line.indexOf("=") + 1); //$NON-NLS-1$
- }
- } catch (IOException e) {
- System.out.println("Fail to read."); //$NON-NLS-1$
- e.printStackTrace();
- } finally {
- if (null != br) {
- try {
- br.close();
- } catch (IOException e) {
- e.printStackTrace();
+
+ // case 1 : sdk.info
+ rootPath = getPathFromSdkInfoFile(false);
+ if (null == rootPath) {
+ try {
+ rootPath = TIZEN_SDK_DATA_PATH + File.separator + INSTALL;
+ File file = new File(rootPath);
+ if (!file.isFile()) {
+ return null;
+ }
+ br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+ line = br.readLine();
+ if (null == line) {
+ return null;
+ } else {
+ return line.substring(line.indexOf("=") + 1); //$NON-NLS-1$
+ }
+ } catch (IOException e) {
+ System.out.println("Fail to read."); //$NON-NLS-1$
+ e.printStackTrace();
+ } finally {
+ if (null != br) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}
}
return list;
}
-
+
public static boolean deleteFile(File file) {
if (file.isDirectory()) {
String[] children = file.list();
// Directory is empty so delete
return file.delete();
}
+
+ private static String getPathFromSdkInfoFile(boolean isDataPath) {
+ String retPath = null;
+ BufferedReader br = null;
+ String line = null;
+ // case 1 : sdk.info
+ try {
+ String path = null;
+ path = Platform.getInstallLocation().getURL().getPath();
+ if (null != path && !path.isEmpty()) {
+ String infoPath = path + AnalyzerPaths.SDK_INFO_RELATIVE_PATH;
+ File infoFile = new File(infoPath);
+ if (infoFile.exists() && infoFile.isFile()) {
+ br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(infoFile)));
+ line = br.readLine(); // sdkpath
+ if (isDataPath) {
+ line = br.readLine(); // sdk data path
+ }
+ if (line != null) {
+ retPath = line.substring(line
+ .indexOf(CommonConstants.EQUAL) + 1);
+ }
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (null != br) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return retPath;
+ }
}
import java.io.IOException;
import java.io.InputStreamReader;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.communicator.CommunicatorUtils;
public static String getTizenSdkDataPath() {
String defaultPath = null;
- if (AnalyzerUtil.isLinux()) {
- defaultPath = System.getenv(AnalyzerConstants.LINUX_INSTALL_ENV)
- + File.separator + AnalyzerConstants.TIZEN_SDK_DATA;
- } else if (AnalyzerUtil.isWin()) {
- defaultPath = getRegistryValue(AnalyzerConstants.WIN_INSTALL_NODE,
- AnalyzerConstants.WIN_INSTALL_KEY)
- + File.separator
- + AnalyzerConstants.TIZEN_SDK_DATA;
- } else if (AnalyzerUtil.isMac()) {
- defaultPath = System.getenv(AnalyzerConstants.LINUX_INSTALL_ENV)
- + File.separator + AnalyzerConstants.TIZEN_SDK_DATA;
- } else {
- final Shell shell = AnalyzerUtil.getWorkbenchWindow().getShell();
- DADialog dialog = new DADialog(shell, SWT.NONE); // FIXME
- dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
- dialog.setMessage(AnalyzerLabels.OS_WARNING);
- if (dialog.open() == true) {
- System.exit(-1);
+
+ // case 1 : sdk.info
+ defaultPath = getPathFromSdkInfoFile(true);
+
+ if (null == defaultPath) {
+ if (AnalyzerUtil.isLinux()) {
+ defaultPath = System
+ .getenv(AnalyzerConstants.LINUX_INSTALL_ENV)
+ + File.separator + AnalyzerConstants.TIZEN_SDK_DATA;
+ } else if (AnalyzerUtil.isWin()) {
+ defaultPath = getRegistryValue(
+ AnalyzerConstants.WIN_INSTALL_NODE,
+ AnalyzerConstants.WIN_INSTALL_KEY)
+ + File.separator + AnalyzerConstants.TIZEN_SDK_DATA;
+ } else if (AnalyzerUtil.isMac()) {
+ defaultPath = System
+ .getenv(AnalyzerConstants.LINUX_INSTALL_ENV)
+ + File.separator + AnalyzerConstants.TIZEN_SDK_DATA;
+ } else {
+ final Shell shell = AnalyzerUtil.getWorkbenchWindow()
+ .getShell();
+ DADialog dialog = new DADialog(shell, SWT.NONE); // FIXME
+ dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
+ dialog.setMessage(AnalyzerLabels.OS_WARNING);
+ if (dialog.open() == true) {
+ System.exit(-1);
+ }
}
}
return defaultPath;
}
- public static String getDefaultRoot() {
- String rootPath = null;
+ private static String getPathFromSdkInfoFile(boolean isDataPath) {
+ String retPath = null;
BufferedReader br = null;
String line = null;
+ // case 1 : sdk.info
try {
- rootPath = AnalyzerPaths.TIZEN_SDK_DATA_PATH + File.separator
- + AnalyzerConstants.INSTALL;
- File file = new File(rootPath);
- if (!file.isFile()) {
- return null;
- }
- br = new BufferedReader(new InputStreamReader(new FileInputStream(
- file)));
- line = br.readLine();
- if (null == line) {
- return null;
- } else {
- return line.substring(line.indexOf(CommonConstants.EQUAL) + 1);
+ String path = null;
+ path = Platform.getInstallLocation().getURL().getPath();
+ if (null != path && !path.isEmpty()) {
+ String infoPath = path + AnalyzerPaths.SDK_INFO_RELATIVE_PATH;
+ File infoFile = new File(infoPath);
+ if (infoFile.exists() && infoFile.isFile()) {
+ br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(infoFile)));
+ line = br.readLine(); // sdkpath
+ if (isDataPath) {
+ line = br.readLine(); // sdk data path
+ }
+ if (line != null) {
+ retPath = line.substring(line
+ .indexOf(CommonConstants.EQUAL) + 1);
+ }
+ }
}
-
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
}
+ return retPath;
+ }
+
+ public static String getDefaultRoot() {
+ String rootPath = null;
+ BufferedReader br = null;
+ String line = null;
+
+ // case 1 : sdk.info
+ rootPath = getPathFromSdkInfoFile(false);
+ if (null == rootPath) {
+ try {
+ // case 2 : tizensdkpath
+ rootPath = AnalyzerPaths.TIZEN_SDK_DATA_PATH + File.separator
+ + AnalyzerConstants.INSTALL;
+ File file = new File(rootPath);
+ if (!file.isFile()) {
+ return null;
+ }
+ br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file)));
+ line = br.readLine();
+ if (null == line) {
+ return null;
+ } else {
+ return line
+ .substring(line.indexOf(CommonConstants.EQUAL) + 1);
+ }
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (null != br) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
return rootPath;
}