Teamcenter13.3-RCP开发基础

一、插件概述

1Plugin定义

一个插件(plug-in)是Eclipse平台中的最小功能单元,它可以被独立的开发和发布。

2Plugin的内容组成

1)JAR中的Java代码

2)一些只读文件和其它资源(例如图片、web模板、消息资源文件、本地类库等)。

3)一个插件清单,用于声明它与其它插件之间的连接关系,一个插件的清单由几个文件表示:

①manifest.mf文件是一个OSGI bundle清单,它描述了插件间运行时的依赖关系;

②plugin.xml是一个XML文件,它描述了扩展和扩展点的信息

3Eclipse Plugin体系结构

4、Dependencies页签加入以下Required Plug-ins

  1. com.teamcenter.rac.aifrcp:Teamcenter基础客户化插件,一些主要的接口以及抽象类,入口类等都在该插件中进行了定义。
  2. com.teamcenter.rac.common:Teamcenter的一些动作和菜单都在该插件包中进行了定义,如菜单栏,工具栏,以及右键菜单等。
  3. com.teamcenter.rac.external:Teamcenter插件中引用到的第三方类大部分都在该插件中进行了集成,可以说该插件为资源性插件。
  4. com.teamcenter.rac.kernel:Teamcenter核心插件包。
  5. com.teamcenter.rac.neva:`com.teamcenter.rac.neva`  是一个  Java  类库,属于  Siemens  Teamcenter  集成平台(RAC)的一部分。NEVA  全称为  "New  Enterprise  Visualization  Architecture",是一个用于将  3D  模型、工程图纸等企业内部数据类型进行可视化的技术。在  Teamcenter  系统中,NEVA  技术被用于支持  3D  模型可视化及交互式浏览操作,类库  `com.teamcenter.rac.neva`  就是  NEVA  技术的一项实现,它提供了相应的  API  接口供客户端应用程序调用。使用  `com.teamcenter.rac.neva`  类库,可以快速、轻松地构建出高效、灵活的  3D  可视化应用程序,满足各种企业或行业内部的需求。
  6. com.teamcenter.rac.tcapps:Teamcenter中部分应用的基础实现都在该类中进行了实现,这个主要是遗留问题,虽然现在的应用大 部分都是以相应的插件进行了区别与分类,但是大部分应用的业务逻辑都在该插件中进行实现,还有一些公共组件等
  7. com.teamcenter.rac.util:

    (1)该插件是Teamcenter对大部分Swing组件进行了继承与重写。如: iTextField继承于JTextField; iComboBox类为Teamcenter自己定义的组件。

    (2)该插件中还定义了一些公共工具类,如:TcLogger日志控制类,Registry注册控制类等。

  8. Debug配置文件:
  9. -Xms256m -Xmx1024m -Djava.library.path=C:\Siemens\Teamcenter11\tccs\lib -Dautologin.user=infodba -Dautologin.pass=infodba 

5、菜单添加的三要素

Command:有一个唯一的ID号,它代表了一个动作的抽象意义,例如拷贝,粘贴,保存。它不代表一个动作的实施。

Menu contributions:代表一个特定的视图或者一个命令的视图话呈现。它创建了菜单和工具条的结构框架并且把他们插入到Eclipse的正确位置。每个位置都是用URI( Uniform Resource Identifier )来标识的。Menu contribution能够定义一个菜单的标签,助记符和图标。它和已经被定义的Command之间相互关联。一个菜单可以通过visibleWhen来控制它的显示。

Handlers:大多数是继承于AbstractHandler类。Handlers在它的execute(*)方法中提供了一个应用程序上下文。如果一个命令没有一个激活的handlers被定义,任何一个Menu contributions中定义的Command都不可见。一个Command可以定义一个默认的handler来确保它能够有一个可被激活的handler。handler可以通过ActiveWhen语句来被显示的激活声明或者被编程的形式激活。Handler也可以在任何一个Menu contributions中用enabledWhen表达式,显示的定义一个按钮什么时候可显示。

6plugin.xml页签

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?eclipse version="3.4"?>
  3. <plugin>
  4. <extension point="org.eclipse.ui.commands">
  5. <!-- 20219月练习 -->
  6. <command id="com.dgt.hyl.ox.sept.commands.CreateComponenCommand" name="创建零部件"/>
  7. </extension>
  8. <extension point="org.eclipse.ui.handlers">
  9. <!-- 20219月练习 -->
  10. <handler commandId="com.dgt.hyl.ox.sept.commands.CreateComponenCommand" class="com.dgt.hyl.ox.sept.handlers.CreateComponenHandler"/>
  11. </extension>
  12. <extension point="org.eclipse.ui.menus">
  13. <!-- 主菜单 -->
  14. <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
  15. <menu id="Menu_202109" label="2021年九月练习">
  16. <command commandId="com.dgt.hyl.ox.sept.commands.CreateComponenCommand"/>
  17. <visibleWhen>
  18. <and>
  19. <or>
  20. <!-- 我的制造工艺规划器 -->
  21. <reference definitionId="com.teamcenter.rac.cme.mpp.inMainView"/>
  22. </or>
  23. </and>
  24. </visibleWhen>
  25. </menu>
  26. </menuContribution>
  27. </extension>
  28. </plugin>

7、常见的locationURI:

主菜单栏:menu:org.eclipse.ui.main.menu

主工具栏:toolbar:org.eclipse.ui.main.toolbar

弹出菜单:popup:org.eclipse.ui.popup.any

8、需要继承的类

Handler继承:Handler extends AbstractHandler;

Action继承:Action extends AbstractAIFAction;

Command继承:Command extends AbstractAIFCommand;

Dialog继承:Dialog extends AbstractAIFDialog;

Operation继承:Operation extends AbstractAIFOperation;

9、继承的类

1AbstractHandler

①handler继承于此类;

②public Object execute(*)方法是程序的执行入口。

2AbstractAIFAction

①Action一般继承于此类;

②public void run( )是程序的入口,必须实现的方法(可在此初始化Command);

③executeModal( )执行Command。

3AbstractAIFCommand

①Command的继承于此类;

②setRunnable( )方法可以让来运行初始化对话框。

4AbstractAIFDialog

①Dialog继承于此类,用来定义对话框;

②此类中的事件监听器中,初始化Operation,即操作。

5AbstractAIFOperation

①Operation继承于此类,用于定义操作;

②executeOperation( )方法是程序必须执行的方法,里面主要定义具体的操作。

10Teamcenter

1)TCComponent

2)TCComponentItem——对应Item

3)TCComponentItemRevision——对应Item Revision

4)TCComponentItemType——对应Item类型

5)TCComponentFolderType——对应文件夹类型

6)TCComponentUser——对应用户

7)TCComponentPerson——对应人员

8)TCComponentGroup——对应组织

9)TCComponentRole——对应角色

10)TCComponentForm——对应表单

11Teamcenter UI ComponentsTC页面元素

1)iTextField——文本框

2)JCheckBox——复选框

3)JButton——按钮

4)Jpanel——面板

5)Jlabel——标签

6)Jdialog——对话框

7)DateButton——日历

二、Item零件对象

