6.1.3 Locks and the user-interface
These different types of lock and locking strategies are
designed to reflect the normal pattern of modeling tool usage, to give the most
efficient and invisible support.
Starting and ending sessions and transactions are actions
that are explicitly carried out by the user. Locking, on the other hand, is
performed automatically by MetaEdit+ on behalf of the user, based on the
user’s actions. Why this distinction? Virtually every action in MetaEdit+
requires some kind of locking operation or check, and the burden on the user of
manually setting and releasing the locks would be huge. In addition, the safety
of the work done in a transaction depends on the correct locks being obtained at
the correct times: any mistake, and the transaction would probably be unable to
commit because of conflicting changes with another
user.
Types of data
For our purposes, we can divide data in MetaEdit+ into three
kinds:
 | conceptual
graphs |
 | representational
graphs and their
elements |
 | conceptual
objects, relationships, roles and
properties |
A representational graph is a
diagram, matrix or table. A conceptual graph is the ‘real’ data that
underlies that representational graph: a conceptual graph may have several
different representations. Information stored by a representational graph and
its elements includes the positions of individual symbols, the order of items on
an axis in a matrix, and the widths of the columns in a table. Correspondingly a
conceptual graph stores information about which objects belong to the graph, how
they are connected together via relationships, and what other graphs they
explode to.
Locks in editors
These first two types of data are session locked in connection
with opening an editor on a representational graph. MetaEdit+ will automatically
try to obtain locks both for the representational graph, and for the underlying
conceptual graph. The success of these locks determines which actions the user
may perform in that editor: if one or both locks fail, the editor will still
open, but some of the menu items will be hidden, and other e.g. mouse operations
may have no effect. You can view lock information in editors through Info Tool
(
Graph | Graph Info).
For instance, if a diagram is opened and locked
successfully, but the conceptual graph cannot be locked, the user will be able
to move symbols around in the diagram, but not be able to add new objects or
relationships to the graph. He will however be able to add a symbol for an
object that already exists in the conceptual graph (Shift-click). If
neither lock was obtained, the user’s actions will be restricted to
scrolling, zooming, viewing selected types, and editing the properties of the
objects etc. in the graph.
For as long as the editor remains open, the user will keep
the locks he initially obtained on opening it. If he wants to relinquish the
locks, or to try to gain more locks, he should close and reopen the editor on
that representation graph.
Short-lived locks
Whilst locks
in editors are generally
held for a while, maybe over several transactions (session locks), other locks
in MetaEdit+ are often held only for a single transaction (although their
effects will be felt by other users throughout any transaction overlapping the
one where these were locked). These are the transaction locks on individual
objects, relationships, and roles, and on their individual properties.
The most common use of such locks is in property dialogs.
When a user opens a dialog on an object’s properties, MetaEdit+ attempts
to lock all that object’s properties, so they can be changed. If one or
more of the locks fail, then no locks are taken, and the user can only view the
properties in the property dialog: the OK button will be grayed. If all
locks were obtained, the user will be able to press the OK button to
accept his changes.
Similar short-lived locks are taken in various other
circumstances, often so that their success is not noted in any particular way,
but a failure to obtain a lock will be shown to the user as a warning dialog. In
general these warnings are no real cause for concern, and the user will be able
to continue working as normal.
Locks and creating new graphs
When a user creates a new graph, it is automatically added to
the collection of graphs owned by the current default project. This collection
is of course also used by other users, and so changes to it by two users in
overlapping transactions would normally not be possible. MetaEdit+ uses a
special locking strategy for these collections, though, which normally allows
many users to add to them simultaneously. Under certain circumstances however it
may happen that the collection is locked so that a user cannot create a new
graph in that project.
As with other locking problems, the solution is to have
the other user whose lock conflicts with yours commit their transaction, and
then for you to commit your transaction. In that way you will see the new graph
the other user created, and also be able to lock the collection to add your new
graph.