Extending Creo Elements/Direct Model Manager
The Creo Elements/Direct Model Manager Java code, XML files, and build scripts are provided with the product so partners can extend Creo Elements/Direct Model Manager to implement custom business rules and data models.
The general pattern for customizing Creo Elements/Direct Model Manager is to write Java classes to implement the new behaviors and then modify the xml file to use the new Java classes. You can also configure the behavior of your custom Java classes by incorporating values from the xml files.
The XML files
When Creo Elements/Direct Model Manager starts, it reads two xml files: wmconf.xml and another xml file. If more than two XML files are available, the user must choose one in the Login dialog.
The wmconf.xml is no longer deployed to the file system, instead the default configuration is read from the class path (WorkManager.jar). The custom.xml file is created when Creo Elements/Direct Model Manager is installed and contains the configurations entered during the installation process. You should create a new XML file to contain your customizations. This document uses the term custom xml file to refer to the XML file you are customizing.
The custom XML file contains two basic types of tags:
Property tags
Java class assignment tags
Property tags
Property tags configure general behavior, possibly for many classes. Property tags usually have simple values that are constants, such as on, true or a file name.
For example, the following tag controls whether Projects functionality is enabled:
<EnableProjects>true</EnableProjects>
Examples of Property Tags
Attribute mapping between CAD and database attributes
<InstanceNameAttributeName>
<DescriptionAttributeName>
Behavior toggles
<EnableCompare>
<EnableHistory>
<EnableProjects>
Class and attribute settings
<CanCreateInUI>
<ChangeNoteClass>
<DraftingClass>
Define default values
<InitialPositionNumber>
<InitialState>
<DisplayDateFormat>
Display settings
<DisplayName>
<Searchable>
<Visible>
<Protect>
Icon file locations
<DragIconFile>
<FileIcon>
See Valid XML tags for information about the tags.
You can create a new tag to configure your extension from the custom XML file. You can also make your extension configurable based on the tags supplied with Creo Elements/Direct Model Manager. For example, if your extension behaves differently when Projects functionality is enabled, your custom Java class can access the value of the <EnableProjects> tag.
Java class assignment tags
Java class assignment tags define a specific Java class that will be used to control a cluster of behaviors. For example, the <BusinessObjectClass> tag specifies the name of the Java class that should be used to control the interaction of Creo Elements/Direct Model Manager with specific database classes and attributes.
Java class assignment tags have values that are classes within the Creo Elements/Direct Model Manager Java code structure. You can specify classes included with the product or configure Creo Elements/Direct Model Manager to use your custom class.
For example, the following tag specifies the name of the Java class that controls the behavior of data from the database class MODEL_3D as the product is shipped:
<BusinessObjectClass>com.osm.dm.biz.DMModel3D</BusinessObjectClass>
You can configure Creo Elements/Direct Model Manager to use your custom class with a tag of this form:
<BusinessObjectClass>com.custom.dm.biz.CustomDMModel3D</BusinessObjectClass>
Examples of Java class assignment tags
Database class and attribute business objects
<AttributeEditorClass>
<BusinessObjectClass>
Table column models
<AnnotationLoadTableColumnModel>
<AnnotationSaveTableColumnModel>
Listeners
<PostApplyListener>
<PreApplyListener>
Menus
<MainMenuBarMenu>
<BomManagerMenuBarMenu>
<DefaultSendToMenu>
Editors
<EditorClass>
Accessing XML values from the Java code
Creo Elements/Direct Model Manager reads the XML files when the user logs in and creates an instance of the com.osm.biz.WMConfig object. You can use the WMConfig class methods to access the XML configuration values.
For example, getTagValue(String section, String tagValue) returns the value for the given tag in the given section.
Examples of other WMConfig methods that read XML tags
getClassAttributeTagValue (String className, String classType, String attributeName, String tag) - Returns the value for the given tag within the definition of the given class name.
getClassTagValue (String className, String tag) - Returns the value for the given tag in the given class.
getOption (String tagName) - Returns the value for the specified tag in the Options section.
getOptionList (String tagName) - Returns a list of values for the specified tag in the Options section.
getTagValueList (String section, String tagValue) - Returns a list of the tag values for the given tag in the given section.
Example of Java code that reads XML values
The method canCreateInUI from com.osm.biz.WMClass reads the class tag <CanCreateInUI>. This tag controls whether an element of the specified class can be created from the Workspace. If the tag does not exist in the xml file, the method returns a default Boolean value of false.
Example section from wmconf.xml:
<Class extends="DB_PACKET">
<Name>BASE_DBR_DEFAULT_PACKET</Name>
<BusinessObjectClass>com.osm.biz.WMPacket</BusinessObjectClass>
<DisplayName catalog="eprojects" msg_num="1129">Default Packet
</DisplayName>
<CanCreateInUI>true</CanCreateInUI>
Example of Java code that reads the <CanCreateInUI> tag:
public static boolean canCreateInUI(String className) {
synchronized (pdm.semaphore) {
try {
String canCreateNew =
WMConfig.getInstance().getClassTagValue(className, "CanCreateInUI");

if ((canCreateNew != null) && canCreateNew.equalsIgnoreCase("true")) {
return true;
}
} catch (WMException ignore) {
}

return false;
}
}
Was this helpful?