public class StructureRootNode extends DocumentRangeNode implements IDisposable, ITypedElement
StructureCreator
.
This node performs the following tasks tasks:
ISharedDocumentAdapter
that provides the proper
document key (@see getAdapter(Class)
).IStructureCreator.save(IStructureComparator, Object)
when nodeChanged(DocumentRangeNode)
is called.IDisposable
provided in the constructor when
dispose()
is called.This class may be subclassed by clients.
Modifier and Type | Field and Description |
---|---|
static String |
ROOT_ID
The string constant (value
"root" ) that is used as the id of the root node. |
static int |
ROOT_TYPE
The integer constant (value
0 ) that is used as the type code of the root node. |
FOLDER_TYPE, TEXT_TYPE, UNKNOWN_TYPE
RANGE_CATEGORY
Constructor and Description |
---|
StructureRootNode(IDocument document,
Object input,
StructureCreator creator,
ISharedDocumentAdapter adapter)
Create the structure root node.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes of this service.
|
Object |
getAdapter(Class adapter)
Override
IAdaptable.getAdapter(Class) in order to provide
an ISharedDocumentAdapter that provides the proper look up key based
on the input from which this structure node was created. |
Image |
getImage()
Returns an image for this object.
|
String |
getName()
Returns the name of this object.
|
String |
getType()
Returns the type of this object.
|
boolean |
isReadOnly()
Return whether the typed element being displayed
is read-only. a read-only element will require a
call to validateEdit before the element can be modified on disk.
|
protected void |
nodeChanged(DocumentRangeNode node)
Override in order to invoke
IStructureCreator.save(IStructureComparator, Object) when the
contents of a node have changed. |
ITypedElement |
replace(ITypedElement child,
ITypedElement other)
This method is called on a parent to add or remove a child,
or to copy the contents of a child.
|
IStatus |
validateEdit(Shell shell)
If the element is read-only, this method should be called
to attempt to make it writable.
|
addChild, equals, getAppendPosition, getCharset, getChildren, getContents, getDocument, getId, getParentNode, getRange, getTypeCode, hashCode, internalSetContents, isEditable, setAppendPosition, setContent, setId, setLength
public static final int ROOT_TYPE
0
) that is used as the type code of the root node.public static final String ROOT_ID
"root"
) that is used as the id of the root node.DocumentRangeNode.getId()
,
Constant Field Valuespublic StructureRootNode(IDocument document, Object input, StructureCreator creator, ISharedDocumentAdapter adapter)
document
- the documentinput
- the input associated with the documentcreator
- the structure creator that is creating the nodeadapter
- the shared document adapter from which the document was obtained or null
if the document was not obtained from an ISharedDocumentAdapter
public void dispose()
IDisposable
dispose
in interface IDisposable
public Object getAdapter(Class adapter)
IAdaptable.getAdapter(Class)
in order to provide
an ISharedDocumentAdapter
that provides the proper look up key based
on the input from which this structure node was created.getAdapter
in interface IAdaptable
getAdapter
in class DocumentRangeNode
adapter
- the adapter class to look upnull
IAdaptable.getAdapter(Class)
protected void nodeChanged(DocumentRangeNode node)
IStructureCreator.save(IStructureComparator, Object)
when the
contents of a node have changed.nodeChanged
in class DocumentRangeNode
node
- the changed nodepublic ITypedElement replace(ITypedElement child, ITypedElement other)
IEditableContent
add: | dest == null | src != null |
remove: | dest != null | src == null |
copy: | dest != null | src != null |
replace
in interface IEditableContent
replace
in class DocumentRangeNode
child
- the existing child of this object to be replaced; if null
a new child can be added.other
- the new child to be added or replaced; if null
an existing child can be removed.dest
public Image getImage()
ITypedElement
getImage
in interface ITypedElement
null
if this type of input has no imagepublic String getName()
ITypedElement
getName
in interface ITypedElement
public String getType()
ITypedElement
FOLDER_TYPE
.
The type is used for determining a suitable viewer for this object.getType
in interface ITypedElement
public boolean isReadOnly()
IEditableContentExtension
isReadOnly
in interface IEditableContentExtension
isReadOnly
in class DocumentRangeNode
public IStatus validateEdit(Shell shell)
IEditableContentExtension
validateEdit
in interface IEditableContentExtension
validateEdit
in class DocumentRangeNode
shell
- a shell used to prompt the user if required.OK
if things are fine,
otherwise a status describing reasons why modifying the given files is not
reasonable. A status with a severity of CANCEL
is returned
if the validation was canceled, indicating the edit should not proceed.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.