50% found this document useful (2 votes)
2K views66 pages

FPLM Teamcenter UA Client Customization Guide

FPLM Teamcenter UA Client Customization Guide
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
50% found this document useful (2 votes)
2K views66 pages

FPLM Teamcenter UA Client Customization Guide

FPLM Teamcenter UA Client Customization Guide
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
You are on page 1/ 66

FaithPLM Solutions

Simplifying complex enterprise…

Teamcenter UA Client Customization Guide

FaithPLM Solutions, Pune Page 1


FaithPLM Solutions
Simplifying complex enterprise…

What is This Document?

This Document describes various activities involved in Teamcenter UA Client


Customization.

This guide assumes reader has basic understanding of Teamcenter application.

Audience:

1. FPLM Training Participants

Manual History:

Manual Description of Author Publication Date


Revision Change
Initial version Initial version Anant B(FPLM) 18-04-2014

FaithPLM Solutions, Pune Page 2


FaithPLM Solutions
Simplifying complex enterprise…

INDEX

SR Title Page No
No
1 Eclipse Rich Client Non Programming 4
Customization
2 Rich Client Customization Environment 23
Setup
3. Overriding TC Existing Command 25
4. Add Custom Menu in TC 26
Command
MENU contribution
Handler
5. Kernel API Example 29
6. Rich Client UI Form Customization
7. Teamcenter Form Types Basis
Automatic Form
JavaBeans 55
Abstract Handler 50

FaithPLM Solutions, Pune Page 3


FaithPLM Solutions
Simplifying complex enterprise…

Eclipse Rich Client Non Programming Customization

Using style sheets


Style sheets are the easiest way to carelessly customize the rich client and thin
client. You can customize the display by editing the style sheet. The advantages
are:

Types of style sheets


Following are the available types of style sheets:
• Property
Defines the layout of the Properties dialog box.
• Form
Defines the layout of forms, such as the Item Master form or the Item
RevisionMaster form.
• Summary
Defines the layout of the Summary tab.
• Create
Defines the layout of dialog boxes used in the creation wizard when you
choose File-->New-->Other and some portions of dialog boxes when you
choose
File-->New-->object.
• Save As
Defines the layout of Save As dialog boxes when you select an object and
choose
File-->Save As.
These types are set on a style sheet using the Stylesheet Type box in the
rich client.
Types Of Stylesheet

FaithPLM Solutions, Pune Page 4


FaithPLM Solutions
Simplifying complex enterprise…

Property style sheet


The Property style sheet type defines the layout of the Properties dialog box.
To view the Properties dialog box in the rich client, right-click an object and
choose
View Properties.

FaithPLM Solutions, Pune Page 5


FaithPLM Solutions
Simplifying complex enterprise…

To view the Properties dialog box in the thin client, click the arrow on an object
and choose Properties.

To set a style sheet to the Property type, in the rich client open the style sheet
dataset in the Viewer tab and select Property in the Stylesheet Type box.
FaithPLM Solutions, Pune Page 6
FaithPLM Solutions
Simplifying complex enterprise…

Notice how this Item style sheet defines the layout of the Properties dialog box
for the selected item.PLM00075

Form style sheet


The Form style sheet defines the layout of forms, such as the Item Master form
or the Item RevisionMaster form.
FaithPLM Solutions, Pune Page 7
FaithPLM Solutions
Simplifying complex enterprise…

To view a form in the rich client, select an instance of a form and click the
Viewer tab.

To view a form in the thin client, click the arrow on a form object and choose
Open.

FaithPLM Solutions, Pune Page 8


FaithPLM Solutions
Simplifying complex enterprise…

To set a style sheet to the Form type, in the rich client, open the style sheet
dataset in the Viewer tab and select Form in the Stylesheet Type box.
Summary style sheet The Summary style sheet type defines the layout of the
Summary tab in the rich client and the Overview tab in the thin client.

FaithPLM Solutions, Pune Page 9


FaithPLM Solutions
Simplifying complex enterprise…

Summary tab in the rich client

Summary style sheet


Notice how this ItemSummary style sheet defines the layout of the Summary
tab in the rich client and the Overview tab in the thin client.

Create style sheet


The Create style sheet type defines the layout of dialog boxes used in the
creation wizard.

FaithPLM Solutions, Pune Page 10


FaithPLM Solutions
Simplifying complex enterprise…

To view creation dialog boxes in the rich client, choose File-->New-->Other.


Note Only some portions of dialog boxes are defined with the create style
sheet when you choose File-->New-->object.

To view creation dialog boxes in the thin client, choose New-->object.

FaithPLM Solutions, Pune Page 11


FaithPLM Solutions
Simplifying complex enterprise…

To set a style sheet to the Create type, in the rich client, open the style sheet
dataset in the Viewer tab and select Create in the Stylesheet Type box.

FaithPLM Solutions, Pune Page 12


FaithPLM Solutions
Simplifying complex enterprise…

FaithPLM Solutions, Pune Page 13


FaithPLM Solutions
Simplifying complex enterprise…

Notice how this ItemCreate style sheet defines the layout of the creation dialog
boxes for the Item business object

Search for style sheets


To find style sheets in the rich client, search for XMLRenderingStylesheet
datasets.
1. Click the Open Search View button .
2. Click the arrow on the Select a Search button and choose General.
Starting the search for style sheets

3. In the Type box, type XMLRenderingStylesheet.


If you are looking for style sheets for a particular kind of object, enter a string in
the Name box to look for those kinds of style sheets. For example, if you want
to find all style sheets for items or item revisions, type *Item* in the Name box.

FaithPLM Solutions, Pune Page 14


FaithPLM Solutions
Simplifying complex enterprise…

Searching for XMLRenderingStylesheet datasets


4. Press the Enter key or click the Execute the Search button .
The results are displayed in the Search Results view

FaithPLM Solutions, Pune Page 15


FaithPLM Solutions
Simplifying complex enterprise…

Viewing the search results for XMLRenderingStylesheet datasets


5. In the Search Results tab, select the style sheet you want to view. Click the
Viewer tab to see the style sheet.

FaithPLM Solutions, Pune Page 16


FaithPLM Solutions
Simplifying complex enterprise…

Viewing the style sheet contents in the rich client

Create a custom style sheet based on an existing style sheet


