List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.nokia.s60tools.analyzetool.preferences.AnalyzeToolPreferencePage.java
License:Open Source License
/** * Checks preferences initial values if logging mode is not set to S60 * disables S60 data file name selections. *///from w ww .ja va 2 s . c om public final void checkInitValues() { IPreferenceStore store = Activator.getPreferences(); // get stored atool folder String atoolFolder = store.getString(Constants.ATOOL_FOLDER); atoolVerLabel.setText(Constants.PREFS_ATOOL_VER_NOT_FOUND); // if atool folder is set to point default atool location if (atoolFolder.equals(Constants.DEFAULT_ATOOL_FOLDER)) { // check that stored atool location exists File file = new File(atoolFolder); if (file.exists()) { // if exists use this location and update // preference page buttons useDefaultLocation.setSelection(false); store.setValue(Constants.USE_INTERNAL, false); } else { // location could not found => use internal atool useDefaultLocation.setSelection(true); store.setValue(Constants.USE_INTERNAL, true); } } else { boolean useDef = store.getBoolean(Constants.USE_INTERNAL); useDefaultLocation.setSelection(useDef); } // get atool.exe path and set it atool.exe path field String atoolPath = store.getString(Constants.USER_SELECTED_FOLDER); atoolDirText.setText(atoolPath); // update preference page buttons handleDefaultLocationChange(); // get logging mode and update buttons String fileMode = store.getString(Constants.LOGGING_MODE); setGroupButtons(fileMode); logPathText.setText(store.getString(Constants.DEVICE_LOG_FILE_PATH)); fileNameText.setText(store.getString(Constants.DEVICE_LOG_FILE_NAME)); logPathText.setText(store.getString(Constants.DEVICE_LOG_FILE_PATH)); fileNameText.setText(store.getString(Constants.DEVICE_LOG_FILE_NAME)); verboseButton.setSelection(store.getBoolean(Constants.ATOOL_VERBOSE)); // get stored callstack size int callstackSize = store.getInt(Constants.CALLSTACK_SIZE); if (callstackSize == 0) { zeroButton.setSelection(true); spinner.setEnabled(false); } else if (callstackSize == 40) { fortyButton.setSelection(true); spinner.setEnabled(false); } else if (callstackSize == 100) { hundredButton.setSelection(true); spinner.setEnabled(false); } else { // if callstack size is set to custom area // enable spinner and set stored callstack size customButton.setSelection(true); spinner.setEnabled(true); spinner.setSelection(callstackSize); } }
From source file:com.nokia.s60tools.analyzetool.ui.MainView.java
License:Open Source License
/** * Change report detail level./*from ww w . ja v a2s .co m*/ */ public final void changeDetailLevel() { // sync with UI thread PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { // get preference store IPreferenceStore store = Activator.getPreferences(); // get active report level String reportLevel = store.getString(Constants.REPORT_LEVEL); boolean updateMemLeakAlso = false; // set new report level if (Constants.REPORT_EVERY.equals(reportLevel)) { store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_KNOWN); updateMemLeakAlso = true; } else if (Constants.REPORT_KNOWN.equals(reportLevel)) { store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_TOPMOST); } else if (Constants.REPORT_TOPMOST.equals(reportLevel)) { store.setValue(Constants.REPORT_LEVEL, Constants.REPORT_EVERY); updateMemLeakAlso = true; } if (updateMemLeakAlso && runView != null) { activeTreeItem = null; // set view content runView.setInput(getResults(false)); // refresh view runView.refresh(); // if last selected item not found current item list if (activeTreeItem == null) { runView.setAutoExpandLevel(2); } else { // set selection to correct item runView.setSelection(new StructuredSelection(activeTreeItem), true); } } if (callstackView != null) { // update view callstack view content callstackView.setInput(getCallStack(activeTreeItem)); // expand all the trees on call stack view callstackView.expandAll(); } // change tooltip changeReportActionTooltip(); } }); }
From source file:com.nokia.s60tools.analyzetool.ui.MainView.java
License:Open Source License
/** * Change logging mode.//w w w .j a va2 s. c o m * * @param loggingMode * Used logging mode */ public final void changeLogTarget(final String loggingMode) { if (logTargetMenu == null) { return; } // get preference store IPreferenceStore store = Activator.getPreferences(); String usedLoggingMode = ""; // if no logging mode given get it from the AnalyzeTool preferences if (loggingMode == null) { usedLoggingMode = store.getString(Constants.LOGGING_MODE); } // logging mode is given => so start to use it else { store.setValue(Constants.LOGGING_MODE, loggingMode); usedLoggingMode = loggingMode; } if (Constants.LOGGING_S60.equals(usedLoggingMode)) { logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_CELLURAR)); logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_S60); if (loggingMode == null) { s60LogTargetAction.setChecked(true); externalFastLogTargetAction.setChecked(false); askLogTargetAction.setChecked(false); } } else if (Constants.LOGGING_EXT_FAST.equals(usedLoggingMode)) { logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_COMPUTER_FAST)); logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_FAST); if (loggingMode == null) { s60LogTargetAction.setChecked(false); externalFastLogTargetAction.setChecked(true); askLogTargetAction.setChecked(false); } } // current logging mode is "ask_always" else { logTargetMenu.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_ASK)); logTargetMenu.setToolTipText(Constants.ACTION_CHANGE_LOGGING_MODE_TOOLTIP_ASK); if (loggingMode == null) { s60LogTargetAction.setChecked(false); externalFastLogTargetAction.setChecked(false); askLogTargetAction.setChecked(true); } } // if the fast data gathering mode is enabled by the preference page => // enable also toolbar option // else disable fast data gathering mode externalFastLogTargetAction.setEnabled(store.getBoolean(Constants.LOGGING_FAST_ENABLED)); }
From source file:com.nokia.s60tools.analyzetool.ui.MainView.java
License:Open Source License
/** * Changes "Change report detail level" action tooltip. *///from w w w . ja v a2 s . co m public final void changeReportActionTooltip() { if (changeDetails == null) { return; } // get preference store IPreferenceStore store = Activator.getPreferences(); // get active report level String reportLevel = store.getString(Constants.REPORT_LEVEL); // set new report level if (Constants.REPORT_EVERY.equals(reportLevel)) { changeDetails.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_DETAILS_ALL)); changeDetails.setToolTipText(Constants.ACTION_CHANGE_REPORT_LEVEL_ALL); } else if (Constants.REPORT_KNOWN.equals(reportLevel)) { changeDetails.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_DETAILS_KNOWN)); changeDetails.setToolTipText(Constants.ACTION_CHANGE_REPORT_LEVEL_KNOWN); } else if (Constants.REPORT_TOPMOST.equals(reportLevel)) { changeDetails.setImageDescriptor(Activator.getImageDescriptor(Constants.BUTTON_DETAILS_TOPMOST)); changeDetails.setToolTipText(Constants.ACTION_CHANGE_REPORT_LEVEL_TOPMOST); } }
From source file:com.nokia.s60tools.analyzetool.ui.OutputModeDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new GridLayout(1, false)); traceOutputButton = new Button(container, SWT.RADIO); traceOutputButton.setToolTipText(Constants.PREFS_EXT_FAST_TOOLTIP); traceOutputButton.setText(Constants.PREFS_EXT_FAST); traceOutputButton.addListener(SWT.Selection, this); fileOutputButton = new Button(container, SWT.RADIO); fileOutputButton.setToolTipText(Constants.PREFS_S60_TOOLTIP); fileOutputButton.setText(Constants.PREFS_S60); fileOutputButton.addListener(SWT.Selection, this); Composite compS60 = new Composite(container, SWT.NULL); final GridLayout layoutS60 = new GridLayout(); layoutS60.marginLeft = 15;/* w w w. j av a 2 s. co m*/ layoutS60.numColumns = 2; compS60.setLayout(layoutS60); logPath = new Label(compS60, SWT.NONE); logPath.setToolTipText("Log file path in the device."); logPath.setText("Log file path:"); logPathText = new Text(compS60, SWT.BORDER); logPathText.setLayoutData(new GridData(280, SWT.DEFAULT)); logFileName = new Label(compS60, SWT.NONE); logFileName.setToolTipText("Log file name."); logFileName.setText("Filename:"); logFileNameText = new Text(compS60, SWT.BORDER); logFileNameText.setLayoutData(new GridData(280, SWT.DEFAULT)); IPreferenceStore store = Activator.getPreferences(); String path = store.getString(Constants.DEVICE_LOG_FILE_PATH); if (!path.equals("")) { logPathText.setText(path); } else { logPathText.setText("C:\\logs\\atool\\"); } String fileName = store.getString(Constants.DEVICE_LOG_FILE_NAME); if (!fileName.equals("")) { logFileNameText.setText(fileName); } else { logFileNameText.setText("%processname%.dat"); } traceOutputButton.setSelection(true); logPath.setEnabled(false); logPathText.setEnabled(false); logFileName.setEnabled(false); logFileNameText.setEnabled(false); return container; }
From source file:com.nokia.s60tools.compatibilityanalyser.model.CompatibilityAnalyserEngine.java
License:Open Source License
/** * This method gets invoked when User tries to use Core Tools from WebServer. * This method checks whether download of CoreTools is required or not. * The method checks if previous donwloaded Core Tools exist in File System. * If they exist, then it checks whether previous WebServer URL is same as Current URL. * If they are same then it checks the last modification time of CoreTools in WebServer. * If modification time of Tools in WebServer is not higher than the previous downloaded Tools, * then the tool assumes that WebServer Content is not modified and returns false. * In all other cases, the method returns true. * @param currentUrl specfies Current Webserver URL. * @return boolean to indicate the need for Download of CoreTools from WebServer. *///ww w .ja v a 2 s.c o m public static boolean isDownloadAndExtractionNeeded(String currentUrl) { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); String previousUrl = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL); String previousPath = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH); if (!"".equals(previousPath)) { File prevFolder = new File(previousPath); if (prevFolder.exists() && previousUrl.equals(currentUrl)) { try { URL url = new URL(currentUrl); URLConnection connection = url.openConnection(); Long webServerModTime = connection.getLastModified(); if (webServerModTime <= prevFolder.lastModified()) return false; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } return true; }
From source file:com.nokia.s60tools.compatibilityanalyser.model.HeaderAnalyserEngine.java
License:Open Source License
/** * This method validates the Current SDK and Baseline SDK data and * throws back error messages back to UI. * Also, it prepares the config file used in invoking HA through Checkbc * @param currentData specifies the Current SDK data * @param baselineData specifies the Baseline SDK data * @returns any error in the Input/*from www . j a va2s .com*/ */ public String readAndCheckInput(ProductSdkData currentData, BaselineSdkData baselineData) { pythonPath = PythonUtilities.getPythonPath(); if (pythonPath == null) return Messages.getString("HeaderAnalyserEngine.PythonNotFoundError"); //$NON-NLS-1$ // Validating the python version boolean python_validity = PythonUtilities .validatePython(CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION); if (!python_validity) return Messages.getString("CompatibilityAnalyserEngine.InstallValidPython") //$NON-NLS-1$ + CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION; if (baselineData == null) { return Messages.getString("HeaderAnalyserEngine.BaselineNotExistError"); } String coreToolsExtraction = null; if (currentData.useWebServerCoreTools) { if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentData.urlPathofCoreTools)) { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); //If core tools were already downloaded from web server earlier, they will be deleted. String previousContents = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR); if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$ { File oldContents = new File(previousContents); if (oldContents.exists()) FileMethods.deleteFolder(previousContents); } String targetPath = FileMethods.appendPathSeparator(CompatibilityAnalyserEngine.getWorkspacePath()) + Messages.getString("HeaderAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$ coreToolsExtraction = CompatibilityAnalyserEngine .readAndDownloadSupportedCoretools(currentData.urlPathofCoreTools, targetPath, monitor); if (coreToolsExtraction == null) { prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL, currentData.urlPathofCoreTools); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH, CompatibilityAnalyserEngine.getWebServerToolsPath()); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR, targetPath); currentData.coreToolsPath = CompatibilityAnalyserEngine.getWebServerToolsPath(); } } else { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); currentData.coreToolsPath = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH); } } if (currentData.useDefaultCoreTools) { String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin(); if (corePath == null || corePath.equalsIgnoreCase("")) //$NON-NLS-1$ { return Messages.getString("HeaderAnalyserEngine.CouldnotfindToolsPluginError"); //$NON-NLS-1$ } else { File toolsFolder = new File(FileMethods.appendPathSeparator(corePath) + Messages.getString("HeaderAnalyserEngine.BCTools")); //$NON-NLS-1$ if (!toolsFolder.exists()) return new String( Messages.getString("HeaderAnalyserEngine.ToolsPluginDoesNotContainCoreComponents")); //$NON-NLS-1$ currentData.coreToolsPath = FileMethods.appendPathSeparator(corePath) + Messages.getString("HeaderAnalyserEngine.BCTools") + File.separator; } } if (coreToolsExtraction == null) { try { //Validating the DATA VERSION String dv = CompatibilityAnalyserEngine.getDataVersion(currentData.coreToolsPath); int num = Integer.parseInt(dv); if (num != CompatibilityAnalyserPlugin.DATA_VERSION) { if (!currentData.coreToolsPath .equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath())) { feedbackHandler.reStartAnalysisUsingSameData("Compatibility Analyser - Header Analysis", Messages.getString("HeaderAnalyserEngine.CoreToolsAreNotCompatible") + CompatibilityAnalyserPlugin.DATA_VERSION + ".\n\nWould you like to run analysis with the default core tools?"); return ""; } return "Please update the " + CompatibilityAnalyserPlugin.CORE_COMPONENTS_PLUGIN_ID + " plugin. The one being used is incompatible with the tool."; } } catch (Exception e1) { return Messages.getString("HeaderAnalyserEngine.InvalidDataVersion"); //$NON-NLS-1$ } try { config_folder = engine.getCurrentSdkData().getconfigfolder(); configFile = new File( config_folder + File.separator + Messages.getString("HeaderAnalyserEngine.carbide_ha.cf")); //$NON-NLS-1$ temp_folder = config_folder + File.separator + "temp"; if (!configFile.getParentFile().exists()) return Messages.getString("HeaderAnalyserEngine.InvalidCoreToolsPathError"); //$NON-NLS-1$ if (configFile.exists()) configFile.delete(); if (!configFile.createNewFile()) { return Messages.getString("HeaderAnalyserEngine.ErrorInConfigFileCreation"); } FileOutputStream outStr = new FileOutputStream(configFile); outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_NAME") + baselineData.baselineSdkName + "\n").getBytes()); //$NON-NLS-1$ outStr.write( (Messages.getString("HeaderAnalyserEngine.BASELINE_SDK_DIR") + baselineData.epocRoot + "\n") //$NON-NLS-2$ .getBytes()); outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_SDK_S60_VERSION") + baselineData.baselineSdkVersion + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_NAME") + currentData.productSdkName + "\n").getBytes()); //$NON-NLS-1$ outStr.write( (Messages.getString("HeaderAnalyserEngine.CURRENT_SDK_DIR") + currentData.epocRoot + "\n") //$NON-NLS-2$ .getBytes()); outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_SDK_S60_VERSION") + currentData.productSdkVersion + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.TEMP") + temp_folder + "\n").getBytes()); //$NON-NLS-2$ //$NON-NLS-3$ outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_HEADERS") + FileMethods.convertToOneString(baselineData.baselineHeaderDir) + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_HEADERS") + FileMethods.convertToOneString(currentData.currentHeaderDir) + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.BASELINE_SYSTEMINCLUDEDIR") + baselineData.baselineIncludes + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.CURRENT_SYSTEMINCLUDEDIR") + currentData.readIncludePaths() + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.USE_PLATFORM_DATA") + currentData.usePlatformData + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("HeaderAnalyserEngine.RECURSIVE_HEADERS") + currentData.useRecursive + "\n").getBytes()); //$NON-NLS-1$ if (currentData.replaceSet != null && currentData.replaceSet.size() > 0) { StringBuffer sb = new StringBuffer(""); for (String s : currentData.replaceSet) { sb.append(s + ";"); } outStr.write((Messages.getString("HeaderAnalyserEngine.REPLACE_HEADERS") + sb.toString() + "\n") //$NON-NLS-2$ .getBytes()); } if (currentData.forcedHeaders != null && currentData.forcedHeaders.size() > 0) { currentForcedHeaders = new File( config_folder + File.separator + "carbide_currentforced_headers.h"); if (currentForcedHeaders.exists()) currentForcedHeaders.delete(); if (!currentForcedHeaders.createNewFile()) { return "Unable to prepare Forced Headers List. CoreTools path is write protected."; } FileOutputStream forcedOutStr = new FileOutputStream(currentForcedHeaders); for (String s : currentData.forcedHeaders) { forcedOutStr.write(("#include <" + s + ">" + "\n").getBytes()); } if (forcedOutStr != null) forcedOutStr.close(); outStr.write( ("CURRENT_FORCED_HEADERS=" + currentForcedHeaders.getAbsolutePath() + "\n").getBytes()); } if (baselineData.forcedHeaders != null && baselineData.forcedHeaders.length > 0) { baselineForcedHeaders = new File( config_folder + File.separator + "carbide_baselineforced_headers.h"); if (baselineForcedHeaders.exists()) baselineForcedHeaders.delete(); if (!baselineForcedHeaders.createNewFile()) { return "Unable to prepare Forced Headers List. CoreTools path is write protected."; } FileOutputStream forcedOutStr = new FileOutputStream(baselineForcedHeaders); for (String s : baselineData.forcedHeaders) { forcedOutStr.write(("#include <" + s + ">" + "\n").getBytes()); } if (forcedOutStr != null) forcedOutStr.close(); outStr.write(("BASELINE_FORCED_HEADERS=" + baselineForcedHeaders.getAbsolutePath() + "\n") .getBytes()); } reportName = FileMethods.appendPathSeparator(currentData.reportPath) + Messages.getString("HeaderAnalyserEngine.Headers_") + currentData.reportName; outStr.write( (Messages.getString("HeaderAnalyserEngine.REPORT_FILE_HEADERS") + currentData.reportPath + File.separator + Messages.getString("HeaderAnalyserEngine.Headers_") //$NON-NLS-1$ + currentData.reportName + "\n").getBytes()); //$NON-NLS-1$ if (outStr != null) outStr.close(); if (currentData.filterNeeded) prepareKnownIssuesPath(); } catch (Exception e) { e.printStackTrace(); return e.getMessage(); } } else return coreToolsExtraction; return null; }
From source file:com.nokia.s60tools.compatibilityanalyser.model.HeaderAnalyserEngine.java
License:Open Source License
/** * This method gets invoked if user selects Filter option. * This method reads the selecetd KnownIssues configuration from the preferences * and writes the KnownIssues path in the given configuration file. * @param report specifies name of the report being filtered. *//*from w ww. j a v a 2s . c om*/ private void prepareKnownIssuesPath() { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); LastUsedKnownissues issuesData = new LastUsedKnownissues(); String knownIssuesPath = null; try { if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LOCAL_ISSUES)) { String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.LOCAL_ISSUES_PATH); totalIssueFiles = issuesArr.length; if (issuesArr != null && issuesArr.length != 0) { String all = issuesArr[0]; for (int i = 1; i < issuesArr.length; i++) { all = all + ";" + issuesArr[i]; } knownIssuesPath = all; } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.DEFAULT_ISSUES)) { totalIssueFiles = 1; String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin(); if (corePath == null || corePath.equalsIgnoreCase("")) { return; } else { File toolsFolder = new File(FileMethods.appendPathSeparator(corePath) + Messages.getString("HeaderAnalyserEngine.BCTools")); if (!toolsFolder.exists()) return; else knownIssuesPath = FileMethods.appendPathSeparator(toolsFolder.getAbsolutePath()) + Messages.getString("HeaderAnalyserEngine.data") + File.separator + Messages.getString("HeaderAnalyserEngine.knownissues.xml"); //$NON-NLS-3$ } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_ISSUES)) { String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.ISSUES_URL); totalIssueFiles = issuesArr.length; if (issuesArr != null && issuesArr.length != 0) { String all = issuesArr[0]; for (int i = 1; i < issuesArr.length; i++) { all = all + ";" + issuesArr[i]; } knownIssuesPath = all; } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LATEST_ISSUES)) { totalIssueFiles = 1; knownIssuesPath = prefStore.getString(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL); } FileOutputStream outStream = new FileOutputStream(configFile, true); outStream.write( (Messages.getString("HeaderAnalyserEngine.ISSUES_FILE") + knownIssuesPath + "\n").getBytes()); if (outStream != null) outStream.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.nokia.s60tools.compatibilityanalyser.model.LibraryAnalyserEngine.java
License:Open Source License
/** * This method validates the Current SDK and Baseline SDK data and * throws back error messages to UI./*from w w w .jav a2s . co m*/ * Also, it prepares the config file used in invoking OC through Checkbc * @param currentData specifies the Current SDK data * @param baselineData specifies the Baseline SDK data * @returns any error in the Input */ public String readAndCheckInput(ProductSdkData currentData, BaselineSdkData baselineData) { pythonPath = PythonUtilities.getPythonPath(); if (pythonPath == null) return Messages.getString("LibraryAnalyserEngine.PythonNotFoundError"); //$NON-NLS-1$ boolean python_validity = PythonUtilities .validatePython(CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION); if (!python_validity) return Messages.getString("CompatibilityAnalyserEngine.CompatibilityAnalyserEngine.InstallValidPython") + CompatibilityAnalyserEngine.SUPPORTED_PYTHON_VERSION; if (baselineData == null) return Messages.getString("LibraryAnalyserEngine.BaselineProfileNotFoundError"); //$NON-NLS-1$ String coreToolsExtraction = null; if (currentData.useWebServerCoreTools) { if (CompatibilityAnalyserEngine.isDownloadAndExtractionNeeded(currentData.urlPathofCoreTools)) { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); //If coretools are downloaded earlier from webserver, they will be deleted String previousContents = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR); if (previousContents != null && !previousContents.equals("")) //$NON-NLS-1$ { File oldContents = new File(previousContents); if (oldContents.exists()) FileMethods.deleteFolder(previousContents); } String targetPath = CompatibilityAnalyserEngine.getWorkspacePath() + File.separator + Messages.getString("LibraryAnalyserEngine.WebServerContentsNew"); //$NON-NLS-1$ coreToolsExtraction = CompatibilityAnalyserEngine .readAndDownloadSupportedCoretools(currentData.urlPathofCoreTools, targetPath, monitor); if (coreToolsExtraction == null) { prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_URL, currentData.urlPathofCoreTools); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH, CompatibilityAnalyserEngine.getWebServerToolsPath()); prefStore.setValue(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_ROOTDIR, targetPath); currentData.coreToolsPath = CompatibilityAnalyserEngine.getWebServerToolsPath(); } } else { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); currentData.coreToolsPath = prefStore .getString(CompatibilityAnalyserPreferencesConstants.PREVIOUS_WEB_CORE_TOOLS_PATH); } } if (currentData.useDefaultCoreTools) { String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin(); if (corePath.equalsIgnoreCase("")) //$NON-NLS-1$ { return Messages.getString("LibraryAnalyserEngine.ToolsPluginNotFoundError"); //$NON-NLS-1$ } else { File toolsFolder = new File(FileMethods.appendPathSeparator(corePath) + Messages.getString("LibraryAnalyserEngine.Bctools")); //$NON-NLS-1$ if (!toolsFolder.exists()) return new String( Messages.getString("LibraryAnalyserEngine.CoreComponentsNotFoundInPluginError")); //$NON-NLS-1$ currentData.coreToolsPath = FileMethods.appendPathSeparator(corePath) + Messages.getString("LibraryAnalyserEngine.Bctools") + File.separator; //$NON-NLS-1$ } } if (coreToolsExtraction == null) { try { //Validating the DATA VERSION String dv = CompatibilityAnalyserEngine.getDataVersion(currentData.coreToolsPath); int num = Integer.parseInt(dv); if (num != CompatibilityAnalyserPlugin.DATA_VERSION) { if (!currentData.coreToolsPath .equalsIgnoreCase(CompatibilityAnalyserPlugin.getDefaltCoretoolsPath())) { feedbackHandler.reStartAnalysisUsingSameData("Compatibility Analyser - Library Analysis", Messages.getString("HeaderAnalyserEngine.CoreToolsAreNotCompatible") + CompatibilityAnalyserPlugin.DATA_VERSION + ".\n\nWould you like to run analysis with the default core tools?"); return ""; } return "Please update the " + CompatibilityAnalyserPlugin.CORE_COMPONENTS_PLUGIN_ID + " plugin. The one being used is incompatible with the tool."; } } catch (Exception e1) { return Messages.getString("LibraryAnalyserEngine.InvalidDataVersion"); //$NON-NLS-1$ } try { config_folder = engine.getCurrentSdkData().getconfigfolder(); configFile = new File( config_folder + File.separator + Messages.getString("LibraryAnalyserEngine.carbide_oc.cf")); temp_folder = config_folder + File.separator + "temp"; if (configFile.exists()) configFile.delete(); if (!configFile.createNewFile()) { return Messages.getString("LibraryAnalyserEngine.CouldNotFindConfigFile"); //$NON-NLS-1$ } FileOutputStream outStr = new FileOutputStream(configFile); outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_NAME") + currentData.productSdkName + "\n").getBytes()); outStr.write( (Messages.getString("LibraryAnalyserEngine.CURRENT_SDK_DIR") + currentData.epocRoot + "\n") .getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_SDK_S60_VERSION") + currentData.productSdkVersion + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_NAME") + baselineData.baselineSdkName + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_SDK_DIR") + baselineData.epocRoot + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_SDK_S60_VERSION") + baselineData.baselineSdkVersion + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.TOOLCHAIN") + currentData.toolChain + "\n") .getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_IMPORTLIBRARIES") + FileMethods.convertToOneString(currentData.currentLibsDir) + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.CURRENT_IMPORTDLLS") + FileMethods.convertToOneString(currentData.currentDllDir) + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_IMPORTLIBRARIES") + FileMethods.convertToOneString(baselineData.baselineLibsDir) + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.BASELINE_IMPORTDLLS") + FileMethods.convertToOneString(baselineData.baselineDllDir) + "\n").getBytes()); outStr.write((Messages.getString("LibraryAnalyserEngine.TOOLCHAIN_PATH") + currentData.toolChainPath + "\n").getBytes()); reportName = currentData.reportPath + File.separator + Messages.getString("LibraryAnalyserEngine.Libraries_") + currentData.reportName; outStr.write( (Messages.getString("LibraryAnalyserEngine.REPORT_FILE_LIBRARIES") + currentData.reportPath + File.separator + Messages.getString("LibraryAnalyserEngine.Libraries_") + currentData.reportName + "\n").getBytes()); //$NON-NLS-1$ outStr.write((Messages.getString("LibraryAnalyserEngine.TEMP") + temp_folder + "\n").getBytes()); //$NON-NLS-3$ if (outStr != null) outStr.close(); if (currentData.filterNeeded) getKnonwIssuesData(); } catch (FileNotFoundException e) { e.printStackTrace(); return e.getMessage(); } catch (IOException e1) { e1.printStackTrace(); return e1.getMessage(); } catch (Exception e2) { e2.printStackTrace(); return e2.getMessage(); } } else return coreToolsExtraction; return null; }
From source file:com.nokia.s60tools.compatibilityanalyser.model.LibraryAnalyserEngine.java
License:Open Source License
/** * This method gets invoked after the Ordinal Analysis, if user selects Filter option. * This method filters the given report file. * This method reads the selecetd KnownIssues configuration from the preferences * and prepares the config file with Report Path and KnownIssues path. * @param report specifies name of the report being filtered. *//*from w w w . j av a 2 s . co m*/ private void getKnonwIssuesData() { IPreferenceStore prefStore = CompatibilityAnalyserPlugin.getCompatabilityAnalyserPrefStore(); LastUsedKnownissues issuesData = new LastUsedKnownissues(); String knownIssuesPath = null; try { if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LOCAL_ISSUES)) { String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.LOCAL_ISSUES_PATH); totalIssueFiles = issuesArr.length; if (issuesArr != null && issuesArr.length != 0) { String all = issuesArr[0]; for (int i = 1; i < issuesArr.length; i++) { all = all + ";" + issuesArr[i]; } knownIssuesPath = all; } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.DEFAULT_ISSUES)) { totalIssueFiles = 1; String corePath = CompatibilityAnalyserPlugin.getInstallPathOfToolsPlugin(); if (corePath == null || corePath.equalsIgnoreCase("")) { return; } else { File toolsFolder = new File(FileMethods.appendPathSeparator(corePath) + Messages.getString("LibraryAnalyserEngine.Bctools")); if (!toolsFolder.exists()) return; else knownIssuesPath = FileMethods.appendPathSeparator(toolsFolder.getAbsolutePath()) + Messages.getString("LibraryAnalyserEngine.data") + File.separator + Messages.getString("LibraryAnalyserEngine.knownissues.xml"); //$NON-NLS-3$ } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.WEB_ISSUES)) { String[] issuesArr = issuesData.getPreviousValues(LastUsedKnownissues.ValueTypes.ISSUES_URL); totalIssueFiles = issuesArr.length; if (issuesArr != null && issuesArr.length != 0) { String all = issuesArr[0]; for (int i = 1; i < issuesArr.length; i++) { all = all + ";" + issuesArr[i]; } knownIssuesPath = all; } } else if (prefStore.getBoolean(CompatibilityAnalyserPreferencesConstants.LATEST_ISSUES)) { totalIssueFiles = 1; knownIssuesPath = prefStore.getString(CompatibilityAnalyserPreferencesConstants.KNOWNISSUES_URL); } FileOutputStream outStream = new FileOutputStream(configFile, true); outStream.write( (Messages.getString("LibraryAnalyserEngine.ISSUES_FILE") + knownIssuesPath + "\n").getBytes()); if (outStream != null) outStream.close(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }