FPLM Teamcenter UA Client Customization Guide
FPLM Teamcenter UA Client Customization Guide
Audience:
Manual History:
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
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
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.
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.
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.
Notice how this ItemCreate style sheet defines the layout of the creation dialog
boxes for the Item business object
<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.
Viewing the business object type that the style sheet is registered to
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.
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"/>
</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.
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
m) In the Target Definition box, ensure Nothing is selected and click Next.
n) In the Target Content dialog box, click Add
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.
• 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>
Kernel API
Class TCComponent
The TC Component is an AIF Component that allows the AIF to manage this
component.
Class TCSession
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
4. Click on Next
5. Click On Finish
6. Replace The following plugin.xml into existing Plugin.xml
<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">
<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>
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;
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);
@Override
public void widgetSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
AbstractAIFUIApplication app
=AIFUtility.getCurrentApplication();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
});
return null;
}
}
environment
======================================================================
Create the Dataset and attach that dataset to existing
1. Open the Eclipse
2. Create the Project
4.
<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"
icon="icons/sample.gif"
tooltip="Say hello world"
id="com.attachdataset.tc.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>
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…
@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…
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 FileSave All.
9. Choose RunRun Configurations to start the rich client from your Eclipse
environment
==============================================================
Display the selected Object Property on UI
4. Cick on Next
5. Click On Finish
6. Replace The following plugin.xml into existing Plugin.xml
<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="FPLM.commands.category">
</category>
<command
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>
</command>
</menuContribution>
</extension>
</plugin>
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;
TCComponent itemrev;
@SuppressWarnings("deprecation")
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException
{
itemrev= (TCComponent)AIFUtility.getTargetComponent();
itemrev.getSession();
try {
h=(HashMap)itemrev.getProperties();
Set s=h.entrySet();
Iterator i= s.iterator();
int j=0;
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();
}
====================================================================
Rich Client UI Form Customization
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.
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;
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);
}
}
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. 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.
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
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…
P2_MYItemRevision_master.JAVARENDERING=com.teamcenter.rac.stylesheet.CustomSa
mplePanel
==========================================
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 FileNewProject.
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?.
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
NewPackage. To create a class, right-click the package and
choose NewClass.
• 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
NewFolder.
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:
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
}
}
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
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 FileSave All.
5. Verify the customization.
a. Choose RunRun 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.