You can create your own custom style sheet.
For example, you create a custom business object in the Business Modeler IDE
and install it to the rich client, and you want to create a unique style sheet to
display the custom properties. To create the style sheet, in the rich client,
search for XMLRenderingStylesheet datasets, save one as your own custom
style sheet dataset, and then register the custom style sheet for use with the
custom business object.
1. In the rich client, search for a style sheet you can base your new style sheet
on.
2. In the Search Results view, select the style sheet you want to use, choose
File-->Save As, and rename it. For example, if you want to create a style sheet
to be used with a custom A5_MyItem business object, you could name the
stylesheet A5_MyItem.
The new style sheet dataset is saved in your Newstuff folder in the Home view
and is still displayed in the Viewer tab.
3. Edit the style sheet.
a. Change the named reference for the file by selecting the style sheet dataset
and choosing View-->Named References. In the Name column in the Named
References dialog box, change the old name of the file to the new save as
file name.
b. In the Viewer tab, click the arrow in the Registered Type box and select the
business object type you want to register it to. For example, if you have a
custom A5_MyItem business object added to your server, select A5_MyItem
from the list.
c. Edit the style sheet in the Viewer tab to include the elements you want
displayed in the layout.
For example, if you want to display custom properties, add them where you
want them to appear on the page, like this:
<page title="General" titleKey="tc_xrt_General">
<column>
<property name="object_string" column="32"/>
<separator/>
<property name="object_name" column="32"/>
<property name="object_desc" />
FaithPLM Solutions, Pune Page 17
FaithPLM Solutions
Simplifying complex enterprise…

<separator/>
<property name="owning_user" renderingHint="objectlink"
modifiable="false" />
<property name="owning_group" renderingHint="objectlink"
modifiable="false" />
<property name="last_mod_user" /> <property name="a5_MyDate"/>
<property name="a5_MyDouble"/>
<property name="a5_MyFlag"/>
<property name="a5_MyLongString"/>
<property name="a5_MyLOV"/>
<property name="a5_MyRef"/>
</column>
<column>
<image/>
</column>
</page>
d. To change the style sheet type, click the arrow in the Stylesheet Type box.
You can choose one of the following types:
Property
Form
Summary

4. When you are done making changes, click the Apply button in the lower
right
corner of the view.

FaithPLM Solutions, Pune Page 18


FaithPLM Solutions
Simplifying complex enterprise…

Registering style sheets


Style sheets are registered to specific business object types so that they appear
when the object type is selected in the user interface. To register a style sheet
using the rich client, open the style sheet in the Viewer view, select the
business object type in the Registered Type box, and click the Apply button in
the lower right corner of the Viewer view.
Register a style sheet
Each commonly used business object type (such as item, folder, and dataset)
has style sheets that define the layout of its properties in the user interface.
1. To see the business object that a style sheet is registered to, in the rich
client, first search for XMLRenderingStylesheet datasets.
For more information, see Search for style sheets.
2. Select the style sheet, and in the Viewer tab, see the business object listed in
the Registered Type box on the style sheet

FaithPLM Solutions, Pune Page 19


FaithPLM Solutions
Simplifying complex enterprise…

Viewing the business object type that the style sheet is registered to

1. To specify how the style sheet is to be used, select it in the Stylesheet


Type box (for example, for properties display, form rendering, Summary
view, or creation dialog boxes).

Modify the Summary view using style sheets


You can modify what appears in the rich client Summary view and the thin
client Overview panel by codelessly changing the rendering using Teamcenter
style sheets.

FaithPLM Solutions, Pune Page 20


FaithPLM Solutions
Simplifying complex enterprise…

The Properties dialog box and the item create panes in the New Business
Object wizard also use style sheet rendering and can be similarly customized.
You can also use this technique to create custom renderings for new custom
business objects.
For more information about using style sheets, see Using style sheets.
This example adds the checked_out property to the folder summary header
rendering, and a Contents section to the folder summary page.
1. In the rich client, find all XMLRenderingStylesheet datasets using the
search capability by removing all search criteria except for Type and setting it
to XMLRenderingStylesheet. For more information, see Search for style sheets.
2. Select the FolderSummary dataset and choose File-->Save As. Type
MyFolderSummary in the Name box.
3. Select MyFolderSummary and the Viewer pane.
The XML style sheet is displayed in the viewer.
4. In the Registered Type box, select Folder, and in the Stylesheet Type box,
select Summary.
5. Edit the MyFolderSummary style sheet to add the checked_out property to
the header area. The following is an example of the modified header area:
<header>
<image source="type"/>
<property name="owning_user" />
<property name="last_mod_date" /> <property name="checked_out" />
<property name="release_status_list" />
<property name="object_type" />
</header>
6. Click the Apply button.
7. Choose Edit-->Options, click the Search link at the bottom of the Options
dialog box, locate the Folder.SUMMARYRENDERING preference, and verify
that the preference value has been changed from FolderSummary to
MyFolderSummary.
If it has not been changed, click the Edit button and change the value to
MyFolderSummary.
8. Select a folder and select the Summary pane.
You see the checked_out property displayed as Checked-Out.

FaithPLM Solutions, Pune Page 21


FaithPLM Solutions
Simplifying complex enterprise…

Adding a property to the rich client Summary pane


Note If the change doesn’t appear in the rich client, you can exit the rich client
and restart it using the -clean c

You can configure the folder summary in many other ways. For example, to
show folder contents using the objectSet tag, place the following code
highlighted in bold into the MyFolderSummary style sheet after the properties
section, and click the Apply button:
<section titleKey="tc_xrt_ItemProperties">
<property name="object_name"/>
<property name="object_desc"/>
<property name="object_type"/>
<separator/>
<property name="owning_user" renderingHint="objectlink"
modifiable="false"/>
<property name="owning_group" renderingHint="objectlink"
modifiable="false"/>
<property name="last_mod_user"/>
<separator/>
<command commandId="com.teamcenter.rac.properties"
titleKey="tc_xrt_moreProperties"/>
<</sseeccttiioonnt>title="Contents">
so<rotbbjye=c"toSbejtecsto_unracmee=""scoornttdeinrtesc.tWioornk=s"paas
cceeOnbdjiencgt"">defaultdisplay="thumbnailDisplay"
<tab<lperDoipseprltayy>name="object_string"/>
<property name="object_desc"/>
<property name="object_type"/>
<property name="owning_user"/>
<property name="owning_group"/>
<property name="last_mod_user"/>

FaithPLM Solutions, Pune Page 22


FaithPLM Solutions
Simplifying complex enterprise…

