Teamcenter Rich Client Customization : Overview

Lets give a short and quick overview of Rich client customization.
For better understanding , please read this page once you done with client customization guide PDF.


The client is the user interface (UI) layer and is built and customized using the Java language (rich client) or JavaScript (thin client) and other methods. The server layer can be customized using the Integration Toolkit (ITK) and the C++ programming language.


The rich client is based on Eclipse, your customizations have access to all Eclipse extension points and OSGi services. They can also use Teamcenter-developed customization techniques. To customize the rich client, you can use:

· Base Eclipse extension points and services (for example, the org.eclipse.ui.menus extension point).

· Teamcenter extension points and services (for example, the application extension points).

· Teamcenter customization mechanisms (for example, style sheets).

Within the Teamcenter rich client user interface, application functionality is provided in perspectives and views. Some applications use perspectives and views to arrange how functionality is presented.

You can control the behavior and display of Teamcenter applications in both the rich client and the thin client using options and preferences.

· Preferences are configuration variables  stored in a Teamcenter database that are read when a Teamcenter session is initiated.
· Options are preferences presented in the rich client by category
The Teamcenter rich client is hosted within the Eclipse rich client platform (RCP) framework.  The RCP is a general purpose application framework which provides strong support for modular and extensible component-based development through the use of plug-ins.
Following are some of the basic tasks you perform during client customizations:
·Change the layout of pages in both the rich client and thin client using style sheets.
For more information, see Using style sheets.
·Set up your environment to perform rich client-only customizations.
For more information, see Enable rich client customization.
·Override Teamcenter commands.
For more information, see Suppressing menu commands.
·Create custom forms on the rich client.
For more information, see Methods of form customization.
·Add a command to a menu on the rich client.
For more information, see Adding menu commands to a menu,toolbar,and shortcut menu.
Style sheets are the easiest way to codelessly customize the rich client and thin client. You can customize the display by editing the style sheet. The advantages are:
·You can customize using configuration instead of coding.
·The customization affects both the rich client and thin client.
The three parts to the MVC paradigm are:
·Command
·Menu contributions
·Handler
·
Command has a globally unique ID and represents the abstract semantic concept of a behavior, such as copy, paste, and save. A command is  not the implementation of that behavior nor is it the visual representation of that behavior.
<command id="com.teamcenter.rac.command"
     name="%com.teamcenter.rac.command.name">
</command>
Menu contributions represent a particular view or visual representation of a command. The menu contributions create the menu and toolbar structures and insert them into the correct Eclipse location. The location is specified as an Uniform Resource Identifier (URI) and can be any one of the following:
·Main menu
·Main toolbar
·View toolbar
·View menu
·Context (popup) menu
·Trim area
The menu contribution can define a menu label, mnemonic, or icon. It contains visual references to already defined commands.
The menu contribution can define when it will be visible with a visibleWhen clause. The visibleWhen clause refers to all standard Eclipse expressions. This expression can be very simple or very complex and evaluates to either true or false which determines whether a menu is visible or not.
<menuContribution locationURI="menu:org.eclipse.ui.main.menu">
   <menu id="file" label="%menu.file.label" mnemonic="%menu.file.mnemonic">
      <command commandId="org.eclipse.ui.file.refresh"
                mnemonic="%command.refresh.mnemonic"
                style="push">
      </command>
      <separator name="sep1" visible="true"/>
      <command commandId="org.eclipse.ui.file.exit"
                mnemonic="%command.exit.mnemonic"
                style="push">       </command>    </menu> </menuContribution>
handler implements one particular behavior for a given command. For any given command, there can be zero or several handlers defined. However only none or one handler may be active for a given command. The active handler controls the command’s enabled state.
Handlers most commonly  extend the AbstractHandler class
Handlers are provided an application context in their execute(*) method
If a command has no active handlers defined, any menu contributions defined for a command are not visible
The handler can be declaratively activated via the ActiveWhen clause or programmatically activated.
There are two different methods you use to distribute rich client customizations, depending if the rich client is a two-tier or four-tier client.
·For four-tier clients, use a solution file and the Web Application Manager (insweb).
.
For two-tier clients, use Teamcenter Environment Manager (TEM) Updates Manager.
·to place the menu command at the bottom of the  Tools menu. Replace the entire contents of the plugin.xml file with the following code:
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.6"?> <plugin> <extension point="org.eclipse.ui.commands">
               <command
                  name="Sample Command"
                  id="com.mycom.addmenuitem.commands.sampleCommand">
               </command>
            </extension>
            <extension point="org.eclipse.ui.handlers">
               <handler
                  commandId="com.mycom.addmenuitem.commands.sampleCommand"
                  class="com.mycom.addmenuitem.handlers.SampleHandler">
              </handler>
            </extension>
            <extension point="org.eclipse.ui.menus">
               <menuContribution locationURI="menu:tools?after=additions">
                  <command
                     commandId="com.mycom.addmenuitem.commands.sampleCommand"
            mnemonic="S"
                     icon="icons/sample.gif"
                     id="com.mycom.addmenuitem.menus.sampleCommand">
                     <visibleWhen>
               <reference
                  definitionId="com.teamcenter.rac.ui.inMainPerspective">
               </reference>
                     </visibleWhen>
         </command>
               </menuContribution>
   </extension>
</plugin>
The visibleWhen clause uses the com.teamcenter.rac.ui.inMainPerspective definition to control visibility. This definition is in the com.teamcenter.rac.common plug-in's plugin.xml file. Each Teamcenter perspective has an inMainPerspective definition, usually in the plug-in's plugin.xml file.
For example, the inMainPerspective definition for Structure Manager is in the plugin.xml file in the com.teamcenter.rac.pse plug-in. If you want the menu command to be visible in Structure Manager, change the visibleWhen clause to the following:

<visibleWhen>
   <reference
      definitionId="com.teamcenter.rac.pse.inMainPerspective">
   </reference>
</visibleWhen>

to place the menu command on the shortcut menu

<menuContribution 
         locationURI="popup:org.eclipse.ui.popup.any?after=additions">
 
To place the button on the My Teamcenter toolbar
<menuContribution 
         locationURI="toolbar:navigator_Toolbar?after=additions">
Each Teamcenter perspective has its own toolbar. 
For example, the My Teamcenter toolbar is navigator_Toolbar, and 
the Structure Manager toolbar is pse_Toolbar. 
The toolbar is usually defined in the plugin.xml file for the perspective. 
For example, the pse_Toolbar is defined in the plugin.xml file in the com.teamcenter.rac.pse plug-in.

That means if we want to go for any module then we can check its plugin.xml file to have its toolbar id ,menu perspective id  to use .
<menuContribution
            locationURI="menu:com.teamcenter.rac.ui.views.DetailsView?after=group4">
         <menu
               id="closeMenu"
               label="Close">
            <command
                  commandId="com.mycom.exitcommand.command1.Exit"
                  label="Exit"
                  style="push"
                  tooltip="Exit the application">
            </command>
         </menu>
      </menuContribution>

<menuContribution
            locationURI="toolbar:com.teamcenter.rac.ui.views.DetailsView">
         <toolbar
               id="com.mycom.exitcommand.toolbar1">
            <command
                  commandId="com.mycom.exitcommand.command1.Exit"
                  icon="icons/sample.gif"
                  label="Exit"
                  style="push"
                  tooltip="Exit the application">
            </command>
         </toolbar>

 Add a toggle menu item:

<command
            categoryId="com.mycom.toggle.commands.category"
            defaultHandler="com.mycom.toggle.handlers.ToggleInfoHandler"
            id="com.mycom.toggle.commands.infoCommand"
            name="Info">
         <state
               class="org.eclipse.ui.handlers.RegistryToggleState:true"
               id="org.eclipse.ui.commands.toggleState">
         </state>

State element specify that I am toggle command

IMP Note:
If you make changes to any of the .properties files, or you add new plug-ins or change plug-in content, you must run the genregxml script to ensure your changes are included when the rich client starts. This enhances performance because it caches the properties so they can be loaded at startup.
(location :TC_ROOT\portal\registry\genregxml )
Add a view to the rich client:
Important things to add custom view is   Plugin.xml include below statement
<extension point="org.eclipse.ui.views">
      <view
         name="MyCom Custom View"
         class="com.mycom.customview.views.CustomView"
         id="com.mycom.customview.views.CustomView">
      </view>
   </extension>
Class indicates that specified class will create View 
Create  class and that class must extends ViewPart class and override createPartControl 
Method
Format :
public void createPartControl(Composite parent) {
               parent.setLayout( new FillLayout() );
               Text t = new Text( parent, SWT.BORDER );
 
}
We can say parent is our frame on which we add element .
View appears in Window→Show View→Other→Other→MyCom Custom View.
Add a new rich client application:i.e
Adding Application like my teamcenter(if wanted to  appear just below it or in  navigation view then  disply mode is primary else display mode secondary and need to select from available application like workflowdesigner available. )
Plugin.xml must contain
<extension point=”com.teamcenter.rac.aifrcp.appliation”>
<aif_app_item
                        Displaymode=”primary”
        groupName="Mycompany"
        icon="icons/defaultapplication_32.png"
        id="com.mycom.customapp"
        name="Custom Application"
        ordinality="200"
        perspective_id="com.mycom.customapp.perspectives.CustomPerspective"
        session="com.teamcenter.rac.kernel.TCSession"
        tooltip="Custom Application"/> 
 
<extension point="org.eclipse.ui.perspectives">
      <perspective
        class="com.mycom.customapp.perspectives.CustomPerspective"
        icon="icons/defaultapplication_16.png"
        id="com.mycom.customapp.perspectives.CustomPerspective"
        name="Custom Application"/>
   </extension>
 
<extension point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension targetID="*">
         <perspectiveShortcut 
         id="com.mycom.sendtoapp.perspectives.CustomPerspective" />
      </perspectiveExtension>
   </extension>
 
   <extension point="org.eclipse.ui.views">
      <view
         allowMultiple="false"
         class="com.mycom.customapp.views.CustomView"
         icon="icons/pview.gif"
         id="com.mycom.customapp.views.CustomView"
         name="Custom View"/>
   </extension>
