List of usage examples for org.eclipse.jface.preference PreferenceStore getString
@Override
public String getString(String name)
From source file:net.certiv.fluentmark.spell.SpellingConfigurationBlock.java
License:Open Source License
/** * Creates the encoding field editor./* w w w .j av a 2 s .c om*/ * * @param composite the parent composite * @param string list with all controls */ private void encodingControl(Composite composite, String text) { Label label = new Label(composite, SWT.NONE); label.setText(text); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); fEncodingEditorParent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; fEncodingEditorParent.setLayout(layout); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; gd.horizontalIndent += SwtUtil.getIndent(); fEncodingEditorParent.setLayoutData(gd); encEditor = new EncodingFieldEditor(SPELLING_USER_DICTIONARY_ENCODING, "", null, fEncodingEditorParent); //$NON-NLS-1$ PreferenceStore store = new PreferenceStore(); String defaultEncoding = ResourcesPlugin.getEncoding(); store.setDefault(SPELLING_USER_DICTIONARY_ENCODING, defaultEncoding); String encoding = store.getString(SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(SPELLING_USER_DICTIONARY_ENCODING, encoding); encEditor.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 })); } }; encEditor.setPage(fakePage); encEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) { encEditor.loadDefault(); } }
From source file:net.sourceforge.eclipsetrader.core.CorePlugin.java
License:Open Source License
/** * Log4j configurator/*from w w w . java2s . c om*/ */ public void configureLogging() { try { PreferenceStore preferences = new PreferenceStore(); // Set the default values from extension registry IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry .getExtensionPoint(CorePlugin.LOGGER_PREFERENCES_EXTENSION_POINT); IConfigurationElement[] members = extensionPoint.getConfigurationElements(); for (int i = 0; i < members.length; i++) { IConfigurationElement element = members[i]; if (element.getName().equals("logger")) //$NON-NLS-1$ { if (element.getAttribute("defaultValue") != null) //$NON-NLS-1$ { String[] item = element.getAttribute("name").split(";"); //$NON-NLS-1$ //$NON-NLS-2$ for (int x = 0; x < item.length; x++) preferences.setDefault("log4j.logger." + item[x], element.getAttribute("defaultValue")); //$NON-NLS-1$ //$NON-NLS-2$ } } } // Set the default values from the bundle's properties file try { URL url = CorePlugin.getDefault().getBundle().getResource("log4j.properties"); //$NON-NLS-1$ Properties properties = new Properties(); properties.load(url.openStream()); for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); preferences.setDefault(key, (String) properties.get(key)); } // Read the values from the user's configuration File file = CorePlugin.getDefault().getStateLocation().append("log4j.properties").toFile(); //$NON-NLS-1$ if (file.exists()) preferences.load(new FileInputStream(file)); } catch (Exception e) { CorePlugin.logException(e); } // Configure log4j Properties properties = new Properties(); String[] names = preferences.preferenceNames(); for (int i = 0; i < names.length; i++) properties.put(names[i], preferences.getString(names[i])); PropertyConfigurator.configure(properties); } catch (Exception e) { BasicConfigurator.configure(); logException(e); } }
From source file:net.sourceforge.eclipsetrader.trading.actions.OpenLevel2Action.java
License:Open Source License
public void run(IAction action) { if (security != null) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); PreferenceStore preferences = new PreferenceStore( Level2View.getPreferenceStoreLocation(security).toOSString()); try {/* w w w. j a v a2 s.co m*/ preferences.load(); } catch (Exception e) { } // Builds a random secondary id, if a new view needs to be opened String secondaryId = preferences.getString("secondaryId"); if (secondaryId.equals("")) { String values = "abcdefghijklmnopqrstuvwxyz"; for (int i = 0; i < 8; i++) secondaryId += values.charAt((int) (Math.random() * values.length())); } try { Level2View view = (Level2View) page.showView(Level2View.VIEW_ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE); view.setSecurity(security); } catch (PartInitException e) { CorePlugin.logException(e); } } }
From source file:org.archicontribs.database.DBSelectDatabase.java
License:Open Source License
private void loadValues() { PreferenceStore store = new PreferenceStore("org.archicontribs.database"); //if preferences are not set, that's not an error try {/*from w w w . ja va 2s . c om*/ store.load(); } catch (IOException e) { return; } driver.setText(store.getString("driver")); server.setText(store.getString("server")); port.setText(store.getString("port")); database.setText(store.getString("database")); remember.setSelection(store.getBoolean("remember")); doNotAskAgain.setSelection(store.getBoolean("doNotAskAgain")); username.setText(store.getString("username")); password.setText(store.getString("password")); }
From source file:org.eclipse.titan.designer.properties.pages.CCompilerOptionsPage.java
License:Open Source License
@Override public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { String actualValue = null;/*w w w .j a va 2 s. c o m*/ String copyValue = null; try { actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, CCompilerOptionsData.CXX_COMPILER_PROPERTY)); } catch (CoreException ce) { ErrorReporter.logExceptionStackTrace(ce); } copyValue = tempStorage.getString(CCompilerOptionsData.CXX_COMPILER_PROPERTY); return ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); }
From source file:org.eclipse.titan.designer.properties.pages.COptimalizationOptionsPage.java
License:Open Source License
@Override public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { String actualValue = null;/* w w w . j a va 2s. co m*/ String copyValue = null; boolean result = false; for (int i = 0; i < COptimalizationOptionsData.PROPERTIES.length; i++) { try { actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, COptimalizationOptionsData.PROPERTIES[i])); copyValue = tempStorage.getString(COptimalizationOptionsData.PROPERTIES[i]); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); result = true; } } return result; }
From source file:org.eclipse.titan.designer.properties.pages.LinkerFlagsOptionsPage.java
License:Open Source License
@Override public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { String actualValue = null;/* ww w. jav a 2s . c om*/ String copyValue = null; boolean result = false; for (int i = 0; i < LinkerFlagsOptionsData.PROPERTIES.length; i++) { try { actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, LinkerFlagsOptionsData.PROPERTIES[i])); copyValue = tempStorage.getString(LinkerFlagsOptionsData.PROPERTIES[i]); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); result = true; } } return result; }
From source file:org.eclipse.titan.designer.properties.pages.LinkerLibrariesOptionsPage.java
License:Open Source License
@Override public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { String actualValue = null;/* w w w . j a v a2 s . c o m*/ String copyValue = null; boolean result = false; for (int i = 0; i < LinkerLibrariesOptionsData.PROPERTIES.length; i++) { try { actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, LinkerLibrariesOptionsData.PROPERTIES[i])); copyValue = tempStorage.getString(LinkerLibrariesOptionsData.PROPERTIES[i]); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); } catch (CoreException e) { ErrorReporter.logExceptionStackTrace(e); result = true; } } return result; }
From source file:org.eclipse.titan.designer.properties.pages.MakeAttributesTab.java
License:Open Source License
/** * Evaluates the properties on the option page, and compares them with * the saved values.//w w w. ja v a 2 s. c o m * * @param project * the actual project (the real preference store). * @param tempStorage * the temporal store to copy the values to. * * @return true if the values in the real and the temporal storage are * different (they have changed), false otherwise. * */ public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { boolean result = false; try { String actualValue = project.getPersistentProperty( new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.BUILD_LEVEL_PROPERTY)); actualValue = MakeAttributesData.getBuildLevel(actualValue); String copyValue = tempStorage.getString(MakeAttributesData.BUILD_LEVEL_PROPERTY); result |= !actualValue.equals(copyValue); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_MAKEFILE_SCRIPT_PROPERTY)); copyValue = tempStorage.getString(MakeAttributesData.TEMPORAL_MAKEFILE_SCRIPT_PROPERTY); result |= actualValue == null || !actualValue.equals(copyValue); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_MAKEFILE_FLAGS_PROPERTY)); copyValue = tempStorage.getString(MakeAttributesData.TEMPORAL_MAKEFILE_FLAGS_PROPERTY); result |= actualValue == null || !actualValue.equals(copyValue); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_WORKINGDIRECTORY_PROPERTY)); copyValue = tempStorage.getString(MakeAttributesData.TEMPORAL_WORKINGDIRECTORY_PROPERTY); result |= actualValue == null || !actualValue.equals(copyValue); } catch (CoreException ce) { ErrorReporter.logExceptionStackTrace(ce); } return result; }
From source file:org.eclipse.titan.designer.properties.pages.MakefileCreationTab.java
License:Open Source License
/** * Evaluates the properties on the option page, and compares them with * the saved values./*from w w w.j a v a2s . c o m*/ * * @param project * the actual project (the real preference store). * @param tempStorage * the temporal store to copy the values to. * * @return true if the values in the real and the temporal storage are * different (they have changed), false otherwise. * */ public boolean evaluatePropertyStore(final IProject project, final PreferenceStore tempStorage) { boolean result = false; String actualValue = null; String copyValue = null; try { actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.USE_ABSOLUTEPATH_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.USE_ABSOLUTEPATH_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty( new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.GNU_MAKE_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.GNU_MAKE_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.INCREMENTAL_DEPENDENCY_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.INCREMENTAL_DEPENDENCY_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.DYNAMIC_LINKING_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.DYNAMIC_LINKING_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.FUNCTIONTESTRUNTIME_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.FUNCTIONTESTRUNTIME_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.SINGLEMODE_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.SINGLEMODE_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.CODE_SPLITTING_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.CODE_SPLITTING_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.DEFAULT_TARGET_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.DEFAULT_TARGET_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); actualValue = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.TARGET_EXECUTABLE_PROPERTY)); copyValue = tempStorage.getString(MakefileCreationData.TARGET_EXECUTABLE_PROPERTY); result |= ((actualValue != null && !actualValue.equals(copyValue)) || (actualValue == null && copyValue == null)); } catch (CoreException ce) { ErrorReporter.logExceptionStackTrace(ce); } return result; }