org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile Java Examples
The following examples show how to use
org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile.
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 | 6 votes |
/** * Returns a list of {@link org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile} stored in the <code>scope</code>, * including the built-in profiles. * @param scope the context from which to retrieve the profiles * @return list of profiles, not null * @since 3.3 */ public static List<Profile> loadProfiles(IScopeContext scope) { CleanUpProfileVersioner versioner= new CleanUpProfileVersioner(); ProfileStore profileStore= new ProfileStore(CleanUpConstants.CLEANUP_PROFILES, versioner); List<Profile> list= null; try { list= profileStore.readProfiles(scope); } catch (CoreException e1) { JavaPlugin.log(e1); } if (list == null) { list= getBuiltInProfiles(); } else { list.addAll(getBuiltInProfiles()); } return list; }
Example #2
Source File: ModifyDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) { super(parentShell); fProfileStore= profileStore; fLastSaveLoadPathKey= lastSavePathKey; fKeyPreferredWidth= JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_WIDTH; fKeyPreferredHight= JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_HEIGHT; fKeyPreferredX= JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_X; fKeyPreferredY= JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_PREFERRED_Y; fKeyLastFocus= JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_LAST_FOCUS; fProfileManager= profileManager; fNewProfile= newProfile; fProfile= profile; setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName())); fWorkingValues= new HashMap<String, String>(fProfile.getSettings()); setStatusLineAboveButtons(false); fTabPages= new ArrayList<IModifyDialogTabPage>(); fDialogSettings= JavaPlugin.getDefault().getDialogSettings(); }
Example #3
Source File: ProfileStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example #4
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Exports all the profiles to a file. * * @since 3.6 */ private void exportAllButtonPressed() { final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.SAVE); dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_export_profiles_dialog_title); dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$ final String lastPath= JavaPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$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(fComposite.getShell(), FormatterMessages.CodingStyleConfigurationBlock_export_profiles_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_export_profiles_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.addAll(fProfileManager.getSortedProfiles()); try { fProfileStore.writeProfilesToFile(profiles, file, encoding); } catch (CoreException e) { final String title= FormatterMessages.CodingStyleConfigurationBlock_export_profiles_error_title; final String message= FormatterMessages.CodingStyleConfigurationBlock_export_profiles_error_message; ExceptionHandler.handle(e, fComposite.getShell(), title, message); } }
Example #5
Source File: CleanUpRefactoringWizard.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Hashtable<String, Profile> loadProfiles() { List<Profile> list= CleanUpPreferenceUtil.loadProfiles(InstanceScope.INSTANCE); Hashtable<String, Profile> profileIdsTable= new Hashtable<String, Profile>(); for (Iterator<Profile> iterator= list.iterator(); iterator.hasNext();) { Profile profile= iterator.next(); profileIdsTable.put(profile.getID(), profile); } return profileIdsTable; }
Example #6
Source File: ModifyDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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: FormatterProfileStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<Profile> readProfiles(IScopeContext scope) throws CoreException { List<Profile> profiles= super.readProfiles(scope); if (profiles == null) { profiles= readOldForCompatibility(scope); } return profiles; }
Example #8
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void performDefaults() { Profile profile= fProfileManager.getDefaultProfile(); if (profile != null) { int defaultIndex= fProfileManager.getSortedProfiles().indexOf(profile); if (defaultIndex != -1) { fProfileManager.setSelected(profile); } } }
Example #9
Source File: ProfileStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equals(XML_NODE_SETTING)) { final String key= attributes.getValue(XML_ATTRIBUTE_ID); final String value= attributes.getValue(XML_ATTRIBUTE_VALUE); fSettings.put(key, value); } else if (qName.equals(XML_NODE_PROFILE)) { fName= attributes.getValue(XML_ATTRIBUTE_NAME); fKind= attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND); if (fKind == null) //Can only be an CodeFormatterProfile created pre 3.3M2 fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND; fSettings= new HashMap<String, String>(200); } else if (qName.equals(XML_NODE_ROOT)) { fProfiles= new ArrayList<Profile>(); try { fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION)); } catch (NumberFormatException ex) { throw new SAXException(ex); } } }
Example #10
Source File: CleanUpPreferenceUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns a list of built in clean up profiles * @return the list of built in profiles, not null * @since 3.3 */ public static List<Profile> getBuiltInProfiles() { ArrayList<Profile> result= new ArrayList<Profile>(); Map<String, String> settings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_CLEAN_UP_OPTIONS).getMap(); final Profile eclipseProfile= new BuiltInProfile(CleanUpConstants.ECLIPSE_PROFILE, CleanUpMessages.CleanUpProfileManager_ProfileName_EclipseBuildIn, settings, 2, CleanUpProfileVersioner.CURRENT_VERSION, CleanUpProfileVersioner.PROFILE_KIND); result.add(eclipseProfile); return result; }
Example #11
Source File: FormatterModifyDialog.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) { super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey); this.fProfile = profile; this.fKeyLastFocus = JavaUI.ID_PLUGIN + dialogPreferencesKey + DS_KEY_LAST_FOCUS; this.fDialogSettings = JavaPlugin.getDefault().getDialogSettings(); }
Example #12
Source File: FormatterModifyDialog.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public FormatterModifyDialog create(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) { FormatterModifyDialog modifyDialog = new FormatterModifyDialog(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey); injector.injectMembers(modifyDialog); return modifyDialog; }
Example #13
Source File: ProfileStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public List<Profile> getProfiles() { return fProfiles; }
Example #14
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void update(Observable o, Object arg) { Profile selected= ((ProfileManager)o).getSelected(); final boolean notBuiltIn= !selected.isBuiltInProfile(); fDeleteButton.setEnabled(notBuiltIn); }
Example #15
Source File: FormatterConfigurationBlock.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override protected ModifyDialog createModifyDialog(Shell shell, ProfileManager.Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) { return formatterModifyDialogFactory.create(shell, profile, profileManager, profileStore, newProfile, "", ""); //$NON-NLS-1$ //$NON-NLS-2$ }
Example #16
Source File: CodeFormatterConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) { return new FormatterModifyDialog(shell, profile, profileManager, profileStore, newProfile, FORMATTER_DIALOG_PREFERENCE_KEY, DIALOGSTORE_LASTSAVELOADPATH); }
Example #17
Source File: CodeFormatterConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) { return new FormatterProfileManager(profiles, context, access, profileVersioner); }
Example #18
Source File: FormatterModifyDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) { super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey); }
Example #19
Source File: CleanUpConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) { profiles.addAll(CleanUpPreferenceUtil.getBuiltInProfiles()); fProfileManager= new CleanUpProfileManager(profiles, context, access, profileVersioner); return fProfileManager; }
Example #20
Source File: CleanUpConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) { return new CleanUpModifyDialog(shell, profile, profileManager, profileStore, newProfile, CLEANUP_PAGE_SETTINGS_KEY, DIALOGSTORE_LASTSAVELOADPATH); }
Example #21
Source File: CleanUpModifyDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public CleanUpModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) { super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey); }
Example #22
Source File: ProfileStore.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * @return Returns the collection of profiles currently stored in the preference store or * <code>null</code> if the loading failed. The elements are of type {@link ProfileManager.CustomProfile} * and are all updated to the latest version. * @throws CoreException */ public List<Profile> readProfiles(IScopeContext scope) throws CoreException { return readProfilesFromString(scope.getNode(JavaUI.ID_PLUGIN).get(fProfilesKey, null)); }
Example #23
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | votes |
protected abstract ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner);
Example #24
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | votes |
protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile);