private static List<Profile> addBuiltinProfiles(List<Profile> profiles, IProfileVersioner profileVersioner) { final Profile javaProfile= new BuiltInProfile(JAVA_PROFILE, FormatterMessages.ProfileManager_java_conventions_profile_name, getJavaSettings(), 1, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(javaProfile); final Profile eclipseProfile= new BuiltInProfile(ECLIPSE_PROFILE, FormatterMessages.ProfileManager_eclipse_profile_name, getEclipseSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipseProfile); final Profile eclipse21Profile= new BuiltInProfile(ECLIPSE21_PROFILE, FormatterMessages.ProfileManager_default_profile_name, getEclipse21Settings(), 3, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipse21Profile); return profiles; }
public List readProfilesFromString(String profiles) throws CoreException { if (profiles != null && profiles.length() > 0) { byte[] bytes; try { bytes= profiles.getBytes(ENCODING); } catch (UnsupportedEncodingException e) { bytes= profiles.getBytes(); } InputStream is= new ByteArrayInputStream(bytes); try { List res= readProfilesFromStream(new InputSource(is)); if (res != null) { for (int i= 0; i < res.size(); i++) { fProfileVersioner.update((CustomProfile) res.get(i)); } } return res; } finally { try { is.close(); } catch (IOException e) { /* ignore */ } } } return null; }
IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion()); if (version != fProfileVersioner.getCurrentVersion()) { Map allOptions= new HashMap(); for (int i= 0; i < fKeySets.length; i++) { addAll(context.getNode(fKeySets[i].getNodeName()), allOptions); CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$ fProfileVersioner.update(profile); return profile.getSettings();
final CustomProfile profile= (CustomProfile)iter.next(); if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] { fProfileVersioner.getProfileKind(), profile.getKind() }); MessageDialog.openError(fComposite.getShell(), title, message); if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title; final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message; return; fProfileVersioner.update(profile); fProfileManager.addProfile(profile);
public void writeProfiles(Collection<Profile> profiles, IScopeContext instanceScope) throws CoreException { ByteArrayOutputStream stream= new ByteArrayOutputStream(2000); try { writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner); String val; try { val= stream.toString(ENCODING); } catch (UnsupportedEncodingException e) { val= stream.toString(); } IEclipsePreferences uiPreferences = instanceScope.getNode(JavaUI.ID_PLUGIN); uiPreferences.put(fProfilesKey, val); uiPreferences.putInt(fProfilesVersionKey, fProfileVersioner.getCurrentVersion()); } finally { try { stream.close(); } catch (IOException e) { /* ignore */ } } }
private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) { final Element element= document.createElement(XML_NODE_PROFILE); element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName()); element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion())); element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind()); final Iterator keyIter= profile.getSettings().keySet().iterator(); while (keyIter.hasNext()) { final String key= (String)keyIter.next(); final String value= (String)profile.getSettings().get(key); if (value != null) { final Element setting= document.createElement(XML_NODE_SETTING); setting.setAttribute(XML_ATTRIBUTE_ID, key); setting.setAttribute(XML_ATTRIBUTE_VALUE, value); element.appendChild(setting); } else { JavaPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$ } } return element; }
IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion()); if (version != fProfileVersioner.getCurrentVersion()) { Map<String, String> allOptions= new HashMap<>(); for (int i= 0; i < fKeySets.length; i++) { addAll(context.getNode(fKeySets[i].getNodeName()), allOptions); CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$ fProfileVersioner.update(profile); return profile.getSettings();
final CustomProfile profile= (CustomProfile)iter.next(); if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] { fProfileVersioner.getProfileKind(), profile.getKind() }); MessageDialog.openError(fComposite.getShell(), title, message); if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title; final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message; return; fProfileVersioner.update(profile); fProfileManager.addProfile(profile);
rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) { final Element element= document.createElement(XML_NODE_PROFILE); element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName()); element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion())); element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind()); final Iterator<String> keyIter= profile.getSettings().keySet().iterator(); while (keyIter.hasNext()) { final String key= keyIter.next(); final String value= profile.getSettings().get(key); if (value != null) { final Element setting= document.createElement(XML_NODE_SETTING); setting.setAttribute(XML_ATTRIBUTE_ID, key); setting.setAttribute(XML_ATTRIBUTE_VALUE, value); element.appendChild(setting); } else { JavaPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$ } } return element; }
IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN); int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion()); if (version != fProfileVersioner.getCurrentVersion()) { Map<String, String> allOptions= new HashMap<>(); for (int i= 0; i < fKeySets.length; i++) { addAll(context.getNode(fKeySets[i].getNodeName()), allOptions); CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$ fProfileVersioner.update(profile); return profile.getSettings();
private static List addBuiltinProfiles(List profiles, IProfileVersioner profileVersioner) { final Profile javaProfile= new BuiltInProfile(JAVA_PROFILE, FormatterMessages.ProfileManager_java_conventions_profile_name, getJavaSettings(), 1, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(javaProfile); final Profile eclipseProfile= new BuiltInProfile(ECLIPSE_PROFILE, FormatterMessages.ProfileManager_eclipse_profile_name, getEclipseSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipseProfile); final Profile eclipse21Profile= new BuiltInProfile(ECLIPSE21_PROFILE, FormatterMessages.ProfileManager_default_profile_name, getEclipse21Settings(), 3, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipse21Profile); return profiles; }
if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] {fProfileVersioner.getProfileKind(), profile.getKind()}); MessageDialog.openError(fComposite.getShell(), title, message); return; if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) { final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title; final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message; return; fProfileVersioner.update(profile); fProfileManager.addProfile(profile);
rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
public List<Profile> readProfilesFromString(String profiles) throws CoreException { if (profiles != null && profiles.length() > 0) { byte[] bytes; try { bytes= profiles.getBytes(ENCODING); } catch (UnsupportedEncodingException e) { bytes= profiles.getBytes(); } InputStream is= new ByteArrayInputStream(bytes); try { List<Profile> res= readProfilesFromStream(new InputSource(is)); if (res != null) { for (int i= 0; i < res.size(); i++) { fProfileVersioner.update((CustomProfile) res.get(i)); } } return res; } finally { try { is.close(); } catch (IOException e) { /* ignore */ } } } return null; }
private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) { final Element element= document.createElement(XML_NODE_PROFILE); element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName()); element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion())); element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind()); final Iterator<String> keyIter= profile.getSettings().keySet().iterator(); while (keyIter.hasNext()) { final String key= keyIter.next(); final String value= profile.getSettings().get(key); if (value != null) { final Element setting= document.createElement(XML_NODE_SETTING); setting.setAttribute(XML_ATTRIBUTE_ID, key); setting.setAttribute(XML_ATTRIBUTE_VALUE, value); element.appendChild(setting); } else { JavaPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$ } } return element; }
private static List<Profile> addBuiltinProfiles(List<Profile> profiles, IProfileVersioner profileVersioner) { final Profile javaProfile= new BuiltInProfile(JAVA_PROFILE, FormatterMessages.ProfileManager_java_conventions_profile_name, getJavaSettings(), 1, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(javaProfile); final Profile eclipseProfile= new BuiltInProfile(ECLIPSE_PROFILE, FormatterMessages.ProfileManager_eclipse_profile_name, getEclipseSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipseProfile); final Profile eclipse21Profile= new BuiltInProfile(ECLIPSE21_PROFILE, FormatterMessages.ProfileManager_default_profile_name, getEclipse21Settings(), 3, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); profiles.add(eclipse21Profile); return profiles; }
rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
public List<Profile> readProfilesFromString(String profiles) throws CoreException { if (profiles != null && profiles.length() > 0) { byte[] bytes; try { bytes= profiles.getBytes(ENCODING); } catch (UnsupportedEncodingException e) { bytes= profiles.getBytes(); } InputStream is= new ByteArrayInputStream(bytes); try { List<Profile> res= readProfilesFromStream(new InputSource(is)); if (res != null) { for (int i= 0; i < res.size(); i++) { fProfileVersioner.update((CustomProfile) res.get(i)); } } return res; } finally { try { is.close(); } catch (IOException e) { /* ignore */ } } } return null; }
private void saveButtonPressed() { Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());