Lets give a short and quick overview of Rich client customization.
For better understanding , please read this page once you done with client customization guide PDF.
The client is the user interface (UI) layer and is built and customized using the Java language (rich client) or JavaScript (thin client) and other methods. The server layer can be customized using the Integration Toolkit (ITK) and the C++ programming language.
The rich client is based on Eclipse, your customizations have access to all Eclipse extension points and OSGi services. They can also use Teamcenter-developed customization techniques. To customize the rich client, you can use:
· Base Eclipse extension points and services (for example, the org.eclipse.ui.menus extension point).
· Teamcenter extension points and services (for example, the application extension points).
· Teamcenter customization mechanisms (for example, style sheets).
Within the Teamcenter rich client user interface, application functionality is provided in perspectives and views. Some applications use perspectives and views to arrange how functionality is presented.
You can control the behavior and display of Teamcenter applications in both the rich client and the thin client using options and preferences.
<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>
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.6"?> <plugin> <extension point="org.eclipse.ui.commands">
<command
name="Sample Command"
id="com.mycom.addmenuitem.commands.sampleCommand">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler
commandId="com.mycom.addmenuitem.commands.sampleCommand"
class="com.mycom.addmenuitem.handlers.SampleHandler">
</handler>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:tools?after=additions">
<command
commandId="com.mycom.addmenuitem.commands.sampleCommand"
mnemonic="S"
icon="icons/sample.gif"
id="com.mycom.addmenuitem.menus.sampleCommand">
<visibleWhen>
<reference
definitionId="com.teamcenter.rac.ui.inMainPerspective">
</reference>
</visibleWhen>
</command>
</menuContribution>
</extension>
</plugin>
<visibleWhen>
<reference
definitionId="com.teamcenter.rac.pse.inMainPerspective">
</reference>
</visibleWhen>
to place the menu command on the shortcut menu
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
To place the button on the My Teamcenter toolbar
<menuContribution
locationURI="toolbar:navigator_Toolbar?after=additions">
Each Teamcenter perspective has its own toolbar.
For example, the My Teamcenter toolbar is navigator_Toolbar, and
the Structure Manager toolbar is pse_Toolbar.
The toolbar is usually defined in the plugin.xml file for the perspective.
For example, the pse_Toolbar is defined in the plugin.xml file in the com.teamcenter.rac.pse plug-in.
That means if we want to go for any module then we can check its plugin.xml file to have its toolbar id ,menu perspective id to use .
<menuContribution
locationURI="menu:com.teamcenter.rac.ui.views.DetailsView?after=group4">
<menu
id="closeMenu"
label="Close">
<command
commandId="com.mycom.exitcommand.command1.Exit"
label="Exit"
style="push"
tooltip="Exit the application">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:com.teamcenter.rac.ui.views.DetailsView">
<toolbar
id="com.mycom.exitcommand.toolbar1">
<command
commandId="com.mycom.exitcommand.command1.Exit"
icon="icons/sample.gif"
label="Exit"
style="push"
tooltip="Exit the application">
</command>
</toolbar>
Add a toggle menu item:
<command
categoryId="com.mycom.toggle.commands.category"
defaultHandler="com.mycom.toggle.handlers.ToggleInfoHandler"
id="com.mycom.toggle.commands.infoCommand"
name="Info">
<state
class="org.eclipse.ui.handlers.RegistryToggleState:true"
id="org.eclipse.ui.commands.toggleState">
</state>
State element specify that I am toggle command
<extension point="org.eclipse.ui.views">
<view
name="MyCom Custom View"
class="com.mycom.customview.views.CustomView"
id="com.mycom.customview.views.CustomView">
</view>
</extension>
Class indicates that specified class will create View
Create class and that class must extends ViewPart class and override createPartControl
Method
Format :
public void createPartControl(Composite parent) {
parent.setLayout( new FillLayout() );
Text t = new Text( parent, SWT.BORDER );
}
We can say parent is our frame on which we add element .
View appears in Window→Show View→Other→Other→MyCom Custom View.
<extension point=”com.teamcenter.rac.aifrcp.appliation”>
<aif_app_item
Displaymode=”primary”
groupName="Mycompany"
icon="icons/defaultapplication_32.png"
id="com.mycom.customapp"
name="Custom Application"
ordinality="200"
perspective_id="com.mycom.customapp.perspectives.CustomPerspective"
session="com.teamcenter.rac.kernel.TCSession"
tooltip="Custom Application"/>
<extension point="org.eclipse.ui.perspectives">
<perspective
class="com.mycom.customapp.perspectives.CustomPerspective"
icon="icons/defaultapplication_16.png"
id="com.mycom.customapp.perspectives.CustomPerspective"
name="Custom Application"/>
</extension>
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="*">
<perspectiveShortcut
id="com.mycom.sendtoapp.perspectives.CustomPerspective" />
</perspectiveExtension>
</extension>
<extension point="org.eclipse.ui.views">
<view
allowMultiple="false"
class="com.mycom.customapp.views.CustomView"
icon="icons/pview.gif"
id="com.mycom.customapp.views.CustomView"
name="Custom View"/>
</extension>
When application is loaded perspective i.e CustomPerspective will get called and in that perspective we have added view so viewcode i.e CustomView will get called.
Specifying a perspectiveShortcut indicates that another perspective (specified by id) should be added to the Window>Open Perspective... menu of the target perspective
public class CustomPerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) { // IPageLayout interface
// TODO Auto-generated method stub
layout.setEditorAreaVisible(false);
String editorArea = layout.getEditorArea();
IFolderLayout top = layout.createFolder("top", IPageLayout.TOP, -2f,
editorArea);
top.addView( "com.mycom.customapp.views.CustomView" );
}
}
A page layout defines the initial layout for a perspective within a page in a workbench window.
This interface (IPageLayout interface) is not intended to be implemented by clients.
When a perspective is opened, it creates a new page layout with a single editor area. This layout is then passed to the perspective factory createInitialLayout(IPageLayout) where additional views and other content can be added, using the existing editor area as the initial point of reference.
createFolder(id, relationship,ration,referenacepart)
CustomView will be
public class CustomView extends ViewPart {
public CustomView() {
super();
}
@Override
public void createPartControl(Composite parent) {
// add text or component to parent etc .
}
<extension point="org.eclipse.ui.commandImages">
<command
icon="icons/defaultapplication_16.png"
id="com.mycom.sendtoapp.sendto">
</command>
</extension>
Menu :
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:com.teamcenter.rac.sendto?after=additions">
<command
commandId="com.mycom.sendtoapp.sendto">
Handler :
<extension point="org.eclipse.ui.handlers">
<handler
commandId="com.mycom.sendtoapp.sendto"
class="com.teamcenter.rac.common.handlers.SendToHandler:com.mycom.sendtoapp.perspectives.CustomPerspective">
<enabledWhen>
<iterate ifEmpty="false">
<reference definitionId="com.mycom.sendtoapp.sendToActive"/>
</iterate>
</enabledWhen>
</handler>
See handler is teamcenter handler which will handle the request and we have provided to it our perspective as value i.e object selected is send to our perspective
Create our own perspective and View as created before
The SendToHandler handler takes the perspective ID to open as an argument.
The SendToHandler handler shows the specified perspective, gets the registered OpenService (registered in activator setupServices () method)service, then calls the OpenService.open() method.
Activator.java
protected void setupServices(BundleContext context) {
// TODO Auto-generated method stub
Dictionary<String, String> properties = new java.util.Hashtable<String, String>();
// Register the open service
properties.put( IServiceConstants.PERSPECTIVE,
"com.mycom.sendtoapp.perspectives.CustomPerspective" );//perspective id
CustomOpenService customOpenService = new CustomOpenService();
context.registerService( IOpenService.class.getName(),
customOpenService, properties );
}
Openservice which we have registerd above :
public class CustomOpenService implements IOpenService {
@Override
public boolean close() throws Exception {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean open(final InterfaceAIFComponent cmp) {
Display.getDefault().asyncExec( new Runnable() {
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
MessageDialog
.openInformation(window.getShell(),
"CustomOpenService",
"You sent this component to the SendTo Application: "
+ cmp.toString());
}
});
return false;
}
@Override
public boolean open(InterfaceAIFComponent[] cmps) {
// TODO Auto-generated method stub
return false;
}
}
Override Teamcenter commands
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com.teamcenter.rac.newItem" // THIS ID IS id OF NEW ITEM option WHICH WE have IN TEAMCNTER
class="com.mycom.myitem.handlers.MyItemHandler"> //AND PROVIDED OUR HANDLER SO IT wil get executed WHEN NEW ITEM IS CREATED
Workbench Core Expressions:
Core expressions are used declaratively in the plugin.xml files, and
programmatically with some of the services provided in the workbench.
Declarative Expression Examples
Basic IStructuredSelection
Most of the tree or table like viewers return an IStructuredSelection.
For example, the Project Explorer and Package Explorer.
When using the default variable you must treat it as an java.util.Collection. That means using
<count> or <iterate>
Ex. The expression below returns true
if all of the selected items are Person.
<enabledWhen>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</enabledWhen>
This is equivalent to:
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</with>
</enabledWhen>
The behaviour of iterate is:
iterate ands the results of evaluating its child
expressions for each element in the collection, unless you set the operator attribute.
Default
operator is and.
iterate with an operator of and returns
true if the collection is empty, unless you set the ifEmpty attribute.
Ex. If you want to be enabled if only one Person is selected, you can include a count element.
<enabledWhen>
<with variable="selection">
<count value="1"/>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</with>
</enabledWhen>
The same expression using the default variable:
<enabledWhen>
<and>
<count value="1"/>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</and>
</enabledWhen>
Resources and the Package or Project Explorer
The Package Explorer is a mixture of org.eclipse.core.resources.IResource, org.eclipse.jdt.core.IJavaElement and
other classes.
Ex. If you are trying to find all of the "*.java"
files, you would need to:
Iterate through the default variable.
Adapt the selection elements to your class, in this
case org.eclipse.core.resources.IResource.
Use one of the org.eclipse.core.resources property
testers to test the org.eclipse.core.resources.IResource property.
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name"
value="*.java"/>
</adapt>
</iterate>
</with>
</enabledWhen>
When working with the current selection and property testers it does not
always make sense to use adapt.
In these situations it is a good practice to check that the object under test
is a valid type for that property tester:
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<instanceof type="org.eclipse.core.resources.IResource"/>
<test property="org.eclipse.core.resources.name"
value="*.java"/>
</iterate>
</with>
</enabledWhen>
Active Contexts
If your handler should be enabled when your view or editor activates a context,
you can use the activeContexts
variable. Contexts are defined in the org.eclipse.ui.contexts
extension point and activated programmatically using the org.eclipse.ui.contexts.IContextService.
<enabledWhen>
<with variable="activeContexts">
<iterate ifEmpty="false" operator="or">
<equals value="org.example.view.context"/>
</iterate>
</with>
</enabledWhen>
Note: activeContexts is a collection of the active context IDs as strings.
Active Views and Editor
For handlers that are to be contributed to a specific view or editor, you
can use activeEditorId and activePartId in the activeWhen clause.
This is an example for a handler that should be active in text editors:
<activeWhen>
<with variable="activeEditorId">
<equals value="org.eclipse.ui.DefaultTextEditor"/>
</with>
</activeWhen>
The following clause is for a handler that's active while in the Project
Explorer:
<activeWhen>
<with variable="activePartId">
<equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
</with>
</activeWhen>
ActionSets and Contexts
As of 3.3 all org.eclipse.ui.actionSets
(Deprecated)
Variables Provided in the Workbench : http://wiki.eclipse.org/Command_Core_Expressions
Condition for handler is defined using activewhen and enabledwhen clause: i.e when the handler should execute the behaviour of the command.
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="commandId"
class="org.eclipse.compare.Command">
<activeWhen>
<with variable="selection"> //The variables used for command framework evaluation are //listed in ISources.java file org.eclipse.ui.ISources
//represent The current global selection.
<count value="1" />
<iterate operator="and">
<adapt type="org.eclipse.core.resources.IResource" />
</iterate>
//This element is used to iterate over a variable that is of
type java.util.Collection, or a variable that adapts to
//org.eclipse.core.expressions.IIterable. If the object in focus is not one of
the above then a CoreException with an //ExpressionStatus will be thrown while
evaluating the expression. The child expressions of an iterate expression are
//combined using the "and" operator.
//operator - either "and" or "or".
//ifEmpty - the value returned from the "iterate" expression if the collection is empty.
</with>
</activeWhen>
</handler>
<handler
commandId="other.commandId"
class="org.eclipse.ui.TalkToMe">
<activeWhen>
<with variable="activePartId"> // The ID of the currently active part.
<equals value="org.eclipse.ui.views.SampleView"/>
</with>
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="commandId"
class="org.eclipse.Handler">
<enabledWhen>
<with variable="activeContexts"> //activeContexts is collection so iterate to check for context
<iterator operator="or">
<equals value="org.eclipse.ui.contexts.window"/>
</iterator>
</with>
</enabledWhen>
</handler>
</extension>
Localize your customizations:
Add the following line to the end of the MANIFEST.MF file:
Bundle-Localization: plugin
All the static value like name of command and label etc will be taken from plugin.properties file
at the same level as the plugin.xml file.using file->new file
Add the following name/value pairs to the
plugin.properties file:
myMenuitem.label=My Hello world
myTooltip.tip=My Say hello world
myCommand.name=My Command
Add a Spanish localization by creating a
plugin_es.properties:
myMenuitem.label=Mi Hola mundo
myTooltip.tip=Mi para Decir hola mundo
myCommand.name=Mi Orden
Edit the plugin.xml file
replacing hard coded values with %keyname for the name/value pairs you typed in the plugin.properties file. For example:
label="%myMenuitem.label"
<command
name="%myCommand.name"
categoryId="com.mycom.l10n.commands.category"
id="com.mycom.l10n.commands.sampleCommand">
</command>
<menu
label="%myMenuitem.label"
mnemonic="M"
Verify the customization thus far.
a. Create a new configuration for the Spanish locale by choosing Run→Run Configurations (or Run→Debug Configurations) and specifying -nl es instead of -nl ${target.nl} on the Arguments tab. For example:
-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl es
We have modified a label command name to display in Spanish but how the message displayed in handler be modified to display in Spanish or other locale.
Localize the message.
a.
In Eclipse, choose Handler in which we have message and
then Source→Externalize Strings.
Sample Handler
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
public SampleHandler() {
}
/**
* the command has been executed, so extract
extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openInformation(window.getShell(),"TestProject","Hello,Eclipse world");
return null;
}
}
This creates the Messages.java and messages.properties
Content of messages.properties :
SampleHandler_0=TestProject
SampleHandler_1=Hello, Eclipse world
b.
Now Again Select Handler and then Source→Externalize Strings
Customize
the rich client properties files:
· Open WinZip, navigate to the TC_ROOT\portal\plugins
directory, and open the JAR file that contains the properties file you want to
override. The file name has the form property.properties. For example, to override the mpp.properties file, open the com.teamcenter.rac.cme.legacy.jar
file.
· Extract the properties file you want to
override from the JAR file. For example, extract the mpp.properties
file.
· In a text editor, open the properties file to
determine the syntax of the property you want to modify.
· Create a new property_user.properties in a text editor. For example, if you
open the mpp.properties file, create the mpp_user.properties file.
Update the project tabs.
open plugin.xml
Select the com.teamcenter.rac.util.tc_properties extension point.
Click the plugin.xml tab. Type text in the file so it
looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.6"?>
<plugin>
<extension
point="com.teamcenter.rac.util.tc_properties">
</extension>
</plugin>
Create a package.
a. In the Package Explorer view, right-click your project and choose New→Package.
b. In the Name box, type the path name where the properties file was
originally. For example, if you originally extracted the mpp.properties file, the package name should be com.teamcenter.rac.cme.mpp.
c. Click the MANIFEST.MF tab and type your new package at the end of the Export-Package line. For example, if your project name
is com.mycom.propertiesfile and the new package is called com.teamcenter.rac.cme.mpp, the line
should read:
d. Export-Package: com.mycom.propertiesfile, com.teamcenter.rac.cme.mpp
Developing forms using JavaBeans
You can create a custom Java panel
(JPanel) assigned to a custom business object
and display the properties using JavaBeans.
when a user selects a custom ItemRevision business object and chooses the Viewer view or View→Properties,
the custom panel is displayed.
Panel rendering is registered to the business object by placing the following command
into a custom stylesheet_user.properties file:
Syntax: custom-business-object-name.JAVARENDERING=package-name.custom-java-panel-name
A)
1. Create a custom item business object.
2. In the Business Objects view, open the item revision business object (for example, A4_MyItemRevision), click the Properties tab,
and create the custom persistent properties you want to display in the panel,
3. Set the Enabled property constant to True for each of the new properties
4. Deploy the custom template
B)
1. Create the Eclipse project.
2. Update the Dependencies tab.
3. Update the Extensions tab.
Click the Add button.
Select the com.teamcenter.rac.util.tc_properties extension point
4. choose New→Package.
5. In the Name box, type com.teamcenter.rac.stylesheet
6. Right-click the com.teamcenter.rac.stylesheet package and choose New→File. In
the File Name box, type CustomSamplePanel.java and click Finish
7. Open the project’s Runtime tab, click the Add button, and add the com.teamcenter.rac.stylesheet
package.
8. Open the CustomSamplePanel.java file and enter the code: of Property to be
displayed
Ex: JPanel jPanel1 = new JPanel();
jPanel1.setLayout( new PropertyLayout() );
jPanel1.setOpaque( false );
JLabel jLabel1 = new JLabel("Test double");
PropertyTextField doubleTextField = new PropertyTextField();
doubleTextField.setProperty( "a4_MyDouble" );//This statement will get the value from database to rendere in Our Panel as a4_MyDouble is Property name in BMIDE
ench Core Expressions:
Core expressions are used declaratively in the plugin.xml files, and
programmatically with some of the services provided in the workbench.
Declarative Expression Examples
Basic IStructuredSelection
IResources and the Package or Project Explorer
Active Contexts
Active Views and Editor
ActionSets and Contexts
Basic IStructuredSelection
Most of the tree or table like viewers return an IStructuredSelection.
For example, the Project Explorer and Package Explorer.
When using the default variable you must treat it as an java.util.Collection. That means using
<count> or <iterate>
Ex. The expression below returns true
if all of the selected items are Person.
<enabledWhen>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</enabledWhen>
This is equivalent to:
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</with>
</enabledWhen>
The behaviour of iterate is:
iterate ands the results of evaluating its child
expressions for each element in the collection, unless you set the operator attribute.
Default
operator is and.
iterate with an operator of and returns
true if the collection is empty, unless you set the ifEmpty attribute.
Ex. If you want to be enabled if only one Person is selected, you can include a count element.
<enabledWhen>
<with variable="selection">
<count value="1"/>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</with>
</enabledWhen>
The same expression using the default variable:
<enabledWhen>
<and>
<count value="1"/>
<iterate ifEmpty="false">
<instanceof value="org.eclipse.ui.examples.contributions.model.Person"/>
</iterate>
</and>
</enabledWhen>
Resources and the Package or Project Explorer
The Package Explorer is a mixture of org.eclipse.core.resources.IResource, org.eclipse.jdt.core.IJavaElement and
other classes.
Ex. If you are trying to find all of the "*.java"
files, you would need to:
Iterate through the default variable.
Adapt the selection elements to your class, in this
case org.eclipse.core.resources.IResource.
Use one of the org.eclipse.core.resources property
testers to test the org.eclipse.core.resources.IResource property.
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name"
value="*.java"/>
</adapt>
</iterate>
</with>
</enabledWhen>
When working with the current selection and property testers it does not
always make sense to use adapt.
In these situations it is a good practice to check that the object under test
is a valid type for that property tester:
<enabledWhen>
<with variable="selection">
<iterate ifEmpty="false">
<instanceof type="org.eclipse.core.resources.IResource"/>
<test property="org.eclipse.core.resources.name"
value="*.java"/>
</iterate>
</with>
</enabledWhen>
Active Contexts
If your handler should be enabled when your view or editor activates a context,
you can use the activeContexts
variable. Contexts are defined in the org.eclipse.ui.contexts
extension point and activated programmatically using the org.eclipse.ui.contexts.IContextService.
<enabledWhen>
<with variable="activeContexts">
<iterate ifEmpty="false" operator="or">
<equals value="org.example.view.context"/>
</iterate>
</with>
</enabledWhen>
Note: activeContexts is a collection of the active context IDs as strings.
Active Views and Editor
For handlers that are to be contributed to a specific view or editor, you
can use activeEditorId and activePartId in the activeWhen clause.
This is an example for a handler that should be active in text editors:
<activeWhen>
<with variable="activeEditorId">
<equals value="org.eclipse.ui.DefaultTextEditor"/>
</with>
</activeWhen>
The following clause is for a handler that's active while in the Project
Explorer:
<activeWhen>
<with variable="activePartId">
<equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
</with>
</activeWhen>
ActionSets and Contexts
As of 3.3 all org.eclipse.ui.actionSets
(Deprecated)
Variables Provided in the Workbench : http://wiki.eclipse.org/Command_Core_Expressions
Condition for handler is defined using activewhen and enabledwhen clause: i.e when the handler should execute the behaviour of the command.
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="commandId"
class="org.eclipse.compare.Command">
<activeWhen>
<with variable="selection"> //The variables used for command framework evaluation are //listed in ISources.java file org.eclipse.ui.ISources
//represent The current global selection.
<count value="1" />
<iterate operator="and">
<adapt type="org.eclipse.core.resources.IResource" />
</iterate>
//This element is used to iterate over a variable that is of
type java.util.Collection, or a variable that adapts to
//org.eclipse.core.expressions.IIterable. If the object in focus is not one of
the above then a CoreException with an //ExpressionStatus will be thrown while
evaluating the expression. The child expressions of an iterate expression are
//combined using the "and" operator.
//operator - either "and" or "or".
//ifEmpty - the value returned from the "iterate" expression if the collection is empty.
</with>
</activeWhen>
</handler>
<handler
commandId="other.commandId"
class="org.eclipse.ui.TalkToMe">
<activeWhen>
<with variable="activePartId"> // The ID of the currently active part.
<equals value="org.eclipse.ui.views.SampleView"/>
</with>
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="commandId"
class="org.eclipse.Handler">
<enabledWhen>
<with variable="activeContexts"> //activeContexts is collection so iterate to check for context
<iterator operator="or">
<equals value="org.eclipse.ui.contexts.window"/>
</iterator>
</with>
</enabledWhen>
</handler>
</extension>
Localize your customizations:
Add the following line to the end of the MANIFEST.MF file:
Bundle-Localization: plugin
All the static value like name of command and label etc will be taken from plugin.properties file
at the same level as the plugin.xml file.using file->new file
Add the following name/value pairs to the
plugin.properties file:
myMenuitem.label=My Hello world
myTooltip.tip=My Say hello world
myCommand.name=My Command
Add a Spanish localization by creating a
plugin_es.properties:
myMenuitem.label=Mi Hola mundo
myTooltip.tip=Mi para Decir hola mundo
myCommand.name=Mi Orden
Edit the plugin.xml file
replacing hard coded values with %keyname for the name/value pairs you typed in the plugin.properties file. For example:
label="%myMenuitem.label"
<command
name="%myCommand.name"
categoryId="com.mycom.l10n.commands.category"
id="com.mycom.l10n.commands.sampleCommand">
</command>
<menu
label="%myMenuitem.label"
mnemonic="M"
Verify the customization thus far.
a.
Create a new configuration for the Spanish locale by
choosing Run→Run Configurations (or Run→Debug Configurations) and
specifying -nl es instead of -nl ${target.nl} on the Arguments tab. For
example:
-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl es
We have modified a label command name to display in Spanish but how the message displayed in handler be modified to display in Spanish or other locale.
Localize the message.
a.
In Eclipse, choose Handler in which we have message and
then Source→Externalize Strings.
Sample Handler
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
public SampleHandler() {
}
/**
* the command has been executed, so extract
extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openInformation(window.getShell(),"TestProject","Hello,Eclipse world");
return null;
}
}
This creates the Messages.java and messages.properties
Content of messages.properties :
SampleHandler_0=TestProject
SampleHandler_1=Hello, Eclipse world
b. Now Again Select
Handler and then Source→Externalize Strings
Customize
the rich client properties files:
· Open WinZip, navigate to the TC_ROOT\portal\plugins
directory, and open the JAR file that contains the properties file you want to
override. The file name has the form property.properties. For example, to override the mpp.properties file, open the com.teamcenter.rac.cme.legacy.jar
file.
· Extract the properties file you want to
override from the JAR file. For example, extract the mpp.properties
file.
· In a text editor, open the properties file to
determine the syntax of the property you want to modify.
· Create a new property_user.properties in a text editor. For example, if you
open the mpp.properties file, create the mpp_user.properties file.
Update the project tabs.
open plugin.xml
Select the com.teamcenter.rac.util.tc_properties extension point.
Click the plugin.xml tab. Type text in the file so it
looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.6"?>
<plugin>
<extension
point="com.teamcenter.rac.util.tc_properties">
</extension>
</plugin>
Create a package.
a. In the Package Explorer view, right-click your project and choose New→Package.
b. In the Name box, type the path name where the properties file was
originally. For example, if you originally extracted the mpp.properties file, the package name should be com.teamcenter.rac.cme.mpp.
c. Click the MANIFEST.MF tab and type your new package at the end of the Export-Package line. For example, if your project name
is com.mycom.propertiesfile and the new package is called com.teamcenter.rac.cme.mpp, the line
should read:
d. Export-Package: com.mycom.propertiesfile, com.teamcenter.rac.cme.mpp
Developing forms using JavaBeans
You can create a custom Java panel
(JPanel) assigned to a custom business object
and display the properties using JavaBeans.
when a user selects a custom ItemRevision business object and chooses the Viewer view or View→Properties,
the custom panel is displayed.
Panel rendering is registered to the business object by placing the following command
into a custom stylesheet_user.properties file:
Syntax: custom-business-object-name.JAVARENDERING=package-name.custom-java-panel-name
A)
1. Create a custom item business object.
2. In the Business Objects view, open the item revision business object (for example, A4_MyItemRevision), click the Properties tab,
and create the custom persistent properties you want to display in the panel,
3. Set the Enabled property constant to True for each of the new properties
4. Deploy the custom template
B)
1. Create the Eclipse project.
2. Update the Dependencies tab.
3. Update the Extensions tab.
Click the Add button.
Select the com.teamcenter.rac.util.tc_properties extension point
4. choose New→Package.
5. In the Name box, type com.teamcenter.rac.stylesheet
6. Right-click the com.teamcenter.rac.stylesheet package and choose New→File. In
the File Name box, type CustomSamplePanel.java and click Finish
7. Open the project’s Runtime tab, click the Add button, and add the com.teamcenter.rac.stylesheet
package.
8. Open the CustomSamplePanel.java file and enter the code: of Property to be
displayed
Ex: JPanel jPanel1 = new JPanel();
jPanel1.setLayout( new PropertyLayout() );
jPanel1.setOpaque( false );
JLabel jLabel1 = new JLabel("Test double");
PropertyTextField doubleTextField = new PropertyTextField();
doubleTextField.setProperty( "a4_MyDouble" );//This statement will get the value from database to rendere in Our Panel as a4_MyDouble is Property name in BMIDE
9. Right-click the com.teamcenter.rac.stylesheet
package and choose New→File. In the File Name box, type stylesheet_user.properties
and click Finish.
This file adds content to the stylesheet.properties
file. The _user name in the file indicates that this is a custom file
provided by a user.
Open the stylesheet_user.properties file and enter the following line:
A5_MyItemRevision.JAVARENDERING=com.teamcenter.rac.stylesheet.CustomSamplePanel
This setting will render the Property based
on CustomPanel code provided we have set the preference in Rich CLient
In the rich client,
create a preference for this rendering. Choose Edit→Options→Index→New
and in the Name box type A4_MyItemRevision.JAVARENDERING and in
the Values box, type com.teamcenter.rac.stylesheet.CustomSamplePanel.
Deploy Project and check:
Select Item
revision of custom Item and then View properties
*
The base component for a rich client form is a JPanel component that provides flexibility for the
placement of forms within different parent containers