When application is loaded perspective i.e CustomPerspective will get called and in that perspective we have added view so viewcode i.e CustomView  will get called.
 
Specifying a perspectiveShortcut indicates that another perspective (specified by id) should be added to the Window>Open Perspective... menu of the target perspective
public class CustomPerspective implements IPerspectiveFactory {
 
public void createInitialLayout(IPageLayout layout) { // IPageLayout interface 
               // TODO Auto-generated method stub
        layout.setEditorAreaVisible(false);
        String editorArea = layout.getEditorArea();
        IFolderLayout top = layout.createFolder("top", IPageLayout.TOP, -2f, 
         editorArea);
        top.addView( "com.mycom.customapp.views.CustomView" );
        }
}

A page layout defines the initial layout for a perspective within a page in a workbench window.
This interface (IPageLayout interface) is not intended to be implemented by clients.
When a perspective is opened, it creates a new page layout with a single editor area. This layout is then passed to the perspective factory  createInitialLayout(IPageLayout)  where additional views and other content can be added, using the existing editor area as the initial point of reference.

createFolder(id, relationship,ration,referenacepart)

CustomView will be 
public class CustomView extends ViewPart {
        
        public CustomView() {
               super();
        }
        @Override
        public void createPartControl(Composite parent) {
 
        // add text or component  to parent etc .
}
Add an application to the Teamcenter Send To menu
Command :
<extension point="org.eclipse.ui.commandImages">
      <command
         icon="icons/defaultapplication_16.png"
         id="com.mycom.sendtoapp.sendto">
      </command>
   </extension>
Menu :
<extension point="org.eclipse.ui.menus">
      <menuContribution 
         locationURI="popup:com.teamcenter.rac.sendto?after=additions">
         <command
               commandId="com.mycom.sendtoapp.sendto">
Handler :
<extension point="org.eclipse.ui.handlers">
      <handler
         commandId="com.mycom.sendtoapp.sendto"
  class="com.teamcenter.rac.common.handlers.SendToHandler:com.mycom.sendtoapp.perspectives.CustomPerspective">
         <enabledWhen>
            <iterate ifEmpty="false">
               <reference definitionId="com.mycom.sendtoapp.sendToActive"/>
            </iterate>
         </enabledWhen>
      </handler>
See handler is teamcenter handler which will handle the request and we have provided to it our perspective as value i.e object selected is send to our perspective 
Create our own perspective and View as created before 
The SendToHandler handler takes the perspective ID to open as an argument.
The SendToHandler handler shows the specified perspective, gets the registered OpenService (registered in activator setupServices () method)service, then calls the OpenService.open() method.
Activator.java 
protected void setupServices(BundleContext context) {
               // TODO Auto-generated method stub
       
 Dictionary<String, String> properties = new java.util.Hashtable<String, String>();
        // Register the open service
        properties.put( IServiceConstants.PERSPECTIVE,
                    "com.mycom.sendtoapp.perspectives.CustomPerspective" );//perspective id
        CustomOpenService customOpenService = new CustomOpenService();

        context.registerService( IOpenService.class.getName(),
                customOpenService, properties );
               
        }
Openservice  which we have registerd above :
 public class CustomOpenService implements IOpenService {
        @Override
        public boolean close() throws Exception {
               // TODO Auto-generated method stub
               return false;
        }
        @Override
        public boolean open(final InterfaceAIFComponent cmp) {
               Display.getDefault().asyncExec( new Runnable() {
                       public void run() {
                               IWorkbenchWindow window = PlatformUI.getWorkbench()
                                              .getActiveWorkbenchWindow();
                               MessageDialog
                                              .openInformation(window.getShell(),
                                                             "CustomOpenService",
                                                             "You sent this component to the SendTo Application: "
                                                                            + cmp.toString());
                       }
               });
               return false;
        }
        @Override
        public boolean open(InterfaceAIFComponent[] cmps) {
               // TODO Auto-generated method stub
               return false;
        }
}

Override Teamcenter commands

<extension
         point="org.eclipse.ui.handlers">
      <handler
            commandId="com.teamcenter.rac.newItem"   // THIS ID IS id OF NEW ITEM option  WHICH WE have IN TEAMCNTER
            class="com.mycom.myitem.handlers.MyItemHandler">  //AND PROVIDED OUR HANDLER SO IT wil get executed WHEN NEW ITEM IS CREATED
Workbench Core Expressions:
Core expressions are used declaratively in the plugin.xml files, and
programmatically with some of the services provided in the workbench. 

Declarative Expression Examples

  1. Basic IStructuredSelection
  2. IResources and the Package or Project Explorer
  3. Active Contexts
  4. Active Views and Editor
  5. ActionSets and Contexts

Basic IStructuredSelection

Most of the tree or table like viewers return an IStructuredSelection.
For example, the Project Explorer and Package Explorer. 

When using the default variable you must treat it as an java.util.Collection. That means using
<count> or <iterate>

Ex. The expression below returns true
if all of the selected items are Person. 

<enabledWhen>

    <iterate ifEmpty="false">

        <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

