cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

How to add submodel on right click under part structure

Pushpak_Old
9-Granite

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

11 REPLIES 11

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

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 .


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

 

Hello @HelesicPetr,


I am talking about submenu which I added under part structure I gave the names which ends with GWT only but still the action is getting hidden all the time.
Is there anything else have to do?

Hi @Pushpak_Old ,

 

There isn't any preference that can allow or disallow the action. Only Profiles(just for OOTB actions).

If you use own actions then there is not reason why custom action is not shown.

Different are OOTB actions. There are many actions which you can use anywhere and also some of them are not allowed to use anywhere.

For a better help I would need to see your definition of customActions and customActionModel because I don't want to shoot as a blind man 😄 

 

So share the definition screenshots and so on.

 

If you follow the previous instructions it has to work. I configured it previous day just to proof if it works that way.

 

If not, there must be some misspelling.

 

PetrH

 

Hi @HelesicPetr ,

I added submodel in the psbRelatedPartTreeContextMenu as mentioned below

PB_10020575_0-1650611707081.png

After that I added model like as shown-

PB_10020575_1-1650611890230.png

But Now I am not getting the Action and Submenu under part Structure when I right click on it.

PB_10020575_2-1650611982534.png

 

@Pushpak_Old 

 

Does the resourceBundle exists? Compiled? as a class?  if no, remove this from the line.

 

don't forget to restart server or if you change just custom action xmls you can use reload action from customization tools.

 

PetrH

Hi @Pushpak_Old 

 

btw, do the custom actions exist in a customAction.xml definition? Are they correctly defined?

so do they work outside of the submenu?

if not, the submenu is not shown. 

 

PetrH

Hello @Pushpak_Old ,

There is another point with adding a customAction to a structure.

The definition in customAction have to follow some rules.

 

specific class is needed in a command... (LaunchURLAction or LaunchCustomURLAction)

 

More you can find in an another thread How to add a custom-action to Windchill PSB where command is-not...

 

Hope this can help.

 

PetrH

Hi @HelesicPetr ,
Thanks for your solution I can able to see action.

I have one doubt -

Which method I can use in the validator to hide the action on the right click on structure?

 

I tried the following method but did not worked-

UIValidationResultSet.newInstance(UIValidationResult.newInstance(validationKey, UIValidationStatus.HIDDEN)

 

 

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

Top Tags