private void initFromPrefs() { IPreferenceStore editorPreferences = EditorsPlugin.getDefault().getPreferenceStore(); IPreferenceStore toolsPreferences = PreferenceConstants.getPreferenceStore(); lineNumbersCheck.setSelection( editorPreferences.getBoolean( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); printMarginCheck.setSelection(DartFormatter.getMaxLineLengthEnabled()); printMarginText.setText(DartFormatter.getMaxLineLength()); printMarginText.setEnabled(printMarginCheck.getSelection()); enableAutoCompletion.setSelection( toolsPreferences.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION)); if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) { enableFolding.setSelection( toolsPreferences.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED)); } removeTrailingWhitespaceCheck.setSelection( toolsPreferences.getBoolean(PreferenceConstants.EDITOR_REMOVE_TRAILING_WS)); formatCheck.setSelection( toolsPreferences.getBoolean(PreferenceConstants.EDITOR_FORMAT_ON_SAVES)); IEclipsePreferences prefs = DartCore.getPlugin().getPrefs(); if (prefs != null) { runPubAutoCheck.setSelection(prefs.getBoolean(DartCore.PUB_AUTO_RUN_PREFERENCE, true)); enableAnalysisServerButton.setSelection( prefs.getBoolean(DartCoreDebug.ENABLE_ANALYSIS_SERVER_PREF, true)); } }
@Override public boolean performOk() { IPreferenceStore editorPreferences = EditorsPlugin.getDefault().getPreferenceStore(); editorPreferences.setValue( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, lineNumbersCheck.getSelection()); DartFormatter.setMaxLineLengthEnabled(printMarginCheck.getSelection()); if (printMarginCheck.getSelection()) { DartFormatter.setMaxLineLength(printMarginText.getText()); } IPreferenceStore toolsPreferenceStore = PreferenceConstants.getPreferenceStore(); toolsPreferenceStore.setValue( PreferenceConstants.CODEASSIST_AUTOACTIVATION, enableAutoCompletion.getSelection()); if (!DartCoreDebug.ENABLE_ANALYSIS_SERVER) { toolsPreferenceStore.setValue( PreferenceConstants.EDITOR_FOLDING_ENABLED, enableFolding.getSelection()); } toolsPreferenceStore.setValue( PreferenceConstants.EDITOR_REMOVE_TRAILING_WS, removeTrailingWhitespaceCheck.getSelection()); toolsPreferenceStore.setValue( PreferenceConstants.EDITOR_FORMAT_ON_SAVES, formatCheck.getSelection()); handleSave(editorPreferences); handleSave(toolsPreferenceStore); IEclipsePreferences prefs = DartCore.getPlugin().getPrefs(); if (prefs != null) { prefs.putBoolean(DartCore.PUB_AUTO_RUN_PREFERENCE, runPubAutoCheck.getSelection()); try { DartCore.getPlugin().savePrefs(); } catch (CoreException e) { DartToolsPlugin.log(e); } // // If the user has changed the preference to true, // then run pub on all pubspecs in the workspace // if (runPubChanged) { UIInstrumentationBuilder instrumentation = UIInstrumentation.builder(this.getClass()); try { boolean autoRunPubEnabled = runPubAutoCheck.getSelection(); instrumentation.metric("autoRunPubEnabled", autoRunPubEnabled); if (autoRunPubEnabled) { PlatformUI.getWorkbench() .getDisplay() .asyncExec( new Runnable() { @Override public void run() { runPubNow(); } }); } } catch (RuntimeException e) { instrumentation.record(e); throw e; } finally { instrumentation.log(); } } } boolean serverChanged = setPrefBool(DartCoreDebug.ENABLE_ANALYSIS_SERVER_PREF, true, enableAnalysisServerButton); if (serverChanged) { MessageDialog.openInformation( getShell(), "Restart Required", "These changes will only take effect once the IDE has been restarted."); } return true; }