Java Code Examples for org.eclipse.core.runtime.preferences.IEclipsePreferences#PreferenceChangeEvent

The following examples show how to use org.eclipse.core.runtime.preferences.IEclipsePreferences#PreferenceChangeEvent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EclipsePreferencesAdapter.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
	if (Display.getCurrent() == null) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
			}
		});
	} else {
		firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
	}
}
 
Example 2
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
	if (Display.getCurrent() == null) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
			}
		});
	} else {
		firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
	}
}
 
Example 3
Source File: EclipsePreferencesAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
	if (Display.getCurrent() == null) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
			}
		});
	} else {
		firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
	}
}
 
Example 4
Source File: JavaProject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns the project custom preference pool.
 * Project preferences may include custom encoding.
 * @return IEclipsePreferences or <code>null</code> if the project
 * 	does not have a java nature.
 */
public IEclipsePreferences getEclipsePreferences() {
	if (!JavaProject.hasJavaNature(this.project)) return null;
	// Get cached preferences if exist
	JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, true);
	if (perProjectInfo.preferences != null) return perProjectInfo.preferences;
	// Init project preferences
	IScopeContext context = new ProjectScope(getProject());
	final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID);
	updatePreferences(eclipsePreferences);
	perProjectInfo.preferences = eclipsePreferences;

	// Listen to new preferences node
	final IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) eclipsePreferences.parent();
	if (eclipseParentPreferences != null) {
		if (this.preferencesNodeListener != null) {
			eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener);
		}
		this.preferencesNodeListener = new IEclipsePreferences.INodeChangeListener() {
			public void added(IEclipsePreferences.NodeChangeEvent event) {
				// do nothing
			}
			public void removed(IEclipsePreferences.NodeChangeEvent event) {
				if (event.getChild() == eclipsePreferences) {
					JavaModelManager.getJavaModelManager().resetProjectPreferences(JavaProject.this);
				}
			}
		};
		eclipseParentPreferences.addNodeChangeListener(this.preferencesNodeListener);
	}

	// Listen to preferences changes
	if (this.preferencesChangeListener != null) {
		eclipsePreferences.removePreferenceChangeListener(this.preferencesChangeListener);
	}
	this.preferencesChangeListener = new IEclipsePreferences.IPreferenceChangeListener() {
		public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) {
			String propertyName = event.getKey();
			JavaModelManager manager = JavaModelManager.getJavaModelManager();
			if (propertyName.startsWith(JavaCore.PLUGIN_ID)) {
				if (propertyName.equals(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER) ||
					propertyName.equals(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) ||
					propertyName.equals(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) ||
					propertyName.equals(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER) ||
					propertyName.equals(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) ||
					propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS) ||
					propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) ||
					propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) ||
					propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) ||
					propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE) ||
					propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL) ||
					propertyName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))
				{
					manager.deltaState.addClasspathValidation(JavaProject.this);
				}
				manager.resetProjectOptions(JavaProject.this);
				JavaProject.this.resetCaches(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568
			}
		}
	};
	eclipsePreferences.addPreferenceChangeListener(this.preferencesChangeListener);
	return eclipsePreferences;
}
 
Example 5
Source File: EclipsePreferencesAdapter.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
	firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
}