MobilityDesigner2Listening

Visual Mobility Designer - How to Listen on DesignDocument Changes - Module VMD IO (vmd.io)

Contents


Abstract

This document shows hot how to listen on the DesignDocument changes. It describes hot to get notification about events like switching between DesignDocuments, closing Designdocument. Knowledge of this part of Mobility API is needed in designing additional Visual Mobile Designer modules and it's not require to create Custom Components for VMD.

Core functionality - DesignDocumentAwarness interface and DataObjectContext class

The DesignDocumentAwareness is responsible for notifying application that state of DesignDocument has been changed. Interface has only one method "setDesignDocument" which is called every time when new DocumentDesign is set or DesignDocument references are set to null.

The DesignDocumentAwareness interface:


public interface DesignDocumentAwareness {

    public void setDesignDocument (DesignDocument designDocument);

}

In practice there is only two state to handle.

1) The DesignDocument object passed through setDesignDocument IS NOT NULL. It basically means that received DesignDocument object IS ACTIVE.

2) The DesignDocument object passed through setDesignDocument IS NULL. It basically means that received DesignDocument object IS NOT ACTIVE any more.

Based on the combination of this information developer can make a decision and take action in VMD Module. To receive notification about state of the DesignDocument from DesignDocumentAwareness listener user has to register instance of DesignDocumentAwreness in the DataObjectContext using method "addDesignDocumentAwareness" and from this moment module should be aware of DesignDocument changes.

Using DesignDocumentAwarness

This part shows how to implement DesignDocumentAwareness in example module.

There is a lot of example of usage of the DesignDocumentAwareness almost every module of VMD uses this functionality. This interface is used in case when developer needs to do some tasks when Visual Midlet is activated or deactivated. Particular examples:

  • User opens Visual Midlet then user recives new instance of DesignDocument.
  • User opens Visual Midlet then user receives instance of DesignDocument.
  • User closes Visual Midlet then user receives null references.
  • User switches from Visual Midlet to any other type of file then null references are set.

Combination of this component helps inform developer about what is going on with DesignDocument and take action like initialization of modules, loading cash, flushing cache, cleaning references and many other tasks.

Places in the Visual Mobile Designer with DesignDocumentAwarness implemented:

  • VMD Flow Designer (vmd.flow) - FlowViewController
  • VMD Properties (vmd.propertirs) - PropertiesNodesManager
  • VMD Structure (vmd.structure) - DocumentController
  • VMD MIDP (vmd.midp) - ExportFlowAsImageAction
  • VMD MIDPNB (vmd.midpnb) - SVGFormFileChangePresneter
  • VMD Screen (vmd.screen) - ScreenViewController
  • and many more

contact: Karol Harezlak

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo