List of usage examples for org.eclipse.jface.preference IPreferenceStore getString
String getString(String name);
From source file:com.qcenzo.tools.localize.popup.actions.Localize.java
License:Open Source License
public void run(IAction action) { try {/*from w ww . jav a2 s . co m*/ if (_selected == null) { MessageDialog.openInformation(_shell, "Error", "Fail to localize."); return; } IPreferenceStore store = Activator.getDefault().getPreferenceStore(); _extensionsPattern = Pattern.compile(store.getString(LocalizationPreferenceConstants.EXTENSIONS) .replaceAll("[\\s" + "|]+", "").replaceAll(";+", "|").toLowerCase()); _node = _nodePicker = new Node(); findFile(Paths.get(_selected.getLocation().toOSString())); _translatorPattern = Pattern .compile(refine(store.getString(LocalizationPreferenceConstants.REGEX).getBytes())); TranslatorManager.getInstance().init(store.getString(LocalizationPreferenceConstants.TRANSLATOR), store.getInt(LocalizationPreferenceConstants.FROMTO)); new ProgressMonitorDialog(_shell).run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { int current = 1; monitor.beginTask("Localizing...(" + current + "/" + Node.number + ")", IProgressMonitor.UNKNOWN); while (_node.path != null) { if (monitor.isCanceled()) monitor.done(); monitor.setTaskName("Localizing...(" + (current++) + "/" + Node.number + ")"); monitor.subTask(_node.path.toString()); translate(_node.path); _node = _node.next; } monitor.done(); } catch (Throwable e) { monitor.done(); } } }); Node.number = 0; IHandlerService s = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); s.executeCommand("org.eclipse.ui.file.refresh", null); } catch (Throwable e) { } }
From source file:com.rcpcompany.uibindings.extests.manager.AbstractPreferenceStoreEnumTest.java
License:Open Source License
/** * Tests for {@link IManager#getE()}.//from w w w .j a va 2 s .c om */ @Test public void testGet() { final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); assertNoLog(new Runnable() { @Override public void run() { assertNotNull(ps); final String value = ps.getString(getPreferenceName()); assertEquals(getDefault().name(), value); assertEquals(getDefault(), m.eGet(getFeature())); ps.setValue(getPreferenceName(), getValues()[1].name()); for (final E s : getValues()) { testPS2M(s); } } }); testPS2MError("sdsdsdsdsd"); ps.setValue(getPreferenceName(), getDefault().name()); }
From source file:com.rcpcompany.uibindings.extests.manager.AbstractPreferenceStoreEnumTest.java
License:Open Source License
public void testM2PS(final E newValue) { final E oldValue = (E) m.eGet(getFeature()); final TestAdapter adapter = new TestAdapter(oldValue, newValue); final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); assertNoLog(new Runnable() { @Override// w w w.j av a 2s.c o m public void run() { m.eAdapters().add(adapter); m.eSet(getFeature(), newValue); assertEquals(1, adapter.called); m.eAdapters().remove(adapter); } }); final String s = ps.getString(getPreferenceName()); assertEquals(newValue.name(), s); assertEquals(newValue, m.eGet(getFeature())); }
From source file:com.rcpcompany.uibindings.internal.Activator.java
License:Open Source License
protected void updateManagerProperties() { final IManager manager = IManager.Factory.getManager(); final IPreferenceStore preferenceStore = getPreferenceStore(); Assert.isNotNull(manager);/*from w w w.jav a 2s . c om*/ boolean b; int i; String s; s = preferenceStore.getString(Constants.PREF_TEXT_COMMIT_STRATEGY); try { final TextCommitStrategy cs = TextCommitStrategy.valueOf(s); if (manager.getTextCommitStrategy() != cs) { manager.setTextCommitStrategy(cs); } } catch (final IllegalArgumentException ex) { LogUtils.error(this, "Unknown text commit strategy: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$ } i = preferenceStore.getInt(Constants.PREF_TEXT_COMMIT_STRATEGY_DELAY); if (manager.getTextCommitStrategyDelay() != i) { manager.setTextCommitStrategyDelay(i); } b = preferenceStore.getBoolean(Constants.PREF_AUTO_APPLY_QUICKFIX); if (manager.isAutoApplySingleQuickfix() != b) { manager.setAutoApplySingleQuickfix(b); } b = preferenceStore.getBoolean(Constants.PREF_DELETE_HANDLER_CHECK_ENABLED); if (manager.isDeleteHandlerCheckEnabled() != b) { manager.setDeleteHandlerCheckEnabled(b); } b = preferenceStore.getBoolean(Constants.PREF_EDIT_CELL_ANY_KEY); if (manager.isEditCellAnyKey() != b) { manager.setEditCellAnyKey(b); } b = preferenceStore.getBoolean(Constants.PREF_EDIT_CELL_SINGLE_CLICK); if (manager.isEditCellSingleClick() != b) { manager.setEditCellSingleClick(b); } b = preferenceStore.getBoolean(Constants.PREF_ALTERNATE_ROW_COLORS); if (manager.isAlternateRowColors() != b) { manager.setAlternateRowColors(b); } b = preferenceStore.getBoolean(Constants.PREF_VALIDATION_ERRORS_ARE_FATAL); if (manager.isValidationErrorsAreFatal() != b) { manager.setValidationErrorsAreFatal(b); } s = preferenceStore.getString(Constants.PREF_MESSAGE_DECORATION_POSITION); final DecorationPosition mdp = DecorationPosition.get(s); if (mdp != null) { if (manager.getMessageDecorationPosition() != mdp) { manager.setMessageDecorationPosition(mdp); } } else { LogUtils.error(this, "Unknown message decoration position: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$ } s = preferenceStore.getString(Constants.PREF_MESSAGE_DECORATION_MINIMUM_SEVERITY); final BindingMessageSeverity ms = BindingMessageSeverity.get(s); if (ms != null) { if (manager.getMessageDecorationMinimumSeverity() != ms) { manager.setMessageDecorationMinimumSeverity(ms); } } else { LogUtils.error(this, "Unknown message decoration minimum severity: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$ } s = preferenceStore.getString(Constants.PREF_ALTERNATIVE_DECORATION_POSITION); final DecorationPosition adp = DecorationPosition.get(s); if (adp != null) { if (manager.getAlternativeDecorationPosition() != adp) { manager.setAlternativeDecorationPosition(adp); } } else { LogUtils.error(this, "Unknown alternative decoration position: '" + s + "'"); //$NON-NLS-1$ //$NON-NLS-2$ } i = preferenceStore.getInt(Constants.PREF_VALIDATION_DELAY); if (manager.getValidationDelay() != i) { manager.setValidationDelay(i); } i = preferenceStore.getInt(Constants.PREF_VALIDATION_DELAY_WINDOW); if (manager.getValidationDelayWindow() != i) { manager.setValidationDelayWindow(i); } b = preferenceStore.getBoolean(Constants.PREF_REQUIRED_VBID_SHOWN); if (manager.isRequiredVBImageDecorationShown() != b) { manager.setRequiredVBImageDecorationShown(b); } b = preferenceStore.getBoolean(Constants.PREF_QUICKFIX_VBID_SHOWN); if (manager.isQuickfixVBImageDecorationShown() != b) { manager.setQuickfixVBImageDecorationShown(b); } b = preferenceStore.getBoolean(Constants.PREF_ASSIST_VBID_SHOWN); if (manager.isAssistVBImageDecorationShown() != b) { manager.setAssistVBImageDecorationShown(b); } b = preferenceStore.getBoolean(Constants.PREF_VIEW_NAVIGATION_RECORDED); if (manager.isViewNavigationRecorded() != b) { manager.setViewNavigationRecorded(b); } }
From source file:com.rcpcompany.uibindings.navigator.extests.manager.PreferenceTest.java
License:Open Source License
/** * Tests that the defaults and the current values are all correct. *///w w w. j a v a2s. c o m @Test public void testDefaults() { final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); final INavigatorManager manager = INavigatorManager.Factory.getManager(); for (final CEObjectHolder<EObject> pmt : manager.getPreferenceModelTypes()) { final IEditorInformation mt = manager.getEditorInformation(pmt.getObjectClass()); final String c = mt.getModelType(); final String def = ps.getDefaultString(c); if (def == null || def.length() == 0) { continue; } assertEquals(mt.getEditors().get(0).getId(), def); assertEquals(ps.getString(c), def); assertEquals(mt.getEditors().get(0), mt.getPreferredEditor()); } }
From source file:com.rcpcompany.uibindings.navigator.extests.manager.PreferenceTest.java
License:Open Source License
/** * Tests that setting the preferred will change the preferences *///w ww . j a va 2 s.c o m @Test public void testPreferredToPreference() { final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); /* * Find the model type with multiple editors. */ final IEditorInformation mt = NavigatorTestUtils.getMultipleEditorModelType(); final IEditorPartDescriptor first = mt.getEditors().get(0); final IEditorPartDescriptor second = mt.getEditors().get(1); assertEquals(first, mt.getPreferredEditor()); assertEquals(first.getId(), ps.getString(mt.getModelType())); assertNoLog(new Runnable() { @Override public void run() { mt.setPreferredEditor(second); } }); assertEquals(second, mt.getPreferredEditor()); assertEquals(second.getId(), ps.getString(mt.getModelType())); assertNoLog(new Runnable() { @Override public void run() { mt.setPreferredEditor(null); } }); assertEquals(first, mt.getPreferredEditor()); assertEquals(first.getId(), ps.getString(mt.getModelType())); }
From source file:com.rcpcompany.uibindings.navigator.extests.manager.PreferenceTest.java
License:Open Source License
/** * Tests that setting the preference will change the preferred *//*from w ww . ja va2s. c om*/ @Test public void testPreferenceToPreferred() { final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); /* * Find the model type with multiple editors. */ final IEditorInformation mt = NavigatorTestUtils.getMultipleEditorModelType(); final IEditorPartDescriptor first = mt.getEditors().get(0); final IEditorPartDescriptor second = mt.getEditors().get(1); assertEquals(first, mt.getPreferredEditor()); assertEquals(first.getId(), ps.getString(mt.getModelType())); assertNoLog(new Runnable() { @Override public void run() { ps.setValue(mt.getModelType(), second.getId()); } }); assertEquals(second, mt.getPreferredEditor()); assertEquals(second.getId(), ps.getString(mt.getModelType())); // Wrong value defaults to first.. assertOneLog(new Runnable() { @Override public void run() { ps.setValue(mt.getModelType(), "aaa"); } }); assertEquals(first, mt.getPreferredEditor()); assertEquals(first.getId(), ps.getString(mt.getModelType())); }
From source file:com.rcpcompany.uibindings.navigator.internal.NavigatorManagerImpl.java
License:Open Source License
/** * Finds the current preference value and sets the default editor. * /*from w ww .j av a 2 s . co m*/ * @param ei the model type to set the default editor for */ protected void setCurrentPreferenceValue(final IEditorInformation ei) { final IPreferenceStore ps = Activator.getDefault().getPreferenceStore(); String key = ei.getModelType(); if (key == null) { key = ei.getTreeItemID(); } final String id = ps.getString(key); IEditorPartDescriptor pref = null; /* * Try to lookup the editor id */ for (final IEditorPartDescriptor e : ei.getEditors()) { if (e.getId().equals(id)) { pref = e; break; } } /* * Use the default (the editor with the highest priority) */ if (pref == null && (id == null || id.length() == 0)) { pref = ei.getEditors().get(0); } if (pref == null) { /* * The preference was not found. Can happen if a newer version of the application does * not support the editor any more... or if somebody have changed the id by mistake. */ LogUtils.error(this, "Preference not found for " + key + ": '" + id + "'. Reset to default."); pref = ei.getEditors().get(0); } if (pref != ei.getPreferredEditor()) { ei.setPreferredEditor(pref); } }
From source file:com.redhat.ceylon.eclipse.code.wizard.BuildPathsBlock.java
License:Open Source License
private List<CPListElement> getDefaultClassPath(IJavaProject jproj) { List<CPListElement> list = new ArrayList<CPListElement>(); IResource srcFolder;//ww w . j a v a 2s . c o m IPreferenceStore store = PreferenceConstants.getPreferenceStore(); String sourceFolderName = store.getString(PreferenceConstants.SRCBIN_SRCNAME); if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ) && sourceFolderName.length() > 0) { srcFolder = jproj.getProject().getFolder(sourceFolderName); } else { srcFolder = jproj.getProject(); } list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder)); IClasspathEntry[] jreEntries = PreferenceConstants.getDefaultJRELibrary(); list.addAll(getCPListElements(jreEntries, null)); return list; }
From source file:com.rohanclan.afae.editor.AfaeEditor.java
License:Open Source License
/** * Set the background color of the editor window based on the user's * preferences/*from www .j a v a 2 s. c o m*/ */ private void setBackgroundColor() { // Only try to set the background color when the source fViewer is // available if (this.getSourceViewer() != null && this.getSourceViewer().getTextWidget() != null) { IPreferenceStore store = AfaePlugin.getDefault().getPreferenceStore(); this.getSourceViewer().getTextWidget().setForeground(new org.eclipse.swt.graphics.Color( Display.getCurrent(), StringConverter.asRGB(store.getString(NULL_COLOR)))); this.getSourceViewer().getTextWidget().setBackground(new org.eclipse.swt.graphics.Color( Display.getCurrent(), StringConverter.asRGB(store.getString(INVALID_COLOR)))); // //// The newer style stuff needs to repartition the whole // document when applied // //// it can't just update the single attributes (to handle // background changes and // //// other items. The following updates the background and style // settings for all // //// of text elements IPreferencesConstants.ALL_TEXT_STYLES ((AfaeSourceViewerConfiguration) this.getSourceViewerConfiguration()).refreshAllStyles(); Object ele = ((AfaeDocumentProvider) this.getDocumentProvider()).element; ((AfaeDocumentProvider) this.getDocumentProvider()) .partitionDocument(this.getDocumentProvider().getDocument(ele), ele); // ////////////// } }