1、根据零件版本创建视图对象

  1. /**
  2. * 根据零件版本,创建视图对象
  3. * @param tCPBOMItemRevision
  4. */
  5. public static TCComponentBOMLine createTCPBOMLine(TCComponentItemRevision tCPBOMItemRevision)
  6. {
  7.     try {
  8.         TCComponentRevisionRuleType revRuleType = (TCComponentRevisionRuleType) session.getTypeComponent("RevisionRule");
  9.         TCComponentRevisionRule revRule = revRuleType.getDefaultRule();
  10.         TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
  11.         TCComponentBOMWindow bomWindow = bomWindowType.create(revRule);
  12.         TCComponentBOMLine createBomLine = bomWindow.setWindowTopLine(tCPBOMItemRevision.getItem(), tCPBOMItemRevision, null, null);
  13.         return createBomLine;
  14.     } catch (Exception e) {
  15.         e.printStackTrace();
  16.         MessageBox.post(e.getMessage(),"提示",MessageBox.ERROR);
  17.     }
  18.     return null;
  19. }

2、创建带有必填字段的Item对象

  1. /**
  2. * 创建带有必填字段的Item对象
  3. * @param session
  4. * @param item_type 创建的对象类型
  5. * @param item_property_map 创建的Item需要设置的属性,<属性名,属性值>
  6. * @param itemRev_property_map 创建的ItemRevison需要设置的属性,<属性名,属性值>
  7. *
  8. * 2017-11-28
  9. */
  10. @SuppressWarnings("rawtypes")
  11. public static TCComponent performCreate_bak(TCSession session,String item_type,Map<String, String> item_property_map,Map<String, String> itemRev_property_map)throws TCException{
  12.     IBOCreateDefinition IBOcreateDefinition = BOCreateDefinitionFactory.getInstance().getCreateDefinition(session, item_type);
  13.     if (IBOcreateDefinition == null){
  14.         MessageBox.post("IBOCreateDefinition获取失败","出错了",MessageBox.INFORMATION);
  15.         return null;
  16.     }
  17.     List<ICreateInstanceInput> m_inputs = new ArrayList<>();
  18.     CreateInstanceInput localCreateInstanceInput = new CreateInstanceInput(IBOcreateDefinition);
  19.     for(Map.Entry<String, String> entry:item_property_map.entrySet()){
  20.         localCreateInstanceInput.add(entry.getKey(), entry.getValue());
  21.     }
  22.     m_inputs.add(localCreateInstanceInput);
  23.     List<IBOCreateDefinition> localList = IBOcreateDefinition.getSecondaryCreateDefinition("revision");
  24.     if ((localList != null) && (localList.size() > 0)){
  25.         IBOCreateDefinition localIBOCreateDefinition2 = (IBOCreateDefinition)localList.get(0);
  26.         if (localIBOCreateDefinition2 != null){
  27.             CreateInstanceInput localCreateInstanceInput2 = new CreateInstanceInput(localIBOCreateDefinition2);
  28.             // localCreateInstanceInput2.add("item_revision_id", "");
  29.             for(Map.Entry<String, String> entry:itemRev_property_map.entrySet()){
  30.                 // localCreateInstanceInput2.add("ca9_DocumentType", "HJFJGKB");
  31.                 // localCreateInstanceInput2.add("ca9_CarSeries", bomLine.parent().getItemRevision().getProperty("ca9_CarSeries"));
  32.                 // localCreateInstanceInput2.add("ca9_Profession", "HJ");
  33.                 localCreateInstanceInput2.add(entry.getKey(), entry.getValue());
  34.             }
  35.             m_inputs.add(localCreateInstanceInput2);
  36.         }
  37.     }
  38.     Object localObject1 = null;
  39.     List<TCComponent> localList2 = SOAGenericCreateHelper.create(session, IBOcreateDefinition, m_inputs);
  40.     Object localObject2;
  41.     Object localObject3;
  42.     if ((localList2 != null) && (localList2.size() > 0)) {
  43.         localObject2 = localList2.iterator();
  44.         while (((Iterator)localObject2).hasNext())
  45.         {
  46.         localObject3 = (TCComponent)((Iterator)localObject2).next();
  47.         if ((localObject3 instanceof TCComponentItem))
  48.         {
  49.         localObject1 = localObject3;
  50.         break;
  51.         }
  52.         }
  53.     }
  54.     return (TCComponent)localObject1;
  55. }

3、创建ITEM

  1. //1、创建没有必填属性的零件对象
  2. TCSession session =(TCSession)AIFUtility.getDefaultSession();
  3. TCComponentItemType tccomponentItemType = (TCComponentItemType)
  4. session.getTypeComponent("Item");//itemformfolder
  5. TCComponentItem item = tccomponentItemType.create(ITEMID, REV ID, ITEM TYPE, OBJECT NAME, DESC, null);
  6. //2、创建有必填属性的零件对象
  7. /**创建含有必填项的零件*/
  8. public void createItem() {
  9.     (TCComponentItemType) itemType = (TCComponentItemType) session.getTypeComponent(ItemType);//根据类型获取类型对象
  10.     DGTUtility dgtUtility = new DGTUtility(session);
  11.     TCComponentItemRevisionType itemRevType = dgtUtility.getItemRevisionType(ItemType);//根据类型获取版本类型对象
  12.     Map<String,Object> item_property_map = getPropertyMap(itemType,itemRev.getItem());//获取可显示输入的零件属性值列表
  13.     Map<String,Object> itemRev_property_map = getPropertyMap(itemRevType,itemRev);//获取可显示输入的零件版本属性值列表
  14.     Map<String, TCComponent> uomTagObject = getUomTagObject();//获取度量单位对象
  15.     String property = itemRev.getItem().getProperty("uom_tag");//获取选中零件的度量单位
  16.     item_property_map.put("uom_tag", uomTagObject.get(property));//复制度量单位属性
  17.     ID = itemRev.getItem().getProperty("item_id")+"_REF";
  18.     item_property_map.put("item_id", ID);//更改继承的ID
  19.     //item_property_map.put("object_name", NAME);//更改继承的名称
  20.        TCComponentItem docItem = (TCComponentItem) DGTUtility.performCreate_bak3(session, ItemType, item_property_map, itemRev_property_map);
  21. }

4、根据零件类型获取零件版本类型

  1. /**
  2. * 根据零件类型获取零件版本类型
  3. * @param itemType:零件类型
  4. */
  5. public TCComponentItemRevisionType getItemRevisionType(String itemType) {
  6.     TCComponentItemRevisionType tccomponentitemrevisiontype = null;
  7.     try {
  8.         TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(itemType);
  9.         if (typeComponent != null) {
  10.             String s2 = typeComponent.getRevisionTypeName(itemType);
  11.             tccomponentitemrevisiontype = (TCComponentItemRevisionType) session.getTypeComponent(s2);
  12.         }
  13.     } catch (TCException e) {
  14.         e.printStackTrace();
  15.     }
  16.     return tccomponentitemrevisiontype;
  17. }

5、获取可显示输入的属性对象列表

  1. /**
  2. * 获取可显示输入的属性对象列表
  3. * @param type:类型对象
  4. * @param item:选中的零件对象*/
  5. public Map<String,Object> getPropertyMap(TCComponentType type,TCComponent item) throws TCException{
  6.     Map<String,Object> property_map = new HashMap<>();
  7.     //获取获取可显示输入的属性对象
  8.     BOCreateDefinition bocreatedefinition3 = (BOCreateDefinition)BOCreateDefinitionFactory.getInstance().getCreateDefinition(type.getSession(), type.getType());
  9.     List<BOCreatePropertyDescriptor> createPropertyDescriptors = bocreatedefinition3.getCreatePropertyDescriptors();
  10.     for(int i = 0;i<createPropertyDescriptors.size();i++) {
  11.         TCPropertyDescriptor propertyDescriptor = createPropertyDescriptors.get(i).getPropertyDescriptor();
  12.         String name2 = propertyDescriptor.getName();
  13.         String property = item.getProperty(name2);
  14.         if(DGTUtility.isEmpty(property)) {//判断选中零件的该属性是否有值
  15.             //无值使用属性本身默认值
  16.             property_map.put(name2, propertyDescriptor.getDefaultValue());
  17.         }else {
  18.             //获取属性LOV
  19.             TCComponentListOfValues lov = propertyDescriptor.getLOV();
  20.             if (lov != null) {//判断是否有LOV
  21.                 //获取LLOV对象
  22.                 Map<String, Object> lovObject = getLOVObject(lov);
  23.                 Object object = lovObject.get(property);
  24.                 property_map.put(name2, object);//写入LOV对象
  25.             }else {
  26.                 property_map.put(name2, property);
  27.             }
  28.         }
  29.     }
  30.     return property_map;
  31. }

