Interface EPartService
public interface EPartService
The part service provides clients with the functionalities of showing and hiding parts. Part
events can also be tracked via the part service.
It is expected that any methods that are exposed by this service that takes an MPart
as an argument be a part that is actually being managed by this service.
- Since:
- 1.0
- Restriction:
- This interface is not intended to be implemented by clients.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Applicable states that a part can be in. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Activates the given part.void
Activates the given 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.createPart
(String partDescriptorId) Creates a new part of the given id.Creates a new placeholder for a part of the given id.createSharedPart
(String id, boolean force) Creates a new placeholder for a part of the given id.Finds and returns a part with the given id.Returns the active part.Returns a collection of all the dirty parts that are being managed by this service.getParts()
Returns a collection of all the parts that are being managed by this part service.void
Hides the given part.void
Hides the given part.boolean
isPartOrPlaceholderInPerspective
(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
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
Saves the contents of the part if it is dirty and returns whether the operation completed.showPart
(String id, EPartService.PartState partState) Shows a part with the identified by the given id.showPart
(MPart part, EPartService.PartState partState) Shows the given part.switchPerspective
(String perspectiveId) Switch to the specified perspective.void
switchPerspective
(MPerspective perspective) Switch to the specified perspective.
-
Field Details
-
ACTIVE_ON_CLOSE_TAG
Used to tag the currently active part in a presentation for subsequent activation on session startup- See Also:
-
REMOVE_ON_HIDE_TAG
A tag on a part to indicate that it should be removed from the model when it is hidden.- See Also:
-
-
Method Details
-
addPartListener
Adds the given listener for part lifecycle events. Has no effect if an identical listener has already been registered.Note: Listeners should be removed when no longer necessary.
- Parameters:
listener
- the listener to attach
-
removePartListener
Removes the given listener so that it will no longer be notified of part lifecycle events. Has no effect if an identical listener has not been registered.- Parameters:
listener
- the listener to remove
-
activate
Activates the given part. The part will be brought to top (if necessary) and granted focus.- Parameters:
part
- the part to activate, must not benull
-
activate
Activates the given part. The part will be brought to top (if necessary) and, ifrequiresFocus
is true, then granted focus.- Parameters:
part
- the part to activate, must not benull
requiresFocus
- if true, then also cause the part to acquire focus
-
requestActivation
void requestActivation()Ask the service to assign activation to a valid part in the currently active presentation. -
bringToTop
Brings this part to the top so that it will become visible to the end user. This does not imply that the part will be granted focus.- Parameters:
part
- the part to bring to top
-
findPart
Finds and returns a part with the given id.- Parameters:
id
- the id of the part to search for, must not benull
- Returns:
- the part with the specified id, or
null
if no such part could be found
-
getParts
Collection<MPart> getParts()Returns a collection of all the parts that are being managed by this part service.- Returns:
- a collection of parts that are being managed by this service, never
null
-
getActivePart
MPart getActivePart()Returns the active part.- Returns:
- an active part within the scope of this service, or
null
if no part is currently active
-
isPartVisible
Returns whether the specified part is currently visible to the end user.- Parameters:
part
- the part to check- Returns:
true
if the part is currently visible,false
otherwise
-
createPart
Creates a new part of the given id.- Parameters:
partDescriptorId
- the identifier of the Part Descriptor, must not benull
- Returns:
- a new part of the given id, or
null
if no part descriptors can be found that match the specified partDescriptorId
-
showPart
Shows a part with the identified by the given id. In the event that there are multiple parts with the specified id, the client is recommended to usegetParts()
and iterate over the collection to find the interested part and invokeshowPart(MPart, PartState)
on it. The behavior of this method is dictated by the supplied state.- If
ACTIVATE
is supplied, then the part is made visible and granted focus. - If
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. - If
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.
- Parameters:
id
- the identifier of the part, must not benull
partState
- the desired state of the shown part to be in- Returns:
- the shown part, or
null
if no parts or part descriptors can be found that match the specified id
- If
-
showPart
Shows the given part.- If there cannot be multiple parts of this type and a part already exists, the already existing part will be shown and returned.
- If multiple parts of this type is allowed, then the provided part will be shown and returned
The behavior of this method is dictated by the supplied state.
- If
ACTIVATE
is supplied, then the part is made visible and granted focus. - If
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. - If
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.
- Parameters:
part
- the part to showpartState
- the desired state of the shown part to be in- Returns:
- the shown part
-
hidePart
Hides the given part. The part must be a part managed by this service.If the part has been tagged with the
REMOVE_ON_HIDE_TAG
tag, it will be removed from the model when the service hides it.To save the part before hiding, use
savePart(MPart, boolean)
:if (partService.savePart(part, true)) { partService.hidePart(part); }
- Parameters:
part
- the part to hide- See Also:
-
hidePart
Hides the given part. The part must be a part managed by this service.If
force
istrue
or the part has been tagged with theREMOVE_ON_HIDE_TAG
tag, it will be removed from the model when the service hides it.To save the part before hiding, use
savePart(MPart, boolean)
:if (partService.savePart(part, true)) { partService.hidePart(part); }
- Parameters:
part
- the part to hideforce
- if the part should be removed from the model regardless of itsREMOVE_ON_HIDE_TAG
tag- See Also:
-
getDirtyParts
Collection<MPart> getDirtyParts()Returns a collection of all the dirty parts that are being managed by this service.- Returns:
- a collection of dirty parts that are being managed by this service, never
null
-
savePart
Saves the contents of the part if it is dirty and returns whether the operation completed.- Parameters:
part
- the part to saveconfirm
-true
if the user should be prompted prior to saving the changes, andfalse
to save changes without asking- Returns:
true
if the operation completed successfully,false
if the user canceled the operation or if an error occurred while saving the changes- See Also:
-
saveAll
boolean saveAll(boolean confirm) Saves the contents of all dirty parts and returns whether the operation completed.- Parameters:
confirm
-true
if the user should be prompted prior to saving the changes, andfalse
to save changes without asking- Returns:
true
if the operation completed successfully,false
if the user canceled the operation or if an error occurred while saving the changes
-
switchPerspective
Switch to the specified perspective. It will be selected and brought to top (if necessary). It may not necessarily be granted focus if there is another active window present.- Parameters:
perspective
- the perspective to switch to, must not benull
and it must be a perspective that's being managed by this service- Since:
- 1.4
-
switchPerspective
Switch to the specified perspective. It will be selected and brought to top (if necessary). It may not necessarily be granted focus if there is another active window present.- Parameters:
perspectiveId
- the perspective to switch to, must not benull
and it must identify a perspective that's being managed by this service- Returns:
- an java.util.Optional<MPerspective> containing the perspective, which has been switched to or an empty Optional.
- Since:
- 1.4
-
isPartOrPlaceholderInPerspective
Indicates whether a part with a certain elementId is currently rendered in a certain perspective or not.- Parameters:
elementId
- the id of the part, which should be checkedperspective
- the perspective, which may contain the part with the given elementId- Returns:
true
if the part with the given elementId is rendered in the given perspective andfalse
otherwise- Since:
- 1.3
-