3d com |
Adding a New Edit Properties DialogHow to add a new dialog and execute a server command from it |
|
Use Case |
AbstractThis article shows how to add a new panel in the Portal transient area and execute an Update Object command from it. |
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]
CAALCANavCustoProperties is a use case of the CAALCANavigator.edu framework that illustrates the LCANavigator customization capabilities.
[Top]
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]
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]
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]
To create the custoproperties command and its panel, there are four steps:
[Top]
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]
Create a new icon of 16x16 pixels identifying the new command on the Toolbar and Contextual menu:
[Top]
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.)
... 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]
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:
... 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):
... 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]
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]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Jun 2005] | Document created |
[Top] |
Copyright © 1994-2005, Dassault Systèmes. All rights reserved.