6、创建带必填项的零件

  1. /**
  2. * 创建带必填项的零件
  3. * @param session
  4. * @param item_type 创建的对象类型
  5. * @param item_property_map 创建的Item需要设置的属性,<属性名,属性值>
  6. * @param itemRev_property_map 创建的ItemRevison需要设置的属性,<属性名,属性值>
  7. */
  8. @SuppressWarnings("rawtypes")
  9. public static TCComponent performCreate_bak3(TCSession session, String item_type,
  10.     Map<String, Object> item_property_map, Map<String, Object> itemRev_property_map) throws TCException {
  11.     IBOCreateDefinition IBOcreateDefinition = BOCreateDefinitionFactory.getInstance().getCreateDefinition(session,item_type);
  12.     if (IBOcreateDefinition == null) {
  13.         MessageBox.post("IBOCreateDefinition获取失败", "出错了", MessageBox.INFORMATION);
  14.         return null;
  15.     }
  16.     List<ICreateInstanceInput> m_inputs = new ArrayList<>();
  17.     CreateInstanceInput localCreateInstanceInput = new CreateInstanceInput(IBOcreateDefinition);
  18.     for (Map.Entry<String, Object> entry : item_property_map.entrySet()) {
  19.         localCreateInstanceInput.add(entry.getKey(), entry.getValue());
  20.     }
  21.     m_inputs.add(localCreateInstanceInput);
  22.     List<IBOCreateDefinition> localList = IBOcreateDefinition.getSecondaryCreateDefinition("revision");
  23.     if ((localList != null) && (localList.size() > 0)) {
  24.         IBOCreateDefinition localIBOCreateDefinition2 = (IBOCreateDefinition) localList.get(0);
  25.         if (localIBOCreateDefinition2 != null) {
  26.             CreateInstanceInput localCreateInstanceInput2 = new CreateInstanceInput(localIBOCreateDefinition2);
  27.             for (Map.Entry<String, Object> entry : itemRev_property_map.entrySet()) {
  28.                    localCreateInstanceInput2.add(entry.getKey(), entry.getValue());
  29.             }
  30.             m_inputs.add(localCreateInstanceInput2);
  31.         }
  32.     }
  33.     Object localObject1 = null;
  34.     List<TCComponent> localList2 = SOAGenericCreateHelper.create(session, IBOcreateDefinition, m_inputs);
  35.     Object localObject2;
  36.     Object localObject3;
  37.     if ((localList2 != null) && (localList2.size() > 0)) {
  38.         localObject2 = localList2.iterator();
  39.         while (((Iterator) localObject2).hasNext()) {
  40.             localObject3 = (TCComponent) ((Iterator) localObject2).next();
  41.             if ((localObject3 instanceof TCComponentItem)) {
  42.                 localObject1 = localObject3;
  43.                 break;
  44.             }
  45.         }
  46.     }
  47.     return (TCComponent) localObject1;
  48. }

7、创建ItemFormFolder

  1. TCSession session =(TCSession)AIFUtility.getDefaultSession();
  2. TCComponentItemType tccomponentItemType = (TCComponentItemType)
  3. session.getTypeComponent("Item");//itemformfolder
  4. TCComponentItem item = tccomponentItemType.create(ITEMID, REV ID, ITEM TYPE, OBJECT NAME, DESC, null);

8、获取指定规则的零组件最新ID:根据零组件命名规则模式和零组件类型

  1. //包:TcSoaCoreRac
  2. /**
  3. * 根据零组件命名规则模式和零组件类型获取指定规则的零组件最新ID
  4. * @param String pattern:命名规则模式
  5. * @param String type:零组件类型
  6. * @return String pattern模式的零组件ID
  7. * huyanling 2021-10-14
  8. * */
  9. @SuppressWarnings({ "rawtypes" })
  10. public String getItemIdByPatternAndType(String pattern,String type) {
  11.     String s = null;
  12.     try {
  13.         Object obj1;
  14.         String result = "isTrue:"+type+":item_id:"+pattern;
  15.         String as4[] = {result};
  16.         TCPreferenceService tcPreferenceService = session.getPreferenceService();//获取当前会话设置模式的服务
  17.         tcPreferenceService.setStringArray(1, "TC_LAST_USED_PATTERNS", as4);//根据模式设置最新生成ID的命名规则模式
  18.         DataManagementService datamanagementservice = DataManagementService.getService(session);
  19.         //创建有几个agenerateitemidsandinitialrevisionidsproperties对象的GenerateItemIdsAndInitialRevisionIdsProperties对象
  20.         com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties agenerateitemidsandinitialrevisionidsproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties[1];
  21.         agenerateitemidsandinitialrevisionidsproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties();
  22.         agenerateitemidsandinitialrevisionidsproperties[0].item = null;
  23.         agenerateitemidsandinitialrevisionidsproperties[0].itemType = type;//零组件类型
  24.         agenerateitemidsandinitialrevisionidsproperties[0].count = 1;//获取几个最新ID
  25.         //获取零组件类型的自增长零组件ID及零组件版本ID
  26.         obj1 = datamanagementservice.generateItemIdsAndInitialRevisionIds(agenerateitemidsandinitialrevisionidsproperties);
  27.         //获取obj1中的值
  28.         Map map = ((com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse) (obj1)).outputItemIdsAndInitialRevisionIds;
  29.         Iterator iterator = map.entrySet().iterator();
  30.         if(iterator.hasNext())//遍历提取出newItemId
  31.         {
  32.             java.util.Map.Entry entry = (java.util.Map.Entry)iterator.next();
  33.             com.teamcenter.services.rac.core._2006_03.DataManagement.ItemIdsAndInitialRevisionIds aitemidsandinitialrevisionids[] = (com.teamcenter.services.rac.core._2006_03.DataManagement.ItemIdsAndInitialRevisionIds[])entry.getValue();
  34.             com.teamcenter.services.rac.core._2006_03.DataManagement.ItemIdsAndInitialRevisionIds itemidsandinitialrevisionids = aitemidsandinitialrevisionids[0];
  35.             s = itemidsandinitialrevisionids.newItemId;
  36.         }
  37.     } catch (TCException e) {
  38.         e.printStackTrace();
  39.     }
  40.     return s;
  41. }

9、根据零件类型查询其命名规则模式列表

  1. /**
  2. * 根据零件类型查询其命名规则模式列表
  3. * String ITEMTYPE = "D2_GeneralDesign";
  4. * @param ITEMTYPE:零件类型
  5. * */
  6. public void getPatternsByItemType(String ITEMTYPE)
  7. {
  8.     String as[] = {
  9.         "item_id", "item_revision_id"
  10.     };
  11.     String as1[] = {
  12.         ITEMTYPE, ITEMTYPE
  13.     };
  14.     //获取命名规则列表,包括itemitemRevision的命名规则
  15.     NamingRule anamingrule[] = NamingRulesHelper.getInstance().getNamingRules(session, as1, as);
  16.     String as2[] = anamingrule[0].getPatterns();//item命名规则
  17.     String as3[] = anamingrule[1].getPatterns();//itemRevision命名规则
  18.     String s1 = anamingrule[0].getPreferredPattern();//当零件未关联命名规则时,默认零件命名规则
  19.     String s2 = anamingrule[1].getPreferredPattern();//当零件版本未关联命名规则时,默认版本命名规则
  20.     String condition1 = anamingrule[0].getCondition();//命名规则判断条件
  21.     String condition2 = anamingrule[1].getCondition();//版本命名规则判断条件
  22. }

