Class AbstractWorkbenchPanelPresenter<P extends AbstractWorkbenchPanelPresenter<P>>
- java.lang.Object
-
- org.uberfire.client.workbench.panels.impl.AbstractWorkbenchPanelPresenter<P>
-
- All Implemented Interfaces:
WorkbenchPanelPresenter
- Direct Known Subclasses:
AbstractDockingWorkbenchPanelPresenter,ImmutableWorkbenchPanelPresenter,LayoutPanelPresenter,SplitLayoutPanelPresenter,StaticWorkbenchPanelPresenter,TemplatedWorkbenchPanelPresenter,UnanchoredStaticWorkbenchPanelPresenter
public abstract class AbstractWorkbenchPanelPresenter<P extends AbstractWorkbenchPanelPresenter<P>> extends Object implements WorkbenchPanelPresenter
Basic implementation of common functionality in a panel presenter.At the least, concrete subclasses have to implement
asPresenterType()to returnthis. Subclasses may override other methods as necessary to customize behaviour for use with specialized layouts and view implementations.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<org.uberfire.workbench.model.Position,WorkbenchPanelPresenter>childPanelsprotected PerspectiveManagerperspectiveManager
-
Constructor Summary
Constructors Constructor Description AbstractWorkbenchPanelPresenter(WorkbenchPanelView<P> view, PerspectiveManager perspectiveManager)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddPanel(WorkbenchPanelPresenter child, org.uberfire.workbench.model.Position position)This base implementation should be sufficient for most panels.voidaddPart(WorkbenchPartPresenter part)voidaddPart(WorkbenchPartPresenter part, String contextId)Adds the given part to the view returned bygetPanelView(), ignoring the givencontextId.protected abstract PasPresenterType()Returns a reference tothis.voidchangeTitle(org.uberfire.workbench.model.PartDefinition part, String title, com.google.gwt.user.client.ui.IsWidget titleDecorator)StringgetDefaultChildType()Most panel types are their own default child type, so this implementation returnsgetClass().getName().org.uberfire.workbench.model.PanelDefinitiongetDefinition()Returns a@Portabledescription of the current state of this panel.Map<org.uberfire.workbench.model.Position,WorkbenchPanelPresenter>getPanels()Returns the immediate child panels of this panel.WorkbenchPanelView<P>getPanelView()Returns the view that was given to this panel when it was first created.WorkbenchPanelPresentergetParent()Returns the current parent of this panel presenter.Class<? extends WorkbenchPartPresenter>getPartType()Returns the type of new parts.voidmaximize()Makes this panel's view take up most of the space on the workbench.voidonResize(int width, int height)protected org.uberfire.workbench.model.PositionpositionOf(WorkbenchPanelPresenter child)booleanremovePanel(WorkbenchPanelPresenter child)Removes the given panel presenter and its view from this panel, freeing all resources associated with them.booleanremovePart(org.uberfire.workbench.model.PartDefinition part)Removes the given part from this panel, updating this panel's definition and the part's definition to reflect that the part no longer belongs to this panel.booleanselectPart(org.uberfire.workbench.model.PartDefinition part)voidsetDefinition(org.uberfire.workbench.model.PanelDefinition definition)Called by the framework when the panel instance is first created.voidsetFocus(boolean hasFocus)voidsetParent(WorkbenchPanelPresenter parent)Sets the current parent of this panel presenter.StringtoString()voidunmaximize()Restores this panel's view to its original unmaximized size and position.
-
-
-
Field Detail
-
perspectiveManager
protected final PerspectiveManager perspectiveManager
-
childPanels
protected final Map<org.uberfire.workbench.model.Position,WorkbenchPanelPresenter> childPanels
-
-
Constructor Detail
-
AbstractWorkbenchPanelPresenter
public AbstractWorkbenchPanelPresenter(WorkbenchPanelView<P> view, PerspectiveManager perspectiveManager)
-
-
Method Detail
-
asPresenterType
protected abstract P asPresenterType()
Returns a reference tothis. Helps superclass code work around generic type checking problems.
-
getParent
public WorkbenchPanelPresenter getParent()
Description copied from interface:WorkbenchPanelPresenterReturns the current parent of this panel presenter.- Specified by:
getParentin interfaceWorkbenchPanelPresenter- Returns:
- the parent panel presenter. If this panel is the root, or it is not attached to a parent, the return value is null.
-
setParent
public void setParent(WorkbenchPanelPresenter parent)
Description copied from interface:WorkbenchPanelPresenterSets the current parent of this panel presenter. This method should only be called by another WorkbenchPanelPresenter when adding or removing this panel as a child.- Specified by:
setParentin interfaceWorkbenchPanelPresenter- Parameters:
parent- the new parent of this panel. If this panel is being removed, the parent should be set to null.
-
getDefinition
public org.uberfire.workbench.model.PanelDefinition getDefinition()
Description copied from interface:WorkbenchPanelPresenterReturns a@Portabledescription of the current state of this panel.- Specified by:
getDefinitionin interfaceWorkbenchPanelPresenter
-
setDefinition
public void setDefinition(org.uberfire.workbench.model.PanelDefinition definition)
Description copied from interface:WorkbenchPanelPresenterCalled by the framework when the panel instance is first created. Application code should not call this method directly.- Specified by:
setDefinitionin interfaceWorkbenchPanelPresenter- Parameters:
definition- description of the state this panel should put itself in. This panel is also responsible for keeping the definition up to date with the panel's current state.
-
getDefaultChildType
public String getDefaultChildType()
Most panel types are their own default child type, so this implementation returnsgetClass().getName(). Subclasses can override if they prefer a different child type.- Specified by:
getDefaultChildTypein interfaceWorkbenchPanelPresenter- Returns:
- the fully-qualified class name of a WorkbenchPanelPresenter implementation. Returns null if this panel presenter does not allow child panels.
-
addPart
public void addPart(WorkbenchPartPresenter part)
CallsaddPart(org.uberfire.client.workbench.part.WorkbenchPartPresenter, String). Subclasses can take advantage of this by only overriding the 2-arg version.- Specified by:
addPartin interfaceWorkbenchPanelPresenter- Parameters:
part- the part to add. Must not be null, and must not currently belong to any panel.
-
addPart
public void addPart(WorkbenchPartPresenter part, String contextId)
Adds the given part to the view returned bygetPanelView(), ignoring the givencontextId. Subclasses that care about context id's will override this method.- Specified by:
addPartin interfaceWorkbenchPanelPresenter- Parameters:
part- the part to add. Must not be null, and must not currently belong to any panel.- See Also:
WorkbenchPanelPresenter.addPart(WorkbenchPartPresenter)
-
removePart
public boolean removePart(org.uberfire.workbench.model.PartDefinition part)
Description copied from interface:WorkbenchPanelPresenterRemoves the given part from this panel, updating this panel's definition and the part's definition to reflect that the part no longer belongs to this panel.- Specified by:
removePartin interfaceWorkbenchPanelPresenter- Returns:
- true if the given part was found and removed; false if this call had no effect
- See Also:
WorkbenchPanelPresenter.addPart(WorkbenchPartPresenter)
-
addPanel
public void addPanel(WorkbenchPanelPresenter child, org.uberfire.workbench.model.Position position)
This base implementation should be sufficient for most panels. It modifies the panel definition and adds the child view to this panel's view. In case the requested position is already in use for this panel, this method will throw anIllegalStateException. Subclasses may override and implement some other collision avoidance strategy.- Specified by:
addPanelin interfaceWorkbenchPanelPresenter- Parameters:
child- the panel to add. The presenter, its view, and its definition must not belong to any parent. As a side effect of this call (if the call is successful), the given presenter, its view, and its definition will get attached to their new parents.position- the position to add the child at. Different panel implementations support different position types.
-
removePanel
public boolean removePanel(WorkbenchPanelPresenter child)
Description copied from interface:WorkbenchPanelPresenterRemoves the given panel presenter and its view from this panel, freeing all resources associated with them.- Specified by:
removePanelin interfaceWorkbenchPanelPresenter- Parameters:
child- The child panel to remove. Must be a direct child of this panel, and must be empty (contain no parts or child panels). Null is not permitted.- Returns:
- true if the child was found and removed from this panel; false if the child panel could not be found.
-
getPanels
public Map<org.uberfire.workbench.model.Position,WorkbenchPanelPresenter> getPanels()
Description copied from interface:WorkbenchPanelPresenterReturns the immediate child panels of this panel. Note that panels and parts are not the same thing; this method only returns the panels.- Specified by:
getPanelsin interfaceWorkbenchPanelPresenter- Returns:
- an unmodifiable snapshot of the immediate child panels nested within this one. Never null, and will not update to reflect subsequent changes to this panel's children. Safe to iterate over when adding or removing child panels.
-
positionOf
protected org.uberfire.workbench.model.Position positionOf(WorkbenchPanelPresenter child)
-
changeTitle
public void changeTitle(org.uberfire.workbench.model.PartDefinition part, String title, com.google.gwt.user.client.ui.IsWidget titleDecorator)- Specified by:
changeTitlein interfaceWorkbenchPanelPresenter
-
setFocus
public void setFocus(boolean hasFocus)
- Specified by:
setFocusin interfaceWorkbenchPanelPresenter
-
selectPart
public boolean selectPart(org.uberfire.workbench.model.PartDefinition part)
- Specified by:
selectPartin interfaceWorkbenchPanelPresenter
-
maximize
public void maximize()
Description copied from interface:WorkbenchPanelPresenterMakes this panel's view take up most of the space on the workbench. The exact meaning of "maximize" is left to the implementation ofWorkbenchLayout.- Specified by:
maximizein interfaceWorkbenchPanelPresenter
-
unmaximize
public void unmaximize()
Description copied from interface:WorkbenchPanelPresenterRestores this panel's view to its original unmaximized size and position.- Specified by:
unmaximizein interfaceWorkbenchPanelPresenter
-
getPanelView
public WorkbenchPanelView<P> getPanelView()
Description copied from interface:WorkbenchPanelPresenterReturns the view that was given to this panel when it was first created.- Specified by:
getPanelViewin interfaceWorkbenchPanelPresenter
-
onResize
public void onResize(int width, int height)- Specified by:
onResizein interfaceWorkbenchPanelPresenter
-
getPartType
public Class<? extends WorkbenchPartPresenter> getPartType()
Description copied from interface:WorkbenchPanelPresenterReturns the type of new parts.- Specified by:
getPartTypein interfaceWorkbenchPanelPresenter
-
-