summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-03 15:23:43 (EDT)
committer pelder2007-05-03 15:23:43 (EDT)
commitadce6f8dbdb63b6325e925f0440176a9c9eeb10d (patch)
tree9b249b0cc22f7bdb4bb5e5168c3873abb1fb3f74
parentd12c3abf26fd7462a5d0589f361c3fa153010ecb (diff)
downloadorg.eclipse.jet-adce6f8dbdb63b6325e925f0440176a9c9eeb10d.zip
org.eclipse.jet-adce6f8dbdb63b6325e925f0440176a9c9eeb10d.tar.gz
org.eclipse.jet-adce6f8dbdb63b6325e925f0440176a9c9eeb10d.tar.bz2
Back out changes for 163256. More thought is needed on who this interacts with 'write-on-change'
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java105
1 files changed, 3 insertions, 102 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
index a9d184b..65b8234 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
@@ -34,20 +34,15 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jet.IWriterListener;
import org.eclipse.jet.JET2Writer;
-import org.eclipse.jet.internal.core.NewLineUtil;
import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.taglib.JET2TagException;
@@ -73,8 +68,6 @@ public final class ActionsUtil
*/
private final static byte[] BOM_UTF_8 = { (byte)0xEF, (byte)0xBB, (byte)0xBF };
- private static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
-
/**
*
*/
@@ -86,7 +79,7 @@ public final class ActionsUtil
/**
* Write the file with the specified options from a JET writer.
* <p>
- * This method delegates to {@link #writeTextFile(IFile, boolean, String, boolean, String, String, IProgressMonitor) writeTextFile}
+ * This method delegates to {@link #writeTextFile(IFile, boolean, String, boolean, String, IProgressMonitor) writeTextFile}
* after finalizing the writer's content and notifying writer listeners via {@link IWriterListener#finalizeContent(JET2Writer, Object)}.
* If the content is written, then the writer listeners are informed of this after the write via
* {@link IWriterListener#postCommitContent(JET2Writer, Object)}.
@@ -111,41 +104,9 @@ public final class ActionsUtil
JET2Writer writer,
IProgressMonitor monitor) throws JET2TagException
{
- return writeTextFileFromWriter(file, replace, encoding, derived, writer, getLineSeparator(file), monitor);
- }
-
- /**
- * Write the file with the specified options from a JET writer.
- * <p>
- * This method delegates to {@link #writeTextFile(IFile, boolean, String, boolean, String, String, IProgressMonitor) writeTextFile}
- * after finalizing the writer's content and notifying writer listeners via {@link IWriterListener#finalizeContent(JET2Writer, Object)}.
- * If the content is written, then the writer listeners are informed of this after the write via
- * {@link IWriterListener#postCommitContent(JET2Writer, Object)}.
- * </p>
- * @param file the file to write
- * @param replace <code>true</code> if existing verions of the file should be overwritten.
- * @param encoding the file encoding or <code>null</code> for the default encoding.
- * @param derived <code>true</code> if the file is derived (and will be ignored by the team environment.
- * @param writer the writer containing the file's content.
- * @param lineSeparator the line separator to use for the content or <code>null</code> for the system line separator
- * @param monitor a progress monitor
- * @return <code>true</code> if the file was written, <code>false</code> if <code>replace</code> is <code>true</code>
- * and the file already exists..
- * @throws JET2TagException if the file cannot be created or written, or the encoding is invalid.
- * @see IWriterListener#finalizeContent(JET2Writer, Object)
- * @see IWriterListener#postCommitContent(JET2Writer, Object)
- */
- public static boolean writeTextFileFromWriter(
- IFile file,
- boolean replace,
- String encoding,
- boolean derived,
- JET2Writer writer,
- String lineSeparator, IProgressMonitor monitor) throws JET2TagException
- {
finalizeContent(writer, file);
- boolean written = writeTextFile(file, replace, encoding, derived, writer.toString(), lineSeparator, monitor);
+ boolean written = writeTextFile(file, replace, encoding, derived, writer.toString(), monitor);
if (written)
{
@@ -192,29 +153,6 @@ public final class ActionsUtil
final String contents,
IProgressMonitor monitor) throws JET2TagException
{
- return writeTextFile(file, replace, encoding, derived, contents, getLineSeparator(file), monitor);
- }
-
- /**
- * Write the specified text file from a string.
- * @param file the file to write
- * @param replace <code>true</code> if existing verions of the file should be overwritten.
- * @param encoding the file encoding or <code>null</code> for the default encoding.
- * @param derived <code>true</code> if the file is derived (and will be ignored by the team environment.
- * @param contents the contents to write.
- * @param lineSeparator the line separator to use for the content or <code>null</code> for the system line separator
- * @param monitor a progress monitor
- * @return <code>false</code> <code>replace</code> was <code>true</code> and the file existed; <code>true</code> otherwise.
- * @throws JET2TagException if the file cannot be created or written, or the encoding is invalid.
- */
- public static boolean writeTextFile(
- IFile file,
- boolean replace,
- String encoding,
- boolean derived,
- final String contents,
- String lineSeparator, IProgressMonitor monitor) throws JET2TagException
- {
try
{
final String fileMessage = MessageFormat.format(
@@ -261,8 +199,7 @@ public final class ActionsUtil
}
// Step 3: convert the contents to a byte stream of the proper type
- String nlContents = NewLineUtil.setLineTerminator(contents, lineSeparator != null ? lineSeparator : getLineSeparator(file));
- InputStream source = new ByteArrayInputStream(nlContents.getBytes(file.getCharset()));
+ InputStream source = new ByteArrayInputStream(contents.getBytes(file.getCharset()));
// work around SUN bug with UTF-8 encoding and byte-order marks.
// See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
@@ -662,40 +599,4 @@ public final class ActionsUtil
}
}
-
- /**
- * Return the workspace defined default separator for this file.
- * @param file an existing IFile
- * @return Returns the new line separator.
- */
- private static String getLineSeparator(IFile file)
- {
- // check for the platform defined line separator for this file...
- String lineDelimiter = null;
- if (file != null && file.getProject() != null)
- {
- // try project preference
- lineDelimiter = Platform.getPreferencesService().getString(
- Platform.PI_RUNTIME,
- Platform.PREF_LINE_SEPARATOR,
- null,
- new IScopeContext []{ new ProjectScope(file.getProject()) });
- }
- if (lineDelimiter == null)
- {
- // try the workspace preference
- lineDelimiter = Platform.getPreferencesService().getString(
- Platform.PI_RUNTIME,
- Platform.PREF_LINE_SEPARATOR,
- null,
- new IScopeContext []{ new InstanceScope() });
- }
- if (lineDelimiter == null)
- {
- // fall back the the JRE default
- lineDelimiter = NL;
- }
- return lineDelimiter;
- }
-
}