Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 140866 Details for
Bug 48966
[preferences] Should be able to export from 'Formatter' preference page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with the fix.
patch3_48966.txt (text/plain), 12.89 KB, created by
Raksha Vasisht
on 2009-07-06 09:26:06 EDT
(
hide
)
Description:
Patch with the fix.
Filename:
MIME Type:
Creator:
Raksha Vasisht
Created:
2009-07-06 09:26:06 EDT
Size:
12.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java,v >retrieving revision 1.12 >diff -u -r1.12 ProfileConfigurationBlock.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java 18 Mar 2009 11:06:47 -0000 1.12 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java 6 Jul 2009 13:19:26 -0000 >@@ -13,6 +13,7 @@ > import java.io.File; > import java.util.ArrayList; > import java.util.Collection; >+import java.util.Iterator; > import java.util.List; > import java.util.Observable; > import java.util.Observer; >@@ -32,6 +33,8 @@ > import org.eclipse.swt.widgets.Shell; > > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.core.runtime.preferences.DefaultScope; > import org.eclipse.core.runtime.preferences.IScopeContext; > import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; >@@ -58,6 +61,7 @@ > import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile; > import org.eclipse.jdt.internal.ui.util.ExceptionHandler; > import org.eclipse.jdt.internal.ui.util.SWTUtil; >+import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > > > public abstract class ProfileConfigurationBlock { >@@ -146,6 +150,7 @@ > fEditButton.addSelectionListener(this); > fDeleteButton.addSelectionListener(this); > fLoadButton.addSelectionListener(this); >+ fSaveAllButton.addSelectionListener(this); > update(fProfileManager, null); > } > >@@ -165,6 +170,45 @@ > newButtonPressed(); > else if (button == fLoadButton) > loadButtonPressed(); >+ else if(button == fSaveAllButton) >+ saveAllButtonPressed(); >+ } >+ >+ /** >+ * Exports all the profiles to a file. >+ * @since 3.6 >+ */ >+ private void saveAllButtonPressed() { >+ final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.SAVE); >+ dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profiles_dialog_title); >+ dialog.setFileName("formatterprofiles"); //$NON-NLS-1$ >+ 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(); >+ >+ 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_save_profiles_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 profiles= new ArrayList(); >+ profiles.addAll(fProfileManager.getSortedProfiles()); >+ try { >+ fProfileStore.writeProfilesToFile(profiles, file, encoding); >+ } catch (CoreException e) { >+ final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profiles_error_title; >+ final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message; >+ ExceptionHandler.handle(e, fComposite.getShell(), title, message); >+ } >+ > } > > public void widgetDefaultSelected(SelectionEvent e) { >@@ -218,29 +262,31 @@ > } > if (profiles == null || profiles.isEmpty()) > return; >+ for (Iterator iter=profiles.iterator(); iter.hasNext();) { >+ final CustomProfile profile= (CustomProfile)iter.next(); > >- final CustomProfile profile= (CustomProfile)profiles.iterator().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); >- return; >- } >+ 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; >- MessageDialog.openWarning(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; >+ MessageDialog.openWarning(fComposite.getShell(), title, message); >+ } > >- if (fProfileManager.containsName(profile.getName())) { >- final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager); >- if (aeDialog.open() != Window.OK) >- return; >+ if (fProfileManager.containsName(profile.getName())) { >+ final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager); >+ if (aeDialog.open() != Window.OK) >+ return; >+ } >+ fProfileVersioner.update(profile); >+ fProfileManager.addProfile(profile); > } >- fProfileVersioner.update(profile); >- fProfileManager.addProfile(profile); > } > } > >@@ -253,6 +299,7 @@ > private Button fDeleteButton; > private Button fNewButton; > private Button fLoadButton; >+ private Button fSaveAllButton; > > private PixelConverter fPixConv; > /** >@@ -365,6 +412,7 @@ > > fNewButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); > fLoadButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc, GridData.HORIZONTAL_ALIGN_END); >+ fSaveAllButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_save_all_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); > createLabel(fComposite, "", 3); //$NON-NLS-1$ > > configurePreview(fComposite, numColumns, fProfileManager); >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java,v >retrieving revision 1.25 >diff -u -r1.25 FormatterMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 8 Dec 2008 16:49:40 -0000 1.25 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 6 Jul 2009 13:19:25 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -448,6 +448,7 @@ > > public static String CodingStyleConfigurationBlock_save_profile_dialog_title; > public static String CodingStyleConfigurationBlock_save_profile_error_title; >+ public static String CodingStyleConfigurationBlock_save_profiles_error_title; > public static String CodingStyleConfigurationBlock_save_profile_error_message; > public static String CodingStyleConfigurationBlock_load_profile_dialog_title; > public static String CodingStyleConfigurationBlock_load_profile_error_title; >@@ -455,6 +456,7 @@ > public static String CodingStyleConfigurationBlock_load_profile_error_too_new_title; > public static String CodingStyleConfigurationBlock_load_profile_error_too_new_message; > public static String CodingStyleConfigurationBlock_save_profile_overwrite_title; >+ public static String CodingStyleConfigurationBlock_save_profiles_overwrite_title; > public static String CodingStyleConfigurationBlock_save_profile_overwrite_message; > public static String CodingStyleConfigurationBlock_edit_button_desc; > public static String CodingStyleConfigurationBlock_remove_button_desc; >@@ -464,8 +466,10 @@ > public static String CodingStyleConfigurationBlock_preview_label_text; > public static String CodingStyleConfigurationBlock_error_reading_xml_message; > public static String CodingStyleConfigurationBlock_error_serializing_xml_message; >+ public static String CodingStyleConfigurationBlock_save_all_button_desc; > public static String CodingStyleConfigurationBlock_delete_confirmation_title; > public static String CodingStyleConfigurationBlock_delete_confirmation_question; >+ public static String CodingStyleConfigurationBlock_save_profiles_dialog_title; > > public static String CreateProfileDialog_status_message_profile_with_this_name_already_exists; > public static String CreateProfileDialog_status_message_profile_name_is_empty; >Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties,v >retrieving revision 1.77 >diff -u -r1.77 FormatterMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 8 Dec 2008 16:49:40 -0000 1.77 >+++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 6 Jul 2009 13:19:26 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2008 IBM Corporation and others. >+# Copyright (c) 2000, 2009 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -507,6 +507,7 @@ > > CodingStyleConfigurationBlock_save_profile_dialog_title=Export Profile > CodingStyleConfigurationBlock_save_profile_error_title=Export Profile >+CodingStyleConfigurationBlock_save_profiles_error_title=Export Profiles > CodingStyleConfigurationBlock_save_profile_error_message=Could not export the profiles. > CodingStyleConfigurationBlock_load_profile_dialog_title=Import Profile > CodingStyleConfigurationBlock_load_profile_error_title=Import Profile >@@ -517,6 +518,7 @@ > default values and newer settings are ignored. Please note \ > that upgrading profiles from older to newer builds is fully supported. > CodingStyleConfigurationBlock_save_profile_overwrite_title=Export Profile >+CodingStyleConfigurationBlock_save_profiles_overwrite_title= Export Profiles > CodingStyleConfigurationBlock_save_profile_overwrite_message=The file ''{0}'' already exists.\nDo you want to replace it? > CodingStyleConfigurationBlock_edit_button_desc=&Edit... > CodingStyleConfigurationBlock_remove_button_desc=&Remove >@@ -526,8 +528,10 @@ > CodingStyleConfigurationBlock_preview_label_text=Prev&iew: > CodingStyleConfigurationBlock_error_reading_xml_message=Problems reading profiles from XML > CodingStyleConfigurationBlock_error_serializing_xml_message=Problems serializing the profiles to XML >+CodingStyleConfigurationBlock_save_all_button_desc=Expo&rt All... > CodingStyleConfigurationBlock_delete_confirmation_title=Confirm Remove > CodingStyleConfigurationBlock_delete_confirmation_question=Are you sure you want to remove profile ''{0}''? >+CodingStyleConfigurationBlock_save_profiles_dialog_title= Export Profiles > > CreateProfileDialog_status_message_profile_with_this_name_already_exists=A profile with this name already exists. > CreateProfileDialog_status_message_profile_name_is_empty=Profile name is empty
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review-
Actions:
View
|
Diff
Attachments on
bug 48966
:
140866
|
141296
|
142359