    </iterate>

</enabledWhen>
This is equivalent to:
<enabledWhen>

    <with variable="selection">

        <iterate ifEmpty="false">


            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </with>

</enabledWhen>
The behaviour of iterate is: 


iterate ands the results of evaluating its child
     expressions for each element in the collection, unless you set the operator attribute.

Default
     operator is and.

iterate with an operator of and returns
     true if the collection is empty, unless you set the ifEmpty attribute.


Ex.  If you want to be enabled if only one Person is selected, you can include a count element.  
<enabledWhen>

    <with variable="selection">

        <count value="1"/>

        <iterate ifEmpty="false">

            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </with>

</enabledWhen>

The same expression using the default variable: 

<enabledWhen>

    <and>

        <count value="1"/>

        <iterate ifEmpty="false">

            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </and>

</enabledWhen>

Resources and the Package or Project Explorer

The Package Explorer is a mixture of org.eclipse.core.resources.IResource, org.eclipse.jdt.core.IJavaElement and
other classes.


Ex. If you are trying to find all of the "*.java"
files, you would need to: 


Iterate through the default variable.

Adapt the selection elements to your class, in this
     case org.eclipse.core.resources.IResource.

Use one of the org.eclipse.core.resources property
     testers to test the org.eclipse.core.resources.IResource property.

<enabledWhen>


   <with variable="selection">


       <iterate ifEmpty="false">


        <adapt type="org.eclipse.core.resources.IResource">


           <test property="org.eclipse.core.resources.name"


             value="*.java"/>


        </adapt>


       </iterate>


   </with>


</enabledWhen>

When working with the current selection and property testers it does not
always make sense to use adapt.
In these situations it is a good practice to check that the object under test
is a valid type for that property tester: 

<enabledWhen>

    <with variable="selection">

        <iterate ifEmpty="false">

            <instanceof type="org.eclipse.core.resources.IResource"/>

            <test property="org.eclipse.core.resources.name"

                     value="*.java"/>

        </iterate>

    </with>

</enabledWhen>

Active Contexts

If your handler should be enabled when your view or editor activates a context,
you can use the activeContexts
variable. Contexts are defined in the org.eclipse.ui.contexts
extension point and activated programmatically using the org.eclipse.ui.contexts.IContextService.

<enabledWhen>

    <with variable="activeContexts">

        <iterate ifEmpty="false" operator="or">

            <equals value="org.example.view.context"/>

        </iterate>

    </with>

</enabledWhen>
Note: activeContexts is a collection of the active context IDs as strings.

Active Views and Editor

For handlers that are to be contributed to a specific view or editor, you
can use activeEditorId and activePartId in the activeWhen clause. 


This is an example for a handler that should be active in text editors: 

<activeWhen>

    <with variable="activeEditorId">

        <equals value="org.eclipse.ui.DefaultTextEditor"/>

    </with>

</activeWhen>
The following clause is for a handler that's active while in the Project
Explorer: 
<activeWhen>

    <with variable="activePartId">

        <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>

    </with>

</activeWhen>

ActionSets and Contexts

As of 3.3 all org.eclipse.ui.actionSets
(Deprecated)


Variables Provided in the Workbench :  http://wiki.eclipse.org/Command_Core_Expressions


Condition for handler is defined using  activewhen and enabledwhen clause:  i.e when the handler  should execute the behaviour of the command.

<extension

 point="org.eclipse.ui.handlers">

 <handler

  commandId="commandId"

  class="org.eclipse.compare.Command">

 

  <activeWhen>

   <with variable="selection"> //The variables used for command framework evaluation are //listed in ISources.java file org.eclipse.ui.ISources

                               //represent The current global selection.

    <count value="1" />

    <iterate operator="and">

     <adapt type="org.eclipse.core.resources.IResource" />

    </iterate>


//This element is used to iterate over a variable that is of
type java.util.Collection, or a variable that adapts to
//org.eclipse.core.expressions.IIterable. If the object in focus is not one of
the above then a CoreException with an //ExpressionStatus will be thrown while
evaluating the expression. The child expressions of an iterate expression are
//combined using the "and" operator.


//operator - either "and" or "or".


//ifEmpty - the value returned from the "iterate" expression if the collection is empty.


   </with>

  </activeWhen>

 

 </handler>

 <handler

  commandId="other.commandId"

  class="org.eclipse.ui.TalkToMe">

  <activeWhen>

   <with variable="activePartId"> // The ID of the currently active part.

    <equals value="org.eclipse.ui.views.SampleView"/>

   </with>

  </activeWhen>

 </handler>

</extension>



<extension

 point="org.eclipse.ui.handlers">

 <handler

  commandId="commandId"

  class="org.eclipse.Handler">

  <enabledWhen>

   <with variable="activeContexts"> //activeContexts is collection so iterate to check for         context

     <iterator operator="or">

       <equals value="org.eclipse.ui.contexts.window"/>

     </iterator>

   </with>

  </enabledWhen>