</t<atbhluemDbinsapillaDyi>splay/>
<t<rpereoDpiesrptlyayn>ame="object_string"/>
<property name="object_desc"/>
<property name="object_type"/>
<property name="owning_user"/>
<property name="owning_group"/>
<property name="last_mod_user"/>
</<tlriesetDDiissppllaayy>/>
commandId="<ccoomm.mtaenadmcaecnttieorn.Kreayc=."cnoemwmBouns.iA
ndedsNseOwb"jreecntdCeornitnegxHtiunatl=A"cctoimomna"ndbutton"/>
renderingHin<tc=o"mcmoamnmdanadcbtuitotnoKne"y>="cutAction"
commandId="org.eclipse.ui.edit.cut" </c<opmamraanmde>ter
name="localSelection" value="true"/>
renderingHin<tc=o"mcmoamnmdanadcbtuitotnoKne"y/=>"copyAction"
commandId="com.teamcenter.rac.copy"
commandId="c<ocmo.mtmeaanmdceanctteiro.nrKaecy.=v"ipeawsetre.Apcat
sitoenw"ithContext" renderingHint="commandbutton"/>
</<s/eocbtjieocnt>Set>
When you select a folder and click the Summary tab, the Contents section
is displayed.

FaithPLM Solutions, Pune Page 23


FaithPLM Solutions
Simplifying complex enterprise…

Rich Client Customization

1. Rich Client Environment Setup

a. Install Eclipse version 3.5 or more than that


b. Create a batch file that sets the environment, starts the server, and launches
Eclipse using the JDK command line parameters. Use the following template to
create your batch file:

set FMS_HOME=TC_ROOT\tccs
set JAVA_HOME=jre-install-directory
set JRE_HOME=jre-install-directory
set CLASSPATH=TC_ROOT\portal
set PATH=%FMS_HOME%\bin;%FMS_HOME%\lib;TC_ROOT\portal;%PATH%
start "TAO ImR" /min cmd /c "TC_ROOT\iiopservers\start_imr.bat" Eclipse-
install-directory\eclipse.exe -vm jdk-install-directory\bin\javaw

c. Run the batch file you just created


d. Use the default location for the workspace. This location is used by Eclipse to
store the project related information. Click OK.

2. Set the project preferences

a) In Eclipse , choose Window-> Preferences to open the preferences


dialog box.
b) Double click on java node.
c) Select Install JRE node.
d) Click Add button.
e) In JRE dialog box type name .
f) Type JRE directory.
g) Click OK.
h) In preference dialog box , double click the Plug-in Development node,
i) Select target platform
j) Click Browse.
k) Navigate to the TC_ROOT\portal directory and click OK.
l) IN the preference dialog box ,click ok.

FaithPLM Solutions, Pune Page 24


FaithPLM Solutions
Simplifying complex enterprise…

m) In the Target Definition box, ensure Nothing is selected and click Next.
n) In the Target Content dialog box, click Add

FaithPLM Solutions, Pune Page 25


FaithPLM Solutions
Simplifying complex enterprise…

o) In the Add Content dialog box, select Directory and click Next.
p) Click the Finish button.
The Target Platform dialog box appears.
q) In the Target Platform dialog box, select the target you just set and click
OK.

Adding menus and toolbars


To add menu bars, toolbars, and shortcut menus, use the declarative approach
provided by Eclipse. The definition of the menu bar, toolbar, and context
menus are provided in the individual plug-in’s plugin.xml file. Menus and the
resulting application logic they call can be placed in a Model-View-Controller
(MVC) paradigm.
The three parts to the MVC paradigm are:
• Command

FaithPLM Solutions, Pune Page 26


FaithPLM Solutions
Simplifying complex enterprise…

• Menu contributions
• Handler
For more information and full examples about how to use the Eclipse
declarative approach to menus and toolbars, see the following links:

• http://wiki.eclipse.org/Menu_Contributions
• http://wiki.eclipse.org/Platform_Command_Framework
• http://wiki.eclipse.org/Command_Core_Expressions
• http://www.vogella.de/articles/EclipseCommands/article.html

Command
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
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 visual representations of
commands may include labels, icons, and mnemonics. Menu contributions also
may include separators. Separators are only visible if there are visible
commands before and after a separator. The menu contribution can define
when it will be visible with a visibleWhen clause. The visibleWhen clause refers
FaithPLM Solutions, Pune Page 27
FaithPLM Solutions
Simplifying complex enterprise…

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
A 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. A command can also define a default handler ensuring that a
command always has an active handler. The handler can be declaratively
activated via the ActiveWhen clause or programmatically activated. The
handler also defines declaratively when a command appears enabled in any
menu contribution with the enabledWhen expression for the handler.

<handler
commandId="Com.sampleapps.tc.commands.sampleCommand"
class="com.sampleapps.tc.handlers.SampleHandler">

</handler>

FaithPLM Solutions, Pune Page 28


FaithPLM Solutions
Simplifying complex enterprise…

Kernel API
Class TCComponent

The TC Component is an AIF Component that allows the AIF to manage this
component.

Class TCSession

The TC Session is responsible for logging into TC

AIFRCP API

Class AbstractAIFUIApplication
This class contains the definition for the AbstractAIFApplication. It is used as a
base class that all AIF applications will inherit from.

Class AIFUtility
public class AIFUtility extends java.lang.Object

AbstractAIFUIApplication app =AIFUtility.getCurrentApplication();


final TCSession session=(TCSession) app.getSession();

Rich client Javadoc


Teamcenter provides APIs you can use in your rich client customizations. The
Javadoc documentation for these rich client APIs can be found in the JavaDoc.zip
file provided within the Teamcenter-version_pub.zip file on the Teamcenter
installation source. After unzipping the JavaDoc.zip file, open the index.html files to
view the Javadoc for these packages, for example,
javadoc\com.teamcenter.rac.common\index.html.

Rich Client Development

Create a Item Using RAC API


1. Open the Eclipse
2. Create the Project

FaithPLM Solutions, Pune Page 29


FaithPLM Solutions
Simplifying complex enterprise…

3. Enter the Project Name

4. Click on Next

FaithPLM Solutions, Pune Page 30


FaithPLM Solutions
Simplifying complex enterprise…

5. Click On Finish
6. Replace The following plugin.xml into existing Plugin.xml

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


<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="Com.sampleapps.tc.commands.category">
</category>
<command
name="Sample Command"
categoryId="Com.sampleapps.tc.commands.category"
id="Com.sampleapps.tc.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="Com.sampleapps.tc.commands.sampleCommand"
class="com.sampleapps.tc.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">

FaithPLM Solutions, Pune Page 31


FaithPLM Solutions
Simplifying complex enterprise…

