Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.core.filebuffers')
-rw-r--r--org.eclipse.core.filebuffers/.classpath7
-rw-r--r--org.eclipse.core.filebuffers/.cvsignore1
-rw-r--r--org.eclipse.core.filebuffers/.project31
-rw-r--r--org.eclipse.core.filebuffers/about.html30
-rw-r--r--org.eclipse.core.filebuffers/build.properties17
-rw-r--r--org.eclipse.core.filebuffers/hglegal2003.htm14
-rw-r--r--org.eclipse.core.filebuffers/ngibmcpy2003.gifbin1101 -> 0 bytes
-rw-r--r--org.eclipse.core.filebuffers/plugin.properties16
-rw-r--r--org.eclipse.core.filebuffers/plugin.xml36
-rw-r--r--org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd136
-rw-r--r--org.eclipse.core.filebuffers/schema/documentCreation.exsd143
-rw-r--r--org.eclipse.core.filebuffers/schema/documentSetup.exsd143
-rw-r--r--org.eclipse.core.filebuffers/scripts/exportplugin.xml28
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java114
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java38
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java33
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java41
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java137
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java98
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java139
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java57
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java40
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java56
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java73
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/package.html17
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java36
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java130
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java32
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java557
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.java82
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties29
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java96
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java217
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java436
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java426
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java523
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java315
37 files changed, 0 insertions, 4324 deletions
diff --git a/org.eclipse.core.filebuffers/.classpath b/org.eclipse.core.filebuffers/.classpath
deleted file mode 100644
index 065ac06e197..00000000000
--- a/org.eclipse.core.filebuffers/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.core.filebuffers/.cvsignore b/org.eclipse.core.filebuffers/.cvsignore
deleted file mode 100644
index c5e82d74585..00000000000
--- a/org.eclipse.core.filebuffers/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/org.eclipse.core.filebuffers/.project b/org.eclipse.core.filebuffers/.project
deleted file mode 100644
index ac71d98c0f7..00000000000
--- a/org.eclipse.core.filebuffers/.project
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.core.filebuffers</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.resources</project>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.text</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.core.filebuffers/about.html b/org.eclipse.core.filebuffers/about.html
deleted file mode 100644
index 9db411aab99..00000000000
--- a/org.eclipse.core.filebuffers/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
-other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.core.filebuffers/build.properties b/org.eclipse.core.filebuffers/build.properties
deleted file mode 100644
index a1cc6f2a06a..00000000000
--- a/org.eclipse.core.filebuffers/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-bin.includes = plugin.properties,\
- plugin.xml,\
- *.jar,\
- about.html
-src.includes = about.html,\
- schema/
-source.filebuffers.jar = src/
diff --git a/org.eclipse.core.filebuffers/hglegal2003.htm b/org.eclipse.core.filebuffers/hglegal2003.htm
deleted file mode 100644
index 47c8540c84c..00000000000
--- a/org.eclipse.core.filebuffers/hglegal2003.htm
+++ /dev/null
@@ -1,14 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <LINK REL="stylesheet" HREF="book.css" CHARSET="ISO-8859-1" TYPE="text/css">
- <title>Legal Notices</title>
-</head>
-<body>
-
-<h3>
-<a NAME="Notices"></a>Notices</h3>
-(c) Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.
-</body>
-</html>
diff --git a/org.eclipse.core.filebuffers/ngibmcpy2003.gif b/org.eclipse.core.filebuffers/ngibmcpy2003.gif
deleted file mode 100644
index c786e43e1f9..00000000000
--- a/org.eclipse.core.filebuffers/ngibmcpy2003.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.core.filebuffers/plugin.properties b/org.eclipse.core.filebuffers/plugin.properties
deleted file mode 100644
index 69a845b81ad..00000000000
--- a/org.eclipse.core.filebuffers/plugin.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-pluginName= File Buffers
-providerName= Eclipse.org
-documentCreationPoint= Document Creation
-documentSetupPoint= Document Setup
-annotationModelCreationPoint= Annotation Model Creation
-defaultDocumentFactory= Default Document Factory
diff --git a/org.eclipse.core.filebuffers/plugin.xml b/org.eclipse.core.filebuffers/plugin.xml
deleted file mode 100644
index e7677fa0559..00000000000
--- a/org.eclipse.core.filebuffers/plugin.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.core.filebuffers"
- name="%pluginName"
- version="3.0.0"
- provider-name="%providerName"
- class="org.eclipse.core.internal.filebuffers.FileBuffersPlugin">
-
- <runtime>
- <library name="filebuffers.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.text"/>
- </requires>
-
-
- <extension-point id="documentCreation" name="%documentCreationPoint" schema="schema/documentCreation.exsd"/>
- <extension-point id="documentSetup" name="%documentSetupPoint" schema="schema/documentSetup.exsd"/>
- <extension-point id="annotationModelCreation" name="%annotationModelCreationPoint" schema="schema/annotationModelCreation.exsd"/>
-
- <extension
- id="DefaultDocumentFactory"
- name="%defaultDocumentFactory"
- point="org.eclipse.core.filebuffers.documentCreation">
- <factory
- extensions="*"
- class="org.eclipse.core.internal.filebuffers.DefaultDocumentFactory">
- </factory>
- </extension>
-
-</plugin>
diff --git a/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd b/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd
deleted file mode 100644
index aae20f4746b..00000000000
--- a/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.core.filebuffers">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.core.filebuffers" id="annotationModelCreation" name="Annotation Model Creation"/>
- </appInfo>
- <documentation>
- This extension point is used to customize the annotation model creation behavior of this plug-in&apos;s default text file buffer manager. It allows to specify which annotation model factory should be used in order to create the annotation model instance of a text file buffer created for a certain file content type, file extension, or file name.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factory"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <annotation>
- <documentation>
- The specification of a annotation model factory. In order to find a factory for a given file the attributes of each factory specification are consulted in the following sequence: contentTypeId, fileNames, extensions. If multiple, equally specific factory specifications are found for a given file it is not specified which factory is used.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified name of the factory implementation class. This class must implement the org.eclipse.core.filebuffers.IAnnotationModelFactory interface.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.core.filebuffers.IAnnotationModelFactory"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string">
- <annotation>
- <documentation>
- A comma separated list of file extensions for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="fileNames" type="string">
- <annotation>
- <documentation>
- A comma separated list of file names for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="contentTypeId" type="string">
- <annotation>
- <documentation>
- The id of a content type as defined by the org.eclipse.core.runtime.contentTypes extension point for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;pre&gt;
- &lt;extension
- point=&quot;org.eclipse.core.filebuffers.annotationModelCreation&quot;&gt;
- &lt;factory
- extensions=&quot;xzy&quot;
- class=&quot;org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFactory&quot;&gt;
- &lt;/factory&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Annotation model factories have to implement org.eclipse.core.filebuffers.IAnnotationModelFactory.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.core.filebuffers/schema/documentCreation.exsd b/org.eclipse.core.filebuffers/schema/documentCreation.exsd
deleted file mode 100644
index 2bdca3617f5..00000000000
--- a/org.eclipse.core.filebuffers/schema/documentCreation.exsd
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.core.filebuffers">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.core.filebuffers" id="documentCreation" name="Document Creation"/>
- </appInfo>
- <documentation>
- This extension point is used to customize the document creation behavior of this plug-in&apos;s default text file buffer manager. It allows to specify which document factory should be used in order to create the document instance of a text file buffer created for a certain file content type, file extension, or file name.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="factory"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="factory">
- <annotation>
- <documentation>
- The specification of a document factory. In order to find a factory for a given file the attributes of each factory specification are consulted in the following sequence: contentTypeId, fileNames, extensions. If multiple, equally specific factory specifications are found for a given file it is not specified which factory is used.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified name of the factory implementation class. This class must implement the org.eclipse.core.filebuffers.IDocumentFactory interface.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.core.filebuffers.IDocumentFactory"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string">
- <annotation>
- <documentation>
- A comma separated list of file extensions for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="fileNames" type="string">
- <annotation>
- <documentation>
- A comma separated list of file names for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="contentTypeId" type="string">
- <annotation>
- <documentation>
- The id of a content type as defined by the org.eclipse.core.runtime.contentTypes extension point for which this factory should be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;pre&gt;
-&lt;extension
- id=&quot;org.eclipse.jdt.debug.ui.SnippetDocumentFactory&quot;
- name=&quot;%snippetDocumentFactory.name&quot;
- point=&quot;org.eclipse.core.filebuffers.documentCreation&quot;&gt;
- &lt;factory
- extensions=&quot;jpage&quot;
- class=&quot;org.eclipse.jdt.internal.debug.ui.snippeteditor.SnippetDocumentFactory&quot;&gt;
- &lt;/factory&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Document factories have to implement org.eclipse.core.filebuffers.IDocumentFactory.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- &lt;p&gt;
-&lt;a href=&quot;hglegal.htm&quot;&gt;
- &lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
- BORDER=&quot;0&quot; height=&quot;14&quot; width=&quot;324&quot;&gt;&lt;/a&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.core.filebuffers/schema/documentSetup.exsd b/org.eclipse.core.filebuffers/schema/documentSetup.exsd
deleted file mode 100644
index c15fc1b2eb0..00000000000
--- a/org.eclipse.core.filebuffers/schema/documentSetup.exsd
+++ /dev/null
@@ -1,143 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.core.filebuffers">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.core.filebuffers" id="documentSetup" name="Document Setup"/>
- </appInfo>
- <documentation>
- This extension point is used to customize the initialization process of a document for a text file buffer manager by this plug-in&apos;s default text file buffer manager. It allows to specify which document setup participant should be involved in the initialization process for a text file buffer created for a certain file content type, file extension, or file name.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="participant"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="participant">
- <annotation>
- <documentation>
- The specification of a document setup participant. In order find all participants for a given file the attributes of each participant specification are consulted in the following sequence: contentTypeId, fileNames, extensions. If multiple participants are found, the sequence in which they are called is not specified.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified name of the participant implementation class. This class must implement the org.eclipse.core.filebuffers.IDocumentSetupParticipant interface.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.core.filebuffers.IDocumentSetupParticipant"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string">
- <annotation>
- <documentation>
- A comma separated list of file extensions for which this participant should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="fileNames" type="string">
- <annotation>
- <documentation>
- A comma separated list of file names for which this participant should be used.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="contentTypeId" type="string">
- <annotation>
- <documentation>
- The id of a content type as defined by the org.eclipse.core.runtime.contentTypes extension point for which this participant should be used.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;pre&gt;
- &lt;extension
- id=&quot;JavaDocumentSetupParticipant&quot;
- name=&quot;%javaDocumentSetupParticipant&quot;
- point=&quot;org.eclipse.core.filebuffers.documentSetup&quot;&gt;
- &lt;participant
- extensions=&quot;java&quot;
- class=&quot;org.eclipse.jdt.internal.ui.javaeditor.JavaDocumentSetupParticipant&quot;&gt;
- &lt;/participant&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Document setup participants have to implement org.eclipse.core.filebuffers.IDocumentSetupParticipant.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- &lt;p&gt;
-&lt;a href=&quot;hglegal.htm&quot;&gt;
- &lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
- BORDER=&quot;0&quot; height=&quot;14&quot; width=&quot;324&quot;&gt;&lt;/a&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.core.filebuffers/scripts/exportplugin.xml b/org.eclipse.core.filebuffers/scripts/exportplugin.xml
deleted file mode 100644
index 57d44f387a0..00000000000
--- a/org.eclipse.core.filebuffers/scripts/exportplugin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<project name="Export Text" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.core.filebuffers" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/filebuffers.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <zip zipfile="${dest}/filebufferssrc.zip">
- <fileset dir="src" />
- </zip>
- </target>
-</project>
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java
deleted file mode 100644
index 9c8ad357f76..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/FileBuffers.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import java.io.File;
-
-import org.eclipse.core.internal.filebuffers.FileBuffersPlugin;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-
-
-/**
- * Facade for the file buffers plug-in. Provides access to the text file buffer
- * manager and helper methods for location handling. This facade is available
- * independent from the activation status of the file buffers plug-in.
- *
- * @since 3.0
- */
-public final class FileBuffers {
-
- /**
- * Cannot be instantiated.
- */
- private FileBuffers() {
- }
-
- /**
- * Returns the text file buffer manager. May return <code>null</code> if
- * the file buffers plug-in may no be activated. This is, for example, the
- * case when the method is called on plug-in shutdown.
- *
- * @return the text file buffer manager or <code>null</code>
- */
- public static ITextFileBufferManager getTextFileBufferManager() {
- FileBuffersPlugin plugin= FileBuffersPlugin.getDefault();
- return plugin != null ? plugin.getFileBufferManager() : null;
- }
-
- /**
- * Returns the workspace file at the given location or <code>null</code> if
- * the location is not a valid location in the workspace.
- *
- * @param location the location
- * @return the workspace file at the location or <code>null</code>
- */
- public static IFile getWorkspaceFileAtLocation(IPath location) {
- IPath normalized= normalizeLocation(location);
- if (normalized.segmentCount() >= 2) {
- // @see IContainer#getFile for the required number of segments
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- IFile file= workspaceRoot.getFile(normalized);
- if (file != null && file.exists())
- return file;
- }
- return null;
- }
-
- /**
- * Returns a copy of the given location in a normalized form.
- *
- * @param location the location to be normalized
- * @return normalized copy of location
- */
- public static IPath normalizeLocation(IPath location) {
- IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
- IProject[] projects= workspaceRoot.getProjects();
-
- for (int i= 0, length= projects.length; i < length; i++) {
- IPath path= projects[i].getLocation();
- if (path != null && path.isPrefixOf(location)) {
- IPath filePath= location.removeFirstSegments(path.segmentCount());
- filePath= projects[i].getFullPath().append(filePath);
- return filePath.makeAbsolute();
- }
-
- }
- return location.makeAbsolute();
- }
-
- /**
- * Returns the file in the local file system for the given location.
- * <p>
- * The location is either a full path of a workspace resource or an
- * absolute path in the local file system.
- * </p>
- *
- * @param location the location
- * @return the {@link File} in the local file system for the given location
- */
- public static File getSystemFileAtLocation(IPath location) {
- if (location == null)
- return null;
-
- IFile file= getWorkspaceFileAtLocation(location);
- if (file != null) {
- IPath path= file.getLocation();
- return path.toFile();
- }
-
- return location.toFile();
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java
deleted file mode 100644
index b21f02413ab..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-
-/**
- * Factory for text file buffer annotation models. Used by the text file buffer
- * manager to create the annotation model for a new text file buffer.
- * <p>
- * This interface is the expected interface for extensions provided for the
- * <code>"org.eclipse.core.filebuffers.annotationModelCreation"</code>
- * extension point.
- *
- * @since 3.0
- */
-public interface IAnnotationModelFactory {
-
- /**
- * Creates and returns a new annotation model.
- *
- * @param location the normalized location
- * @return a new annotation model
- */
- IAnnotationModel createAnnotationModel(IPath location);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java
deleted file mode 100644
index 3631487e80a..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * Factory for text file buffer documents. Used by the text file buffer manager
- * to create the document for a new text file buffer.
- * <p>
- * This interface is the expected interface of extensions provided for the
- * <code>"org.eclipse.core.filebuffers.documentCreation"</code> extension
- * point.
- *
- * @since 3.0
- */
-public interface IDocumentFactory {
-
- /**
- * Creates and returns a new, empty document.
- *
- * @return a new, empty document
- */
- IDocument createDocument();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java
deleted file mode 100644
index efc4089547b..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * Participates in the setup of a text file buffer document.
- * <p>
- * This interface is the expected interface for extensions provided for the
- * <code>"org.eclipse.core.filebuffers.documentSetup"</code> extension point.
- * <p>
- * Participants have to be aware of the existence of other participants. I.e.
- * they should always setup a document in a way that does not interfere with
- * others. E.g., when a participant wants to install partitioning on the
- * document, it should use the
- * {@link org.eclipse.jface.text.IDocumentExtension3}API and choose a unique
- * partitioning id.
- *
- * @since 3.0
- * @see org.eclipse.jface.text.IDocumentExtension3
- */
-public interface IDocumentSetupParticipant {
-
- /**
- * Sets up the document to be ready for use by a text file buffer.
- *
- * @param document the document to be set up
- */
- void setup(IDocument document);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java
deleted file mode 100644
index b483d0d5ecb..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBuffer.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-
-/**
- * A file buffer represents a file that can be edited by more than one client.
- * Editing is session oriented. This means that editing is a sequence of
- * modification steps. The start of the sequence and the end of the sequence are
- * explicitly indicated. There are no time constraints connected with the
- * sequence of modification steps. A file buffer reifies editing sessions and
- * allows them to interleave.
- * <p>
- * It is not specified whether simultaneous editing sessions can be owned by
- * different threads.
- * <p>
- * Clients are not supposed to implement that interface. Instances of this type
- * are obtained from a {@link org.eclipse.core.filebuffers.IFileBufferManager}.
- *
- * @since 3.0
- */
-public interface IFileBuffer {
-
- /**
- * Returns the location of this file buffer.
- * <p>
- * The location is either a full path of a workspace resource or an
- * absolute path in the local file system.
- * </p>
- *
- * @return the location of this file buffer
- */
- IPath getLocation();
-
- /**
- * Returns whether this file buffer is synchronized with the file system. This is when
- * the file buffer's underlying file is in synchronization with the file system and the file buffer
- * has been initialized after the underlying files has been modified the last time.
- *
- * @return <code>true</code> if the file buffer is synchronized with the file system
- */
- boolean isSynchronized();
-
- /**
- * Reverts the contents of this file buffer to the content of its underlying file. After
- * that call successfully returned, <code>isDirty</code> returns <code>false</code> and
- * <code>isSynchronized</code> returns <code>true</code>.
- *
- * @param monitor the progress monitor
- * @throws CoreException if reading or accessing the underlying file fails
- */
- void revert(IProgressMonitor monitor) throws CoreException;
-
- /**
- * Commits this file buffer by changing the contents of the underlying file to
- * the contents of this file buffer. After that call, <code>isDirty</code>
- * returns <code>false</code> and <code>isSynchronized</code> returns
- * <code>true</code>.
- *
- * @param monitor the progress monitor
- * @param overwrite indicates whether the underlying file should be overwritten if it is not synchronized with the file system
- * @throws CoreException if writing or accessing the underlying file fails
- */
- void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- /**
- * Returns whether changes have been applied to this file buffer since initialization, or the most
- * recent <code>revert</code> or <code>commit</code> call.
- *
- * @return <code>true</code> if changes have been applied to this buffer
- */
- boolean isDirty();
-
- /**
- * Returns whether this file buffer is shared by more than one client.
- *
- * @return <code>true</code> if this file buffer is shared by more than one client
- */
- boolean isShared();
-
- /**
- * Validates the state of this file buffer and tries to bring the buffer's
- * underlying file into a state in which it can be modified. If state
- * validation is not supported this operation does nothing.
- *
- * @param monitor the progress monitor
- * @param computationContext the context in which the validation is
- * performed, e.g., a SWT shell
- * @exception CoreException if the underlying file can not be accessed to
- * it's state cannot be changed
- */
- void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException;
-
- /**
- * Returns whether the state of this file buffer has been validated. If
- * state validation is not supported this method always returns <code>true</code>.
- *
- * @return <code>true</code> if the state has been validated, <code>false</code>
- * otherwise
- */
- boolean isStateValidated();
-
- /**
- * Resets state validation. If state validation is supported, <code>isStateValidated</code>
- * afterwards returns <code>false</code> until the state is revalidated.
- */
- void resetStateValidation();
-
- /**
- * Returns the status of this file buffer. This is the result of the last operation performed on this file buffer or
- * internally initiated by this file buffer.
- *
- * @return the status of this file buffer
- */
- IStatus getStatus();
-
- /**
- * Returns the modification stamp of the file underlying this file buffer.
- *
- * @return the modification stamp of the file underlying this file buffer
- */
- long getModificationStamp();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java
deleted file mode 100644
index 366af3018f4..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferListener.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Interface for listeners to file buffer changes.
- *
- * @since 3.0
- */
-public interface IFileBufferListener {
-
- /**
- * Informs the listener about the creation of the given buffer.
- *
- * @param buffer the created file buffer
- */
- void bufferCreated(IFileBuffer buffer);
-
- /**
- * Informs the listener about the disposal of the given buffer.
- *
- * @param buffer the disposed file buffer
- */
- void bufferDisposed(IFileBuffer buffer);
-
- /**
- * Informs the listener about an upcoming replace of the contents of the given buffer.
- *
- * @param buffer the effected file buffer
- */
- void bufferContentAboutToBeReplaced(IFileBuffer buffer);
-
- /**
- * Informs the listener that the buffer of the given buffer has been replaced.
- *
- * @param buffer the effected file buffer
- */
- void bufferContentReplaced(IFileBuffer buffer);
-
- /**
- * Informs the listener about the start of a state changing operation on
- * the given buffer.
- *
- * @param buffer the effected file buffer
- */
- void stateChanging(IFileBuffer buffer);
-
- /**
- * Informs the listener that the dirty state of the given buffer changed
- * to the specified value
- *
- * @param buffer the effected file buffer
- * @param isDirty <code>true</code> if the buffer is dirty, <code>false</code> otherwise
- */
- void dirtyStateChanged(IFileBuffer buffer, boolean isDirty);
-
- /**
- * Informs the listener that the state validation changed to the specified value.
- *
- * @param buffer the effected file buffer
- * @param isStateValidated <code>true</code> if the buffer state is validated, <code>false</code> otherwise
- */
- void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated);
-
- /**
- * Informs the listener that the file underlying the given file buffer has been moved to the
- * given location.
- *
- * @param buffer the effected file buffer
- * @param path the new location (not just the container)
- */
- void underlyingFileMoved(IFileBuffer buffer, IPath path);
-
- /**
- * Informs the listener that the file underlying the given file buffer has been deleted.
- *
- * @param buffer the effected file buffer
- */
- void underlyingFileDeleted(IFileBuffer buffer);
-
- /**
- * Informs the listener that a state changing operation on the given
- * file buffer failed.
- *
- * @param buffer the effected file buffer
- */
- void stateChangeFailed(IFileBuffer buffer);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java
deleted file mode 100644
index bde4ee66ad2..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IFileBufferManager.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-
-/**
- * A file buffer manager manages file buffers for files while the files are
- * connected to the file buffer manager. In order to connect a file to a file
- * buffer manager call <code>connect</code>. After that call has
- * successfully completed the file buffer can be obtained by <code>getFileBuffer</code>.
- * The file buffer is created on the first connect and disposed on the last
- * disconnect. I.e. the file buffer manager keeps track of how often a file is
- * connected and returns the same file buffer to each client as long as the
- * file is connected.
- *
- * @since 3.0
- */
-public interface IFileBufferManager {
-
- /**
- * Connects the file at the given location to this manager. After that call
- * successfully completed it is guaranteed that each call to <code>getFileBuffer</code>
- * returns the same file buffer until <code>disconnect</code> is called.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location of the file to be connected
- * @param monitor the progress monitor
- * @throws CoreException if the file could not successfully be connected
- */
- void connect(IPath location, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Disconnects the file at the given location from this manager. After that
- * call successfully completed there is no guarantee that <code>getFileBuffer</code>
- * will return a valid file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location of the file to be disconnected
- * @param monitor the progress monitor
- * @throws CoreException if the file could not successfully be disconnected
- */
- void disconnect(IPath location, IProgressMonitor monitor) throws CoreException;
-
- /**
- * Returns the file buffer managed for the given location or <code>null</code>
- * if there is no such file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- * @return the file buffer managed for that location or <code>null</code>
- */
- IFileBuffer getFileBuffer(IPath location);
-
- /**
- * Sets the synchronization context for this file buffer manager, i.e., for
- * all file buffers this manager manages.
- *
- * @param context the synchronization context managed by this file buffer
- * manager
- */
- void setSynchronizationContext(ISynchronizationContext context);
-
- /**
- * The caller requests that the synchronization context is used to
- * synchronize the given location with its file buffer. This call as no
- * effect if there is no file buffer managed for the given location.
- * <p>
- * The provided location is either a full path of a workspace resource or an
- * absolute path in the local file system. The file buffer manager does not
- * resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- */
- void requestSynchronizationContext(IPath location);
-
- /**
- * The caller no longer requests the synchronization context for the file
- * buffer managed for the given location. This method has no effect if there
- * is no file buffer managed for this location.
- * <p>
- * The provided location is either a full path of a workspace resource or an
- * absolute path in the local file system. The file buffer manager does not
- * resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- */
- void releaseSynchronizationContext(IPath location);
-
- /**
- * Adds the given listener to the list of file buffer listeners. After that
- * call the listener is informed about changes related to this file
- * buffer manager. If the listener is already registered with the file buffer, this
- * call has no effect.
- *
- * @param listener the listener to be added
- */
- void addFileBufferListener(IFileBufferListener listener);
-
- /**
- * Removes the given listener from the list of file buffer listeners. If
- * the listener is not registered with this file buffer, this call has no
- * effect.
- *
- * @param listener the listener to be removed
- */
- void removeFileBufferListener(IFileBufferListener listener);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java
deleted file mode 100644
index 82c681d5cdb..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.text.IDocument;
-
-
-
-/**
- * Tagging interface for {@link org.eclipse.jface.text.source.IAnnotationModel} implementers that offer
- * state persistence.
- *
- * @since 3.0
- */
-public interface IPersistableAnnotationModel {
-
- /**
- * Transforms the current transient state of the annotation model into a
- * persistent state.
- *
- * @param document the document the annotation model is connected to
- * @throws CoreException in case the transformation fails
- */
- void commit(IDocument document) throws CoreException;
-
- /**
- * Changes the current transient state of the annotation model to match the
- * last persisted state.
- *
- * @param document the document the annotation model is connected to
- * @throws CoreException in case accessing the persisted state
- */
- void revert(IDocument document) throws CoreException;
-
- /**
- * Forces this annotation model to re-initialize from the persistent state.
- * The persistent state must not be the same as the last persisted state.
- * I.e. external modification may have caused changes to the persistent
- * state since the last <code>commit</code> or <code>revert</code>
- * operation.
- *
- * @param document the document the annotation model is connected to
- * @throws CoreException in case accessing the persistent state fails
- */
- void reinitialize(IDocument document) throws CoreException;
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java
deleted file mode 100644
index bb27c5bf1b9..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ISynchronizationContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-/**
- * A file buffer manager (see
- * {@link org.eclipse.core.filebuffers.IFileBufferManager}uses a
- * <code>ISynchronizationContext</code> in order to execute commands
- * encapsulated as {@link java.lang.Runnable}. The synchronization context
- * executes the <code>Runnables</code> according to a specific
- * synchronization/execution policy. This could be that the given
- * <code>Runnable</code> is executed in a specific thread or environment or
- * adhere to specific timing constraints. The concrete characteristics of the
- * policy is to be specified by the context implementer.
- * <p>
- * This interface can be implemented by clients. Clients use
- * {@link org.eclipse.core.filebuffers.IFileBufferManager#setSynchronizationContext(ISynchronizationContext)}
- * to install a particular synchronization context with a file buffer manager.
- *
- * @since 3.0
- */
-public interface ISynchronizationContext {
-
- /**
- * Executes the given runnable according to the specified
- * synchronization/execution policy.
- *
- *
- * @param runnable the runnable to be executed
- */
- void run(Runnable runnable);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
deleted file mode 100644
index 74ee3df9252..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-/**
- * A text file buffer is a file buffer for text files. The contents of a text
- * file buffer is given in the form of a document and an associated annotation
- * model. Also, the text file buffer provides methods to manage the character
- * encoding used to read and write the buffer's underlying text file.
- *
- * @since 3.0
- */
-public interface ITextFileBuffer extends IFileBuffer {
-
- /**
- * Returns the document of this text file buffer.
- *
- * @return the document of this text file buffer
- */
- IDocument getDocument();
-
- /**
- * Returns the character encoding to be used for reading and writing the
- * buffer's underlying file.
- *
- * @return the character encoding
- */
- String getEncoding();
-
- /**
- * Sets the character encoding to be used for reading and writing the buffer's
- * underlying file.
- *
- * @param encoding the encoding
- */
- void setEncoding(String encoding);
-
- /**
- * Returns the annotation model of this text file buffer.
- *
- * @return the annotation model of this text file buffer
- */
- IAnnotationModel getAnnotationModel();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
deleted file mode 100644
index 846a46671a5..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.filebuffers;
-
-
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-
-/**
- * A text file buffer manager manages text file buffers for files whose contents
- * is considered text.
- *
- * @since 3.0
- */
-public interface ITextFileBufferManager extends IFileBufferManager {
-
- /**
- * Returns the text file buffer managed for the file at the given location
- * or <code>null</code> if either there is no such text file buffer.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location
- * @return the text file buffer managed for that location or <code>null</code>
- */
- ITextFileBuffer getTextFileBuffer(IPath location);
-
- /**
- * Returns the default encoding that is used to read the contents of text files
- * if no other encoding is specified.
- *
- * @return the default text file encoding
- */
- String getDefaultEncoding();
-
- /**
- * Creates a new empty document . The document is set up in the same way as
- * it would be used in a text file buffer for a file at the given location.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system. The file buffer manager does
- * not resolve the location of workspace resources in the case of linked
- * resources.
- * </p>
- *
- * @param location the location used to set up the newly created document
- * @return a new empty document
- */
- IDocument createEmptyDocument(IPath location);
-
- /**
- * Creates a new annotation for the given location.
- *
- * @param location the location
- * @return the newly created annotation model
- */
- IAnnotationModel createAnnotationModel(IPath location);
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/package.html b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/package.html
deleted file mode 100644
index 419fe478093..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/package.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html><head>
- <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
- <meta content="IBM" name="Author">
- <meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]" name="GENERATOR"><title>text infrastructure</title></head>
-
-<body>
-<p>Provides the API for accessing file buffers.</p>
-<h3>Package Specification</h3>
-<p>File buffers represent a file that is being edited. Text file buffers are
- specific for text files. They represent the content of a text file in form of
- an <tt>IDocument</tt> and and associated <tt>IAnnotationModel</tt>. File buffers are managed by
- a file buffer manager. The <tt>org.eclipse.core.filebuffers</tt> plug-in provides a default
- file buffer manager that can be obtained by calling <tt>FileBuffers.getTextFileBufferManager()</tt>.
- The file buffer manager supports listeners, <tt>IFileBufferListener</tt>, that are informed about all relevant
- state changes of file buffers as well as their creation and disposal.</p>
-</body></html> \ No newline at end of file
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java
deleted file mode 100644
index f0721e2475f..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/AbstractFileBuffer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.core.filebuffers.IFileBuffer;
-
-/**
- * @since 3.0
- */
-public abstract class AbstractFileBuffer implements IFileBuffer {
-
-
- public abstract void create(IPath location, IProgressMonitor monitor) throws CoreException;
-
- public abstract void connect();
-
- public abstract void disconnect() throws CoreException;
-
- public abstract boolean isDisposed();
-
- public abstract void requestSynchronizationContext();
-
- public abstract void releaseSynchronizationContext();
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
deleted file mode 100644
index ec5f82f8323..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-public class ContainerGenerator {
-
- private IPath fContainerFullPath;
- private IContainer fContainer;
- private IWorkspace fWorkspace;
-
- public ContainerGenerator(IWorkspace workspace, IPath containerPath) {
- fWorkspace= workspace;
- fContainerFullPath = containerPath;
- }
-
- private IFolder createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException {
- folderHandle.create(false, true, monitor);
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- return folderHandle;
- }
-
- private IFolder createFolderHandle(IContainer container, String folderName) {
- return container.getFolder(new Path(folderName));
- }
-
- private IProject createProject(IProject projectHandle, IProgressMonitor monitor) throws CoreException {
- try {
- monitor.beginTask("",2000);//$NON-NLS-1$
-
- projectHandle.create(new SubProgressMonitor(monitor, 1000));
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- projectHandle.open(new SubProgressMonitor(monitor, 1000));
- if (monitor.isCanceled())
- throw new OperationCanceledException();
-
- } finally {
- monitor.done();
- }
-
- return projectHandle;
- }
-
- private IProject createProjectHandle(IWorkspaceRoot root, String projectName) {
- return root.getProject(projectName);
- }
-
- public IContainer generateContainer(IProgressMonitor monitor) throws CoreException {
- IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(FileBuffersMessages.getString("ContainerGenerator.task.creatingContainer"), 1000 * fContainerFullPath.segmentCount()); //$NON-NLS-1$
- if (fContainer != null)
- return;
-
- // Does the container exist already?
- IWorkspaceRoot root= fWorkspace.getRoot();
- IResource found= root.findMember(fContainerFullPath);
- if (found instanceof IContainer) {
- fContainer= (IContainer) found;
- return;
- } else if (found != null) {
- // fContainerFullPath specifies a file as directory
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getFormattedString("ContainerGenerator.destinationMustBeAContainer", fContainerFullPath), null)); //$NON-NLS-1$
- }
-
- // Create the container for the given path
- fContainer= root;
- for (int i = 0; i < fContainerFullPath.segmentCount(); i++) {
- String currentSegment = fContainerFullPath.segment(i);
- IResource resource = fContainer.findMember(currentSegment);
- if (resource != null) {
- if (resource instanceof IContainer) {
- fContainer= (IContainer) resource;
- monitor.worked(1000);
- } else {
- // fContainerFullPath specifies a file as directory
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getFormattedString("ContainerGenerator.destinationMustBeAContainer", resource.getFullPath()), null)); //$NON-NLS-1$
- }
- }
- else {
- if (i == 0) {
- IProject projectHandle= createProjectHandle(root, currentSegment);
- fContainer= createProject(projectHandle, new SubProgressMonitor(monitor,1000));
- }
- else {
- IFolder folderHandle= createFolderHandle(fContainer, currentSegment);
- fContainer= createFolder(folderHandle, new SubProgressMonitor(monitor,1000));
- }
- }
- }
- }
- };
-
- // Get scheduling rule
- IWorkspaceRoot root= fWorkspace.getRoot();
- IPath existingParentPath= fContainerFullPath;
- while (!root.exists(existingParentPath))
- existingParentPath= existingParentPath.removeLastSegments(1);
-
- IResource schedulingRule= root.findMember(existingParentPath);
- fWorkspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
- return fContainer;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java
deleted file mode 100644
index 61ab7ca3b67..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/DefaultDocumentFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import org.eclipse.core.filebuffers.IDocumentFactory;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * The default document factory.
- */
-public class DefaultDocumentFactory implements IDocumentFactory {
-
- public DefaultDocumentFactory() {
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IDocumentFactory#createDocument()
- */
- public IDocument createDocument() {
- return new Document();
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
deleted file mode 100644
index f1926c6932e..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-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.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IAnnotationModelFactory;
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * This registry manages sharable document factories. Document factories are specified
- * in <code>plugin.xml</code> per file name extension.
- */
-public class ExtensionsRegistry {
-
- /**
- * Adapts IContentType with the ability to check
- * equality. This allows to use them in a collection.
- */
- private static class ContentTypeAdapter {
-
- /** The adapted content type. */
- private IContentType fContentType;
-
- /**
- * Creates a new content type adapter for the
- * given content type.
- *
- * @param contentType the content type to be adapted
- */
- public ContentTypeAdapter(IContentType contentType) {
- Assert.isNotNull(contentType);
- fContentType= contentType;
- }
-
- /**
- * Return the adapted content type.
- *
- * @return the content type
- */
- public IContentType getContentType() {
- return fContentType;
- }
-
- /**
- * Return the Id of the adapted content type.
- *
- * @return the Id
- */
- public String getId() {
- return fContentType.getId();
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- return obj instanceof ContentTypeAdapter && fContentType.getId().equals(((ContentTypeAdapter)obj).getId());
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fContentType.getId().hashCode();
- }
- }
-
- private final static String WILDCARD= "*"; //$NON-NLS-1$
-
- /** The mapping between file attributes and configuration elements describing document factories. */
- private Map fFactoryDescriptors= new HashMap();
- /** The mapping between configuration elements for document factories and instantiated document factories. */
- private Map fFactories= new HashMap();
- /** The mapping between file attributes and configuration elements describing document setup participants. */
- private Map fSetupParticipantDescriptors= new HashMap();
- /** The mapping between configuration elements for setup participants and instantiated setup participants. */
- private Map fSetupParticipants= new HashMap();
- /** The mapping between file attributes and configuration elements describing annotation model factories. */
- private Map fAnnotationModelFactoryDescriptors= new HashMap();
- /** The mapping between configuration elements for annotation model factories */
- private Map fAnnotationModelFactories= new HashMap();
- /** The content type manager. */
- private IContentTypeManager fContentTypeManager= Platform.getContentTypeManager();
-
-
- /**
- * Creates a new document factory registry and initializes it with the information
- * found in the plug-in registry.
- */
- public ExtensionsRegistry() {
- initialize("documentCreation", "contentTypeId", true, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentCreation", "fileNames", false, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentCreation", "extensions", false, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "contentTypeId", true, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "fileNames", false, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "extensions", false, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("annotationModelCreation", "contentTypeId", true, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("annotationModelCreation", "fileNames", false, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("annotationModelCreation", "extensions", false, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /**
- * Reads the comma-separated value from the given configuration element for the given attribute name and remembers
- * the configuration element in the given map under the individual tokens of the attribute value.
- *
- * @param attributeName the name of the attribute
- * @param element the configuration element
- * @param map the map which remembers the configuration element
- */
- private void read(String attributeName, IConfigurationElement element, Map map) {
- String value= element.getAttribute(attributeName);
- if (value != null) {
- StringTokenizer tokenizer= new StringTokenizer(value, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String token= tokenizer.nextToken().trim();
-
- Set s= (Set) map.get(token);
- if (s == null) {
- s= new HashSet();
- map.put(token, s);
- }
- s.add(element);
- }
- }
- }
-
- /**
- * Reads the value from the given configuration element for the given attribute name and remembers
- * the configuration element in the given map under the individual content type of the attribute value.
- *
- * @param attributeName the name of the attribute
- * @param element the configuration element
- * @param map the map which remembers the configuration element
- */
- private void readContentType(String attributeName, IConfigurationElement element, Map map) {
- String value= element.getAttribute(attributeName);
- if (value != null) {
- IContentType contentType= fContentTypeManager.getContentType(value);
- if (contentType == null) {
- log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, FileBuffersMessages.getFormattedString("ExtensionsRegistry.error.contentTypeDoesNotExist", new Object[] { value }), null)); //$NON-NLS-1$
- return;
- }
- ContentTypeAdapter adapter= new ContentTypeAdapter(contentType);
- Set s= (Set) map.get(adapter);
- if (s == null) {
- s= new HashSet();
- map.put(adapter, s);
- }
- s.add(element);
- }
- }
-
- /**
- * Adds an entry to the log of this plug-in for the given status
- * @param status the status to log
- */
- private void log(IStatus status) {
- ILog log= FileBuffersPlugin.getDefault().getLog();
- log.log(status);
- }
-
- /**
- * Initializes this registry. It retrieves all implementers of the given
- * extension point and remembers those implementers based on the
- * file name extensions in the given map.
- *
- * @param extensionPointName the name of the extension point
- * @param childElementName the name of the child elements
- * @param isContentTypeId the child element is a content type id
- * @param descriptors the map to be filled
- */
- private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map descriptors) {
-
- IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(FileBuffersPlugin.PLUGIN_ID, extensionPointName);
- if (extensionPoint == null) {
- log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, FileBuffersMessages.getFormattedString("ExtensionsRegistry.error.extensionPointNotFound", new Object[] { extensionPointName}), null)); //$NON-NLS-1$
- return;
- }
-
- IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- if (isContentTypeId)
- readContentType(childElementName, elements[i], descriptors);
- else
- read(childElementName, elements[i], descriptors);
- }
- }
-
- /**
- * Returns the executable extension for the given configuration element.
- * If there is no instantiated extension remembered for this
- * element, a new extension is created and put into the cache if it is of the requested type.
- *
- * @param entry the configuration element
- * @param extensions the map of instantiated extensions
- * @param extensionType the requested result type
- * @return the executable extension for the given configuration element.
- */
- private Object getExtension(IConfigurationElement entry, Map extensions, Class extensionType) {
- Object extension= extensions.get(entry);
- if (extension != null)
- return extension;
-
- try {
- extension= entry.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException x) {
- log(x.getStatus());
- }
-
- if (extensionType.isInstance(extension)) {
- extensions.put(entry, extension);
- return extension;
- }
-
- return null;
- }
-
- /**
- * Returns the first enumerated element of the given set.
- *
- * @param set the set from which to choose
- * @return the selected configuration element
- */
- private IConfigurationElement selectConfigurationElement(Set set) {
- if (set != null && !set.isEmpty()) {
- Iterator e= set.iterator();
- return (IConfigurationElement) e.next();
- }
- return null;
- }
-
- /**
- * Returns a sharable document factory for the given file name or file extension.
- *
- * @param nameOrExtension the name or extension to be used for lookup
- * @return the sharable document factory or <code>null</code>
- */
- private IDocumentFactory getDocumentFactory(String nameOrExtension) {
- Set set= (Set) fFactoryDescriptors.get(nameOrExtension);
- if (set != null) {
- IConfigurationElement entry= selectConfigurationElement(set);
- return (IDocumentFactory) getExtension(entry, fFactories, IDocumentFactory.class);
- }
- return null;
- }
-
- /**
- * Returns a sharable document factory for the given content types.
- *
- * @param contentTypes the content types used to find the factory
- * @return the sharable document factory or <code>null</code>
- */
- private IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
- Set set= null;
- int i= 0;
- while (i < contentTypes.length && set == null) {
- set= (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
- }
-
- if (set != null) {
- IConfigurationElement entry= selectConfigurationElement(set);
- return (IDocumentFactory) getExtension(entry, fFactories, IDocumentFactory.class);
- }
- return null;
- }
-
- /**
- * Returns a sharable document factory for the given content types. This
- * method considers the base content types of the given set of content
- * types.
- *
- * @param contentTypes the content types used to find the factory
- * @return the sharable document factory or <code>null</code>
- */
- private IDocumentFactory getDocumentFactory(IContentType[] contentTypes) {
- IDocumentFactory factory= doGetDocumentFactory(contentTypes);
- while (factory == null) {
- contentTypes= computeBaseContentTypes(contentTypes);
- if (contentTypes == null)
- break;
- factory= doGetDocumentFactory(contentTypes);
- }
- return factory;
- }
-
- /**
- * Returns the set of setup participants for the given file name or extension.
- *
- * @param nameOrExtension the name or extension to be used for lookup
- * @return the sharable set of document setup participants
- */
- private List getDocumentSetupParticipants(String nameOrExtension) {
- Set set= (Set) fSetupParticipantDescriptors.get(nameOrExtension);
- if (set == null)
- return null;
-
- List participants= new ArrayList();
- Iterator e= set.iterator();
- while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
- if (participant != null)
- participants.add(participant);
- }
-
- return participants;
- }
-
- /**
- * Returns the set of setup participants for the given content types.
- *
- * @param contentTypes the contentTypes to be used for lookup
- * @return the sharable set of document setup participants
- */
- private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
- Set resultSet= new HashSet();
- int i= 0;
- while (i < contentTypes.length) {
- Set set= (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
- if (set != null)
- resultSet.addAll(set);
- }
-
- List participants= new ArrayList();
- Iterator e= resultSet.iterator();
- while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
- if (participant != null)
- participants.add(participant);
- }
-
- return participants.isEmpty() ? null : participants;
- }
-
- /**
- * Returns the set of setup participants for the given content types. This
- * method considers the base content types of the given set of content
- * types.
- *
- * @param contentTypes the contentTypes to be used for lookup
- * @return the sharable set of document setup participants
- */
- private List getDocumentSetupParticipants(IContentType[] contentTypes) {
- List participants= doGetDocumentSetupParticipants(contentTypes);
- while (participants == null) {
- contentTypes= computeBaseContentTypes(contentTypes);
- if (contentTypes == null)
- break;
- participants= doGetDocumentSetupParticipants(contentTypes);
- }
- return participants;
- }
-
- /**
- * Returns a sharable annotation model factory for the given content types.
- *
- * @param contentTypes the content types used to find the factory
- * @return the sharable annotation model factory or <code>null</code>
- */
- private IAnnotationModelFactory doGetAnnotationModelFactory(IContentType[] contentTypes) {
- Set set= null;
- int i= 0;
- while (i < contentTypes.length && set == null) {
- set= (Set) fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
- }
-
- if (set != null) {
- IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
- }
- return null;
- }
-
- /**
- * Returns a sharable annotation model factory for the given content types.
- * This method considers the base content types of the given set of content
- * types.
- *
- * @param contentTypes the content types used to find the factory
- * @return the sharable annotation model factory or <code>null</code>
- */
- private IAnnotationModelFactory getAnnotationModelFactory(IContentType[] contentTypes) {
- IAnnotationModelFactory factory= doGetAnnotationModelFactory(contentTypes);
- while (factory == null) {
- contentTypes= computeBaseContentTypes(contentTypes);
- if (contentTypes == null)
- break;
- factory= doGetAnnotationModelFactory(contentTypes);
- }
- return factory;
- }
-
- /**
- * Returns a sharable annotation model factory for the given file name or file extension.
- *
- * @param extension the name or extension to be used for lookup
- * @return the sharable document factory or <code>null</code>
- */
- private IAnnotationModelFactory getAnnotationModelFactory(String extension) {
- Set set= (Set) fAnnotationModelFactoryDescriptors.get(extension);
- if (set != null) {
- IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
- }
- return null;
- }
-
- /**
- * Returns the set of content types for the given location.
- *
- * @param location the location for which to look up the content types
- * @return the set of content types for the location
- */
- private IContentType[] findContentTypes(IPath location) {
- IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
- if (file != null) {
- try {
- IContentDescription contentDescription= file.getContentDescription();
- if (contentDescription != null) {
- IContentType contentType= contentDescription.getContentType();
- if (contentType != null)
- return new IContentType[] {contentType};
- }
- } catch (CoreException x) {
- // go for the default
- }
- }
- return fContentTypeManager.findContentTypesFor(location.lastSegment());
- }
-
- /**
- * Returns the set of direct base content types for the given set of content
- * types. Returns <code>null</code> if non of the given content types has
- * a direct base content type.
- *
- * @param contentTypes the content types
- * @return the set of direct base content types
- */
- private IContentType[] computeBaseContentTypes(IContentType[] contentTypes) {
- List baseTypes= new ArrayList();
- for (int i= 0; i < contentTypes.length; i++) {
- IContentType baseType= contentTypes[i].getBaseType();
- if (baseType != null)
- baseTypes.add(baseType);
- }
-
- IContentType[] result= null;
- int size= baseTypes.size();
- if (size > 0) {
- result= new IContentType[size];
- baseTypes.toArray(result);
- }
- return result;
- }
-
- /**
- * Returns the sharable document factory for the given location.
- *
- * @param location the location for which to looked up the factory
- * @return the sharable document factory
- */
- public IDocumentFactory getDocumentFactory(IPath location) {
- IDocumentFactory factory= getDocumentFactory(findContentTypes(location));
- if (factory == null)
- factory= getDocumentFactory(location.lastSegment());
- if (factory == null)
- factory= getDocumentFactory(location.getFileExtension());
- if (factory == null)
- factory= getDocumentFactory(WILDCARD);
- return factory;
- }
-
- /**
- * Returns the sharable set of document setup participants for the given location.
- *
- * @param location the location for which to look up the setup participants
- * @return the sharable set of document setup participants
- */
- public IDocumentSetupParticipant[] getDocumentSetupParticipants(IPath location) {
- List participants= new ArrayList();
-
- List p= getDocumentSetupParticipants(findContentTypes(location));
- if (p != null)
- participants.addAll(p);
-
- p= getDocumentSetupParticipants(location.lastSegment());
- if (p != null)
- participants.addAll(p);
-
- p= getDocumentSetupParticipants(location.getFileExtension());
- if (p != null)
- participants.addAll(p);
-
- p= getDocumentSetupParticipants(WILDCARD);
- if (p != null)
- participants.addAll(p);
-
- IDocumentSetupParticipant[] result= new IDocumentSetupParticipant[participants.size()];
- participants.toArray(result);
- return result;
- }
-
- /**
- * Returns the sharable annotation model factory for the given location.
- *
- * @param location the location for which to look up the factory
- * @return the sharable annotation model factory
- */
- public IAnnotationModelFactory getAnnotationModelFactory(IPath location) {
- IAnnotationModelFactory factory= getAnnotationModelFactory(findContentTypes(location));
- if (factory == null)
- factory= getAnnotationModelFactory(location.lastSegment());
- if (factory == null)
- factory= getAnnotationModelFactory(location.getFileExtension());
- if (factory == null)
- factory= getAnnotationModelFactory(WILDCARD);
- return factory;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.java
deleted file mode 100644
index e3230fff257..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.core.internal.filebuffers;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-/**
- * Helper class to get NLSed messages.
- *
- * @since 3.0
- */
-class FileBuffersMessages {
-
- private static final String RESOURCE_BUNDLE= FileBuffersMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private FileBuffersMessages() {
- }
-
- /**
- * Gets a string from the resource bundle.
- *
- * @param key the string used to get the bundle value, must not be <code>null</code>
- * @return the string from the resource bundle
- */
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the given arguments.
- *
- * @param key the string used to get the bundle value, must not be <code>null</code>
- * @param args the arguments used to format the string
- * @return the formatted string
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the given argument.
- *
- * @param key the string used to get the bundle value, must not be <code>null</code>
- * @param arg the argument used to format the string
- * @return the formatted string
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
deleted file mode 100644
index efbe8b0d373..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-ExtensionsRegistry.error.extensionPointNotFound= Extension point "{0}" not found.
-ExtensionsRegistry.error.contentTypeDoesNotExist= The content type with id "{0}" specified in the extension point does not exist.
-
-FileBuffer.error.fileDoesNotExist= The file does not exist.
-FileBuffer.error.outOfSync= The file is not synchronized with the the local file system.
-
-FileBuffer.status.ok= OK
-FileBuffer.status.error= Error
-
-FileBufferManager.error.canNotCreateFilebuffer= Cannot create file buffer.
-
-ContainerGenerator.task.creatingContainer= Creating container...
-ContainerGenerator.destinationMustBeAContainer=Specified path is not a folder: {0}
-
-ResourceTextFileBuffer.error.unsupported_encoding.message_arg= Character encoding \"{0}\" is not supported by this platform.
-ResourceTextFileBuffer.error.closeReader= Could not close reader.
-
-JavaTextFileBuffer.error.closeStream= Could not close stream.
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java
deleted file mode 100644
index 14610ace3a2..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersPlugin.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Plugin;
-
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.text.Assert;
-
-
-/**
- * The plug-in runtime class for the file buffers plug-in (id <code>"org.eclipse.core.filebuffers"</code>).
- *
- * @since 3.0
- */
-public class FileBuffersPlugin extends Plugin {
-
- public final static String PLUGIN_ID= "org.eclipse.core.filebuffers"; //$NON-NLS-1$
-
- /** The shared plug-in instance */
- private static FileBuffersPlugin fgPlugin;
- /** The resource bundle */
- private ResourceBundle fResourceBundle;
- /** The file buffer manager */
- private ITextFileBufferManager fTextFileBufferManager;
-
- /**
- * Creates a plug-in instance.
- */
- public FileBuffersPlugin() {
- Assert.isTrue(fgPlugin == null);
- fgPlugin= this;
- try {
- fResourceBundle= ResourceBundle.getBundle("org.eclipse.core.internal.filebuffers.FileBuffersPlugin"); //$NON-NLS-1$
- } catch (MissingResourceException x) {
- fResourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- *
- * @return the default plug-in instance
- */
- public static FileBuffersPlugin getDefault() {
- return fgPlugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- *
- * @param key the resource string key
- * @return the resource string for the given key
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle= FileBuffersPlugin.getDefault().getResourceBundle();
- try {
- return (bundle!=null ? bundle.getString(key) : key);
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle.
- *
- * @return the resource bundle
- */
- private ResourceBundle getResourceBundle() {
- return fResourceBundle;
- }
-
- /**
- * Returns the text file buffer manager of this plug-in.
- *
- * @return the text file buffer manager of this plug-in
- */
- public ITextFileBufferManager getFileBufferManager() {
- if (fTextFileBufferManager == null)
- fTextFileBufferManager= new TextFileBufferManager();
- return fTextFileBufferManager;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java
deleted file mode 100644
index 5b8b3535f5d..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaFileBuffer.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-
-/**
- * @since 3.0
- */
-public abstract class JavaFileBuffer extends AbstractFileBuffer {
-
- /** The location */
- protected IPath fLocation;
- /** The element for which the info is stored */
- protected File fFile;
- /** How often the element has been connected */
- protected int fReferenceCount;
- /** Can the element be saved */
- protected boolean fCanBeSaved= false;
- /** The status of this element */
- protected IStatus fStatus;
- /** The time stamp at which this buffer synchronized with the underlying file. */
- protected long fSynchronizationStamp= IFile.NULL_STAMP;
- /** How often the synchronization context has been requested */
- protected int fSynchronizationContextCount;
- /** The text file buffer manager */
- protected TextFileBufferManager fManager;
-
-
- public JavaFileBuffer(TextFileBufferManager manager) {
- super();
- fManager= manager;
- }
-
- abstract protected void addFileBufferContentListeners();
-
- abstract protected void removeFileBufferContentListeners();
-
- abstract protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException;
-
- abstract protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- /**
- * Returns the file at the given location or <code>null</code> if
- * there is no such file.
- *
- * @param location the location
- * @return the file at the given location
- */
- private File getFileAtLocation(IPath location) {
- File file= FileBuffers.getSystemFileAtLocation(location);
- return file.exists() ? file : null;
- }
-
- public void create(IPath location, IProgressMonitor monitor) throws CoreException {
- File file= getFileAtLocation(location);
- if (file == null)
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("FileBuffer.error.fileDoesNotExist"), null)); //$NON-NLS-1$
-
- fLocation= location;
- fFile= file;
- initializeFileBufferContent(monitor);
- fSynchronizationStamp= fFile.lastModified();
-
- addFileBufferContentListeners();
- }
-
- public void connect() {
- ++ fReferenceCount;
- }
-
- public void disconnect() throws CoreException {
- -- fReferenceCount;
- }
-
- /**
- * Returns whether this file buffer has already been disposed.
- *
- * @return <code>true</code> if already disposed, <code>false</code> otherwise
- */
- public boolean isDisposed() {
- return fReferenceCount <= 0;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getLocation()
- */
- public IPath getLocation() {
- return fLocation;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#commit(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- if (!isDisposed() && fCanBeSaved) {
-
- fManager.fireStateChanging(this);
-
- try {
- commitFileBufferContent(monitor, overwrite);
- } catch (CoreException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- } catch (RuntimeException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- }
-
- fCanBeSaved= false;
- addFileBufferContentListeners();
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isDirty()
- */
- public boolean isDirty() {
- return fCanBeSaved;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isShared()
- */
- public boolean isShared() {
- return fReferenceCount > 1;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#validateState(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object)
- */
- public void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException {
- // nop
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isStateValidated()
- */
- public boolean isStateValidated() {
- return true;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#resetStateValidation()
- */
- public void resetStateValidation() {
- // nop
- }
-
- /**
- * Sends out the notification that the file serving as document input has been moved.
- *
- * @param newLocation the path of the new location of the file
- */
- protected void handleFileMoved(IPath newLocation) {
- fManager.fireUnderlyingFileMoved(this, newLocation);
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- */
- protected void handleCoreException(CoreException exception) {
- ILog log= FileBuffersPlugin.getDefault().getLog();
- log.log(exception.getStatus());
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isSynchronized()
- */
- public boolean isSynchronized() {
- return fSynchronizationStamp == fFile.lastModified();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getModificationStamp()
- */
- public long getModificationStamp() {
- return fFile.lastModified();
- }
-
- /**
- * Requests the file buffer manager's synchronization context for this file buffer.
- */
- public void requestSynchronizationContext() {
- ++ fSynchronizationContextCount;
- }
-
- /**
- * Releases the file buffer manager's synchronization context for this file buffer.
- */
- public void releaseSynchronizationContext() {
- -- fSynchronizationContextCount;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
deleted file mode 100644
index 28bdfcda6a9..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IResourceStatus;
-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.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentDescription;
-
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-/**
- * @since 3.0
- */
-public class JavaTextFileBuffer extends JavaFileBuffer implements ITextFileBuffer {
-
-
- private class DocumentListener implements IDocumentListener {
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fCanBeSaved= true;
- removeFileBufferContentListeners();
- fManager.fireDirtyStateChanged(JavaTextFileBuffer.this, fCanBeSaved);
- }
- }
-
- /**
- * Reader chunk size.
- */
- private static final int READER_CHUNK_SIZE= 2048;
- /**
- * Buffer size.
- */
- private static final int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
- /**
- * Constant for representing the OK status. This is considered a value object.
- */
- private static final IStatus STATUS_OK= new Status(IStatus.OK, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("FileBuffer.status.ok"), null); //$NON-NLS-1$
- /**
- * Constant for representing the error status. This is considered a value object.
- */
- private static final IStatus STATUS_ERROR= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.INFO, FileBuffersMessages.getString("FileBuffer.status.error"), null); //$NON-NLS-1$
- /**
- * Constant denoting UTF-8 encoding.
- */
- private static final String CHARSET_UTF_8= "UTF-8"; //$NON-NLS-1$
-
-
- /** The element's document */
- protected IDocument fDocument;
- /** The encoding used to create the document from the storage or <code>null</code> for workbench encoding. */
- protected String fEncoding;
- /** Internal document listener */
- protected IDocumentListener fDocumentListener= new DocumentListener();
- /**
- * The encoding which has explicitly been set on the file.
- */
- private String fExplicitEncoding;
- /**
- * Tells whether the file on disk has a BOM.
- */
- private boolean fHasBOM;
-
-
- public JavaTextFileBuffer(TextFileBufferManager manager) {
- super(manager);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBuffer#getAnnotationModel()
- */
- public IAnnotationModel getAnnotationModel() {
- return null;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
- */
- public String getEncoding() {
- return fEncoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#setEncoding(java.lang.String)
- */
- public void setEncoding(String encoding) {
- fEncoding= encoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFile#getStatus()
- */
- public IStatus getStatus() {
- if (!isDisposed()) {
- if (fStatus != null)
- return fStatus;
- return (fDocument == null ? STATUS_ERROR : STATUS_OK);
- }
- return STATUS_ERROR;
- }
-
- private InputStream getFileContents(IProgressMonitor monitor) {
- try {
- return new FileInputStream(fFile);
- } catch (FileNotFoundException e) {
- }
- return null;
- }
-
- private void setFileContents(InputStream stream, boolean overwrite, IProgressMonitor monitor) {
- try {
- OutputStream out= new FileOutputStream(fFile, false);
-
- try {
- byte[] buffer = new byte[8192];
- while (true) {
- int bytesRead = -1;
- try {
- bytesRead = stream.read(buffer);
- } catch (IOException e) {
- }
- if (bytesRead == -1)
- break;
- try {
- out.write(buffer, 0, bytesRead);
- } catch (IOException e) {
- }
- monitor.worked(1);
- }
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- } finally {
- try {
- out.close();
- } catch (IOException e) {
- }
- }
- }
- } catch (FileNotFoundException e) {
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#revert(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void revert(IProgressMonitor monitor) throws CoreException {
- if (isDisposed())
- return;
-
- IDocument original= null;
- IStatus status= null;
-
- try {
- original= fManager.createEmptyDocument(getLocation());
- setDocumentContent(original, getFileContents(monitor), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- fStatus= status;
-
- if (original != null) {
-
- String originalContents= original.get();
- boolean replaceContents= !originalContents.equals(fDocument.get());
-
- if (replaceContents) {
- fManager.fireBufferContentAboutToBeReplaced(this);
- fDocument.set(original.get());
- }
-
- if (fCanBeSaved) {
- fCanBeSaved= false;
- addFileBufferContentListeners();
- }
-
- if (replaceContents)
- fManager.fireBufferContentReplaced(this);
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#addFileBufferContentListeners()
- */
- protected void addFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.addDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#removeFileBufferContentListeners()
- */
- protected void removeFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.removeDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#initializeFileBufferContent(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException {
- try {
- fDocument= fManager.createEmptyDocument(getLocation());
- fEncoding= null;
- fHasBOM= false;
-
- InputStream stream= getFileContents(monitor);
- try {
- QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
- IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(stream, fFile.getName(), options);
- if (description != null) {
- fEncoding= description.getCharset();
- fHasBOM= description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
- }
- } catch (IOException e) {
- // do nothing
- } finally {
- try {
- stream.close();
- } catch (IOException ex) {
- FileBuffersPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("JavaTextFileBuffer.error.closeStream"), ex)); //$NON-NLS-1$
- }
- }
-
- setDocumentContent(fDocument, getFileContents(monitor), fEncoding);
- } catch (CoreException x) {
- fDocument= fManager.createEmptyDocument(getLocation());
- fStatus= x.getStatus();
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#commitFileBufferContent(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- String encoding= computeEncoding();
- try {
-
- byte[] bytes= fDocument.get().getBytes(encoding);
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- */
- if (fHasBOM && CHARSET_UTF_8.equals(encoding)) {
- int bomLength= IContentDescription.BOM_UTF_8.length;
- byte[] bytesWithBOM= new byte[bytes.length + bomLength];
- System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength);
- System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length);
- bytes= bytesWithBOM;
- }
-
- InputStream stream= new ByteArrayInputStream(bytes);
-
- if (fFile.exists()) {
-
- if (!overwrite)
- checkSynchronizationState();
-
-
- // here the file synchronizer should actually be removed and afterwards added again. However,
- // we are already inside an operation, so the delta is sent AFTER we have added the listener
- setFileContents(stream, overwrite, monitor);
- // set synchronization stamp to know whether the file synchronizer must become active
- fSynchronizationStamp= fFile.lastModified();
-
- // TODO if there is an annotation model update it here
-
- } else {
-
-// try {
-// monitor.beginTask("Saving", 2000); //$NON-NLS-1$
-// ContainerGenerator generator = new ContainerGenerator(fFile.getWorkspace(), fFile.getParent().getFullPath());
-// generator.generateContainer(new SubProgressMonitor(monitor, 1000));
-// fFile.create(stream, false, new SubProgressMonitor(monitor, 1000));
-// }
-// finally {
-// monitor.done();
-// }
-
- }
-
- } catch (UnsupportedEncodingException x) {
- String message= FileBuffersMessages.getFormattedString("ResourceTextFileBuffer.error.unsupported_encoding.message_arg", encoding); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- }
- }
-
- private String computeEncoding() {
- // User-defined encoding has first priority
- if (fExplicitEncoding != null)
- return fExplicitEncoding;
-
- // Probe content
- Reader reader= new BufferedReader(new StringReader(fDocument.get()));
- try {
- QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
- IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(reader, fFile.getName(), options);
- if (description != null) {
- String encoding= description.getCharset();
- if (encoding != null)
- return encoding;
- }
- } catch (IOException ex) {
- // try next strategy
- } finally {
- try {
- reader.close();
- } catch (IOException ex) {
- FileBuffersPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("ResourceTextFileBuffer.error.closeReader"), ex)); //$NON-NLS-1$
- }
- }
-
- // Use file's encoding if the file has a BOM
- if (fHasBOM)
- return fEncoding;
-
- // Use global default
- return fManager.getDefaultEncoding();
- }
-
- /**
- * Intitializes the given document with the given stream using the given encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @exception CoreException if the given stream can not be read
- */
- private void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException {
- Reader in= null;
- try {
-
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- * </p>
- */
- if (fHasBOM && CHARSET_UTF_8.equals(encoding))
- contentStream.read(new byte[IContentDescription.BOM_UTF_8.length]);
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
- StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
- char[] readBuffer= new char[READER_CHUNK_SIZE];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } catch (IOException x) {
- String msg= x.getMessage() == null ? "" : x.getMessage(); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, msg, x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /**
- * Checks whether the given file is synchronized with the the local file system.
- * If the file has been changed, a <code>CoreException</code> is thrown.
- *
- * @param file the file to check
- * @exception CoreException if file has been changed on the file system
- */
- private void checkSynchronizationState() throws CoreException {
- if (!isSynchronized()) {
- Status status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IResourceStatus.OUT_OF_SYNC_LOCAL, FileBuffersMessages.getString("FileBuffer.error.outOfSync"), null); //$NON-NLS-1$
- throw new CoreException(status);
- }
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
deleted file mode 100644
index d8acbd11282..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
+++ /dev/null
@@ -1,426 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-
-
-public abstract class ResourceFileBuffer extends AbstractFileBuffer {
-
- /**
- * Runnable encapsulating an element state change. This runnable ensures
- * that a element change failed message is sent out to the element state
- * listeners in case an exception occurred.
- */
- private class SafeFileChange implements Runnable {
-
- /**
- * Creates a new safe runnable for the given file.
- */
- public SafeFileChange() {
- }
-
- /**
- * Execute the change.
- * Subclass responsibility.
- *
- * @exception an exception in case of error
- */
- protected void execute() throws Exception {
- }
-
- /**
- * Does everything necessary prior to execution.
- */
- public void preRun() {
- fManager.fireStateChanging(ResourceFileBuffer.this);
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
-
- if (isDisposed()) {
- fManager.fireStateChangeFailed(ResourceFileBuffer.this);
- return;
- }
-
- try {
- execute();
- } catch (Exception x) {
- FileBuffersPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, "Exception when synchronizing", x)); //$NON-NLS-1$
- fManager.fireStateChangeFailed(ResourceFileBuffer.this);
- }
- }
- }
-
- /**
- * Synchronizes the document with external resource changes.
- */
- private class FileSynchronizer implements IResourceChangeListener, IResourceDeltaVisitor {
-
- /** A flag indicating whether this synchronizer is installed or not. */
- private boolean fIsInstalled= false;
-
- /**
- * Creates a new file synchronizer. Is not yet installed on a file.
- */
- public FileSynchronizer() {
- }
-
- /**
- * Installs the synchronizer on the file.
- */
- public void install() {
- fFile.getWorkspace().addResourceChangeListener(this);
- fIsInstalled= true;
- }
-
- /**
- * Uninstalls the synchronizer from the file.
- */
- public void uninstall() {
- fFile.getWorkspace().removeResourceChangeListener(this);
- fIsInstalled= false;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent e) {
- IResourceDelta delta= e.getDelta();
- try {
- if (delta != null && fIsInstalled)
- delta.accept(this);
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /*
- * @see IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
-
- if (delta != null && fFile.equals(delta.getResource())) {
-
- SafeFileChange fileChange= null;
-
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- if ((IResourceDelta.CONTENT & delta.getFlags()) != 0) {
- if (!isDisposed() && !fCanBeSaved && !isSynchronized()) {
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileContentChanged();
- }
- };
- }
- }
- break;
- case IResourceDelta.REMOVED:
- if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0) {
- final IPath path= delta.getMovedToPath();
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileMoved(path);
- }
- };
- } else {
- if (!isDisposed() && !fCanBeSaved) {
- fileChange= new SafeFileChange() {
- protected void execute() throws Exception {
- handleFileDeleted();
- }
- };
- }
- }
- break;
- }
-
- if (fileChange != null) {
- fileChange.preRun();
- fManager.execute(fileChange, fSynchronizationContextCount > 0);
- }
- }
-
- return true; // because we are sitting on files anyway
- }
- }
-
-
-
- /** The location */
- protected IPath fLocation;
- /** The element for which the info is stored */
- protected IFile fFile;
- /** How often the element has been connected */
- protected int fReferenceCount;
- /** Can the element be saved */
- protected boolean fCanBeSaved= false;
- /** Has element state been validated */
- protected boolean fIsStateValidated= false;
- /** The status of this element */
- protected IStatus fStatus;
- /** The file synchronizer. */
- protected FileSynchronizer fFileSynchronizer;
- /** The time stamp at which this buffer synchronized with the underlying file. */
- protected long fSynchronizationStamp= IFile.NULL_STAMP;
- /** How often the synchronization context has been requested */
- protected int fSynchronizationContextCount;
- /** The text file buffer manager */
- protected TextFileBufferManager fManager;
-
-
-
-
- public ResourceFileBuffer(TextFileBufferManager manager) {
- super();
- fManager= manager;
- }
-
- abstract protected void handleFileContentChanged();
-
- abstract protected void addFileBufferContentListeners();
-
- abstract protected void removeFileBufferContentListeners();
-
- abstract protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException;
-
- abstract protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException;
-
- public void create(IPath location, IProgressMonitor monitor) throws CoreException {
- IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
- if (file == null || !file.exists())
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("FileBuffer.error.fileDoesNotExist"), null)); //$NON-NLS-1$
-
- fLocation= location;
- fFile= file;
- fFileSynchronizer= new FileSynchronizer();
-
- refreshFile(monitor);
- initializeFileBufferContent(monitor);
- fSynchronizationStamp= fFile.getModificationStamp();
-
- addFileBufferContentListeners();
- }
-
- public void connect() {
- ++ fReferenceCount;
- if (fReferenceCount == 1)
- connected();
- }
-
- /**
- * Called when this file buffer has been connected. This is the case when
- * there is exactly one connection.
- * <p>
- * Clients may extend this method.
- */
- protected void connected() {
- fFileSynchronizer.install();
- }
-
- public void disconnect() throws CoreException {
- -- fReferenceCount;
- if (fReferenceCount == 0)
- disconnected();
- }
-
- /**
- * Called when this file buffer has been disconnected. This is the case when
- * the number of connections drops to <code>0</code>.
- * <p>
- * Clients may extend this method.
- */
- protected void disconnected() {
- if (fFileSynchronizer != null)
- fFileSynchronizer.uninstall();
- fFileSynchronizer= null;
- }
-
- /**
- * Returns whether this file buffer has already been disposed.
- *
- * @return <code>true</code> if already disposed, <code>false</code> otherwise
- */
- public boolean isDisposed() {
- return fFileSynchronizer == null;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getLocation()
- */
- public IPath getLocation() {
- return fLocation;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#commit(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- public void commit(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- if (!isDisposed() && fCanBeSaved) {
-
- fManager.fireStateChanging(this);
-
- try {
- commitFileBufferContent(monitor, overwrite);
- } catch (CoreException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- } catch (RuntimeException x) {
- fManager.fireStateChangeFailed(this);
- throw x;
- }
-
- fCanBeSaved= false;
- addFileBufferContentListeners();
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isDirty()
- */
- public boolean isDirty() {
- return fCanBeSaved;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isShared()
- */
- public boolean isShared() {
- return fReferenceCount > 1;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#validateState(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object)
- */
- public void validateState(IProgressMonitor monitor, Object computationContext) throws CoreException {
- if (!isDisposed() && !fIsStateValidated) {
-
- if (fFile.isReadOnly()) {
- IWorkspace workspace= fFile.getWorkspace();
- fStatus= workspace.validateEdit(new IFile[] { fFile }, computationContext);
- if (fStatus.isOK())
- handleFileContentChanged();
- }
- fIsStateValidated= true;
- fManager.fireStateValidationChanged(this, fIsStateValidated);
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isStateValidated()
- */
- public boolean isStateValidated() {
- return fIsStateValidated;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#resetStateValidation()
- */
- public void resetStateValidation() {
- if (fIsStateValidated) {
- fIsStateValidated= false;
- fManager.fireStateValidationChanged(this, fIsStateValidated);
- }
- }
-
- /**
- * Sends out the notification that the file serving as document input has been moved.
- *
- * @param newLocation the path of the new location of the file
- */
- protected void handleFileMoved(IPath newLocation) {
- fManager.fireUnderlyingFileMoved(this, newLocation);
- }
-
- /**
- * Sends out the notification that the file serving as document input has been deleted.
- */
- protected void handleFileDeleted() {
- fManager.fireUnderlyingFileDeleted(this);
- }
-
- /**
- * Refreshes the given file.
- */
- protected void refreshFile(IProgressMonitor monitor) {
- try {
- fFile.refreshLocal(IFile.DEPTH_INFINITE, monitor);
- } catch (OperationCanceledException x) {
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- */
- protected void handleCoreException(CoreException exception) {
- ILog log= FileBuffersPlugin.getDefault().getLog();
- log.log(exception.getStatus());
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#isSynchronized()
- */
- public boolean isSynchronized() {
- return fSynchronizationStamp == fFile.getModificationStamp() && fFile.isSynchronized(IResource.DEPTH_ZERO);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#getModificationStamp()
- */
- public long getModificationStamp() {
- File file= FileBuffers.getSystemFileAtLocation(getLocation());
- if (file != null)
- return file.lastModified();
- return IResource.NULL_STAMP;
- }
-
- /**
- * Requests the file buffer manager's synchronization context for this file buffer.
- */
- public void requestSynchronizationContext() {
- ++ fSynchronizationContextCount;
- }
-
- /**
- * Releases the file buffer manager's synchronization context for this file buffer.
- */
- public void releaseSynchronizationContext() {
- -- fSynchronizationContextCount;
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
deleted file mode 100644
index c1d7612acfc..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResourceStatus;
-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.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-
-import org.eclipse.core.filebuffers.IPersistableAnnotationModel;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-/**
- * @since 3.0
- */
-public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextFileBuffer {
-
-
- private class DocumentListener implements IDocumentListener {
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fCanBeSaved= true;
- removeFileBufferContentListeners();
- fManager.fireDirtyStateChanged(ResourceTextFileBuffer.this, fCanBeSaved);
- }
- }
-
- /**
- * Reader chunk size.
- */
- static final private int READER_CHUNK_SIZE= 2048;
- /**
- * Buffer size.
- */
- static final private int BUFFER_SIZE= 8 * READER_CHUNK_SIZE;
- /**
- * Qualified name for the encoding key.
- */
- static final private QualifiedName ENCODING_KEY= new QualifiedName(FileBuffersPlugin.PLUGIN_ID, "encoding"); //$NON-NLS-1$
- /**
- * Constant for representing the OK status. This is considered a value object.
- */
- static final private IStatus STATUS_OK= new Status(IStatus.OK, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("FileBuffer.status.ok"), null); //$NON-NLS-1$
- /**
- * Constant for representing the error status. This is considered a value object.
- */
- static final private IStatus STATUS_ERROR= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.INFO, FileBuffersMessages.getString("FileBuffer.status.error"), null); //$NON-NLS-1$
- /**
- * Constant denoting UTF-8 encoding.
- */
- private static final String CHARSET_UTF_8= "UTF-8"; //$NON-NLS-1$
-
-
- /** The element's document */
- protected IDocument fDocument;
- /** The encoding used to create the document from the storage or <code>null</code> for workbench encoding. */
- protected String fEncoding;
- /** Internal document listener */
- protected IDocumentListener fDocumentListener= new DocumentListener();
- /** The element's annotation model */
- protected IAnnotationModel fAnnotationModel;
- /**
- * The encoding which has explicitly been set on the file.
- */
- private String fExplicitEncoding;
- /**
- * Tells whether the file on disk has a BOM.
- */
- private boolean fHasBOM;
-
-
- public ResourceTextFileBuffer(TextFileBufferManager manager) {
- super(manager);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getDocument()
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBuffer#getAnnotationModel()
- */
- public IAnnotationModel getAnnotationModel() {
- return fAnnotationModel;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
- */
- public String getEncoding() {
- return fEncoding;
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedTextFile#setEncoding(java.lang.String)
- */
- public void setEncoding(String encoding) {
- fEncoding= encoding;
- fExplicitEncoding= encoding;
- fHasBOM= false;
- try {
- fFile.setCharset(encoding);
- if (encoding == null)
- fEncoding= fFile.getCharset();
- setHasBOM();
- } catch (CoreException x) {
- handleCoreException(x);
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFile#getStatus()
- */
- public IStatus getStatus() {
- if (!isDisposed()) {
- if (fStatus != null)
- return fStatus;
- return (fDocument == null ? STATUS_ERROR : STATUS_OK);
- }
- return STATUS_ERROR;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBuffer#revert(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void revert(IProgressMonitor monitor) throws CoreException {
- if (isDisposed())
- return;
-
- refreshFile(monitor);
-
- IDocument original= null;
- IStatus status= null;
-
- try {
- original= fManager.createEmptyDocument(fFile.getLocation());
- setDocumentContent(original, fFile.getContents(), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- fStatus= status;
-
- if (original != null) {
-
- String originalContents= original.get();
- boolean replaceContents= !originalContents.equals(fDocument.get());
-
- if (replaceContents) {
- fManager.fireBufferContentAboutToBeReplaced(this);
- fDocument.set(original.get());
- }
-
- if (fCanBeSaved) {
- fCanBeSaved= false;
- addFileBufferContentListeners();
- }
-
- if (replaceContents)
- fManager.fireBufferContentReplaced(this);
-
- if (fAnnotationModel instanceof IPersistableAnnotationModel) {
- IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
- persistableModel.revert(fDocument);
- }
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#addFileBufferContentListeners()
- */
- protected void addFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.addDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#removeFileBufferContentListeners()
- */
- protected void removeFileBufferContentListeners() {
- if (fDocument != null)
- fDocument.removeDocumentListener(fDocumentListener);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#initializeFileBufferContent(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void initializeFileBufferContent(IProgressMonitor monitor) throws CoreException {
- try {
- fEncoding= null;
- fExplicitEncoding= null;
- try {
- fEncoding= fFile.getPersistentProperty(ENCODING_KEY);
- } catch (CoreException x) {
- // we ignore exceptions here because we support the ENCODING_KEY property only for compatibility reasons
- }
- if (fEncoding != null) {
- // if we found an old encoding property, we try to migrate it to the new core.resources encoding support
- try {
- fExplicitEncoding= fEncoding;
- fFile.setCharset(fEncoding);
- // if successful delete old property
- fFile.setPersistentProperty(ENCODING_KEY, null);
- } catch (CoreException ex) {
- // log problem because we could not migrate the property successfully
- handleCoreException(ex);
- }
- } else {
- fExplicitEncoding= fFile.getCharset(false);
- if (fExplicitEncoding != null)
- fEncoding= fExplicitEncoding;
- else
- fEncoding= fFile.getCharset();
- }
-
- setHasBOM();
-
- fDocument= fManager.createEmptyDocument(fFile.getLocation());
- setDocumentContent(fDocument, fFile.getContents(), fEncoding);
-
- fAnnotationModel= fManager.createAnnotationModel(fFile.getLocation());
-
- } catch (CoreException x) {
- fDocument= fManager.createEmptyDocument(fFile.getLocation());
- fStatus= x.getStatus();
- }
- }
-
- /**
- * Sets whether the underlying file has a BOM.
- *
- * @throws CoreException if reading of file's content description fails
- */
- protected void setHasBOM() throws CoreException {
- fHasBOM= false;
- IContentDescription description= fFile.getContentDescription();
- fHasBOM= description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.ResourceFileBuffer#connected()
- */
- protected void connected() {
- super.connected();
- if (fAnnotationModel != null)
- fAnnotationModel.connect(fDocument);
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.ResourceFileBuffer#disconnected()
- */
- protected void disconnected() {
- if (fAnnotationModel != null)
- fAnnotationModel.disconnect(fDocument);
- super.disconnected();
- }
-
- /*
- * @see org.eclipse.core.internal.filebuffers.FileBuffer#commitFileBufferContent(org.eclipse.core.runtime.IProgressMonitor, boolean)
- */
- protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException {
- String encoding= computeEncoding();
- try {
-
- byte[] bytes= fDocument.get().getBytes(encoding);
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- */
- if (fHasBOM && CHARSET_UTF_8.equals(encoding)) {
- int bomLength= IContentDescription.BOM_UTF_8.length;
- byte[] bytesWithBOM= new byte[bytes.length + bomLength];
- System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength);
- System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length);
- bytes= bytesWithBOM;
- }
-
- InputStream stream= new ByteArrayInputStream(bytes);
- if (fFile.exists()) {
-
- if (!overwrite)
- checkSynchronizationState();
-
-
- // here the file synchronizer should actually be removed and afterwards added again. However,
- // we are already inside an operation, so the delta is sent AFTER we have added the listener
- fFile.setContents(stream, overwrite, true, monitor);
- // set synchronization stamp to know whether the file synchronizer must become active
- fSynchronizationStamp= fFile.getModificationStamp();
-
- if (fAnnotationModel instanceof IPersistableAnnotationModel) {
- IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
- persistableModel.commit(fDocument);
- }
-
- } else {
-
- try {
- monitor.beginTask("Saving", 2000); //$NON-NLS-1$
- ContainerGenerator generator = new ContainerGenerator(fFile.getWorkspace(), fFile.getParent().getFullPath());
- generator.generateContainer(new SubProgressMonitor(monitor, 1000));
- fFile.create(stream, false, new SubProgressMonitor(monitor, 1000));
- }
- finally {
- monitor.done();
- }
- }
-
- } catch (UnsupportedEncodingException x) {
- String message= FileBuffersMessages.getFormattedString("ResourceTextFileBuffer.error.unsupported_encoding.message_arg", encoding); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- }
- }
-
- private String computeEncoding() {
- // User-defined encoding has first priority
- if (fExplicitEncoding != null)
- return fExplicitEncoding;
- try {
- /*
- * FIXME
- * Check whether explicit encoding has been set via properties dialog.
- * This is needed because no notification is sent when this property
- * changes, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=64077
- */
- fExplicitEncoding= fFile.getCharset(false);
- if (fExplicitEncoding != null)
- return fExplicitEncoding;
- } catch (CoreException e) {
- }
-
- // Probe content
- Reader reader= new BufferedReader(new StringReader(fDocument.get()));
- try {
- QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
- IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(reader, fFile.getName(), options);
- if (description != null) {
- String encoding= description.getCharset();
- if (encoding != null)
- return encoding;
- }
- } catch (IOException ex) {
- // try next strategy
- } finally {
- try {
- reader.close();
- } catch (IOException ex) {
- FileBuffersPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getString("ResourceTextFileBuffer.error.closeReader"), ex)); //$NON-NLS-1$
- }
- }
-
- // Use file's encoding if the file has a BOM
- if (fHasBOM)
- return fEncoding;
-
- // Use parent chain
- try {
- return fFile.getParent().getDefaultCharset();
- } catch (CoreException ex) {
- // Use global default
- return fManager.getDefaultEncoding();
- }
- }
-
- /**
- * Updates the element info to a change of the file content and sends out appropriate notifications.
- */
- protected void handleFileContentChanged() {
- if (isDisposed())
- return;
-
- IDocument document= fManager.createEmptyDocument(fFile.getLocation());
- IStatus status= null;
-
- try {
- setDocumentContent(document, fFile.getContents(false), fEncoding);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- String newContent= document.get();
-
- if ( !newContent.equals(fDocument.get())) {
-
- fManager.fireBufferContentAboutToBeReplaced(this);
-
- removeFileBufferContentListeners();
- fDocument.set(newContent);
- fCanBeSaved= false;
- fSynchronizationStamp= fFile.getModificationStamp();
- fStatus= status;
- addFileBufferContentListeners();
-
- fManager.fireBufferContentReplaced(this);
-
- if (fAnnotationModel instanceof IPersistableAnnotationModel) {
- IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
- try {
- persistableModel.reinitialize(fDocument);
- } catch (CoreException x) {
- fStatus= status;
- }
- }
-
- } else {
-
- removeFileBufferContentListeners();
- fCanBeSaved= false;
- fSynchronizationStamp= fFile.getModificationStamp();
- fStatus= status;
- addFileBufferContentListeners();
-
- fManager.fireDirtyStateChanged(this, fCanBeSaved);
- }
- }
-
- /**
- * Intitializes the given document with the given stream using the given encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @exception CoreException if the given stream can not be read
- */
- private void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException {
- Reader in= null;
- try {
-
- if (encoding == null)
- encoding= fManager.getDefaultEncoding();
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- */
- if (fHasBOM && CHARSET_UTF_8.equals(encoding))
- contentStream.read(new byte[IContentDescription.BOM_UTF_8.length]);
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
- StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
- char[] readBuffer= new char[READER_CHUNK_SIZE];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } catch (IOException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /**
- * Checks whether the given file is synchronized with the the local file system.
- * If the file has been changed, a <code>CoreException</code> is thrown.
- *
- * @param file the file to check
- * @exception CoreException if file has been changed on the file system
- */
- private void checkSynchronizationState() throws CoreException {
- if (!fFile.isSynchronized(IFile.DEPTH_ZERO)) {
- Status status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IResourceStatus.OUT_OF_SYNC_LOCAL, FileBuffersMessages.getString("FileBuffer.error.outOfSync"), null); //$NON-NLS-1$
- throw new CoreException(status);
- }
- }
-}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
deleted file mode 100644
index c179f10286b..00000000000
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.filebuffers;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IAnnotationModelFactory;
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.IFileBufferListener;
-import org.eclipse.core.filebuffers.ISynchronizationContext;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-/**
- * @since 3.0
- */
-public class TextFileBufferManager implements ITextFileBufferManager {
-
- private Map fFilesBuffers= new HashMap();
- private List fFileBufferListeners= new ArrayList();
- private ExtensionsRegistry fRegistry;
- private ISynchronizationContext fSynchronizationContext;
-
-
- public TextFileBufferManager() {
- fRegistry= new ExtensionsRegistry();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#connect(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void connect(IPath location, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer == null) {
-
- fileBuffer= createFileBuffer(location);
- if (fileBuffer == null)
- throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, 0, FileBuffersMessages.getString("FileBufferManager.error.canNotCreateFilebuffer"), null)); //$NON-NLS-1$
-
- fileBuffer.create(location, monitor);
- fileBuffer.connect();
- fFilesBuffers.put(location, fileBuffer);
- fireBufferCreated(fileBuffer);
-
- } else {
- fileBuffer.connect();
- }
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#disconnect(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void disconnect(IPath location, IProgressMonitor monitor) throws CoreException {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null) {
- fileBuffer.disconnect();
- if (fileBuffer.isDisposed()) {
- fFilesBuffers.remove(location);
- fireBufferDisposed(fileBuffer);
- }
- }
- }
-
- private AbstractFileBuffer createFileBuffer(IPath location) {
- if (!isTextFile(location))
- return null;
-
- if (isWorkspaceResource(location))
- return new ResourceTextFileBuffer(this);
-
- return new JavaTextFileBuffer(this);
- }
-
- private boolean isWorkspaceResource(IPath location) {
- return FileBuffers.getWorkspaceFileAtLocation(location) != null;
- }
-
- private boolean isTextFile(IPath location) {
- return true;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#getFileBuffer(org.eclipse.core.runtime.IPath)
- */
- public IFileBuffer getFileBuffer(IPath location) {
- location= FileBuffers.normalizeLocation(location);
- return (IFileBuffer) fFilesBuffers.get(location);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBufferManager#getTextFileBuffer(org.eclipse.core.runtime.IPath)
- */
- public ITextFileBuffer getTextFileBuffer(IPath location) {
- location= FileBuffers.normalizeLocation(location);
- return (ITextFileBuffer) fFilesBuffers.get(location);
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileManager#getDefaultEncoding()
- */
- public String getDefaultEncoding() {
- return ResourcesPlugin.getEncoding();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBufferManager#createEmptyDocument(org.eclipse.core.runtime.IPath)
- */
- public IDocument createEmptyDocument(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- IDocumentFactory factory= fRegistry.getDocumentFactory(location);
-
- IDocument document= null;
- if (factory != null)
- document= factory.createDocument();
- else
- document= new Document();
-
- IDocumentSetupParticipant[] participants= fRegistry.getDocumentSetupParticipants(location);
- if (participants != null) {
- for (int i= 0; i < participants.length; i++)
- participants[i].setup(document);
- }
-
- return document;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.ITextFileBufferManager#createAnnotationModel(org.eclipse.core.runtime.IPath)
- */
- public IAnnotationModel createAnnotationModel(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
- IAnnotationModelFactory factory= fRegistry.getAnnotationModelFactory(location);
- if (factory != null)
- return factory.createAnnotationModel(location);
- return null;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#addFileBufferListener(org.eclipse.core.filebuffers.IFileBufferListener)
- */
- public void addFileBufferListener(IFileBufferListener listener) {
- Assert.isNotNull(listener);
- if (!fFileBufferListeners.contains(listener))
- fFileBufferListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#removeFileBufferListener(org.eclipse.core.filebuffers.IFileBufferListener)
- */
- public void removeFileBufferListener(IFileBufferListener listener) {
- Assert.isNotNull(listener);
- fFileBufferListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#setSynchronizationContext(org.eclipse.core.filebuffers.ISynchronizationContext)
- */
- public void setSynchronizationContext(ISynchronizationContext context) {
- fSynchronizationContext= context;
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#requestSynchronizationContext(org.eclipse.core.runtime.IPath)
- */
- public void requestSynchronizationContext(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null)
- fileBuffer.requestSynchronizationContext();
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferManager#releaseSynchronizationContext(org.eclipse.core.runtime.IPath)
- */
- public void releaseSynchronizationContext(IPath location) {
- Assert.isNotNull(location);
- location= FileBuffers.normalizeLocation(location);
-
- AbstractFileBuffer fileBuffer= (AbstractFileBuffer) fFilesBuffers.get(location);
- if (fileBuffer != null)
- fileBuffer.releaseSynchronizationContext();
- }
-
- /**
- * Executes the given runnable in the synchronization context of this file buffer manager.
- * If there is no synchronization context connected with this manager, the runnable is
- * directly executed.
- *
- * @param runnable the runnable to be executed
- */
- public void execute(Runnable runnable, boolean requestSynchronizationContext) {
- if (requestSynchronizationContext && fSynchronizationContext != null)
- fSynchronizationContext.run(runnable);
- else
- runnable.run();
- }
-
- protected void fireDirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.dirtyStateChanged(buffer, isDirty);
- }
- }
-
- protected void fireBufferContentAboutToBeReplaced(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferContentAboutToBeReplaced(buffer);
- }
- }
-
- protected void fireBufferContentReplaced(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferContentReplaced(buffer);
- }
- }
-
- protected void fireUnderlyingFileMoved(IFileBuffer buffer, IPath target) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.underlyingFileMoved(buffer, target);
- }
- }
-
- protected void fireUnderlyingFileDeleted(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.underlyingFileDeleted(buffer);
- }
- }
-
- protected void fireStateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateValidationChanged(buffer, isStateValidated);
- }
- }
-
- protected void fireStateChanging(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateChanging(buffer);
- }
- }
-
- protected void fireStateChangeFailed(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.stateChangeFailed(buffer);
- }
- }
-
- protected void fireBufferCreated(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferCreated(buffer);
- }
- }
-
- protected void fireBufferDisposed(IFileBuffer buffer) {
- Iterator e= new ArrayList(fFileBufferListeners).iterator();
- while (e.hasNext()) {
- IFileBufferListener l= (IFileBufferListener) e.next();
- l.bufferDisposed(buffer);
- }
- }
-}

Back to the top