 </handler>

</extension>
Localize your customizations:


Add the following line to the end of the MANIFEST.MF file:

Bundle-Localization: plugin

 

All the static value like name of command and label etc will be taken from plugin.properties file

at the same level as the plugin.xml file.using file->new file

Add the following name/value pairs to the 

 

plugin.properties file:

 

myMenuitem.label=My Hello world

myTooltip.tip=My Say hello world

myCommand.name=My Command
 

Add a Spanish localization by creating a 

plugin_es.properties:

 

myMenuitem.label=Mi Hola mundo

myTooltip.tip=Mi para Decir hola mundo

myCommand.name=Mi Orden
 


Edit the plugin.xml file
replacing hard coded values with %keyname for the name/value pairs you typed in the plugin.properties file. For example:
label="%myMenuitem.label"

 

<command

         name="%myCommand.name"

         categoryId="com.mycom.l10n.commands.category"

         id="com.mycom.l10n.commands.sampleCommand">

      </command>

 

<menu

            label="%myMenuitem.label"

            mnemonic="M"
Verify the customization thus far.

a.       Create a new configuration for the Spanish locale by choosing Run→Run Configurations (or Run→Debug Configurations) and specifying -nl es instead of -nl ${target.nl} on the Arguments tab. For example:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl es
We have modified a label command name to display in Spanish but how the message displayed in handler be modified to display in Spanish or other locale.
Localize the message.

a.      
In Eclipse, choose Handler in which we have message and
then Source→Externalize Strings. 


Sample Handler
public class SampleHandler extends AbstractHandler {


       /**


        * The constructor.


        */


       public SampleHandler() {


       }





       /**


        * the command has been executed, so extract
extract the needed information


        * from the application context.


        */


public Object execute(ExecutionEvent event) throws ExecutionException {


IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);


MessageDialog.openInformation(window.getShell(),"TestProject","Hello,Eclipse world");


  return null;


}


}
This creates the Messages.java and messages.properties
Content of messages.properties  :

SampleHandler_0=TestProject


SampleHandler_1=Hello, Eclipse world

b. 

Now Again Select Handler and then Source→Externalize Strings

Customize
the rich client properties files:


·  Open WinZip, navigate to the TC_ROOT\portal\plugins
directory, and open the JAR file that contains the properties file you want to
override. The file name has the form property.properties. For example, to override the mpp.properties file, open the com.teamcenter.rac.cme.legacy.jar
file.


·  Extract the properties file you want to


override from the JAR file. For example, extract the mpp.properties
file.


·  In a text editor, open the properties file to


determine the syntax of the property you want to modify.


· Create a new property_user.properties in a text editor. For example, if you


open the mpp.properties file, create the mpp_user.properties file.


Update the project tabs.


open plugin.xml


Select the com.teamcenter.rac.util.tc_properties extension point. 


Click the plugin.xml tab. Type text in the file so it


looks like the following:

<?xml version="1.0" encoding="UTF-8"?>

<?eclipse version="3.6"?>

<plugin>

   <extension

          point="com.teamcenter.rac.util.tc_properties">

   </extension>

</plugin>

Create a package.


a.       In the Package Explorer view, right-click your project and choose New→Package.


b.      In the Name box, type the path name where the properties file was
originally. For example, if you originally extracted the mpp.properties file, the package name should be com.teamcenter.rac.cme.mpp.


c.       Click the MANIFEST.MF tab and type your new package at the end of the Export-Package line. For example, if your project name
is com.mycom.propertiesfile and the new package is called com.teamcenter.rac.cme.mpp, the line
should read:


d.  Export-Package: com.mycom.propertiesfile, com.teamcenter.rac.cme.mpp

Developing forms using JavaBeans


You can create a custom Java panel
(JPanel) assigned to a custom business object
and display the properties using JavaBeans.

when a user selects a custom ItemRevision  business object and chooses the Viewer view or View→Properties,


the custom panel is displayed.


Panel rendering is registered to the business object by placing the following command
into a custom stylesheet_user.properties file:

Syntax: custom-business-object-name.JAVARENDERING=package-name.custom-java-panel-name


A) 


1.      Create a custom item business object.


2.     In the Business Objects view, open the item revision business object (for example, A4_MyItemRevision), click the Properties tab,
and create the custom persistent properties you want to display in the panel, 


3.      Set the Enabled property constant to True for each of the new properties


4.      Deploy the custom template


B)


1.      Create the Eclipse project.


2.      Update the Dependencies tab.


3.      Update the Extensions tab.


Click the Add button.


               Select the com.teamcenter.rac.util.tc_properties extension point


4.      choose New→Package.


5.      In the Name box, type com.teamcenter.rac.stylesheet


6.      Right-click the com.teamcenter.rac.stylesheet package and choose New→File. In
the File Name box, type CustomSamplePanel.java and click Finish


7.      Open the project’s Runtime tab, click the Add button, and add the com.teamcenter.rac.stylesheet
package.


8.      Open the CustomSamplePanel.java file and enter the code: of Property to be
displayed

Ex: JPanel jPanel1 = new JPanel();


              jPanel1.setLayout( new PropertyLayout() );

               jPanel1.setOpaque( false );

               JLabel jLabel1 = new JLabel("Test double");

                       PropertyTextField doubleTextField = new PropertyTextField();

                 doubleTextField.setProperty( "a4_MyDouble" );//This statement will get the value from database to rendere in Our Panel as a4_MyDouble is Property name in BMIDE