<key
commandId="Com.sampleapps.tc.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="Sample Menu"
mnemonic="M"
id="Com.sampleapps.tc.menus.sampleMenu">
<command
commandId="Com.sampleapps.tc.commands.sampleCommand"
mnemonic="S"
id="Com.sampleapps.tc.menus.sampleCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="Com.sampleapps.tc.toolbars.sampleToolbar">
<command
commandId="Com.sampleapps.tc.commands.sampleCommand"
icon="icons/sample.gif"
tooltip="Say hello world"
id="Com.sampleapps.tc.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>

</plugin>

7. Replace the code in the SampleHandler.java file with the following:


package com.sampleapps.tc.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;

FaithPLM Solutions, Pune Page 32


FaithPLM Solutions
Simplifying complex enterprise…

import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;

/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
Text t1,t2;
public SampleHandler() {
}

/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell s1 = new Shell();
s1.setBounds(200, 200, 300, 300);
s1.setText("IGATE SWT Sample");
s1.setVisible(true);

Label l1 = new Label(s1,SWT.NONE);


l1.setText("Item Id");
l1.setBounds(10, 10, 100, 40);

t1 = new Text(s1, SWT.BORDER);


t1.setBounds(120, 10, 100, 20);

Label l2 = new Label(s1,SWT.NONE);


l2.setText("Item Name");
l2.setBounds(10, 60, 100, 40);

t2 = new Text(s1, SWT.BORDER);


t2.setBounds(120, 60, 100, 20);

Button b1 = new Button(s1, SWT.PUSH);


b1.setText("Create");
b1.setBounds(120, 100, 100, 20);
b1.addSelectionListener(new SelectionListener() {

@Override
public void widgetSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
AbstractAIFUIApplication app
=AIFUtility.getCurrentApplication();

FaithPLM Solutions, Pune Page 33


FaithPLM Solutions
Simplifying complex enterprise…

final TCSession session=(TCSession) app.getSession();

//Find item type


try {
TCComponentItemType type=(TCComponentItemType)
session.getTypeComponent("Item");
//Create item
TCComponent item=type.create(t1.getText(), null,
"Item", t2.getText(), "", null);
//System.out.println("Hi!!");

} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub

}
});

return null;
}
}

8. Choose FileSave All.


9. Choose RunRun Configurations to start the rich client from your Eclipse

FaithPLM Solutions, Pune Page 34


FaithPLM Solutions
Simplifying complex enterprise…

environment

======================================================================
Create the Dataset and attach that dataset to existing
1. Open the Eclipse
2. Create the Project

FaithPLM Solutions, Pune Page 35


FaithPLM Solutions
Simplifying complex enterprise…

3. Enter the Project Name

4.

FaithPLM Solutions, Pune Page 36


FaithPLM Solutions
Simplifying complex enterprise…

5. Replace The following plugin.xml into existing Plugin.xml


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

<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="com.attachdataset.tc.commands.category">
</category>
<command
name="Sample Command"
categoryId="com.attachdataset.tc.commands.category"
id="com.attachdataset.tc.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com.attachdataset.tc.commands.sampleCommand"
class="com.attachdataset.tc.handlers.SampleHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.attachdataset.tc.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="Sample Menu"
mnemonic="M"
id="com.attachdataset.tc.menus.sampleMenu">
<command
commandId="com.attachdataset.tc.commands.sampleCommand"
mnemonic="S"
id="com.attachdataset.tc.menus.sampleCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="com.attachdataset.tc.toolbars.sampleToolbar">
<command
commandId="com.attachdataset.tc.commands.sampleCommand"

FaithPLM Solutions, Pune Page 37


FaithPLM Solutions
Simplifying complex enterprise…

icon="icons/sample.gif"
tooltip="Say hello world"
id="com.attachdataset.tc.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>

</plugin>

6. Replace the code in the SampleHandler.java file with the following:

package com.attachdataset.tc.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentDataset;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
FaithPLM Solutions, Pune Page 38
FaithPLM Solutions
Simplifying complex enterprise…

import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentProjectType;
import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.pse.common.BOMLineNode;

/**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
IWorkbenchWindow window;
String value=null;
Combo cb;
Text t1,t2;
public SampleHandler() {
}

/**
* the command has been executed, so extract extract the needed
information
* from the application context.
*/
public Object execute(final ExecutionEvent event) throws
ExecutionException {
Shell s1 = new Shell();
s1.setBounds(300, 300, 300, 300);
s1.setText("Faith SWT Sample");
s1.setVisible(true);
FaithPLM Solutions, Pune Page 39
FaithPLM Solutions
Simplifying complex enterprise…

Label l1 = new Label(s1,SWT.NONE);


l1.setText("Existing Item Id");
l1.setBounds(10, 10, 100, 40);

t1 = new Text(s1, SWT.BORDER);


t1.setBounds(120, 10, 100, 20);

Label l2 = new Label(s1,SWT.NONE);


l2.setText("Dataset_Name");
l2.setBounds(10, 50, 100, 40);

t2 = new Text(s1, SWT.BORDER);


t2.setBounds(120, 50, 100, 20);

Label l3 = new Label(s1,SWT.NONE);


l3.setText("Dataset_Type");
l3.setBounds(10, 90, 100, 40);

cb = new Combo(s1, 0);


cb.add("PDF");
cb.add("TEXT");
cb.add("MSWord");

cb.setBounds(120, 90, 100, 20);

Button b1 = new Button(s1,SWT.NONE);


b1.setBounds(40, 130, 100, 40);
b1.setText("Attach Dataset");
b1.setToolTipText("Sample button testing");
b1.addSelectionListener(new SelectionListener() {

@Override
public void widgetSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
AbstractAIFUIApplication
app=AIFUtility.getCurrentApplication();
FaithPLM Solutions, Pune Page 40
FaithPLM Solutions
Simplifying complex enterprise…

TCSession session=(TCSession) app.getSession();


try {
TCComponentItemType
Itype=(TCComponentItemType) session.getTypeComponent("Item");
TCComponentItem
item=Itype.find(t1.getText());

AIFComponentContext[]
comp=item.getChildren();
for(int i=0;i<comp.length;i++)

{
TCComponent compt = (TCComponent)
comp[i].getComponent();
if(compt instanceof
TCComponentItemRevision)
{
System.out.println("Revision
name"+comp[i].toString());
TCComponentDatasetType
dtype=(TCComponentDatasetType) session.getTypeComponent("Dataset");

TCComponentDataset
dataset=dtype.create(t2.getText(), "", cb.getText());
compt.add("IMAN_specification",
dataset);

IWorkbenchWindow window =
HandlerUtil.getActiveWorkbenchWindowChecked(event);

MessageDialog.openInformation(

window.getShell(),
"Dataset
attach",
FaithPLM Solutions, Pune Page 41
FaithPLM Solutions
Simplifying complex enterprise…

"Dataset attach
Sucessfully...");
}
}

} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub

}
});

return null;
}
}
. Choose FileSave All.
9. Choose RunRun Configurations to start the rich client from your Eclipse
environment

FaithPLM Solutions, Pune Page 42


FaithPLM Solutions
Simplifying complex enterprise…

==============================================================
Display the selected Object Property on UI

1. Open the Eclipse


2. Create the Project

3. Enter the Project Name

FaithPLM Solutions, Pune Page 43


FaithPLM Solutions
Simplifying complex enterprise…

4. Cick on Next

FaithPLM Solutions, Pune Page 44


FaithPLM Solutions
Simplifying complex enterprise…

5. Click On Finish
6. Replace The following plugin.xml into existing Plugin.xml

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


<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="FPLM.commands.category">
</category>
<command

FaithPLM Solutions, Pune Page 45


FaithPLM Solutions
Simplifying complex enterprise…

name="get properties"
categoryId="FPLM.commands.category"
id="FPLM.commands.removepending">
</command>
<command
name="Sample Command"
categoryId="FPLM.commands.category"
id="FPLM.commands.sampleCommand">
</command>
<command
name="Relibility Window"
categoryId="FPLM.commands.category"
id="FPLM.commands.RelibilityWindow">
</command>

</extension>

<extension
point="org.eclipse.ui.handlers">
<handler
commandId="FPLM.commands.removepending"
class="ibm.handlers.IBMCreateItemHandler">
</handler>

</extension>

<extension
point="org.eclipse.ui.bindings">
<key
commandId="FPLM.commands.removepending"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>

<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<command
commandId="FPLM.commands.removepending"
icon="icons/processviewerapplication_16.png"
id="FPLM.menus.sampleCommand">

<visiblewhen>
<reference

definitionId="com.teamcenter.rac.myteamcenter.inMainPerspective">
</reference>
</visiblewhen>

FaithPLM Solutions, Pune Page 46


FaithPLM Solutions
Simplifying complex enterprise…

</command>
</menuContribution>
</extension>

</plugin>

Replace the code in the IBMCreateItemHandler.java file with the following:

package ibm.handlers;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.table.DefaultTableModel;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;

public class IBMCreateItemHandler extends AbstractHandler{

TCComponent itemrev;
@SuppressWarnings("deprecation")
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException
{
itemrev= (TCComponent)AIFUtility.getTargetComponent();
itemrev.getSession();

// we can find properties of any TCComponent


JFrame f=new JFrame("TCComponent Properties");
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2,2));
String Values1[][]= new String[2][230];
String Values2[]={"key","value"};
HashMap h= new HashMap();

try {
h=(HashMap)itemrev.getProperties();

Set s=h.entrySet();
Iterator i= s.iterator();
int j=0;

FaithPLM Solutions, Pune Page 47


FaithPLM Solutions
Simplifying complex enterprise…

while(i.hasNext())
{
Map.Entry me= (Map.Entry)i.next();
System.out.println("Valeus:"+h.size());
String key= (String) me.getKey();
String value= (String) me.getValue();
Values1[0][j]=key;
Values1[1][j]=value;
++j;
}
DefaultTableModel model = new
DefaultTableModel(Values1,Values2);
JTable table= new JTable(model);
for (int k=0;k<Values1[0].length;k++)
{
System.out.println("Key="+Values1[0][k]+"
"+"Value= "+Values1[1][k]);
model.insertRow(k,new
Object[]{Values1[0][k],Values1[1][k]});
}
panel.add(table);
int ver =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int horz =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(panel,ver,horz);
f.getContentPane().add(jsp);
f.setBounds(200,200,380,310);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (TCException e) {
System.out.println("Hello Error Here");
// TODO Auto-generated catch block
e.printStackTrace();
}

// TODO Auto-generated method stub


return null;
}
}
. Choose FileSave All.
9. Choose RunRun Configurations to start the rich client from your Eclipse
environment

FaithPLM Solutions, Pune Page 48


FaithPLM Solutions
Simplifying complex enterprise…

FaithPLM Solutions, Pune Page 49


FaithPLM Solutions
Simplifying complex enterprise…

====================================================================
Rich Client UI Form Customization

Create the Eclipse project.


a. In Eclipse, choose File®New®Project.
b. In the New Project dialog box, select Plug-in Project. Click Next.
c. In the Project name box, type com.mycom.masterform. Click Next.
d. Under Options, ensure the Generate an activator and This plug-in will make
contributions to the UI check boxes are selected. Click Next.
e. Clear the Create a plug-in using one of these templates check box. Click
Finish.

3. Update the project tabs.


a. Update the Dependencies tab.
A. In Eclipse, click your project tab and click its Dependencies tab.
B. Under Required Plug-ins, click the Add button.
C. Select the following plug-ins from the list by holding down the Ctrl key
while you click them:

FaithPLM Solutions, Pune Page 50


FaithPLM Solutions
Simplifying complex enterprise…

com.teamcenter.rac.aifrcp
com.teamcenter.rac.common
com.teamcenter.rac.external

com.teamcenter.rac.kernel
com.teamcenter.rac.neva
com.teamcenter.rac.tcapps
com.teamcenter.rac.util

D. Click OK.
b. Update the Runtime tab.
A. Click your project’s Runtime tab.
B. Under Exported Packages, click the Add button.
C. Select the com.mycom.custompanel and com.teamcenter.rac.stylesheet
packages and click OK.
c. Update the Extensions tab.
A. Click your project’s Extensions tab.
B. Click the Add button.
C. Select the com.teamcenter.rac.util.tc_properties extension point.
D. Click Finish.

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


<?eclipse version="3.2"?>
<plugin>
<extension point="com.teamcenter.rac.util.tc_properties">
<plugin_properties pluginName="com.mycom.masterform"/>
</extension>
</plugin>

Save the project by choosing File®Save All

4. Create the project files.


a. Create the custom item revision master form.
A. Right-click the com.mycom.masterform package and choose New File.
B. In the File Name box, type A5_MyItemMaster.java and click Finish.
C. Open the A5_MyItemMaster.java file and enter the following code:

package com.mycom.masterform;

import com.teamcenter.rac.stylesheet.AbstractRendering;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;

FaithPLM Solutions, Pune Page 51


