List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.motorolamobility.preflighting.ui.CommandLinePreferencePage.java
License:Apache License
@Override protected Control createContents(Composite parent) { PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, PREFERENCE_PAGE_HELP); pagesComposite = new ArrayList<AbstractAppValidatorTabComposite>(); IPreferenceStore prefStore = PreflightingUIPlugin.getDefault().getPreferenceStore(); if ((!prefStore.contains(PreflightingUIPlugin.OUTPUT_LIMIT_VALUE)) && prefStore.contains(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY) && (!(prefStore.getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY)) .equals(PreflightingUIPlugin.DEFAULT_BACKWARD_COMMANDLINE))) { Label backLabel = new Label(parent, SWT.WRAP); GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false); layoutData.widthHint = 450;/*www .j a va 2s .c om*/ backLabel.setLayoutData(layoutData); backLabel.setText("You have previously set the following App Validator parameters:\n" + prefStore.getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY)); } Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(1, false)); GridData mainData = new GridData(SWT.FILL, SWT.TOP, true, false); mainComposite.setLayoutData(mainData); TabFolder tabFolder = new TabFolder(mainComposite, SWT.TOP); tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); TabItem generalSettingsTab = new TabItem(tabFolder, SWT.NONE); generalSettingsTab.setText(PreflightingUiNLS.CommandLinePreferencePage_GeneralSettingTabName); AbstractAppValidatorTabComposite genSettingsComposite = new GeneralSettingsComposite(tabFolder, SWT.NONE); generalSettingsTab.setControl(genSettingsComposite); genSettingsComposite.addUIChangedListener(new UIChangedListener() { public void uiChanged(AbstractAppValidatorTabComposite composite) { validateUI(composite); } }); pagesComposite.add(genSettingsComposite); TabItem checkersSettingsTab = new TabItem(tabFolder, SWT.NONE); checkersSettingsTab.setText(PreflightingUiNLS.CommandLinePreferencePage_Checkers_Tab); AbstractAppValidatorTabComposite checkersTabComposite = new CheckersTabComposite(tabFolder, SWT.NONE, getPreferenceStore()); checkersSettingsTab.setControl(checkersTabComposite); checkersTabComposite.addUIChangedListener(new UIChangedListener() { public void uiChanged(AbstractAppValidatorTabComposite composite) { validateUI(composite); } }); pagesComposite.add(checkersTabComposite); TabItem devicesSettingTab = new TabItem(tabFolder, SWT.NONE); devicesSettingTab.setText(PreflightingUiNLS.CommandLinePreferencePage_Devices_Tab); AbstractAppValidatorTabComposite devicesTabComposite = new DevicesTabComposite(tabFolder, SWT.NONE, getPreferenceStore()); devicesSettingTab.setControl(devicesTabComposite); pagesComposite.add(devicesTabComposite); setValid(((GeneralSettingsComposite) genSettingsComposite).canFinish()); return mainComposite; }
From source file:com.motorolamobility.preflighting.ui.handlers.AnalyzeApkHandler.java
License:Apache License
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbench workbench = PlatformUI.getWorkbench(); if ((workbench != null) && !workbench.isClosing()) { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window != null) { ISelection selection = null; if (initialSelection != null) { selection = initialSelection; } else { selection = window.getSelectionService().getSelection(); }/* w w w. ja va 2s.c om*/ if (selection instanceof IStructuredSelection) { IStructuredSelection sselection = (IStructuredSelection) selection; Iterator<?> it = sselection.iterator(); String sdkPath = AndroidUtils.getSDKPathByPreference(); if (monitor != null) { monitor.setTaskName(PreflightingUiNLS.ApplicationValidation_monitorTaskName); monitor.beginTask(PreflightingUiNLS.ApplicationValidation_monitorTaskName, sselection.size() + 1); monitor.worked(1); } ArrayList<PreFlightJob> jobList = new ArrayList<PreFlightJob>(); boolean isHelpExecution = false; IPreferenceStore preferenceStore = PreflightingUIPlugin.getDefault().getPreferenceStore(); boolean showMessageDialog = true; if (preferenceStore.contains( PreflightingUIPlugin.SHOW_BACKWARD_DIALOG + PreflightingUIPlugin.TOGGLE_DIALOG)) { showMessageDialog = MessageDialogWithToggle.ALWAYS.equals(preferenceStore.getString( PreflightingUIPlugin.SHOW_BACKWARD_DIALOG + PreflightingUIPlugin.TOGGLE_DIALOG)); } if (showMessageDialog && (!preferenceStore.contains(PreflightingUIPlugin.OUTPUT_LIMIT_VALUE)) && preferenceStore.contains(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY) && (!(preferenceStore.getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY)) .equals(PreflightingUIPlugin.DEFAULT_BACKWARD_COMMANDLINE))) { String commandLine = PreflightingUIPlugin.getDefault().getPreferenceStore() .getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY); MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), PreflightingUiNLS.AnalyzeApkHandler_BackwardMsg_Title, NLS.bind(PreflightingUiNLS.AnalyzeApkHandler_BackwardMsg_Message, commandLine), PreflightingUiNLS.AnalyzeApkHandler_Do_Not_Show_Again, false, preferenceStore, PreflightingUIPlugin.SHOW_BACKWARD_DIALOG + PreflightingUIPlugin.TOGGLE_DIALOG); int returnCode = dialog.getReturnCode(); if (returnCode == IDialogConstants.YES_ID) { EclipseUtils.openPreference( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_PAGE); } } String userParamsStr = preferenceStore .getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY); downgradeErrors = preferenceStore .contains(PreflightingUIPlugin.ECLIPSE_PROBLEM_TO_WARNING_VALUE) ? preferenceStore .getBoolean(PreflightingUIPlugin.ECLIPSE_PROBLEM_TO_WARNING_VALUE) : true; //we look for a help parameter: -help or -list-checkers //in such case we execute app validator only once, //since all executions will have the same output if (userParamsStr.length() > 0) { String regex = "((?!(\\s+" + "-" + ")).)*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Pattern pat = Pattern.compile(regex); Matcher matcher = pat.matcher(userParamsStr); while (matcher.find()) { String parameterValues = userParamsStr.substring(matcher.start(), matcher.end()); if (parameterValues.equals("-" //$NON-NLS-1$ + ApplicationParameterInterpreter.PARAM_HELP) || parameterValues.equals( "-" //$NON-NLS-1$ + ApplicationParameterInterpreter.PARAM_LIST_CHECKERS)) { isHelpExecution = true; } } } while (it.hasNext()) { IResource analyzedResource = null; Object resource = it.next(); String path = null; if (resource instanceof IFile) { IFile apkfile = (IFile) resource; analyzedResource = apkfile; if (apkfile.getFileExtension().equals("apk") && apkfile.exists() //$NON-NLS-1$ && apkfile.getLocation().toFile().canRead()) { /* * For each apk, execute all verifications passaing the two needed parameters */ path = apkfile.getLocation().toOSString(); } else { MessageDialog.openError(window.getShell(), PreflightingUiNLS.AnalyzeApkHandler_ErrorTitle, PreflightingUiNLS.AnalyzeApkHandler_ApkFileErrorMessage); } } else if (resource instanceof File) { File apkfile = (File) resource; if (apkfile.getName().endsWith(".apk") && apkfile.exists() //$NON-NLS-1$ && apkfile.canRead()) { /* * For each apk, execute all verifications passaing the two needed parameters */ path = apkfile.getAbsolutePath(); } else { MessageDialog.openError(window.getShell(), PreflightingUiNLS.AnalyzeApkHandler_ErrorTitle, PreflightingUiNLS.AnalyzeApkHandler_ApkFileErrorMessage); } enableMarkers = false; } else if (resource instanceof IProject) { IProject project = (IProject) resource; analyzedResource = project; path = project.getLocation().toOSString(); } else if (resource instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) resource; IProject project = (IProject) adaptable.getAdapter(IProject.class); analyzedResource = project; if (project != null) { path = project.getLocation().toOSString(); } } if (path != null) { PreFlightJob job = new PreFlightJob(path, sdkPath, analyzedResource); jobList.add(job); if (isHelpExecution) { //app validator is executed only once for help commands break; } } } if (enableMarkers) { // Show and activate problems view Runnable showProblemsView = new Runnable() { public void run() { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(PROBLEMS_VIEW_ID); } catch (PartInitException e) { PreflightingLogger.error("Error showing problems view."); //$NON-NLS-1$ } } }; Display.getDefault().asyncExec(showProblemsView); } //show console for external apks else { showApkConsole(); } ParentJob parentJob = new ParentJob( PreflightingUiNLS.AnalyzeApkHandler_PreflightingToolNameMessage, jobList); parentJob.setUser(true); parentJob.schedule(); try { if (monitor != null) { monitor.done(); } } catch (Exception e) { //Do nothing } } } } return null; }
From source file:com.motorolamobility.preflighting.ui.handlers.AnalyzeApkHandler.java
License:Apache License
private int executePreFlightingTool(String path, String sdkPath, IResource analyzedResource, StringBuilder strbValidationOutput) { int returnValue = EXIT_CODE_OK; List<Parameter> parameters = null; //Remove app validator markers every time. if (enableMarkers) { cleanMarkers(analyzedResource);/*from www. j a va 2s . c o m*/ } // set default warning and verbosity levels ByteArrayOutputStream verboseOutputStream = new ByteArrayOutputStream(); PrintStream prtStream = new PrintStream(verboseOutputStream); DebugVerboseOutputter.setStream(prtStream); DebugVerboseOutputter.setCurrentVerboseLevel(DebugVerboseOutputter.DEFAULT_VERBOSE_LEVEL); WarningLevelFilter.setCurrentWarningLevel(WarningLevelFilter.DEFAULT_WARNING_LEVEL); DebugVerboseOutputter.printVerboseMessage("", VerboseLevel.v0); //$NON-NLS-1$ DebugVerboseOutputter.printVerboseMessage("", VerboseLevel.v0); //$NON-NLS-1$ DebugVerboseOutputter.printVerboseMessage(PreflightingUiNLS.AnalyzeApkHandler_Header, VerboseLevel.v0); DebugVerboseOutputter.printVerboseMessage("", VerboseLevel.v0); //$NON-NLS-1$ IPreferenceStore preferenceStore = PreflightingUIPlugin.getDefault().getPreferenceStore(); String userParamsStr = null; if (preferenceStore.contains(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY)) { userParamsStr = preferenceStore.getString(PreflightingUIPlugin.COMMAND_LINE_PREFERENCE_KEY); } else { userParamsStr = PreflightingUIPlugin.DEFAULT_COMMANDLINE; } try { if (userParamsStr.length() > 0) { CommandLineInputProcessor commandLineInputProcessor = new CommandLineInputProcessor(); parameters = commandLineInputProcessor.processCommandLine(userParamsStr); } else { parameters = new ArrayList<Parameter>(5); } parameters.add(new Parameter(ValidationManager.InputParameter.APPLICATION_PATH.getAlias(), path)); //If user selected a different SDK, let's use their definition, otherwise we'll pick the SDK currently set Parameter sdkParam = new Parameter(ValidationManager.InputParameter.SDK_PATH.getAlias(), null); if (!parameters.contains(sdkParam)) { parameters.add(new Parameter(ValidationManager.InputParameter.SDK_PATH.getAlias(), sdkPath)); } //If user selected the help, list-checker, list-devices or describe-device parameter, let's clear and use only those parameters Parameter helpParam = new Parameter(ApplicationParameterInterpreter.PARAM_HELP, null); boolean hasHelpParam = parameters.contains(helpParam); Parameter listCheckersParam = new Parameter(ApplicationParameterInterpreter.PARAM_LIST_CHECKERS, null); boolean hasListCheckersParam = parameters.contains(listCheckersParam); Parameter describeDeviceParam = new Parameter(ApplicationParameterInterpreter.PARAM_DESC_DEVICE, null); boolean hasDescribeDeviceParam = parameters.contains(describeDeviceParam); Parameter listDevicesParam = new Parameter(ApplicationParameterInterpreter.PARAM_LIST_DEVICES, null); boolean hasListDevicesParam = parameters.contains(listDevicesParam); if (hasHelpParam || hasListCheckersParam || hasDescribeDeviceParam || hasListDevicesParam) { int neededParamIdx = hasHelpParam ? parameters.indexOf(helpParam) : hasListCheckersParam ? parameters.indexOf(listCheckersParam) : hasDescribeDeviceParam ? parameters.indexOf(describeDeviceParam) : parameters.indexOf(listDevicesParam); Parameter parameter = parameters.get(neededParamIdx); parameters.clear(); parameters.add(parameter); // Show console showApkConsole(); } List<Parameter> parametersCopy = new ArrayList<Parameter>(parameters); AbstractOutputter outputter = null; for (Parameter param : parametersCopy) { if (InputParameter.OUTPUT.getAlias().equals(param.getParameterType())) { ApplicationParameterInterpreter.validateOutputParam(param.getValue()); outputter = OutputterFactory.getInstance().createOutputter(parameters); parameters.remove(param); break; } } if (outputter == null) { outputter = OutputterFactory.getInstance().createOutputter(null); } ValidationManager validationManager = new ValidationManager(); if (userParamsStr.length() > 0) { ApplicationParameterInterpreter.checkApplicationParameters(parameters, validationManager, prtStream); } if (!hasHelpParam && !hasListCheckersParam && !hasDescribeDeviceParam && !hasListDevicesParam) { List<ApplicationValidationResult> results = validationManager.run(parameters); ApplicationValidationResult result = null; //inside studio, there won't be any support zip files, thus the map will have only one result for (ApplicationValidationResult aResult : results) { result = aResult; } strbValidationOutput.append(verboseOutputStream.toString()); if (enableMarkers && (analyzedResource != null) && (result != null)) { // Create problem markers createProblemMarkers(result.getResults(), analyzedResource); } if (result != null) { ByteArrayOutputStream baos = null; try { baos = new ByteArrayOutputStream(); outputter.print(result, baos, parameters); strbValidationOutput.append(baos.toString()); } finally { try { baos.close(); } catch (IOException e) { StudioLogger.error("Could not close stream: ", e.getMessage()); } } if ((result.getResults().size() > 0)) { //result already used //clean it to help Garbage Collector to work freeing memory result.getResults().clear(); result = null; Runtime.getRuntime().gc(); } } } else { strbValidationOutput.append(verboseOutputStream.toString()); } try { verboseOutputStream.flush(); } catch (IOException e) { StudioLogger.error("Could not flush stream: ", e.getMessage()); } } catch (PreflightingParameterException pe) { // only log, do not print message (ValidationManager.run() method already prints // each problem individually) PreflightingLogger.error(AnalyzeApkHandler.class, "Parameter problems executing MOTODEV Studio Application Validator", pe); //$NON-NLS-1$ strbValidationOutput.append(verboseOutputStream.toString()); // Show console showApkConsole(); returnValue = EXIT_CODE_TOOL_CONTEXT_ERROR; } catch (PreflightingToolException e) { PreflightingLogger.error(AnalyzeApkHandler.class, "An error ocurred trying to execute MOTODEV Studio Application Validator", e); //$NON-NLS-1$ strbValidationOutput.append(verboseOutputStream.toString()); strbValidationOutput .append(PreflightingUiNLS.AnalyzeApkHandler_PreflightingApplicationExecutionErrorMessage); strbValidationOutput.append(e.getMessage()); strbValidationOutput.append(NEWLINE); returnValue = EXIT_APPLICATION_CONTEXT_ERROR; // Show console showApkConsole(); } catch (ParameterParseException e) { PreflightingLogger.error(AnalyzeApkHandler.class, "An error ocurred trying to execute MOTODEV Studio Application Validator", e); //$NON-NLS-1$ strbValidationOutput.append(verboseOutputStream.toString()); strbValidationOutput .append(PreflightingUiNLS.AnalyzeApkHandler_PreflightingApplicationExecutionErrorMessage); strbValidationOutput.append(e.getMessage()); strbValidationOutput.append(NEWLINE); // Show console showApkConsole(); returnValue = EXIT_CODE_TOOL_CONTEXT_ERROR; } finally { try { verboseOutputStream.close(); prtStream.close(); } catch (IOException e) { StudioLogger.error("Could not close stream: ", e.getMessage()); } } return returnValue; }
From source file:com.motorolamobility.preflighting.ui.tabs.CheckersTabComposite.java
License:Apache License
private void init(IPreferenceStore preferenceStore) { /*/*from w ww .j a v a 2 s .c om*/ * Populate condition maps */ ValidationManager validationManager = new ValidationManager(); for (CheckerDescription checkerDescription : checkersDescriptions) { allConditionsMap.put(checkerDescription.getId(), validationManager.getCheckerConditions(checkerDescription.getId())); } String checkersPreference = preferenceStore.getString(PreflightingUIPlugin.CHECKERS_PREFERENCE_KEY); // Preference is empty means first time. Perform defaults if (checkersPreference.length() == 0) { performDefaults(); } else { /* * Checkers information */ if (!checkersPreference.equals(NO_CHECKERS_SELECTED)) //There's checkers to load and check on the table { StringTokenizer tokenizer = new StringTokenizer(checkersPreference, ","); //$NON-NLS-1$ List<CheckerDescription> selectedCheckerDescriptions = new ArrayList<CheckerDescription>( tokenizer.countTokens()); while (tokenizer.hasMoreTokens()) { String checkerId = tokenizer.nextToken(); CheckerDescription checkerDescription = getCheckerDescription(checkerId); if (checkerDescription != null) { selectedCheckerDescriptions.add(checkerDescription); } } checkersTableViewer.setCheckedElements(selectedCheckerDescriptions.toArray()); } selectAllCheckersCheck.setSelection(areAllItemsChecked(checkersTableViewer)); String checkersConditionsPreference = preferenceStore .getString(PreflightingUIPlugin.CHECKERS_CONDITIONS_PREFERENCE_KEY); if (checkersConditionsPreference.length() > 0) { StringTokenizer tokenizer = new StringTokenizer(checkersConditionsPreference, ";"); while (tokenizer.hasMoreElements()) { String checkerConditionStr = tokenizer.nextToken(); String[] split = checkerConditionStr.split(":"); if (split.length == 2) { String checkerId = split[0]; String[] selectedConditionsIds = split[1].split(","); // define which are the selected conditions Set<String> selectedConditionsIdsSet = new HashSet<String>(); for (String selectedConditionId : selectedConditionsIds) { selectedConditionsIdsSet.add(selectedConditionId); } // get the Condition objects and add them to the selected conditions map List<Condition> allConditionsList = allConditionsMap.get(checkerId); List<Condition> selectedConditionsList = new ArrayList<Condition>(); if (allConditionsList != null) { for (Condition condition : allConditionsList) { if (selectedConditionsIdsSet.contains(condition.getId())) { selectedConditionsList.add(condition); } } } selectedConditionsMap.put(checkerId, selectedConditionsList); } } } // create an empty list for the checkers that had no preferences set (new checkers, for example) for (CheckerDescription checkerDescription : checkersDescriptions) { if (selectedConditionsMap.get(checkerDescription.getId()) == null) { selectedConditionsMap.put(checkerDescription.getId(), new ArrayList<Condition>()); } } /* * Get Extended Properties */ // Checker parameters loadExtendedProperty(checkerParams, preferenceStore, PreflightingUIPlugin.CHECKERS_PARAMS_PREFERENCE_KEY, String.class); // Custom checker warning levels loadExtendedProperty(customCheckersWarningLevels, preferenceStore, PreflightingUIPlugin.CHECKERS_WARNING_LEVELS_PREFERENCE_KEY, Boolean.class); // Custom conditions warning levels loadExtendedProperty(customConditionsWarningLevels, preferenceStore, PreflightingUIPlugin.CHECKERS_CONDITIONS_WARNING_LEVELS_PREFERENCE_KEY, Boolean.class); checkersTableViewer.refresh(); } }
From source file:com.motorolamobility.preflighting.ui.tabs.CheckersTabComposite.java
License:Apache License
/** * Load saved extend property. The extended properties are related to * a checker or condition, and are saved in the form: * <id>,<extended_property>;<id>,<extended_property>... * /*from w w w . j a v a 2 s . co m*/ * These properties are loaded in a map <id> -> <extended_property> * * @param map the map where the information will be loaded * @param preferenceStore the preference store * @param preferenceName the preference key used to store */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void loadExtendedProperty(Map map, IPreferenceStore preferenceStore, String preferenceName, Class valueType) { String preference = preferenceStore.getString(preferenceName); if (preference.length() > 0) { StringTokenizer tokenizer = new StringTokenizer(preference, ";"); while (tokenizer.hasMoreElements()) { String extendedProperty = tokenizer.nextToken(); String[] split = extendedProperty.split(","); if (split.length == 2) { String id = split[0]; String params = split[1]; // string (checker param) if (valueType.getName().equals("java.lang.String")) { map.put(id, params); } // boolean (warning levels) else { map.put(id, new Boolean(params)); } } } } }
From source file:com.motorolamobility.preflighting.ui.tabs.DevicesTabComposite.java
License:Apache License
private void init(IPreferenceStore preferenceStore) { String prefKey = preferenceStore.getString(PreflightingUIPlugin.DEVICES_PREFERENCE_KEY); if (prefKey.length() > 0) //Found devices, check them! {/*from w w w . java 2s .c om*/ if (!prefKey.equals(NO_DEVICE_SELECTED)) { modifyCheckBoxes(false); StringTokenizer tokenizer = new StringTokenizer(prefKey, ","); //$NON-NLS-1$ while (tokenizer.hasMoreTokens()) { String deviceIdPref = tokenizer.nextToken(); checkTableItem(deviceIdPref); } } } else { performDefaults(); } selectAllCheck.setSelection(isAllItemsChecked()); }
From source file:com.motorolamobility.studio.android.db.core.ui.wizards.createdb.CreateDatabaseWizard.java
License:Apache License
private boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor perspective) { IPreferenceStore store = DbCoreActivator.getDefault().getPreferenceStore(); String preference = store.getString(SWITCH_MOTODEV_DATABASE_PERSPECTIVE); if (preference.equals("")) //$NON-NLS-1$ {/*w w w. j a v a 2s. c o m*/ store.setValue(SWITCH_MOTODEV_DATABASE_PERSPECTIVE, MessageDialogWithToggle.PROMPT); preference = MessageDialogWithToggle.PROMPT; } boolean result; if (MessageDialogWithToggle.ALWAYS.equals(preference)) { result = true; } else if (MessageDialogWithToggle.NEVER.equals(preference)) { result = false; } else { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), DbCoreNLS.UI_CreateDatabaseWizard_ChangePerspectiveTitle, DbCoreNLS.UI_CreateDatabaseWizard_ChangePerspectiveQuestion, null, false, store, SWITCH_MOTODEV_DATABASE_PERSPECTIVE); int dialogResult = dialog.getReturnCode(); result = dialogResult == IDialogConstants.YES_ID; } return result; }
From source file:com.motorolamobility.studio.android.db.devices.model.DeviceDbNode.java
License:Apache License
/** * @return/* w ww.j av a 2 s. c o m*/ * @throws IOException */ private File getLocalTempFile() throws IOException { IPreferenceStore preferenceStore = DbDevicesPlugin.getDefault().getPreferenceStore(); File tempLocationFile = null; if (!preferenceStore.isDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE)) { String tempLocation = preferenceStore.getString(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE); tempLocationFile = new File(tempLocation); if (!tempLocationFile.isDirectory() || !FileUtil.canWrite(tempLocationFile)) { EclipseUtils.showErrorDialog(DbDevicesNLS.ERR_DbUtils_Local_Db_Title, NLS.bind(DbDevicesNLS.ERR_DbUtils_Local_Db_Msg, tempLocation)); preferenceStore.setToDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE); } } //If tempLocationFile is null the file will be created on system's default temp dir. File tempFile = File.createTempFile(serialNumber + "_" + remoteDbPath.segment(1) + "_" + getName(), //$NON-NLS-1$ //$NON-NLS-2$ "db", tempLocationFile); //$NON-NLS-1$ tempFile.deleteOnExit(); return tempFile; }
From source file:com.motorolamobility.studio.android.db.devices.ui.preferences.DbPreferencePage.java
License:Apache License
public static void restoreBackWardPref(IPreferenceStore currentPrefStore) { IPreferenceStore preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, LEGACY_PLUGIN_ID); String backwardDbTempPath = preferenceStore.getString(LEGACY_DB_PATH_PREFERENCE); if (!backwardDbTempPath.isEmpty()) { currentPrefStore.setValue(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE, backwardDbTempPath); preferenceStore.setValue(LEGACY_DB_PATH_PREFERENCE, ""); //$NON-NLS-1$ }/*from w w w . java 2s . c o m*/ }
From source file:com.mountainminds.eclemma.internal.ui.launching.InplaceInstrumentationHandler.java
License:Open Source License
public Object handleStatus(IStatus status, Object source) throws CoreException { ILaunchConfiguration config = (ILaunchConfiguration) source; Shell parent = EclEmmaUIPlugin.getInstance().getShell(); String title = UIMessages.InstrumentationWarning_title; String message = NLS.bind(UIMessages.InstrumentationWarning_message, config.getName()); IPreferenceStore store = EclEmmaUIPlugin.getInstance().getPreferenceStore(); if (MessageDialogWithToggle.ALWAYS .equals(store.getString(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION))) { return Boolean.TRUE; }/*from w w w . j a v a 2s. co m*/ MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, null, false); dialog.setPrefKey(UIPreferences.PREF_ALLOW_INPLACE_INSTRUMENTATION); dialog.setPrefStore(store); dialog.open(); return Boolean.valueOf(dialog.getReturnCode() == IDialogConstants.OK_ID); }