ench Core Expressions:

Core expressions are used declaratively in the plugin.xml files, and
programmatically with some of the services provided in the workbench. 

Declarative Expression Examples


Basic IStructuredSelection

IResources and the Package or Project Explorer

Active Contexts

Active Views and Editor

ActionSets and Contexts

Basic IStructuredSelection

Most of the tree or table like viewers return an IStructuredSelection.
For example, the Project Explorer and Package Explorer. 

When using the default variable you must treat it as an java.util.Collection. That means using
<count> or <iterate>

Ex. The expression below returns true
if all of the selected items are Person. 

<enabledWhen>

    <iterate ifEmpty="false">

        <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

    </iterate>

</enabledWhen>

This is equivalent to: 

<enabledWhen>

    <with variable="selection">

        <iterate ifEmpty="false">


            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </with>

</enabledWhen>


The behaviour of iterate is: 


iterate ands the results of evaluating its child
     expressions for each element in the collection, unless you set the operator attribute.

Default
     operator is and.

iterate with an operator of and returns
     true if the collection is empty, unless you set the ifEmpty attribute.


Ex.  If you want to be enabled if only one Person is selected, you can include a count element. 

<enabledWhen>

    <with variable="selection">

        <count value="1"/>

        <iterate ifEmpty="false">

            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </with>

</enabledWhen>

The same expression using the default variable: 

<enabledWhen>

    <and>

        <count value="1"/>

        <iterate ifEmpty="false">

            <instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>

        </iterate>

    </and>

</enabledWhen>


Resources and the Package or Project Explorer

The Package Explorer is a mixture of org.eclipse.core.resources.IResource, org.eclipse.jdt.core.IJavaElement and
other classes.


Ex. If you are trying to find all of the "*.java"
files, you would need to: 


Iterate through the default variable.

Adapt the selection elements to your class, in this
     case org.eclipse.core.resources.IResource.

Use one of the org.eclipse.core.resources property
     testers to test the org.eclipse.core.resources.IResource property.

<enabledWhen>


   <with variable="selection">


       <iterate ifEmpty="false">


        <adapt type="org.eclipse.core.resources.IResource">


           <test property="org.eclipse.core.resources.name"


             value="*.java"/>


        </adapt>


       </iterate>


   </with>


</enabledWhen>

When working with the current selection and property testers it does not
always make sense to use adapt.
In these situations it is a good practice to check that the object under test
is a valid type for that property tester: 

<enabledWhen>

    <with variable="selection">

        <iterate ifEmpty="false">

            <instanceof type="org.eclipse.core.resources.IResource"/>

            <test property="org.eclipse.core.resources.name"

                     value="*.java"/>

        </iterate>

    </with>

</enabledWhen>


Active Contexts

If your handler should be enabled when your view or editor activates a context,
you can use the activeContexts
variable. Contexts are defined in the org.eclipse.ui.contexts
extension point and activated programmatically using the org.eclipse.ui.contexts.IContextService.

<enabledWhen>

    <with variable="activeContexts">

        <iterate ifEmpty="false" operator="or">

            <equals value="org.example.view.context"/>

        </iterate>

    </with>

</enabledWhen>

Note: activeContexts is a collection of the active context IDs as strings.


Active Views and Editor

For handlers that are to be contributed to a specific view or editor, you
can use activeEditorId and activePartId in the activeWhen clause. 


This is an example for a handler that should be active in text editors: 

<activeWhen>

    <with variable="activeEditorId">

        <equals value="org.eclipse.ui.DefaultTextEditor"/>

    </with>

</activeWhen>

The following clause is for a handler that's active while in the Project
Explorer: 

<activeWhen>

    <with variable="activePartId">

        <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>

    </with>

</activeWhen>


ActionSets and Contexts

As of 3.3 all org.eclipse.ui.actionSets
(Deprecated)


Variables Provided in the Workbench :  http://wiki.eclipse.org/Command_Core_Expressions


Condition for handler is defined using  activewhen and enabledwhen clause:  i.e when the handler  should execute the behaviour of the command.

<extension

 point="org.eclipse.ui.handlers">

 <handler

  commandId="commandId"

  class="org.eclipse.compare.Command">



  <activeWhen>

   <with variable="selection"> //The variables used for command framework evaluation are //listed in ISources.java file org.eclipse.ui.ISources

                               //represent The current global selection.

    <count value="1" />

    <iterate operator="and">

     <adapt type="org.eclipse.core.resources.IResource" />

    </iterate>


//This element is used to iterate over a variable that is of
type java.util.Collection, or a variable that adapts to
//org.eclipse.core.expressions.IIterable. If the object in focus is not one of
the above then a CoreException with an //ExpressionStatus will be thrown while
evaluating the expression. The child expressions of an iterate expression are
//combined using the "and" operator.


//operator - either "and" or "or".