10、根据零件类型获取零件版本类型

  1. /**根据零件类型获取零件版本类型
  2. * @param itemType:零件类型*/
  3. public TCComponentItemRevisionType getItemRevisionType(String itemType) {
  4.     TCComponentItemRevisionType tccomponentitemrevisiontype = null;
  5.     try {
  6.         TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(itemType);
  7.         if(typeComponent != null){
  8.             String s2 = typeComponent.getRevisionTypeName(itemType);
  9.             tccomponentitemrevisiontype = (TCComponentItemRevisionType)session.getTypeComponent(s2);
  10.         }
  11.     } catch (TCException e) {
  12.         e.printStackTrace();
  13.     }
  14.     return tccomponentitemrevisiontype;
  15. }

11、根据零件类型和属性,获取属性的LOV

  1. /**根据零件类型和属性,获取属性的LOV
  2. * @param typeComponent:零件对象类型,如"TCComponentItemType"
  3. * @param properName:属性名称,如"uom_tag":度量单位
  4. * @author huyanling
  5. * 2021-10-20
  6. * */
  7. public Map<Object, Object> getPropLOVMap(TCComponentType typeComponent,String properName){
  8.     Map<Object, Object> maps = null;
  9.     try {
  10.         TCPropertyDescriptor tcpropertydescriptor = typeComponent.getPropertyDescriptor(properName);
  11.         TCComponentListOfValues lov = tcpropertydescriptor.getLOV();
  12.         if(lov == null) {
  13.             MessageBox.post(properName+"属性没有LOV,请配置附加LOV!","提示",MessageBox.INFORMATION);
  14.             return null;
  15.         }
  16.         maps = new HashMap<Object, Object>();
  17.         ListOfValuesInfo listOfValues = lov.getListOfValues();
  18.         Object[] lovbd1 = listOfValues.getListOfValues();//LOV
  19.         String[] lovs1 = listOfValues.getLOVDisplayValues();//LOV本地化值
  20.         for(int i = 0;i<lovbd1.length;i++) {
  21.             //真实名称与本地化名称不匹配时直接使用真实名称列表
  22.             if(lovbd1.length > lovs1.length) {
  23.                 maps.put(lovbd1[i], lovbd1[i]);
  24.             }else {
  25.                 maps.put(lovs1[i], lovbd1[i]);
  26.             }
  27.         }
  28.     } catch (TCException e) {
  29.         MessageBox.post(e.getMessage(),"提示",MessageBox.INFORMATION);
  30.         return null;
  31.     }
  32.     return maps;
  33. }

12、根据零件类型和属性,获取属性本地化的LOV列表

  1. /**根据零件类型和属性,获取属性本地化的LOV列表
  2. * @param typeComponent:零件对象类型,如"TCComponentItemType"
  3. * @param properName:属性名称,如"uom_tag":度量单位
  4. * @author huyanling
  5. * 2021-10-20
  6. * */
  7. public Object[] getPropLOVDisList(TCComponentType typeComponent,String properName){
  8.     try {
  9.         TCPropertyDescriptor tcpropertydescriptor = typeComponent.getPropertyDescriptor(properName);
  10.         TCComponentListOfValues lov = tcpropertydescriptor.getLOV();
  11.         if(lov == null) {
  12.             MessageBox.post(properName+"属性没有LOV,配置附加LOV!","提示",MessageBox.INFORMATION);
  13.             return null;
  14.         }
  15.         ListOfValuesInfo listOfValues = lov.getListOfValues();
  16.         Object[] lovbd1 = listOfValues.getListOfValues();//LOV
  17.         Object[] lovs1 = listOfValues.getLOVDisplayValues();//LOV本地化值
  18.         //真实名称与本地化名称不匹配时直接使用真实名称列表
  19.         if(lovbd1.length > lovs1.length) {
  20.          lovs1 = lovbd1;
  21.         }
  22.         return lovs1;
  23.     } catch (TCException e) {
  24.         MessageBox.post(e.getMessage(),"提示",MessageBox.INFORMATION);
  25.         return null;
  26.     }
  27. }

三、Folder文件夹对象

1、创建文件夹Folder

  1. TCComponentFolderType folder = (TCComponentFolderType) session.getTypeComponent("Folder");
  2. folder.create("练习0825", "", null);

2、获取home文件夹

  1. TCSession session =(TCSession)AIFUtility.getDefaultSession();
  2. TCComponentFolder homeFolder = session.getUser().getHomeFolder();//获取的home文件夹
  3. TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();
  4. homeFolder.add("contents", tcComponentItem);//“contents”关系将item放入home

3、创建零件、自定义文件夹

  1. TCComponentFolderType folder = (TCComponentFolderType) session.getTypeComponent("Folder");
  2. folder.create("练习0825", "", null);
  3. TCComponentItemType item = (TCComponentItemType) session.getTypeComponent("Item");
  4. //item.create(itemID, revID, 类型, 名称, 描述, null)
  5. TCComponentItem newItem = item.create("10009", "A", "QL2_Change", "test", "", null);

四、Dataset数据集对象

1、创建数据集Dataset

  1. TCComponentDatasetType typeComponent = (TCComponentDatasetType) session.getTypeComponent("Dataset");
  2. //创建数据集typeComponent.create(名称, 描述, 类型);
  3. //TCComponentDataset create1 = typeComponent.create("测试数据集", "", "MSExcel");
  4. //create1.setFiles(new String[]{"D:\\attributenew.xls"}, new String[]{"excel"});
  5. TCComponentDataset create = typeComponent.create("word测试", "", "MSWordX");
  6. create.setFiles(new String[]{"D:\\IP.docx"}, new String[]{"word"});
  7. addDatasetNewstuff(create);

五、Form表单对象

六、BOMline对象

七、EPMTask工作流程任务

1、通过已有的流程模板发起一个流程

  1. /**
  2. * 通过已有的流程模板发起一个流程
  3. * @throws TCException
  4. */
  5. public void startProcess(TCComponentItemRevision item) throws TCException{
  6.     //获取session
  7.     TCSession session = getSession();
  8.     //获取流程模板类型对象
  9.     TCComponentTaskTemplateType TaskTemplateT = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate");
  10.     //获取流程模板 arg:流程模板名称
  11.     TCComponentTaskTemplate find = TaskTemplateT.find("TCM Release Process", 0);
  12.     //获取流程类型对象
  13.     TCComponentProcessType procesType = (TCComponentProcessType) session.getTypeComponent("Job");
  14.     //获取零件名称
  15.     String itemName = item.getProperty("object_name");
  16.     //发起流程
  17.     procesType.create(itemName, "", find, new TCComponent[]{item}, new int[]{1});
  18. }

八、其它

1、获取选中对象

  1. //方式一:获取选中的多个对象
  2. StructuredSelection str = (StructuredSelection)HandlerUtil.getCurrentSelection(event);
  3. Iterator iterator = str.iterator();//获取所有选择的对象
  4. while (iterator.hasNext()) {//遍历选择对象
  5. AIFComponentContext aif = (AIFComponentContext)iterator.next();}
  6. //方式二:获取选中的多个对象
  7. InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
  8. for (InterfaceAIFComponent interfaceAIFComponent:targetComponents) {
  9. System.out.println("方式二多个对象:"+interfaceAIFComponent);}
  10. //方式三:获取选中的单个对象
  11. InterfaceAIFComponent targetComponent = application.getTargetComponent();

