List of usage examples for org.eclipse.jface.preference IPreferenceStore getBoolean
boolean getBoolean(String name);
From source file:com.palantir.typescript.preferences.ContentAssistPreferencePage.java
License:Apache License
private void synchronizeAutoActivation() { IPreferenceStore preferenceStore = TypeScriptPlugin.getDefault().getPreferenceStore(); boolean autoActivationEnabled = preferenceStore .getBoolean(IPreferenceConstants.CONTENT_ASSIST_AUTO_ACTIVATION_ENABLED); this.autoActivationEnabledButton.setSelection(autoActivationEnabled); for (Control control : this.controls) { String preferenceName = (String) control.getData(); if (preferenceName != null) { if (control instanceof Text) { String value = preferenceStore.getString(preferenceName); ((Text) control).setText(value); }/* www . ja v a 2s . c o m*/ } } this.synchronizeAutoActivationEnabled(); }
From source file:com.palantir.typescript.services.language.CompilerOptions.java
License:Apache License
public static CompilerOptions fromProject(IProject project) { checkNotNull(project);//from w w w.j a v a2s. co m IPreferenceStore preferenceStore = new ProjectPreferenceStore(project); // create the compilation settings from the preferences CompilerOptions compilationSettings = new CompilerOptions(); compilationSettings.declaration = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_DECLARATION); compilationSettings.experimentalDecorators = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_EXPERIMENTAL_DECORATORS); compilationSettings.inlineSourceMap = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_INLINE_SOURCE_MAP); compilationSettings.inlineSources = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_INLINE_SOURCES); compilationSettings.jsx = JsxEmit.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_JSX)); compilationSettings.module = ModuleKind .parse(preferenceStore.getString(IPreferenceConstants.COMPILER_MODULE)); compilationSettings.moduleResolution = ModuleResolutionKind.CLASSIC; compilationSettings.noEmitOnError = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_NO_EMIT_ON_ERROR); compilationSettings.noImplicitAny = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_NO_IMPLICIT_ANY); compilationSettings.noLib = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_NO_LIB); compilationSettings.removeComments = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_REMOVE_COMMENTS); compilationSettings.sourceMap = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_SOURCE_MAP); compilationSettings.suppressExcessPropertyErrors = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_SUPPRESS_EXCESS_PROPERTY_ERRORS); compilationSettings.suppressImplicitAnyIndexErrors = preferenceStore .getBoolean(IPreferenceConstants.COMPILER_SUPPRESS_IMPLICIT_ANY_INDEX_ERRORS); compilationSettings.target = ScriptTarget .valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_TARGET)); // set the output directory or file if it was specified String outDir = preferenceStore.getString(IPreferenceConstants.COMPILER_OUT_DIR); String outFile = preferenceStore.getString(IPreferenceConstants.COMPILER_OUT_FILE); // get the eclipse name for the output directory String outputFolderName = null; if (!Strings.isNullOrEmpty(outDir)) { IFolder outputFolder = project.getFolder(outDir); outputFolderName = EclipseResources.getContainerName(outputFolder); } if (!Strings.isNullOrEmpty(outFile)) { if (outputFolderName == null) { outputFolderName = EclipseResources.getContainerName(project); } compilationSettings.out = outputFolderName + outFile; } else if (outputFolderName != null) { compilationSettings.outDir = outputFolderName; } return compilationSettings; }
From source file:com.palantir.typescript.services.language.LanguageService.java
License:Apache License
private void updateCompilationSettings() { IPreferenceStore preferenceStore = TypeScriptPlugin.getDefault().getPreferenceStore(); CompilationSettings compilationSettings = new CompilationSettings( preferenceStore.getBoolean(IPreferenceConstants.COMPILER_NO_LIB), LanguageVersion.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_CODE_GEN_TARGET)), ModuleGenTarget.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_MODULE_GEN_TARGET)), preferenceStore.getBoolean(IPreferenceConstants.COMPILER_MAP_SOURCE_FILES), preferenceStore.getBoolean(IPreferenceConstants.COMPILER_REMOVE_COMMENTS)); Request request = new Request(SERVICE, "setCompilationSettings", compilationSettings); this.bridge.call(request, Void.class); }
From source file:com.palantir.typescript.TypeScriptBuilder.java
License:Apache License
@Override protected void clean(IProgressMonitor monitor) throws CoreException { checkNotNull(monitor);//from w ww . j a va 2 s . c o m // delete built files if compile-on-save is enabled IPreferenceStore projectPreferenceStore = new ProjectPreferenceStore(this.getProject()); if (projectPreferenceStore.getBoolean(IPreferenceConstants.COMPILER_COMPILE_ON_SAVE) && !isOutputFileSpecified()) { Set<FileDelta> fileDeltas = getAllSourceFiles(Delta.REMOVED); this.clean(fileDeltas, monitor); } // clean the language service in case it is out-of-sync this.languageEndpoint.cleanProject(this.getProject()); this.deleteAllMarkers(); }
From source file:com.palantir.typescript.TypeScriptBuilder.java
License:Apache License
private void incrementalBuild(IProgressMonitor monitor) throws CoreException { IProject project = this.getProject(); IResourceDelta delta = this.getDelta(project); // update all source and exported files in the language service Set<FileDelta> allFileDeltas = TypeScriptProjects.getFileDeltas(project, Folders.SOURCE_AND_EXPORTED, delta);//from w w w . ja v a 2s .c o m if (!allFileDeltas.isEmpty()) { this.languageEndpoint.updateFiles(project, allFileDeltas); } // build the modified source files Set<FileDelta> sourceFileDeltas = TypeScriptProjects.getFileDeltas(project, Folders.SOURCE, delta); if (!sourceFileDeltas.isEmpty()) { // replace the file deltas with all the source files if an output file is specified if (this.isOutputFileSpecified()) { sourceFileDeltas = this.getAllSourceFiles(Delta.ADDED); } IPreferenceStore projectPreferenceStore = new ProjectPreferenceStore(this.getProject()); // compile the source files if compile-on-save is enabled if (projectPreferenceStore.getBoolean(IPreferenceConstants.COMPILER_COMPILE_ON_SAVE)) { this.build(sourceFileDeltas, monitor); } } // re-create the markers for projects which reference this one for (IProject referencingProject : this.getProject().getReferencingProjects()) { if (!this.languageEndpoint.isProjectInitialized(referencingProject)) { this.languageEndpoint.initializeProject(referencingProject); } this.deleteAllMarkers(referencingProject); this.createMarkers(referencingProject, monitor); } }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java
License:Open Source License
@Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { // deal with indent property changing // deal with events that should NOT reach the parent ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer == null) return;/* ww w. j a v a 2 s . c om*/ String property = event.getProperty(); // System.out.println("Property Event: " + property); if (FormatterGeneralPreferences.FORMATTER_INDENTSIZE.equals(property) || FormatterGeneralPreferences.FORMATTER_SPACES_FOR_TABS.equals(property)) { IPreferenceStore store = getPreferenceStore(); if (store != null) sourceViewer.getTextWidget() .setTabs(store.getInt(FormatterGeneralPreferences.FORMATTER_INDENTSIZE)); uninstallTabsToSpacesConverter(); if (store.getBoolean(FormatterGeneralPreferences.FORMATTER_SPACES_FOR_TABS)) installTabsToSpacesConverter(); return; } if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) { // INHIBIT THIS - Puppet editor is always "spaces for tabs" and does NOT follow the // Editor tab width setting, it is always the same as the indent size for formatting. return; } if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(property)) { // INHIBIT THIS CHANGE - Puppet editor is always "spaces for tabs" return; } super.handlePreferenceStoreChanged(event); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.linked.ExtLinkedXtextEditor.java
License:Open Source License
@Override protected boolean isTabsToSpacesConversionEnabled() { IPreferenceStore store = getPreferenceStore(); return store == null || store.getBoolean(FormatterGeneralPreferences.FORMATTER_SPACES_FOR_TABS); }
From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.PPPreferencesHelper.java
License:Open Source License
private boolean getResourceSpecificBoolean(IResource r, String property) { // get project specific preference and use them if they are enabled IPreferenceStore store = preferenceStoreAccess.getContextPreferenceStore(r.getProject()); return store.getBoolean(property); }
From source file:com.python.pydev.refactoring.actions.ToggleMarkOccurrences.java
License:Open Source License
public Object execute(ExecutionEvent event) throws ExecutionException { ITextEditor activeEditor = EditorUtils.getActiveEditor(); if (!(activeEditor instanceof PyEdit)) { return null; }/*from w w w . j a va 2 s.c o m*/ PyEdit editor = (PyEdit) activeEditor; try { IPreferenceStore store = RefactoringPlugin.getDefault().getPreferenceStore(); boolean prev = store.getBoolean(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES); store.setValue(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES, !prev); editor.getStatusLineManager() .setMessage("Toggled mark occurrences. Currently: " + (prev ? "Off" : "On")); MarkOccurrencesJob.scheduleRequest(new WeakReference<BaseEditor>(editor), editor.createTextSelectionUtils(), 0); //On the action, ask it to happen now. } catch (Exception e) { Log.log(e); } return null; }
From source file:com.python.pydev.refactoring.wizards.rename.PyRenameRefactoringWizard.java
License:Open Source License
protected TextInputWizardPage createInputPage(String message, final String initialSetting) { return new TextInputWizardPage(message, true, initialSetting) { private Text textField; private IFile targetFile; @Override/*w w w.j a va 2s .co m*/ protected RefactoringStatus validateTextField(String text) { RefactoringStatus status = new RefactoringStatus(); boolean acceptPoint = fRequest.isModuleRenameRefactoringRequest(); if (PyStringUtils.isValidIdentifier(text, acceptPoint)) { fRequest.setInputName(text); } else { status.addFatalError("The name: " + text + " is not a valid identifier."); } return status; } @Override protected Text createTextInputField(Composite parent, int style) { Text ret = super.createTextInputField(parent, style); this.textField = ret; setTextToFullName(); return ret; } private void setTextToResourceName() { if (targetFile != null) { String curr = targetFile.getName(); textField.setText(curr); int i = curr.lastIndexOf('.'); if (i >= 0) { textField.setSelection(0, i); } else { textField.selectAll(); } } } private void setTextToFullName() { textField.setText(initialSetting); String text = initialSetting; int i = text.lastIndexOf('.'); if (i >= 0) { textField.setSelection(i + 1, text.length()); } else { textField.selectAll(); } } @Override protected void textModified(String text) { if (targetFile != null && fRequest.getSimpleResourceRename()) { if (!isEmptyInputValid() && text.equals("")) { //$NON-NLS-1$ setPageComplete(false); setErrorMessage(null); restoreMessage(); return; } if ((!isInitialInputValid()) && text.equals(targetFile.getName())) { setPageComplete(false); setErrorMessage(null); restoreMessage(); return; } setPageComplete(validateTextField(text)); } if (fRequest instanceof MultiModuleMoveRefactoringRequest) { RefactoringStatus status; if (text.length() == 0) { //Accept empty for move! status = new RefactoringStatus(); status.addInfo("Empty text: move to source folder"); } else { status = validateTextField(text); } if (!status.hasFatalError()) { fRequest.setInputName(text); } setPageComplete(status); } else { super.textModified(text); } } public void createControl(Composite parent) { Composite superComposite = new Composite(parent, SWT.NONE); setControl(superComposite); initializeDialogUnits(superComposite); superComposite.setLayout(new GridLayout()); Composite composite = new Composite(superComposite, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.verticalSpacing = 8; composite.setLayout(layout); Label label = new Label(composite, SWT.NONE); label.setText("New &value:"); Text text = createTextInputField(composite); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.widthHint = convertWidthInCharsToPixels(25); text.setLayoutData(gd); // layouter.perform(label, text, 1); // if (fRequest.isModuleRenameRefactoringRequest()) { Button updateReferencesButton = addOptionalUpdateReferencesCheckbox(composite); IFile targetFile = fRequest.getIFileResource(); if (targetFile != null) { this.targetFile = targetFile; addResourceRenameCheckbox(composite, updateReferencesButton); } } // addOptionalUpdateTextualMatches(composite, layouter); // addOptionalUpdateQualifiedNameComponent(composite, layouter, layout.marginWidth); Dialog.applyDialogFont(superComposite); } protected Button addResourceRenameCheckbox(Composite result, final Button updateReferencesButton) { final Button resourceRename = new Button(result, SWT.CHECK); resourceRename.setText("&Simple Resource Rename / Change Extension?"); IPreferenceStore preferences = PydevPrefs.getPreferences(); preferences.setDefault(SIMPLE_RESOURCE_RENAME, false); //Default is always false to rename resources. boolean simpleResourceRenameBool = preferences.getBoolean(SIMPLE_RESOURCE_RENAME); resourceRename.setSelection(simpleResourceRenameBool); fRequest.setSimpleResourceRename(simpleResourceRenameBool); resourceRename.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPreferenceStore preferences = PydevPrefs.getPreferences(); boolean simpleResourceRenameBool = resourceRename.getSelection(); updateReferencesButton.setVisible(!simpleResourceRenameBool); preferences.setValue(SIMPLE_RESOURCE_RENAME, simpleResourceRenameBool); fRequest.setSimpleResourceRename(simpleResourceRenameBool); // Must be the last thing. if (simpleResourceRenameBool) { setTextToResourceName(); } else { setTextToFullName(); } } }); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 2; resourceRename.setLayoutData(gridData); updateReferencesButton.setVisible(!simpleResourceRenameBool); if (simpleResourceRenameBool) { setTextToResourceName(); } return resourceRename; } protected Button addOptionalUpdateReferencesCheckbox(Composite result) { final Button updateReferences = new Button(result, SWT.CHECK); updateReferences.setText("&Update References?"); IPreferenceStore preferences = PydevPrefs.getPreferences(); preferences.setDefault(UPDATE_REFERENCES, true); //Default is always true to update references. boolean updateRefs = preferences.getBoolean(UPDATE_REFERENCES); updateReferences.setSelection(updateRefs); fRequest.setUpdateReferences(updateRefs); updateReferences.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IPreferenceStore preferences = PydevPrefs.getPreferences(); boolean updateRefs = updateReferences.getSelection(); preferences.setValue(UPDATE_REFERENCES, updateRefs); fRequest.setUpdateReferences(updateRefs); } }); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 2; updateReferences.setLayoutData(gridData); return updateReferences; } }; }