3d com

 

Adding a New Query Dialog

How to add a new dialog and execute a query from it
Use Case

Abstract

This article shows how to add a new panel in the Portal transient area and execute a Query from it.


What You Will Learn With This Use Case

This use case is intended to help you add a new dialog in the Portal transient area. This dialog is created with the CATJDialog APIs. It is displayed by selecting one row in a list and clicking a new icon added to the Toolbar and the Contextual Menu.

[Top]

The CAALCANavCustoQuery Use Case

CAALCANavCustoQuery is a use case of the CAALCANavigator.edu framework that illustrates the LCANavigator customization capabilities.

[Top]

What Does CAALCANavCustoQuery Do

For CAALCANavCustoQuery create a new command named custoquery and associate a new icon with it. For the command to be executed, implement the execute function in a class extending LCANavCommand. Finally create a new CATJDialog panel named CustoQuery which controller is CAALcnCustoqueryController.java

[Top]

How to Launch CAALCANavCustoQuery

To launch CAALCANavCustoQuery, you will need to set up the build time environment, then compile CAALCANavCustoQuery along with its prerequisites, set up the run time environment, and then execute the use case [1].

Customize the untime view: Replace in the runtime view CustoTestGeneric.xml and rename it to Generic.xml

[Top]

Where to Find the CAALCANavCustoQuery Code

The CAALCANavCustoQuery use case is made of a single module CAALcnCustoQuery.mj module of the CAALCANavigator.edu framework:

Windows InstallRootDirectory\CAALCANavigator.edu\CAALcnCustoQuery.mj\
Unix InstallRootDirectory/CAALCANavigator.edu/CAALcnCustoQuery.mj/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

To create the custoquery command and its panel, there are four steps:

  1. Creating a the New Command
  2. Creating a New Icon for the Command
  3. Implementing the execute Function
  4. Creating the New CATJDialog Panel

[Top]

Creating a the New Command

Name the new command: custoquery.

To map the new command to the desired action defined in the new command class :

Create/Update manually the properties files to be deployed in the runtime view.

Name the new command: custoquery.

Create:/resources/pprregistry/command/definition/custoquery.xml with the following content:

<Command name="custoquery" readonly="true" icon="$/I_CMD_custoquery.gif" msgcatalog="CustoQuery"/>

Update (for this new command to apply to all LCA types): /resources/pprregistry/command/ENOVIA/assignment/Generic.xml

Add the following line:

<Command  name="custoquery"    multiRowEnabled="false" enablement="true"  visibility="true"/>

[Top]

Creating a New Icon for the Command

Create a new icon of 16x16 pixels identifying the new command on the Toolbar/Contextual menu:

[Top]

Implementing the execute Function

In the new class CAALcnCustobase.CAALcnCustocmds.command.custoquery.Generic.java extending LCANavCommand implements the execute function:

This new class implement the "custoquery" command for the object type "Generic" (the parent of all types.)
  • Retrieve the UUIDs of the selected objects
  • Check if one and only one object was selectd
  • Stack the CustoproQuery panel with the UUID for which the object will be queried
...
public class Generic extends LCANavCommand
{
  public void execute( CATSession iSession )
  {
    String[] uuids = getUUIDs( iSession );
	if( uuids == null || uuids.length == 0 ) {
	  MessageStack.pushInfoMessage( "custoQuery", "NoObjectSelected", null, iSession );
	  showStatusMessage( iSession, false );
	  return;
	}
	else if ( uuids.length > 1 )
	{
	  MessageStack.pushInfoMessage( "custoQuery", "MoreThenOneObjectSelected", null, iSession );
	  showStatusMessage( iSession, false );
	  return;
	}
	String parms = "UUIDPARAM="+uuids[0];
	this.stackSingleObjectDialog( iSession, "CustoQuery", parms );
  }
}
...

[Top]

Creating the New CATJDialog Panel

Create the new CATJDialog panel CustoProperties to be displayed in the transient area. The new controller extends LCANavDialogController

Call super in Create for the controller to automatically retrieve the document:

...
  public void onCreate( CATDialog iDialog, CATNotification iNotification, Object iData )
  {
    super.onCreate( iDialog, iNotification, iData );
  }
...

Implement the onDocumentChanged method:

  • Retrieve the selected UUIDs
  • Retrieve the object
  • Display the object name on the Query panel
...
  public void onDocumentChanged(CATDialog iDialog, CATNotification iNotification, Object iData) {
    String uuid = (String)getParameter("UUIDPARAM");
    _dob =  LCANavUtils.getDataObject( iDialog.getSession(), uuid, ENOVTypeMask.READ_MASK);
    _key.setTitle(_dob.getObjectName());
  }
  ...

Callbak implementation for OK (Run Query):

  • Create the query
  • Add the criteria
  • Run the query and fill the table with the rsult
...
  public void onOK(CATDialog iDialog, CATNotification iNotification, Object iData)
  {
	ENOVIQuery query = ENOVQueryFactory.getQueryEngine(LCANavUtils.getLogonToken(iDialog));
	query.initialize(_dob.getObjectType());
	String val = _dob.getObjectName();
	query.addCriteria("V_name", val);
	try
	{
	  query.runQuery();
	  _queryResults = query.getQueryResults();
	  fillTable();
	}
	catch (ENOVWebException e){;}
  }
  ...

Fill list table with query result:

  • Retrieve object type
  • Retrieve logon token
  • Create a ENOVDataPPRTablemodel
  • Add the model to the table to display the list
...
  private void fillTable()
  {
    if( _queryResults == null || _queryResults.length == 0 )
	  return;
	String type = _dob.getObjectType();
	ENOVILogonToken token = LCANavUtils.getLogonToken(_tableResults);
	_model = new ENOVDataPPRTableModel( _tableResults, type, _queryResults, token, true);
	_model.setPreferencePrefix("custoquerylist");//List specific Preferences for the list
	_tableResults.setKeyModel( _model );
	_tableResults.setMultipleSelection( true );
  }
  ...

Create the CustoQuery.CATNls file with the following content for all new NLS values

Title="My Customized Query";

Frame1.FrameInfo.Info.Title="Click OK to query :";

Command.custoquery.title = "Customized Query";

[Top]


In Short

This use case shows hwo to create a command that can be executed from a new CATJDialog panel in the Portal transient area. First a new comand is created thanks to RADE, and a new icon is associated with it. Then the command code is created by extending LCANavCommand to implement the execute function. The CATJDialog panel is finally created along with its different callbacks to allow for triggering the server command. 

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Jun 2005] Document created
[Top]

Copyright © 1994-2005, Dassault Systèmes. All rights reserved.