2、查询已存在的用户

  1. TCComponentUserType type = (TCComponentUserType) session.getTypeComponent("User");
  2. TCComponentUser find = type.find(user);

3、设置对象属性

  1. //1)常用
  2. TCComponentItem item = new TCComponentItem();
  3. item.setProperty("object_name", "hello");
  4. item.setProperty("item_id", "122222");
  5. item.getProperty("object_name");
  6. //2)当是大批量的properties要设定值时
  7. TCFormProperty[] ps = f.getAllFormProperties();
  8. ps[0].setStringValueData ( "abc" );
  9. ps[1].setStringValueData ( "def" );
  10. f.setTCProperties(ps); // Now is saved to the db
  11. //3)当properties数量不大时
  12. TCFormProperty p = f.getFormTCProperty("my_prop_name");
  13. p.setStringValue ( "abc" );

4、获取子对象

  1. InterfaceAIFComponent targetComponent = application.getTargetComponent();
  2. if(targetComponent instanceof TCComponentItem){
  3.     TCComponentItem item = (TCComponentItem)targetComponent;
  4.     //获取子对象:getRelationObject(item);
  5. }
  6. //1)获取所以子对象
  7. AIFComponentContext[] children = item.getChildren();
  8. for(AIFComponentContext aif:children){
  9.     System.out.print(aif);
  10. }
  11. //2)根据关系获取最新对象
  12. TCComponent relatedComponent = item.getRelatedComponent("revision_list");
  13. if(relatedComponent instanceof TCComponentItemRevision){
  14.     TCComponentItemRevision item1 = (TCComponentItemRevision)relatedComponent;
  15.     System.out.print(item1);
  16. }
  17. //3)根据关系获取所有对象
  18. TCComponent[] relatedComponents = item.getRelatedComponents("revision_list");
  19. for(TCComponent tc:relatedComponents){
  20.     if(tc instanceof TCComponentItemRevision){
  21.         TCComponentItemRevision item2 = (TCComponentItemRevision)tc;
  22.         System.out.print(item2);
  23.     }
  24. }

5、查看对象被哪个对象所引用

  1. TCComponentDataset dataset = new TCComponentDataset();
  2. AIFComponentContext[] whereReferenced = dataset.whereReferenced();
  3. for (AIFComponentContext aif:whereReferenced) {
  4. System.out.print("数据集被"+aif+"对象引用。");
  5. }

6、上传文件到TC

  1. TCComponentDatasetType typeComponent = (TCComponentDatasetType) session.getTypeComponent("Dataset");
  2. //创建数据集typeComponent.create(名称, 描述, 类型);
  3. //TCComponentDataset create1 = typeComponent.create("测试数据集", "", "MSExcel");
  4. //create1.setFiles(new String[]{"D:\\attributenew.xls"}, new String[]{"excel"});
  5. TCComponentDataset create = typeComponent.create("word测试", "", "MSWordX");
  6. create.setFiles(new String[]{"D:\\IP.docx"}, new String[]{"word"});
  7. addDatasetNewstuff(create);

7、从TC上下载文件

  1. InterfaceAIFComponent targetComponent = application.getTargetComponent();
  2. //运行时判断是否是他的类或者子类
  3. if(targetComponent instanceof TCComponentDataset){
  4. TCComponentDataset dataset = (TCComponentDataset)targetComponent;
  5. //方式一
  6. TCComponentTcFile[] files2 = dataset.getTcFiles();
  7. for (TCComponentTcFile tc:files2) {
  8. tc.getFile("D:\\");
  9. }
  10. //方式二:
  11. dataset.getFiles("excel");//下载进入默认路径C:\\temp
  12. }

8、创建Excel

  1. public void createExcel(){
  2.     FileOutputStream fos=null;
  3.     //创建工作簿
  4.     HSSFWorkbook workbook = new HSSFWorkbook();
  5.     //创建sheet
  6.     HSSFSheet sheet = workbook.createSheet();
  7.     //创建row
  8.     HSSFRow row = sheet.createRow(0);
  9.     //创建cell
  10.     HSSFCell cell = row.createCell(0);
  11.     //设置cell的值
  12.     cell.setCellValue("hello");
  13.     File file=new File("D:\\hello.xlsx");//指定写入路径
  14.     try {
  15.         fos=new FileOutputStream(file);
  16.     } catch (FileNotFoundException e) {
  17.         e.printStackTrace();
  18.     }finally{
  19.         try {
  20.             workbook.write(fos);
  21.             fos.close();
  22.         } catch (IOException e) {
  23.          e.printStackTrace();
  24.         }
  25.     }
  26. }

9、读取Excel

  1. public void readExcel(){
  2.     File f=new File("D:\\hello.xlsx");    //指定写入路径
  3.     try {
  4.         //创建输入流对象
  5.         FileInputStream fileInput = new FileInputStream(f);
  6.         //创建工作簿对象
  7.         HSSFWorkbook workbook = new HSSFWorkbook(fileInput);
  8.         //获取sheet
  9.         HSSFSheet sheet = workbook.getSheet("Sheet0");
  10.         //HSSFSheet sheetAt = workbook.getSheetAt(0);
  11.         //获取row
  12.         HSSFRow row = sheet.getRow(0);
  13.         //获取cell
  14.         HSSFCell cell = row.getCell(0);
  15.         //查看cell的值
  16.         String stringCellValue = cell.getStringCellValue();
  17.         System.out.println(stringCellValue);
  18.     } catch (FileNotFoundException e) {
  19.         e.printStackTrace();
  20.     } catch (IOException e) {
  21.         e.printStackTrace();
  22.     }
  23. }

10java调用查询构建器

  1. public TCComponentDataset findDataBase(String findName){
  2.     TCSession session =(TCSession)AIFUtility.getDefaultSession();
  3.     try {
  4.         TCComponentQueryType typeComponent = (TCComponentQueryType) session.getTypeComponent("ImanQuery");
  5.         TCComponentQuery find = (TCComponentQuery) typeComponent.find("数据集...");
  6.         if(find == null){
  7.          return null;
  8.         }
  9.         TCQueryClause[] describe = find.describe();
  10.         String[] userId = {findName};
  11.         String[] strings = {"名称"};
  12.         TCComponent[] execute = find.execute(strings, userId);
  13.         if(execute.length>0){
  14.             System.out.println(execute[0]);
  15.             return (TCComponentDataset)execute[0];
  16.         }
  17.     } catch (TCException e) {
  18.         e.printStackTrace();
  19.     }
  20.     return null;
  21. }

11、开启一个新的线程

session.queueOperation(new ExportFastOperation(session, logger, findData));

12、获取LOV列表

  1. /**
  2. * 获取LOV列表
  3. * @param lovLOV对象
  4. * */
  5. public Map<String, Object> getLOVObject(TCComponentListOfValues lov) throws TCException {
  6.     Map<String, Object> maps = new HashMap<String, Object>();
  7.     ListOfValuesInfo listOfValues = lov.getListOfValues();
  8.     Object[] lovbd1 = listOfValues.getListOfValues();// LOV
  9.     String[] lovs1 = listOfValues.getLOVDisplayValues();// LOV本地化值
  10.     for (int j = 0; j < lovbd1.length; j++) {
  11.         // 真实名称与本地化名称不匹配时直接使用真实名称列表
  12.         if (lovbd1.length > lovs1.length) {
  13.          maps.put(lovbd1[j].toString(), lovbd1[j]);
  14.         } else {
  15.          maps.put(lovs1[j], lovbd1[j]);
  16.         }
  17.     }
  18.     return maps;
  19. }

