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 90964 Details for
Bug 211380
Removing line delimiter preferences
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
211380.patch (text/plain), 33.11 KB, created by
Nitin Dahyabhai
on 2008-02-28 01:00:56 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Nitin Dahyabhai
Created:
2008-02-28 01:00:56 EST
Size:
33.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.ui >Index: src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java,v >retrieving revision 1.18 >diff -u -r1.18 NewXMLGenerator.java >--- src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java 25 Apr 2007 21:55:06 -0000 1.18 >+++ src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLGenerator.java 28 Feb 2008 05:49:48 -0000 >@@ -23,14 +23,18 @@ > import javax.xml.parsers.DocumentBuilderFactory; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ProjectScope; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; > import org.eclipse.core.runtime.content.IContentType; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.util.Assert; > import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver; > import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; > import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; > import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; >+import org.eclipse.wst.sse.core.utils.StringUtils; > import org.eclipse.wst.xml.core.internal.XMLCorePlugin; > import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry; > import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; >@@ -113,6 +117,14 @@ > > return cmDocument; > } >+ >+ private String applyLineDelimiter(IFile file, String text) { >+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope() });//$NON-NLS-1$ >+ String convertedText = StringUtils.replace(text, "\r\n", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\r", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter); >+ return convertedText; >+ } > > /** > * @deprecated use createTemplateXMLDocument(IFile, String) instead >@@ -129,6 +141,7 @@ > ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); > > PrintWriter writer = new PrintWriter(new OutputStreamWriter(outputStream, charSet)); >+ contents = applyLineDelimiter(newFile, contents); > writer.println(contents); > writer.flush(); > outputStream.close(); >@@ -164,7 +177,10 @@ > String charset = newFile.getCharset(); > ByteArrayOutputStream outputStream = createXMLDocument(xmlFileName, charset); > >- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); >+ String contents = outputStream.toString(charset); >+ contents = applyLineDelimiter(newFile, contents); >+ >+ ByteArrayInputStream inputStream = new ByteArrayInputStream(contents.getBytes(charset)); > newFile.setContents(inputStream, true, true, null); > inputStream.close(); > } >Index: src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java,v >retrieving revision 1.9 >diff -u -r1.9 XMLFilesPreferencePage.java >--- src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java 12 Dec 2006 06:09:32 -0000 1.9 >+++ src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java 28 Feb 2008 05:49:48 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2001, 2006 IBM Corporation and others. >+ * Copyright (c) 2001, 2008 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 >@@ -16,7 +16,6 @@ > import java.util.Arrays; > import java.util.Iterator; > import java.util.List; >-import java.util.Vector; > > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; >@@ -41,8 +40,6 @@ > public class XMLFilesPreferencePage extends AbstractPreferencePage { > protected EncodingSettings fEncodingSettings = null; > >- protected Combo fEndOfLineCode = null; >- private Vector fEOLCodes = null; > private Combo fDefaultSuffix = null; > private List fValidExtensions = null; > private Button fWarnNoGrammar = null; >@@ -50,7 +47,6 @@ > protected Control createContents(Composite parent) { > Composite composite = (Composite) super.createContents(parent); > PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID); >- createContentsForCreatingOrSavingGroup(composite); > createContentsForCreatingGroup(composite); > createContentsForValidatingGroup(composite); > >@@ -78,19 +74,6 @@ > ((GridData) fEncodingSettings.getLayoutData()).horizontalSpan = 2; > } > >- protected void createContentsForCreatingOrSavingGroup(Composite parent) { >- Group creatingOrSavingGroup = createGroup(parent, 2); >- creatingOrSavingGroup.setText(XMLUIMessages.Creating_or_saving_files); >- >- Label label = createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code_desc); >- ((GridData) label.getLayoutData()).horizontalSpan = 2; >- ((GridData) label.getLayoutData()).grabExcessHorizontalSpace = true; >- >- createLabel(creatingOrSavingGroup, XMLUIMessages.End_of_line_code); >- fEndOfLineCode = createDropDownBox(creatingOrSavingGroup); >- populateLineDelimiters(); >- } >- > protected void createContentsForValidatingGroup(Composite parent) { > Group validatingGroup = createGroup(parent, 2); > validatingGroup.setText(XMLUIMessages.Validating_files); >@@ -131,19 +114,6 @@ > return fValidExtensions; > } > >- /** >- * Return the currently selected line delimiter preference >- * >- * @return a line delimiter constant from CommonEncodingPreferenceNames >- */ >- private String getCurrentEOLCode() { >- int i = fEndOfLineCode.getSelectionIndex(); >- if (i >= 0) { >- return (String) (fEOLCodes.elementAt(i)); >- } >- return ""; //$NON-NLS-1$ >- } >- > /* > * (non-Javadoc) > * >@@ -154,7 +124,6 @@ > } > > protected void initializeValues() { >- initializeValuesForCreatingOrSavingGroup(); > initializeValuesForCreatingGroup(); > initializeValuesForValidatingGroup(); > } >@@ -168,17 +137,6 @@ > fEncodingSettings.setIANATag(encoding); > } > >- protected void initializeValuesForCreatingOrSavingGroup() { >- String endOfLineCode = getModelPreferences().getString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); >- >- if (endOfLineCode.length() > 0) { >- setCurrentEOLCode(endOfLineCode); >- } >- else { >- setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); >- } >- } >- > protected void initializeValuesForValidatingGroup() { > boolean warnNoGrammarButtonSelected = getModelPreferences().getBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); > >@@ -189,7 +147,6 @@ > } > > protected void performDefaults() { >- performDefaultsForCreatingOrSavingGroup(); > performDefaultsForCreatingGroup(); > performDefaultsForValidatingGroup(); > >@@ -206,17 +163,6 @@ > // fEncodingSettings.resetToDefaultEncoding(); > } > >- protected void performDefaultsForCreatingOrSavingGroup() { >- String endOfLineCode = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.END_OF_LINE_CODE); >- >- if (endOfLineCode.length() > 0) { >- setCurrentEOLCode(endOfLineCode); >- } >- else { >- setCurrentEOLCode(CommonEncodingPreferenceNames.NO_TRANSLATION); >- } >- } >- > protected void performDefaultsForValidatingGroup() { > boolean warnNoGrammarButtonSelected = getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.WARN_NO_GRAMMAR); > >@@ -233,42 +179,7 @@ > return result; > } > >- /** >- * Populates the vector containing the line delimiter to display string >- * mapping and the combobox displaying line delimiters >- */ >- private void populateLineDelimiters() { >- fEOLCodes = new Vector(); >- fEndOfLineCode.add(XMLUIMessages.EOL_Unix); >- fEOLCodes.add(CommonEncodingPreferenceNames.LF); >- >- fEndOfLineCode.add(XMLUIMessages.EOL_Mac); >- fEOLCodes.add(CommonEncodingPreferenceNames.CR); >- >- fEndOfLineCode.add(XMLUIMessages.EOL_Windows); >- fEOLCodes.add(CommonEncodingPreferenceNames.CRLF); >- >- fEndOfLineCode.add(XMLUIMessages.EOL_NoTranslation); >- fEOLCodes.add(CommonEncodingPreferenceNames.NO_TRANSLATION); >- } >- >- /** >- * Select the line delimiter in the eol combobox >- * >- */ >- private void setCurrentEOLCode(String eolCode) { >- // Clear the current selection. >- fEndOfLineCode.clearSelection(); >- fEndOfLineCode.deselectAll(); >- >- int i = fEOLCodes.indexOf(eolCode); >- if (i >= 0) { >- fEndOfLineCode.select(i); >- } >- } >- > protected void storeValues() { >- storeValuesForCreatingOrSavingGroup(); > storeValuesForCreatingGroup(); > storeValuesForValidatingGroup(); > } >@@ -280,11 +191,6 @@ > getModelPreferences().setValue(CommonEncodingPreferenceNames.OUTPUT_CODESET, fEncodingSettings.getIANATag()); > } > >- protected void storeValuesForCreatingOrSavingGroup() { >- String eolCode = getCurrentEOLCode(); >- getModelPreferences().setValue(CommonEncodingPreferenceNames.END_OF_LINE_CODE, eolCode); >- } >- > protected void storeValuesForValidatingGroup() { > if (fWarnNoGrammar != null) { > boolean warnNoGrammarButtonSelected = fWarnNoGrammar.getSelection(); >#P org.eclipse.wst.html.ui >Index: src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java,v >retrieving revision 1.9 >diff -u -r1.9 NewHTMLWizard.java >--- src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java 1 Jun 2006 21:21:54 -0000 1.9 >+++ src/org/eclipse/wst/html/ui/internal/wizard/NewHTMLWizard.java 28 Feb 2008 05:49:48 -0000 >@@ -15,7 +15,11 @@ > import java.io.OutputStreamWriter; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ProjectScope; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >@@ -32,6 +36,7 @@ > import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImageHelper; > import org.eclipse.wst.html.ui.internal.editor.HTMLEditorPluginImages; > import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; >+import org.eclipse.wst.sse.core.utils.StringUtils; > > public class NewHTMLWizard extends Wizard implements INewWizard { > >@@ -48,6 +53,14 @@ > fNewFileTemplatesPage = new NewHTMLTemplatesWizardPage(); > addPage(fNewFileTemplatesPage); > } >+ >+ private String applyLineDelimiter(IFile file, String text) { >+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope() });//$NON-NLS-1$ >+ String convertedText = StringUtils.replace(text, "\r\n", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\r", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter); >+ return convertedText; >+ } > > public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) { > fSelection = aSelection; >@@ -94,6 +107,7 @@ > // put template contents into file > String templateString = fNewFileTemplatesPage.getTemplateString(); > if (templateString != null) { >+ templateString = applyLineDelimiter(file, templateString); > // determine the encoding for the new file > Preferences preference = HTMLCorePlugin.getDefault().getPluginPreferences(); > String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); >Index: src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java,v >retrieving revision 1.9 >diff -u -r1.9 HTMLFilesPreferencePage.java >--- src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java 10 Apr 2007 18:30:16 -0000 1.9 >+++ src/org/eclipse/wst/html/ui/internal/preferences/ui/HTMLFilesPreferencePage.java 28 Feb 2008 05:49:48 -0000 >@@ -54,7 +54,6 @@ > */ > protected Control createContents(Composite parent) { > Composite scrolledComposite = createScrolledComposite(parent); >- createContentsForCreatingOrSavingGroup(scrolledComposite); > createContentsForCreatingGroup(scrolledComposite); > createContentsForLoadingGroup(scrolledComposite); > >#P org.eclipse.wst.dtd.ui >Index: src/org/eclipse/wst/dtd/ui/internal/wizard/NewDTDWizard.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.dtd.ui/src/org/eclipse/wst/dtd/ui/internal/wizard/NewDTDWizard.java,v >retrieving revision 1.12 >diff -u -r1.12 NewDTDWizard.java >--- src/org/eclipse/wst/dtd/ui/internal/wizard/NewDTDWizard.java 7 Mar 2006 21:00:59 -0000 1.12 >+++ src/org/eclipse/wst/dtd/ui/internal/wizard/NewDTDWizard.java 28 Feb 2008 05:49:49 -0000 >@@ -21,12 +21,15 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ProjectScope; > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; > import org.eclipse.core.runtime.content.IContentType; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >@@ -47,6 +50,7 @@ > import org.eclipse.wst.dtd.ui.internal.editor.DTDEditorPluginImageHelper; > import org.eclipse.wst.dtd.ui.internal.editor.DTDEditorPluginImages; > import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; >+import org.eclipse.wst.sse.core.utils.StringUtils; > > public class NewDTDWizard extends Wizard implements INewWizard { > private WizardNewFileCreationPage fNewFilePage; >@@ -97,6 +101,14 @@ > return fValidExtensions; > } > >+ private String applyLineDelimiter(IFile file, String text) { >+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope() });//$NON-NLS-1$ >+ String convertedText = StringUtils.replace(text, "\r\n", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\r", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter); >+ return convertedText; >+ } >+ > /** > * Verifies if fileName is valid name for content type. Takes base content > * type into consideration. >@@ -213,6 +225,7 @@ > // put template contents into file > String templateString = fNewFileTemplatesPage.getTemplateString(); > if (templateString != null) { >+ templateString = applyLineDelimiter(file, templateString); > // determine the encoding for the new file > Preferences preference = DTDCorePlugin.getInstance().getPluginPreferences(); > String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); >#P org.eclipse.jst.jsp.ui >Index: src/org/eclipse/jst/jsp/ui/internal/wizard/NewJSPWizard.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/wizard/NewJSPWizard.java,v >retrieving revision 1.9 >diff -u -r1.9 NewJSPWizard.java >--- src/org/eclipse/jst/jsp/ui/internal/wizard/NewJSPWizard.java 1 Jun 2006 21:22:40 -0000 1.9 >+++ src/org/eclipse/jst/jsp/ui/internal/wizard/NewJSPWizard.java 28 Feb 2008 05:49:50 -0000 >@@ -15,7 +15,11 @@ > import java.io.OutputStreamWriter; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ProjectScope; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >@@ -32,6 +36,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.ide.IDE; > import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; >+import org.eclipse.wst.sse.core.utils.StringUtils; > > public class NewJSPWizard extends Wizard implements INewWizard { > private NewJSPFileWizardPage fNewFilePage; >@@ -48,6 +53,14 @@ > addPage(fNewFileTemplatesPage); > } > >+ private String applyLineDelimiter(IFile file, String text) { >+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope() });//$NON-NLS-1$ >+ String convertedText = StringUtils.replace(text, "\r\n", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\r", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter); >+ return convertedText; >+ } >+ > public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) { > fSelection = aSelection; > setWindowTitle(JSPUIMessages._UI_WIZARD_NEW_TITLE); >@@ -94,6 +107,7 @@ > // put template contents into file > String templateString = fNewFileTemplatesPage.getTemplateString(); > if (templateString != null) { >+ templateString = applyLineDelimiter(file, templateString); > // determine the encoding for the new file > Preferences preference = JSPCorePlugin.getDefault().getPluginPreferences(); > String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); >#P org.eclipse.wst.css.ui >Index: src/org/eclipse/wst/css/ui/internal/preferences/ui/CSSFilesPreferencePage.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/preferences/ui/CSSFilesPreferencePage.java,v >retrieving revision 1.7 >diff -u -r1.7 CSSFilesPreferencePage.java >--- src/org/eclipse/wst/css/ui/internal/preferences/ui/CSSFilesPreferencePage.java 10 Apr 2007 18:31:10 -0000 1.7 >+++ src/org/eclipse/wst/css/ui/internal/preferences/ui/CSSFilesPreferencePage.java 28 Feb 2008 05:49:50 -0000 >@@ -38,7 +38,6 @@ > > protected Control createContents(Composite parent) { > Composite scrolledComposite = createScrolledComposite(parent); >- createContentsForCreatingOrSavingGroup(scrolledComposite); > createContentsForCreatingGroup(scrolledComposite); > > PlatformUI.getWorkbench().getHelpSystem().setHelp(scrolledComposite, IHelpContextIds.CSS_PREFWEBX_FILES_HELPID); >@@ -53,19 +52,16 @@ > } > > protected void initializeValues() { >- initializeValuesForCreatingOrSavingGroup(); > initializeValuesForCreatingGroup(); > } > > protected void performDefaults() { >- performDefaultsForCreatingOrSavingGroup(); > performDefaultsForCreatingGroup(); > > updateApplyButton(); > } > > protected void storeValues() { >- storeValuesForCreatingOrSavingGroup(); > storeValuesForCreatingGroup(); > } > } >Index: src/org/eclipse/wst/css/ui/internal/wizard/NewCSSWizard.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/internal/wizard/NewCSSWizard.java,v >retrieving revision 1.9 >diff -u -r1.9 NewCSSWizard.java >--- src/org/eclipse/wst/css/ui/internal/wizard/NewCSSWizard.java 1 Jun 2006 21:22:28 -0000 1.9 >+++ src/org/eclipse/wst/css/ui/internal/wizard/NewCSSWizard.java 28 Feb 2008 05:49:50 -0000 >@@ -16,7 +16,11 @@ > import java.io.OutputStreamWriter; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ProjectScope; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Preferences; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; >@@ -33,6 +37,7 @@ > import org.eclipse.wst.css.ui.internal.editor.CSSEditorPluginImages; > import org.eclipse.wst.css.ui.internal.image.CSSImageHelper; > import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; >+import org.eclipse.wst.sse.core.utils.StringUtils; > > public class NewCSSWizard extends Wizard implements INewWizard { > private NewCSSFileWizardPage fNewFilePage; >@@ -49,6 +54,14 @@ > addPage(fNewFileTemplatesPage); > } > >+ private String applyLineDelimiter(IFile file, String text) { >+ String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] {new ProjectScope(file.getProject()), new InstanceScope() });//$NON-NLS-1$ >+ String convertedText = StringUtils.replace(text, "\r\n", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\r", "\n"); >+ convertedText = StringUtils.replace(convertedText, "\n", lineDelimiter); >+ return convertedText; >+ } >+ > public void init(IWorkbench aWorkbench, IStructuredSelection aSelection) { > fSelection = aSelection; > setWindowTitle(CSSUIMessages._UI_WIZARD_NEW_TITLE); //$NON-NLS-1$ >@@ -94,6 +107,7 @@ > // put template contents into file > String templateString = fNewFileTemplatesPage.getTemplateString(); > if (templateString != null) { >+ templateString = applyLineDelimiter(file, templateString); > // determine the encoding for the new file > Preferences preference = CSSCorePlugin.getDefault().getPluginPreferences(); > String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); >#P org.eclipse.wst.sse.core >Index: src-encoding/org/eclipse/wst/sse/core/internal/encoding/CommonEncodingPreferenceNames.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.core/src-encoding/org/eclipse/wst/sse/core/internal/encoding/CommonEncodingPreferenceNames.java,v >retrieving revision 1.3 >diff -u -r1.3 CommonEncodingPreferenceNames.java >--- src-encoding/org/eclipse/wst/sse/core/internal/encoding/CommonEncodingPreferenceNames.java 10 Apr 2007 20:07:24 -0000 1.3 >+++ src-encoding/org/eclipse/wst/sse/core/internal/encoding/CommonEncodingPreferenceNames.java 28 Feb 2008 05:49:51 -0000 >@@ -23,14 +23,17 @@ > > /** > * Constant to be used when referring to CR/MAC line delimiter >+ * @deprecated - no longer used > */ > public static final String CR = "EOL_Mac"; //$NON-NLS-1$ > /** > * Constant to be used when referring to CRLF/WINDOWS line delimiter >+ * @deprecated - no longer used > */ > public static final String CRLF = "EOL_Windows"; //$NON-NLS-1$ > /** > * The end-of-line character(s) to use. >+ * @deprecated - no longer used > */ > public static final String END_OF_LINE_CODE = "endOfLineCode";//$NON-NLS-1$ > /** >@@ -40,10 +43,12 @@ > > /** > * Constant to be used when referring to LF/UNIX line delimiter >+ * @deprecated - no longer used > */ > public static final String LF = "EOL_Unix"; //$NON-NLS-1$ > /** > * Constant to be used when referring to No translation of line delimiters >+ * @deprecated - no longer used > */ > public static final String NO_TRANSLATION = ""; //$NON-NLS-1$ > /** >@@ -53,16 +58,19 @@ > > /** > * String representation of CR/MAC line delimiter >+ * @deprecated - no longer used > */ > public static final String STRING_CR = "\r";//$NON-NLS-1$ > > /** > * String representation of CRLF/WINDOWS line delimiter >+ * @deprecated - no longer used > */ > public static final String STRING_CRLF = "\r\n";//$NON-NLS-1$ > > /** > * String representation of LF/UNIX line delimiter >+ * @deprecated - no longer used > */ > public static final String STRING_LF = "\n";//$NON-NLS-1$ > >Index: src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java,v >retrieving revision 1.41 >diff -u -r1.41 BasicStructuredDocument.java >--- src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java 4 Dec 2007 17:40:00 -0000 1.41 >+++ src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java 28 Feb 2008 05:49:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2001, 2007 IBM Corporation and others. >+ * Copyright (c) 2001, 2008 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 >@@ -22,6 +22,8 @@ > import java.util.Map; > > import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.BadPartitioningException; > import org.eclipse.jface.text.BadPositionCategoryException; >@@ -299,17 +301,11 @@ > private byte[] listenerLock = new byte[0]; > private NullDocumentEvent NULL_DOCUMENT_EVENT; > >- // > /** >- * in case preferred delimiter is not set, we'll assume the platform >- * default Note: it is not final static to make sure it won't be inlined >- * by compiler. >+ * Theoretically, a document can contain mixed line delimiters, but the >+ * user's preference is usually to be internally consistent. > */ >- private final String PlatformLineDelimiter = System.getProperty("line.separator"); //$NON-NLS-1$ >- /** >- * theoretically, a document can contain mixed line delimiters >- */ >- private String preferedDelimiter; >+ private String fInitialLineDelimiter; > private final String READ_ONLY_REGIONS_CATEGORY = "_READ_ONLY_REGIONS_CATEGORY_"; //$NON-NLS-1$ > /** > * Current rewrite session, or none if not presently rewriting. >@@ -1320,28 +1316,35 @@ > * @see org.eclipse.jface.text.IDocumentExtension4#getDefaultLineDelimiter() > */ > public String getDefaultLineDelimiter() { >- // specific preferred line delimiter >- if (preferedDelimiter != null) >- return preferedDelimiter; >+ >+ String lineDelimiter= null; >+ >+ try { >+ lineDelimiter= getLineDelimiter(0); >+ } catch (BadLocationException x) { >+ } >+ >+ if (lineDelimiter != null) >+ return lineDelimiter; > >+ if (fInitialLineDelimiter != null) >+ return fInitialLineDelimiter; > >- // no line delimiter has been used so just use platform's default >- String lineDelimiter = null; >- String sysLineDelimiter = PlatformLineDelimiter; >- String[] delimiters = getLegalLineDelimiters(); >+ String sysLineDelimiter= System.getProperty("line.separator"); //$NON-NLS-1$ >+ String[] delimiters= getLegalLineDelimiters(); > Assert.isTrue(delimiters.length > 0); >- for (int i = 0; i < delimiters.length; i++) { >+ for (int i= 0; i < delimiters.length; i++) { > if (delimiters[i].equals(sysLineDelimiter)) { >- lineDelimiter = sysLineDelimiter; >+ lineDelimiter= sysLineDelimiter; > break; > } > } >- >- // no platform default so just use first legal delimiter >+ > if (lineDelimiter == null) >- lineDelimiter = delimiters[0]; >- >+ lineDelimiter= delimiters[0]; >+ > return lineDelimiter; >+ > } > > /** >@@ -2530,16 +2533,16 @@ > * > * @see org.eclipse.jface.text.IDocumentExtension4#setInitialLineDelimiter(java.lang.String) > */ >- public void setInitialLineDelimiter(String delimiter) { >+ public void setInitialLineDelimiter(String lineDelimiter) { > // make sure our preferred delimiter is > // one of the legal ones >- if (Utilities.containsString(getLegalLineDelimiters(), delimiter)) { >- preferedDelimiter = delimiter; >+ if (Utilities.containsString(getLegalLineDelimiters(), lineDelimiter)) { >+ fInitialLineDelimiter= lineDelimiter; > } > else { > if (Logger.DEBUG_DOCUMENT) > Logger.log(Logger.INFO, "Attempt to set linedelimiter to non-legal delimiter"); //$NON-NLS-1$ //$NON-NLS-2$ >- preferedDelimiter = PlatformLineDelimiter; >+ fInitialLineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, System.getProperty("line.separator"), new IScopeContext[] { new InstanceScope() });//$NON-NLS-1$ > } > } > >Index: src/org/eclipse/wst/sse/core/internal/cleanup/AbstractStructuredCleanupProcessor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/cleanup/AbstractStructuredCleanupProcessor.java,v >retrieving revision 1.7 >diff -u -r1.7 AbstractStructuredCleanupProcessor.java >--- src/org/eclipse/wst/sse/core/internal/cleanup/AbstractStructuredCleanupProcessor.java 16 Oct 2007 19:16:45 -0000 1.7 >+++ src/org/eclipse/wst/sse/core/internal/cleanup/AbstractStructuredCleanupProcessor.java 28 Feb 2008 05:49:51 -0000 >@@ -22,6 +22,9 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.preferences.IScopeContext; >+import org.eclipse.core.runtime.preferences.InstanceScope; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.DocumentRewriteSession; > import org.eclipse.jface.text.DocumentRewriteSessionType; >@@ -31,10 +34,8 @@ > import org.eclipse.jface.text.TextUtilities; > import org.eclipse.wst.sse.core.StructuredModelManager; > import org.eclipse.wst.sse.core.internal.Logger; >-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; > import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; > import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; > import org.w3c.dom.Attr; > import org.w3c.dom.Node; > >@@ -300,30 +301,6 @@ > IStructuredFormatProcessor formatProcessor = getFormatProcessor(); > formatProcessor.formatModel(structuredModel); > } >- >- // convert EOL codes >- if (getConvertEOLCodesPreference(structuredModel)) { >- IDocument document = structuredModel.getStructuredDocument(); >- String endOfLineCode = getEOLCodePreference(structuredModel); >- String endOfLineCodeString = null; >- if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.LF) == 0) >- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_LF; >- else if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.CR) == 0) >- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_CR; >- else if (endOfLineCode.compareTo(CommonEncodingPreferenceNames.CRLF) == 0) >- endOfLineCodeString = CommonEncodingPreferenceNames.STRING_CRLF; >- if (endOfLineCodeString != null) { >- convertLineDelimiters(document, endOfLineCodeString); >- // DMW: 8/24/2002 setting line delimiter in >- // document allows >- // subsequent editing to insert the same line >- // delimiter. >- if (document instanceof IStructuredDocument) { >- ((IStructuredDocument) document).setLineDelimiter(endOfLineCodeString); >- } >- structuredModel.setDirtyState(true); >- } >- } > } > finally { > // we need two finally's, just in case first fails >@@ -444,7 +421,8 @@ > > protected String getEOLCodePreference(IStructuredModel structuredModel) { > >- String eolCode = System.getProperty("line.separator"); //$NON-NLS-1$ >+ IScopeContext[] scopeContext = new IScopeContext[]{new InstanceScope()}; >+ String eolCode = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext); > > IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0)); > if (cleanupHandler != null) {
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 211380
:
90963
| 90964 |
90965