|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.runtime.PlatformObject
org.eclipse.jdt.internal.core.JavaElement
org.eclipse.jdt.internal.core.Openable
public abstract class Openable
Abstract class for implementations of java elements which are IOpenable.
IJavaElement
,
IOpenable
Field Summary |
---|
Fields inherited from class org.eclipse.jdt.internal.core.JavaElement |
---|
JEM_ANNOTATION, JEM_CLASSFILE, JEM_COMPILATIONUNIT, JEM_COUNT, JEM_ESCAPE, JEM_FIELD, JEM_IMPORTDECLARATION, JEM_INITIALIZER, JEM_JAVAPROJECT, JEM_LOCALVARIABLE, JEM_METHOD, JEM_PACKAGEDECLARATION, JEM_PACKAGEFRAGMENT, JEM_PACKAGEFRAGMENTROOT, JEM_TYPE, JEM_TYPE_PARAMETER |
Fields inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER |
Method Summary | |
---|---|
void |
bufferChanged(BufferChangedEvent event)
The buffer associated with this element has changed. |
boolean |
canBeRemovedFromCache()
|
boolean |
canBufferBeRemovedFromCache(IBuffer buffer)
|
boolean |
exists()
Returns whether this Java element exists in the model. |
java.lang.String |
findRecommendedLineSeparator()
Finds and returns the recommended line separator for this element. |
IBuffer |
getBuffer()
Note: a buffer with no unsaved changes can be closed by the Java Model since it has a finite number of buffers allowed open at one time. |
IBufferFactory |
getBufferFactory()
Deprecated. |
IResource |
getCorrespondingResource()
Return my underlying resource. |
IOpenable |
getOpenable()
Returns the first openable parent. |
PackageFragmentRoot |
getPackageFragmentRoot()
Find enclosing package fragment root if any |
IResource |
getResource()
Returns the innermost resource enclosing this element. |
IResource |
getUnderlyingResource()
Returns the smallest underlying resource that contains this element, or null if this element is not contained
in a resource. |
boolean |
hasUnsavedChanges()
Returns true if this element is open and:
its buffer has unsaved changes, or
one of its descendants has unsaved changes, or
a working copy has been created on one of this
element's children and has not yet destroyed
|
boolean |
isConsistent()
Subclasses must override as required. |
boolean |
isOpen()
Returns whether this openable is open. |
boolean |
isStructureKnown()
Returns whether the structure of this element is known. |
void |
makeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor)
Makes this element consistent with its underlying resource or buffer by updating the element's structure and properties as necessary. |
void |
open(org.eclipse.core.runtime.IProgressMonitor pm)
Opens this element and all parent elements that are not already open. |
IResource |
resource()
|
void |
save(org.eclipse.core.runtime.IProgressMonitor pm,
boolean force)
Saves any changes in this element's buffer to its underlying resource via a workspace resource operation. |
Methods inherited from class org.eclipse.core.runtime.PlatformObject |
---|
getAdapter |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.jdt.core.IOpenable |
---|
close |
Methods inherited from interface org.eclipse.jdt.core.IJavaElement |
---|
getElementType, getPath |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
---|
getAdapter |
Method Detail |
---|
public void bufferChanged(BufferChangedEvent event)
bufferChanged
in interface IBufferChangedListener
event
- the change eventIBufferChangedListener
public boolean canBeRemovedFromCache()
public boolean canBufferBeRemovedFromCache(IBuffer buffer)
public boolean exists()
IJavaElement
Java elements are handle objects that may or may not be backed by an
actual element. Java elements that are backed by an actual element are
said to "exist", and this method returns true
. For Java
elements that are not working copies, it is always the case that if the
element exists, then its parent also exists (provided it has one) and
includes the element as one of its children. It is therefore possible
to navigated to any existing Java element from the root of the Java model
along a chain of existing Java elements. On the other hand, working
copies are said to exist until they are destroyed (with
IWorkingCopy.destroy
). Unlike regular Java elements, a
working copy never shows up among the children of its parent element
(which may or may not exist).
exists
in interface IJavaElement
exists
in class JavaElement
true
if this element exists in the Java model, and
false
if this element does not existIJavaElement
public java.lang.String findRecommendedLineSeparator() throws JavaModelException
IOpenable
Platform.PREF_LINE_SEPARATOR
on this element's project or workspace is returned.
Finally if no such preference is set, the system line separator is returned.
findRecommendedLineSeparator
in interface IOpenable
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.public IBuffer getBuffer() throws JavaModelException
getBuffer
in interface IOpenable
null
if this element does not have a buffer
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IOpenable
public IBufferFactory getBufferFactory()
public IResource getCorrespondingResource() throws JavaModelException
getCorrespondingResource
in interface IJavaElement
null
if none
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElement
public IOpenable getOpenable()
IJavaElement
null
if this element doesn't have
an openable parent.
This is a handle-only method.
getOpenable
in interface IJavaElement
getOpenable
in class JavaElement
null
if this element doesn't have
an openable parent.public IResource getUnderlyingResource() throws JavaModelException
IJavaElement
null
if this element is not contained
in a resource.
getUnderlyingResource
in interface IJavaElement
null
if none
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its underlying resourceIJavaElement
public boolean hasUnsavedChanges() throws JavaModelException
IOpenable
true
if this element is open and:
hasUnsavedChanges
in interface IOpenable
true
if this element is open and:
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resource.IOpenable
public boolean isConsistent()
isConsistent
in interface IOpenable
IOpenable
public boolean isOpen()
IOpenable
isOpen
in interface IOpenable
IOpenable
public boolean isStructureKnown() throws JavaModelException
IJavaElement
false
is returned.
If the structure of an element is unknown, navigations will return reasonable
defaults. For example, getChildren
for a compilation unit with
syntax errors will return a collection of the children that could be parsed.
Note: This does not imply anything about consistency with the underlying resource/buffer contents.
isStructureKnown
in interface IJavaElement
true
if the structure of this element is known
JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceIJavaElement
public void makeConsistent(org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
IOpenable
Note: Using this functionality on a working copy will interfere with any
subsequent reconciling operation. Indeed, the next
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
or
ICompilationUnit.reconcile(int, boolean, boolean, WorkingCopyOwner, IProgressMonitor)
operation will not account for changes which occurred before an
explicit use of IOpenable.makeConsistent(IProgressMonitor)
makeConsistent
in interface IOpenable
monitor
- the given progress monitor
JavaModelException
- if the element is unable to access the contents
of its underlying resource. Reasons include:
IOpenable
public void open(org.eclipse.core.runtime.IProgressMonitor pm) throws JavaModelException
IOpenable
Note: although IOpenable.open(org.eclipse.core.runtime.IProgressMonitor)
is exposed in the API, clients are
not expected to open and close elements - the Java model does this automatically
as elements are accessed.
open
in interface IOpenable
pm
- the given progress monitor
JavaModelException
- if an error occurs accessing the contents
of its underlying resource. Reasons include:
IOpenable
public IResource getResource()
IJavaElement
null
is returned.
This is a handle-only method.
getResource
in interface IJavaElement
getResource
in class JavaElement
null
if this
element is included in an external archivepublic IResource resource()
resource
in class JavaElement
public void save(org.eclipse.core.runtime.IProgressMonitor pm, boolean force) throws JavaModelException
IOpenable
The force
parameter controls how this method deals with
cases where the workbench is not completely in sync with the local file system.
If false
is specified, this method will only attempt
to overwrite a corresponding file in the local file system provided
it is in sync with the workbench. This option ensures there is no
unintended data loss; it is the recommended setting.
However, if true
is specified, an attempt will be made
to write a corresponding file in the local file system,
overwriting any existing one if need be.
In either case, if this method succeeds, the resource will be marked
as being local (even if it wasn't before).
As a result of this operation, the element is consistent with its underlying resource or buffer.
save
in interface IOpenable
pm
- the given progress monitorforce
- it controls how this method deals with
cases where the workbench is not completely in sync with the local file system
JavaModelException
- if an error occurs accessing the contents
of its underlying resource. Reasons include:
IOpenable
public PackageFragmentRoot getPackageFragmentRoot()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |