[Openchemistry-developers] JobActionFactories in MoleQueue

David Lonie david.lonie at kitware.com
Fri Jun 22 17:17:26 EDT 2012


Hi all,

While Chris wraps up his refactoring of the transport classes in
MoleQueue, I started working on some GUI/extensibility functions. The
patch here:

https://github.com/dlonie/molequeue/commit/aa033536f6f71d01b29e3885b2452cc6cfca40bd

shows a factory design which can be used to customize and extend the
context menu in the job table. The intention here is that new actions
(e.g. "Open with X", "Commit to ChemData", etc) can be configured via
the GUI or added through a plugin. I've described the classes in a bit
more detail in the commit message (below). This isn't ready for
Gerrit, but I'd like to get some early feedback on the approach before
too much is invested in it. Feel free to leave comments on the github
page if you have specific issues, but send me an email so I know to
check.

Thanks!

Dave

Commit message:
This is an early version of the JobActionFactory implementation,
which provides a generic interface to create QActions that operate
on jobs. This class will eventually be used by plugins to extend
functionality.

The abstract JobActionFactory class defines the interface for
the factory. The abstract OpenWithActionFactory provides some
utilities for launching an external application to view job output.
ProgrammableOpenWithActionFactory is a concrete implemention of the
OpenWithActionFactory, which may programmatically set the name of the
executable and a list of regular expressions describing the output
files it can handle.

JobView::contextMenuEvent shows how the factories are used. All
selected jobs are shown to the factory, and the factory keeps the
ones it knows how to open. If any jobs are recognized by the factory
(hasValidActions()), actions are created to open the jobs and added
to the context menu.

If an "OpenWith" action is triggered, the handler will search the
system path for an executable with the specified name. Failing that,
it prompts the user for the executable. It then attempts to resolve the
name of each job's output file by querying the appropriate program.
Finally, a new process is launched.

The chunk in mainwindow.cpp shows how the programmable factory can
be configured to open job output Avogadro. This class can easily be
configured and added via GUI.



More information about the Openchemistry-developers mailing list