13、获取度量单位对象

  1. /**
  2. * 度量单位对象
  3. * */
  4. public Map<String,TCComponent> getUomTagObject() throws TCException {
  5.     Map<String,TCComponent> uom_tagMap = new HashMap<String,TCComponent>();
  6.     TCComponentUnitOfMeasureType localTCComponentUnitOfMeasureType = (TCComponentUnitOfMeasureType)session.getTypeComponent("UnitOfMeasure");
  7.     TCComponent[] arrayOfTCComponents = localTCComponentUnitOfMeasureType.extent();
  8.     String uomtagStr = "";
  9.     for(TCComponent arrayOfTCComponent:arrayOfTCComponents) {
  10.         uomtagStr = arrayOfTCComponent.toString();
  11.         uom_tagMap.put(uomtagStr, arrayOfTCComponent);
  12.     }
  13.     return uom_tagMap;
  14. }

14、创建信封邮件Envelope

  1. //1、使用类型创建信封,需要获取到用户的邮箱文件夹,将信封添加到下面
  2. /**测试创建信封邮件
  3. * @throws Exception */
  4. public void TestNewEnvelope() throws Exception {
  5.     TCComponentEnvelopeType tccomponentenvelopetype = (TCComponentEnvelopeType) session.getTypeComponent("Envelope");
  6.     TCComponentUserType user = (TCComponentUserType)session.getTypeComponent("User");
  7.     TCComponentUser find = user.find("infodba");
  8.     TCComponentUser find2 = user.find("huahua");
  9.     String subject = "主题";
  10.     String message = "邮件";
  11.     TCComponent toReceivers[] = {find};
  12.     TCComponent ccReceivers[] = {find2};
  13.     String toExternalUsers[] = {"infodba"};
  14.     String ccExternalUsers[] = {"huahua"};
  15.     TCComponentFolder mailBox = find.getMailBox();
  16.     TCComponentFolder mailBox2 = find2.getMailBox();
  17.     TCComponent atccomponent1[] = validateAttachments();
  18.     TCComponentEnvelope envelope = tccomponentenvelopetype.create(subject, message, toReceivers, ccReceivers, toExternalUsers, ccExternalUsers, atccomponent1);
  19.     mailBox.add("contents", envelope);
  20.     mailBox2.add("contents", envelope);
  21. }

15、信封邮件附件对象解析

  1. /**信封邮件附件对象解析*/
  2. @SuppressWarnings({ "unchecked", "rawtypes" })
  3. public TCComponent[] validateAttachments(){
  4.     if(attachmentList == null || attachmentList.length == 0)
  5.         return null;
  6.     ArrayList arraylist = new ArrayList();
  7.     ArrayList arraylist1 = new ArrayList();
  8.     Object obj = null;
  9.     Registry registry = Registry.getRegistry(this);
  10.     for(int i = 0; i < attachmentList.length; i++){
  11.         try{
  12.          if(attachmentList[i].isTypeOf("BOMLine")){
  13.                 TCComponentBOMLine tccomponentbomline = (TCComponentBOMLine)attachmentList[i];
  14.                 arraylist.add(tccomponentbomline.getItemRevision());
  15.             } else if(attachmentList[i].isTypeOf("PseudoFolder")) {
  16.                 TCException tcexception1 = new TCException((new StringBuilder(String.valueOf(attachmentList[i].toString()))).append("-").append(registry.getString("invalidAttach.MESSAGE")).toString());
  17.                 arraylist1.add(tcexception1);
  18.             } else if(attachmentList[i] instanceof TCComponentMECfgLine) {
  19.                 TCComponentMECfgLine tccomponentmecfgline = (TCComponentMECfgLine)attachmentList[i];
  20.                 arraylist.add(tccomponentmecfgline.getUnderlyingComponent());
  21.             } else {
  22.                 arraylist.add(attachmentList[i]);
  23.             }
  24.         }catch(TCException tcexception2){
  25.          arraylist1.add(tcexception2);
  26.         }
  27.     }
  28.     
  29.     if(arraylist1.size() > 0) {
  30.         StringBuffer stringbuffer = new StringBuffer();
  31.         for(int j = 0; j < arraylist1.size(); j++) {
  32.             TCException tcexception = (TCException)arraylist1.get(j);
  33.             stringbuffer.append((new StringBuilder(String.valueOf(tcexception.getMessage()))).append("\n").toString());
  34.         }
  35.     }
  36.     TCComponent atccomponent[] = (TCComponent[])arraylist.toArray(new TCComponent[arraylist.size()]);
  37.     return atccomponent;
  38. }
  39. //2、调用系统的创建信封程序
  40. /**测试创建信封邮件
  41. * @throws Exception */
  42. public void TestNewEnvelope() throws Exception {
  43.     AIFDesktop currentDesktop = AIFDesktop.getActiveDesktop().getDesktopManager().getCurrentDesktop();
  44.     //1、传入用户
  45.     TCComponentUserType user = (TCComponentUserType)session.getTypeComponent("User");
  46.     TCComponentUser find = user.find("infodba");
  47.     TCComponentUser find2 = user.find("huahua");
  48.     Recipient recipient = new Recipient(find);
  49.     Recipient recipient2 = new Recipient(find2);
  50.     Recipient[] recipients = {recipient};
  51.     Recipient[] recipients2 = {recipient2};
  52.     //2、传入组
  53.     TCComponentGroupType group = (TCComponentGroupType)session.getTypeComponent("Group");
  54.     TCComponent[] extent = group.extent();
  55.     TCComponentGroup find3 = group.find("dba");
  56.     TCComponentGroup find4 = group.find("test.dba");
  57.     Recipient recipient3 = new Recipient(find3);
  58.     Recipient recipient4 = new Recipient(find4);
  59.     Recipient[] recipients3 = {recipient3};
  60.     Recipient[] recipients4 = {recipient4};
  61.     String subject = "主题234";
  62.     String message = "邮件";
  63.     TCComponentEnvelope envelope = null;
  64.     NewEnvelopeOperation newEnvelopeOperation = new NewEnvelopeOperation(session, null, recipients3, recipients4, subject, message, attachmentList, 0, envelope);
  65.     session.queueOperation(newEnvelopeOperation);
  66. }

16、获取应用ID

  1. /**获取应用ID*/
  2. public void getAppId() {
  3.     String applicationId = AIFDesktop.getActiveDesktop().getDesktopManager().getCurrentDesktop().getCurrentApplication() .getApplicationId();
  4.     System.out.println(applicationId);
  5. }

17、调用外部dll文件的方法

  1. /**调用外部dll文件的方法
  2. * @throws TCException */
  3. public void callExternalDLLFileMethod() throws TCException {
  4.     TCUserService userService = session.getUserService();
  5.     InterfaceAIFComponent targetComponent = application.getTargetComponent();
  6.     TCComponent tcComponent = (TCComponent) targetComponent;
  7.     userService.call("AssignZZItem", new Object[] { tcComponent });
  8. }