FaithPLM Solutions
Simplifying complex enterprise…

import com.teamcenter.rac.util.VerticalLayout;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class A5_MyItemMaster extends AbstractRendering
{
/**
*
*/
private static final long serialVersionUID = 1L;
private JTextField data1_jtextfield;
private JTextField data2_jtextfield;
private TCProperty data1_tcproperty;
private TCProperty data2_tcproperty;
private TCComponentForm form;
public A5_MyItemMaster( TCComponentForm c)throws Exception
{
super ( c );
form = c;
loadRendering();
}
@Override
public void loadRendering() throws TCException
{
initializeUI();
data1_tcproperty = form.getFormTCProperty("user_data_1");
data2_tcproperty = form.getFormTCProperty("user_data_2");
data1_jtextfield.setText(data1_tcproperty.getStringValue());
data2_jtextfield.setText(data2_tcproperty.getStringValue());
}
@Override
public void saveRendering()
{
try
{
FaithPLM Solutions, Pune Page 52
FaithPLM Solutions
Simplifying complex enterprise…

data1_tcproperty.setStringValueData(data1_jtextfield.getText() );

data2_tcproperty.setStringValueData(data2_jtextfield.getText() );
TCProperty[] ps = new TCProperty[2];
ps[0] = data1_tcproperty;
ps[1] = data2_tcproperty;
form.setTCProperties(ps);
}
catch ( TCException ex )
{
MessageBox.post(ex.getMessage(), null,
MessageBox.ERROR);
}
}

private void initializeUI()


{
setLayout ( new VerticalLayout() );
JPanel mainPanel = new JPanel( new PropertyLayout());
mainPanel.setOpaque(false);
mainPanel.setEnabled(false);
// Create all the text fields
data1_jtextfield = new JTextField(15);
data2_jtextfield = new JTextField(15);
//Add components to Panel
mainPanel.add("1.1.right.center",new JLabel("User Data One"));
mainPanel.add("1.2.left.center", data1_jtextfield);
mainPanel.add("2.1.right.center",new JLabel("User Data Two"));
mainPanel.add("2.2.left.center", data2_jtextfield);
add("unbound.bind", mainPanel);
}
}
b. Create a style sheet property file to render the new form.
A. In Package Explorer, right-click your project and choose New®Package.
B. In the Name box, type com.teamcenter.rac.stylesheet. This is the path
name where rich client style sheet files are located.

FaithPLM Solutions, Pune Page 53


FaithPLM Solutions
Simplifying complex enterprise…

C. Click Finish.
D. Right-click the com.teamcenter.rac.stylesheet package and choose
New®File.
E. 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.
F. Open the stylesheet_user.properties file and enter the following line:

A5_MyItemRevisionMaster.FORMJAVARENDERING=com.mycom.masterform.A5_MyItemM
aster

c. Save the new files by choosing File®Save All.


5. Package the project.
a. Right-click the project, choose Export®Plug-in Development®Deployable plug-ins and
fragments, select the TC_ROOT\portal directory as the destination, and click Finish
The com.mycom.project-name JAR file is automatically generated into the
TC_ROOT\portal\plugins directory.
b. Run the TC_ROOT\portal\registry\genregxml file to register the plug-in with the rich client.

c. To clear cache, delete the Teamcenter subdirectory in the user’s home directory on the
client. This directory is automatically created again when the user starts the rich client. This
directory usually contains RAC and TAO subdirectories. On a Windows client, it is typically
the C:\Documents and
Settings\user-name\Teamcenter\ directory on Windows XP or the
Users\user-name\Teamcenter directory on Windows 7. On a Linux client,
it is typically the $HOME/Teamcenter/ directory.

6. Verify the customization.


a. In the rich client, choose File->New->Item and select the new custom item type (for
example, A5_MyItem), and click Next. b. Assign the new item an ID and name and click
Next.
c. Click Next on the Define additional item information page.
d. On the Define additional item revision information page, you should see
your new item revision master form.

FaithPLM Solutions, Pune Page 54


FaithPLM Solutions
Simplifying complex enterprise…

Developing forms using JavaBeans


1. Create a custom item business object.
a. In the Business Modeler IDE, create a custom item business object as a child
of the Item business object, for example, A5_MyItem
b. In the Business Objects view, open the item revision business object (for
example, A5_MyItemRevision), click the Properties tab, and create the
custom persistent properties you want to display in the panel, for example:
• a5_MyDate
Select the Date attribute type.
Tip Type a display name for each of these new properties, for
example, Test Date.
• a5_MyDouble
Select the Double attribute type.
• a5_MyFlag
Select the Boolean attribute type.
• a5_MyLongString
Select the LongString attribute type.
• a5_MyLOV
Select the String attribute type. Attach an LOV to this property, for
example, BillCodes.
• a5_MyRef
Select the TypedReference attribute type. Choose a reference business
object, for example, Item.
FaithPLM Solutions, Pune Page 55
FaithPLM Solutions
Simplifying complex enterprise…

c. Set the Enabled property constant to True for each of the new properties.
This means the property is enabled for display in the user interface.
d. Deploy the custom template from the Business Modeler IDE to your
Teamcenter server. If you use the deployment wizard, select the Generate
Server Cache? check box to generate shared server cache that contains
the new data model
e. After deployment, test your new business object in the Teamcenter rich
client by creating an instance of it.
For example, in the My Teamcenter application, choose File®New®Item.
Your new business object appears in the New Item dialog box. Choose your
new business object and launch the New Item wizard

2. Create the Eclipse project

a. In Eclipse, choose File®New®Project.


b. In the New Project dialog box, select Plug-in Project. Click Next.
c. In the Project name box, type com.mycom.custompanel. Click Next.
d. Under Options, ensure the Generate an activator and This plug-in will make
contributions to the UI check boxes are selected. Click Next.
e. Clear the Create a plug-in using one of these templates check box. Click
Finish.
3. Update the project tabs.
a. Update the Dependencies tab.
A. In Eclipse, click your project tab and click its Dependencies tab.
B. Under Required Plug-ins, click the Add button.
C. Select the following plug-ins from the list by holding down the Ctrl key
while you click them:
com.teamcenter.rac.aifrcp
com.teamcenter.rac.common
com.teamcenter.rac.external
com.teamcenter.rac.kernel
com.teamcenter.rac.neva
com.teamcenter.rac.tcapps
com.teamcenter.rac.util
D. Click OK.
b. Update the Runtime tab.
A. Click your project’s Runtime tab.
A. Click your project’s Runtime tab.
B. Under Exported Packages, click the Add button.
C. Select your project and click OK.
c. Update the Extensions tab.
A. Click your project’s Extensions tab.
B. Click the Add button.
C. Select the com.teamcenter.rac.util.tc_properties extension point.
D. Click Finish.
d. Save the project by choosing FileSave All.
4. Create the project files.
a. Create the custom viewer panel.
A. In Package Explorer, right-click your project and choose New®Package.
FaithPLM Solutions, Pune Page 56
FaithPLM Solutions
Simplifying complex enterprise…

B. In the Name box, type com.teamcenter.rac.stylesheet. This is the path


name where rich client style sheet files are located.
C. Click Finish.
D. Right-click the com.teamcenter.rac.stylesheet package and choose New->File.
E. Open the project’s Runtime tab, click the Add button, and add the
com.teamcenter.rac.stylesheet package.

F. In the File Name box, type CustomSamplePanel.java and click Finish.


G. Open the CustomSamplePanel.java file and enter the following code:

package com.teamcenter.rac.stylesheet;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.teamcenter.rac.util.PropertyLayout;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* This example shows how to use the property java beans to display properties/form.
* To use this example, please create an object with following attributes (or change the
* property names used in this example to match the data model you have):
* p2_MyDouble: double type
* p2_MyDate: date type
* p2_MyFlag: logical type
* p2_MyLongString: long string type
* p2_MyRef: typed reference type
* p2_MyLOV: a string type attached with LOV
**
To register the usage of this panel, user needs to add a line to the stylesheet_user.properties
file,
* with the format: <type_name>.JAVARENDERING=<package name>.CustomSamplePanel
**
For example, I have this panel registered to display my custom item revision properties:
*
A5_MyItemRevision.JAVARENDERING=com.teamcenter.rac.stylesheet.CustomSamplePan
el
**
When user selects A5_MyItemRevision and launches the properties dialog, this
CustomSamplePanel
* should be displayed.
*/
public class CustomSamplePanel extends JPanel
{
public CustomSamplePanel()
{
try
{
FaithPLM Solutions, Pune Page 57
FaithPLM Solutions
Simplifying complex enterprise…

init();
}
catch( Exception e )
{
e.printStackTrace();
}
}
private void init()throws Exception
{
this.setLayout( new BorderLayout() );
this.setOpaque( false );
JPanel jPanel1 = new JPanel();
jPanel1.setLayout( new PropertyLayout() );
jPanel1.setOpaque( false );
JLabel jLabel1 = new JLabel("Test double");
PropertyTextField doubleTextField = new PropertyTextField();
doubleTextField.setProperty( "p2_MyDouble" );
JLabel jLabel2 = new JLabel("plm date" );
PropertyDateButton dateButton = new PropertyDateButton();
//dateButton.setDate( (String) null );
//dateButton.setDisplayFormat( "d-MMM-yyyy HH:mm:ss" );
dateButton.setProperty( "p2_MyDate" );
dateButton.setMandatory( true );
JLabel jLabel3 = new JLabel("Test boolean");
PropertyLogicalPanel logicalPanel = new PropertyLogicalPanel();
logicalPanel.setProperty( "p2_MyFlag" );
JLabel jLabel4 = new JLabel("Test longstring");
PropertyLongTextPanel longTextPanel = new PropertyLongTextPanel();
longTextPanel.setProperty( "p2_MyLong_String" );
JLabel jLabel5 = new JLabel("Test ref");
PropertyObjectLink refLink = new PropertyObjectLink();
refLink.setProperty( "p2_MyRef" );
JLabel jLabel6 = new JLabel("Test Lov");
PropertyLOVUIComponent lovUIComp = new PropertyLOVUIComponent();
lovUIComp.setProperty( "p2_MyLOV" );
this.add( jPanel1, BorderLayout.WEST );
jPanel1.add( "1.1", jLabel1 );
jPanel1.add( "1.2", doubleTextField );
jPanel1.add( "2.1", jLabel2 );
jPanel1.add( "2.2", dateButton );
jPanel1.add( "3.1", jLabel3 );
jPanel1.add( "3.2", logicalPanel );
jPanel1.add( "4.1", jLabel4 );
jPanel1.add( "4.2", longTextPanel );
jPanel1.add( "5.1", jLabel5 );
jPanel1.add( "5.2", refLink );
jPanel1.add( "6.1", jLabel6 );
jPanel1.add( "6.2", lovUIComp );
}
}
FaithPLM Solutions, Pune Page 58
FaithPLM Solutions
Simplifying complex enterprise…

b. Create a style sheet property file to render the new panel.


A. Right-click the com.teamcenter.rac.stylesheet package and choose
New®File.
B. 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.
C. Open the stylesheet_user.properties file and enter the following line:

P2_MYItemRevision_master.JAVARENDERING=com.teamcenter.rac.stylesheet.CustomSa
mplePanel

c. Save the new files by choosing File®Save All.

5. Package the project.


a. Right-click the project, choose Export®Plug-in Development®Deployable
plug-ins and fragments, select the TC_ROOT\portal directory as the
destination, and click Finish.
The com.mycom.project-name JAR file is automatically generated into the
TC_ROOT\portal\plugins directory.
b. Run the TC_ROOT\portal\registry\genregxml file to register the plug-in
with the rich client.
c. To clear cache, delete the Teamcenter subdirectory in the user’s home
directory on the client. This directory is automatically created again when
the user starts the rich client. This directory usually contains RAC and
TAO subdirectories.
On a Windows client, it is typically the C:\Documents and
Settings\user-name\Teamcenter\ directory on Windows XP or the
Users\user-name\Teamcenter directory on Windows 7. On a Linux client,
it is typically the $HOME/Teamcenter/ directory.

6. Verify the customization.


a. In the rich client, choose File®New®Item and select the new custom item
type (for example, A5_MyItem), and create an instance of it.
b. Select the item revision and click the Viewer tab or choose View®Properties
to see your new panel.

FaithPLM Solutions, Pune Page 59


FaithPLM Solutions
Simplifying complex enterprise…

