|
Time Estimates for Completion
|
||
|---|---|---|
|
Customize Creo Elements/Direct Model Manager's classes to add a new attribute.
In this lesson you will extend a Creo Elements/Direct Model Manager class to include a new attribute which is calculated in the java business logic.
|
Description:
|
1 minutes
|
|
Lab exercise:
|
20 minutes
|
|
|
|
Java doesn't care how you name your directories, but Creo Elements/Direct engineers have found that maintaining a consistent directory structure makes it easier to find code later. The convention is to create the directory structure starting with "com" followed by the company name followed by the directory for the type of class. The class you will extend for this lab comes from the dm\biz directory, which holds business logic.
|
package com.acme.biz;
import com.osm.biz.*;
import com.osm.exception.*;
public class AcmeTimeAttribute extends DefaultAttribute {
public AcmeTimeAttribute(Object value, WMAttribute att, WMObject wmObject)
throws WMException {
super(value, att, wmObject);
}
public AcmeTimeAttribute(WMAttribute att, WMObject wmObject)
throws WMException {
super(att, wmObject);
}
@Override
public Object getValue() throws WMException {
return System.currentTimeMillis();
}
@Override
public void setValue(Object obj) throws WMException {
// don’t support set.
}
}
<Class extends="DMModel, DMReleaseProcess">
<Name catalog="awm_stda" msg_num="258">MODEL_3D</Name>
<Attribute>SimpleAttribute
<DisplayName>Simple Attribute</DisplayName>
<BusinessObjectClass>com.acme.biz.AcmeTimeAttribute</BusinessObjectClass>
<Visible>true</Visible>
</Attribute>
</Class>
<Class extends="DTModel, DTReleaseProcess">
<Name catalog="awm_stda" msg_num="10">me_model</Name>
<Attribute>Attribute
<DisplayName>Simple Attribute</DisplayName>
<BusinessObjectClass>com.acme.biz.AcmeTimeAttribute</BusinessObjectClass>
<Visible>true</Visible>
</Attribute>
</Class>

package com.acme.editor;import com.osm.biz.*;
import com.osm.exception.*;
import com.osm.editor.WMAttEditorTextField;.
public class AcmeTimeAttributeEditor extends WMAttEditorTextField {
public AcmeTimeAttributeEditor(WMAttribute wmAttribute)
throws WMException {
super(wmAttribute);
}
public AcmeTimeAttributeEditor(WMAttribute wmAttribute, boolean enabled)
throws WMException {
super(wmAttribute, enabled);
}
@Override
public void setAttributeVal(Object val) {
if (val instanceof AcmeTimeAttribute) {
AcmeTimeAttribute att = (AcmeTimeAttribute) val;
try {
setText(String.valueOf(att.getValue()));
} catch (WMException ex) {
ex.printStackTrace();
}
}
}
@Override
public Object getAttributeVal() {
return getText();
}
}
<Class extends="DMModel, DMReleaseProcess">
<Name catalog="awm_stda" msg_num="258">MODEL_3D</Name>
<Attribute>SimpleAttribute
<DisplayName>Simple Attribute</DisplayName>
<BusinessObjectClass>com.acme.biz.AcmeTimeAttribute</BusinessObjectClass>
<AttributeEditorClass>com.osm.datamgmt.editor.AcmeTimeAttributeEditor</AttributeEditorClass>
<Visible>true</Visible>
</Attribute>
</Class>
<Class extends="DTModel, DTReleaseProcess">
<Name catalog="awm_stda" msg_num="10">me_model</Name>
<Attribute>SimpleAttribute
<DisplayName>Simple Attribute</DisplayName>
<BusinessObjectClass>com.acme.biz.AcmeTimeAttribute</BusinessObjectClass>
<AttributeEditorClass>com.osm.datamgmt.editor.AcmeTimeAttributeEditor</AttributeEditorClass>
<Visible>true</Visible>
</Attribute>
</Class>
<Class>
<Name>SIMPLE_ATT_DEF</Name>
<Attribute>SimpleAttribute
<DisplayName>Simple Attribute</DisplayName>
<AttributeEditorClass>com.osm.datamgmt.biz.SimpleAttributeEditor</AttributeEditorClass>
<BusinessObjectClass>com.osm.datamgmt.biz.SimpleAttribute</BusinessObjectClass>
<Visible>true</Visible>
<SendPseudoAttributeTextReferencesToCad>true</SendPseudoAttributeTextReferencesToCad>
</Attribute>
</Class>
<Class extends="DMModel, DMReleaseProcess, SIMPLE_ATT_DEF">
<Name catalog="awm_stda" msg_num="258">MODEL_3D</Name>
</Class>
<Class extends="DMMasterdata, DMReleaseProcess, SIMPLE_ATT_DEF">
<Name catalog="awm_stda" msg_num="251">MASTERDATA</Name>
</Class>
<Class extends="DMDrawing, DMReleaseProcess, SIMPLE_ATT_DEF">
<Name catalog="awm_stda" msg_num="254">DRAWING_2D</Name>
</Class>
<Class extends="BASE_CHANGENOTE_2D, SIMPLE_ATT_DEF">
<Name catalog="awm_stda" msg_num="255">CHANGENOTE_2D</Name>
</Class>