18、显示Home

  1. /**显示Home
  2. * @throws TCException */
  3. public void showHomeView() throws TCException {
  4.     TCComponentFolder homeFolder = session.getUser().getHomeFolder();
  5.     final Display display = Display.getDefault();
  6.     AIFDesktop aifdesktop = AIFUtility.getActiveDesktop();
  7.     Shell shell = aifdesktop.getShell();
  8.     final Shell shell = new Shell();
  9.     shell.setSize(500, 575);
  10.     shell.setText("Home树结构");
  11.     //树结构
  12.     TreeViewer treeviewer = new TreeViewer(shell, SWT.BORDER|SWT.H_SCROLL);
  13.     //带复选框的树结构
  14.     //ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(shell, SWT.BORDER|SWT.H_SCROLL);
  15.     treeviewer.setLabelProvider(new TCComponentLabelProvider());
  16.     treeviewer.setContentProvider(new TCComponentContentProvider());
  17.     treeviewer.setInput(new ComponentRootNode(homeFolder));
  18.     treeviewer.expandToLevel(2);
  19.     shell.open();
  20.     shell.setLayout(new FillLayout());
  21.     shell.layout();
  22.     while (!shell.isDisposed()) {
  23.         if (!display.readAndDispatch())
  24.          display.sleep();
  25.     }
  26. }

19、调用查询构建器

  1. /**
  2. * 调用查询构建器
  3. *
  4. * @param findName:查询值,如查询5开头的零组件则findName=5*
  5. * @param findValue:查询条件真实名称,如object_name
  6. * @param name:查询名称,如"数据集名称"
  7. * @author huyanling
  8. */
  9. public TCComponent[] findData(String[] findName, String[] findValue, String name) {
  10.     try {
  11.         if (findName.length > findValue.length) {
  12.             MessageBox.post("查询条件与查询值不对应,请检查!", "提示", 2);
  13.             return null;
  14.         }
  15.         TCComponentQueryType typeComponent = (TCComponentQueryType) session.getTypeComponent("ImanQuery");
  16.         TCComponentQuery find = (TCComponentQuery) typeComponent.find(name);
  17.         if (find == null) {
  18.             MessageBox.post("TC中没有【" + name + "】这个查询,请定义该查询后使用!", "提示", 2);
  19.             return null;
  20.         }
  21.         TCQueryClause[] describe = find.describe();
  22.         String[] strings = new String[findValue.length];
  23.         String[] value = findName;
  24.         for (int v = 0; v < findValue.length; v++) {
  25.          strings[v] = describe[v].getUserEntryNameDisplay();
  26.         }
  27.         TCComponent[] execute = find.execute(strings, value);
  28.         if (execute.length > 0) {
  29.          return execute;
  30.         } else {
  31.          return execute;
  32.         }
  33.     } catch (TCException e) {
  34.         e.printStackTrace();
  35.     }
  36.     return null;
  37. }

20、获取当前应用程序对象

  1. //1
  2. AbstractAIFUIApplication application = AIFUtility.getCurrentApplication();
  3. //2
  4. AbstractAIFUIApplication application = AIFDesktop.getActiveDesktop().getCurrentApplication();

21、获取对象属性的LOV

  1. /**获取对象属性的LOV*/
  2. public String[] getLOVByItemType(TCComponent find,String PROPERNAME) throws TCException {
  3.     TCProperty tcProperty = find.getTCProperty(PROPERNAME);
  4.     TCComponentListOfValues lov = tcProperty.getLOV();
  5.     ListOfValuesInfo listOfValues = lov.getListOfValues();
  6.     Object[] listOfValues2 = listOfValues.getListOfValues();//LOV
  7.     String[] lovDisplayValues = listOfValues.getLOVDisplayValues();//LOV本地化值
  8.     return lovDisplayValues;
  9. }

22、获取session服务

  1. //1)第一种方式
  2. ISessionService sessionService = AifrcpPlugin.getSessionService();
  3. TCSession session = (TCSession)sessionService.getSession("com.teamcenter.rac.kernel.TCSession");
  4. //2)第二种方式
  5. AbstractAIFUIApplication application = AIFUtility.getCurrentApplication();
  6. TCSession session = (TCSession)application.getSession();
  7. //3)第三种方式
  8. TCSession session =(TCSession)AIFUtility.getDefaultSession();

23、打开一个或多个对象

  1. //1
  2. NavigatorOpenService navigatorOpenService = new NavigatorOpenService();
  3. navigatorOpenService.open(aifComponent);
  4. //2
  5. AifrcpPlugin.getDefault().openComponents("com.teamcenter.rac.ui.perspectives.navigatorPerspective",new InterfaceAIFComponent[] {aifComponent});
  6. //3
  7. ComponentOpenHelper componentOpenHelper = new ComponentOpenHelper(AifrcpPlugin.getDefault());
  8. componentOpenHelper.openComponents(s, new InterfaceAIFComponent[] {aifComponent});
  9. //4
  10. SearchOpenService searchOpenService = new SearchOpenService();
  11. InterfaceAIFComponent targetComponent = application.getTargetComponent();
  12. searchOpenService.open(targetComponent);
  13. //5
  14. AIFDesktop desktop = AIFDesktop.getActiveDesktop().getDesktopManager().getActiveDesktop();
  15. InterfaceAIFComponent[] targetComponent = application.getTargetComponents();
  16. OpenCommand openCommand = new OpenCommand(desktop, targetComponent);
  17. openCommand.executeModal();

九、获取对象

1、获取对象类型对象

TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(itemType);

2、获取对象版本类型对象

  1. String s2 = typeComponent.getRevisionTypeName(itemType);
  2. tccomponentitemrevisiontype = (TCComponentItemRevisionType) session.getTypeComponent(s2);

3、获取属性对象

TCPropertyDescriptor tcpropertydescriptor = typeComponent.getPropertyDescriptor(properName);

4、获取LOV对象

1、获取所有值列表

  1. TCComponentListOfValuesType ListOfValues = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues");
  2. TCComponent[] extent1 = ListOfValues.extent();

2、获取动态值列表

  1. TCComponentListOfValuesType Dynamic = (TCComponentListOfValuesType) session.getTypeComponent("Fnd0ListOfValuesDynamic");
  2. TCComponent[] extent2 = Dynamic.extent();

3、获取字符型值列表

  1. TCComponentListOfValuesType Char = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesChar");
  2. TCComponent[] extent3 = Char.extent();

4、获取日期值型值列表

  1. TCComponentListOfValuesType Date = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesDate");
  2. TCComponent[] extent4 = Date.extent();

5、获取双精度数值型值列表

  1. TCComponentListOfValuesType Double = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesDouble");
  2. TCComponent[] extent5 = Double.extent();

6、获取过滤器型值列表

  1. TCComponentListOfValuesType Filter = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesFilter");
  2. TCComponent[] extent6 = Filter.extent();

7、获取数值型值列表

  1. TCComponentListOfValuesType Integer = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesInteger");
  2. TCComponent[] extent7 = Integer.extent();

8、获取字符串型值列表

  1. TCComponentListOfValuesType String = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesString");
  2. TCComponent[] extent8 = String.extent();

9、获取标记值列表

  1. TCComponentListOfValuesType Tag = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValuesTag");
  2. TCComponent[] extent9 = Tag.extent();

10、获取属性的值列表

  1. TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent(itemType);
  2. TCPropertyDescriptor tcpropertydescriptor = typeComponent.getPropertyDescriptor(properName);
  3. TCComponentListOfValues lov = tcpropertydescriptor.getLOV();

5、命名规则对象

  1. String as[] = { "item_id", "item_revision_id" };
  2. String as1[] = { ITEMTYPE, ITEMTYPE};
  3. //获取命名规则列表,包括itemitemRevision的命名规则
  4. NamingRule anamingrule[] = NamingRulesHelper.getInstance().getNamingRules(session, as1, as);
  5. String as2[] = anamingrule[0].getPatterns();//item命名规则
  6. String as3[] = anamingrule[1].getPatterns();//itemRevision命名规则

