3d com

 

Adding a New Edit Properties Dialog

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

Abstract

This article shows how to add a new panel in the Portal transient area and execute an Update Object command 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 CAALCANavCustoProperties Use Case

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

[Top]

What Does CAALCANavCustoProperties Do

For CAALCANavCustoProperties create a new command named custoproperties 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 CustoProperties which controller is CAALCnCustoPropertiesController.java

[Top]

How to Launch CAALCANavCustoProperties

To launch CAALCANavCustoProperties, you will need to set up the build time environment, then compile CAALcnCustoPropertiesController 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 CAALCANavCustoProperties Code

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

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

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

[Top]

Step-by-Step

To create the custoproperties 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: custoproperties.

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.

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

<Command name="custoproperties" readonly="true" icon="$/I_CMD_custoproperties.gif" msgcatalog="CustoProperties"/>

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

Add the following line:

<Command  name="custoproperties"    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 and Contextual menu:

[Top]

Implementing the execute Function

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

This new class implement the "custoproperties" 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 CustoproPerties panel and pass it the UUID for which the object properties will be displayed
...
public class Generic extends LCANavCommand
{
  public void execute( CATSession iSession )
  {
    String[] uuids = getUUIDs( iSession );
	if( uuids == null || uuids.length == 0 )
	{
	  MessageStack.pushInfoMessage( "custoProperties", "NoObjectSelected", null, iSession );
	  showStatusMessage( iSession, false );
	  return;
	}
	else if ( uuids.length > 1 )
	{
	  MessageStack.pushInfoMessage( "custoProperties", "MoreThenOneObjectSelected", null, iSession );
	  showStatusMessage( iSession, false );
	  return;
	}
	String parms = "UUIDPARAM="+uuids[0];
	this.stackSingleObjectDialog( iSession, "CustoProperties", 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
  • Loop in object attributes to display attribute name and value in the proper widget
...
public void onDocumentChanged( CATDialog iDialog, CATNotification iNotification, Object iData ) {
  String uuid = (String)getParameter("UUIDPARAM");
  ENOVIDataResolutionObject dro = ENOVDataResolutionFactory.getDataResolutionEngine(LCANavUtils.getLogonToken(iDialog));
  _dob = dro.getObjectFromUUID(uuid, ENOVTypeMask.EDIT_MASK);
  Enumeration e = _dob.getAttributes();
  while (e.hasMoreElements())  {
    ENOVIAttribute attr = (ENOVIAttribute)e.nextElement();
    ENOVAttributeType attType = attr.getType();
    if (attType == ENOVAttributeType.STRING_TYPE) {
      if (attr.isEditable() && attr.getName().equals("V_description")) {
        _att = attr;
        _label = new CATLabel(_mainFrame, "label", 3);
        _label.setTitle( _att.getAlias() + ":" );
        _mainFrame.setConstraints( _label, new GC(0, 0, 1, 1, GC.LEFT, GC.NOFILL) );
        _textField = new CATTextField(_mainFrame, "textfield");
        _mainFrame.setConstraints( _textField, new GC(1, 0, 1, 1, GC.LEFT, GC.FILLH) );
        String val = _dob.getAttrString( _att );
        _textField.setText(_att.getExternalValue(val));
      }
    }
  }
  if (_label == null)  {
    _label = new CATLabel(_mainFrame, "label", 3);
    _label.setTitle( "No Description Attribute on this object" );
    _mainFrame.setConstraints( _label, new GC(0, 0, 1, 1, GC.LEFT, GC.NOFILL) );
  }
}
  ...

onOK callbak implementation (Update the object on the server):

  • Retrieve the new description value
  • Update the object
  • Create and execute the server command
...

public void onOK( CATDialog iDialog, CATNotification iNotification, Object iData ){
  if(_textField == null)
    return;
  String val = _textField.getText();
  boolean ok = false;
  if( val != null )//Update object
    ok = _dob.setAttrValue( _att.getName(), val );
  //Call server
  if (ok) {
    ENOVIClientCommand cmd = ENOVCommandFactory.createClientCommand( editCommandName(), LCANavUtils.getLogonToken(iDialog) );
    cmd.setParameter( "object", _dob, false );
    ok = cmd.execute();
    MessageStack.pushMessages( cmd, _session );
    if( ok ) {
      ENOVIDataObject obj = cmd.getObjectResult( "object" );
      raiseObjectUpdatedNotification( obj );
      onCancel(iDialog, iNotification, iData);
    }
  }
  showStatusMessage( ok );
}
  ...

Return the command name for the server method used to do the update call.:

...
    protected String editCommandName(){
	  String noun = _dob.getObjectType();
	  String cmd = ENOVWebType.getWebType( noun ).getCommandName( "lcaedit" );
	  if( cmd == null ) cmd = "UpdateObjectCommand";
		return cmd;
	}
  ...

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

Title="My Customized Properties";

Command.custoproperties.title = "Customized Properties";

[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 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.