Class DetailViewManager
- java.lang.Object
-
- org.eclipse.emf.ecp.view.spi.swt.masterdetail.DetailViewManager
-
- All Implemented Interfaces:
DetailViewCache
public class DetailViewManager extends java.lang.Object implements DetailViewCache
A manager for the SWT renderings of detail views, with caching.- Since:
- 1.22
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DETAIL_PROPERTY
Name of a boolean-valued view model property indicating that the view model is being rendered as a detail in a master-detail presentation.-
Fields inherited from interface org.eclipse.emf.ecp.view.spi.swt.masterdetail.DetailViewCache
DETAIL_VIEW_CACHE_SIZE, EMPTY
-
-
Constructor Summary
Constructors Constructor Description DetailViewManager(org.eclipse.swt.widgets.Composite parent)
Initializes me.DetailViewManager(org.eclipse.swt.widgets.Composite parent, java.util.function.Function<? super org.eclipse.emf.ecore.EObject,? extends VView> detailView)
Initializes me with explicit detail views.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ECPSWTView
activate(org.eclipse.emf.ecore.EObject eObject)
Present the previously cached view for an object.void
cacheCurrentDetail()
Cache the currently presented detail view, if any, and remove it from the UI.boolean
cacheView(ECPSWTView ecpView)
Caches the providedECPSWTView
to allow it to be reused later, if there is room for it the cache.void
clear()
Dispose all cached views, emptying the cache.void
dispose()
Dispose of me and my UI resources.ECPSWTView
getCachedView(org.eclipse.emf.ecore.EObject selection)
Returns the previously cached view for the provided selection.ECPSWTView
getCurrentDetail()
Obtain the currently presented detail view.org.eclipse.swt.widgets.Control
getDetailContainer()
Obtain the control that contains the rendered details.VViewModelProperties
getDetailProperties()
Obtain the view-model properties used for loading the detail view model.VView
getDetailView(org.eclipse.emf.ecore.EObject object)
Obtain the detail view for anobject
selected in the master view.protected VView
getDetailView(org.eclipse.emf.ecore.EObject object, VViewModelProperties properties)
Get the view provided by the framework for details of the givenobject
.VView
getDetailView(ViewModelContext masterContext, org.eclipse.emf.ecore.EObject object)
Obtain the detail view in the context of the given master view-model context for a selectedobject
in the master view.VView
getDetailView(ViewModelContext masterContext, org.eclipse.emf.ecore.EObject object, java.util.function.Consumer<? super VViewModelProperties> propertiesManipulator)
Obtain the detail view in the context of the given master view-model context for a selectedobject
in the master view.protected ECPSWTView
getNoDetailsControl()
Obtain the renderer control showing a hint that there is no selection or no details for the current selection.protected VView
getNoDetailView()
Obtain a view to use as placeholder when the framework provides no view for the detail of the selection or when there is no selection.boolean
isCached(org.eclipse.emf.ecore.EObject selection)
Checks whether there is already a cached view available.boolean
isDisposed()
Queries whether I have been disposed.org.eclipse.swt.widgets.Composite
layoutDetailParent(org.eclipse.swt.widgets.Composite composite)
Apply a reasonable default layout for the parentcomposite
of a detail container where the only thing contained in that parent is the detail container.ECPSWTView
render(ViewModelContext masterContext, VElement masterView, org.eclipse.emf.ecore.EObject object)
Render the detail view for a givenobject
in the specified master context.ECPSWTView
render(ViewModelContext context, DetailRenderingFunction renderer)
Render the detail view for a givencontext
in the specifiedparent
composite.void
setCache(DetailViewCache cache)
Set the detail-view cache to use.void
setDetailReadOnly(boolean readOnly)
Set the current detail view read-only or not, unless it is intrinsically read-only, in which case it will remain so (this method will have no effect).void
setFocus()
Set focus to the currently presented detail view.void
setNoDetailMessage(java.lang.String noDetailMessage)
Set a message to display to the user when there is no detail to show, either because there is no selection in the master or because it has no details.
-
-
-
Field Detail
-
DETAIL_PROPERTY
public static final java.lang.String DETAIL_PROPERTY
Name of a boolean-valued view model property indicating that the view model is being rendered as a detail in a master-detail presentation. It is useful to distinguish this case in enablement/visibility rules, templates, etc. from the general case of a view rendering.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DetailViewManager
public DetailViewManager(org.eclipse.swt.widgets.Composite parent)
Initializes me.- Parameters:
parent
- the composite in which to create the detail container
-
DetailViewManager
public DetailViewManager(org.eclipse.swt.widgets.Composite parent, java.util.function.Function<? super org.eclipse.emf.ecore.EObject,? extends VView> detailView)
Initializes me with explicit detail views. When the detail function can provide a detail view, then the framework's pluggable view providers are not consulted for it.- Parameters:
parent
- the composite in which to create the detail containerdetailView
- the detail-view provider function
-
-
Method Detail
-
dispose
public void dispose()
Dispose of me and my UI resources.
-
isDisposed
public boolean isDisposed()
Queries whether I have been disposed.- Returns:
- whether I am disposed
-
getDetailContainer
public org.eclipse.swt.widgets.Control getDetailContainer()
Obtain the control that contains the rendered details. This is useful, for example, to set layout parameters on it in the context of its parent composite.- Returns:
- the container of the rendered details
-
setCache
public void setCache(DetailViewCache cache)
Set the detail-view cache to use. If some other cache was being used, any rendered controls that it maintained will be disposed.- Parameters:
cache
- theDetailViewCache
to use, ornull
to use no cache
-
activate
public ECPSWTView activate(org.eclipse.emf.ecore.EObject eObject)
Present the previously cached view for an object.- Parameters:
eObject
- the object to present- Returns:
- the re-rendered view
- Throws:
java.lang.IllegalStateException
- if there is no view cached for the object- See Also:
isCached(EObject)
-
render
public ECPSWTView render(ViewModelContext context, DetailRenderingFunction renderer)
Render the detail view for a givencontext
in the specifiedparent
composite. If a cached rendering is available for the domain model, then it is re-used and thecontext
is disposed. Otherwise, the supplied rendering function is used to render the detail view.- Parameters:
context
- the context to present in the detail viewrenderer
- if needed to render a new detail view control- Returns:
- the rendered view
-
render
public ECPSWTView render(ViewModelContext masterContext, VElement masterView, org.eclipse.emf.ecore.EObject object)
Render the detail view for a givenobject
in the specified master context.- Parameters:
masterContext
- the master context in which theobject
is selectedmasterView
- the master view in which context to render the detail viewobject
- the selected object for which to present the detail- Returns:
- the rendered view
-
getCurrentDetail
public final ECPSWTView getCurrentDetail()
Obtain the currently presented detail view.- Returns:
- the current rendered detail view, or
null
if none
-
cacheCurrentDetail
public void cacheCurrentDetail()
Cache the currently presented detail view, if any, and remove it from the UI.
-
setFocus
public void setFocus()
Set focus to the currently presented detail view.
-
getDetailProperties
public VViewModelProperties getDetailProperties()
Obtain the view-model properties used for loading the detail view model. Clients may update these properties but must not change thedetail property
.- Returns:
- the view-model properties for the detail view
-
getDetailView
public VView getDetailView(ViewModelContext masterContext, org.eclipse.emf.ecore.EObject object)
Obtain the detail view in the context of the given master view-model context for a selectedobject
in the master view.- Parameters:
masterContext
- the master view-model contextobject
- the selection in the master view for which to get a detail view- Returns:
- the detail view
-
getDetailView
public VView getDetailView(ViewModelContext masterContext, org.eclipse.emf.ecore.EObject object, java.util.function.Consumer<? super VViewModelProperties> propertiesManipulator)
Obtain the detail view in the context of the given master view-model context for a selectedobject
in the master view.- Parameters:
masterContext
- the master view-model contextobject
- the selection in the master view for which to get a detail viewpropertiesManipulator
- an optional hook with which to inject properties to assist/filter the detail view model resolution- Returns:
- the detail view
-
getDetailView
public VView getDetailView(org.eclipse.emf.ecore.EObject object)
Obtain the detail view for anobject
selected in the master view. This method is useful for master-detail presentations in which the master is not managed by a Form in aViewModelContext
but explicitly by some custom UI control.- Parameters:
object
- the master view selection- Returns:
- the detail view for the
object
-
setDetailReadOnly
public void setDetailReadOnly(boolean readOnly)
Set the current detail view read-only or not, unless it is intrinsically read-only, in which case it will remain so (this method will have no effect).- Parameters:
readOnly
-true
to set the detail view read-only;false
to let its intrinsic read-only state prevail
-
getDetailView
protected VView getDetailView(org.eclipse.emf.ecore.EObject object, VViewModelProperties properties)
Get the view provided by the framework for details of the givenobject
.- Parameters:
object
- the object for which to get the detail viewproperties
- the properties to use for loading the view- Returns:
- the detail view (never
null
, even if the framework provides nothing)
-
getNoDetailView
protected VView getNoDetailView()
Obtain a view to use as placeholder when the framework provides no view for the detail of the selection or when there is no selection.- Returns:
- the no-details placeholder view
-
getNoDetailsControl
protected ECPSWTView getNoDetailsControl()
Obtain the renderer control showing a hint that there is no selection or no details for the current selection.- Returns:
- the no-details control
-
layoutDetailParent
public org.eclipse.swt.widgets.Composite layoutDetailParent(org.eclipse.swt.widgets.Composite composite)
Apply a reasonable default layout for the parentcomposite
of a detail container where the only thing contained in that parent is the detail container.- Parameters:
composite
- the detail parent composite- Returns:
- the
composite
, for convenience of call chaining
-
setNoDetailMessage
public void setNoDetailMessage(java.lang.String noDetailMessage)
Set a message to display to the user when there is no detail to show, either because there is no selection in the master or because it has no details.- Parameters:
noDetailMessage
- the "no details" message to set, ornull
for the default localized string ("No selection or no details available for selection.")
-
isCached
public boolean isCached(org.eclipse.emf.ecore.EObject selection)
Description copied from interface:DetailViewCache
Checks whether there is already a cached view available.- Specified by:
isCached
in interfaceDetailViewCache
- Parameters:
selection
- The new master object selection- Returns:
true
if there is a cached view for the providedselection
;false
otherwise
-
getCachedView
public ECPSWTView getCachedView(org.eclipse.emf.ecore.EObject selection)
Description copied from interface:DetailViewCache
Returns the previously cached view for the provided selection.- Specified by:
getCachedView
in interfaceDetailViewCache
- Parameters:
selection
- The new master object selection- Returns:
- the cached view, or
null
if none is cached - See Also:
DetailViewCache.isCached(EObject)
-
cacheView
public boolean cacheView(ECPSWTView ecpView)
Description copied from interface:DetailViewCache
Caches the provided
ECPSWTView
to allow it to be reused later, if there is room for it the cache.Note that a view is cached when it is no longer required, usually because another detail view is taking its place in the editor. Consequently, if the cache is size-limited and cannot actually cache the view, it must dispose that view.
- Specified by:
cacheView
in interfaceDetailViewCache
- Parameters:
ecpView
- theECPSWTView
to cache- Returns:
true
if the view was added to the cache;false
otherwise (in which case it would be disposed)
-
clear
public void clear()
Description copied from interface:DetailViewCache
Dispose all cached views, emptying the cache. The cache must still be in a state to be used (this is not a "dispose" operation).- Specified by:
clear
in interfaceDetailViewCache
-
-