【无标题】

  • Teamcenter笔记
  • Teamcenter笔记

    概述

    Teamcenter的标准功能基本可以供用户使用,但是基于每家公司业务问题以及使用习惯,还有一些特殊的应用与数据整合,所以会产生不同的业务需求,这个时候我们就需要通过客户化定制的方式去满足用户的应用。通过对TC系统的二次开发来实现客户化。

    客户端定制

    • 通过个性化定制让用户操作更加方便,提高用户的操作效率。比如一些对话框、操作界面等的定制,数据显示与表单定制,可以对系统中对象图标的显示、表单界面进行具体的定制与开发。

  • 数据显示与表单定制:可以对系统中对象图标的显示、表单界面进行具体的定制与开发。

  • 服务端定制

    • 应用集成:

    使用集成工具包(ITK)或服务(Teamcenter Service)进行定制,改变Teamcenter与外部应用集成时行为(behavior)。比如前处理,后处理,SOA接口,ITK函数,Handler等。

  • 数据共享

  • 通过定制开发可以使Teamcenter系统中的一些数据与别的系统共享,或者Teamcenter共享别的系统中数据,比较典型的有报表、CAD集成ERP集成、CAPP集成等。

    第一章

    1)查看\设置 TC命令行

    set TC_ROOT=D:\Siemens\Teamcenter10
    
    set TC_Data=D:\Siemens\tcdata
    
    call  D:\Siemens\tcdata\tc_profilevars.bat 
    

    2)运行TC命令:

    (1)清除TC死进程   clearlocks -verbose
    
    (2)列出所有登录到TC的用户 list_users –u=infodba –p=infodba
    
    (3)获取TC版本信息  install -ask_version
    
    (4)导出某个Item到本地文件夹中 tcxml_export -u=infodba -p=infodba -file=D:\output.xml -item=000034 -rev=A -floder=Home
    
    (5)文件卷信息备份   backup_xmlinfo -u=infodba -p=infodba -g=dba
    

    3)查看TC环境变量 : set TC

    实践练习2:

    1)运行TC命令:

    (1)导出原始或旧的CAD属性映射文件 export_attr_mappings -u=infodba -p=infodba -g=dba -file=D:\attr.txt

    (2)导入原始或旧的CAD属性映射文件 import_attr_mappings -u=infodba -p=infodba -g=dba -file=D:\attr.txt

    实践练习3:

    1)运行TC命令:

    (1)游离数据收集命令: collect_garbage -u=infodba -p=infodba -g=dba -item -dataset -floder -report

    (2)删除WASTE BASKET文件夹下所有没有引用的对象 collect_garbage -u=infodba -p=infodba -g=dba -all –delete

    第二章

    2.1对象模型和系统框架

    Item和Item Revision模型
    1. POM
  • Item

  • |tem Revision

  • 动态类型

  • Relation

  • 属性及属性分类

  • Teamcenter对象模型由管理数据的类组成 模型可描述成两个基本关系集图

    • 继承关系
    • 关联关系

    对象模型原理

    • Item and Item Revision Model
    • Dataset Model
    • Form Model
    • System Administration Model
    • Product structure object Model
    • Access control Model
    • Application encapsulation M lodel
    POM

    persistent Object Manager

    POM是Teamcenter的核心模块,是应用模块与系统模块的接口,是一个提供内部程序员、第三方以及客户定义他们自己业务对象(business object) 的工具。

    • 系统模块通常是用0DBC访问0racle关系数据库或MS SQL Server

  • POM提供应用程序与系统模块比关系数据库表更高层次的抽象(如创建文件夹),可以创建、存取他们自己的数据以及存取简单的TC数据

  • 可以通过BMIDE (Bus iness Modeler IDE) 创建业务对象,而不是直接编辑表或写代码,提供了数据的面向对象浏览器,而不是SQL 表达式。

  • Item

    Item是TC中管理信息的最基本的对象,提供了用于组织信息、审计/变更控制的物理或概念上的实体。表示真实世界中的一个产品、部件或零件对象等,例如发动机总成、支架等。

    ltem有以下基本信息:

    • Item ID (必须唯一,可以是流水码)
    • |tem Name
  • Item type

  • Unitof Measure (Optional) 。

  • Description

  • 最多240个字符

  • 其中Bus inessOb ject是所有类的基类,再往下是两个分支:

    • POM_ object带有存储类的业务类
    • Runt imeBusinessOb ect动态类型

    Item类型是选择客户化继承类的首选基类。在Item这个视图下,有:存储类、父类、版本类、表单这四项。这里主要解释的是存储类。规则为:每个业务对象,都有一个存储类与之对应。另外同时注意:不同的业务对象可以共同对应于一个存储类。

    Item Revision

    Item Revision用于记录Item的历史 |tem Revision信息

    • ID
    • Item的唯一 标识
  • Revision
  • Name .
  • 动态类型

    例如: BOML ine它实际是从种存储类.上获取属性从而计算得到的。其中包括PSOccur rence,Note,Item,ItemRev等等 属性可以加载到结构管理器。

    Relations

    TC用Re | at i on来关联数据的Item和Item Revision

    ReIation描述了数据是怎样与Item和Ite Revision关联的

    例:一个Dataset包含了CAD模型,这个模型由某个ItemRevisi on说明 例:一个标准文档描述了一个Item所需要特定草图的填充表单和功能

    Item和ltem Revis ion可以与其他一些对象有关,包括Datasets,Forms, Fo Iders以及其他的Item和Item Revision .

    每个与Item关联的对象表示了该ltem的各个方面信息

    TC提供了基本的关系集,对象与Item、Item Revision之间的关系取决于所执行的规则

    • master_ Form
    • 关联Form与Item或Item Revision
    • Form是Item或Item Revis ion的属性(Attr ibutes) 集合
    • 关系规则
    • Item或Item Revis ion必须要有对Form添加、删除master_ Form关系的权限
    • 一个Form与一个Item或Item Revision只能有一个master_ Form关系
    • 一个Form的master_ Form关系只能对应一个Item或Item Revision

    TC提供了基本的关系集,对象与ltem、Item Revision之间的关系取决于所执行的规则

    • requirement

    • 关联data与Item或Item Revision (如:草图的标准、Part的技术需求)

  • 关系规则

    • Item或Item Revis ion必须要有对一个对象添加、删除requirement关系的权限

  • Form与Item或Item Revis ion可以有一个requi rement关系

  • 只有Dataset的0版本可以与Item或Item Revis i on有requi rement关系

  • Folder、 enve | ope、 BOM vi ew或BOM Revis i on不能与Item或ItemRevision有requirement关系

  • 一个Item不能另外的Item或Item Revis ion有requi rement关系

  • 一个Item Revis i on可以与另外的Item或Item Revis ion有requirement关系

  • 一个Item Revision不能与另外的同- -个Item的Item Revision有requi rement关系

  • manifestation关联与Item或Item Revis ion相关其他数据

  • specification关联定义Item Revis ion的数据

  • reference关联数据与Item或Item Revision

  • Revision关联Item Revis ion与相应的Item

  • BOMView关联产品结构与Item

  • BOMView Revision关联产品结构Revision与Item Revision

  • 修改Item/Item Recision
    • 当Item被创建时就有了ID 只有对Item添加了数据,Item才有意义

  • 数据集(Dataset)用于其他应用中创建的信息,这些数据可以与Item和Item Revision关联

  • 在TC中,ItemRevision和Datasetversion都可以表示修改信息

    • Item Revis ion表示Item的明显变化
    • Dataset vers ion表示每天的变化
  • 修改Item、 Item Revis i on的方法

    • 通过cut、paste方法添加或移除Item与Item Revision的关系
    • 修改与Item和ItemRevision相关的对象的内容
    属性及属性分类
    • 类定义了对象的类型(type of object) 、属性(Attr ibutes)和方法(methods)
    • 在TC中,Attr ibute可以是: Integer, Float,Boolean, String,Date,Tag,Array
    • Tag唯一标识Reference和Relation
    • Attribute具有以下特性:
    • Unique
    • Protected:属性只能由创建该对象的应用修改
    • NULLallowed:如果这个特性不为true的话,对象不能保存
    • Upper bound (.上边界)
    • Lower bound (下边界)
    • Default value (默认值)

    永久

    该类型的属性会在数据库中对应一条记录上的一个字段,从而得以保存

    运行时

    一顾名思义,只是运行时动态的属性,需要配合程序计算获得。

    复合

    复合属性,如不清楚可以 查看BMI DE使用帮助

    关系

    从TC8开始关系首先需要定义为属性。 TC2007是不需要的,只用首选项配置。

    其他对象模型

    Dataset Model

    每个产品对象均有一些具体的数据文件来描述其不同方面的详细信息,如设计模型、计算说明、设计要求等。这些数据文件是由不同的应用软件产生的( 如CAD软件、0ffice软件等),具有不同的表现形式(如Text文件、图形文件等)。

    Teamcenter的Dataset (数据集)提供了管理各类应用软件所产生的文件的手段。不管是技术说明文件或CAD / CAM / CAE系统产生的图形数据文件,都可以用原来的形式或点阵形式或其它任何计算机形式的文件存放在Teamcenter系统中。

    Dataset是用来管理(存放)应用软件生成的数据(文件)的-种对象。对应于不同类型(格式)的数据(文件),Teamcenter 提供Dataset Type与之对应。

    业务对象是用于详细说明TC对象的行为的

    Dataset业务对象用于对Dataset分类

    例:当Document Dataset数据打开时, 与该对象关联的WORD处理程序打开

    当创建数据集时,会创建0和1两个版本,Revision 0总是指向最新的版本,所以最初时它指向Revision 1。如果创建了Revision 2,Revision 0就指向2。在编程时,如果希望获得最新的版本,就用Revision 0。

    所有Dataset的版本都有相同的所有者(owning user)、组(group) 和保护(protect ion)机制。

    ITK functions use this convention with R evisions asfollows:

    AE_ask_dataset
    

    Given any dataset, returns Revision 0.

    AE_ask_dataset_first_rev
    

    Given any dataset, returns the oldest Revision.

    AE_ask_dataset_latest_rev
    

    Given any dataset, returns the most recent Revision (nothe Revision 0 copy).

    Given any dataset, returns the most recent evision (nothe Revision 0 copy).

    AE_ask_dataset_next_rev
    

    Given any dataset, returns the next Revision 1n the sequence.

    AE_ask_dataset_prev_rev
    

    Given any dataset, returns the previous Revision in the sequence

    AE_find_dataset ("name", &Dataset)
    

    Finds Revision 0 of the Dataset.

    AOM_refresh(dataset, true)
    

    Loads the given Dataset version for modification.

    AOM_ save (dataset)
    

    Creates a new, later version of the Dataset and saves a copy to Revision 0.

    Form Model

    Form能存储用户定义的属性(Attr ibute), TC提供了标准Form模型。Form是POM对象,可以使用Form |TK函数存取Attr ibute

    所有的POM_ appl icat ion_ _ob ject类和它的子类都有所有者和保护机制,只能被系统管理员修改

    ACL (Access control | ist)实体由对组和/或用户以及子对象授权的引用组成。

    子对象是TC中可以被授权的对象。

    Teamcenter软件系统版本历史如下:

    Teamcenter Enterprise 4.0

    Teamcenter Enterprise 5.0

    Teamcenter Engineering 9.0

    2005年: Teamcenter Engineering 2005

    2007年: Teamcenter 2007

    2009年:Teamcenter 8

    2012年: Teamcenter 9

    201 3年: Teamcenter10

    201 6年:Teamcenter11

    201 8年:Teamcenter1 2

    第三章

    3.1客户端开发技术

    Teamcenter 胖客户端基于客户端-服务器架构模式,客户端和服务器层均可以定制开发。胖客户端具有UI界面,使用Java语言进行构建与定制。服务器端使用Integration Toolkit (ITK) 和 C/C++ 编程语言进行开发。

    因为胖客户端基于Eclipse平台,开发时可以获取所有扩展点,作为Teamcenter 开发定制技术,可以使用如下三种方式定制客户端:

    Base Eclipse extension points and services (使用org.eclipse.ui.menus extension point).
    Teamcenter extension points and services (使用application extension points).
    Teamcenter customization mechanisms (使用style sheets).
    

    ​ 基础定制技术用于在客户端创建具有用户界面的插件,并加以显示,需要熟练掌握Eclipse。

    Teamcenter 提供几种界面,包括:

    • 胖客户端界面;

  • 基于Web的瘦客户端界面;

  • 业务建模器;

  • Teamcenter集成Microsoft Office;

  • Teamcenter集成CAX,ERP等

  • 因为胖客户端与瘦客户端接口开放了定制方法,仅提供此两种开发方式。

    随着Teamcenter软件的发展和进步,利用新技术,尽可能灵活和简单化Teamcenter扩展和定制的能力。

    • Back and Forward buttons
    • Application banner
    • Search box
    • Navigation pane
    • Application pane
    • Getting Started application button.
    • Primary applications
    • Secondary applications
    • Clipboard button
    3.11AWT & Java Swing

    Abstract Windows Toolkit(AWT)是最原始的、具有有限 GUI 组件、布局管理和函数功能的工具包。AWT的主要优点是,它在 Java 技术的每个版本上都成为了一种标准配置,包括早期的 Web 浏览器中的 Java 实现。另外它也非常稳定,可以在任何一个以Java为基础的环境中运行使用。

    AWT中包含了许多类和接口,用于Java Application的GUI编程。通过图形用户界面用户和程序之间可以方便地进行交互。

    ava的抽象窗口工具包AWT由Java的java.awt包提供,该包中有许多用来设计GUI的组件类,如:按钮、菜单、列表、文本框等组件类,同事它还包含窗口、面板等容器类。

    ava Swing是Java Foundation Classes(JFC)的一部分,它是在 AWT 组件基础上构建的,所有 Swing组件实际上也是 AWT 的一部分。在Swing 中,Sun 开发了一个经过仔细设计的、灵活而强大的 GUI工具包。

    Swing 具有内嵌于Java 技术的优点,可完全移植的。Swing 也具有高级图形应用程序所需要的优点。SWT 具有可以作为本地应用程序实现的优点,这可以提高性能,并利用基于SWT 的GUI 来实现本地兼容性。

    在SWT之前,Sun已经提供了跨平台GUI开发工具包AWT。AWT框架底层使用原生窗口部件(native widgets)构建,只能使用各个平台窗口部件的子集。在大部分情况中,都是使用Swing与结合了JFace的SWT一起构建GUI。

    在SWT之前,Sun已经提供了跨平台GUI开发工具包AWT。AWT框架底层使用原生窗口部件(native widgets)构建,只能使用各个平台窗口部件的子集。在大部分情况中,都是使用Swing 与结合了JFace 的SWT 一起构建GUI。 Standard Widget Toolkit (SWT),即标准部件工具包。它是一个Java平台下开放源码的Native GUI组件库,也是Eclipse平台的UI组件之一。如果只为一种平台来开发系统,那么SWT 就具有主机兼容性方面的优点,包括与主机特性的集成,例如在Windows 上对ActiveX控件的使用。 Teamcenter2007以上都是采用SWT与Swing结合进行客户端构建的。

    与 AWT 的概念相比,SWT 是一个低级的 GUI 工具包。JFace是一组用来简化使用SWT构建GUI的增强组件和工具服务。SWT的创建者为了建立一个只有两者的有点而没有缺点的系统,从AWT和Swing的实践中吸取了大量的经验。从很多方面来说,他们已经成功了。SWT 的 GUI 既具有主机外观,又具有主机的性能。这样就避免了使用 AWT 和 Swing 而引起的大部分问题。特定的主机具有一些低级功能控件,因此 SWT 提供了扩充版本,从而可以产生更一致的行为。

    RCP的概念

    ​ RCP是Rich Client Platform的缩写,利用Eclipse核心平台和一些有用的插件,进行应用系统的构建。只要新的代码符合插件的代码结构,将代码放入工作空间后,Eclipse平台会自动加载新代码,构成新的Eclipse平台。

    ​ Eclipse RCP 提供了标准化的组件模型,包括菜单,工具栏,以及可叠加的窗口组件(编辑器和视图)、按钮、表格、树形结构的支持。

    Eclipse RCP的优点

    • 组件化:基于Eclipse的系统设计由被称为plug-ins的插件构成,可以通过扩展点进行配置,也可以被不同应用程序共享。

  • 便利性:Eclipse RCP对各个平台下的产品包装提供了强有力的支持,其开发的RCP甚至可以在嵌入式设备、掌上电脑上运行。Sun公司对Java的口号是“write once,run everywhere”,Eclipse也可以说是“RCP run everywhere”。

  • 智能安装和升级:Eclipse提供了专门的Update组件,可以实现通过HTTP、Web站点、复制等多种方式进行安装和更新,避免了早期胖客户端应用、部署升级的麻烦。

  • 可扩展性:Eclipse基于插件进行扩展的思想使得用户可以方便地搭建各种规模、类型和用途的应用程序。按照Eclipse官方的说法,Eclipse RCP一开始就被设计为可扩展的。

  • 使用体验:Eclipse为各种操作系统提供了本地图形接口包。当RCP运行时,Eclipse首先直接调用本机窗口组件,只有没有本机所需组件时才进行模拟。无论RCP在哪种操作系统上运行,都可以保持与本机一致的外观和行为。一个设计优良的富客户端,可以提供诸如拖曳操作、剪切板、导航等 UI元素。UI设计者也可以利用各种界面工具,轻松设计出完美的用户界面。

  • image-20200317163944826

    CP中的每个视图都对应程序中的UI界面。每个透视图对应一个应用组合,如在Teamcenter中 :我的Teamcenter、结构管理器、分类管理等。下图是以Teamcenter系统为例展示RCP应用程序运行的界面:

    image-20200317164014013

    透视图 perspective

    一个客户端可以运行多个透视图,但每次在界面中只显示一个透视图;在一个透视图中可以添加和重新排列视图,以在透视图中同时显示多个信息集;可以保存重排的透视图,并使用当前名字,也可以为新的排列创建一个新名字。系统管理员可以使用 HiddenPerspectives 首选项来显示/隐藏各个透视图功能。

    视图 View

    视图中相关工作改变通常会对其他视图中的选项更改;视图中数据的更改会立即保存;视图在透视图中可以便捷的加载,当前透视图中的视图排列可以存储到本透视图,或者新创建的透视图中。

    3.2Teamcenter插件开发

    Eclipse的设计思想是:一切皆插件。Eclipse核心很小,其它所有功能都以插件的形式附加于Eclipse核心之上。Eclipse基 本内核包括:图形API (SWT/Jface),Java开 发环境插件(JDT ),插件开发环境(PDE), JDT与PDE构成了Platform run-time。 Teamcenter胖客户端宿主于Eclipse胖客户端平台框架。RCP是一个通用的应用程序框架,通过使用插件,提供了模块化和基于可扩展的组件开发的支持。

    PDE和Java Deve lopment Tooling (JDT) IDE 是Eclipse的标准扩展。PDE提供了一些向导以帮助创建插件。 Workbench和Workspace是 Eclipse平台的两个必备的插件它们.

    提供了大多数插件使用的扩展点。插件需要添加到扩展点才可以运行。Workbench组件包含了一些扩展点,允许插件扩展Eclipse 用户界面,使这些用户界面带有菜单选择和工具栏按钮;请求不同类型事件的通知;以及创 建新视图。Workspace 组件包含了可以与资源(包括项目和文件)交互的扩展点。

    除了Workbench和Workspace,其它插件也可以扩展Eclipse组件。Debug组件可以让插件启动程序、与正在运行的程序交互,以及处理错误Team组件允许Eclipse 资源与版本控制系统(VCS) 交互,构建VCS的Eclipse客户机时,Team 组件就象Debug组件一样,会扩展或增强Eclipse的功能。Help组件可以提供应用程序的联机文档和与上下文的帮助。

    一个插件(p lug- in)是Ec lipse平台中的最小功能单元,可以进行独立的开发和发布。

    插件是用Java编写的。插件由以下内容组成:

    • JAR中的Java代码
    • 一些只读文件和其它资源(例如图片、web模板、消息资源文件、本地类库等)。
  • 一个插件清单,用于声明它与其它插件之间的连接关系,一个插件的清单由几个文件表示:

    • manifest,mf文件是一个OSGI bundle清单, 它描述了插件间运行时的依赖关系;
    • plugin.xml是一 -个XML文件,它描述了扩展和扩展点的信息

    插件目录

    标签的结解释,各个标签页的作用

    扩展与扩展点

    Plugin. xmI中扩展点(extens ion point) 解释

    • org.eclipse.ui.perspectives:定义新透视图。
    • org.eclipse. ui.views ::为工作台定义额外的视图。
    • org.eclipse.ui.commands:命令定义,定义命令、命令目录以及默认快捷键。
    • org.eclipse.ui.perspectiveExtensions :扩展其他插件定义的透视图。允许添加菜单、工具栏项目、快捷键、视图等等。
    • org.eclipse.ui.menus :将命令与界面菜单或工具栏绑定。确定菜单创建的区域。用来对菜单进行扩展,可以对主菜单,工具栏,上下文菜单进行扩展。
    • org.eclipse.ui.handlers:命令实现,(command的具体行为,定义command对应的c lass。
    • org. eclipse. ui. command Images: comand的图片。

    注册程序在Rich Client中起着至关重要的作用,注册程序使用属性文件定义应用程序的实现类( classes)、启动图标、本地化文本、搜索顺序和外观等。许多基本的客户化任务是用注册程序完成的,同时注册程序在Teamcenter 的程序组内增添程序入口,用于启动新开发的程序。不论是二次开发,还是Rich Client的原开发,都是通过这一注册机制来实现程序的调用。

    在进行TC客户化时主要的配置文件可以通过修改registry完成。例如修改aif. properties文件中的修改显示信息 flashScreen. ICON=images/FlashScreen. jpg执行%TC_ _ROOT%\portal \registry\genregxml. bat文件,如果修改了. properties文件需要执行此程序。执行这个文件的作用是,将所有jar包中的. properties文件中的配置信息写入到RegistryLoader. xml. gz文件及其多国语言文件中。Teamcenter中的Regisity类,从这些文件中预先读取配置信 息。

    也支持基本类型的注册,支持以下类型: color、 font、integer、float、 double、 char、 boolean、 string、 string array 和images。有些类型使用特殊的格式,如下所示:

    Color

    red, green, blue
    255,255,255
    

    Font

    font-name,. font-style,font-size
    "Times Roman, Font.ITALIC, 12”
    

    String array

    one,two,three
    

    快捷启动eclipse

    @echo off
    rem 
    
    setlocal
    
    title Teamcenter Rich Client
    
    set TC_JRE_HOME=C:\Program Files\Java\jdk1.8.0_201\jre
    set TPR=D:\Siemens\Teamcenter10\portal
    set FMS_HOME=D:\Siemens\Teamcenter10\tccs
    
    set PATH=%SYSTEMROOT%\system32;%FMS_HOME%\bin;%FMS_HOME%\lib;%TPR%;%AUX_PATH%
    
    set JAVA_HOME=%TC_JRE_HOME%
    set JRE_HOME=%TC_JRE_HOME%
    
    start "TAO ImR" /min cmd /c "D:\Siemens\Teamcenter10\iiopservers\start_imr.bat"
    
    start D:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_201\bin\javaw"
    
    对插件程序的注册方法: .
    1. 将jar格式的文件复制到TC的plugins文件夹中:D:\Siemens\Teamcenter 10\portal\plugins;
    2. 打开D:\Siemens\Teamcenter10\portal中 的register文件夹,浏览到注册文件程序genregxml.bat;
    3. 双击注册文件程序genregxml.bat,开始进行注册,等待注册文件程序genregxml.bat自动关闭;
    4. 清理TC缓存;C:\Users\Administrator\Teamcenter
    5. 打开TC,验证程序功能,查看注册文件。关于–>安装详细信息

    注册程序在Rich Client中起着至关重要的作用,注册程序使用属性文件定义应用程序的实现类( classes)、 启动图标、本地化文本、搜索顺序和外:观等。许多基本的客户化任务是用注册程序完成的,同时注册程序在Teamcenter的程序组内增添程序入口,用于启动新开发的程序。不论是二次开发,还是Rich Client的原开发,都是通过这一注册机制来实现程序的调用。.

    1)、将Jar文件com. newProcess. rac_ 1. 0. jar复制到TC Plugins文件夹;D:\Siemens\Teamcenter10\portal\plugins

    2)、修改genregxml.bat,start D:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_201\bin\javaw"

    3)、双击注册文件

    4)、清理TC缓存

    5)、打开TC验证程序功能

    3.3TC开发环境搭建

    配置tcEc lipse集成文件

    Teamcenter胖客户端本质是建立在Eclipse框架之上的应用程序,因此通过改造启动Teamcenter的启动脚本portal.bat,可以快速方便的构建一个可以直接启动Teamcenter的调试环境。

    1)、复制%TC_ ROOT%\portal\portal.bat

    2)、将脚本最后启动Teamcenter部分,修改为启动Eclipse程序。原始脚本:

    @echo Starting Teamcenter Rich Client. ···start Teamcenter.exe %* -vm "%JRE_ HOME%\bin\javaw.exe"
    -Vmargs -Xmx%VM XMX% -XX:MaxPermSize=128m -Xbootclasspath/a:"%JRE_ HOME%lib\plugin.jar";"%JRE_ HOME%\lib\deploy.jar";"%JRE_ HOME%\lib\javaws.jar"
    

    修改后脚本:

    @echo Starting Teamcenter Rich Client..start cmd /c "D: leclipseleclipse.exe" -vm "C:\ProgramFiles\Java\jdk1.8.0_ 201\bin\javaw"
    

    双击该脚本,启动Eclipse, 那么就具备了调试Teamcenter系统的基础环境。

    @echo off
    rem 
    
    setlocal
    
    rem TPR is short for TC_PORTAL_ROOT to reduce command line length
    title Teamcenter Rich Client
    
    call "D:\Siemens\Teamcenter10\install\tem_init.bat"
    
    set TPR=D:\Siemens\Teamcenter10\portal
    if not defined FMS_HOME set FMS_HOME=D:\Siemens\Teamcenter10\tccs
    
    rem use AUX_PATH env var for any additional required paths
    rem save original path for external applications
    set ORIGINAL_PATH=%PATH%
    rem for optimal startup performance, keep the PATH length at a minimum
    set PATH=%SYSTEMROOT%\system32;%FMS_HOME%\bin;%FMS_HOME%\lib;%TPR%;%AUX_PATH%
    
    set JAVA_HOME=%TC_JRE_HOME%
    set JRE_HOME=%TC_JRE_HOME%
    
    start "TAO ImR" /min cmd /c "D:\Siemens\Teamcenter10\iiopservers\start_imr.bat"
    
    :start_portal
    cd /d %TPR%
    set CLASSPATH=.;
    set VM_XMX=1024m
    rem Set DJIPJL_VMARG environment variable
    IF EXIST "%TPR%\DJIPJL\setenv.cmd" call "%TPR%\DJIPJL\setenv.cmd"
    
    @echo Starting Teamcenter Rich Client...
    
    start D:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.8.0_201\bin\javaw"
    

    i、配置Eclipse JRE的首选项

    1)、使用tcEclipse快捷方式启动Eclipse。 2)、单击菜单:窗口→首选项 3)、打开“安装JRE”窗口。自Preferences

    ii、添加JRE位置和系统库

    1)、单击添加。 2)、在Add JRE对话框中,选择Standard VM,然后单击下一步。 3)、单击目录…导航到JAVA_HOME,然后单击确定。 4)、等待作为Eclipse中填入的JRE系统库。 ii、更改Preference以使用新安装的JRE 1)、在Preferences对话框,请确认所安装的JRE被选中。 2)、取消选择默认安装的JRE。 3)、选择添加的jdk1.8.0 45的JRE。 4)、保持Preferences窗口打开。

    iii、设置Eclipse优先目标平台Teamcenter 由于当前针对Teamcenter平台使用Eclipse进行开发,因此需要将Eclipse开发平台设置为Teamcenter。 1)、单击菜单:窗口- >首选项。

    2)、双击Plug-in Development树将其展开,选择Target Platform。

    3)、在Target Platform对话框中,单击Add… ,打开“New Target Definition”窗口

    4)、初始化目标定义为: Nothing: Start with an empty target definition,点击下一步。

    5)、在位置选项卡上,单击“添加”,并使用目录选项,浏览到胖客户端位于:%TC_ ROOT%\portal。

    6)、单击Finish。 7)、更改名称: Tc10 Rich Client, 然后单击Finish。 8)、设置“TC10 Rich client”为激活状态。

    iiii、设置Teamcenter调试环境参数 1)、单击Run-→Run Configuration…. 2)、双击Eclipse Application。 3)、名称输入“Tc10.1 Rich Client”。

    4)、选择Arguments选项卡,在VM参数区域中,输入-Xms256m -Xmx1024m,设置JVM最大内存参数为1024m。 5)、保留值的其余部分保持不变。

    创建TC插件项目

    i、创建新项目

    (1)、单击文件- +新建→项目 (2)、从项目列表中选择Plug-in Project。 (3) 、单击下一步。

    ii、输入项目信息 (1)、对于项目名称,键入c9.mycustom (2)、清除源文件夹框。 (3)、保留值的其余部分保持不变。 (4)、单击下一步。

    iii、添加插件信息 (1)、在Plug-in Content对话框中,在Vendor框 中输入training Class。

    (2)、该值的其余部分应默认

    iiii、完成创建 (1)、选择创建检查插件使用的模板“hello, world command”。

    (2)、单击Finish。

    iiiii、检查调试配置项 (1)、单击Run-→Run Configuration….,查看各项参数设置。

    调试测试

    (1)单击Eclipse的运行菜单run,运行程序;

    调试测试

    (2)、在TC登录界面输入账号和密码,登录TC系统; (3)、单击TC中的菜单:帮助一->关于,弹出TC10的关于对话框; (4)、在“安装详细信息”中可以检索到自定义的插件。 (5)、在TC中可以查看程序功能。

    项目打包与部署

    (1)、单击文件“导出”,弹出到处对话框,选择“导出”,选择“Deployment plug-in and fragments” ;

    (2)、选择要导出的插件项目及路径,默认设置在%TC_ ROOT %/Portal文件夹中单击完成按钮,执行导出任务; (3)、在TC的插件文件夹中查看导出的插件包;

    (4)、执行插件包的注册; (5)、打开TC,从“安装详细信息”中检索插件包。

    配置反编译环境

    点击Eclipse中菜单windows- > preference。

    选中导航树上的Java >JadClipse

    编辑Path to decompiler,

    内容为刚刚下载的jadnet158.zip所解压缩后路径,如右图所示,路径是软件环境中的具体路径。

    设置Class文件默认查看器选中导航树上的General >Editors→File Associations,

    在右边列表里,选中*.class确保”JadClipse Class FileViewer”是默认(default)

    这样反编译工具JAD就和Eclipse集成到一-起了,只要在Eclipse中双击Class文件就能自动进行编译并显示源代 码。不过有时候反编译会不完全。

    3.4客户化开发常用接口

    com.teamcenter.rac.aifrcp

    Teamcenter基础客户化插件,在该插件中定义了主要的接口以及抽象类、出口类等,如:

    AbstractAIFApplication
    AbstractAIFSession
    AbstractAIFDialog
    AbstractAIFOperation
    AlFDesktop
    AIFPortal
    AbstractAI FA ction
    

    Teamcenter基础客户化插件,在该插件中定义了主要的接口以及抽象类、出口类等,如:

    AbstractAI FApplication
    

    用于创建Application Integration Frame(AIF )应用程序的基本AIFApplication类。该类包含AbstractAIFApplication的定义。它被用作所有AIF应用程序都要继承的基类。

    getSession()
    initialize(java.util.Map parameters)
    open(InterfaceAIFComponent[] components )
    refresh()
    

    Teamcenter基础客户化插件,在该插件中定义了主要的接口以及抽象类、出口类等,如:

    AbstractAIFSession
    

    这个类表示抽象的AIF会话对象,应用程序集成框架要求它的注册应用程序实现这个对象。子类包括TCSession。

    getUserName()
    login()
    refresh()
    
    com.teamcenter.rac .common

    Teamcenter的一- 些动作和菜单都在该插件包中进行了定义和注册,如菜单栏,工具栏,以及右键菜单等。一般的菜单动作都在com.teamcenter.rac.common.actions中进行了定义,如新建Item,Dataset, folder.

    1.在该包中建LNewltemAction类,并继承AbstractAIFAction类,实现public void run(方法。

    2.在action.properties文件中进行了注册,如下所示:

    File-> New -> Item

    newItemAction=com. teamcenter.rac.common. actions. NewItemAction
    newItemAction.ICON=images/newitem_ 1 6.png
    newItemAction.COMM AND=newItem( Command
    newItem Action.ACCELERATOR=ctrl pressed T
    newItemC ommand=com.teamcenter.rac.commands. newitem.N ewItemCommand
    

    3.相应的,在该插件中对应一一个com.teamcenter.rac.commands.newitem包,创建Item 的业务逻辑都在该包中进行了实现。

    com.teamcenter.rac.external

    Teamcenter插件中引用到的第三方类大部分都在该插件中进行了继承,可以说该插件为资源性插件

    com.teamcenter.rac .kernal

    对于客户端开发,都是基于Kernel API组件的,通过Kernel API,可以调用服务器端的功能,实际上Kernel API用 于Rich Client的ITK界面。进程(Session)对象是Kernel API的核心,通过-一个组件或者应用程序的getSession( )方法可以获取该对象的引用,AIFComponentManager是一个当前Session中所存组件的缓存器。二次开发工作所涉及的对象是:进程(Session)、 类型(Type)、服务( Service)、组件(Component),在做二次开发的时候,如果要从当前的组件转到其他的组件,一般通过Session来进行。

    Type组件存在于Teamcenter的每一类对象类型中,主要用来执行如:创建这样的任务,就面向对象来说,当一个对象还没有示例化的时候,无法调用其create方法,所以必须首先获得-一个指向Session的引用,这样即可从Session中获得Type组件。例如:创建-一个Folder的代码如下(假设当前已经获得了一个Session):

    TCComponentFolderType foldertype= (
    TCComponentFolderType).getTypeComponent("Folder");
    TCComponentFolder folder= foldertypecreate("Folder Name",
    "Folder Description", "Folder Type" ); .
    

    Kernel API面向对象的本质是通过应用程序接口(API)来满足用户的需求,整个Kernel的方法模式是创建对象、查找对应的 Type组件和对对象执行操作,组件类中的方法和服务是定义好的就Kernel而言,另外一个需要注意的问题是: Rich Client中所有的组件都是基于属性(property)的,即当要获取-一个对象名称的时候不能用getName( )方法(实际上也没有这个方法),而是通过getProperty(object_ name; )的方法来完成这个功能。

    这主要是因为整个的Kernel是建立在属性(property)层之上的,所以组件类具备获取属性信息的能力,而新建的类是继 承自TC Component组件类的,显然具备获取属性(property)信息的能力。比如当获取-一个BOMLine的数量属性的时候,通过BOMLine.getProperty( bl_ _quantity )即可得到。.

    TCSession session = RACUIUtil.getTCSession0;
    AbstractAIFUIApplication app = AIFUtility.getCurrentApplication0;
    AIFComponentContext[] selectedContexts = app.getTargetContexts();
    InterfaceAIFComponent component = context.getComponent(;
    TCComponentItem targetItem = (TCComponentItem)component;
    TCComponentItemRevision rev = targetItem.getLatestItemRevision(;
    TCComponentForm form =
    (TCComponentForm )rev.getRelatedComponent("IMAN_ master_ form_ rev");
    if(form.getProperty("user_ _data_ 1")== ="" ||
    form.getProperty("user_ _data_ 2")="")
    {
    MessageBox.post("ITEM无法取到用户数据属性! ", "提示",
    MessageBox.INFORMATION);
    }
    

    该插件对业务对象进行了组件的定义,系统中每个业务对象都在该插件中有相应的类去实现。如Folder是文件夹对象,该对象对应的系统类是:

    1)、TCComponentFolder

    该类继承了TCComponent类。扩展定义了Folder的获取以及和属性的修改方法。基本上所有的业务对象都继承于TCComponent类。相应的我们可以联想到,Item对 应的组件类为TCComponentItem; Dataset对 应的组件类为TCComponentDataset。

    该插件对业务对象进行了组件的定义,系统中每个业务对象都在该插件中有相应的类去实现。如Folder是文件夹对象,该对象对应的系统类是:

    2)、一个业务类对应的组件类相应的也会对应-一个业务类型类,如Folder对应的业务类型组件类为TCComponentFolderType。该类继承于TCComponentType类。相应的我们可以联想到,Item对应的组件类型类为TCComponentItemType; Dataset对应的组件类型类为TCComponentDatasetType。该类主要扩展定义了相应的业务对象的创建以及另存为等方法。

    通过业务对象对应的类型组件类去创建业务对象,还是以Folder对象为例:

    TCComponentFolderType t = (TCComponentFolderType)
    session.getTypeComponent("Folder");
    TCComponentFolder f= t.create("My Folder Name","My Folder Description", "My Folder Type");
    
    com.teamcenter.rac.tcapps

    Teamcenter中部分应用的基础实现和业务逻辑都在该类中进行了实现,该类也定义了–些公共组件等。

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

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

    com.teamcenter.rac.cme.mpp			对MSE应用进行了实现
    com.teamcenter.rac.pse				对结构管理器进行了实现
    com.teamcenter.rac.query builder	 对查询构建器进行了实现
    com.teamcenter.rac.explorer			对浏览器进行了实现
    

    任务要求:

    1)、掌握jar的解压方式; 2)、掌握使用Common包中的类,构建Jar包,实现快捷菜单添加新建零组件新建数据集的功能。

    在EcIipse中创建一个新的插件项目,命名为com.newCreate,不使用模板;

    新建plugin. xml文件,调用Common包中的newltem,newDataset类, 实现右键新建Item,新建数据集的功能。

    <?xml version="1.0" encoding="UTF-8"?>
    
    <?eclipse version="3.4"?>
    
    <plugin>
    
      <extension point="org.eclipse.ui.commands">
    
      <command id="CustNewItem" name="Create New Item"/>
    
      <command id="CustNewDataset" name="Create New Dataset"/>
    
      </extension>
    
      <extension point="org.eclipse.ui.handlers">
    
      <handler commandId="CustNewDataset"   class="com.teamcenter.rac.handlers.LegacyHandler:newDatasetAction:com.teamcenter.rac.common.actions.actions" />
    
            <handler commandId="CustNewItem" 
    
            class="com.teamcenter.rac.handlers.LegacyHandler:newItemAction:com.teamcenter.rac.common.actions.actions" />
    
      </extension>
    
      <extension point="org.eclipse.ui.menus">
    
      <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    
      <command commandId="CustNewItem"></command>
    
      </menuContribution>
    
            <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    
      <command commandId="CustNewDataset"></command>
    
      </menuContribution>
    
      </extension>
    
    </plugin>
    

    修改p lugin.xmI文件,调用Common包中的newltem,newDataset类, 实现右键新建Item,新建数据集的功能。

    思考:此处设置的p lugin. xmI脚本文件中,和com. newProcess. rac_1.0解压之后的p lugin.xm |做个比较。

    在runtime选项卡中添加导出包。

    在Build选项卡中,勾选.上plugin. xml文件,确保生成jar包时,plugin. xml也在包中。

    修改Minifest清单文件如下。

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: NewCreate
    Bundle-SymbolicName: com.newCreate;singleton:=true
    Bundle-Version: 1.0.0.qualifier
    Bundle-Activator: com.newcreate.Activator
    Bundle-Vendor: Mycom
    Require-Bundle: org.eclipse.core.runtime,
     com.teamcenter.rac.common;bundle-version="10000.1.0",
     org.eclipse.core.runtime.compatibility;bundle-version="3.2.200",
     com.teamcenter.rac.kernel;bundle-version="10000.1.0",
     com.teamcenter.rac.aifrcp;bundle-version="10000.1.0",
     org.eclipse.ui;bundle-version="3.8.0",
     com.teamcenter.rac.external;bundle-version="10000.1.0"
    Import-Package: com.teamcenter.rac.commands.newitem
    Import-Package: com.teamcenter.rac.commands.newdataset
    Bundle-RequiredExecutionEnvironment: JavaSE-1.7
    Bundle-ActivationPolicy: lazy
    Export-Package: com.newcreate
    

    生成结束后,打包jar包,放到p lugin文件夹中,并通过genr egxml. bat注册,清除缓存后登录TC查看功能结果。

    3.5TCSession的使用

    在进行Teamcenter客户化(二次开发)前,我们首先要了解哪些是核心API。只有掌握了核心API的使用,才能游刃有余的进行定制开发。下图展示了Teamcenter的核心API。从图中可以看到TC Session是核心API的核 心,通过TC Session沟通了应用程序AbstractAIFUIApplication、业务对象TCComponent、缓存AIFComponentManager、数据类型Type、业务服务Service。其中Type和Services是 各种相关类的集合。

    TcSession类在com.teamcenter.rac.kernel包中,是com.teamcenter.rac.aif.kernel.AbstractAIFSession的子类。TC会话负责登录到TC,并记录会话信息。它扩i展了AbstractAIFSession类的功能,使用AIF会话管理器管理会话。AIF : Application Integration Framework

    获取TCSession的三种办法
    从当前应用程序直接获取TC Session
    AbstractAIFUIApplication app =AIFUtility.getCurrentApplication();
    TCSession tcSession = (TCSession) app.getSession();
    

    AbstractAIFUIApplication类在com.teamcenter.rac.aif包中,是com.teamcenter.rac.aif.AbstractAIFApplication的子类。

    从TCComponent对象上获取TC Session
    TCSession tcSession = null;
    AbstractAIFUIApplication app = AIFUtility.getCurrentApplication();
    //获取选择的目标对象
    InterfaceAIFComponent target = app.getTargetComponent();
    if(target != null){
        TCComponent tcComp = (TCComponent)target;
        tcSession = target.getSession(;
    }
    
    通过ISessionService获取到TCSession

    在启动Teamcenter后,TCSession缓存到 了AIFSessionManager中,而AIFSessionManager实现了ISessionService接口。

    ISessionService iss = AifrcpPlugin. getSessionService();
    TCSession tcSession = null;
    try {
    	tcSession =(TCSession)iss.getSession( "com.teamcenter.rac.kernel.TCSession");
    } catch (Exceptione) {
    	e.printStackTrace();
    }
    
    获取当前TC信息
    tcSession.getUser();
    //获取用户
    tcSession. getCurrentGroup();
    //获取组信息
    tcSession.getGroup(); 
    tcSession.getCurrentOrganization();
    tcSession.getLoginGroupOrganization();
    tcSession.getCurrentRole); // 获取角色.
    tcSession.getRole();
    
    设置当前用户
    tcSession.setCurrentGroupMember(TCComponentGroup,TCComponentRole);
    tcSession.setCurrentOrganization(TCComponentGroup);
    tcSession.setCurrentProject(TCComponentProject); 
    
    DBA用户旁路功能打开

    首选要判断是否为DBA角色。注意:实际上,非BA用户也是可以开通旁路功能的,但是实现的方式稍微复杂些。在某些业务场景下,可能存在这个超越权限的特殊处理,一般是通过代码的方式,使用完后,及时关闭。

    tcSession.enableBypass(true);
    
    获取Type

    函数:

    TCComponentType type =tcSession.getTypeComponent("XXXType")
    

    Type组件,存在于Teamcenter的所有数据类型对象中,比如Item、Dataset、 Folder、 Revision等。 这种Type组件主要用于执行一些.如对象的创建、对象的查找等功能。因此,当需要创建对象的时候,首先应该想到通过Type实现。

    以下是一些常用的Type:

    表单: TCComponentFormType Item对象: TCComponentItemType 版本对象: TCComponentItemRevisionType 数据集: TTCComponentDatasetType 文件夹: CComponentFolderType 分类对象: TCComponentICOType 项目: TCComponentProjectType 查询: TCComponentQueryType 流程: TCComponentProcessType 时间表: TCComponentScheduleType BOM行: TCComponentBOMLineType BOM: TCComponentBOM WindowType 工艺对象: TCComponentMEProcessType

    例如创建文件夹功能代码如下:

    TCComponentFolderType type = (TCComponentFolderType)
    tcSession.getTypeComponent("Folder");
    TCComponentFolder f= type.create("My Folder Name", "MyFolder Description","My Folder Type");
    

    getTypeComponent函数中传递的参数,多数情况下, 就是TCComponentXXXType中的XXX。但是也有特列。更准确的说这个参数应该与对象的存储类名–致。例如:

    TCComponentQueryType queryType = (TCComponentQueryType)tcSession.getTypeComponent("ImanQuery");
    TCComponentProjectType tcComponentProjectType =(TCComponentProjectType)tcSession.getTypeComponent("TC_ Project");
    TCComponentProcessType processType =(TCComponentProcessType) tcSession.getTypeComponent("Job");
    

    对于自定义的对象类型N4MTMOPTrackingRevision,获取参数的 代码如下:

    TCComponentType tcComptype =tcSession.getTypeComponent("N4MTMOPTrackingRevision");
    
    获取Service服务

    以下是在二次开发过程中常用的几个服务: (1)首选项服务,可以操作与首选项相关的大部分操作。

    TCPreferenceService preferenceService =tcSession. getPreferenceService();
    

    (2)分类管理服务,可以完成大部分分类管理操作,包括创建 分类对象、查找分类对象、获取分类结构信息等。

    TCClassificationService classi ficationService =tcSession. getClassificationService();
    

    3.6创建TC对象

    TCAPI接口

    TCComponent TCComponentItem TCComponentI temRevision . TCComponent ItemType . TCComponentFolderType TCComponentUser TCComponentPerson TCComponentGroup TCComponentRole TCComponentForm TCComponentBOMW indow TCComponentRevi si onRule . TCComponentiTextField JCheckBox JFi 1 eChooser JButton JPanel JLabel JTextArea LOVComboBox,LOVUIComponent,TCComponentListOfValues Jtable JDialog DateButton

    Teamcenter中对象的创建一般都是通过会话获取要创建 对象的类型,然后再根据类型去创建具体的数据对象。每种 对象的创建用的函数方法都不一样。下面将根据不同对象的 创建方式进行说明: 1. Folder 的创建。 2. Form的创建。 3. Item的创建。 4. Dataset 的创建。

    Folder

    文件夹的创建需要对三个参数赋值,即文件夹名称、文件夹描述、文件夹的类型,以下是系统中创建文件夹的代码。

    TCComponentFolderType t = (TCComponentFolderType)
    session. getTypeComponent ("Folder") ;
    TCComponentFolder f=t. create(" My Folder Name ”,” MyFolder Description", "My Folder Type") ;
    
    Form的创建:

    Form的创建和Folder的创建类似,需要对三个参数赋值。Form名称、Form描述,以及Form类型。

    TCComponentFormType tccomponentFormType = (TCComponentFormType)session. getTypeComponent (' MyForm' ) ;
    TCComponentForm tccomponentForm =tccomponentFormType.create (' MyForm', "MyFormDescription","MyForm") ;
    
    Item的创建:

    Item的创建相对来说比前两个都复杂点,具体原理就是先根据系统类型从系统中获取编码和版本编码,然后进行创建。

    item _ID和item Revision获取方法:
    TCComponentI temType tccomponenti temtype =(TCComponentItemType) session. getTypeComponent (i temType) ;
    String itemId = tccomponenti temtype.getNewID();
    String itemRev = tccomponenti temtype.getNewRev();
    
    Item单位获取方法
    TCComponentType uom=session. getTypeComponent ("Uni tOfMeasure") ;
    TCComponent[] uoms = uom.extent() ;
    
    Item创建方法
    TCComponentItem item =tccomponent i temtype. create (i temId, i temRev, itemType, itemName, i temD
    escription, uoms[0]);
    ((TCComponentFolder)target).add("contents","item") ;
    
    Dataset的创建方法

    数据集的创建涉及到命名引用,创建过程:先创建某一一个类型的数据集,然后把命名引用添加上去。代码如下:

    String as1[] = {url};
    String as2[] = {"Text"};
    String as3[] = {"Text"};
    String as4[] = {"P1ain"};
    TCComponentDatasetType tccomponentDatasetType =(TCComponentDatasetType)session. getTypeComponent(" Text") ;
    TCComponentDataset tccomponentDataset =tccomponentDatasetType.create(dataFileName,"Text","Text") ;
    tccomponentDataset.setFiles (as1,as2,as3,as4,);
    
    查询构建器的调用

    Teamcenter中有专门的查询构建器模块,我们可以通过配置查询构建器,然后通过代码对系统中的对象进行搜索,以下是调用代码:

    TCTextService tcTextService = session. getTextService() ;
    String asKey[] = tcTextService. getTextValue(“item_id") ;
    String asValues[] ="00001";
    InterfaceAIFComponent interfaceAifComponent [] =session.search("ItemId...",asKey,asValues) ;
    
    Teamcenter中BOM结构的构建

    Teamcenter中的BOM结构建立,具体方法是先在系统中创建B0MWindow对象,然后再得到B0MLine对象,分别在BOMLine.上进行添加即可,实现代码如下:

    获取版本规则
    TCComponentRevisionRuleType tcComponentRevisionRuleType =(TCComponentRevisionRuleType)session. getTypeComponent ("RevisionRule") ;
    TCComponentRevisionRule tcComponentRevisionRule =tcComponentRevisionRuleType. getDefaultRule() ;
    
    创建BOMWi ndow
    TCComponentBOMWindowType tcComponentBomWindowType =(TCComponentBOMWindowType) session.getTypeComponent ("BOMWindow") ;
    TCComponentBOMWi ndow tcComponentBomWindow =tcComponentBomWindowType. create(tcComponentRevisionRule) ;
    
    获取BOMLine的两种方法
    TCComponentB0MLine line= ((AbstractPSEApplication)app).getTopBOMLine() ;
    
    TCComponentBOMLine []Lines= ( (AbstractPSEApplication) app).getSelectedBOMLines() ;
    
    添加对象到BOMLine
    TCComponentBOMLine tcComponentBomLine1 =tcomponentBomWindow.setWindowTopLine (tcComponentItem,tcComponentI temRevision1,tcComponent,tcComponent1) ;
    
    Java调用c的方法

    有时候某些功能需要Java程序和C语言程序同时去处理,以下是Java程序调用C语言程序的方法,以调用C语言程序来创建I tem为例:

    TCUserService userServ = sessionObj.getUserService() ;
    Object objs = new Object[3];
    String itemId = new String( "1234");
    String itemRev = new String ("A");
    String itemName = new String ("Nameof1234" );
    objs[0] = itemId;
    objs[1] = itemRev;
    objs[2] = itemName;
    TCComponent itemComp = (TCComponent) userServ.call ( "createItem",objs) ;
    

    通过以下的方式,可以取得目前的session user所属的newstuff folder, 并将objects贴附在这个folder下

    TCComponentFolder newStuffFolder=tcfolder. getNewStuffFolder (session) ;
    newStuffFolder.add ("contents",tcComponentItem) ;
    

    通过以下的方式,建立一个已经存在的workflow template, 并将i tem贴附到target中:

    TCComponentProcessType tcComponentProcessType= (TCComponentProcessType) session. getTypeComponent("Job' ) ;
    TCComponentProcess newProcess:s= (TCComponentProcess) tcComponentProcessType.create (PROCESS NAME, PROCESS DESC ,WORKFLOW TEMPLATE NAME,TCComponent[], Target : 1) ;
    TCComponentTaskTemplateType tcComponentTaskTemplateType
    =(TCComponentTaskTemplateType) session. getTypeComponent ( "EPMTaskTemplate");
    tcComponentTaskTemplate=tcComponentTaskTemplateType.extentReadyTemplates (true) ;
    

    第四章

    菜单定制是各种软件及其开发平台都会提供的必备功能。Teamcenter平台继承自Eclipse平台,其菜单功能与Eclipse平台是一脉相承的,因此Teamcenter平 台也提供了丰富的菜单功能项。如何实现Teamcenter的菜单功能,是Teamcenter二次 开发者必须掌握的重要技能。本章节将重点介绍Teamcenter中菜单的定制方法,并且以示例的方式引导读者深入了解Teamcenter的菜单定制功能。

    菜单定制

    Teamcenter Rich Client客户端本身是一个RCP程序,Teamcenter菜单的扩展遵循Ecl ipse菜单扩展的规则,给开发 人员提供了很好的用户体验。 Teamcenter菜单种类包括:

    • 主菜单.
    • 上下文菜单
    • 视图/编辑器菜单
    • 工具栏按钮
    • 发送到菜单
    • 切换菜单项Toggle menu Item
    Teamcenter主菜单

    主菜单一般位于软件的最顶层。下 图中的Sample Menu, 就是二次开发定制的主菜单,我们称这类菜单为一级主菜单。点开一-级主菜单“编辑”后,展开的一般是二级主菜单。Teamcenter平台即支持定制一 级菜单,也支持在OOTB平台.上定制二级菜单。主菜单在哪些应用程序显示,在什么情况下显示,也是可以定制的。

    上下文菜单

    上下文菜单(Context Menu),也称为快捷菜单(Shortcut Menu) ,右键点击时才会出现,出现频率较高的菜单项才会出现在上下文菜单中。上下文菜单具有很强的灵活项,随着点击对象的不同,弹出的菜单也会有相应的变化。

    视图/编辑器菜单

    视图/编辑器菜单(ViewPart/EditorPartMenu),最右侧弹出的就是“详细信息”视图的菜单。这部分区域的菜单,也是可定制的。

    工具栏按钮

    工具栏(Toolbar) 是显示位图式按钮行的控制条,使用位图式按钮用来执行命令。按工具栏按钮相当于选择菜单项;如果某个菜单项具有和工具栏按钮相同的ID,那么使用工具栏按钮将会调用映射到该菜单项的同一个处理程序。可以配置按钮,使其在外观和行为上表现为普通按钮、单选按钮或复选框。

    菜单扩展点

    按照RCP开发方式,菜单配置信息位于plugin. xml文件中,Teamcenter提供了两种扩展点供用户添加菜单到相应的位置:

    org.eclipse.ui.actionSets,简称为Actions方式;

    org.eclipse.ui.commands,简称为Commands方式。

    Actions,方式为界面上不同区域的表现方式提供了相应的扩展点,并且没有分离其界面表现和内在实现。主要在Teamcenter2007及以前的版本使用,后续版本使用Commands方式扩展。因此,课程仅讲解Commands方式的菜单项扩展。

    Commands;方式通过三步设置,有效的达到界面表现和内部实现的分离:

    1. 通过org. eclipse. ui. commands 扩展点创建命令和类别(Category),并且可以把某些命令放在- 一个类别(Category) 中;
    2. 通过org. eclipse. ui. menus指定命令出现在界面的哪个区域(视图菜单/主菜单/上下文菜单) ;
    3. 通过org. eclipse. ui. handlers指定命令的实现。

    针对上下文菜单,除了Actions方式和Comnands方式均可创建外,Eclipse还提供了另外一●种创建上下文菜单的扩展点 org. ecl ipse. ui. popupMenus,简称为popupMenus方 式。

    采用Commands方 式创建视图菜单,需要引入org. ecl ipse. ui. menus扩展点、org. eclipse. ui. handlers扩 展点和org. eclipse. ui. bindings扩展点。相关知识点包括:

    1. 菜单项扩展点
    2. locationURI语法规则
    3. 菜单显示/隐藏控制方法
    菜单项扩展点

    在具体介绍各菜单扩展点时,我们使用3.3节“hello,world command” 工程中自动创建的菜单,这份配置主要包括 四个扩展点: 第一个扩展点,定义了命令ID:

    com.teamcenter.helloworld.commands.sampleCommnand
    

    在这个扩展点中,主要定义command id。

    <extension point="org.eclipse.ui.commands" >
        <category name="Sample Category" id="com.teamcenter.helloworld.commands.category">
        </category>
        <command name= =' Sample Command"
        categoryId=" com.teamcenter.helloworld.commands.category" id=" com.teamcenter.helloworld.commands.sampleCommand">
        </command>
    </extension>
    

    第三个扩展点,是给COMMANID增加快捷键的绑定。这个 扩展点主要用于增强用户体验。M1+6代表了当按下快捷键. Ctr1+6时也会执行相应的命令,M2代表Shift。

    <extension point=" org. eclipse. ui. bindings' >
        <key commandId=" com.teamcenter.helloworld.commands.sampleCommand" contextId=”org.eclipse.ui.contexts.window" sequence=“M1+6"schemeId=" org. eclipse. ui. defaul tAcce leratorConf iguration">
        </key>
    </extension>
    

    第四个扩展点,完成了采单的定义。这个扩展点需要重 点掌握,我们大部分的菜单配置项,都在这个扩展点中实现。.

    <extension point=" org.eclipse.ui.menus" >
    	<menuContribution locat ionURI=' menu:org. eclipse. ui. main. menu?after additions' >
            <menu 1abe1="Sample Menu" mnemonic="M" id= 'com.teamcenter.helloworld.menus.sampleMenu'>
                <command commandId= =" com. teamcenter. hellowor ld. commands. sampleCommand" mnemonic="S"
                id=" com. teamcenter. hel lowor ld. menus. sampl eCommand”>
                </command>
            </menu>
    	</menuContribution>
        <menuContribution locationURI= toolbar:org.eclipse.ui.main.toolbar?after=additions' >
            <toolbar id= "com.teamcenter.helloworld.toolbars.sampleToolbar">
                <command commandId=" com. teamcenter. hel loworld. commands. sampl eCommand"
                icon :"icons/sample.gif" tooltip="Say hello world" id=" com.teamcenter.helloworld.toolbars.sampleCommand^ >
                </command>
            </toolbar>
        </menuContribution>
    </extension>
    

    locationURI语法规则

    在定义菜单在Teamcenter出现的位置,需要设置locationURI的参数值。locationURI属性格式如 下:

    <menuContribution locationURI="[Scheme]:[id] ? [argument-list] ">
    

    其中:

    • Scheme 为该菜单项出现的区域,为menu、popup、toolbar中 的任何一个。
    • id为菜单区域ID,即现在已经存在的菜单ID、视图ID。
    • argument-list为该菜单项出现在指定菜单的位置。
    主菜单定义

    通过Commands 方式把菜单项添加到主菜单及其工具栏上,和视图菜单一样,也是通过扩 展点org. eclipse. ui. menus ;实现,需要设定其menuContribution的locationURI。

    例如,添加一个菜单(菜单可以包含若干个菜单项)到主菜单栏中的某一个位置,其locationURI 为:

    menu:org.eclipse.ui.main.menu?before=Edit
    

    例如,把菜单项添加到已经存在的菜单当中。例如,添加-一个菜单项到File主菜单当中,其locationURI为: menu:File? after=additionso . 例如,在DetailsView的 下拉菜单加一一个 菜单项,其MenuContribution的locationURI 应为: menu: org.eclipse.ui.views.DetailsView?after= additions;

    快捷键参数

    D:\Siemens\Teamcenter10\portal\portal.bat -nl zh_CN
    D:\Siemens\Teamcenter10\portal\portal.bat -nl en_US
    

    plugin.xml文件中定义的脚本程序:

    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
       <extension
             point="org.eclipse.ui.commands">
          <category
                name="Sample Category"
                id="c9.mycustom.commands.category">
          </category>
          <command
                name="Sample Command"
                categoryId="c9.mycustom.commands.category"
                id="c9.mycustom.commands.sampleCommand">
          </command>
       </extension>
       <extension
             point="org.eclipse.ui.handlers">
          <handler
                commandId="c9.mycustom.commands.sampleCommand"
                class="c9.mycustom.handlers.SampleHandler">
          </handler>
       </extension>
       <extension
             point="org.eclipse.ui.bindings">
          <key
                commandId="c9.mycustom.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?before=Edit">
            <menu
                  label="Sample Menu"
                  mnemonic="M"
                  id="c9.mycustom.menus.sampleMenu">
               <command  commandId="c9.mycustom.commands.sampleCommand"
                     mnemonic="S"
                     id="c9.mycustom.commands.sampleCommand">
               </command>           
               <visibleWhen>
                <or>
                 <reference definitionId="com.teamcenter.rac.ui.inMainPerspective"/> 
                 <reference definitionId="com.teamcenter.rac.cme.mpp.inMainView" />
                </or>
               </visibleWhen>  
            </menu>
         </menuContribution>
           <menuContribution locationURI="menu:file?after=additions">
    			 <command
                      commandId="c9.mycustom.commands.sampleCommand"
                      icon="icons/sample.gif"
                       mnemonic="S"
                      id="c9.mycustom.commands.sampleCommand3">
                </command>
    		</menuContribution>
          <menuContribution
                locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
             <toolbar
                   id="c9.mycustom.toolbars.sampleToolbar">
                <command
                      commandId="c9.mycustom.commands.sampleCommand"
                      icon="icons/sample.gif"
                      tooltip="Say hello world"
                      id="c9.mycustom.toolbars.sampleCommand">
                </command>
             </toolbar>
          </menuContribution>
          <menuContribution locationURI="menu:com.teamcenter.rac.ui.views.DetailsView?after=additions">
    			 <command
                      commandId="c9.mycustom.commands.sampleCommand"
                      icon="icons/sample.gif"
                      mnemonic="S"
                      id="c9.mycustom.commands.sampleCommand2">
                </command>
    		</menuContribution>
    		      <menuContribution locationURI="toolbar:com.teamcenter.rac.ui.views.DetailsView?after=additions">
    			 <command
                      commandId="c9.mycustom.commands.sampleCommand"
                      icon="icons/sample.gif"
                      mnemonic="S"
                      id="c9.mycustom.commands.sampleCommand22">
                </command>
    		</menuContribution>
       </extension>
    </plugin>
    
    上下文菜单

    Commands;方式与添加视图菜单和主菜单的方式-样,通过设定其menuContribution的locationURI 来实现。 例如,添加一个上下文菜单到快捷菜单中,其locat ionURI为: popup:org.eclipse.ui.popup.any?after=additions

    菜单显示/隐藏控制方法

    菜单控制是-一个常见的功能。例如,随着选定的内容或当前窗口的不同,菜单中的菜单项会有相应的变化(显示/隐藏或启用/禁用菜单项)。如何控制菜单是插件开发必须掌握的知识。Eclipse为菜单控制提供了两种方法,一种是通过扩展点;另一种是通过API的方式编写程序控制。通过Command方式创建的菜单,可以通过org. eclipse. ui. commands的visibleWhen 属性控制菜单的显示和隐藏。visibleWhen是用于控制菜单显示的核心表达式。该标签即可位于menu标签之下,也可位于command标签之前。尽管从官方的语法说明来看,可以作用于toobar标签下,但是经过测试toolbar 下的visibl eWhen标签不生效。通过org. eclipse. ui. handlers的activewhen 或enabledWhen 控制菜单的启用或禁用。

    visibleWhen可以用在command、menu子节点下在menu标签下,添加如下代码,可以让该菜单及其子菜单,仅仅显示在“我的Teamcenter”、“制造工艺规划器中”和“分类”。“or.”标签用于在多个应用程序中显示。

    <visibleWhen>
        <or>
        <reference
        defini tionId=" com. teamcenter. rac. ui. inMainPerspective”/>
        <reference definitionId=" com. teamcenter. rac. cme. mpp. inMainView'/>
        <reference
        definitionId=" com. teamcenter. rac. classification. icm. inMainView" />
        </or>
    </visibleWhen>
    

    Teamcenter中常见的应用程序ID如下:

    “我的Teamcenter”: com.teamcenter. rac. ui.inMainPerspective “制造工艺规划器”: com.teamcenter. rac. cme. mpp. inMainView “结构管理器”: com. teamcenter. rac. pse. inMainView . “分类管理”: com. teamcenter. rac. classification. icadmin. inMainView “分类”:com. teamcenter. rac. classification. icm. inMainView “入门”: com. teamcenter. rac. gettingstarted. inMainView “项目”: com. teamcenter. rac. project. inMainView

    实践练习一:

    加载项目c9. mycustom,查看其扩展的设置方式,并修改:

    • 自定义菜单sampl eCommand在Main menu中 出现的位置,出现在windows菜单中;
    • 自定义菜单sampleCommand出现在上下文菜单中。
    实践练习二:

    定义两个主菜单报表输出、功能

    报表输出含有:产品报表导出

    功能:创建项目文件夹、创建数据文件夹、修改技术文档ID

    实例

    工具栏toolbar
    <?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.addbutton.commands.sampleCommand">
            </command>
        </extension>
        <extension point="org.eclipse.ui.handlers">
            <handler
                     commandId="com.mycom.addbutton.commands.sampleCommand"
                     class="com.mycom.addbutton.handlers.SampleHandler">
            </handler>
        </extension>
        <extension point="org.eclipse.ui.menus">
            <menuContribution
                              locationURI="toolbar:navigator_Toolbar?after=additions">
                <command
                         commandId="com.mycom.addbutton.commands.sampleCommand"
                         icon="icons/sample.gif"
                         tooltip="Say hello world"
                         id="com.mycom.addbutton.toolbars.sampleCommand">
                    <visibleWhen>
                        <reference
                                   definitionId="com.teamcenter.rac.ui.inMainPerspective">
                        </reference>
                    </visibleWhen>
                </command>
            </menuContribution>
        </extension>
    </plugin>
    
    菜单栏中添加一个新的菜单
    <?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>
    
    package com.mycom.addmenuitem.handlers;
    
    import org.eclipse.core.commands.AbstractHandler;
    import org.eclipse.core.commands.ExecutionEvent;
    import org.eclipse.core.commands.ExecutionException;
    import org.eclipse.ui.IWorkbenchWindow;
    import org.eclipse.ui.handlers.HandlerUtil;
    import org.eclipse.jface.dialogs.MessageDialog;
    
    /**
     * 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.
    	 */
    	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(),
    				"Addmenuitem",
    				"demo");
    		return null;
    	}
    }
    

    菜单栏选项

    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
        <extension
                   point="org.eclipse.ui.commands">
            <category
                      name="Sample Category"
                      id="com.teamcenter.rac.toggleexample.commands.category">
            </category>
            <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>
            </command>
            <command
                     categoryId="com.mycom.toggle.commands.category"
                     defaultHandler="com.mycom.toggle.handlers.ToggleWarnHandler"
                     id="com.mycom.toggle.commands.warnCommand"
                     name="Warn">
                <state
                       class="org.eclipse.ui.handlers.RegistryToggleState:false"
                       id="org.eclipse.ui.commands.toggleState">
                </state>
            </command>
            <command
                     categoryId="com.mycom.toggle.commands.category"
                     defaultHandler="com.mycom.toggle.handlers.ToggleErrorHandler"
                     id="com.mycom.toggle.commands.errorCommand"
                     name="Error">
                <state
                       class="org.eclipse.ui.handlers.RegistryToggleState:false"
                       id="org.eclipse.ui.commands.toggleState">
                </state>
            </command>
        </extension>
        <extension
                   point="org.eclipse.ui.menus">
            <menuContribution
                              locationURI="menu:org.eclipse.ui.main.menu?after=additions">
                <menu
                      id="com.mycom.toggle.menus.sampleMenu"
                      label="Error Level"
                      mnemonic="L">
                    <command
                             commandId="com.mycom.toggle.commands.infoCommand"
                             label="Info"
                             mnemonic="I"
                             style="toggle">
                        <visibleWhen>
                            <reference
                                       definitionId="com.teamcenter.rac.ui.inMainPerspective">
                            </reference>
                        </visibleWhen>
                    </command>
                    <command
                             commandId="com.mycom.toggle.commands.warnCommand"
                             label="Warn"
                             mnemonic="W"
                             style="toggle">
                        <visibleWhen>
                            <reference
                                       definitionId="com.teamcenter.rac.ui.inMainPerspective">
                            </reference>
                        </visibleWhen>
                    </command>
                    <command
                             commandId="com.mycom.toggle.commands.errorCommand"
                             label="Error"
                             mnemonic="E"
                             style="toggle">
                        <visibleWhen>
                            <reference
                                       definitionId="com.teamcenter.rac.ui.inMainPerspective">
                            </reference>
                        </visibleWhen>
                    </command>
                </menu>
            </menuContribution>
        </extension>
    </plugin>
    

    image-20200621220623531

    在右键上添加
    <?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.addshortcut.commands.sampleCommand">
            </command>
        </extension>
        <extension point="org.eclipse.ui.handlers">
            <handler
                     commandId="com.mycom.addshortcut.commands.sampleCommand"
                     class="com.mycom.addshortcut.handlers.SampleHandler">
            </handler>
        </extension>
        <extension point="org.eclipse.ui.menus">
            <menuContribution
                              locationURI="popup:org.eclipse.ui.popup.any?after=additions">
                <command
                         commandId="com.mycom.addshortcut.commands.sampleCommand"
                         mnemonic="S"
                         icon="icons/sample.gif"
                         id="com.mycom.addshortcut.menus.sampleCommand">
                    <visibleWhen>
                        <reference
                                   definitionId="com.teamcenter.rac.ui.inMainPerspective">
                        </reference>
                    </visibleWhen>
                </command>
            </menuContribution>
        </extension>
    </plugin>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
    	<extension point="org.eclipse.ui.commands">
    		<command id="CustNewItem" name="Create New Item"/>
    		<command id="CustNewDataset" name="Create New Dataset"/>
    	</extension>
    	<extension point="org.eclipse.ui.handlers">
    		<handler commandId="CustNewDataset" 
    		class="com.teamcenter.rac.handlers.LegacyHandler:newDatasetAction:com.teamcenter.rac.common.actions.actions" />
            <handler commandId="CustNewItem" 
            class="com.teamcenter.rac.handlers.LegacyHandler:newItemAction:com.teamcenter.rac.common.actions.actions" />
    	</extension>
    	<extension point="org.eclipse.ui.menus">
    		<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    			<command commandId="CustNewItem"></command>
    		</menuContribution>
            <menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    			<command commandId="CustNewDataset"></command>
    		</menuContribution>
    	</extension>
    </plugin>
    
    视图
    <?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.customview.commands.sampleCommand">
    	</command>
    </extension>
    <extension point="org.eclipse.ui.handlers">
    	<handler
    	    commandId="com.mycom.customview.commands.sampleCommand"
    	    class="com.mycom.customview.handlers.SampleHandler">
    	</handler>
    </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.mycom.customview.menus.sampleMenu">
    			<command
    			commandId="com.mycom.customview.commands.sampleCommand"
    			mnemonic="S"
    			id="com.mycom.customview.menus.sampleCommand">
    				<visibleWhen>
    					<reference
    					definitionId="com.mycom.customview.inMainView" />
    				</visibleWhen>
    			</command>
    		</menu>
    	</menuContribution>
    </extension>
    <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>
    <extension point="org.eclipse.core.expressions.definitions">
    	<definition id="com.mycom.customview.inMainView">
    		<with variable="activePartId">
    			<equals value="com.mycom.customview.views.CustomView" />
    		</with>
    	</definition>
    </extension>
    </plugin>
    
    退出
    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
        <extension
                   point="org.eclipse.ui.commands">
            <category
                      name="Sample Category"
                      id="com.teamcenter.rac.exit.commands.category">
            </category>
            <command
                     name="Sample Command"
                     categoryId="com.mycom.exitcommand.commands.category"
                     id="com.mycom.exitcommand.commands.sampleCommand">
            </command>
            <command
                     defaultHandler="com.mycom.exitcommand.handlers.SampleHandler"
                     id="com.mycom.exitcommand.command1.Exit"
                     name="Exit">
            </command>
        </extension>
        <extension
                   point="org.eclipse.ui.handlers">
            <handler
                     commandId="com.mycom.exitcommand.commands.sampleCommand"
                     class="com.mycom.exitcommand.handlers.SampleHandler">
            </handler>
        </extension>
        <extension
                   point="org.eclipse.ui.bindings">
            <key
                 commandId="com.mycom.exitcommand.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: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>
                <command
                         commandId="com.mycom.exitcommand.command1.Exit"
                         icon="icons/sample.gif"
                         label="Exit"
                         style="push"
                         tooltip="Exit the application">
                </command>
            </menuContribution>
        </extension>
    </plugin>
    
    综合
    <?xml version="1.0" encoding="UTF-8"?>
    <?eclipse version="3.4"?>
    <plugin>
        <extension point="org.eclipse.ui.commands">
            <command
                     name="新建文件夹"
                     id="com.origin.custom.handler.newFolderHandler">
            </command>
        </extension>
        <extension point="org.eclipse.ui.handlers">
            <handler
                     commandId="com.origin.custom.handler.newFolderHandler"
                     class="com.origin.custom.handler.NewFolderHandler">
            </handler>
        </extension>
        <extension  point="org.eclipse.ui.menus">
            <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
                <menu label="客户化菜单(M)" mnemonic="M" id="customMenus">
                    <command
                             commandId="com.origin.custom.handler.newFolderHandler"
                             mnemonic="S"
                             icon="icons/newfolder_16.png"
                             id="customMenus">
                        <visibleWhen>
                            <reference
                                       definitionId="com.teamcenter.rac.ui.inMainPerspective">
                            </reference>
                        </visibleWhen>
                    </command>
                </menu>
            </menuContribution>
    
            <menuContribution
                              locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
                <toolbar id="customToolbar">
                    <command
                             commandId="com.origin.custom.handler.newFolderHandler"
                             icon="icons/newfolder_16.png"
                             tooltip="新建文件夹"
                             id="customToolbar">
                    </command>
                </toolbar>
            </menuContribution>
            <menuContribution
                              locationURI="popup:org.eclipse.ui.popup.any?after=additions">
                <command
                         commandId="com.origin.custom.handler.newFolderHandler"
                         mnemonic="S"
                         icon="icons/newfolder_16.png"
                         id="customPopup">
                    <visibleWhen>
                        <reference
                                   definitionId="com.teamcenter.rac.ui.inMainPerspective">
                        </reference>
                    </visibleWhen>
                </command>
            </menuContribution> </extension>
    </plugin>
    
    

    第五章

    五代码化定制任务

    5.1.1无代码化定制

    实例:定制Teamcenter 胖客户端logon window.通过定制com.teamcenter.rac.kernel version.jar文件, 当登录TC时,可以改变加载的登录界面。

    1、自定义登录窗口(logon window)

    使用解压缩包工具打开%TC _RO0T%\portal\plugins\com.teamcenter.rac.kernel_10000.1. 0.jar文件,替换\icons’下的background. png文件。

    注意:修改原始文件前,先做好备份,并去掉. jar后缀名。

    2、按照清理TC缓存的方法,删除C: \Documents andSettings \Admini strator \Teamcenter*目录,重新打开TC验证功能。

    1、修改Views,Dial og boxes,Forms,Wizards的布局和内容

    可以使用渲染文件Style sheets来改变Teamcenter views, dialogboxes, forms,和wizards using的布局与内容。Style sheets是一种数据集类型,使用Style sheets可以按照实际需求加载定制的数据属性。可供修改的数据对象包括Views,Dialog boxes,Forms的窗口信息。使用渲染文件进行定制的步骤如下

    (1)在TC的Newstuff文件夹中新建XMLRenderingStylesheet数据集。例如,要修改汇总(Summary)视图的布局和加载属性,可以命名数据集为myItemSummary。

    image-20200621222406300

    (2)使用“数据集…..”查询,检索系统中现有的XMLRenderingStylesheet,找到Itemsummary数据集。

    image-20200621222416976

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    =======================================================================
    Copyright 2012.
    Siemens Product Lifecycle Management Software Inc.
    All Rights Reserved.
    =======================================================================
         Filename: ItemSummary.xml
    
        Style sheet rendering for Item summary.
    =======================================================================
    -->
    <rendering xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="XMLRenderingStylesheet_Schema.xsd">
        <header>
            <image source="thumbnail"/>
            <classificationTrace/>
            <property name="owning_user"/>
            <property name="last_mod_date"/>
            <property name="release_status_list"/>
            <property name="object_type"/>
        </header>
        <page titleKey="tc_xrt_Overview">
            <column>
                <section titleKey="tc_xrt_AvailableRevisions">
                    <objectSet source="revision_list.ItemRevision" defaultdisplay="listDisplay" sortdirection="descending" sortby="item_revision_id">
                        <tableDisplay>
                            <property name="object_string"/>
                            <property name="item_revision_id"/>
                            <property name="release_status_list"/>
                            <property name="last_mod_date"/>
                            <property name="last_mod_user"/>
                            <property name="checked_out_user"/>
                        </tableDisplay>
                        <thumbnailDisplay/>
                        <treeDisplay>
                            <property name="object_string"/>
                            <property name="item_revision_id"/>
                            <property name="release_status_list"/>
                            <property name="last_mod_date"/>
                            <property name="last_mod_user"/>
                            <property name="checked_out_user"/>
                        </treeDisplay>
                        <listDisplay/>
                    </objectSet>
                </section>
                <section titleKey="tc_xrt_ItemProperties">
                    <property name="object_desc"/>
                    <separator/><!--分隔符-->
                    <property name="owning_user" renderingHint="objectlink" modifiable="false"/>
                    <property name="owning_group" renderingHint="objectlink" modifiable="false"/>
                    <property name="last_mod_user"/>
                    <separator/>
                    <property name="checked_out"/>
                    <property name="checked_out_user"/>
                    <separator/>
                    <command commandId="com.teamcenter.rac.properties" titleKey="tc_xrt_moreProperties"/>
                </section>
                <section titleKey="tc_xrt_ClassificationProperties">
                    <classificationProperties/>
                </section>
            </column>
            <column>
                <section titleKey="tc_xrt_Preview">
                    <image source="preview"/>
                </section>
                <section titleKey="tc_xrt_actions" commandLayout="vertical">
                    <command actionKey="copyAction" commandId="com.teamcenter.rac.copy" />
                    <command actionKey="saveAsAction" commandId="org.eclipse.ui.file.saveAs" />
                    <command actionKey="newProcessAction" commandId="com.teamcenter.rac.newProcess" titleKey="tc_xrt_newProc" />
                </section>
            </column>
        </page>
        <page titleKey="tc_xrt_AttachedFiles">
            <objectSet source="IMAN_reference.Dataset,IMAN_manifestation.Dataset,IMAN_Rendering.Dataset" defaultdisplay="tableDisplay" sortby="object_string" sortdirection="ascending">
                <tableDisplay>
                    <property name="object_string"/>
                    <property name="release_status_list"/>
                    <property name="relation"/>
                    <property name="last_mod_date"/>
                    <property name="last_mod_user"/>
                    <property name="checked_out_user"/>
                </tableDisplay>
                <thumbnailDisplay/>
                <treeDisplay>
                    <property name="object_string"/>
                    <property name="release_status_list"/>
                    <property name="relation"/>
                    <property name="last_mod_date"/>
                    <property name="last_mod_user"/>
                    <property name="checked_out_user"/>
                </treeDisplay>
                <listDisplay/>
                <command actionKey="newBusinessObjectContextualAction" commandId="com.teamcenter.rac.common.AddNew" renderingHint="commandbutton"/>
                <command actionKey="pasteAction" commandId="com.teamcenter.rac.viewer.pastewithContext" renderingHint="commandbutton"/>
                <command actionKey="cutAction" commandId="org.eclipse.ui.edit.cut" renderingHint="commandbutton">
                        <parameter name="localSelection" value="true"/>
                </command>
            </objectSet>
        </page>
        <page title="Related Links" titleKey="tc_xrt_RelatedLinks" visibleWhen="{pref:LIS_RelatedLinkTabVisible}==true">
            <objectSet source="IMAN_specification.Lis0Link,IMAN_reference.Lis0Link" defaultdisplay="tableDisplay" sortby="object_string" sortdirection="ascending">
                <tableDisplay>
                    <property name="object_string"/>
                    <property name="lis0site"/>
                    <property name="lis0serviceProvider"/>
                    <property name="relation"/>
                    <property name="last_mod_date"/>
                    <property name="last_mod_user"/>
                    <property name="checked_out_user"/>
                </tableDisplay>
                <command actionKey="newBusinessObjectContextualAction" commandId="com.teamcenter.rac.lisfmwrk.newRelatedLink" renderingHint="commandbutton"/>
                <command actionKey="copyAction" commandId="com.teamcenter.rac.copy" renderingHint="commandbutton">
                    <parameter name="localSelection" value="true"/>
                </command>
                <command actionKey="pasteAction" commandId="com.teamcenter.rac.viewer.pastewithContext" renderingHint="commandbutton"/>
                <command actionKey="cutAction" commandId="org.eclipse.ui.edit.cut" renderingHint="commandbutton">
                    <parameter name="localSelection" value="true"/>
                </command>
            </objectSet>
        </page>
        <page titleKey="tc_xrt_AuditLogs" visibleWhen="{pref:TC_audit_manager_version}==3">
            <command titleKey="tc_xrt_ExportToExcel"  actionKey="exportExcelAction" commandId = "com.teamcenter.rac.exportAuditSummaryToExcel" renderingHint="commandbutton"/>
            <command titleKey="tc_xrt_ExportToCSV" actionKey="exportCSVAction" commandId = "com.teamcenter.rac.exportAuditSummaryToCSV" renderingHint="commandbutton"/>
            <section titleKey="tc_xrt_WorkflowLogs" initialstate="collapsed">
                <customPanel java="com.teamcenter.rac.auditmanager.WorkflowLegacyAuditLinkPanel"/>
                <objectSet source="fnd0WorkflowAuditLogs.Fnd0WorkflowAudit" defaultdisplay="tableDisplay" sortby="fnd0LoggedDate" sortdirection="ascending">
                    <tableDisplay>
                        <property name="fnd0LoggedDate"/>
                        <property name="object_type"/>
                        <property name="fnd0EventTypeName"/>
                        <property name="object_name"/>
                        <property name="job_name"/>
                        <property name="process_templateDisp"/>
                        <property name="fnd0UserId"/>
                        <property name="fnd0SponsoringUserID"/>
                        <property name="task_state"/>
                        <property name="task_result"/>
                        <property name="fnd0Comments"/>
                        <property name="responsible_party"/>
                        <property name="fnd0SignoffUserID"/>
                        <property name="fnd0SignoffGroupName"/>
                        <property name="fnd0SignoffRoleName"/>
                        <property name="fnd0SecondaryObjectType"/>
                        <property name="fnd0SecondaryObjDispName"/>
                        <property name="fnd0SecondaryObjQualifier"/>
                    </tableDisplay>
                </objectSet>
                <customPanel java="com.teamcenter.rac.auditmanager.WorkflowSecondaryAuditPanel" js="displayWorkflowCustomPanel" />
            </section>
            <section titleKey="tc_xrt_GeneralLogs" initialstate="collapsed">
                <customPanel java="com.teamcenter.rac.auditmanager.CheckoutHistoyLinkPanel"/>
                <objectSet source="fnd0GeneralAuditLogs.Fnd0GeneralAudit" defaultdisplay="tableDisplay" sortby="fnd0LoggedDate" sortdirection="ascending">
                    <tableDisplay>
                        <property name="fnd0LoggedDate"/>
                        <property name="object_type"/>
                        <property name="fnd0EventTypeName"/>
                        <property name="object_name"/>
                        <property name="fnd0PrimaryObjectID"/>
                        <property name="fnd0PrimaryObjectRevID"/>
                        <property name="fnd0UserId"/>
                        <property name="fnd0SponsoringUserID"/>
                        <property name="fnd0GroupName"/>
                        <property name="fnd0RoleName"/>
                        <property name="sequence_id"/>
                        <property name="fnd0ChangeID"/>
                        <property name="fnd0Reason"/>
                        <property name="fnd0SecondaryObjectType"/>
                        <property name="fnd0SecondaryObjDispName"/>
                    </tableDisplay>
                </objectSet>
            </section>
            <section titleKey="tc_xrt_LicenseExportLogs" initialstate="collapsed">
                <objectSet source="fnd0LicenseExportAuditLogs.Fnd0LicenseExportAudit" defaultdisplay="tableDisplay" sortby="fnd0LoggedDate" sortdirection="ascending">
    
                    <tableDisplay>
                        <property name="fnd0LoggedDate"/>
                        <property name="object_type"/>
                        <property name="fnd0EventTypeName"/>
                        <property name="object_name"/>
                        <property name="fnd0UserId"/>
                        <property name="fnd0SponsoringUserID"/>
                        <property name="fnd0GroupName"/>
                        <property name="fnd0RoleName"/>
                        <property name="id"/>
                        <property name="fnd0SecondaryObjectID"/>
                        <property name="fnd0SecondaryObjectRevID"/>
                        <property name="fnd0SecondaryObjectType"/>
                        <property name="fnd0SecondaryObjectName"/>
                        <property name="fnd0SecondaryObjDispName"/>
                        <property name="fnd0SecondaryObjectSeqID"/>
                        <property name="ead_paragraph"/>
                    </tableDisplay>
                </objectSet>
                <customPanel java="com.teamcenter.rac.auditmanager.LicenseExportSecondaryAuditPanel" js="displayLicenseExportCustomPanel" />
            </section>
            <section titleKey="tc_xrt_StructureLogs" initialstate="collapsed">
                <objectSet source="fnd0StructureAuditLogs.Fnd0StructureAudit" defaultdisplay="tableDisplay" sortby="fnd0LoggedDate" sortdirection="ascending">
                    <tableDisplay>
                        <property name="fnd0LoggedDate"/>
                        <property name="object_type"/>
                        <property name="fnd0EventTypeName"/>
                        <property name="object_name"/>
                        <property name="fnd0UserId"/>
                        <property name="fnd0SponsoringUserID"/>
                        <property name="fnd0GroupName"/>
                        <property name="fnd0RoleName"/>
                        <property name="item_id"/>
                        <property name="item_revision_id"/>
                        <property name="sequence_id"/>
                        <property name="fnd0SecondaryObjectID"/>
                        <property name="fnd0SecondaryObjectRevID"/>
                        <property name="fnd0SecondaryObjectType"/>
                        <property name="fnd0SecondaryObjectName"/>
                        <property name="fnd0SecondaryObjDispName"/>
                        <property name="fnd0SecondaryObjectSeqID"/>
                        <property name="comp_position"/>                    
                    </tableDisplay>
                </objectSet>
                <customPanel java="com.teamcenter.rac.auditmanager.StructureSecondaryAuditPanel" js="displayStructureCustomPanel" />
            </section>
            
        </page>
    </rendering>
    

    (3)将Itemsummary数据集中的XML脚本语句复制到新建的数据集myItemSummary中。可以通过修改XML脚本,增添属 性、修改布局,单击工具栏中的保存按钮进行保存。

    image-20200621222429260

    (4)从查看器中“注册类型”的下拉列表框中选择C9_ myItem,“样式表类型” 的下拉列表框选择“汇总”,单击“应用按钮”,进行配置。

    image-20200621222441988

    (5)在新建的C9 myItem业务对象中,在汇总视图中查看配置后的效果。

    image-20200621222450202

    2、增加或修改对象图标 1)可以修改BMIDE中现有的业务对象图标,或者为新创建的业务对象指定图标。从BIMIE中导入图标的素材,然后将对 应的图标添加到零组件的属性中,通过部署项目完成图标的设置。实例:业务建模器中添加图标

    2)可以使用属性文件来修改各类图标。将替代的图标添加到创建的属性文件中,然后将属性文件拖拽到.jar包中。修改属 性文件的图标格式是:business- object.ICON=image-directory/image-file-name实例:使用“自定义发布流程”发布C9_myItem版本对象,实现将发布后的系统默认状态图标变为自定义的图标。

    (3)使用普通用户登录Teamcenter,新建C9_ myItem零组 件使用自定义发布流程发布C9_ myItem零组件的A版本数据。此时,发布后的状态图标还是黑色的旗子。

    (4)创建configuration_ 10000.1.0文件夹,在此文件夹中新建customer.properties属性文件。在customer.properties 属性文件中添加脚本文件如下,完成对自定义发布状态的图标定制:

    release_ status_ list. I_ Released.ICON=images/C9_ IReleased.png
    release_ statuses. I_ Released.ICON=images/ C9_ IReleased.png
    

    image文件夹中放置C9_ IReleased.png的1 6位像素图标。

    image文件夹中放置C9_ IReleased.png的1 6位像素图标。

    (5)将configuration_ 10000.1 .0文件夹复制到%TC_ ROOT%\portal\plugins文件家中, 和系统中已有的configuration_ 10000.1 .0文件夹进行合并。

    (6)使用genregxml.bat文件注册配置文件,注册完成后清除TC缓存。再使用普通用户登录Teamcenter,查看刚才发布的数据,此时发布状态字变为自定义的图标。

    5.2 无代码化定制应用

    image-20200621163511952

    授权,针对于组织中的组和子组的用户,开放或收回特定的应用模块。例如,针对工程组的用户,可以开放组织和工作流设计器的功能,由工程组的人员进行组织和流程的设计。

    image-20200621163546735

    5.2.2 首选项

    1、首选项概念

    首选项是存储在TC数据库中的环境变量。当设置和修改的时候都要读取。例如可以设置登陆的名称和属性表显示的列,一些权限等都与这些首选项有关。站点(Site)首选项:站点的首选项影响到Teamcenter的整个站点。只有管理员可以创建和修改;用户(User)首选项:用户首选项是针对特定用户的,这个用户可设置和创建,具有最高的优先级,dba组的人员也可创建和修改;组(Group)首选项和 角色(Role)首选项:组和角色的首选项是针对特定的组和角色的,组管理员有权限设置,dba组的人员也可创建和修改

    2、首选项的分级规则

    首选项分两种,系统首选项和分级首选项:

    (1)系统首选项:适用于整个站点;

    (2)分级首选项有保护范围:用户,角色,组,站点,级别从用户到站点依次递增。

    首选项位置优先顺序是:用户>角色>组>站点。系统根据级别搜索首选项值,开始于当前定义的首选项保护范围,然后根据当前用户->当前角色->当前组->当前站点的顺序读取

    image-20200621163722189

    首选项保护范围:定义保护范围,确定了可创建首选项实例的最低级别,按从高到低的级别顺序依次为站点和系统>组>角色>用户。

    比如系统读取一个保护范围为角色的首选项:

    (1)如果当前角色有一个值,就使用这个值;

    (2)如果当前角色没有值,但是当前组有值,使用组的值;

    (3)如果当前角色和组都没有值,但是站点有值,就用站点的值;

    (4)如果当前角色、组、站点都没有值,则没有值使用。

    根据保护范围创建首选项:

    (1)管理员可以创建所有保护级别的首选项实例,包括站点、组、角色、用户的首选项。站点的首选项,影响到Teamcenter的整个站点,只有管理员可以创建和修改;

    (2)组管理员可以创建保护范围为组、角色和用户的实例;

    (3)普通用户只能创建保护范围是用户的实例。

    站点的首选项,影响到Teamcenter的整个站点。 只有管理员可以创建和修改

    例如:TC_show_open_in_nx_button,此首选项用于设置用户是否可以使用NX按钮,即控制用户是否可以在TC客户端中打开NX集成的选项。当值设置为false后,用户不能通过首选项界面添加NX按钮。

    3、首选项的使用界面

    打开菜单“编辑”,找到“选项”来进行首选项的使用。可以使用典型的首选项,搜索首选项,设置首选项的值,创建新的首选项,删除

    已经存在的首选项

    可以打开首选项的帮助文档,查看各类首选项的使用方法。

    preferences_manager工具

    作用:

    在新安装TC的时候合并首选项到数据库中,也可以用于TC升级的时候把历史的首选项转换为XML格式,从数据库中导出首选项,检查

    TC_DATA目录下的gpfiles/rpfiles/upfiles是否有数据,把这些首选项导入到数据库中,在%TC_ROOT%\bin下:

    Syntax:
    
    preferences_manager
    
    -u=user-name
    
    {-p=password | -pf=password-file}
    
    -g=group-name
    
    -mode= {append | category | cleanup | cleanup_definitions | clear | export |
    
    generatexml | import | migrate | delete | remove | upgradexml}
    
    [-h]
    

    4、 首选项的相关操作

    (1)创建首选项,填写首选项的名称、保护范围、描述、值,选择类别、

    环境变量、类型、是否多个值,填写好后单击“保存”按钮

    (2)修改首选项,查找到某个首选项后,单击“编辑”按钮,可以对首选项

    的相关属性值进行修改。

    (3)删除首选项,选择某一个待删除的首选项,单击删除按钮,删除此首

    选项

    5、 常用首选项举例

    下表是在TC系统中设置的常用首选项,通过系统配置,可实现对应的功能,构建站点级别的参数设置。

    image-20200621164050278

    HiddenPerspectives–隐藏功能模块

    AE_dataset_default_keep_limit数据集保存的版本数量。当超过这

    个数值以后,老的版本即被删除。

    5.2.3访问权限管理

    1、访问权限 在分布式计算机环境中,对象保护和所有权管理非常重要,对象代表了数据库中的产品信息,TC可执行两个层次的数据保护:基于规则的保护:作为-一个管理员,你可以定义多种条件或规则来控制对对象的访问,这些规则影响TC的整个节点,用访问控制器来定义。

    基于对象的保护:可更改对象访问控制权限的任何TC用户都可以设置基于对象的保护ACL (访问控制列表),来创建基于规则保护外的保护。当需要对具体的对象设置较宽松或较有限的访问权限时,对象的ACL非常有用,访问控制列表ACL显示了当前对一个对象的保护,并允许用户更改这些保护。初始的保护决定于规则树。

    image-20200621164235383

    image-20200621164245452

    2、访问管理器 在访问管理器规则树中来组织规则,并按照该规则在树结构中的位置起作用。TC安装时包括的默认规则树假定只要权限没被显示地拒绝,用户就拥有该访问权限。当应用于所选对象的条件满足时,在ACL中定义的权限将被使用。注意:在规则树中的子分支总是优先于父结构。

    image-20200621164330705

    创建和管理命名的ACL

    image-20200621164343069

    4、ACL 的优先级控制 对某一对象有效的ACL是在规则树中适用于该对象的所有命名的ACL的累积组合。ACL的优先级顺序:当判断规则树中的优先级顺序时, 遵守下列方针:

    • 子级优先于父级
    • 同级中上层高于下层.

    评价哪个权限最终被授予取决于两个标准,最终的结果是

    • 一个有效的ACL ,控制者对对象的访问。, 规则树中条件声明的优先级别
    • 命名的ACL中的访问者优先级别

    5、ACL指导方针

    • 不要删除或修改规则树中. 上面部分分支的顺序。这可能会导致不可预知的后果或丢失数据。
    • 在Working分支下为工作数据添加规则,这是为工作数据类型添加新规则的最合适的地方。 不要直接修改COTS规则(系统内置设置的规则) , 但是可以创建一个新的规则来代替它。
    • 在作修改前或后需要导出规则树备份。

    image-20200621164534006

    第六章

    BOM管理是PLM系统管理的核心之一。在产品生命的各个阶段,都有BOM的身影,因此我们必须掌握BOM的二次开发技能,以及对应的业务场景。本教程系列主要用于探讨BOM管理的基本业务,以及围绕BOM管理,可能涉及的开发知识点。 TC报表开发技术

    • BOM的概念及类型

  • BOM转换方式

  • TC报表生成方式

  • BOM开发过程

  • BOM开发关键技术

  • BOM开发技术比较

  • BOM的英文全称是Bill Of Material,中文名称是物料清单。BOM是一个比较宽泛的概念,根据不同的场景、用途,BOM又衍生出许多的种类。比如需求BOM、工程BOM、设计BOM、工艺BOM、制造BOM、装配BOM、客户BOM、销售BOM、维修BOM、采购BOM、成本BOM等等,因此BOM是无处不在的。从广义的角度上来说,BOM已经远远超出了物料清单的概念范畴,任何以父子结构呈现的树状数据结构,我们都认为是BOM的- -种表现形式。下图展示的是需求BOM,在Teamcenter 系统中,所有类型的BOM数据,大体上都是这种层级的表现形式。

    下面是几种常见的BOM类型,以及他们之间的基本转换进行初步的探讨,不一定适合 所有的行业或业务。 设计BOM:又称工程BOM,主要以产品结构、功能的角度组织数据,通常描述产品的设计指标,零件和零件之间的设计关系。设计BOM-般较少考虑加工工艺、装配工艺等。在设计员的眼中,它是- -件完美的艺术品,至于如何实现,能否实现考虑得较少。同时设计BOM一般会关联三维装配模型。

    工艺BOM:在设计BOM的基础之.上,由工艺设计部门根据企业生产工艺的要求,补充相关工艺特性后形成的。工艺BOM除了添加工艺路线、工艺定额等信息外,还可能涉及对设计BOM的结构进行调整,不过这种调整一~般是局部的。但是对于BOM而言,一旦调整结构,那么从调整零部件开始,其所有父级节点,都需要创建新的零部件对象,并重新装配。比如:某些零部件受限于工艺能力,不能完整加工,需要进行拆分加工,然后通过焊接工艺连接在一起,这类业务涉及的自制件,在企业中通常叫”拆件”’;另外有些零部件,从经济性,可加工性的角度考虑,可能需要多个零部件在-起生产,最后通过切割的方式得到设计零部件,这种业务涉及的自制件在企业中通常叫”合件”;工艺BOM大概率会新增原材料、辅料等,这些也会导致BOM结构的调整。

    装配BOM:在装配工艺的编制过程中,形成的产品、部组件的装配关系,反应的是装配顺序。比如,在设计上,部组件结构可能是多层BOM组成,但是装配工艺要求在-个装配工位,一次安装完成,这个时候需要将多层设计BOM,调整为单层的装配BOM,部分部组件对象就不体现在装配BOM中。

    制造BOM: -般来源于工艺部门编制的工艺卡片上的内容。主要包括零件加工工艺、部组件装配工艺、生产加工中零部件流转路线、以及每个BOM节点上关联的工装、设备、工时等信息。其主要作用是为ERP等软件生产计划等模块提供基础数据。目前大部分的Teamcenter软件并没有直接生成制造BOM,企业主要通过开发与ERP、MES等系统的集成接口,实现按需构建制造BOM,通过中间件的方式,向ERP、MES等系统传递制造BOM数据。因此ERP接口开发、MES接口开发是目前Teamcenter二次开发的重要内容。

    在讨论设计BOM、工艺BOM、装配BOM、制造BOM的过程中,BOM转换是客户关注的焦点。不同的行业、不同的企业,由于业务不一样、运营模式不一样、研发体系不-样等等,会导致BOM转换的需求和要求不一样,自然解决方案也不- -样。OOTB系统提供的BOM转换功能,无法满足企业需求,因此需要通过定制开发的方式实现。在探讨BOM开发之前,我们需要简单的了解,为什么需要进行BOM转换。有没有可能一个BOM通吃?如果产品特别简单,或许还是存在这种可能的。但是随着产品复杂度的增加,分工的增加,-套BOM打天下的局面是不可想象的。

    BOM转换中,除了拆件、合件,大部分的零部件对象,是不需要转换的。由于绝大部分部组件是新建对象,因此如果需要完整的三维装配模型,需要重新在三维软件中装配。设计BOM转装配BOM-般存在对三维模型的重新装配问题,用于指导三维装配工艺的编制。设计BOM转工艺BOM, - -般不会涉及对三维模型的操作,可以是-一个纯粹的不带三维信息的BOM。主要需要处理拆件、合件,添加原材料、辅料等对象。制造BOM一般由装配BOM、工艺BOM、工艺规程等组合而成,通过集成接口按一定的规则往 下游传递,-般不在Teamcenter系统中创建新的BOM数据。

    BOM报表系统既要统计出符合要求的数据,又要使生成的报表符合规定的格式,并且要嵌入Teamcenter系统运行,实现无缝集成。

    6.1.3 为什么需要报表开发

    每个企业都有自己的特定需求,Teamcenter中有自带的报表的导出方式和模板,TC中自带的报表导出已经不能满足企业的需求。这也是西门子提供二次开发的目的。报表的自动化、个性化生成对企业成功实施PDM系统有着重要意义。尽管TC中程序处理BOM方面功能非常强大,但由于企业内部各类报表都有固定的模版和格式,因此需要掌握BOM报表开发相关知识。.

    6.1.4 TC报表生成方式

    image-20200621194046940

    image-20200621194136136

    image-20200621194155240

    TC系统为我们提供了两种方式的报表:HTML、XSL 每种报表都有对多国语言支持版本,所以下面对话框中有4个选项,我们选第一个。

    image-20200621194235529

    通过开发生成报表的方法. 在现行的报表开发中,主要有以下三种开发方式:

    • 一、Java开发报表导出
    • 二、Java+VBA
    • ①导入到特殊格式时,需要打印
    • ②数据量很大的时候,执行效率高
    • ③需要电子签名
  • 三、C语言编程,EXE文件执行
  • image-20200621200117704

    image-20200621200127979

    1、POI技术 POI用法:

    Apache POI是用Java编写的免费开源的跨平台的Java API,Apache POI提供API给 Java程式对Mi crosoft 0ffice格式档案读 和写的功能。 Apache POI 是创建和维护操作各种符合Office Open XML(00XML)标准和微软的0LE 2复合文档格式(OLE2) 的Java API,用它可以使用Java读取和创建,修改Microsoft Excel 文件。

    POI用法:

    Apache POI可以到www. apache. org下载到。实际运行时,需要有POI包即可,Horrible SpreadSheet Format (HSSF) 提供给用户使用的对象在org. apache. poi. hssf. usermode1包中,主要部分包括Exce1对象,样式和格式,还有辅助操作。Excel文件的组织形式: 一个Excel文件对应于-一个workbook (HSSF Workbook) 一 个workbook可以有多个sheet(HSSF Sheet)组成,一个sheet是由多个row (HSSF Row)组成,一个row是由多个cell (HSSF Cell) 组成。

    POI用法: 创建一个Excel文件代码解析

    HSSFWorkbook wb= new HSSFWorkbook(); //创建WorkBook
    HSSFSheet sheet = wb. createSheet(' new sheet' ); //创建Sheet
    HSSFRow row= sheet. createRow( (short)0); //创建Row
    HSSFCell cell = row. createCell(0); //创建Cell
    cell. setCellValue("hello Excel"); //写入数据
    File0utputStream file0ut=new
    File0utputStream(“c:\\workbook. xls" ); //在C盘下建立文件
    wb. write(file0ut); //将信息流写入文件
    file0ut. close(); //关闭流
    

    POI用法: 读取一个Excel文件代码解析

    FileInputStream inputStream= new FileInputStream (" c: \\workbook. xls");
    HSSFWorkbook workbook = new HSSFWorkbook (inputStream) ;//创建WorkBook
    HSSFSheet sheet1 = workbook. getSheet(' new sheet" ); //获取Sheet
    HSSFRow row1 = sheet1. getRow(0); //获取Row .
    HSSFCell cel11 = row1. getCe11(0); //获取第-一个单元格
    String cellValue1 = ce111. getStringCel1Value( ); //获取单元格的值有关POI
    

    的详细用法,请登录到以下网址: http://poi. apache. org/

    2.使用BOM类创建BOM结构

    我们主要使用以下几个类读取BOM结构:

    TCComponentBOMWindowType、TCComponentBOM Window、TCComponentRevisionRule、TCComponentBOMLine。

    (1)创建BomWindow对象

    TCComponentBOMWindowType type = (TCComponentBOMWindowType)
    tcSession.getTypeComponent("BOMWindow");
    bomWindow = type.create(null); //使用默认的版本规则
    
    
    

    (2)设置版本规则 如果不使用默认的版本规则,需要替换其他版本规则的话,比如以下就是使用”Latest Working”版本规则。

        TCComponentRevisionRuleType ruleType = (TCComponentRevisionRuleType)
        tcSession. getTypeComponent("RevisionRule");
        TCComponent[] rules = ruleType.extent();
        for (inti= 0;i< rules.length;i++) { .
        String ruleName = rules[i].getProperty("object name");
        if("Latest Working".equals(ruleName)){
        TCComponentRevisionRule rule = (TCComponentRevisionRule) rules[i];
        bomWindow. setRevisionRule(rule);
        break; }
        }
    

    (3)加载顶层BOM行

    topBomline = bomWindow.setWindowTopLine(topRevision.getItem(),topRevision,null, null);
    topBomline.pack(); .
    

    BOM数据来源 TC BOM表中需要提取的信息可分为三部分:

    第一类信息是在PSE的BOMLine属性中的,这是BOMLine的固有属性,如bl_ item_ object_ name表明当前BOMLine的Item 的名称,bl_ _quantity表明当前BOMLine的数量属性等,这些在PSE中可以进行添加或者修改; 第二部分信息是BOMLine所对应的零/部件版本( Item、ItemRevision)本身的属性,如Owning User、date等,这些信息可以通过getProperty( )函数获得其值。

    第三部分信息存在于BOMLine所对应的Item Revision的Master Form表中,当用缺省的Item类型创建-一个零部件时,在查看器中显示的项目id、系列号等就属于Master Form表的信息,可以在浏览器中查看或者修改。要提取Master Form中包含的信息,首先必须通过BOML ine获取对应的Item Revision,然后通过Item Revision获取Master Form,最后通过此Form的getProperty( )方法来获得其Master Form的属性。

    TCComponentBOMLine bomline = (TCComponentBOMLine)
    bomlineelement( );
    TCComponentItemRevision irev = ( TCComponentItemRevision)
    Bomline.getItemRevision( );
    / /通过BOMLine获取对应的Item Revision
    AIFComponentContext [ ] irm= irev.getChildren( IMAN master form_ rev);
    / /通过Item Revision获取Master Form
    TCComponentForm mf = ( TCComponentForm) irm[0].getComponent( );
    String serial_ number = mf.getProperty("user_ data_ 1").toString( );
    1 /getProperty( )方法来获得其Master Form的属性
    
    

    要进行BOM汇总必须对PSE中的产品结构进行遍历,遍历BOM有两种递归方式:深度优先遍历算法(BFS)和广度优先遍历算法(DFS)

    深度优先遍历算法(BFS)以产品结构树中的零/部件是否有子件为递归条件,充分展现了零/部件间的层次关系和BOM树的结构。该算法的优点是程序简单,但由于是递归调用,涉及到堆栈的操作,在进行深层次遍历时,系统消耗的资源会很大。

    程序代码逻辑:
    private void BomBFS(TCComponentBOMLine
    parent) {
    //优先遍历
    if (parent.hasChildren() {
    AlFComponentContext[ children =
    parent.getChildren();
    for (inti= 0; i< children.length; i++){
    InterfaceAlFComponent tcComp =
    children[i].getComponent();
    TCComponentBOML ine childBomline =
    (TCComponentBOML ine) tcComp;
    BomBFS(childBomline)
    }
    } // 处理业务逻辑
    }..
    
    

    广度优先遍历算法(DFS)首先访问层次数为0的根节点,然后访问层次数为1的所有节点,依次逐层往下遍历直到访问完最后一层的所有节点。

    程序代码逻辑:

    private void BomDFS(TCComponentBOMLine parent) {
    AIFComponentContext0 children =
    parent.getChildren();
    if (children != null){ // 优先处理单层BOM业务逻辑
    for (int i= 0; i < children.length; i++) {
    InterfaceAlFComponent tcComp =
    children[i].getComponent();
    TCComponentBOMLine childBomline =
    (TCComponentBOMLine) tcComp;
    } //下面开始遍历
    for (inti= 0; i< children.length; i++){
    InterfaceAlFComponent tcComp =
    children[i].getComponent();
    TCComponentBOML ine childBomline =
    (TCComponentBOMLine) tcComp;
    BomDFS(childBomline)
    }
    }
    }
    
    

    BOM遍历算法 鉴于BOM汇总是由各项目下的子类逐层向父类归并的情况,同时考虑到企业的BOM汇总中明细表项目较多、层次较浅(- -般为3~ 4层)的特点,本文BOM开发采用深度优先遍历算法,由( TCComponentBOMLine )aifcomponentcontexts[0].getComponent( )获取选定的根节点,利用getChildren( )的方法获取根的子节点,对于每-一个子节点重复利用函数getChildren( )的方法获得其子组件,如此循环下去直到没有子节点,完成BOM的遍历。

    由于事先无法预知BOM汇总中零/部件的具体数量,所以可以用数组来容纳所汇总的零/部件信息是不现实的,而且数组-般只能存放-种类型的数据,而在产品信息中数据类型显然不能是单一的,因此采用Vector类来解决汇总过程中的数据存放问题。

    image-20200621200906710

    操作步骤: 获取Teamcenter数据,以获取Teamcenter中 Item的属性为例。 Step1.获取Item,

    public static TCComponent[ ] getItem (String[ ]names, String [ ]values, String
    queryname) throws TCException
    TCSession session = (TCSession) AIFUtility. getDefaultSession() ;
    TCComponentQueryType querytype = (TCComponentQueryType)
    session. getTypeComponent (" ImanQuery' ) ;
    TCComponentQuery query =(TCComponentQuery) querytype. find (queryname) ;
    TCQueryClause[] Clause = query. describe() ;
    for (int i = 0; i < names. length; i++) {
    for (int m = 0; m < Clause. length; m++) {
    if (names [i]. equals (Clause [m]. getUserEntryName ()) {
    names[i] = Clause [m]. getUserEntryNameDisplay
    break;
    }
    }
    return query. execute (names,values) ;
    

    2-获取Item的属性。

    public static String[ ] getProperties (TCComponentItem item, String [ ] properties) {
    String [ ] values=null;
    try {
    values=i tem. getProperties (properties) ;
    } catch (Exception e) {
    e. printStackTrace () ;
    return values ;
    }
    
    

    3.在Teamcenter NewStuff下新建文件夹用于存放文件。

    public static TCComponentFolder getFolder (String foldername) {
    TCSession
    session = (TCSession) AIFUtility. getDefaultSession() ;
    TCComponentFolder newStuff = null;
    TCComponentFolder newFolder = null;
    newStuff=TCComponentFolder. getNewStuffFolder (session) ;
    TCComponentFolderType createFolderType
    = (TCComponentFol derType) session. getTypeComponent (" Folder") ;
    newFolder=createFolderType. create (foldername,"", ” Folder") ;
    newStuff. add(" contents",newFolder) ;
    return newFolder ;
    }
    
    

    Step4:把i tem属性写入C:\temp路径下的temp. xls中。

    public void writeToExcel(String[ properties){
    FileOutputStream fos= =null;
    HSSFWorkbook xlss =new HSS FW orkbook(;
    HSSFSheet sheet=xlss.createSheet0;
    HSS FRow row=sheet.createRow(0);
    row.createCell(0).setCellValuet("item_ id");
    row.createCell(1 ).setCellValue("object_ name");
    row.createCell(2).setCelIValue("creation_ date");
    row.createCell(3 ).setCellValue("current_ id");
    HSSFRow row1=sheet.createRow(1);
    row1.createCell(0).setCellValue(properties[0]);
    row 1.createCell(1).setCellValue(properties[1]);
    row 1.createCell(2).setCellValue(properties[2]);
    row 1.createCell(3).setCellValue(properties[3]);
    File xls_ file=new File(tempfile); 1/指定写 入路径
    fos=new FileOutputStream(xls_ file);
    xlss.write(fos);
    }
    

    Step5:将建立的临时excel文件导入到TC中。

    public static TCComponentDataset createDataset (TCSession session, String path,
    String dType, String dRef,String dName,TCComponentFolder folder, boolean
    replaceA1ert)
    {
    TCComponentDataset datasetcomponent nul1 ;
    TCComponentDatasetType TCDatasetType= (TCComponentDatasetType)
    typeService. getTypeComponent (datasetType) ;
    String filepathnames[]= {path} ;
    String nameRefs []= {dRef};
    datasetcomponent=TCDatasetType. setFiles (dName,null, dType, filepathnames,
    nameRefs) ;
    folder. add(" contents',datasetcomponent) ;
    return datasetcomponent ;
    }
    

    Step6: 创建报表的界面。

    image-20200621201516481

    Step7: 生成的临时文件。

    Step8: TC中创建的报表。

    <?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.addbutton.commands.sampleCommand">
            </command>
        </extension>
        <extension point="org.eclipse.ui.handlers">
            <handler
                     commandId="com.mycom.addbutton.commands.sampleCommand"
                     class="com.mycom.addbutton.handlers.SampleHandler">
            </handler>
        </extension>
        <extension point="org.eclipse.ui.menus">
            <menuContribution
                              locationURI="toolbar:navigator_Toolbar?after=additions">
                <command
                         commandId="com.mycom.addbutton.commands.sampleCommand"
                         icon="icons/sample.gif"
                         tooltip="Say hello world"
                         id="com.mycom.addbutton.toolbars.sampleCommand">
                    <visibleWhen>
                        <reference
                                   definitionId="com.teamcenter.rac.ui.inMainPerspective">
                        </reference>
                    </visibleWhen>
                </command>
            </menuContribution>
        </extension>
    </plugin>
    
    </div>
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值