How to add submodel on right click under part structure
I wanted to add one new submodel under the part structure and Product family structure. The action should be visible on the right click of the object. So How we can do it?
I wanted to add one new submodel under the part structure and Product family structure. The action should be visible on the right click of the object. So How we can do it?
Hello
You should specify why you would hide an action.
Write own validator and use it in a action definition.
here is an example how simple validator could look like. (button\action is hidden if user is not administrator)
public class AVEditPropertiesValidator extends DefaultSimpleValidationFilter
{
private static final WVSLogger logger = WVSLogger.getLogger(AVEditPropertiesValidator.class, "cz.aveng.AVEditPropertiesValidator");
public AVEditPropertiesValidator()
{
}
public UIValidationStatus preValidateAction(UIValidationKey valKey, UIValidationCriteria criteria)
{
UIValidationStatus validatioNStatus = UIValidationStatus.ENABLED; // if STATUS is ENABLED action is shown, if is HIDDEN ...
WTReference contextObject = criteria.getContextObject();
if (contextObject != null)
{
try
{
// condition if Usera can use an action (in this case only admins can)
WTPrincipal realUser = SessionHelper.manager.getPrincipal();
Vector<String> groupsList = UtilTeam.GetUserGroup((WTUser) realUser, realUser.getOrganization().getContainer());
//boolean isUserInSAPgroup = groupsList.contains("GroupName");
boolean isUserAdmin = groupsList.contains("Administrators");
//boolean isSiteAdmin = realUser.getName().equalsIgnoreCase("administrator");
// check group member
if (!isUserAdmin)
{
validatioNStatus = UIValidationStatus.HIDDEN;
}
} catch (WTException e)
{
e.printStackTrace();
}
}
logger.debug("Exit AVConfigPropertiesValidator.preValidateAction() status=" + validatioNStatus);
return validatioNStatus;
}
}
after you create own validator class, define it in a service.properties
site.xconf example>
<Service context="default" name="com.ptc.core.ui.validation.SimpleValidationFilter"
targetFile="codebase/service.properties">
<Option cardinality="duplicate" order="1" overridable="true"
requestor="java.lang.Object"
selector="hideAVEditPropertiesValidator"
serviceClass="cz.aveng.AVConfigEditor.AVEditPropertiesValidator"/>
</Service>
if service is propagated to the properties file
add the filter to the action.xml definition (selector string is used)
<includeFilter name="hideAVEditPropertiesValidator"/>
Hope this can help
PetrH
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.