INTERNAL: tizen sdk path setting 74/23174/2
authorgreatim <jaewon81.lim@samsung.com>
Wed, 18 Jun 2014 17:36:36 +0000 (02:36 +0900)
committergreatim <jaewon81.lim@samsung.com>
Thu, 19 Jun 2014 02:54:28 +0000 (11:54 +0900)
modify the way to get tizen sdk installation path, using common-eplugin APIs.

Change-Id: Ib0c4ba1fb5d60b664f78a697b027c017cfc8e8ae
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer.workbench/META-INF/MANIFEST.MF
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java
org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/workbench/Application.java
org.tizen.dynamicanalyzer/META-INF/MANIFEST.MF

index b4411d0..04ceaa5 100644 (file)
@@ -19,3 +19,4 @@ Export-Package: org.tizen.dynamicanalyzer.common.path,
    org.eclipse.equinox.app,
    org.eclipse.swt.widgets",
  org.tizen.dynamicanalyzer.workbench.perspective;uses:="org.eclipse.ui"
+Import-Package: org.tizen.common.core.application
index 2439b2e..70b4cd9 100644 (file)
@@ -27,8 +27,6 @@ public class PathConstants {
        public static final String TOOL_RECORDER_NAME = "da_event"; //$NON-NLS-1$
 
        // constant related to path
-       public static final String TIZEN_SDK_DATA = "tizen-sdk-data";//$NON-NLS-1$
-       public static final String INSTALLATION_INFO = "tizensdkpath"; //$NON-NLS-1$
        public static final String TIZEN_FOLDER_ROOTSTRAPS = "rootstraps"; //$NON-NLS-1$
        public static final String TIZEN_FOLDER_USR = "usr"; //$NON-NLS-1$
        public static final String TIZEN_FOLDER_INCLUDE = "include"; //$NON-NLS-1$
index 27d1747..f6111c3 100755 (executable)
 
 package org.tizen.dynamicanalyzer.common.path;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.eclipse.core.runtime.Platform;
+import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.dynamicanalyzer.util.CommonUtil;
 
 // All paths of PathManager should not be ended with File.separater
 public class PathManager {
        private static String logPostFix = null;
 
-       private static final String SDK_INFO_RELATIVE_PATH = "../../sdk.info"; //$NON-NLS-1$
-
        // tizen paths
-       public static final String TIZEN_SDK_DATA_PATH = getTizenSdkDataPath();
        public static final String TIZEN_SDK_INSTALL_PATH = getTizenSdkInstallPath();
+       public static final String TIZEN_SDK_DATA_PATH = getTizenSdkDataPath();
 
        // sdb path
-       public static final String SDB_PATH = TIZEN_SDK_INSTALL_PATH
-                       + File.separator + PathConstants.TOOLS_FOLDER_NAME + File.separator
-                       + "sdb"; //$NON-NLS-1$
+       public static final String SDB_PATH = InstallPathConfig.getSDBPath(); //$NON-NLS-1$
 
        // dynamic analyzer paths
-       public static final String DA_DATA_PATH = TIZEN_SDK_DATA_PATH
-                       + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
-       public static final String DA_INSTALL_PATH = TIZEN_SDK_INSTALL_PATH
-                       + File.separator + PathConstants.TOOLS_FOLDER_NAME + File.separator
+       public static final String DA_DATA_PATH = TIZEN_SDK_DATA_PATH + File.separator
                        + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
-       public static final String DA_AUTOTEST_PATH = TIZEN_SDK_DATA_PATH
-                       + File.separator + "test" + File.separator
+       public static final String DA_INSTALL_PATH = TIZEN_SDK_INSTALL_PATH + File.separator
+                       + PathConstants.TOOLS_FOLDER_NAME + File.separator
                        + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
-       public static final String DA_READELF_PATH = DA_INSTALL_PATH
-                       + File.separator + PathConstants.TARGET_FOLDER_NAME;
+       public static final String DA_AUTOTEST_PATH = TIZEN_SDK_DATA_PATH + File.separator
+                       + "test" + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME;
+       public static final String DA_READELF_PATH = DA_INSTALL_PATH + File.separator
+                       + PathConstants.TARGET_FOLDER_NAME;
 
        public static final String DA_LOG_PATH = DA_DATA_PATH + File.separator
                        + PathConstants.LOGS_FOLDER_NAME;
@@ -72,24 +62,24 @@ public class PathManager {
                        + PathConstants.SETTING_FOLDER_NAME;
        public static final String DA_RPM_PATH = DA_DATA_PATH + File.separator
                        + PathConstants.RPM_FOLDER_NAME;
-       public static final String DA_CONFIG_FOLDER_PATH = DA_INSTALL_PATH
-                       + File.separator + PathConstants.CONFIG_FOLDER_NAME;
-       public static final String DA_TOOL_FOLDER_PATH = DA_INSTALL_PATH
-                       + File.separator + PathConstants.TOOL_FOLDER_NAME;
+       public static final String DA_CONFIG_FOLDER_PATH = DA_INSTALL_PATH + File.separator
+                       + PathConstants.CONFIG_FOLDER_NAME;
+       public static final String DA_TOOL_FOLDER_PATH = DA_INSTALL_PATH + File.separator
+                       + PathConstants.TOOL_FOLDER_NAME;
 
        public static final String DA_DEBUG_DATA_CHANNEL_LOG_FILE = DA_LOG_PATH
                        + File.separator + "data.log"; //$NON-NLS-1$
        public static final String DA_DEBUG_CONTROL_CHANNEL_LOG_FILE = DA_LOG_PATH
                        + File.separator + "control.log"; //$NON-NLS-1$
-       public static final String DA_TEMP_FOLDER_PATH = DA_SAVE_PATH
-                       + File.separator + PathConstants.TEMP_FOLDER_NAME;
-       public static final String DA_BINARY_AUTO_SAVE_FILE = DA_SAVE_PATH
-                       + File.separator + "BinarySettings.save";
+       public static final String DA_TEMP_FOLDER_PATH = DA_SAVE_PATH + File.separator
+                       + PathConstants.TEMP_FOLDER_NAME;
+       public static final String DA_BINARY_AUTO_SAVE_FILE = DA_SAVE_PATH + File.separator
+                       + "BinarySettings.save";
 
-       public static final String IDE_ACTIVE_PORT_PATH = DA_SAVE_PATH
-                       + File.separator + "active_da_plugin"; //$NON-NLS-1$
-       public static final String IDE_ACTIVE_SAVE_PORT_PATH = DA_SAVE_PATH
-                       + File.separator + "current_active_ide_port"; //$NON-NLS-1$
+       public static final String IDE_ACTIVE_PORT_PATH = DA_SAVE_PATH + File.separator
+                       + "active_da_plugin"; //$NON-NLS-1$
+       public static final String IDE_ACTIVE_SAVE_PORT_PATH = DA_SAVE_PATH + File.separator
+                       + "current_active_ide_port"; //$NON-NLS-1$
 
        public static boolean checkTizenPathValidation() {
                if (TIZEN_SDK_DATA_PATH == null || TIZEN_SDK_INSTALL_PATH == null) {
@@ -107,94 +97,10 @@ public class PathManager {
                return logPostFix;
        }
 
-       private static String getRegistryValue(String node, String key) {
-               BufferedReader br = null;
-               String value = "";
-
-               String query = "reg query " + "\"" + node + "\" /v " + "\"" + key + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-               try {
-                       Process process = Runtime.getRuntime().exec(query);
-                       String encoding = System.getProperty("sun.jnu.encoding"); //$NON-NLS-1$
-
-                       br = new BufferedReader(new InputStreamReader(
-                                       process.getInputStream(), encoding));
-
-                       String line = null;
-                       while ((line = br.readLine()) != null) {
-                               int index = line.indexOf("REG_SZ"); //$NON-NLS-1$
-                               if (index >= 0) {
-                                       value = line.substring(index + "REG_SZ".length()).trim(); //$NON-NLS-1$
-                               }
-                       }
-               } catch (IOException e) {
-                       e.printStackTrace();
-               } finally {
-                       CommonUtil.tryClose(br);
-               }
-               return value;
-       }
-
-       private static String getPathFromSdkInfoFile(boolean isDataPath) {
-               String retPath = null;
-               BufferedReader br = null;
-
-               try {
-                       String curpath = null;
-                       curpath = Platform.getInstallLocation().getURL().getPath();
-                       if (null != curpath && !curpath.isEmpty()) {
-                               String sdkinfoPath = curpath + SDK_INFO_RELATIVE_PATH;
-                               File sdkinfoFile = new File(sdkinfoPath);
-                               if (sdkinfoFile.exists() && sdkinfoFile.isFile()) {
-                                       br = new BufferedReader(new InputStreamReader(
-                                                       new FileInputStream(sdkinfoFile)));
-
-                                       String line = br.readLine(); // sdk install path
-                                       if (isDataPath) {
-                                               line = br.readLine(); // sdk data path
-                                       }
-                                       if (line != null) {
-                                               retPath = line.substring(line.indexOf("=") + 1);
-                                       }
-                               }
-                       }
-               } catch (IOException e) {
-                       e.printStackTrace();
-               } finally {
-                       if (null != br) {
-                               try {
-                                       br.close();
-                               } catch (IOException e) {
-                                       e.printStackTrace();
-                               }
-                       }
-               }
-
-               return retPath;
-       }
-
        public static String getTizenSdkDataPath() {
                String defaultPath = null;
 
-               // case 1 : read from sdk.info
-               defaultPath = getPathFromSdkInfoFile(true);
-
-               // case 2 : get default install directory
-               if (null == defaultPath || defaultPath.isEmpty()) {
-                       if (CommonUtil.isLinux()) {
-                               defaultPath = System.getenv(PathConstants.LINUX_INSTALL_ENV)
-                                               + File.separator + PathConstants.TIZEN_SDK_DATA;
-                       } else if (CommonUtil.isWin()) {
-                               defaultPath = getRegistryValue(PathConstants.WIN_INSTALL_NODE,
-                                               PathConstants.WIN_INSTALL_KEY)
-                                               + File.separator
-                                               + PathConstants.TIZEN_SDK_DATA;
-                       } else if (CommonUtil.isMac()) {
-                               defaultPath = System.getenv(PathConstants.LINUX_INSTALL_ENV)
-                                               + File.separator + PathConstants.TIZEN_SDK_DATA;
-                       } else {
-                               defaultPath = "";
-                       }
-               }
+               defaultPath = InstallPathConfig.getUserDataPath();
 
                File file = new File(defaultPath);
                if (file == null || !file.exists()) {
@@ -205,40 +111,16 @@ public class PathManager {
        }
 
        public static String getTizenSdkInstallPath() {
-               String retPath = null;
-               BufferedReader br = null;
-
-               // case 1 : sdk.info
-               retPath = getPathFromSdkInfoFile(false);
-
-               // case 2 : tizensdkpath in tizen-sdk-data directory
-               if (null == retPath || retPath.isEmpty()) {
-                       try {
-                               String infoPath = TIZEN_SDK_DATA_PATH + File.separator
-                                               + PathConstants.INSTALLATION_INFO;
-                               File file = new File(infoPath);
-                               if (file.exists() && file.isFile()) {
-                                       br = new BufferedReader(new InputStreamReader(
-                                                       new FileInputStream(file)));
-                                       String line = br.readLine();
-                                       if (null != line) {
-                                               retPath = line.substring(line.indexOf("=") + 1);
-                                       }
-                               }
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       } finally {
-                               if (null != br) {
-                                       try {
-                                               br.close();
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                       }
-                               }
-                       }
+               String defaultPath = null;
+
+               defaultPath = InstallPathConfig.getSDKPath();
+
+               File file = new File(defaultPath);
+               if (file == null || !file.exists()) {
+                       defaultPath = null;
                }
 
-               return retPath;
+               return defaultPath;
        }
 
        // get tizen header file directory in sdk local rootstraps
@@ -277,13 +159,12 @@ public class PathManager {
        public static String getTargetPath(String platform) {
                if (null != platform && !platform.isEmpty()) {
                        return TIZEN_SDK_INSTALL_PATH + File.separator
-                                       + PathConstants.PLATFORM_FOLDER_NAME + File.separator
-                                       + platform + File.separator
-                                       + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME
+                                       + PathConstants.PLATFORM_FOLDER_NAME + File.separator + platform
+                                       + File.separator + PathConstants.DYNAMIC_ANALYZER_FOLDER_NAME
                                        + File.separator;
                } else {
-                       return DA_INSTALL_PATH + File.separator
-                                       + PathConstants.TARGET_FOLDER_NAME + File.separator;
+                       return DA_INSTALL_PATH + File.separator + PathConstants.TARGET_FOLDER_NAME
+                                       + File.separator;
                }
        }
 
@@ -310,8 +191,7 @@ public class PathManager {
 
                                @Override
                                public boolean accept(File dir, String name) {
-                                       return name
-                                                       .contains(PathConstants.BASE_PLATFORM_PLUGIN_FOLDER_NAME);
+                                       return name.contains(PathConstants.BASE_PLATFORM_PLUGIN_FOLDER_NAME);
                                }
                        });
                } else {
@@ -322,9 +202,8 @@ public class PathManager {
                        return "";
                }
 
-               String aboutFilePath = aboutFolderPath + File.separator
-                               + files[files.length - 1] + File.separator
-                               + PathConstants.ABOUT_FILE_NAME;
+               String aboutFilePath = aboutFolderPath + File.separator + files[files.length - 1]
+                               + File.separator + PathConstants.ABOUT_FILE_NAME;
 
                return aboutFilePath;
        }
@@ -342,8 +221,7 @@ public class PathManager {
 
                                @Override
                                public boolean accept(File dir, String name) {
-                                       return name
-                                                       .contains(PathConstants.WORKBENCH_PLUGIN_FOLDER_NAME);
+                                       return name.contains(PathConstants.WORKBENCH_PLUGIN_FOLDER_NAME);
                                }
                        });
                } else {
@@ -354,8 +232,7 @@ public class PathManager {
                        return "";
                }
 
-               String aboutFilePath = aboutFolderPath + File.separator
-                               + files[files.length - 1];
+               String aboutFilePath = aboutFolderPath + File.separator + files[files.length - 1];
 
                return aboutFilePath;
        }
@@ -363,9 +240,8 @@ public class PathManager {
        public static String getRootstrapsPath(String platform) {
                if (platform != null) {
                        return TIZEN_SDK_INSTALL_PATH + File.separator
-                                       + PathConstants.PLATFORM_FOLDER_NAME + File.separator
-                                       + platform + File.separator
-                                       + PathConstants.TIZEN_FOLDER_ROOTSTRAPS;
+                                       + PathConstants.PLATFORM_FOLDER_NAME + File.separator + platform
+                                       + File.separator + PathConstants.TIZEN_FOLDER_ROOTSTRAPS;
                } else {
                        return "";
                }
index 5073cb4..35a11df 100755 (executable)
@@ -109,6 +109,16 @@ public class Application implements IApplication {
        public Object start(IApplicationContext context) throws Exception {
                Display display = PlatformUI.createDisplay();
 
+               // set workspace directory for dynamic analyzer
+               // this work must be done first before any other work.
+               Location instanceLoc = Platform.getInstanceLocation();
+               String path = Platform.getInstallLocation().getURL().getPath() + File.separator;
+               try {
+                       instanceLoc.set(new URL("file", null, path), false);
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               }
+
                // check for tizen sdk installation
                boolean pathValidness = PathManager.checkTizenPathValidation();
                if (pathValidness == false) {
@@ -120,15 +130,6 @@ public class Application implements IApplication {
                        System.exit(-1);
                }
 
-               // set workspace directory for dynamic analyzer
-               // why?
-               Location instanceLoc = Platform.getInstanceLocation();
-               String path = PathManager.DA_INSTALL_PATH + File.separator;
-               try {
-                       instanceLoc.set(new URL("file", null, path), false);
-               } catch (MalformedURLException e) {
-                       e.printStackTrace();
-               }
 
                DA_LOG.performance("TEST", DALogger.testState.START);
                
index e04c294..e6882a8 100644 (file)
@@ -7,10 +7,11 @@ Bundle-Version: 1.0.0.qualifier
 Bundle-Vendor: %providerName
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
+ org.tizen.common,
  org.tizen.dynamicanalyzer.common;bundle-version="1.0.0",
- org.tizen.dynamicanalyzer.widgets;bundle-version="1.0.0",
  org.tizen.dynamicanalyzer.appearance;bundle-version="1.0.0",
- org.tizen.dynamicanalyzer.workbench;bundle-version="2.1.0"
+ org.tizen.dynamicanalyzer.widgets;bundle-version="1.0.0",
+ org.tizen.dynamicanalyzer.workbench;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Activator: org.tizen.dynamicanalyzer.common.AnalyzerPlugin
 Bundle-ActivationPolicy: lazy
@@ -24,7 +25,6 @@ Bundle-ClassPath: .,
  lib/protobuf.jar
 Import-Package: junit.framework;version="4.8.2",
  org.junit,
- org.tizen.common.sdb.command,
  org.tizen.sdblib,
  org.tizen.sdblib.exception,
  org.tizen.sdblib.receiver,