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.TreeViewercreateTree(org.eclipse.swt.widgets.Composite parent)This method is called to create theTreeViewer.voidcustomizeMenu(java.util.Collection<MasterDetailAction> rightClickActions)Sets the right click actions of the menu.voidcustomizeMenu(DeleteActionBuilder deleteActionBuilder)Sets the delete action.voidcustomizeMenu(CreateElementCallback createElementCallback)Sets theCreateElementCallback.voiddispose()Disposes the element.protected org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvidergetAdapterFactoryContentProvider()Returns theAdapterFactoryContentProvider.protected org.eclipse.emf.edit.provider.ComposedAdapterFactorygetComposedAdapterFactory()Gives access to the composed adapter factory.org.eclipse.jface.viewers.IContentProvidergetContentProvider()Creates the content provider added to the treeviewer.org.eclipse.swt.dnd.DragSourceListenergetDragListener(org.eclipse.jface.viewers.TreeViewer treeViewer)Returns theDragSourceListenerused to setup thedrag supportfor the viewer.intgetDragOperations()Returns the drag operations bits used to setup thedrag supportfor the viewer.org.eclipse.swt.dnd.Transfer[]getDragTransferTypes()Returns the drag transfer types used to setup thedrag supportfor the viewer.org.eclipse.swt.dnd.DropTargetListenergetDropListener(org.eclipse.emf.edit.domain.EditingDomain editingDomain, org.eclipse.jface.viewers.TreeViewer treeViewer)Returns theDragSourceListenerused to setup thedrop supportfor the viewer.intgetDropOperations()Returns the drag operations bits used to setup thedrop supportfor the viewer.org.eclipse.swt.dnd.Transfer[]getDropTransferTypes()Returns the drag transfer types used to setup thedrop supportfor the viewer.org.eclipse.emf.ecore.EObjectgetInitialSelection(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 theILabelDecoratorto use.org.eclipse.jface.viewers.IBaseLabelProvidergetLabelProvider()Creates the label provider added to the treeviewer.org.eclipse.swt.widgets.MenugetMenu(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.booleanhasDND()Whether DND support should be added to the tree.booleanisReadOnly()Returns whether the tree should be read-only.voidsetContentProvider(ContentProviderProvider contentProvider)Sets the content provider provider.voidsetDragAndDrop(DNDProvider dnd)Sets the d&d support.voidsetInitialSelection(InitialSelectionProvider selection)Sets the initial selection provider.voidsetLabelDecorator(LabelDecoratorProvider decorator)Sets the label decorator provider.voidsetLabelProvider(LabelProviderProvider labelProvider)Sets the label provider provider.voidsetMenu(MenuProvider menu)Sets the menu provider.voidsetReadOnly(boolean readOnly)Allows to set the tree as read-only.voidsetTree(TreeViewerBuilder tree)Sets the tree builder.voidsetViewerFilters(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:TreeViewerBuilderThis method is called to create theTreeViewer.- Specified by:
createTreein interfaceTreeViewerBuilder- Parameters:
parent- theparent composite- Returns:
- the viewer
-
hasDND
public boolean hasDND()
Description copied from interface:DNDProviderWhether DND support should be added to the tree.- Specified by:
hasDNDin interfaceDNDProvider- Returns:
trueif DND will be added, based on the other methods of this interface, orfalseif DND should not be added
-
getDragOperations
public int getDragOperations()
Description copied from interface:DNDProviderReturns the drag operations bits used to setup thedrag supportfor the viewer.- Specified by:
getDragOperationsin interfaceDNDProvider- Returns:
- the drag operations
-
getDragTransferTypes
public org.eclipse.swt.dnd.Transfer[] getDragTransferTypes()
Description copied from interface:DNDProviderReturns the drag transfer types used to setup thedrag supportfor the viewer.- Specified by:
getDragTransferTypesin interfaceDNDProvider- Returns:
- the drag
transfer types
-
getDragListener
public org.eclipse.swt.dnd.DragSourceListener getDragListener(org.eclipse.jface.viewers.TreeViewer treeViewer)
Description copied from interface:DNDProviderReturns theDragSourceListenerused to setup thedrag supportfor the viewer.- Specified by:
getDragListenerin interfaceDNDProvider- Parameters:
treeViewer- the treeviewer- Returns:
- the listener
-
getDropOperations
public int getDropOperations()
Description copied from interface:DNDProviderReturns the drag operations bits used to setup thedrop supportfor the viewer.- Specified by:
getDropOperationsin interfaceDNDProvider- Returns:
- the drop operations
-
getDropTransferTypes
public org.eclipse.swt.dnd.Transfer[] getDropTransferTypes()
Description copied from interface:DNDProviderReturns the drag transfer types used to setup thedrop supportfor the viewer.- Specified by:
getDropTransferTypesin 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:DNDProviderReturns theDragSourceListenerused to setup thedrop supportfor the viewer.- Specified by:
getDropListenerin interfaceDNDProvider- Parameters:
editingDomain- the editing domaintreeViewer- the treeviewer- Returns:
- the listener
-
getContentProvider
public org.eclipse.jface.viewers.IContentProvider getContentProvider()
Description copied from interface:ContentProviderProviderCreates the content provider added to the treeviewer.- Specified by:
getContentProviderin interfaceContentProviderProvider- Returns:
- the content provider
-
getLabelProvider
public org.eclipse.jface.viewers.IBaseLabelProvider getLabelProvider()
Description copied from interface:LabelProviderProviderCreates the label provider added to the treeviewer.- Specified by:
getLabelProviderin interfaceLabelProviderProvider- Returns:
- the label provider
-
getLabelDecorator
public Optional<org.eclipse.jface.viewers.ILabelDecorator> getLabelDecorator(org.eclipse.jface.viewers.TreeViewer viewer)
Description copied from interface:LabelDecoratorProviderReturns theILabelDecoratorto use.- Specified by:
getLabelDecoratorin interfaceLabelDecoratorProvider- Parameters:
viewer- theTreeViewer- Returns:
- the decorator or empty
-
getViewerFilters
public org.eclipse.jface.viewers.ViewerFilter[] getViewerFilters()
Description copied from interface:ViewerFilterProviderCreates the viewer filters added to the treeviewer.- Specified by:
getViewerFiltersin interfaceViewerFilterProvider- Returns:
- the filters
-
getInitialSelection
public org.eclipse.emf.ecore.EObject getInitialSelection(java.lang.Object input)
Description copied from interface:InitialSelectionProviderCalled to set the initial selection on the tree. This may benullif no specific default selection should be set.- Specified by:
getInitialSelectionin 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:MenuProviderReturns the menu which will be added to the tree.- Specified by:
getMenuin interfaceMenuProvider- Parameters:
treeViewer- the treeviewereditingDomain- the editing domain- Returns:
- the menu
-
dispose
public void dispose()
Description copied from interface:DisposeableDisposes the element.- Specified by:
disposein 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:TreeReadOnlyProviderReturns whether the tree should be read-only.- Specified by:
isReadOnlyin interfaceTreeReadOnlyProvider- Returns:
trueif 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-trueto set as read-only
-
-