6、系统中所有度量单位对象

  1. TCComponentUnitOfMeasureType localTCComponentUnitOfMeasureType = (TCComponentUnitOfMeasureType)session.getTypeComponent("UnitOfMeasure");
  2. TCComponent[] arrayOfTCComponents = localTCComponentUnitOfMeasureType.extent();

7、系统中所有用户对象

  1. TCComponentUserType user = (TCComponentUserType)session.getTypeComponent("User");
  2. TCComponent[] extent = user.extent();

8、系统中所有发布状态对象

  1. TCComponentStatusTypeType status = (TCComponentStatusTypeType)session.getTypeComponent("TaskType");
  2. TCComponent[] extent = status.extent();

9、系统中所有组对象

  1. TCComponentGroupType group = (TCComponentGroupType)session.getTypeComponent("Group");
  2. TCComponent[] extent = group.extent();

10、当前用户所有的工作流程对象

TCComponentProcessType procesType = (TCComponentProcessType) session.getTypeComponent("Job");

11、所有工作流程模板对象

TCComponentTaskTemplateType TaskTemplateT = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate");

12、系统中所有的分类对象

  1. TCComponentICOType icoType = (TCComponentICOType) session.getTypeComponent("icm0");
  2. TCComponent[] ico = icoType.extent();

13、系统中所有工具

  1. TCComponentToolType toolType = (TCComponentToolType) session.getTypeComponent("Tool");
  2. TCComponent[] extent = toolType.extent();

14、系统中所有项目

  1. TCComponentProjectType projectType = (TCComponentProjectType) session.getTypeComponent("TC_Project");
  2. TCComponent[] projects = projectType.extent();

15、系统中所有注释类型列表

  1. TCComponentNoteTypeType noteTypeType = (TCComponentNoteTypeType) session.getTypeComponent("NoteType");
  2. TCComponent[] noteTypes = noteTypeType.extent();

16、系统中所有视图类型列表

  1. TCComponentViewTypeType viewTypeType = (TCComponentViewTypeType) session.getTypeComponent("PSViewType");
  2. TCComponent[] viewTypes = viewTypeType.extent();

17、系统中所有事件类型

  1. TCComponentEventType eventType = (TCComponentEventType) session.getTypeComponent("ImanEventType");
  2. TCComponent[] events = eventType.extent();
  3. //根据零件获取零件对应版本
  4. TCComponentItem item = (TCComponentItem) targetComponent;
  5. //1Item发布的版本
  6. TCComponentItemRevision[] releasedItemRevisions = item.getReleasedItemRevisions();
  7. //2Item工作中的版本
  8. TCComponentItemRevision[] workingItemRevisions = item.getWorkingItemRevisions();
  9. //3Item流程中的版本
  10. TCComponentItemRevision[] inProcessItemRevisions = item.getInProcessItemRevisions();

十、获取属性

1、根据引用属性获取引用属性所属对象

  1. /**根据引用属性获取引用属性所属对象(当属性值不为数组时使用)
  2. * 例:查询选中item对象的所有权项目
  3. * @param property:属性名称 ;例:(owning_project
  4. * @param tcComponent:当前对象;(TCComponentItem
  5. * @return TCComponent:引用对象
  6. * @throws TCException
  7. * */
  8. public TCComponent getReferenceTCComponent(String property,TCComponent tcComponent) throws TCException {
  9.     TCComponent referenceProperty = tcComponent.getReferenceProperty(property);
  10.     return tcComponent;
  11. }

2、根据引用属性获取引用属性所属对象

  1. /**根据引用属性获取引用属性所属对象(当属性值为数组时使用)
  2. * 例:查询选中item对象的项目列表
  3. * @param property:属性名称 ;例:(project_list
  4. * @param tcComponent:当前对象;(TCComponentItem
  5. * @return TCComponent[]:引用对象列表(选中零件的项目列表)
  6. * @throws TCException
  7. * */
  8. public TCComponent[] getReferenceTCComponents(String property,TCComponent tcComponent) throws TCException {
  9.     //1、直接获取
  10.     TCComponent[] referenceListProperty = tcComponent.getReferenceListProperty(property);
  11.     //2、根据属性获取
  12.     TCProperty tcProperty = tcComponent.getTCProperty(property);
  13.     TCComponent[] referenceValues = TCProperty.getReferenceValues(new TCProperty[]{tcProperty});
  14.     return referenceValues;
  15. }

十一、BMIDE中的扩展对象类型

1、获取系统中的用户

  1. /**获取系统中的用户*/
  2. public List<String> getUserList() throws TCException {
  3.     TCComponentUserType user = (TCComponentUserType)session.getTypeComponent("User");
  4.     TCComponent[] extent = user.extent();
  5.     List<String> resultList = new ArrayList<String>(extent.length);
  6.     resultList.add("");
  7.     for(TCComponent tc:extent) {
  8.         if (tc instanceof TCComponentUser) {
  9.             TCComponentUser user1 = (TCComponentUser) tc;
  10.             resultList.add(user1.toString());
  11.             //resultList.add(user1.getUserId());
  12.         }
  13.     }
  14.     return resultList;
  15. }

2、获取系统中的组

  1. /**获取系统中的组*/
  2. public List<String> getGroupList() throws TCException {
  3.     TCComponentGroupType group = (TCComponentGroupType)session.getTypeComponent("Group");
  4.     TCComponent[] extent = group.extent();
  5.     List<String> resultList = new ArrayList<String>(extent.length);
  6.     resultList.add("");
  7.     for(TCComponent tc:extent) {
  8.         resultList.add(tc.toString());
  9.     }
  10.     return resultList;
  11. }

3、获取系统中的发布状态

  1. /**获取系统中的发布状态*/
  2. public List<String> getStatusList() throws TCException {
  3.     TCComponentStatusTypeType status = (TCComponentStatusTypeType)session.getTypeComponent("TaskType");
  4.     TCComponent[] extent = status.extent();
  5.     List<String> resultList = new ArrayList<String>(extent.length);
  6.     resultList.add("");
  7.     for(TCComponent tc:extent) {
  8.         resultList.add(tc.toString());
  9.     }
  10.     return resultList;
  11. }

Teamcenter 11-AWC是一款非常流行的管理软件,用于帮助企业集中管理其产品生命周期的各个阶段。下面是有关Teamcenter 11-AWC安装和使用方面的解释。 首先,安装Teamcenter 11-AWC需要按照特定的步骤进行操作。您需要下载官方网站上的安装程序,然后按照安装指南中的说明进行安装。在安装过程中,您需要选择合适的组件,以满足您的需求。安装完成后,您可以根据需要进行配置和自定义,以确保软件能够适应您的工作环境和团队的需求。 一旦安装完成,您就可以开始使用Teamcenter 11-AWC。使用该软件,您可以通过一个中央数据库来管理各个项目的所有文档和信息。您可以创建和管理项目、任务和工作流程,以及设置权限和角色,以便只有授权的人员可以访问特定的信息。您还可以使用该软件来跟踪项目的进度和完成情况,并与团队成员进行协作和沟通。 除此之外,Teamcenter 11-AWC还提供了一些高级功能,例如版本控制、变更管理和供应链集成等。这些功能可以帮助您确保产品的质量和合规性,提高团队的工作效率,并与外部供应商和合作伙伴进行无缝协作。 总的来说,Teamcenter 11-AWC是一款功能强大且易于使用的管理软件,可以帮助企业有效管理产品生命周期。只要按照正确的步骤进行安装和配置,并了解各个功能的使用方法,您就可以充分发挥软件的优势,提高工作效率,并实现更好的团队协作。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Mr_GGI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值