public class ModelServiceImpl extends java.lang.Object implements EModelService
ABOVE, ANYWHERE, BELOW, CLONED_FROM_KEY, GLOBAL, IN_ACTIVE_PERSPECTIVE, IN_ANY_PERSPECTIVE, IN_MAIN_MENU, IN_PART, IN_SHARED_AREA, IN_TRIM, LEFT_OF, NOT_IN_UI, OUTSIDE_PERSPECTIVE, PRESENTATION, RIGHT_OF| Constructor and Description |
|---|
ModelServiceImpl(IEclipseContext appContext)
This is a singleton service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bringToTop(MUIElement element)
Brings the specified element to the top of its containment structure.
|
MUIElement |
cloneElement(MUIElement element,
MSnippetContainer snippetContainer)
Clones the element, creating a deep copy of its structure.
|
MUIElement |
cloneSnippet(MSnippetContainer snippetContainer,
java.lang.String snippetId,
MWindow refWin)
If a snippet with the given id exists a clone is created and returned. returns
null if no snippet can be found. |
int |
countRenderableChildren(MUIElement element)
Return the count of the children whose 'toBeRendered' flag is true
|
<T extends MApplicationElement> |
createModelElement(java.lang.Class<T> elementType)
Creates instances of model elements.
|
MPart |
createPart(MPartDescriptor descriptor)
Creates a new part from the given descriptor.
|
void |
detach(MPartSashContainerElement element,
int x,
int y,
int width,
int height)
Created a separate (detached) window containing the given element.
|
MUIElement |
find(java.lang.String id,
MUIElement searchRoot)
Returns the first element, recursively searching under the specified search root (inclusive)
|
<T> java.util.List<T> |
findElements(MApplicationElement searchRoot,
java.lang.Class<T> clazz,
int searchFlags,
Selector matcher)
Return a list of any elements that match the given search criteria.
|
<T> java.util.List<T> |
findElements(MUIElement searchRoot,
java.lang.String id,
java.lang.Class<T> clazz,
java.util.List<java.lang.String> tagsToMatch)
This is a convenience method that forwards the parameters on to
EModelService.findElements(MUIElement, String, Class, List, int), passing
EModelService.ANYWHERE as the 'searchFlags'. |
<T> java.util.List<T> |
findElements(MUIElement searchRoot,
java.lang.String id,
java.lang.Class<T> clazz,
java.util.List<java.lang.String> tagsToMatch,
int searchFlags)
This is a convenience method that constructs a new Selector based on
ElementMatcher
and forwards the call on to the base API
EModelService.findElements(MApplicationElement, Class, int, Selector). |
MPlaceholder |
findPlaceholderFor(MWindow window,
MUIElement element)
Given a containing MWindow find the MPlaceholder that is currently being used to host the
given element (if any)
|
MUIElement |
findSnippet(MSnippetContainer snippetContainer,
java.lang.String id)
Convenience method to find a snippet by id in a particular container
|
MPerspective |
getActivePerspective(MWindow window)
Return the active perspective for the given window.
|
MUIElement |
getContainer(MUIElement element)
Get the container of the given element.
|
IEclipseContext |
getContainingContext(MUIElement element)
Locate the context that is closest to the given element in the parent hierarchy.
|
int |
getElementLocation(MUIElement element)
Given an element this method responds with information about where the element exists within
the current UI Model.
|
java.util.List<MPlaceholder> |
getNullRefPlaceHolders(MUIElement element,
MWindow refWin) |
MPartDescriptor |
getPartDescriptor(java.lang.String id)
Returns the descriptor for the given part id.
|
MPerspective |
getPerspectiveFor(MUIElement element) |
MWindow |
getTopLevelWindowFor(MUIElement element)
Get the top-level window containing this UI element.
|
MTrimBar |
getTrim(MTrimmedWindow window,
SideValue sv)
Returns the window's MTrimBar for the specified side.
|
void |
hideLocalPlaceholders(MWindow window,
MPerspective perspective)
This method ensures that there will never be two placeholders for the same referenced element
visible in the presentation at the same time.
|
void |
hostElement(MUIElement element,
MWindow hostWindow,
java.lang.Object uiContainer,
IEclipseContext hostContext)
Allows an element to be rendered in an arbitrary UI container (I.e.
|
void |
insert(MPartSashContainerElement toInsert,
MPartSashContainerElement relTo,
int where,
float ratio)
Inserts the given element into the UI Model by either creating a new sash
or augmenting an existing sash if the orientation permits.
|
boolean |
isHostedElement(MUIElement element,
MWindow hostWindow)
Tests whether the given element is being 'hosted'.
|
boolean |
isLastEditorStack(MUIElement stack)
Returns
true iff the supplied element represents the single visible element in
the shared area. |
<T extends MUIElement> |
move(T element,
<any> newParent)
Move the element to a new location.
|
<T extends MUIElement> |
move(T element,
<any> newParent,
boolean leavePlaceholder)
Move the element to a new location.
|
<T extends MUIElement> |
move(T element,
<any> newParent,
int index)
Move the element to a new location.
|
<T extends MUIElement> |
move(T element,
<any> newParent,
int index,
boolean leavePlaceholder)
Move the element to a new location.
|
void |
removePerspectiveModel(MPerspective persp,
MWindow window)
Remove the given perspective completely from the model.
|
void |
resetPerspectiveModel(MPerspective persp,
MWindow window)
This is a convenience method that will clean the model of all traces of a given perspective.
|
int |
toBeRenderedCount(<any> container)
Count the number of 'toBeRendered' children
|
public ModelServiceImpl(IEclipseContext appContext)
appContext - The applicationContext to get the eventBroker fromjava.lang.NullPointerException - if the given appContext is nullpublic final <T extends MApplicationElement> T createModelElement(java.lang.Class<T> elementType)
EModelServiceMApplicationElement, both in the standard e4 UI model and in an extension models.
Caution: To create model element instances of extension models you need to register
them with the the org.eclipse.e4.workbench.model.definition.enrichment
ExtensionPoint.
createModelElement in interface EModelServiceelementType - the class to instantiate. Cannot be nullpublic <T> java.util.List<T> findElements(MUIElement searchRoot,
java.lang.String id,
java.lang.Class<T> clazz,
java.util.List<java.lang.String> tagsToMatch)
EModelServiceEModelService.findElements(MUIElement, String, Class, List, int), passing
EModelService.ANYWHERE as the 'searchFlags'.findElements in interface EModelServicepublic <T> java.util.List<T> findElements(MUIElement searchRoot,
java.lang.String id,
java.lang.Class<T> clazz,
java.util.List<java.lang.String> tagsToMatch,
int searchFlags)
EModelServiceElementMatcher
and forwards the call on to the base API
EModelService.findElements(MApplicationElement, Class, int, Selector).findElements in interface EModelServiceEModelService.findElements(MApplicationElement, Class, int, Selector)public <T> java.util.List<T> findElements(MApplicationElement searchRoot,
java.lang.Class<T> clazz,
int searchFlags,
Selector matcher)
EModelServicenull in which case that field will always 'match'.
NOTE: This is a generically typed method with the List's generic type expected to be the value of the 'clazz' parameter. If the 'clazz' parameter is null then the returned list is untyped.
findElements in interface EModelServiceT - The generic type of the returned listsearchRoot - The element at which to start the search. This element must be non-null and is
included in the search.clazz - The type of element to be searched for. If non-null this also defines the return
type of the List.searchFlags - A bitwise combination of the following constants:
matcher - An implementation of a Selector that will return true for elements that it wants
in the returned list.public MUIElement find(java.lang.String id,
MUIElement searchRoot)
EModelServicefind in interface EModelServiceid - The id to search for, must not be nullsearchRoot - The element at which to start the search, must not be nullnull if one is not foundpublic int countRenderableChildren(MUIElement element)
EModelServicecountRenderableChildren in interface EModelServiceelement - The element to testpublic IEclipseContext getContainingContext(MUIElement element)
EModelServicegetContainingContext in interface EModelServiceelement - the element to locate parent context forpublic MUIElement cloneElement(MUIElement element,
MSnippetContainer snippetContainer)
EModelServicecloneElement in interface EModelServiceelement - The element to clonesnippetContainer - An optional MUIElement where the cloned snippet is to be saved. null if the clone
need not be savedpublic MUIElement cloneSnippet(MSnippetContainer snippetContainer,
java.lang.String snippetId,
MWindow refWin)
EModelServicenull if no snippet can be found.cloneSnippet in interface EModelServicesnippetContainer - The container of the snippet to clone usedsnippetId - The element id of the snippet to clonerefWin - The window that Placeholder references should be resolved usingnull if no snippet with the given id can be foundpublic java.util.List<MPlaceholder> getNullRefPlaceHolders(MUIElement element,
MWindow refWin)
element - refWin - public MUIElement findSnippet(MSnippetContainer snippetContainer,
java.lang.String id)
EModelServicefindSnippet in interface EModelServicesnippetContainer - The container to look inid - The id of the root element of the snippetnull if none is foundpublic void bringToTop(MUIElement element)
EModelServicebringToTop in interface EModelServiceelement - The element to bring to the toppublic MPlaceholder findPlaceholderFor(MWindow window,
MUIElement element)
EModelServicefindPlaceholderFor in interface EModelServicewindow - The containing windowelement - The element to find the MPlaceholder forpublic <T extends MUIElement> void move(T element,
<any> newParent)
EModelServicemove in interface EModelServiceelement - The element to movenewParent - The new parent for the element.public <T extends MUIElement> void move(T element,
<any> newParent,
boolean leavePlaceholder)
EModelServicemove in interface EModelServiceelement - The element to movenewParent - The new parent for the element.leavePlaceholder - true if a placeholder for the element should be addedpublic <T extends MUIElement> void move(T element,
<any> newParent,
int index)
EModelServicemove in interface EModelServiceelement - The element to movenewParent - The new parent for the element.index - The index to insert the element at; -1 means at the endpublic <T extends MUIElement> void move(T element,
<any> newParent,
int index,
boolean leavePlaceholder)
EModelServicemove in interface EModelServiceelement - The element to movenewParent - The new parent for the element.index - The index to insert the element at; -1 means at the endleavePlaceholder - true if a placeholder for the element should be addedpublic void insert(MPartSashContainerElement toInsert,
MPartSashContainerElement relTo,
int where,
float ratio)
EModelServiceinsert in interface EModelServicetoInsert - The element to insertrelTo - The element that the new one is to be relative towhere - Indication of where the inserted element should be placed:
EModelService.LEFT_OF, EModelService.RIGHT_OF, EModelService.ABOVE,
EModelService.BELOW.ratio - The percentage of the area to be occupied by the inserted
element; should be a number greater than 0 and less than 1public void detach(MPartSashContainerElement element,
int x,
int y,
int width,
int height)
EModelServicedetach in interface EModelServiceelement - The element to detachx - The X position of the new windowy - The Y position of the new windowwidth - The Width of the new windowheight - The Height of the new windowpublic MTrimBar getTrim(MTrimmedWindow window,
SideValue sv)
EModelServicegetTrim in interface EModelServicewindow - The window to get the trim bar forsv - The value for the specified sidepublic MWindow getTopLevelWindowFor(MUIElement element)
EModelServicenull return value
indicates that the element is not directly contained in the UI model (but may, for example,
be a model snippet hosted in a Dialog...)getTopLevelWindowFor in interface EModelServiceelement - The element to get the window fornull return value
indicates that the element is not directly contained in the UI model (but may, for
example, be a model snippet hosted in a Dialog...)public MPerspective getPerspectiveFor(MUIElement element)
getPerspectiveFor in interface EModelServiceelement - The element to get the perspective fornull if the element is not
in a perspectivepublic void resetPerspectiveModel(MPerspective persp,
MWindow window)
EModelServiceresetPerspectiveModel in interface EModelServicepersp - the perspective to removewindow - the window to remove it frompublic void removePerspectiveModel(MPerspective persp,
MWindow window)
EModelServiceremovePerspectiveModel in interface EModelServicepersp - the perspective to removewindow - the window to remove it frompublic MPerspective getActivePerspective(MWindow window)
EModelServicegetActivePerspective in interface EModelServicewindow - The window to determine the active perspective for.null if there is no MPerspectiveStack, it's
empty or has no selected element.public int toBeRenderedCount(<any> container)
EModelServicetoBeRenderedCount in interface EModelServicecontainer - The container to checktruepublic MUIElement getContainer(MUIElement element)
EModelServicegetContainer in interface EModelServiceelement - The element to get the container fornull if the element being checked
is a snippet unattached to the UI Model itself.public int getElementLocation(MUIElement element)
EModelServicegetElementLocation in interface EModelServicepublic MPartDescriptor getPartDescriptor(java.lang.String id)
EModelServiceNOTE: In order to support multiple instance parts there is a convention where the part's id may be in the form 'partId:secondaryId'. If the given id contains a ':' then only the substring before the ':' will be used to find the descriptor.
In order to support this convention it's required that no descriptor contain a ':' in its id
getPartDescriptor in interface EModelServiceid - The id of the descriptor to returnnull if none existspublic MPart createPart(MPartDescriptor descriptor)
EModelServicecreatePart in interface EModelServicedescriptor - a part descriptor, must not be nullEPartService.createPart(String)public void hideLocalPlaceholders(MWindow window,
MPerspective perspective)
EModelServicefalse.hideLocalPlaceholders in interface EModelServicewindow - The window to modifyperspective - if non-null specifies the specific perspective to modify, otherwise all
perspectives in the window are checkedpublic boolean isLastEditorStack(MUIElement stack)
EModelServicetrue iff the supplied element represents the single visible element in
the shared area. This method is used to test for this condition since (by convention) there
must be at least one stack in the shared area at all times.isLastEditorStack in interface EModelServicestack - The element to testtrue iff the element is the last visible stackpublic void hostElement(MUIElement element,
MWindow hostWindow,
java.lang.Object uiContainer,
IEclipseContext hostContext)
EModelServicehostElement in interface EModelServiceelement - The element to be rendered.hostWindow - The MWindow the element is being hosted under. Must be non-nulland rendered.uiContainer - The UI container acting as the rendered element's parent. Must be non-null.hostContext - The IEclipseContext to use for hosting the element. Must be non-null.public boolean isHostedElement(MUIElement element,
MWindow hostWindow)
EModelServiceisHostedElement in interface EModelServiceelement - The element to test. Must be non-null.hostWindow - The window to test the element against. Must be non-null.true iff the given element or one of its ancestors is currently being
hosted in the given MWindow.