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 185962 Details for
Bug 333420
[backport] Add UI for Bug 207510
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 v.0.1
patch333420.txt (text/plain), 10.01 KB, created by
Szymon Ptaszkiewicz
on 2011-01-03 10:37:12 EST
(
hide
)
Description:
Patch v.0.1
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2011-01-03 10:37:12 EST
Size:
10.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java,v >retrieving revision 1.25 >diff -u -r1.25 ResourceEncodingFieldEditor.java >--- src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java 23 Sep 2009 10:09:30 -0000 1.25 >+++ src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java 3 Jan 2011 15:33:29 -0000 >@@ -10,14 +10,19 @@ > *******************************************************************************/ > package org.eclipse.ui.ide.dialogs; > >+import org.eclipse.core.internal.resources.ProjectPreferences; > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ProjectScope; >+import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.content.IContentDescription; > import org.eclipse.core.runtime.jobs.Job; >@@ -27,6 +32,7 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; > import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Group; >@@ -36,6 +42,8 @@ > import org.eclipse.ui.ide.IDEEncoding; > import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; > import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; >+import org.osgi.service.prefs.BackingStoreException; >+import org.osgi.service.prefs.Preferences; > > /** > * The ResourceEncodingFieldEditor is a field editor for editing the encoding of >@@ -56,6 +64,8 @@ > > private Composite group; > >+ private Button separateDerivedEncodingsButton = null; >+ > /** > * Creates a new encoding field editor for setting the encoding on the given > * resource. >@@ -140,6 +150,36 @@ > > } > >+ private boolean getStoredSeparateDerivedEncodingsValue() { >+ // be careful looking up for our node so not to create any nodes as side effect >+ Preferences node = Platform.getPreferencesService().getRootNode() >+ .node(ProjectScope.SCOPE); >+ String projectName = ((IProject) resource).getName(); >+ try { >+ //TODO once bug 90500 is fixed, should be as simple as this: >+ // String path = projectName + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES; >+ // return node.nodeExists(path) ? node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false; >+ // for now, take the long way >+ if (!node.nodeExists(projectName)) >+ return false; >+ node = node.node(projectName); >+ if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES)) >+ return false; >+ node = node.node(ResourcesPlugin.PI_RESOURCES); >+ return node.getBoolean( >+ ProjectPreferences.PREF_SEPARATE_DERIVED_ENCODINGS, false); >+ } catch (BackingStoreException e) { >+ // default value >+ return false; >+ } >+ } >+ >+ private boolean hasSameSeparateDerivedEncodings() { >+ return (separateDerivedEncodingsButton == null) >+ || ((separateDerivedEncodingsButton != null) && (separateDerivedEncodingsButton >+ .getSelection() == getStoredSeparateDerivedEncodingsValue())); >+ } >+ > /* > * (non-Javadoc) > * >@@ -154,7 +194,9 @@ > encoding = null; > } > // Don't update if the same thing is selected >- if (hasSameEncoding(encoding)) { >+ final boolean hasSameEncoding = hasSameEncoding(encoding); >+ final boolean hasSameSeparateDerivedEncodings = hasSameSeparateDerivedEncodings(); >+ if (hasSameEncoding && hasSameSeparateDerivedEncodings) { > return; > } > >@@ -200,11 +242,22 @@ > */ > protected IStatus run(IProgressMonitor monitor) { > try { >- if (resource instanceof IContainer) { >- ((IContainer) resource).setDefaultCharset( >- finalEncoding, monitor); >- } else { >- ((IFile) resource).setCharset(finalEncoding, monitor); >+ if (!hasSameEncoding) { >+ if (resource instanceof IContainer) { >+ ((IContainer) resource).setDefaultCharset( >+ finalEncoding, monitor); >+ } else { >+ ((IFile) resource).setCharset(finalEncoding, >+ monitor); >+ } >+ } >+ if (!hasSameSeparateDerivedEncodings) { >+ Preferences prefs = new ProjectScope((IProject) resource).getNode(ResourcesPlugin.PI_RESOURCES); >+ if (getStoredSeparateDerivedEncodingsValue()) >+ prefs.remove(ProjectPreferences.PREF_SEPARATE_DERIVED_ENCODINGS); >+ else >+ prefs.putBoolean(ProjectPreferences.PREF_SEPARATE_DERIVED_ENCODINGS, true); >+ prefs.flush(); > } > return Status.OK_STATUS; > } catch (CoreException e) {// If there is an error return the >@@ -214,6 +267,9 @@ > IDEWorkbenchMessages.ResourceEncodingFieldEditor_ErrorStoringMessage, > e.getStatus()); > return e.getStatus(); >+ } catch (BackingStoreException e) { >+ IDEWorkbenchPlugin.log(IDEWorkbenchMessages.ResourceEncodingFieldEditor_ErrorStoringMessage, e); >+ return new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, e.getMessage(), e); > } > } > }; >@@ -237,8 +293,7 @@ > * > * @see org.eclipse.jface.preference.FieldEditor#load() > */ >- public void load() {// Override the load method as we are not using a >- // preference store >+ public void load() {// Override the load method as we are not using a preference store > setPresentsDefaultValue(false); > doLoad(); > } >@@ -248,12 +303,22 @@ > * > * @see org.eclipse.jface.preference.FieldEditor#loadDefault() > */ >- public void loadDefault() { >+ public void loadDefault() {// Override the loadDefault method as we are not using a preference store > setPresentsDefaultValue(true); > doLoadDefault(); > refreshValidState(); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault() >+ */ >+ protected void doLoadDefault() { >+ super.doLoadDefault(); >+ if (separateDerivedEncodingsButton != null) >+ separateDerivedEncodingsButton >+ .setSelection(getStoredSeparateDerivedEncodingsValue()); >+ } >+ > /* > * (non-Javadoc) > * >@@ -360,6 +425,17 @@ > label.setLayoutData(layoutData); > > } >+ >+ if (resource.getType() == IResource.PROJECT) { >+ separateDerivedEncodingsButton = new Button(group, SWT.CHECK); >+ GridData data = new GridData(); >+ data.horizontalSpan = 2; >+ separateDerivedEncodingsButton.setLayoutData(data); >+ separateDerivedEncodingsButton >+ .setText(IDEWorkbenchMessages.ResourceEncodingFieldEditor_SeparateDerivedEncodingsLabel); >+ separateDerivedEncodingsButton >+ .setSelection(getStoredSeparateDerivedEncodingsValue()); >+ } > return group; > } > >Index: src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java,v >retrieving revision 1.89 >diff -u -r1.89 IDEWorkbenchMessages.java >--- src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java 12 May 2010 13:26:39 -0000 1.89 >+++ src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java 3 Jan 2011 15:33:29 -0000 >@@ -893,6 +893,7 @@ > public static String ResourceEncodingFieldEditor_ErrorStoringMessage; > public static String ResourceEncodingFieldEditor_EncodingConflictTitle; > public static String ResourceEncodingFieldEditor_EncodingConflictMessage; >+ public static String ResourceEncodingFieldEditor_SeparateDerivedEncodingsLabel; > > public static String ChooseWorkspaceDialog_dialogName; > public static String ChooseWorkspaceDialog_dialogTitle; >Index: src/org/eclipse/ui/internal/ide/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties,v >retrieving revision 1.214 >diff -u -r1.214 messages.properties >--- src/org/eclipse/ui/internal/ide/messages.properties 18 May 2010 12:18:07 -0000 1.214 >+++ src/org/eclipse/ui/internal/ide/messages.properties 3 Jan 2011 15:33:30 -0000 >@@ -915,6 +915,7 @@ > ResourceEncodingFieldEditor_ErrorStoringMessage=Error storing encoding > ResourceEncodingFieldEditor_EncodingConflictTitle=Conflict in Encoding > ResourceEncodingFieldEditor_EncodingConflictMessage= {0} conflicts with the encoding defined in the content type ({1}). Do you wish to set it anyways? >+ResourceEncodingFieldEditor_SeparateDerivedEncodingsLabel=Save encoding of derived resources separately > > ChooseWorkspaceDialog_dialogName=Workspace Launcher > ChooseWorkspaceDialog_dialogTitle=Select a workspace >Index: src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java,v >retrieving revision 1.48 >diff -u -r1.48 ResourceInfoPage.java >--- src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java 10 May 2010 14:01:35 -0000 1.48 >+++ src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java 3 Jan 2011 15:33:30 -0000 >@@ -923,8 +923,6 @@ > if (resource == null) > return true; > >- encodingEditor.store(); >- > if (lineDelimiterEditor != null) { > lineDelimiterEditor.store(); > } >@@ -1005,6 +1003,10 @@ > IDEWorkbenchMessages.InternalError, exception > .getLocalizedMessage(), exception.getStatus()); > return false; >+ } finally { >+ // This must be invoked after the 'derived' property has been set, >+ // because it may influence the place where encoding is stored. >+ encodingEditor.store(); > } > return true; > }
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
Actions:
View
|
Diff
Attachments on
bug 333420
: 185962