org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile Java Examples

The following examples show how to use org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile. 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: CleanUpPreferenceUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Map<String, String> loadFromProject(IScopeContext context) {
final Map<String, String> profileOptions= new HashMap<String, String>();
IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);

  	CleanUpProfileVersioner versioner= new CleanUpProfileVersioner();

  	CleanUpOptions defaultOptions= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS);
  	KeySet[] keySets= CleanUpProfileManager.KEY_SETS;

  	boolean hasValues= false;
for (int i= 0; i < keySets.length; i++) {
       KeySet keySet= keySets[i];
       IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
       for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
		final String key= keyIter.next();
		String val= preferences.get(key, null);
		if (val != null) {
			hasValues= true;
		} else {
			val= defaultOptions.getValue(key);
		}
		profileOptions.put(key, val);
	}
      }

if (!hasValues)
	return null;

int version= uiPrefs.getInt(CleanUpConstants.CLEANUP_SETTINGS_VERSION_KEY, versioner.getFirstVersion());
if (version == versioner.getCurrentVersion())
	return profileOptions;

CustomProfile profile= new CustomProfile("tmp", profileOptions, version, versioner.getProfileKind()); //$NON-NLS-1$
versioner.update(profile);
return profile.getSettings();
  }
 
Example #2
Source File: ProfileStore.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void endElement(String uri, String localName, String qName) {
	if (qName.equals(XML_NODE_PROFILE)) {
		fProfiles.add(new CustomProfile(fName, fSettings, fVersion, fKind));
		fName= null;
		fSettings= null;
		fKind= null;
	}
}
 
Example #3
Source File: CreateProfileDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void okPressed() {
	if (!getStatus().isOK())
		return;

	JavaPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);

	final Map<String, String> baseSettings= new HashMap<String, String>(fSortedProfiles.get(fProfileCombo.getSelectionIndex()).getSettings());
	final String profileName= fNameText.getText();

	fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
	fProfileManager.addProfile(fCreatedProfile);
	super.okPressed();
}
 
Example #4
Source File: ProfileVersioner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static int getVersionStatus(CustomProfile profile) {
	final int version= profile.getVersion();
	if (version < CURRENT_VERSION)
		return -1;
	else if (version > CURRENT_VERSION)
		return 1;
	else
		return 0;
}
 
Example #5
Source File: AlreadyExistsDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public AlreadyExistsDialog(Shell parentShell, CustomProfile profile, ProfileManager profileManager) {
	super(parentShell);
	fProfile= profile;
	fProfileManager= profileManager;
	fOk= new StatusInfo();
	fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_already_exists);
	fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty);

	setHelpAvailable(false);
}
 
Example #6
Source File: ModifyDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void saveButtonPressed() {
	Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());

	final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
	dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
	dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$

	final String lastPath= JavaPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
	if (lastPath != null) {
		dialog.setFilterPath(lastPath);
	}
	final String path= dialog.open();
	if (path == null)
		return;

	JavaPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$

	final File file= new File(path);
	if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, BasicElementLabels.getPathLabel(file)))) {
		return;
	}
	String encoding= ProfileStore.ENCODING;
	final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
	if (type != null)
		encoding= type.getDefaultCharset();
	final Collection<Profile> profiles= new ArrayList<Profile>();
	profiles.add(selected);
	try {
		fProfileStore.writeProfilesToFile(profiles, file, encoding);
	} catch (CoreException e) {
		final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
		final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
		ExceptionHandler.handle(e, getShell(), title, message);
	}
}
 
Example #7
Source File: FormatterProfileVersioner.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void update(CustomProfile profile) {
	//Nothing to do
}
 
Example #8
Source File: CreateProfileDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public final CustomProfile getCreatedProfile() {
	return fCreatedProfile;
}
 
Example #9
Source File: ProfileVersioner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void update(CustomProfile profile) {
	final Map<String, String> oldSettings= profile.getSettings();
	Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
	profile.setVersion(CURRENT_VERSION);
	profile.setSettings(newSettings);
}
 
Example #10
Source File: CleanUpProfileVersioner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void update(CustomProfile profile) {
	final Map<String, String> oldSettings= profile.getSettings();
	Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
	profile.setVersion(CURRENT_VERSION);
	profile.setSettings(newSettings);
}
 
Example #11
Source File: IProfileVersioner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Update the <code>profile</code> to the
 * current version number
 */
public void update(CustomProfile profile);