Teamcenter之RCP的简单创建与运行

1、下载eclipse开发工具,一般为eclipse-SDK--系列。
2、展开eclipse的Window菜单,选择Preferences,选择Java->Installed JREs,选择Add,添加你的jre版本与路径。
3、选择Plug-in Development->Target Platform,选择Add。Teamcenter之RCP的简单创建与运行_第1张图片点击Next,然后点击Add。Teamcenter之RCP的简单创建与运行_第2张图片找到Teamcenter根目录中的portal文件,例如我的源文件为:D:\Siemens\Teamcenter11\portal。
4、选择Run->Debug Configurations,在Main标签中的Run a product后面写入com.teamcenter.rac.aifrcp.product,设置你的JRE环境。
进入Arguments标签,在VM arguments文本框中输入-Xms256m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=128M -Djava.library.path=D:\Siemens\Teamcenter11\tccs\lib,然后点击Apply保存配置。
5、选择File->New->Plug-in Project,如果没有选择File->New->Other,在Wizards中输入Plug-in Project,选择Next。
6、在New Plug-in Project中,输入Project name名(例如com.demo),其他选项默认即可。
Teamcenter之RCP的简单创建与运行_第3张图片选择Next。
7、选择Generate an activator,a Java class that controls the plug-in’s file cycle和This plug-in will make contributions to the UI,在Rich Client Application中选择No。
Teamcenter之RCP的简单创建与运行_第4张图片
点击Next。
8、取消选择Create a plug-in using one of the templates,然后点击Finish,建立项目完成。
9、打开META-INF文件夹下的MANIFEST.MF,上面漏掉一点忘记修改Version,可以在Overriew标签里面的Version中,删除.qualifier。
Teamcenter之RCP的简单创建与运行_第5张图片
10、选择Dependencies标签,点击Add,添加七大标配包,来跟我一起背
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
Teamcenter之RCP的简单创建与运行_第6张图片
11、找到plugin.xml文件开始修改,如果没有可在Extensions标签中点击Add按钮就会自动出现。XML代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
	<extension
		point="org.eclipse.ui.commands">
		<command
			icon="icons/sample.gif" <!--这里是图片-->
			id="com.demo1.handlers.demoOne1"
			name="子菜单一"/>
	</extension>
	
	<extension
		point="org.eclipse.ui.handlers">
		<handler
			class="com.demo1.handlers.DemoOne1"
			commandId="com.demo1.handlers.demoOne1">
		</handler>
	</extension>
	
	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			locationURI="popup:org.eclipse.ui.popup.any?after=additions">
			<menu
				label="上下文菜单"
				id="shang">
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/example.gif">
				</command>
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/example.gif">
				</command>
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/example.gif">
				</command>
			</menu>
		</menuContribution>
	</extension>

	<extension
		point="org.eclipse.ui.menus">
		<menuContribution
			locationURI="menu:org.eclipse.ui.main.menu?after=additions">
			<menu
				label="测试菜单"
				id="ceshi">
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/sample.gif">
				</command>
			</menu>
		</menuContribution>
		<menuContribution
			locationURI="menu:ceshi">
			<menu
				label="菜单一">
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/sample.gif">
				</command>
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/sample.gif">
				</command>
			</menu>
		</menuContribution>
		<menuContribution
			locationURI="menu:ceshi">
			<menu
				label="菜单二">
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/sample.gif">
				</command>
				<command
					commandId="com.demo1.handlers.demoOne1"
					icon="icons/sample.gif">
				</command>
			</menu>
		</menuContribution>
	</extension>		
</plugin>

12、然后新建com.demo1.handlers包,新建class文件DemoOne1,这里一定要记住handler标签里面的class="com.demo1.handlers.DemoOne1"与新建包名和新建class文件名一致,否则运行不会成功。然后id与commandId无所谓,因为我建立时时demo1所以为了方便改成了demo1,这个名字不用讲究。
然后DemoOne1.java代码如下:

package com.demo1.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;

public class DemoOne1 extends AbstractHandler implements IHandler{
	
	public Object execute(ExecutionEvent event) throws ExecutionException{
		//这里可以加个运行代码
		return null;
	}
}

13、导出项目,File->Export,选择Plug-in Development文件夹下的Deployable plug-ins and fragments。点击Next按钮。
14、在Available Plug-ins and Fragments中选择你的包,在Directory中放到你的teamcenter文件夹下的portal文件夹中。teamcenter程序运行都是在portal文件夹中的plugins文件夹中寻找运行程序,而eclipse导出文件是自动导出到plugins文件夹中的。
Teamcenter之RCP的简单创建与运行_第7张图片
15、打开teamcenter,输入ID与密码登录即可。在eclipse中直接运行虽然可以打开teamcenter但是无法运行,这是因为没有打开TAO ImR,但是直接运行teamcenter它会自动帮你打开。TAO窗口与运行结果如下:
Teamcenter之RCP的简单创建与运行_第8张图片
Teamcenter之RCP的简单创建与运行_第9张图片
Teamcenter之RCP的简单创建与运行_第10张图片
以上就是teamcenter从创建到运行的全部过程了,如果有问题可留言哦!

你可能感兴趣的:(teamcenter)