Skip to main content
10-Marble
April 21, 2022
Solved

How to add submodel on right click under part structure

  • April 21, 2022
  • 1 reply
  • 4955 views

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?

Best answer by HelesicPetr

Hello @Pushpak_Old 

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

1 reply

HelesicPetr
22-Sapphire II
April 21, 2022

Hello @Pushpak_Old 

 

It's easy. Just edit a custom-actionModels.xml (codebase/config/actions) and add a submenu definition in it.

In my case I use name of submodel AVSubMenuGWT

 

HelesicPetr_2-1650539835947.png

then use this definition in a menu where you need.

for structure menu the name has to end with GWT

 

menu for psb (wtp structure)

HelesicPetr_1-1650539761805.png

 

Restart Windchill and Submenu will be there (without display name)

HelesicPetr_3-1650540068607.png

 

I guess you would need to add a Display name of the submenu.

 

Then you need to define your own RB file definition. 

 which is java file. this file should be located in <WT_HOME>/src directory and follows(respect)  package location.

In my case:

..Windchill_11.1\Windchill\src\cz\aveng\AVCustomMenu\psbCustomActionsRB.java 

 

resource file definition 

package cz.aveng.AVCustomMenu;

import wt.util.resource.RBComment;
import wt.util.resource.RBEntry;
import wt.util.resource.RBPseudo;
import wt.util.resource.RBUUID;
import wt.util.resource.WTListResourceBundle;

@RBUUID("cz.aveng.AVCustomMenu.psbCustomActionsRB")
public final class psbCustomActionsRB extends WTListResourceBundle {
 /**
 * bcwti
 *
 * Copyright 1998-2005 Windchill Technology Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Windchill Technology. You shall not disclose such confidential information
 * and shall use it only in accordance with the terms of the license
 * agreement you entered into with Windchill.
 *
 * ecwti
 *
 * <Need description here>
 **/

 @RBEntry("AVSubMenu")
 public static final String PSB_AVSubMenuGWT_DESCRIPTION = "object.AVSubMenuGWT.description";

 @RBEntry("AVSubMenu")
 public static final String PSB_AVSubMenuGWT_TITLE = "object.AVSubMenuGWT.title";

 @RBEntry("AVSubMenu")
 public static final String PSB_AVSubMenuGWT_TOOLTIP = "object.AVSubMenuGWT.tooltip";

} // end class

 

then you need to compile this resource bundle file

in windchill shell

ant -f bin/tools.xml class -Dclass.includes=cz/aveng/AVCustomMenu/psbCustomActionsRB.java

class file should be created and located in ..\codebase\cz\aveng\AVCustomMenu\psbCustomActionsRB.class

 

in the end the resource bundle should be added in the custom-actionModels.xml see the first picture.

 

After restart windchill the submenu should have a display name

HelesicPetr_4-1650540479443.png

 

Hope this can help.

 

PetrH

10-Marble
April 21, 2022

Hi @HelesicPetr ,
Thanks for the quick response !!!!

Now I am able to add the new action under Part structure but the only problem I am getting is like its getting hide everytime. Do I need to set any other property to get it visible except validator .


HelesicPetr
22-Sapphire II
April 21, 2022

Hello @Pushpak_Old 

Are you talking about your actions in a submenu or the submenu?

 

All action names in the structure have to end with GWT (internal names in customaction.xml). 

It the WGT is not there, then it is hidden all the time.

 

in my example you can see that my custom actions always end with GWT

HelesicPetr_0-1650541729417.png

 

 

PetrH