<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>Hi guys,<br><br>I've improved the original plugin infrastructure, please find the 2nd revision of UI Plugins proof-of-concept (PoC) patch attached.<br><br>Here's a quick summary of changes:<br><ul><li>PluginSourcePageServlet looks up the actual plugin code in local filesystem (<pluginName>.js), so you can experiment with different plugins. If you want to add new plugins, just modify WebadminDynamicHostingServlet.writeAdditionalJsData() method.</li><li>PluginManager now calls <em>UiInit</em> function on plugins (plugin objects) within the scope of WebAdmin main section (user has logged in, main section UI is initialized and ready), and disables plugin execution outside main section (e.g. when the user logs out).<br></li></ul>(Please find a sample plugin code attached as well. PluginSourcePageServlet tries to load it from a hard-coded location in local filesystem, you probably want to modify this to suit your environment.)<br><br><span style="font-style: italic;">UiInit</span> function is a special event handler function that gets called once, after plugin reports as ready, and before other event handler functions are called. <span style="font-style: italic;">UiInit</span> function would be a good place to extend default WebAdmin UI (adding main tab, etc.).<br><br>This is illustrated on the following use case:<br><ol><li>user requests WebAdmin page, during initialization a plugin iframe gets created and attached to DOM, plugin HTML page gets requested asynchronously, application init code still runs so iframe plugin code evaluation is blocked (this is because of JavaScript runtime being single-threaded in its nature)</li><li>application init code finishes, plugin code gets evaluated, plugin registers itself into <span style="font-style: italic;">pluginApi.plugins</span> and reports back as ready (calls the <span style="font-style: italic;">ready</span> function)</li><li>since the user is still in login section (not logged into WebAdmin), plugin invocation is disabled, until the user logs in</li><li>user logs into the application, UI redirects to main section, and after UI gets initialized, plugin invocation is enabled</li><li><span style="font-style: italic;">UiInit</span> function is called on the plugin</li><li><NOT IMPLEMENTED YET> user performs some actions and WebAdmin calls different functions on the plugin</li><li>assume the user logs out, plugin invocation is disabled, until the user logs in again</li><li>user logs in again, but <span style="font-style: italic;">UiInit</span> isn't called now because it has been called already before</li><li>goto step 6<br></li></ol>The reason why <span style="font-style: italic;">UiInit</span> is called just once (after visiting main section for the first time), is because WebAdmin UI (Views) are mostly singletons, so even when you switch to different section (login section) and go to main section again, singleton Views will still be there, with any adjustments/extensions made previously by plugins.<br><br>Now, as for the next steps, we can proceed with actual tasks Itamar outlined in his email:<br><ul><li>use <span style="font-style: italic;">UiInit</span> event to extend UI (add main tab, etc.)</li><li>define other events (table context menu event, etc.)<br></li><li>allow plugins to do REST API calls through <span style="font-style: italic;">pluginApi</span> object<br></li></ul>I've tried to implement "add main tab" functionality. Unfortunately, this isn't quite easy to do with GWT-Platform (GWTP) framework we use. Each tab in WebAdmin has some place (GWT history token = URL hash fragment) associated. The way GWTP handles tabs is that individual tabs (Presenter) reveal themselves into tab container (TabContainerPresenter), with presenter reveal flow being processed bottom-up. I strongly suggest to go through [http://code.google.com/p/gwt-platform/wiki/GettingStarted] to get some basic understanding of GWTP framework and how tabs work in general.<br><br>Long story short, to add tabs dynamically in a proper way, we need to write custom presenter proxy, here are some links on this matter:<br>Discussion [https://groups.google.com/forum/#!topic/gwt-platform/aJrGOf9Gu04/discussion]<br>Dynamic tab example [http://code.google.com/r/goudreauchristian-update/source/browse/]<br>Working demo [http://olivier.monaco.free.fr/lab/gwtp-editor/]<br><br>So adding main/sub tabs is a task that will require some additional work, especially since we wish to combine both static tabs and dynamic tabs in one tab container. I'll try to work on this one.<br><br>On the other hand, it would be great if others could take the latest PoC patch (attached), and experiment with other stuff like context menu events, REST API calls, etc. You can always reach me on #ovirt (vszocs) if you have a question or need help with anything.<br><br>Cheers,<br>Vojtech<br><br></div></body></html>