Customizing Location in Occurrences Tab
You can add a custom Location string format in the Occurrences tab in Matrix Editor. You can override the translation of the individual coordinate values into the desired Location string format. The custom Location string format appears in attribute panel layouts and table or tree columns. The custom individual coordinate values appear in the attribute panel layouts and table or tree columns. Also, the Occurrences tab synchronizes the values when they are modified. For customization, implement the following methods:
ExampleGWTLocationCellEditor and CustomLocationWidget: These are responsible for bi-directional translation between the Location string and the individual coordinate values.
ExampleGWTLocationCellRenderer: This method is responsible for rendering in the attribute panel layouts and table columns.
ExampleGWTDataUtility: This method indicates ExampleGWTLocationCellEditor and ExampleGWTLocationCellRenderer for occurrenceMatrixLocation attribute. Bind ExampleGWTDataUtility with occurrenceMatrixLocation attribute in cat-dataUtilities.properties.xconf.
A Paste or modification to the "Location" string is properly translated into the individual coordinate values using the customization. The preference Allow pasting location to occurrence must be enabled. A modification to any coordinate value is properly translated into the Location string value using the customization. Verify that any validation related to improper user input is presented in the context of the custom Location string format. Verify that a supported "utility" API is available that properly translates the "Location" string for use in customizations. Any modification to the "Location" string via a supported API call will translate the individual coordinate values using the customization. Any modification to the individual coordinate values via a supported API call will translate the "Location" string format using the customization.
* 
The solution for customizing the Location field will follow the same approach used to customize other attributes within the Matrix Editor.
Create a custom GWT module and compile client side GWT code in the ME application Create custom GWT attribute renderer to display the attribute differently than an out-of-the-box renderer. Specify the renderer in the data utility class (method used is set Rendere ())
Create a custom GWT Attribute Editor for any custom attributed defined on a part, part master, baseline member link or usage link, that allows you to edit and save the attribute value.
Pre-requisite
To apply the customization, you must have the understanding of the following:
Basic web development using JAVA
GWT
Custom tags
HTML forms
Customization Points
Implementing ExampleGWTLocationCellEditor
The ExampleGWTLocationCellEditor method extends CustomTreeCellEditor and implements HasWidgets interface. It provides CustomLocationWidget to LocationField in constructor and handles specialKeyEvents.
Implementing CustomLocationWidget
CustomLocationWidget extends LocationPasteWidget that already has six individual fields created and registered all the necessary events for synchronization of fields. Key methods to override are:
protected void createPastePanel(): locationPasteField must be created here and placed in the mainPanel.
protected void syncFocusFields(): Responsible for synchronization between the individual fields and locationPasteField. This method is executed every time there is a synchronization required between the location input and the individual fields. For example, if you paste the correct location in the location input field.
protected void syncLocationPasteField(): Responsible for synchronization between the locationPasteField and the individual fields. This method is executed every time there is a synchronization required between the individual fields and a single location input. For example, if you modify one of the location fields.
Implementing LocationPasteField
The LocationPasteField is an input field where you can paste location string. This extends FocusTextField<String>. Key methods to override are:
protected boolean validateFormat (): This method validates the location string given by the user. Validation happens every time there is a change in the location input.
public String[] getErrorMessages(): Returns the array of messages that are issued to the user if the validatateFormat method returns false.
protected boolean isAllowableCharacter(char key): Validates whether the given character is allowed in locationPasteField. If not, it will not be added in the field.
Implementing ExampleGWTLocationCellRenderer
ExampleGWTLocationCellRenderer must extend CustomCellRenderer<M>. Override the render method to customize.
Implementing ExampleGWTDataUtility
Needs to indicate ExampleGWTLocationCellEditor and ExampleGWTLocationCellRenderer.
Binding ExampleGWTDataUtility with Location Attribute
Add the following entry to the <WT_HOME>/codebase/com/ptc/cat/cat-dataUtilities.properties.xconf file:
<Option serviceClass="com.ptc.cat.dataUtilities.ExampleGWTDataUtility"
requestor="java.lang.Object"
selector="occurrenceMatrixLocation"
cardinality="duplicate"/>
Propagate this change by running the xconfmanager –pf command.
Customizing Validation of Location Provided by User
Implement the protected boolean validateFormat in LocationPasteField.
Customizing Translation between Location Input and Individual Location Fields during Synchronization
To customize the translation between the Location input and the individual Location fields during synchronization of fields, implement the protected void syncFocusFields() in CustomLocationWidget.
Customizing Translation between Individual Location Fields and Location Input during Synchronization
To customize the translation between the individual Location fields and Location input during synchronization of fields, implement the protected void syncLocationPasteField () in CustomLocationWidget.
Customizing Location Format in Attribute Panel Layouts and Table Tree Columns
To customize the Location format that appears in the Attribute panel layouts and in the table or tree columns, override the render method in ExampleGWTLocationCellRenderer.
Sample Code
The following is the sample code that you can use to customize the Location format from %vX%vY%vZ%aX%aY%aZ to %aZ%aY%aZ%vZ%vY%vX.
ExampleGWTLocationCellEditor.java
CustomLocationWidget.java
ExampleGWTLocationCellRenderer.java
ExampleGWTDataUtility.java
¿Fue esto útil?