Java Code Examples for org.eclipse.jdt.internal.corext.fix.CleanUpPreferenceUtil#loadSaveParticipantOptions()

The following examples show how to use org.eclipse.jdt.internal.corext.fix.CleanUpPreferenceUtil#loadSaveParticipantOptions() . 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: GWTJavaEditor.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private boolean formatOnSaveEnabled(IJavaProject javaProject) {
  SaveParticipantRegistry spr = JavaPlugin.getDefault().getSaveParticipantRegistry();
  IPostSaveListener[] listeners = spr.getEnabledPostSaveListeners(javaProject.getProject());

  for (IPostSaveListener listener : listeners) {
    if (listener instanceof CleanUpPostSaveListener) {
      Map<String, String> settings =
          CleanUpPreferenceUtil.loadSaveParticipantOptions(new ProjectScope(
          javaProject.getProject()));

      if (settings == null) {
        return false;
      }

      return (CLEAN_UP_OPTION_TRUE.equals(settings.get(CleanUpConstants.FORMAT_SOURCE_CODE)));
    }
  }

  return false;
}
 
Example 2
Source File: CleanUpSaveParticipantPreferenceConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialize(final IScopeContext context, IAdaptable element) {
	fContext= context;
	fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(context);

	settingsChanged();

	IJavaProject javaProject= null;
	if (element != null) {
		IProject project= (IProject)element.getAdapter(IProject.class);
		if (project != null) {
			IJavaProject jProject= JavaCore.create(project);
			if (jProject != null && jProject.exists()) {
				javaProject= jProject;
			}
		}
	}

	configurePreferenceLink(fFormatConfigLink, javaProject, CodeFormatterPreferencePage.PREF_ID, CodeFormatterPreferencePage.PROP_ID);
	configurePreferenceLink(fOrganizeImportsConfigLink, javaProject, ImportOrganizePreferencePage.PREF_ID, ImportOrganizePreferencePage.PROP_ID);

	super.initialize(context, element);
}
 
Example 3
Source File: CleanUpSaveParticipantPreferenceConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performDefaults() {
	if (ProjectScope.SCOPE.equals(fContext.getName()) && !hasSettingsInScope(fContext))
		return;

	enabled(true);

	if (ProjectScope.SCOPE.equals(fContext.getName())) {
		fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(InstanceScope.INSTANCE);
	} else {
		fSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
	}
	settingsChanged();

	super.performDefaults();
}