==========================================
This code creates a new application in the rich client that contains a single perspective
and a single view. It is displayed in the navigation pane. The project that contains
the application uses the following Eclipse extensions: org.eclipse.ui.perspectives,
org.eclipse.core.expressions.definitions, and org.eclipse.ui.views. It also uses
the Teamcenter com.teamcenter.rac.aifrcp.application extension.
Use the Eclipse plug-in create wizard to create the plug-in. Add packages and
classes as needed and copy and paste the class and plugin.xml file content from the
following steps. If you use the same names, you can cut and paste; otherwise, edit
your Java files and plugin.xml file using the following steps as a guide.
1. Create the project.
a. In Eclipse, choose FileNewProject.
b. In the New Project dialog box, select Plug-in Project. Click Next.
c. In the New Plug-in Project wizard Plug-in Project dialog box, type
com.mycom.customapp in the Project name box. Click Next.
d. In the New Plug-in Project wizard Content dialog box, do the following:
A. Under Options, ensure the This plug-in will make contributions to the
UI check box is selected.
B. Click the No button next to Would you like to create a rich client
application?.

FaithPLM Solutions, Pune Page 60


FaithPLM Solutions
Simplifying complex enterprise…

C. Click Next.
e. Clear the Create a plug-in using one of these templates check box. Click
Finish.
2. Update the project tabs.
a. Click the Overview tab and select the This plug-in is a singleton check box.
b. Click the Dependencies tab, click the Add button, and select the
com.teamcenter.rac.kernel plug-in.
3. Create the project files.
a. Create the following:
• The com.mycom.customapp.perspectives package and the
CustomPerspective class in it.
Note To create a package, right-click the project and choose
NewPackage. To create a class, right-click the package and
choose NewClass.
• The com.mycom.customapp.views package and the CustomView
class in it.
• An icons directory.
Note To create a directory, right-click the project and choose
NewFolder.
b. Open the com.teamcenter.rac.aifrcp_version.jar in the
TC_ROOT\portal\plugins directory, extract all the
defaultapplication_size.png files and the pview.gif file, and
copy the files to the icons directory you just created.
The plug-in structure looks like this:

c. Replace the code in the Activator.java file with the following:


package com.mycom.customapp;
import org.osgi.framework.BundleContext;

FaithPLM Solutions, Pune Page 61


FaithPLM Solutions
Simplifying complex enterprise…

import com.teamcenter.rac.kernel.AbstractRACPlugin;
import com.teamcenter.rac.services.IAspectService;
import com.teamcenter.rac.services.IAspectUIService;
/**
* The activator class controls the plug-in life cycle*/
public class Activator extends AbstractRACPlugin
{
// The plug-in ID
public static final String PLUGIN_ID = "com.mycom.customapp";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator()
{
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start
* (org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception
{
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop
* (org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception
{
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
**
@return the shared instance
*/
public static Activator getDefault()
{
return plugin;
}
@Override
public IAspectService getLogicService()
FaithPLM Solutions, Pune Page 62
FaithPLM Solutions
Simplifying complex enterprise…

{
// TODO Auto-generated method stub
return null;
}
@Override
public IAspectUIService getUIService()
{
// TODO Auto-generated method stub
return null;
}
protected void setupServices(BundleContext context)
{
// TODO Auto-generated method stub
}
}

d. Replace the code in the CustomPerspective.java file with the following:


package com.mycom.customapp.perspectives;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class CustomPerspective implements IPerspectiveFactory
{
/** The perspective ID */
public static final String ID
="com.mycom.customapp.perspectives.CustomPerspective";
@Override
public void createInitialLayout(IPageLayout layout)
{
// 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" );
}
}
e. Replace the code in the CustomView.java file with the following:
package com.mycom.customapp.views;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
public class CustomView extends ViewPart
{
public CustomView()
{
FaithPLM Solutions, Pune Page 63
FaithPLM Solutions
Simplifying complex enterprise…

super();
}
@Override
public void createPartControl(Composite parent)
{
// TODO Auto-generated method stub
parent.setLayout( new FillLayout() );
Text t = new Text( parent, SWT.BORDER );
t.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_WHITE
));
t.setForeground( parent.getDisplay().getSystemColor( SWT.COLOR_BLUE ));
Font initialFont = t.getFont();
FontData[] fontData = initialFont.getFontData();
for (int i = 0; i < fontData.length; i++)
{
fontData[i].setHeight(18);
}
Font newFont = new Font(parent.getDisplay(), fontData);
t.setFont( newFont );
t.setText( " Welcome to Custom Application !! ");
}
@Override
public void setFocus()
{
// TODO Auto-generated method stub
}
}

f. To create an empty plugin.xml file, click the project’s Extensions tab and
click the Add button in the Extensions view, and click the Cancel button in
the New Extension dialog box.
A plugin.xml file is added to the project.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.6"?>
<plugin>
<extension point="com.teamcenter.rac.aifrcp.application">
<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>
<extension point="org.eclipse.ui.perspectives">
<perspective

FaithPLM Solutions, Pune Page 64


FaithPLM Solutions
Simplifying complex enterprise…

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.views">
<view
allowMultiple="false"
class="com.mycom.customapp.views.CustomView"
icon="icons/pview.gif"
id="com.mycom.customapp.views.CustomView"
name="Custom View"/>
</extension>
<extension point="org.eclipse.core.expressions.definitions">
<definition id="com.mycom.customapp.inMainView">
<or>
<with variable="activePartId">
<equals value="com.mycom.customapp.views.CustomView" />
</with>
<with variable="arc_property.ACTIVE_APPLICATION">
<equals value="com.mycom.customapp" />
</with>
</or>
</definition>
</extension>
</plugin>

This example does not require the definitions extension; you can remove it.
It is included for reference to show how you can determine if your application
is active.
4. Choose FileSave All.
5. Verify the customization.
a. Choose RunRun Configurations to start the rich client from your Eclipse
environment. Clear the workspace by selecting the Clear check box in the
launch configuration dialog box.
For information about how to set up Eclipse to run the rich client, see Enable
rich client customization.
b. Verify that the new Custom Application button is shown in the left-hand
navigation pane in the rich client.
c. Click the Custom Application button to launch the new application.

FaithPLM Solutions, Pune Page 65


FaithPLM Solutions
Simplifying complex enterprise…

6. Package the project.


If you want to package the project for distribution, export it to a JAR file and
place it in the TC_ROOT\portal directory.
a. Right-click the project, choose ExportPlug-in DevelopmentDeployable
plug-ins and fragments, select the TC_ROOT\portal directory as the
destination, and click Finish.
The com.mycom.project-name JAR file is automatically generated into the
TC_ROOT\portal\plugins directory.
b. Run the TC_ROOT\portal\registry\genregxml file to register the plug-in
c. To clear cache, delete the Teamcenter subdirectory in the user’s home
directory on the client. This directory is automatically created again when
the user starts the rich client. This directory usually contains RAC and
TAO subdirectories.

FaithPLM Solutions, Pune Page 66

You might also like