0% found this document useful (0 votes)
83 views10 pages

Creating Custom Preference

This document provides a guide on creating custom preferences in Windchill using the LoadFile method and linking a Resource Bundle. It details the types of preferences available, including combo box, boolean, and string preferences, along with the necessary XML structure and Java resource bundle usage. Additionally, it covers how to retrieve and delete these preferences programmatically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views10 pages

Creating Custom Preference

This document provides a guide on creating custom preferences in Windchill using the LoadFile method and linking a Resource Bundle. It details the types of preferences available, including combo box, boolean, and string preferences, along with the necessary XML structure and Java resource bundle usage. Additionally, it covers how to retrieve and delete these preferences programmatically.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

 

   

CUSTOM  PREFERENCES  
How  to  create  Windchill  custom  preferences    

Abstract  
This  document  shows  how  to  create  Windchill  custom  preferences  by  using  the  LoadFile  method  
and  how  to  create  and  link  a  Resource  Bundle  with  the  custom  preferences.    

FELCO  Solutions,  Inc.    


By  J.D  Felkins  at  FELCO  Solutions  
April  17,  2015  
Revision  A  
FELCO  Solutions  Inc.  

     
Table  of  Contents  
Overview  ......................................................................................................................................................  2  
Resource  Bundle  ...........................................................................................................................................  2  
Prefenece  LoadFile  .......................................................................................................................................  3  
Catergory  ..................................................................................................................................................  3  
Combo  Box  Preference  .............................................................................................................................  4  
LoadFile  ................................................................................................................................................  4  
Java  Resource  Bundle  ...........................................................................................................................  4  
Result  in  Preference  Page  .....................................................................................................................  5  
Boolean  Preference  ..................................................................................................................................  5  
LoadFile  ................................................................................................................................................  5  
Java  Resource  Bundle  ...........................................................................................................................  6  
Result  in  Preference  Page  .....................................................................................................................  6  
String  Preference  ......................................................................................................................................  7  
LoadFile  ................................................................................................................................................  7  
Java  Resource  Bundle  ...........................................................................................................................  7  
Result  in  Preference  Page  .....................................................................................................................  7  
Using  the  Prefrence  in  the  Java  Code  ...........................................................................................................  8  
Deleteing  a  Preference  .................................................................................................................................  9  
 

 
   

Page  1  of  9  
 
FELCO  Solutions  Inc.  

 Custom  Preferences  
Overview  
Companies sometimes need custom preferences to be able to set preferences or variables
of cusotm applications. There are three comman types of preferences selections that can be
used in a perference page, and they are pull down selections, radion button selections, and
using string input fields. A LoadFile method is used to create preferences and a resource
bundle is used for labels, descriptions, displaying names, and defining variable names in
selections fields of a preference.

Resource  Bundle    
The resource bundle is a Java class that extends WTListResourceBundle. The class defines
the lables and values type in the cusotm preference. Labels are needed for displaying
names and descriptions of preference categories, which the new preference will be visible
under in Preference Management UI. Labels are also needed for the display names,
descriptions and long descriptions of each preference under the preference category. The
LoadFile to create the preference, discussed later, references the resource bundle labels.

Below is the example of a resource bundle.

Page  2  of  9  
 
FELCO  Solutions  Inc.  

Prefenece  LoadFile  
A LoadFile is a XML fromated file that includes special keys,handlers, and tags to create
Windchill object types. It is a out of the box utility that is easy to use and supported by PTC.
The loadfile includes three handlers shown below to create preferences:

1. wt.preference.LoadPreference.createPreferenceCategory: To create a category node


2. wt.preference.LoadPreference.createPreferenceDefinition: To create a perference
3. wt.preference.LoadPreference.setClientDefinitionLink: To link the perference

To load a LoadFile, go to the windchill shell and type the below example.

windchill wt.load.LoadFromFile –d <full path>/myloadfile.xml

Catergory    
The catergory node is the node of which the perference will be defined under the tree
structure within the perference utility page. The LoadFile fomat to create a catergory is
shown below.

The  java  resource  bundle  package  


name.   The  java  resource  bundle  variables  to  call  
out  the  labels  

Page  3  of  9  
 
FELCO  Solutions  Inc.  

Combo  Box  Preference  


The combobox preference is shown below. The csvhandler needs to be in one line and not
sepearte lines as shown below or the preference will throw errors when selected in the
preference interface. Each Attribute in the LoadFile references the Resource Bundle shown
below.

LoadFile   The  internal  name  that  is  unique  in  the  system.    

A  
B  
C  

D   The  csvhandler  needs  be  in  one  line.    

Java  Resource  Bundle    


The resource bundle is shown below for the combo box preference. The bold attributes are
referenced in the LoadFile to display the @RBEntry content in the preference page.

The  display  labels  shown  in  the  


preference  page.    

The  Options  shown  in  the  pull  down  menu  in  


the  preference  page    

Page  4  of  9  
 
FELCO  Solutions  Inc.  

Result  in  Preference  Page  


The result is shown below for the pull down preference . The cirlce labels shows the
matching circle labels in the LoadFile displayed in the previous page.

D   B  
A  

C  

D  

Boolean  Preference  
The boolean preference is shown below. Each Attribute in the LoadFile references the
Resource Bundle shown on the following page. The LoadFile defines the Boolean type in the
csvhandle tag and sets the default vale in the csvdefaultValue tag.

LoadFile   The  internal  name  that  is  unique  in  the  system.    

A  
B  
C  
D  

Page  5  of  9  
 
FELCO  Solutions  Inc.  

Java  Resource  Bundle    


The resource bundle is shown below for the boolean preference. The bold attributes are
referenced in the LoadFile to display the @RBEntry content in the preference page.

Result  in  Preference  Page  


The result is shown below for the boolean preference . The cirlce labels shows the matching
circle labels in the LoadFile displayed in the previous page.

A   D   B  

C  

Page  6  of  9  
 
FELCO  Solutions  Inc.  

String  Preference  
The string preference is shown below. Each Attribute in the LoadFile references the
Resource Bundle shown on the following page. The LoadFile defines the String type in the
csvhandle tag and sets the default vale in the csvdefaultValue tag.

LoadFile   The  internal  name  that  is  unique  in  the  system.    

A  
B  
C  

D  

Java  Resource  Bundle    


The resource bundle is shown below for the boolean preference. The bold attributes are
referenced in the LoadFile to display the @RBEntry content in the preference page.

Result  in  Preference  Page  


The result is shown below for the String preference . The cirlce labels shows the matching
circle labels in the LoadFile displayed in the previous page.

A   B  
D  

Page  7  of  9  
 
FELCO  Solutions  Inc.  

C  

Using  the  Prefrence  in  the  Java  Code  


Java classes can get any preferences in the system by knowing the internal name and the
and the client name of a preference. The below code shows how to retrieve a preference.

String prefValue = PreferenceHelper.service.getValue("INTERNAL NAME", "CLIENT NAME").toString();

The  Internal  Name    

The  Client  Name    

Custom the Preference table to view the Internal Name, Handler, Context, and Visibility.
This is help to find the information needed for retrieve a preference in the Java code.

Page  8  of  9  
 
FELCO  Solutions  Inc.  

Deleteing  a  Preference  
A LaodFile needs to be created to delete a custom preference as shown below. The internal
name is used to delete the preference that is defined in the csvname tag.

Page  9  of  9  
 

You might also like