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
Nested Classes Modifier and Type Interface Description static class
EPartService.PartState
Applicable states that a part can be in.
-
Field Summary
Fields Modifier and Type Field Description static String
ACTIVE_ON_CLOSE_TAG
Used to tag the currently active part in a presentation for subsequent activation on session startupstatic String
REMOVE_ON_HIDE_TAG
A tag on a part to indicate that it should be removed from the model when it is hidden.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
activate(MPart part)
Activates the given part.void
activate(MPart part, boolean requiresFocus)
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.MPart
createPart(String partDescriptorId)
Creates a new part of the given id.MPlaceholder
createSharedPart(String id)
Creates a new placeholder for a part of the given id.MPlaceholder
createSharedPart(String id, boolean force)
Creates a new placeholder for a part of the given id.MPart
findPart(String id)
Finds and returns a part with the given id.MPart
getActivePart()
Returns the active part.Collection<MPart>
getDirtyParts()
Returns a collection of all the dirty parts that are being managed by this service.Collection<MInputPart>
getInputParts(String inputUri)
Deprecated.This method should never be used as MInputPart are deprecatedCollection<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(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(String id, EPartService.PartState partState)
Shows a part with the identified by the given id.MPart
showPart(MPart part, EPartService.PartState partState)
Shows the given part.Optional<MPerspective>
switchPerspective(String perspectiveId)
Switch to the specified perspective.void
switchPerspective(MPerspective perspective)
Switch to the specified perspective.
-
-
-
Field Detail
-
ACTIVE_ON_CLOSE_TAG
static final String ACTIVE_ON_CLOSE_TAG
Used to tag the currently active part in a presentation for subsequent activation on session startup- See Also:
- Constant Field Values
-
REMOVE_ON_HIDE_TAG
static final String 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:
hidePart(MPart)
, Constant Field Values
-
-
Method Detail
-
addPartListener
void addPartListener(IPartListener listener)
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
void removePartListener(IPartListener listener)
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
void activate(MPart part)
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
void activate(MPart part, boolean requiresFocus)
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
void bringToTop(MPart part)
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
MPart findPart(String id)
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
boolean isPartVisible(MPart part)
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
MPart createPart(String partDescriptorId)
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
-
createSharedPart
MPlaceholder createSharedPart(String id)
Creates a new placeholder for a part of the given id.- Parameters:
id
- the identifier of the part, must not benull
- Returns:
- a new part of the given id, or
null
if no part descriptors can be found that match the specified id
-
createSharedPart
MPlaceholder createSharedPart(String id, boolean force)
Creates a new placeholder for a part of the given id.- Parameters:
id
- the identifier of the part, must not benull
force
-true
if a new part should be created,false
if the window should be queried for a shared part first- Returns:
- a new part of the given id, or
null
if no part descriptors can be found that match the specified id
-
showPart
MPart showPart(String id, EPartService.PartState partState)
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
MPart showPart(MPart part, EPartService.PartState partState)
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
void hidePart(MPart part)
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:
savePart(MPart, boolean)
-
hidePart
void hidePart(MPart part, boolean force)
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:
savePart(MPart, boolean)
-
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
boolean savePart(MPart part, boolean confirm)
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:
hidePart(MPart, boolean)
-
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
-
getInputParts
@Deprecated Collection<MInputPart> getInputParts(String inputUri)
Deprecated.This method should never be used as MInputPart are deprecatedReturns a collection of allMInputPart
with the inputURI-Attribute set to the given value- Parameters:
inputUri
- the input uri to search for, must not benull
- Returns:
- list of parts or an empty collection
- Throws:
AssertionFailedException
- if null passed as argument- See Also:
- Bug 509868
- Restriction:
- This method is not intended to be referenced by clients.
-
switchPerspective
void switchPerspective(MPerspective perspective)
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
Optional<MPerspective> switchPerspective(String perspectiveId)
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
boolean isPartOrPlaceholderInPerspective(String elementId, MPerspective perspective)
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
-
-