Package com.iizigo.prop
Class TreeItemNavigatorPresentation
- java.lang.Object
- com.iizigo.prop.TreeItemNavigatorPresentation
- All Implemented Interfaces:
INavigatorPresentation
,java.lang.Cloneable
- Direct Known Subclasses:
MemberTreeItemNavigatorPresentation
public class TreeItemNavigatorPresentation extends java.lang.Object implements INavigatorPresentation, java.lang.Cloneable
Class wrapping an item for the filtered common viewer.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description java.lang.Object
attachment
Fields inherited from interface com.iizigo.navigator.INavigatorPresentation
CN_PREFERENCE_FLAGS_NAME, DEFAULT_COMPARATOR, EMPTY_ARRAY, FLAG_ADD_FILE_ITEM_PACKAGE_LOCATION, FLAG_ADD_FILE_ITEM_PROJECT, FLAG_ADD_FOLDER_PACKAGE_LOCATION, FLAG_ADD_FOLDER_PROJECT, FLAG_CUSTOM_1, FLAG_CUSTOM_2, FLAG_CUSTOM_3, FLAG_JAVA_SUPPORT, FLAG_PACKAGE_VIEW, FLAG_SHOW_DESIGNER_PROPERTIES, FLAG_SHOW_EMPTY_MODULE_FOLDERS, FLAG_SHOW_EMPTY_PACKAGES, FLAG_SHOW_FILE_ITEMS, FLAG_SHOW_SUBPROPERTIES, FLAGS_NORMAL, FLAGS_ONLY_FOLDERS
Constructor Summary
Constructors Constructor Description TreeItemNavigatorPresentation(java.lang.String text)
Constructs the viewer wrapper.TreeItemNavigatorPresentation(java.lang.String text, java.lang.Object parent)
Constructs the viewer wrapper.TreeItemNavigatorPresentation(java.lang.String text, org.eclipse.swt.graphics.Image image)
Constructs the viewer wrapper.TreeItemNavigatorPresentation(java.lang.String text, org.eclipse.swt.graphics.Image image, java.lang.Object parent)
Constructs the viewer wrapper.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(java.lang.Object child)
Adds a child.TreeItemNavigatorPresentation
clone()
Clones the instance.boolean
contains(java.lang.Object child)
Checks if a child is present.int
getCNCategory()
Gets the category of this Common Navigator object, used for sorting.java.lang.Object[]
getCNChildren(int flags)
Gets the children of this container for Common Navigator.IViewerComparator
getCNComparator()
Get theComparator
object to sort the children for the Common Navigator when presented visually in the tree.java.lang.String
getCNDescription(int flags)
Provide a description for the status bar view, if available.org.eclipse.swt.graphics.Image
getCNImage(int flags)
Gets the image for the Common Navigator.org.eclipse.swt.graphics.Image
getCNImage(int columnIndex, int flags)
Gets the image for the Common Tree Viewer showing column contents.java.lang.Object
getCNParent(int flags)
Gets the parent for Common Navigator.org.eclipse.jface.viewers.StyledString
getCNStyledText(int flags)
Gets the label text for the Common Navigator.java.lang.String
getCNText(int flags)
Gets the label text for the Common Navigator.java.lang.String
getCNText(int columnIndex, int flags)
Gets the label text for the Common Navigator.java.lang.String
getText()
Gets the text.boolean
hasCNChildren(int level)
Returns whether the given element has children for the Common Navigator.void
removeAllChildren()
Removes all children.boolean
removeChild(java.lang.Object child)
Removes a child.void
setAdditionalText(java.lang.String text)
Sets an additional text to display.void
setParent(java.lang.Object parent)
Sets the parent.void
sortChildren(boolean recursive, java.text.Collator collator)
Sorts this nodes children of type INavigatorPresentation according to their text.
Constructor Detail
TreeItemNavigatorPresentation
public TreeItemNavigatorPresentation(java.lang.String text)
Constructs the viewer wrapper.
TreeItemNavigatorPresentation
public TreeItemNavigatorPresentation(java.lang.String text, org.eclipse.swt.graphics.Image image)
Constructs the viewer wrapper.
TreeItemNavigatorPresentation
public TreeItemNavigatorPresentation(java.lang.String text, org.eclipse.swt.graphics.Image image, java.lang.Object parent)
Constructs the viewer wrapper.
TreeItemNavigatorPresentation
public TreeItemNavigatorPresentation(java.lang.String text, java.lang.Object parent)
Constructs the viewer wrapper.
Method Detail
clone
public TreeItemNavigatorPresentation clone()
Clones the instance.- Overrides:
clone
in classjava.lang.Object
setParent
public void setParent(java.lang.Object parent)
Sets the parent.
addChild
public void addChild(java.lang.Object child)
Adds a child.
removeChild
public boolean removeChild(java.lang.Object child)
Removes a child.- Returns:
- true for removed, false for not found.
contains
public boolean contains(java.lang.Object child)
Checks if a child is present.
removeAllChildren
public void removeAllChildren()
Removes all children.
getText
public java.lang.String getText()
Gets the text.
setAdditionalText
public void setAdditionalText(java.lang.String text)
Sets an additional text to display.
getCNParent
public java.lang.Object getCNParent(int flags)
Gets the parent for Common Navigator.- Specified by:
getCNParent
in interfaceINavigatorPresentation
- Parameters:
flags
- The flag that apply is FLAG_PACKAGE_VIEW.- Returns:
- The parent object: IProject or DesignerProp, or null if no parent exists (property is not added to a container).
getCNCategory
public int getCNCategory()
Gets the category of this Common Navigator object, used for sorting. Subclasses can override this method, in order to get the sorting in the viewer to be done within a category.- Specified by:
getCNCategory
in interfaceINavigatorPresentation
- Returns:
- This method returns 1000 integer value, i.e. "last" in sort order.
getCNComparator
public IViewerComparator getCNComparator()
Get theComparator
object to sort the children for the Common Navigator when presented visually in the tree.Subclasses are invited to override this method for other sorting schemes.
- Specified by:
getCNComparator
in interfaceINavigatorPresentation
- Returns:
- The default comparator. Subclasses can inhibit sorting by returning null.
hasCNChildren
public boolean hasCNChildren(int level)
Returns whether the given element has children for the Common Navigator.- Specified by:
hasCNChildren
in interfaceINavigatorPresentation
- Parameters:
level
- The flags: FLAG_PACKAGE_VIEW, FLAG_SHOW_EMPTY_MAIN_FOLDER, FLAG_SHOW_EMPTY_PACKAGES, FLAG_SHOW_FILE_ITEMS, FLAG_SHOW_DESIGNER_PROPERTIES and FLAG_SHOW_SUBPROPERTIES are relevant.- Returns:
true
if the node has children, andfalse
if it has no children.
getCNChildren
public java.lang.Object[] getCNChildren(int flags)
Description copied from interface:INavigatorPresentation
Gets the children of this container for Common Navigator.- Specified by:
getCNChildren
in interfaceINavigatorPresentation
- Parameters:
flags
- The flags: FLAG_PACKAGE_VIEW, FLAG_SHOW_EMPTY_MAIN_FOLDER, FLAG_SHOW_EMPTY_PACKAGES, FLAG_SHOW_FILE_ITEMS, FLAG_SHOW_DESIGNER_PROPERTIES and FLAG_SHOW_SUBPROPERTIES are relevant.- Returns:
- An array of children objects or EMPTY_ARRAY for none.
getCNImage
public org.eclipse.swt.graphics.Image getCNImage(int flags)
Gets the image for the Common Navigator.- Specified by:
getCNImage
in interfaceINavigatorPresentation
- Parameters:
flags
- The flags for the image, see FLAG_IMAGE_*.- Returns:
- Image or
null
if there is no image.
getCNImage
public org.eclipse.swt.graphics.Image getCNImage(int columnIndex, int flags)
Gets the image for the Common Tree Viewer showing column contents.- Specified by:
getCNImage
in interfaceINavigatorPresentation
- Parameters:
columnIndex
- The zero-based index for the column (zero is never used, the method getCNImage() is called instead.flags
- The flags for the image, see FLAG_IMAGE_*.- Returns:
- Image or
null
if there is no image for the given object at columnIndex.
getCNText
public java.lang.String getCNText(int flags)
Gets the label text for the Common Navigator.- Specified by:
getCNText
in interfaceINavigatorPresentation
- Returns:
- String or or
null
if there is no text.
getCNText
public java.lang.String getCNText(int columnIndex, int flags)
Gets the label text for the Common Navigator.- Specified by:
getCNText
in interfaceINavigatorPresentation
- Parameters:
columnIndex
- The zero-based index for the column (zero is never used, the method getCNText() is called instead.- Returns:
- String or or
null
if there is no text for the given object at columnIndex.
getCNStyledText
public org.eclipse.jface.viewers.StyledString getCNStyledText(int flags)
Gets the label text for the Common Navigator.- Specified by:
getCNStyledText
in interfaceINavigatorPresentation
- Parameters:
flags
- The flags that apply are FLAG_ADD_FOLDER_PACKAGE_LOCATION, FLAG_ADD_FILE_ITEM_PACKAGE_LOCATION, FLAG_ADD_FOLDER_PROJECT and FLAG_ADD_FILE_ITEM_PROJECT.
getCNDescription
public java.lang.String getCNDescription(int flags)
Provide a description for the status bar view, if available. A default string of the form "(x) items selected" will be used if this method choose to return null.The empty string ("") will be respected as a valid value if returned. Return null if the extension defers to the default method of supplying status bar descriptions.
- Specified by:
getCNDescription
in interfaceINavigatorPresentation
- Returns:
- A description for the status bar view, or null if not available.
sortChildren
public void sortChildren(boolean recursive, java.text.Collator collator)
Sorts this nodes children of type INavigatorPresentation according to their text.- Parameters:
recursive
- Flag for recurse or not.collator
- The collator, null for default.