Class PanelManagerImpl
- java.lang.Object
-
- org.uberfire.client.workbench.PanelManagerImpl
-
- All Implemented Interfaces:
PanelManager
@ApplicationScoped public class PanelManagerImpl extends Object implements PanelManager
Standard implementation ofPanelManager.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.uberfire.workbench.model.PartDefinitionactivePartprotected Map<org.uberfire.workbench.model.PanelDefinition,com.google.gwt.user.client.ui.HasWidgets>customPanelsRemembers which HasWidgets contains each existing custom panel.protected Map<org.uberfire.workbench.model.PanelDefinition,elemental2.dom.HTMLElement>customPanelsInsideElemental2HTMLElementsRemembers which Elemental2 HTMLElements contain each existing custom panel.protected Map<org.uberfire.workbench.model.PanelDefinition,org.jboss.errai.common.client.dom.HTMLElement>customPanelsInsideHTMLElementsRemembers which HTMLElements contain each existing custom panel.protected org.jboss.errai.ioc.client.container.SyncBeanManageriocManagerprotected Map<org.uberfire.workbench.model.PanelDefinition,WorkbenchPanelPresenter>mapPanelDefinitionToPresenterprotected Map<org.uberfire.workbench.model.PartDefinition,WorkbenchPartPresenter>mapPartDefinitionToPresenterprotected javax.enterprise.event.Event<PanelFocusEvent>panelFocusEventprotected javax.enterprise.event.Event<PlaceGainFocusEvent>placeGainFocusEventprotected javax.enterprise.event.Event<PlaceHiddenEvent>placeHiddenEventprotected javax.enterprise.event.Event<PlaceLostFocusEvent>placeLostFocusEventprotected javax.enterprise.inject.Instance<PlaceManager>placeManagerprotected javax.enterprise.event.Event<PlaceMaximizedEvent>placeMaximizedEventprotected javax.enterprise.event.Event<PlaceMinimizedEvent>placeMinimizedEventprotected org.uberfire.workbench.model.PanelDefinitionrootPanelDefDescription that the current root panel was created from.protected javax.enterprise.event.Event<SelectPlaceEvent>selectPlaceEvent
-
Constructor Summary
Constructors Constructor Description PanelManagerImpl(javax.enterprise.event.Event<PlaceGainFocusEvent> placeGainFocusEvent, javax.enterprise.event.Event<PlaceLostFocusEvent> placeLostFocusEvent, javax.enterprise.event.Event<PanelFocusEvent> panelFocusEvent, javax.enterprise.event.Event<SelectPlaceEvent> selectPlaceEvent, javax.enterprise.event.Event<PlaceMaximizedEvent> placeMaximizedEvent, javax.enterprise.event.Event<PlaceMinimizedEvent> placeMinimizedEventEvent, javax.enterprise.event.Event<PlaceHiddenEvent> placeHiddenEvent, org.jboss.errai.ioc.client.container.SyncBeanManager iocManager, javax.enterprise.inject.Instance<PlaceManager> placeManager, LayoutSelection layoutSelection, BeanFactory beanFactory, org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil elemental2DomUtil)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.uberfire.workbench.model.CustomPanelDefinitionaddCustomPanel(com.google.gwt.user.client.ui.HasWidgets container, String panelType)Creates an UberFire panel and installs its view in the given widget container.org.uberfire.workbench.model.CustomPanelDefinitionaddCustomPanel(elemental2.dom.HTMLElement container, String panelType)Creates an UberFire panel and installs its view in the given html element container.org.uberfire.workbench.model.CustomPanelDefinitionaddCustomPanel(org.jboss.errai.common.client.dom.HTMLElement container, String panelType)Creates an UberFire panel and installs its view in the given html element container.org.uberfire.workbench.model.PanelDefinitionaddWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition targetPanel, org.uberfire.workbench.model.PanelDefinition childPanel, org.uberfire.workbench.model.Position position)Adds the given child panel to the given target panel at the given position within the target.org.uberfire.workbench.model.PanelDefinitionaddWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition targetPanel, org.uberfire.workbench.model.Position position, Integer height, Integer width, Integer minHeight, Integer minWidth)Adds an empty child panel of the target panel's default child type at the given position within the target panel.voidaddWorkbenchPart(org.uberfire.mvp.PlaceRequest place, org.uberfire.workbench.model.PartDefinition partDef, org.uberfire.workbench.model.PanelDefinition panelDef, org.uberfire.workbench.model.menu.Menus menus, UIPart uiPart, String contextId, Integer preferredWidth, Integer preferredHeight)Adds the given part to the given panel, which must already be part of the visible workbench layout.voidclosePart(org.uberfire.workbench.model.PartDefinition part)Closes the given part.protected BeanFactorygetBeanFactory()org.uberfire.workbench.model.PartDefinitiongetFocusedPart()org.uberfire.workbench.model.PanelDefinitiongetPanelForPlace(org.uberfire.mvp.PlaceRequest place)Returns the first PanelDefinition whose place matches the given one.protected org.uberfire.workbench.model.PartDefinitiongetPartForPlace(org.uberfire.mvp.PlaceRequest place)Returns the first live (associated with an active presenter) PartDefinition whose place matches the given one.org.uberfire.workbench.model.PanelDefinitiongetRoot()Returns the description of the entire panel + part tree that makes up the UI in its current state.voidonPanelFocus(org.uberfire.workbench.model.PanelDefinition panel)Gives focus to the given panel, if it is known to this PanelManager.voidonPartFocus(org.uberfire.workbench.model.PartDefinition part)voidonPartHidden(org.uberfire.workbench.model.PartDefinition part)voidonPartLostFocus()voidonPartMaximized(org.uberfire.workbench.model.PartDefinition part)voidonPartMinimized(org.uberfire.workbench.model.PartDefinition part)protected voidremovePart(org.uberfire.workbench.model.PartDefinition part)Destroys the presenter bean associated with the given part and removes the part's presenter from the panel presenter that contains it (which in turn removes the part definition from the panel definition and the part view from the panel view).booleanremovePartForPlace(org.uberfire.mvp.PlaceRequest toRemove)Removes the part associated with the given PlaceRequest from the panel that contains it.voidremoveWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition toRemove)Removes the panel associated with the given definition, removing the panel's presenter and view from the workbench, and freeing any resources associated with them.voidsetRoot(PerspectiveActivity activity, org.uberfire.workbench.model.PanelDefinition root)Clears all existing panel structure from the user interface, then installs a new root panel according to the specifications in the givenPanelDefinition.
-
-
-
Field Detail
-
mapPartDefinitionToPresenter
protected final Map<org.uberfire.workbench.model.PartDefinition,WorkbenchPartPresenter> mapPartDefinitionToPresenter
-
mapPanelDefinitionToPresenter
protected final Map<org.uberfire.workbench.model.PanelDefinition,WorkbenchPanelPresenter> mapPanelDefinitionToPresenter
-
customPanels
protected final Map<org.uberfire.workbench.model.PanelDefinition,com.google.gwt.user.client.ui.HasWidgets> customPanels
Remembers which HasWidgets contains each existing custom panel. Items are removed from this map when the panels are closed/removed.
-
customPanelsInsideHTMLElements
protected final Map<org.uberfire.workbench.model.PanelDefinition,org.jboss.errai.common.client.dom.HTMLElement> customPanelsInsideHTMLElements
Remembers which HTMLElements contain each existing custom panel. Items are removed from this map when the panels are closed/removed.
-
customPanelsInsideElemental2HTMLElements
protected final Map<org.uberfire.workbench.model.PanelDefinition,elemental2.dom.HTMLElement> customPanelsInsideElemental2HTMLElements
Remembers which Elemental2 HTMLElements contain each existing custom panel. Items are removed from this map when the panels are closed/removed.
-
placeGainFocusEvent
protected javax.enterprise.event.Event<PlaceGainFocusEvent> placeGainFocusEvent
-
placeLostFocusEvent
protected javax.enterprise.event.Event<PlaceLostFocusEvent> placeLostFocusEvent
-
panelFocusEvent
protected javax.enterprise.event.Event<PanelFocusEvent> panelFocusEvent
-
selectPlaceEvent
protected javax.enterprise.event.Event<SelectPlaceEvent> selectPlaceEvent
-
placeMaximizedEvent
protected javax.enterprise.event.Event<PlaceMaximizedEvent> placeMaximizedEvent
-
placeMinimizedEvent
protected javax.enterprise.event.Event<PlaceMinimizedEvent> placeMinimizedEvent
-
placeHiddenEvent
protected javax.enterprise.event.Event<PlaceHiddenEvent> placeHiddenEvent
-
iocManager
protected org.jboss.errai.ioc.client.container.SyncBeanManager iocManager
-
placeManager
protected javax.enterprise.inject.Instance<PlaceManager> placeManager
-
rootPanelDef
protected org.uberfire.workbench.model.PanelDefinition rootPanelDef
Description that the current root panel was created from. Presently, this is a mutable data structure and the whole UF framework tries to keep this in sync with the reality (syncing each change from DOM -> Widget -> UberView -> Presenter -> Definition). This may change in the future. See UF-117.
-
activePart
protected org.uberfire.workbench.model.PartDefinition activePart
-
-
Constructor Detail
-
PanelManagerImpl
@Inject public PanelManagerImpl(javax.enterprise.event.Event<PlaceGainFocusEvent> placeGainFocusEvent, javax.enterprise.event.Event<PlaceLostFocusEvent> placeLostFocusEvent, javax.enterprise.event.Event<PanelFocusEvent> panelFocusEvent, javax.enterprise.event.Event<SelectPlaceEvent> selectPlaceEvent, javax.enterprise.event.Event<PlaceMaximizedEvent> placeMaximizedEvent, javax.enterprise.event.Event<PlaceMinimizedEvent> placeMinimizedEventEvent, javax.enterprise.event.Event<PlaceHiddenEvent> placeHiddenEvent, org.jboss.errai.ioc.client.container.SyncBeanManager iocManager, javax.enterprise.inject.Instance<PlaceManager> placeManager, LayoutSelection layoutSelection, BeanFactory beanFactory, org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil elemental2DomUtil)
-
-
Method Detail
-
getBeanFactory
protected BeanFactory getBeanFactory()
-
getRoot
public org.uberfire.workbench.model.PanelDefinition getRoot()
Description copied from interface:PanelManagerReturns the description of the entire panel + part tree that makes up the UI in its current state.- Specified by:
getRootin interfacePanelManager
-
setRoot
public void setRoot(PerspectiveActivity activity, org.uberfire.workbench.model.PanelDefinition root)
Description copied from interface:PanelManagerClears all existing panel structure from the user interface, then installs a new root panel according to the specifications in the givenPanelDefinition. Only installs the root panel; does not build the child panel/part structure recursively.- Specified by:
setRootin interfacePanelManagerroot- description of the new root panel to install. Must not be null.
-
addWorkbenchPart
public void addWorkbenchPart(org.uberfire.mvp.PlaceRequest place, org.uberfire.workbench.model.PartDefinition partDef, org.uberfire.workbench.model.PanelDefinition panelDef, org.uberfire.workbench.model.menu.Menus menus, UIPart uiPart, String contextId, Integer preferredWidth, Integer preferredHeight)Description copied from interface:PanelManagerAdds the given part to the given panel, which must already be part of the visible workbench layout. Fires aSelectPlaceEventwith the givenPlaceRequestonce the part has been added.- Specified by:
addWorkbenchPartin interfacePanelManager- Parameters:
place- The PlaceRequest that the part was resolved from. Not null.partDef- The description of the part to add. Not null.panelDef- definition of the panel to add the part to (must describe a panel that is already present in the layout). Not null.menus- The menus to display for the given part. Null means no menus.uiPart- The part's title and physical view. Not null.contextId- part of a removed framework feature (TODO: remove this?)preferredWidth- minimum pixel width of the part's activity, or null if there is no known minimum width. The target panel will expand to the this width if the panel is not already at least as wide, and only if it supports resizing on the horizontal axis.preferredHeight- minimum pixel height of the part's activity, or null if there is no known minimum height. The target panel will expand to this height if the panel is not already at least as tall, and only if it supports resizing on the vertical axis.
-
removePartForPlace
public boolean removePartForPlace(org.uberfire.mvp.PlaceRequest toRemove)
Description copied from interface:PanelManagerRemoves the part associated with the given PlaceRequest from the panel that contains it. If this operation removes the last part from the panel, and the panel is not the root panel, it will be removed from the workbench layout. Child panels are preserved by reparenting them to the removed panel's parent. Application code should not call this method directly; it is called by PlaceManager as part of the overall procedure in closing a place.- Specified by:
removePartForPlacein interfacePanelManager- Parameters:
toRemove- the place that is closing. Must not be null.- Returns:
- true if the associated part was found and removed; false if no matching part could be found.
-
addWorkbenchPanel
public org.uberfire.workbench.model.PanelDefinition addWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition targetPanel, org.uberfire.workbench.model.Position position, Integer height, Integer width, Integer minHeight, Integer minWidth)Description copied from interface:PanelManagerAdds an empty child panel of the target panel's default child type at the given position within the target panel. The new child panel will have the given dimensions and minimum sizes set on it.TODO: the usefulness of this method to callers is questionable (versus creating a new child panel definition and calling
PanelManager.addWorkbenchPanel(PanelDefinition, PanelDefinition, Position)). candidate for deletion.- Specified by:
addWorkbenchPanelin interfacePanelManager
-
removeWorkbenchPanel
public void removeWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition toRemove) throws IllegalStateExceptionDescription copied from interface:PanelManagerRemoves the panel associated with the given definition, removing the panel's presenter and view from the workbench, and freeing any resources associated with them. The panel must have no parts and no child panels.- Specified by:
removeWorkbenchPanelin interfacePanelManager- Parameters:
toRemove- the panel to remove from the workbench layout. Must not be null.- Throws:
IllegalStateException- if the panel contains parts or child panels
-
onPartFocus
public void onPartFocus(org.uberfire.workbench.model.PartDefinition part)
- Specified by:
onPartFocusin interfacePanelManager
-
onPartMaximized
public void onPartMaximized(org.uberfire.workbench.model.PartDefinition part)
- Specified by:
onPartMaximizedin interfacePanelManager- Parameters:
part- the part that has been maximized
-
onPartMinimized
public void onPartMinimized(org.uberfire.workbench.model.PartDefinition part)
- Specified by:
onPartMinimizedin interfacePanelManager- Parameters:
part- the part that has been minimized
-
getFocusedPart
public org.uberfire.workbench.model.PartDefinition getFocusedPart()
- Specified by:
getFocusedPartin interfacePanelManager- Returns:
- the focused
PartDefinition
-
onPartHidden
public void onPartHidden(org.uberfire.workbench.model.PartDefinition part)
- Specified by:
onPartHiddenin interfacePanelManager- Parameters:
part- that has been hidden
-
onPartLostFocus
public void onPartLostFocus()
- Specified by:
onPartLostFocusin interfacePanelManager
-
onPanelFocus
public void onPanelFocus(org.uberfire.workbench.model.PanelDefinition panel)
Description copied from interface:PanelManagerGives focus to the given panel, if it is known to this PanelManager. Also removes focus from all other panels associated with this PanelManager.- Specified by:
onPanelFocusin interfacePanelManager- Parameters:
panel- the panel to give focus to. May be null, in which case all panels will lose focus.
-
closePart
public void closePart(org.uberfire.workbench.model.PartDefinition part)
Description copied from interface:PanelManagerCloses the given part. This is a convenience method for placeManager.closePlace(part.getPlace()).- Specified by:
closePartin interfacePanelManager- Parameters:
part- the part to close (remove from the GUI). Must not be null.
-
getPanelForPlace
public org.uberfire.workbench.model.PanelDefinition getPanelForPlace(org.uberfire.mvp.PlaceRequest place)
Description copied from interface:PanelManagerReturns the first PanelDefinition whose place matches the given one.- Specified by:
getPanelForPlacein interfacePanelManager- Returns:
- the definition for the panel servicing the given place, or null if no such part can be found.
-
getPartForPlace
protected org.uberfire.workbench.model.PartDefinition getPartForPlace(org.uberfire.mvp.PlaceRequest place)
Returns the first live (associated with an active presenter) PartDefinition whose place matches the given one.- Returns:
- the definition for the live part servicing the given place, or null if no such part can be found.
-
removePart
protected void removePart(org.uberfire.workbench.model.PartDefinition part)
Destroys the presenter bean associated with the given part and removes the part's presenter from the panel presenter that contains it (which in turn removes the part definition from the panel definition and the part view from the panel view).- Parameters:
part- the definition of the workbench part (screen or editor) to remove from the layout.
-
addWorkbenchPanel
public org.uberfire.workbench.model.PanelDefinition addWorkbenchPanel(org.uberfire.workbench.model.PanelDefinition targetPanel, org.uberfire.workbench.model.PanelDefinition childPanel, org.uberfire.workbench.model.Position position)Description copied from interface:PanelManagerAdds the given child panel to the given target panel at the given position within the target. Upon successful completion of this method, the child panel will have a new parent panel. ItsPanelDefinition,WorkbenchPanelPresenter, andWorkbenchPanelViewand those of its new parent will be updated to reflect the new relationship. Note that the given target panel will not necessarily be the new parent: panel implementations may choose to avoid collisions (more than one child panel in the same position) by redirecting requests to add children.- Specified by:
addWorkbenchPanelin interfacePanelManager
-
addCustomPanel
public org.uberfire.workbench.model.CustomPanelDefinition addCustomPanel(com.google.gwt.user.client.ui.HasWidgets container, String panelType)Description copied from interface:PanelManagerCreates an UberFire panel and installs its view in the given widget container.Custom Panel Lifecycle
Custom panels can be disposed like any other panel: by calling
PanelManager.removeWorkbenchPanel(PanelDefinition). Additionally, custom panels are monitored for DOM detachment. When a custom panel's view is removed from the DOM (whether directly removed from its parent or some ancestor is removed,) all the panel's parts are closed and then the associated panel is disposed.- Specified by:
addCustomPanelin interfacePanelManager- Parameters:
container- the widget container to install the new panel in. The new panel will fill the container.- Returns:
- the definition for the newly constructed panel. Never null. The panel's type will be
panelType; its parent will be null;isRoot()will return false.
-
addCustomPanel
public org.uberfire.workbench.model.CustomPanelDefinition addCustomPanel(org.jboss.errai.common.client.dom.HTMLElement container, String panelType)Description copied from interface:PanelManagerCreates an UberFire panel and installs its view in the given html element container.Custom Panel Lifecycle
Custom panels can be disposed like any other panel: by calling
PanelManager.removeWorkbenchPanel(PanelDefinition). Additionally, custom panels are monitored for DOM detachment. When a custom panel's view is removed from the DOM (whether directly removed from its parent or some ancestor is removed,) all the panel's parts are closed and then the associated panel is disposed.- Specified by:
addCustomPanelin interfacePanelManager- Parameters:
container- the html element container to install the new panel in. The new panel will fill the container.- Returns:
- the definition for the newly constructed panel. Never null. The panel's type will be
panelType; its parent will be null;isRoot()will return false.
-
addCustomPanel
public org.uberfire.workbench.model.CustomPanelDefinition addCustomPanel(elemental2.dom.HTMLElement container, String panelType)Description copied from interface:PanelManagerCreates an UberFire panel and installs its view in the given html element container.Custom Panel Lifecycle
Custom panels can be disposed like any other panel: by calling
PanelManager.removeWorkbenchPanel(PanelDefinition). Additionally, custom panels are monitored for DOM detachment. When a custom panel's view is removed from the DOM (whether directly removed from its parent or some ancestor is removed,) all the panel's parts are closed and then the associated panel is disposed.- Specified by:
addCustomPanelin interfacePanelManager- Parameters:
container- the html element container to install the new panel in. The new panel will fill the container.- Returns:
- the definition for the newly constructed panel. Never null. The panel's type will be
panelType; its parent will be null;isRoot()will return false.
-
-