PUI (Programming User Interface) Step

Warning

The PUI process element is not available on the process palette. The element is described here because OEM customers can implement their own implementation of the process element by using the Xpert.ivy extension mechanism.

Element Details

This element is Xpert.ivy facility to integrate third party client graphical user interfaces through a Java interface. The Program User Interface element will instantiate a Java class that must implement the interface IProgramUserInterfaceProcessExtension and will then call the method perform each time a process comes to the Program User Interface. Inside the perform method the Java class may display any third party graphical user interface to the user on his client machine. The process will be further executed if the PUI implementation calls back the userInputEnded method of the interface IProgramUserInterfaceProcessExtensionListener . An object that implements the listener interface is provided as parameter of the method perform of the interface IProgramUserInterfaceProcessExtension . The common way to implement a Program User Interface bean is to extend the abstract base class AbstractProgramUserInterfaceProcessExtension . The interface also includes an inner editor class to parametrize the bean. You will find the documentation of the interface and the abstract class in the Java Doc of the Xpert.ivy Public API.

Inscription

Name Tab

This tab is included in the mask of all process elements and contains the name and a description of the element. See Name Tab for a more detailed description.

Tab PUI

On this tab you set the Java class which implements the interface IProgramUserInterfaceProcessExtension which is called when the PUI step is executed.

Figure 5.21. The PUI tab

The PUI tab

Java Class to Execute

The fully qualified name of the PUI Java class implementing IProgramUserInterfaceProcessExtension . You can use default copy & paste commands, open a Java Type Browser to search for the class. Use the New Bean Class Wizard () to create a new Java source file with an example implementation of the bean class.

Tip

You can add a graphical configuration editor for the Java call (i.e. setting the parameter values) on the PUI inscription mask. See section Tab Editor for more details.

Tab Editor

This tab displays the editor, that can be integrated in the external Java bean of the process element. The editor is implemented as an inner public static class of the Java bean class and must have the name Editor. Additionally the editor class must implement the IProcessExtensionConfigurationEditorEx interface. The common way to implement the editor class is to extend the abstract base class AbstractProcessExtensionConfigurationEditor and to override the methods createEditorPanelContent, loadUiDataFromConfiguration and saveUiDataToConfiguration. The method createEditorPanelContent can be used to build the UI components of the editor. You can add any AWT/Swing component to the given editorPanel parameter. With the given editorEnvironment parameter, which is of the type IProcessExtensionConfigurationEditorEnvironment , you can create text fields that support ivyScript and has smart buttons which provide access to the process data, environment functions and Java classes.

Here is an example of such an editor:

As you can see, the editor provides you access to any process relevant data, which can be used by your own process elements. For instance, you can easily transfer process data to your legacy system.

The following part shows the implementation of the editor shown above. As mentioned above Xpert.ivy provides the IIvyScriptEditor which represents a text field with ivyScript support and smart buttons. Inside createEditorPanelContent use the method createIvyScriptEditor from the editorEnvironment parameter to create an instance of such an editor. Use the loadUiDataFromConfiguration method to read the bean configuration and set them to the UI components. Inside this method you can use the methods getBeanConfiguration or getBeanConfigurationProperty to read the bean configuration. Use the method saveUiDataToConfiguration to save the data in the UI components to the bean configuration. Inside this method you can use the methods setBeanConfiguration or setBeanConfigurationProperty to save the bean configuration.

  public static class Editor extends AbstractProcessExtensionConfigurationEditor
  {
    private IIvyScriptEditor editorUser;
    private IIvyScriptEditor editorEventTyp;
    private IIvyScriptEditor editorLinkId;
    private IIvyScriptEditor editorFieldValue;
    
    @Override
    protected void createEditorPanelContent(Container editorPanel,
            IProcessExtensionConfigurationEditorEnvironment editorEnvironment)
    {
      editorPanel.setLayout(new GridLayout(4,2));
      editorUser = editorEnvironment.createIvyScriptEditor(null,null, "String");
      editorEventTyp = editorEnvironment.createIvyScriptEditor(null,null, "String");
      editorLinkId = editorEnvironment.createIvyScriptEditor(null, null, "String");
      editorFieldValue = editorEnvironment.createIvyScriptEditor(null, null);
      
      editorPanel.add(new JLabel("User"));
      editorPanel.add(editorUser.getComponent());
      editorPanel.add(new JLabel("Event Typ"));
      editorPanel.add(editorEventTyp.getComponent());
      editorPanel.add(new JLabel("Link-Id"));
      editorPanel.add(editorLinkId.getComponent());
      editorPanel.add(new JLabel("Feldwert"));
      editorPanel.add(editorFieldValue.getComponent());        
    }

    @Override
    protected void loadUiDataFromConfiguration()
    {
      editorUser.setText(getBeanConfigurationProperty("User"));
      editorEventTyp.setText(getBeanConfigurationProperty("EventTyp"));
      editorLinkId.setText(getBeanConfigurationProperty("LinkId"));
      editorFieldValue.setText(getBeanConfigurationProperty("Feldwert"));
    }

    @Override
    protected boolean saveUiDataToConfiguration()
    {
      setBeanConfigurationProperty("User", editorUser.getText());
      setBeanConfigurationProperty("EventTyp", editorEventTyp.getText());
      setBeanConfigurationProperty("LinkId", editorLinkId.getText());
      setBeanConfigurationProperty("Feldwert", editorFieldValue.getText());
      return true;
    }
  }    

At runtime you have to evaluate the IvyScript the user have entered into the ivy script editors. If you implement for example the AbstractUserProcessExtension class there is a perform method which is executed at runtime. At this point you want to access the configured data in the editor. The following code snippet show how you can evaluate the value of an IIvyScriptEditor . If you use the IIvyScriptEditor you only get the value by calling the executeIvyScript method of the AbstractUserProcessExtension .

  public CompositeObject perform(IRequestId requestId, CompositeObject in,
     IIvyScriptContext context) throws Exception
  {
    IIvyScriptContext ownContext;
    CompositeObject out;
    out = in.clone();
    ownContext = createOwnContext(context);

    String eventtyp = "";
    String linkId = "";
    String fieldValue = "";
    String user= "";

    user = (String)executeIvyScript(ownContext, getConfigurationProperty("User"));
    eventtyp = (String)executeIvyScript(ownContext, getConfigurationProperty("Event Typ"));
    linkId = (String)executeIvyScript(ownContext, getConfigurationProperty("Link-Id"));
    fieldValue = (String)executeIvyScript(ownContext, getConfigurationProperty("Feldwert"));
    
    // add your call here
    
    return out;
  }           

Output Tab

On this tab you can configure the output of the element (i.e. the data that leaves the element). See Output Tab for a more detailed description.

Note

On the output tab you have available an additional variable called result. The type of the variable depends on the chosen PUI bean class and it's configuration. The PUI bean class can set the value of the result variable by specifying it as the first parameter to the method userInputEnded call.