List of usage examples for org.eclipse.jface.preference PreferenceStore setValue
@Override public void setValue(String name, boolean value)
From source file:net.sourceforge.texlipse.editor.TexSourceViewerConfiguration.java
License:Open Source License
/** * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer) */// w w w.j ava 2 s. co m @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) return null; if (!TexlipsePlugin.getDefault().getPreferenceStore() .getBoolean(TexlipseProperties.ECLIPSE_BUILDIN_SPELLCHECKER)) return null; //Set TeXlipse spelling Engine as default PreferenceStore store = new PreferenceStore(); store.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE, "net.sourceforge.texlipse.LaTeXSpellEngine"); store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, true); SpellingService spellingService = new SpellingService(store); if (spellingService.getActiveSpellingEngineDescriptor(store) == null) return null; IReconcilingStrategy strategy = new TeXSpellingReconcileStrategy(sourceViewer, spellingService); MonoReconciler reconciler = new MonoReconciler(strategy, true); reconciler.setDelay(500); reconciler.setProgressMonitor(new NullProgressMonitor()); return reconciler; }
From source file:org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryConfiguration.java
License:Apache License
public IRepositoryModel newRepositoryElement(IRepositoryType type) { String id = UUID.randomUUID().toString(); PreferenceStore prefs = new PreferenceStore(); RepositoryModel element = new RepositoryModel(id, "", type, prefs); prefs.setFilename(makeFileName(element)); prefs.setValue("id", id); return element; }
From source file:org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryConfiguration.java
License:Apache License
private static RepositoryModel loadRepository(String id, String key, RepositoryType type, IPreferenceStore prefs) {//from w ww.ja va 2 s.com String name = type.isDynamic() ? prefs.getString(key + NAME) : type.getType(); PreferenceStore repPrefs = new PreferenceStore(); RepositoryModel element = new RepositoryModel(id, name, type, repPrefs); String loc = prefs.getString(key + LOC); if (loc == null || loc.trim().length() == 0) { loc = makeFileName(element); } repPrefs.setFilename(loc); if (new File(loc).exists()) { try { repPrefs.load(); } catch (IOException e) { SigilCore.error("Failed to load properties for repository " + key, e); } } repPrefs.setValue("id", id); return element; }
From source file:org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryPreferences.java
License:Apache License
public PreferenceStore toPreferenceStore(final IRepositoryModel model) { PreferenceStore store = new PreferenceStore(); store.setFilename(makeFileName(model)); for (Map.Entry<Object, Object> e : model.getProperties().entrySet()) { store.setValue((String) e.getKey(), (String) e.getValue()); }// w ww.j a v a2 s . com store.setValue("provider", model.getType().getProvider()); store.addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { model.getProperties().setProperty(event.getProperty(), event.getNewValue().toString()); } }); return store; }
From source file:org.archicontribs.database.DBSelectDatabase.java
License:Open Source License
private void saveValues() { PreferenceStore store = new PreferenceStore("org.archicontribs.database"); if (remember.getSelection()) { store.setValue("driver", driver.getText()); store.setValue("server", server.getText()); store.setValue("port", port.getText()); store.setValue("database", database.getText()); store.setValue("username", username.getText()); store.setValue("password", password.getText()); store.setValue("remember", remember.getSelection()); store.setValue("doNotAskAgain", doNotAskAgain.getSelection()); } else {//from w ww . j a v a 2 s . com store.setValue("driver", ""); store.setValue("server", ""); store.setValue("port", ""); store.setValue("database", ""); store.setValue("username", ""); store.setValue("password", ""); store.setValue("remember", false); store.setValue("doNotAskAgain", false); } try { store.save(); } catch (IOException e) { DBPlugin.popup(Level.Error, "Cannot save preferences.", e); return; } }
From source file:org.bonitasoft.studio.importer.builder.ProcBuilder.java
License:Open Source License
private Element createShape(String id, EObject container, Point location, Dimension size, IElementType type, boolean isCollapsed) throws ProcBuilderException { final PreferencesHint hint = diagramPart.getDiagramPreferencesHint(); final PreferenceStore store = (PreferenceStore) hint.getPreferenceStore(); store.setValue("isCollapsed", isCollapsed); ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor( new CreateElementRequestAdapter(new CreateElementRequest(type)), Node.class, ((IHintedType) type).getSemanticHint(), hint); CreateViewAndElementRequest createRequest = createCreationRequest(location, size, viewDescriptor); if (container == null || !(container instanceof Element)) { throw new ProcBuilderException("Impossible to find the parent EditPart"); }/* www. j a v a 2 s . co m*/ diagramPart.refresh(); IGraphicalEditPart parentEditPart = GMFTools.findEditPart(diagramPart, (Element) container); IGraphicalEditPart compartment = retrieveCompartmentEditPartFor(parentEditPart); diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(compartment.getCommand(createRequest)); compartment.refresh(); Node newNode = (Node) viewDescriptor.getAdapter(Node.class); if (newNode == null) { throw new ProcBuilderException("New elment not created"); } currentView = newNode; Element createdElement = (Element) newNode.getElement(); ShapeNodeEditPart nodeEditPart = (ShapeNodeEditPart) GMFTools.findEditPart(diagramPart, createdElement); if (nodeEditPart == null) { throw new ProcBuilderException("New edit part not created"); } editParts.put(id, nodeEditPart); return createdElement; }
From source file:org.dsource.ddt.lang.text.LangAutoEditStragetyTest.java
License:Open Source License
protected PreferenceStore createPreferenceStore() { PreferenceStore prefStore = new PreferenceStore(); prefStore.setValue(LangAutoEditPreferenceConstants.AE_SMART_INDENT, true); prefStore.setValue(LangAutoEditPreferenceConstants.AE_SMART_DEINDENT, true); prefStore.setValue(LangAutoEditPreferenceConstants.AE_PARENTHESES_AS_BLOCKS, true); prefStore.setValue(LangAutoEditPreferenceConstants.AE_CLOSE_BRACES, true); prefStore.setValue(LangAutoEditPreferenceConstants.AE_CLOSE_BRACKETS, true); prefStore.setValue(LangAutoEditPreferenceConstants.AE_CLOSE_STRINGS, true); prefStore.setValue(PreferenceConstants.EDITOR_SMART_PASTE, true); prefStore.setValue(CodeFormatterConstants.FORMATTER_TAB_SIZE, 4); prefStore.setValue(CodeFormatterConstants.FORMATTER_TAB_CHAR, TabStyle.TAB.getName()); return prefStore; }
From source file:org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage.java
License:Open Source License
/** * Set the values of the component widgets based on the values in the preference store *///from w w w .j a v a2 s . c o m private void setValues() { // Set the number format combo boxes. fVariableFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL, null))); fExpressionFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL, null))); fRegisterFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL, null))); // Set the charset editors. // Create a temporary preference store. PreferenceStore ps = new PreferenceStore(); // Get the default charset and the default wide charset. String defaultCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_CHARSET, null); if (defaultCharset != null) { ps.setDefault(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset); } String defaultWideCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null); if (defaultWideCharset != null) { ps.setDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset); } // Get the charset and the wide charset. If they're unset, use the default instead. // Note that we have to call the setValue() function of the PreferenceStore even if we // want to use the default. This is to ensure proper display of the encoding field editor. String charset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_CHARSET, null); if (charset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, charset); } else if (defaultCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset); } String wideCharset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null); if (wideCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, wideCharset); } else if (defaultWideCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset); } // Initialize the encoding field editors with the values from the preference store. fCharsetEditor.setPreferenceStore(ps); fCharsetEditor.load(); fWideCharsetEditor.setPreferenceStore(ps); fWideCharsetEditor.load(); // Tell the encoding field editors to check the "Default" option if we're currently using the default values. if (charset == null) { fCharsetEditor.loadDefault(); } if (wideCharset == null) { fWideCharsetEditor.loadDefault(); } // Set the values for the remaining preferences. fShowBinarySourceFilesButton.setSelection(Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true, null)); }
From source file:org.eclipse.cdt.internal.ui.preferences.SpellingConfigurationBlock.java
License:Open Source License
/** * Creates the encoding field editor.//from www . j a v a 2 s. c o m * * @param composite the parent composite * @param allControls list with all controls */ private void createEncodingFieldEditor(Composite composite, List<Control> allControls) { Label filler = new Label(composite, SWT.NONE); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 4; filler.setLayoutData(gd); Label label = new Label(composite, SWT.NONE); label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); allControls.add(label); fEncodingEditorParent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; fEncodingEditorParent.setLayout(layout); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; fEncodingEditorParent.setLayoutData(gd); fEncodingEditor = new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, //$NON-NLS-1$ fEncodingEditorParent); PreferenceStore store = new PreferenceStore(); String defaultEncoding = ResourcesPlugin.getEncoding(); store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding); String encoding = getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding); fEncodingEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change listener DialogPage fakePage = new DialogPage() { @Override public void createControl(Composite c) { } @Override public void setErrorMessage(String newMessage) { StatusInfo status = new StatusInfo(); if (newMessage != null) status.setError(newMessage); fEncodingFieldEditorStatus = status; fContext.statusChanged(StatusUtil.getMostSevere( new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); } }; fEncodingEditor.setPage(fakePage); fEncodingEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) fEncodingEditor.loadDefault(); }
From source file:org.eclipse.dltk.ruby.ui.tests.text.indenting.IndentingTest.java
License:Open Source License
private RubyAutoEditStrategy createStrategy(boolean useTabs) { PreferenceStore store = new PreferenceStore(); RubyPreferenceConstants.initializeDefaultValues(store); store.setValue(CodeFormatterConstants.FORMATTER_TAB_CHAR, (useTabs ? CodeFormatterConstants.TAB : CodeFormatterConstants.SPACE)); store.setValue(PreferenceConstants.EDITOR_CLOSE_BRACES, false); String partitioning = IRubyPartitions.RUBY_PARTITIONING; RubyAutoEditStrategy result = new RubyAutoEditStrategy(partitioning, store); return result; }