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.
  • Field Details

    • 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:
    • 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:
  • Method Details

    • 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 be null
    • activate

      void activate(MPart part, boolean requiresFocus)
      Activates the given part. The part will be brought to top (if necessary) and, if requiresFocus is true, then granted focus.
      Parameters:
      part - the part to activate, must not be null
      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 be null
      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 be null
      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 be null
      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 be null
      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 use getParts() and iterate over the collection to find the interested part and invoke showPart(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 be null
      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
    • 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 show
      partState - 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:
    • hidePart

      void hidePart(MPart part, boolean force)
      Hides the given part. The part must be a part managed by this service.

      If force is true or 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
      force - if the part should be removed from the model regardless of its REMOVE_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

      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 save
      confirm - true if the user should be prompted prior to saving the changes, and false 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, and false 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

      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 be null 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 be null 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 checked
      perspective - 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 and false otherwise
      Since:
      1.3