Community
Participate
Working Groups
Build Identifier: M20090917-0800 I would like to have something like ILoadedAction, but with extended functionality. Something like: ICreatedAction { onCreated(String pathInXML, Object sender); } Where "pathInXML" is "/" separated String on XML element names from root element. I need it to recognize Control or Viewer in my own copy of parsed XML. You may also use array of strings or list of them, no matter, I just need some XWT internals independent way to associated created components with elements in XML. And "sender" is created Control, Viewer, Item or any other Widget. Notification should be sent directly after component instance creation, before applying any property. So, I would able to get default values for all properties. Reproducible: Always
Ah... I think that just Control/Widget is not enough. I would like to have this notification for any created Object. For example creation of Layout or LayoutData is also interesting thing.
Hi, XWT have provided a solution to use your own XWTLoader. You need to create a subclass of ResourceLoader and extend it for your purpose. Of course, you need to register it in XWT before using it. We need more information to understand the requirement and the benefices to implement it as standard solution.
1. Right now ResourceLoader has no protected method which is called directly after "targetObject" creation. Nearest method which it has is "postCreation()", but it is called after applying attributes and creating children. I need to process just created component without applying attributes. 2. I've added new method into ResourceLoader, so my subclass can implement it: /** * This method is invoked directly after creation of component instance, but * before applying its attributes and creating children. */ protected void postCreation0(Object target) { // TODO } How can I configure XWT to use my ResourceLoader subclass? Something like this? IXWTLoader activeLoader = XWTLoaderManager.getActive(); Core profile = new Core(new IElementLoaderFactory() { public IVisualElementLoader createElementLoader(IRenderingContext context, IXWTLoader loader) {}, activeLoader); XWT.applyProfile(profile); 3. I've added tweaks into Element, Attribute and their creation to remember original tag names, to be able to find corresponding XML element in my copy of XML tree.
Created attachment 157709 [details] Support for postCreation0() and tweak for Element
Created attachment 157714 [details] Support for postCreation0() and tweak for Element (rev 2) Shell creation handled specially in ResourceLoader, so this patch includes also Shell object processing.
Created attachment 157777 [details] Support for postCreation0() and tweak for Element (rev 3) I found that just using names of elements is not enough, because it is possible that we will have more than one Button in Shell, so we can not distinguish them by name. We should use indexes. So, patch was modified to remember index instead of name in Element.
Thanks for the contribution. The modification is committed in Head -> 20100209. I leave the bug open, please check it out and close it if the fix works.
Almost. :-) I see two little problems: 1. Do you use Element.getOriginalIndex1() instead of Element.getOriginalIndex() intentionally or this is just mistype? 2. English is not my native language, but I see now in compare that I did obvious mistype in JavaDoc for this method. "the index of this element is its parent" -> "the index of this element in its parent".
The modifications in the last patch are validated and committed in Head -> 20100217
I've found problem with using "originalIndex" in Element. It does not work very good when nested properties. --- <Shell xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt"> <Shell.layout> <RowLayout/> </Shell.layout> <TableViewer> <TableViewer.table headerVisible="true" linesVisible="true"> <TableViewer.table.layoutData> <RowData width="326" height="207"/> </TableViewer.table.layoutData> </TableViewer.table> </TableViewer> </Shell> --- In this example "TableViewer.table.layoutData" has "TableViewer" as parent, not "TableViewer.table" as I would expect. But it renders just fine, so I should just adopt to this. To do this, I would like to replace "originalIndex" with "path", which we have in any case already in ElementHandler. To minimize memory overhead, I store it as String.
Created attachment 164714 [details] Support for postCreation0() and tweak for Element (rev 4) Can you review and apply this patch?
Apply the patch and committed -> 20100419