public class PartServiceImpl extends java.lang.Object implements EPartService
EPartService.EPartService.PartState| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PART_ACTIVATION_TIME
The part activation time of a part is stored in it's transient data.
|
ACTIVE_ON_CLOSE_TAG, REMOVE_ON_HIDE_TAG| Constructor and Description |
|---|
PartServiceImpl(MApplication application,
MWindow window) |
| Modifier and Type | Method and Description |
|---|---|
void |
activate(MPart part)
Activates the given part.
|
void |
activate(MPart part,
boolean requiresFocus)
Activates the given part.
|
MPart |
addPart(MPart part) |
void |
addPartListener(IPartListener listener)
Adds the given listener for part lifecycle events.
|
void |
bringToTop(MPart part)
Brings this part to the top so that it will become visible to the end user.
|
MPart |
createPart(java.lang.String id)
Creates a new part of the given id.
|
MPlaceholder |
createSharedPart(java.lang.String id)
Creates a new placeholder for a part of the given id.
|
MPlaceholder |
createSharedPart(java.lang.String id,
boolean force)
Creates a new placeholder for a part of the given id.
|
MPart |
findPart(java.lang.String id)
Finds and returns a part with the given id.
|
MPart |
getActivePart()
Returns the active part.
|
java.util.Collection<MPart> |
getDirtyParts()
Returns a collection of all the dirty parts that are being managed by this service.
|
java.util.Collection<MInputPart> |
getInputParts(java.lang.String inputUri)
Deprecated.
|
java.util.Collection<MPart> |
getParts()
Returns a collection of all the parts that are being managed by this part service.
|
void |
hidePart(MPart part)
Hides the given part.
|
void |
hidePart(MPart part,
boolean force)
Hides the given part.
|
boolean |
isPartOrPlaceholderInPerspective(java.lang.String elementId,
MPerspective perspective)
Indicates whether a part with a certain elementId is currently rendered in a certain
perspective or not.
|
boolean |
isPartVisible(MPart part)
Returns whether the specified part is currently visible to the end user.
|
void |
removePartListener(IPartListener listener)
Removes the given listener so that it will no longer be notified of part lifecycle events.
|
void |
requestActivation()
Ask the service to assign activation to a valid part in the currently active presentation.
|
boolean |
saveAll(boolean confirm)
Saves the contents of all dirty parts and returns whether the operation completed.
|
boolean |
savePart(MPart part,
boolean confirm)
Saves the contents of the part if it is dirty and returns whether the operation completed.
|
MPart |
showPart(MPart part,
EPartService.PartState partState)
Shows a part with the identified by the given id.
|
MPart |
showPart(java.lang.String id,
EPartService.PartState partState)
Shows a part with the identified by the given id.
|
void |
switchPerspective(MPerspective perspective)
Switch to the specified perspective.
|
java.util.Optional<MPerspective> |
switchPerspective(java.lang.String perspectiveId)
Switch to the specified perspective.
|
public static final java.lang.String PART_ACTIVATION_TIME
public void addPartListener(IPartListener listener)
EPartServiceNote: Listeners should be removed when no longer necessary.
addPartListener in interface EPartServicelistener - the listener to attachpublic void removePartListener(IPartListener listener)
EPartServiceremovePartListener in interface EPartServicelistener - the listener to removepublic void bringToTop(MPart part)
EPartServicebringToTop in interface EPartServicepart - the part to bring to toppublic MPart findPart(java.lang.String id)
EPartServicefindPart in interface EPartServiceid - the id of the part to search for, must not be nullnull if no such part could be foundpublic java.util.Collection<MPart> getParts()
EPartServicegetParts in interface EPartServicenullpublic boolean isPartVisible(MPart part)
EPartServiceisPartVisible in interface EPartServicepart - the part to checktrue if the part is currently visible, false otherwisepublic boolean isPartOrPlaceholderInPerspective(java.lang.String elementId,
MPerspective perspective)
EPartServiceisPartOrPlaceholderInPerspective in interface EPartServiceelementId - the id of the part, which should be checkedperspective - the perspective, which may contain the part with the given elementIdtrue if the part with the given elementId is rendered in the given
perspective and false otherwisepublic void switchPerspective(MPerspective perspective)
EPartServiceswitchPerspective in interface EPartServiceperspective - the perspective to switch to, must not be null and it must be a
perspective that's being managed by this servicepublic java.util.Optional<MPerspective> switchPerspective(java.lang.String perspectiveId)
EPartServiceswitchPerspective in interface EPartServiceperspectiveId - the perspective to switch to, must not be null and it must be a
perspective that's being managed by this servicepublic void activate(MPart part)
EPartServiceactivate in interface EPartServicepart - the part to activate, must not be nullpublic void activate(MPart part,
boolean requiresFocus)
EPartServicerequiresFocus is true, then granted focus.activate in interface EPartServicepart - the part to activate, must not be nullrequiresFocus - if true, then also cause the part to acquire focuspublic MPart getActivePart()
EPartServicegetActivePart in interface EPartServicenull if no part is
currently activepublic MPart createPart(java.lang.String id)
EPartServicecreatePart in interface EPartServiceid - the identifier of the part, must not be nullnull if no part descriptors can be found
that match the specified idpublic MPlaceholder createSharedPart(java.lang.String id)
EPartServicecreateSharedPart in interface EPartServiceid - the identifier of the part, must not be nullnull if no part descriptors can be found
that match the specified idpublic MPlaceholder createSharedPart(java.lang.String id,
boolean force)
EPartServicecreateSharedPart in interface EPartServiceid - the identifier of the part, must not be nullforce - true if a new part should be created, false if the
window should be queried for a shared part firstnull if no part descriptors can be found
that match the specified idpublic MPart addPart(MPart part)
public MPart showPart(java.lang.String id,
EPartService.PartState partState)
EPartServiceEPartService.getParts() and iterate over
the collection to find the interested part and invoke EPartService.showPart(MPart, PartState) on
it. The behavior of this method is dictated by the supplied state.
ACTIVATE is supplied, then the part is made visible and granted focus.VISIBLE is supplied, then the part will be made visible and possibly be
granted focus depending on where it is relative to the active part. If it is in the same
stack as the currently active part, then it will be granted focus.CREATE is supplied, then the part will be instantiated though its
contents may not necessarily be visible to the end user. visible to the end user.showPart in interface EPartServiceid - the identifier of the part, must not be nullpartState - the desired state of the shown part to be innull if no parts or part descriptors can be found
that match the specified idpublic MPart showPart(MPart part,
EPartService.PartState partState)
EPartServiceEPartService.getParts() and iterate over
the collection to find the interested part and invoke EPartService.showPart(MPart, PartState) on
it. The behavior of this method is dictated by the supplied state.
ACTIVATE is supplied, then the part is made visible and granted focus.VISIBLE is supplied, then the part will be made visible and possibly be
granted focus depending on where it is relative to the active part. If it is in the same
stack as the currently active part, then it will be granted focus.CREATE is supplied, then the part will be instantiated though its
contents may not necessarily be visible to the end user. visible to the end user.showPart in interface EPartServicepart - the identifier of the part, must not be nullpartState - the desired state of the shown part to be innull if no parts or part descriptors can be found
that match the specified idpublic void requestActivation()
EPartServicerequestActivation in interface EPartServicepublic void hidePart(MPart part)
EPartService
If the part has been tagged with the EPartService.REMOVE_ON_HIDE_TAG tag, it will be removed from
the model when the service hides it.
To save the part before hiding, use EPartService.savePart(MPart, boolean):
if (partService.savePart(part, true)) {
partService.hidePart(part);
}
hidePart in interface EPartServicepart - the part to hideEPartService.savePart(MPart, boolean)public void hidePart(MPart part,
boolean force)
EPartService
If force is true or the part has been tagged with the
EPartService.REMOVE_ON_HIDE_TAG tag, it will be removed from the model when the service hides it.
To save the part before hiding, use EPartService.savePart(MPart, boolean):
if (partService.savePart(part, true)) {
partService.hidePart(part);
}
hidePart in interface EPartServicepart - the part to hideforce - if the part should be removed from the model regardless of its
EPartService.REMOVE_ON_HIDE_TAG tagEPartService.savePart(MPart, boolean)public java.util.Collection<MPart> getDirtyParts()
EPartServicegetDirtyParts in interface EPartServicenullpublic boolean savePart(MPart part,
boolean confirm)
EPartServicesavePart in interface EPartServicepart - the part to saveconfirm - true if the user should be prompted prior to saving the changes, and
false to save changes without askingtrue if the operation completed successfully, false if the
user canceled the operation or if an error occurred while saving the changesEPartService.hidePart(MPart, boolean)public boolean saveAll(boolean confirm)
EPartServicesaveAll in interface EPartServiceconfirm - true if the user should be prompted prior to saving the changes, and
false to save changes without askingtrue if the operation completed successfully, false if the
user canceled the operation or if an error occurred while saving the changes@Deprecated public java.util.Collection<MInputPart> getInputParts(java.lang.String inputUri)
EPartServiceMInputPart with the inputURI-Attribute
set to the given valuegetInputParts in interface EPartServiceinputUri - the input uri to search for, must not be null