//ifEmpty - the value returned from the "iterate" expression if the collection is empty.


   </with>

  </activeWhen>



 </handler>

 <handler

  commandId="other.commandId"

  class="org.eclipse.ui.TalkToMe">

  <activeWhen>

   <with variable="activePartId"> // The ID of the currently active part.

    <equals value="org.eclipse.ui.views.SampleView"/>

   </with>

  </activeWhen>

 </handler>

</extension>

<extension

 point="org.eclipse.ui.handlers">

 <handler

  commandId="commandId"

  class="org.eclipse.Handler">

  <enabledWhen>

   <with variable="activeContexts"> //activeContexts is collection so iterate to check for         context

     <iterator operator="or">

       <equals value="org.eclipse.ui.contexts.window"/>

     </iterator>

   </with>

  </enabledWhen>

 </handler>

</extension>


Localize your customizations:


Add the following line to the end of the MANIFEST.MF file:

Bundle-Localization: plugin

All the static value like name of command and label etc will be taken from plugin.properties file

at the same level as the plugin.xml file.using file->new file

Add the following name/value pairs to the 

plugin.properties file:

myMenuitem.label=My Hello world

myTooltip.tip=My Say hello world

myCommand.name=My Command

Add a Spanish localization by creating a 

plugin_es.properties:

myMenuitem.label=Mi Hola mundo

myTooltip.tip=Mi para Decir hola mundo

myCommand.name=Mi Orden


Edit the plugin.xml file
replacing hard coded values with %keyname for the name/value pairs you typed in the plugin.properties file. For example:

label="%myMenuitem.label"



<command

         name="%myCommand.name"

         categoryId="com.mycom.l10n.commands.category"

         id="com.mycom.l10n.commands.sampleCommand">

      </command>



<menu

            label="%myMenuitem.label"

            mnemonic="M"

Verify the customization thus far.


a.      
Create a new configuration for the Spanish locale by
choosing Run→Run Configurations (or Run→Debug Configurations) and
specifying -nl es instead of -nl ${target.nl} on the Arguments tab. For
example:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl es

We have modified a label command name to display in Spanish but how the message displayed in handler be modified to display in Spanish or other locale.

Localize the message.


a.      
In Eclipse, choose Handler in which we have message and
then Source→Externalize Strings. 


Sample Handler

public class SampleHandler extends AbstractHandler {


       /**


        * The constructor.


        */


       public SampleHandler() {


       }

       /**


        * the command has been executed, so extract
extract the needed information


        * from the application context.


        */


public Object execute(ExecutionEvent event) throws ExecutionException {


IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);


MessageDialog.openInformation(window.getShell(),"TestProject","Hello,Eclipse world");


  return null;


}


}

This creates the Messages.java and messages.properties

Content of messages.properties  :

SampleHandler_0=TestProject


SampleHandler_1=Hello, Eclipse world


b.  Now Again Select
Handler and then Source→Externalize Strings

Customize
the rich client properties files:


·  Open WinZip, navigate to the TC_ROOT\portal\plugins
directory, and open the JAR file that contains the properties file you want to
override. The file name has the form property.properties. For example, to override the mpp.properties file, open the com.teamcenter.rac.cme.legacy.jar
file.


·  Extract the properties file you want to


override from the JAR file. For example, extract the mpp.properties
file.


·  In a text editor, open the properties file to


determine the syntax of the property you want to modify.


· Create a new property_user.properties in a text editor. For example, if you


open the mpp.properties file, create the mpp_user.properties file.


Update the project tabs.


open plugin.xml


Select the com.teamcenter.rac.util.tc_properties extension point. 


Click the plugin.xml tab. Type text in the file so it


looks like the following:

<?xml version="1.0" encoding="UTF-8"?>

<?eclipse version="3.6"?>

<plugin>

   <extension

          point="com.teamcenter.rac.util.tc_properties">

   </extension>

</plugin>


Create a package.


a.       In the Package Explorer view, right-click your project and choose New→Package.


b.      In the Name box, type the path name where the properties file was
originally. For example, if you originally extracted the mpp.properties file, the package name should be com.teamcenter.rac.cme.mpp.


c.       Click the MANIFEST.MF tab and type your new package at the end of the Export-Package line. For example, if your project name
is com.mycom.propertiesfile and the new package is called com.teamcenter.rac.cme.mpp, the line
should read:


d.  Export-Package: com.mycom.propertiesfile, com.teamcenter.rac.cme.mpp


Developing forms using JavaBeans


You can create a custom Java panel
(JPanel) assigned to a custom business object
and display the properties using JavaBeans.

when a user selects a custom ItemRevision  business object and chooses the Viewer view or View→Properties,


the custom panel is displayed.


Panel rendering is registered to the business object by placing the following command
into a custom stylesheet_user.properties file:

Syntax: custom-business-object-name.JAVARENDERING=package-name.custom-java-panel-name


A) 


1.      Create a custom item business object.


2.     In the Business Objects view, open the item revision business object (for example, A4_MyItemRevision), click the Properties tab,
and create the custom persistent properties you want to display in the panel, 


3.      Set the Enabled property constant to True for each of the new properties


4.      Deploy the custom template


B)


1.      Create the Eclipse project.


2.      Update the Dependencies tab.


3.      Update the Extensions tab.


