22
(ATS04-PLAT00) Building Widgets for the Accelrys ELN Home Page David Pirkle Principal Software Engineer, R & D [email protected]

(ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

Embed Size (px)

DESCRIPTION

From a developer’s perspective, the Symyx Notebook Home Page is a container of widgets. It manages the layout of widgets, and handles the persistence of their settings. Several widgets are provided with the application: one for creating new experiments, another for tracking work in progress, and an inbox widget for messages sent through the notebook. This out-of-the-box set can be supplemented by building custom widgets. Several examples of custom widgets will be covered to demonstrate the basic concepts of widget development and the API they implement. We will also discuss best practices, and how to make your widget a good citizen of the Home Page.

Citation preview

Page 1: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

(ATS04-PLAT00) Building Widgets for the Accelrys ELN Home Page

David Pirkle

Principal Software Engineer, R & D

[email protected]

Page 2: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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.

Page 3: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• A quick overview of the home page and out-of-the-box widgets

Demo

Page 4: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

Home Page

• The Home Page is a container of widgets

• Handles widget layout and persistence of widget settings

Page 5: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 6: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• First example: RSS Feed Widget, Part 1

Demo

Page 7: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

Widget View

• The widget view is the user control that appears on the home page

• Create your view by extending UserControlWidgetView

Page 8: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 9: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• Second example: RSS Feed Widget, Part 2

Demo

Page 10: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 11: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

Widget View

• Use DisplayMessage for messages such as errors

• Override Dispose to dispose of resources

Page 12: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• Third example: RSS Feed Widget, Part 3

Demo

Page 13: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 14: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 15: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 16: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 17: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• Fourth example: Structure Search Widget

Demo

Page 18: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 19: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• Fifth example: Pipeline Pilot Protocol Widget

Demo

Page 20: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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

Page 21: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

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)

Page 22: (ATS4-DEV08) Building Widgets for the Symyx Notebook Home Page

• 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