Class DefaultTreeViewerCustomization
- java.lang.Object
-
- org.eclipse.emfforms.internal.swt.treemasterdetail.DefaultTreeViewerCustomization
-
- All Implemented Interfaces:
ContentProviderProvider
,Disposeable
,DNDProvider
,InitialSelectionProvider
,LabelDecoratorProvider
,LabelProviderProvider
,MenuProvider
,TreeReadOnlyProvider
,TreeViewerBuilder
,TreeViewerCustomization
,ViewerFilterProvider
- Direct Known Subclasses:
DefaultTreeMasterDetailCustomization
public class DefaultTreeViewerCustomization extends java.lang.Object implements TreeViewerCustomization
Default implementation of theTreeViewerCustomization
.- Author:
- Johannes Faltermeier
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeViewerCustomization()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.jface.viewers.TreeViewer
createTree(org.eclipse.swt.widgets.Composite parent)
This method is called to create theTreeViewer
.void
customizeMenu(java.util.Collection<MasterDetailAction> rightClickActions)
Sets the right click actions of the menu.void
customizeMenu(DeleteActionBuilder deleteActionBuilder)
Sets the delete action.void
customizeMenu(CreateElementCallback createElementCallback)
Sets theCreateElementCallback
.void
dispose()
Disposes the element.protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider
getAdapterFactoryContentProvider()
Returns theAdapterFactoryContentProvider
.protected org.eclipse.emf.edit.provider.ComposedAdapterFactory
getComposedAdapterFactory()
Gives access to the composed adapter factory.org.eclipse.jface.viewers.IContentProvider
getContentProvider()
Creates the content provider added to the treeviewer.org.eclipse.swt.dnd.DragSourceListener
getDragListener(org.eclipse.jface.viewers.TreeViewer treeViewer)
Returns theDragSourceListener
used to setup thedrag support
for the viewer.int
getDragOperations()
Returns the drag operations bits used to setup thedrag support
for the viewer.org.eclipse.swt.dnd.Transfer[]
getDragTransferTypes()
Returns the drag transfer types used to setup thedrag support
for the viewer.org.eclipse.swt.dnd.DropTargetListener
getDropListener(org.eclipse.emf.edit.domain.EditingDomain editingDomain, org.eclipse.jface.viewers.TreeViewer treeViewer)
Returns theDragSourceListener
used to setup thedrop support
for the viewer.int
getDropOperations()
Returns the drag operations bits used to setup thedrop support
for the viewer.org.eclipse.swt.dnd.Transfer[]
getDropTransferTypes()
Returns the drag transfer types used to setup thedrop support
for the viewer.org.eclipse.emf.ecore.EObject
getInitialSelection(java.lang.Object input)
Called to set the initial selection on the tree.Optional<org.eclipse.jface.viewers.ILabelDecorator>
getLabelDecorator(org.eclipse.jface.viewers.TreeViewer viewer)
Returns theILabelDecorator
to use.org.eclipse.jface.viewers.IBaseLabelProvider
getLabelProvider()
Creates the label provider added to the treeviewer.org.eclipse.swt.widgets.Menu
getMenu(org.eclipse.jface.viewers.TreeViewer treeViewer, org.eclipse.emf.edit.domain.EditingDomain editingDomain)
Returns the menu which will be added to the tree.org.eclipse.jface.viewers.ViewerFilter[]
getViewerFilters()
Creates the viewer filters added to the treeviewer.boolean
hasDND()
Whether DND support should be added to the tree.boolean
isReadOnly()
Returns whether the tree should be read-only.void
setContentProvider(ContentProviderProvider contentProvider)
Sets the content provider provider.void
setDragAndDrop(DNDProvider dnd)
Sets the d&d support.void
setInitialSelection(InitialSelectionProvider selection)
Sets the initial selection provider.void
setLabelDecorator(LabelDecoratorProvider decorator)
Sets the label decorator provider.void
setLabelProvider(LabelProviderProvider labelProvider)
Sets the label provider provider.void
setMenu(MenuProvider menu)
Sets the menu provider.void
setReadOnly(boolean readOnly)
Allows to set the tree as read-only.void
setTree(TreeViewerBuilder tree)
Sets the tree builder.void
setViewerFilters(ViewerFilterProvider filters)
Sets the viewer filter provider.
-
-
-
Method Detail
-
getComposedAdapterFactory
protected org.eclipse.emf.edit.provider.ComposedAdapterFactory getComposedAdapterFactory()
Gives access to the composed adapter factory.- Returns:
- the adapter factory
-
getAdapterFactoryContentProvider
protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider getAdapterFactoryContentProvider()
Returns theAdapterFactoryContentProvider
.- Returns:
- the content provider
-
createTree
public org.eclipse.jface.viewers.TreeViewer createTree(org.eclipse.swt.widgets.Composite parent)
Description copied from interface:TreeViewerBuilder
This method is called to create theTreeViewer
.- Specified by:
createTree
in interfaceTreeViewerBuilder
- Parameters:
parent
- theparent composite
- Returns:
- the viewer
-
hasDND
public boolean hasDND()
Description copied from interface:DNDProvider
Whether DND support should be added to the tree.- Specified by:
hasDND
in interfaceDNDProvider
- Returns:
true
if DND will be added, based on the other methods of this interface, orfalse
if DND should not be added
-
getDragOperations
public int getDragOperations()
Description copied from interface:DNDProvider
Returns the drag operations bits used to setup thedrag support
for the viewer.- Specified by:
getDragOperations
in interfaceDNDProvider
- Returns:
- the drag operations
-
getDragTransferTypes
public org.eclipse.swt.dnd.Transfer[] getDragTransferTypes()
Description copied from interface:DNDProvider
Returns the drag transfer types used to setup thedrag support
for the viewer.- Specified by:
getDragTransferTypes
in interfaceDNDProvider
- Returns:
- the drag
transfer types
-
getDragListener
public org.eclipse.swt.dnd.DragSourceListener getDragListener(org.eclipse.jface.viewers.TreeViewer treeViewer)
Description copied from interface:DNDProvider
Returns theDragSourceListener
used to setup thedrag support
for the viewer.- Specified by:
getDragListener
in interfaceDNDProvider
- Parameters:
treeViewer
- the treeviewer- Returns:
- the listener
-
getDropOperations
public int getDropOperations()
Description copied from interface:DNDProvider
Returns the drag operations bits used to setup thedrop support
for the viewer.- Specified by:
getDropOperations
in interfaceDNDProvider
- Returns:
- the drop operations
-
getDropTransferTypes
public org.eclipse.swt.dnd.Transfer[] getDropTransferTypes()
Description copied from interface:DNDProvider
Returns the drag transfer types used to setup thedrop support
for the viewer.- Specified by:
getDropTransferTypes
in interfaceDNDProvider
- Returns:
- the drop
transfer types
-
getDropListener
public org.eclipse.swt.dnd.DropTargetListener getDropListener(org.eclipse.emf.edit.domain.EditingDomain editingDomain, org.eclipse.jface.viewers.TreeViewer treeViewer)
Description copied from interface:DNDProvider
Returns theDragSourceListener
used to setup thedrop support
for the viewer.- Specified by:
getDropListener
in interfaceDNDProvider
- Parameters:
editingDomain
- the editing domaintreeViewer
- the treeviewer- Returns:
- the listener
-
getContentProvider
public org.eclipse.jface.viewers.IContentProvider getContentProvider()
Description copied from interface:ContentProviderProvider
Creates the content provider added to the treeviewer.- Specified by:
getContentProvider
in interfaceContentProviderProvider
- Returns:
- the content provider
-
getLabelProvider
public org.eclipse.jface.viewers.IBaseLabelProvider getLabelProvider()
Description copied from interface:LabelProviderProvider
Creates the label provider added to the treeviewer.- Specified by:
getLabelProvider
in interfaceLabelProviderProvider
- Returns:
- the label provider
-
getLabelDecorator
public Optional<org.eclipse.jface.viewers.ILabelDecorator> getLabelDecorator(org.eclipse.jface.viewers.TreeViewer viewer)
Description copied from interface:LabelDecoratorProvider
Returns theILabelDecorator
to use.- Specified by:
getLabelDecorator
in interfaceLabelDecoratorProvider
- Parameters:
viewer
- theTreeViewer
- Returns:
- the decorator or empty
-
getViewerFilters
public org.eclipse.jface.viewers.ViewerFilter[] getViewerFilters()
Description copied from interface:ViewerFilterProvider
Creates the viewer filters added to the treeviewer.- Specified by:
getViewerFilters
in interfaceViewerFilterProvider
- Returns:
- the filters
-
getInitialSelection
public org.eclipse.emf.ecore.EObject getInitialSelection(java.lang.Object input)
Description copied from interface:InitialSelectionProvider
Called to set the initial selection on the tree. This may benull
if no specific default selection should be set.- Specified by:
getInitialSelection
in interfaceInitialSelectionProvider
- Parameters:
input
- the input- Returns:
- the object to select or
null
-
getMenu
public org.eclipse.swt.widgets.Menu getMenu(org.eclipse.jface.viewers.TreeViewer treeViewer, org.eclipse.emf.edit.domain.EditingDomain editingDomain)
Description copied from interface:MenuProvider
Returns the menu which will be added to the tree.- Specified by:
getMenu
in interfaceMenuProvider
- Parameters:
treeViewer
- the treeviewereditingDomain
- the editing domain- Returns:
- the menu
-
dispose
public void dispose()
Description copied from interface:Disposeable
Disposes the element.- Specified by:
dispose
in interfaceDisposeable
-
setContentProvider
public void setContentProvider(ContentProviderProvider contentProvider)
Sets the content provider provider.- Parameters:
contentProvider
- the content provider
-
setDragAndDrop
public void setDragAndDrop(DNDProvider dnd)
Sets the d&d support.- Parameters:
dnd
- the dnd
-
setLabelProvider
public void setLabelProvider(LabelProviderProvider labelProvider)
Sets the label provider provider.- Parameters:
labelProvider
- the provider
-
setLabelDecorator
public void setLabelDecorator(LabelDecoratorProvider decorator)
Sets the label decorator provider.- Parameters:
decorator
- the provider
-
setMenu
public void setMenu(MenuProvider menu)
Sets the menu provider.- Parameters:
menu
- the provider
-
customizeMenu
public void customizeMenu(java.util.Collection<MasterDetailAction> rightClickActions)
Sets the right click actions of the menu.- Parameters:
rightClickActions
- the actions
-
customizeMenu
public void customizeMenu(CreateElementCallback createElementCallback)
Sets theCreateElementCallback
.- Parameters:
createElementCallback
- the callback
-
customizeMenu
public void customizeMenu(DeleteActionBuilder deleteActionBuilder)
Sets the delete action.- Parameters:
deleteActionBuilder
- the builder
-
setInitialSelection
public void setInitialSelection(InitialSelectionProvider selection)
Sets the initial selection provider.- Parameters:
selection
- the provider
-
setTree
public void setTree(TreeViewerBuilder tree)
Sets the tree builder.- Parameters:
tree
- the tree builder
-
setViewerFilters
public void setViewerFilters(ViewerFilterProvider filters)
Sets the viewer filter provider.- Parameters:
filters
- the provider
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:TreeReadOnlyProvider
Returns whether the tree should be read-only.- Specified by:
isReadOnly
in interfaceTreeReadOnlyProvider
- Returns:
true
if the tree is read-only
-
setReadOnly
public void setReadOnly(boolean readOnly)
Allows to set the tree as read-only. Default is false. Setting the tree as read-only has two consequences:- The tree's context menu is disabled
- Drag and drop is disabled
- Parameters:
readOnly
-true
to set as read-only
-
-