Click the Add button.


               Select the com.teamcenter.rac.util.tc_properties extension point


4.      choose New→Package.


5.      In the Name box, type com.teamcenter.rac.stylesheet


6.      Right-click the com.teamcenter.rac.stylesheet package and choose New→File. In
the File Name box, type CustomSamplePanel.java and click Finish


7.      Open the project’s Runtime tab, click the Add button, and add the com.teamcenter.rac.stylesheet
package.


8.      Open the CustomSamplePanel.java file and enter the code: of Property to be
displayed
                     

Ex: JPanel jPanel1 = new JPanel();


              jPanel1.setLayout( new PropertyLayout() );

               jPanel1.setOpaque( false );

               JLabel jLabel1 = new JLabel("Test double");

                       PropertyTextField doubleTextField = new PropertyTextField();

                 doubleTextField.setProperty( "a4_MyDouble" );//This statement will get the value from database to rendere in Our Panel as a4_MyDouble is Property name in BMIDE


9.      Right-click the com.teamcenter.rac.stylesheet


package and choose New→File. In the File Name box, type stylesheet_user.properties
and click Finish. 


This file adds content to the stylesheet.properties
file. The _user name in the file indicates that this is a custom file
provided by a user.


 Open the stylesheet_user.properties file and enter the following line:

A5_MyItemRevision.JAVARENDERING=com.teamcenter.rac.stylesheet.CustomSamplePanel

  This setting will render the Property based


on CustomPanel code provided we have set the preference in Rich CLient


In the rich client,
create a preference for this rendering. Choose Edit→Options→Index→New
and in the Name box type A4_MyItemRevision.JAVARENDERING and in
the Values box, type com.teamcenter.rac.stylesheet.CustomSamplePanel.


Deploy Project and check:


Select Item
revision of custom Item and then View properties


*
The base component for a rich client form is a JPanel component that provides flexibility for the
placement of forms within different parent containers

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Teamcenter 11客户端定制程序员指南是一本面向Teamcenter客户端界面定制开发人员的指南。本指南旨在为开发人员提供必要的信息和工具,以便他们可以定制和扩展Teamcenter客户端以满足其客户特定的需求。 该指南介绍了客户端开发环境、客户端界面的结构和体系结构、客户端扩展程序的开发和部署以及客户端UI定制。其中包括了如何使用定制工具创建自己的UI可定制性模板(UCM)和如何使用SDK创建自定义功能、菜单、工具栏、图标、对话框、视图等。 此外,该指南还介绍了如何使用Teamcenter的应用程序编程接口(API)和Teamcenter Services(TCS)开发自定义数据存储和检索解决方案以及如何连接到其他工具和应用程序等技术。 总之,Teamcenter 11客户端定制程序员指南为开发人员提供了丰富的指导和可操作的技术细节,帮助他们更好地理解和利用Teamcenter客户端的强大功能,进而提高其开发效率和客户满意度。 ### 回答2: Teamcenter 11客户端自定义程序员指南是一份详细的文档,旨在帮助开发人员理解和实现Teamcenter客户端的定制需求。这份指南提供了关于Teamcenter客户端架构的详细介绍,例如客户端框架、UI框架、数据访问等。此外,该指南还提供了一些在Teamcenter客户端中定制的开发策略和技术,包括客户端扩展、自定义业务对象和事件驱动等。通过使用这些技术,开发人员可以创建高度定制化的Teamcenter客户端,以适应其业务流程和需求。此外,该指南还包括许多使用案例和示例代码,以帮助开发人员深入了解和掌握这些技术。总之,Teamcenter 11客户端自定义程序员指南是帮助开发人员深入了解Teamcenter客户端定制的宝贵资源,可以帮助他们实现定制化的客户端应用和提高其业务效率。 ### 回答3: Teamcenter 11 Client Customization Programmers Guide是一本详细介绍Teamcenter 11客户端自定义的指南手册。该手册旨在为开发者提供一些有用的信息和知识,以帮助他们更好地理解如何自定义Teamcenter 11客户端。手册内容主要包括以下方面: 首先介绍了Teamcenter 11客户端自定义的概念和基本原理。在此基础上,手册详细讲解了如何使用Teamcenter 11的自定义工具,包括自定义向导、样式表、命令、视图布局等方面的内容。 其次,手册还介绍了如何使用Teamcenter 11客户端自定义API开发自己的扩展应用程序。开发者可以使用这些API来访问Teamcenter 11客户端的数据和功能,并增强它们的自定义能力。手册详细介绍了这些API的使用方法和注意事项,以帮助开发者更好地理解和使用它们。 最后,手册还包括了一些面向开发者的实用技巧和建议,例如如何调试和测试自定义应用程序、如何优化自定义代码的性能等。这些技巧和建议可以帮助开发者更好地管理和维护自己的自定义代码。 总的来说,Teamcenter 11 Client Customization Programmers Guide是一本非常实用和有价值的指南手册。对于想要深入了解Teamcenter 11客户端自定义的开发者来说,阅读此手册可以帮助他们更好地掌握相关知识和技能,从而更好地开发出高效、可靠的自定义应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值