Task Based Application Libraries
Applications created using different Creo API products are interoperable. These products use Creo applications as the medium of interaction, eliminating the task of writing native-platform specific interactions between different programming languages.
Application interoperability allows Creo Object TOOLKIT Java applications to call into Creo TOOLKIT from areas not covered in the native interface. It allows you to put a Java front end on legacy Creo TOOLKIT applications.
Creo Object TOOLKIT Java can call Creo Parametric web pages belonging to Web.Link, and functions in Creo TOOLKIT DLLs. Creo Object TOOLKIT Java synchronous applications can also register tasks for use by other applications.
Managing Application Arguments
Creo Object TOOLKIT Java passes application data to and from tasks in other applications as members of a sequence of pfcArgument.Argument objects. Application arguments consist of a label and a value. The value may be of any one of the following types:
•  Integer
•  Double
•  Boolean
•  ASCII string (a non-encoded string, provided for compatibility with arguments provided from C applications)
•  String (a fully encoded string)
•  pfcSelect.Selection (a selection of an item in a Creo session)
•  pfcBase.Transform3D (a coordinate system transformation matrix)
Methods Introduced:
The class pfcArgument.ArgValue contains one of the seven types of values. Creo Object TOOLKIT Java provides different methods to create each of the seven types of argument values.
The method pfcArgument.ArgValue.Getdiscr returns the type of value contained in the argument value object.
Use the methods listed above to access and modify the argument values.
Modifying Arguments
Methods Introduced:
The method pfcArgument.pfcArgument.Argument_Create creates a new argument. Provide a name and value as the input arguments of this method.
The method pfcArgument.Arguments.create creates a new empty sequence of task arguments.
The method pfcArgument.Argument.GetLabel returns the label of the argument. The method pfcArgument.Argument.SetLabel sets the label of the argument.
The method pfcArgument.Argument.GetValue returns the value of the argument. The method pfcArgument.Argument.SetValue sets the value of the argument.
Launching a Creo TOOLKIT DLL
The methods described in this section enable a Creo Object TOOLKIT Java user to register and launch a Creo TOOLKIT DLL from a Creo Object TOOLKIT Java application. The ability to launch and control a Creo TOOLKIT application enables the following:
•  Reuse of existing Creo TOOLKIT code with Creo Object TOOLKIT Java applications.
•  ATB operations.
Methods Introduced:
Use the method pfcSession.BaseSession.LoadProToolkitDll to register and start a Creo TOOLKIT DLL. The input parameters of this method are similar to the fields of a registry file and are as follows:
•  ApplicationName—The name of the application to initialize.
•  DllPath—The full path to the DLL binary file.
•  TextPath—The path to the application’s message and user interface text files.
•  UserDisplay—Set this parameter to true to register the application in the Creo user interface and to see error messages if the application fails. If this parameter is false, the application will be invisible to the user.
The application's user_initialize() function is called when the application is started. The method returns a handle to the loaded Creo TOOLKIT DLL.
In order to register and start a legacy Pro/TOOLKIT DLL that is not Unicode-compliant, use the method pfcSession.BaseSession.LoadProToolkitLegacyDll. This method conveys to Creo Parametric that the loaded DLL application is not Unicode-compliant and built in the pre-Wildfire 4.0 environment. It takes the same input parameters as the earlier method pfcSession.BaseSession.LoadProToolkitDll.
Note
The method pfcSession.BaseSession.LoadProToolkitLegacyDll must be used only by a pre-Creo Object TOOLKIT Java application to load a pre-Wildfire 4.0 Pro/TOOLKIT DLL.
Use the method pfcSession.BaseSession.GetProToolkitDll to obtain a Creo TOOLKIT DLL handle. Specify the Application_Id, that is, the DLL’s identifier string as the input parameter of this method. The method returns the DLL object or null if the DLL was not in session. The Application_Id can be determined as follows:
•  Use the function ProToolkitDllIdGet() within the DLL application to get a string representation of the DLL application. Pass NULL to the first argument of ProToolkitDllIdGet() to get the string identifier for the calling application.
•  Use the Get method for the Id attribute in the DLL interface. The method pfcProToolkit.Dll.GetId() returns the DLL identifier string.
Use the method pfcProToolkit.Dll.ExecuteFunction to call a properly designated function in the Creo TOOLKIT DLL library. The input parameters of this method are:
•  FunctionName—Name of the function in the Creo TOOLKIT DLL application.
•  InputArguments—Input arguments to be passed to the library function.
The method returns an object of interface com.ptc.pfc.pfcProToolkit.FunctionReturn. This interface contains data returned by a Creo TOOLKIT function call. The object contains the return value, as integer, of the executed function and the output arguments passed back from the function call.
The method pfcProToolkit.Dll.IsActive determines whether a Creo TOOLKIT DLL previously loaded by the method pfcSession.BaseSession.LoadProToolkitDll is still active.
The method pfcProToolkit.Dll.Unload is used to shutdown a Creo TOOLKIT DLL previously loaded by the method pfcSession.BaseSession.LoadProToolkitDll and the application's user_terminate() function is called.
Creating Creo Object TOOLKIT Java Task Libraries
The methods described in this section allow you to setup Creo Object TOOLKIT Java libraries to be used and called from other custom Creo applications in Creo TOOLKIT or Creo Object TOOLKIT Java.
Creo Object TOOLKIT Java task libraries must be compiled using the synchronous Creo Object TOOLKIT Java library called otk.jar. Each task must be registered within the application for it to be called from external applications. Provide the following information to the application to use your Creo Object TOOLKIT Java application as a task library:
1. The required CLASSPATH settings.
2. The name of the invocation class containing the static start and stop methods.
3. The name of static Start() and Stop() methods
4. The path to the text files, if the application deals with messages or menus.
5. The registration name of the task.
6. The input argument names and types.
7. The output argument names and types.
Methods Introduced:
Use the method pfcSession.BaseSession.RegisterTask to register the task or tasks to be executed. This method has two input parameters:
•  The name of the task. This name must be provided by calling applications.
•  Object implementing the interface JLinkTaskListener that has the pfcJLinkTaskListener.OnExecute callback method overridden. The class pfcLink.DefaultJLinkTaskListener makes extending the interface easier.
The method pfcJLinkTaskListener.OnExecute is called when the calling application tries to invoke a registered task. This method must contain the body of the Creo Object TOOLKIT Java task. The method signature includes a sequence of input arguments and allows you to return a sequence of output arguments to the caller.
Use the method pfcSession.BaseSession.UnregisterTask to delete a task that is no longer needed. This method must be called when you exit the application using the application's stop method.
Launching Tasks from Creo Object TOOLKIT Java Task Libraries
The methods described in this section allow you to launch tasks from a predefined Creo Object TOOLKIT Java task library.
Methods Introduced:
Use the method pfcSession.BaseSession.StartJLinkApplication to start a Creo Object TOOLKIT Java application. The input parameters of this method are similar to the fields of a registry file and are as follows:
•  ApplicationName—Assigns a unique name to this Creo Object TOOLKIT Java application.
•  ClassName—Specifies the name of the Java class that contains the Creo Object TOOLKIT Java application’s start and stop method. This should be a fully qualified Java package and class name.
•  StartMethod—Specifies the start method of the Creo Object TOOLKIT Java application.
•  StopMethod—Specifies the stop method of the Creo Object TOOLKIT Java application.
•  AdditionalClassPath—Specifies the locations of packages and classes that must be loaded when starting this Creo Object TOOLKIT Java application. If this parameter is specified as null, the default classpath locations are used.
•  TextPath—Specifies the application text path for menus and messages. If this parameter is specified as null, the default text locations are used.
•  UserDisplay—Specifies whether to display the application in the Auxiliary Applications dialog box in the Creo application.
Upon starting the application, the static start() method is invoked. The method returns a JLink.JLinkApplication referring to the Creo Object TOOLKIT Java application.
The method pfcJLink.JLinkApplication.ExecuteTask calls a registered task method in a Creo Object TOOLKIT Java application. The input parameters of this method are:
•  Name of the task to be executed.
•  A sequence of name value pair arguments contained by the interface pfcArguments.Arguments.
The method outputs an array of output arguments. These arguments are returned by the task’s implementation of the pfcJLinkTaskListener.OnExecute call back method.
The method pfcJLink.JLinkApplication.IsActive returns a True value if the application specified by the pfcJLink.JLinkApplication object is active.
The method pfcJLink.JLinkApplication.Stop stops the application specified by the pfcJLink.JLinkApplication object. This method activates the application’s static Stop() method.