(ATS04-PLAT00) Building Widgets for the Accelrys ELN Home Page
David Pirkle
Principal Software Engineer, R & D
The information on the roadmap and future software development efforts are intended to outline general product direction and should not be relied on in making a purchasing decision.
• A quick overview of the home page and out-of-the-box widgets
Demo
Home Page
• The Home Page is a container of widgets
• Handles widget layout and persistence of widget settings
HomePageWidget
• To start developing a custom widget, extend HomePageWidget
• Subclass is responsible for returning factory classes that create:
– widget view
– widget settings view
• Subclass must also manage widget settings
• First example: RSS Feed Widget, Part 1
Demo
Widget View
• The widget view is the user control that appears on the home page
• Create your view by extending UserControlWidgetView
Publishing a Widget
• See the sample code in the PublishWidgetToVault project
• Command line utility takes 6 parameters:
– Server
– Username
– Password
– Vault path of widget folder
– Widget title
– Assembly-qualified name of the main widget class
• Second example: RSS Feed Widget, Part 2
Demo
Refreshing the Widget View
• View may need to periodically refresh (ex., inbox widget)
• Manual refresh supported by refresh button in widget title bar
• Refresh button triggers call to RefreshView
• If you want auto-refresh, your view must handle this
• Use ShowBusySpinner and HideBusySpinner while view is updating
Widget View
• Use DisplayMessage for messages such as errors
• Override Dispose to dispose of resources
• Third example: RSS Feed Widget, Part 3
Demo
Adding Widget Settings - Overview
• Extend WidgetMemento to persist settings
• Extend UserControlConfigurationView for settings UI
• Extend ConfigurationViewBuilder as a factory for the settings UI
• Modify the widget view to respond to settings
Settings Persistence
• Extend Widget.WidgetMemento
• Implement properties for settings in the memento
• Add serialization decorators (DataContract and DataMember)
• Use your memento in the main widget class by overriding SaveToMemento and RestoreFromMemento
• Implement properties for settings in the main widget
• Also override ResetDefaultValues so the Reset button works OK
Settings UI
• Extend UserControlConfigurationView
• Override OnWidgetSet or use Widget property to access the main widget and its state
• Override SetConfigurationView, and update the UI based on the state of the main widget
• Add event handlers to set the state of the main widget as UI is manipulated
• Widget view subscribes to ConfigurationChanged event of the main widget in its override of OnWidgetSet
ConfigurationViewBuilder
• ConfigurationViewBuilder is a factory that creates the settings UI
• Extend ConfigurationViewBuilder, overriding CreateConfigurationView and CreateConfigurationView
• Override ConfigurationViewBuilders in the main widget to return this new class
• Fourth example: Structure Search Widget
Demo
Widgets that Search
• Work in Progress widget is an example of a widget that presents search results
• Extend QueryWidget to implement the main widget class for a query-based widget
• QueryWidgetViewBuilder can be used as is to create widget views that execute a query and present the results in a grid
• Auto-refresh also handled for you • Extend QueryWidgetConfigurationView to implement the settings
UI • The configuration view sets the main widget’s Query property,
when the settings UI is changed
• Fifth example: Pipeline Pilot Protocol Widget
Demo
ProtocolWidget
• ProtocolWidget can be configured to run a Pipeline Pilot protocol that produces HTML
• Views the result in the WebBrowser control • Modify the PipelinePilot | RunProtocol application permission
to add a new configuration key that specifies the location in the protocol tree where you will publish widget protocols – Name: WidgetProtocolRoot – Value: Protocols/Web Services/Accelrys/Notebook Widgets
• If you need to pass parameters to a protocol, override the GenerateProtocolParameters method
Performance Considerations
• Performance and memory profiling are critical • Widgets that refresh periodically can have a significant negative
impact on performance • Consider adding random amount to refresh interval to avoid
simultaneous refreshes (QueryWidgetView will handle this for you) • Notebook has 2 connections to Vault, so Widgets that refresh and
talk to Vault have the biggest potential to degrade system performance
• QueryWidgetView handles connection limitation for you (VaultObjectGrid.GridLoader set to a KeyedAsynchronousGridLoadStrategy that uses "share" as a key)
• Learned how to build custom widgets
– Extend base classes in Symyx.Notebook.Applications.HomePage and Symyx.Notebook.HomePage
– QueryWidget base classes can be extended for widgets that search
– Performance and memory considerations
• Sample widgets and documentation in the Notebook SDK
• Administration of widgets covered in session ATS4-APP02
Summary