20180411开发培训TC内部培训资料Teamcenter Customization Training - Rich client_第1页
20180411开发培训TC内部培训资料Teamcenter Customization Training - Rich client_第2页
20180411开发培训TC内部培训资料Teamcenter Customization Training - Rich client_第3页
20180411开发培训TC内部培训资料Teamcenter Customization Training - Rich client_第4页
20180411开发培训TC内部培训资料Teamcenter Customization Training - Rich client_第5页
已阅读5页,还剩87页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

TeamcenterRichclientCustomizationTrainingfor10.1,Prerequisites,PrerequisitesKnowledgeTeamcenterApplicationAdministrationTeamcenterProductDataManagementProficiencyinJavaprogrammingCprogramminglanguageexperienceRequiredSoftwareOracle11gTeamcenter10.1(includingadministratorrichclient,onlinehelp,samplefiles)MicrosoftVisualStudio.NET2010JDK1.7Eclipse3.8TextEditor(Notepad,EditPlus,UltraEdit,etc.),TeamcenterRichClientClient-ServerLayer,Teamcenterclient与server端均可客户化Clientlayer:用户接口层,采用Java语言Serverlayer:服务器层,采用IntegrationToolkit(ITK)与C语言,BusinessModelerIDE,Exercise1,找出你的Teamcenter环境变量设置Teamcenter客户化需要的环境变量与对应的文件夹使用BMIDE查看常见对象对应的类,Teamcenter缺省环境变量,缺省环境变量的定义在%TC_DATA%tc_profilevars.bat,TeamcenterClassHierarachy,Teamcenter为面向对象(object-oriented)的系统属性(attributes)与方法(method)都是继承到子类(subclasses)API并没有每一个class均有提供,子类可以使用父类的API,RichClientProgrammingEclipseEnvironment,Eclipse的介绍Eclipse是著名的跨平台的自由集成开发环境(IDE)。最初主要用来Java语言开发,但是目前亦有人通过插件使其作为其他计算机语言比如C/C+、Perl和Python等等的开发工具。Eclipse的本身只是一个框架平台,但是众多插件的支持使得Eclipse拥有其他功能相对固定的IDE软件很难具有的灵活性。许多软件开发商以Eclipse为框架开发自己的IDE。,RichClientProgrammingEclipseEnvironment续1,Eclipse开发环境设置展开Eclipse的Window菜单,选择Perference设定Java的InstalledJREs环境设定Plug-inDevelopment的TargetPlatform的Location为TeamcenterRichClient目录,RichClientProgrammingEclipseEnvironment续2,RichClient开发步骤新增Plug-inProject输入ProjectName(譬如com.customer)选择TargetPlatformEclipse的版本选择产生Activator选择此plug-in将传递到UI选择不要建立一个richclientapplication,RichClientProgrammingEclipseEnvironment续3,RichClient开发步骤展开META-INF文件夹,双击MANIFEST.MF,RichClientProgrammingEclipseEnvironment续4,RichClient开发步骤在Dependencies页签加入以下RequiredPlug-moncom.teamcenter.rac.externalcom.teamcenter.rac.kernelcom.teamcenter.rac.nevacom.teamcenter.rac.tcappscom.teamcenter.rac.util,RichClientProgrammingEclipseEnvironment续5,RichClient开发步骤在Runtime页签加入ExportedPackages:com.customer,RichClientProgrammingEclipseEnvironment续6,设置targetpaltform,指定为teacmenterclient的pluginfolder,RuntherichclientfromEclipse,InEclipse,chooseRunDebugConfigurations.,RichClientProgramming,Encoding编码Compiling编译Packaging打包(使用Eclipse自动会处理)Packaging打包展开Eclipse的File菜单,选择Export.选择Plug-inDevelopment内Deployableplug-insandfragments选择要打包的project指定Destination可直接指定Teamcenterrichclient文件夹,Eclipse会自动把jar放到plugins子文件夹执行genregxml如果有修改properties文档,必须执行TC_ROOTportalregistrygenregxmlDeploy部署two-tierrichclient将打包后的jar文件放到RichClient安装目录的子文件夹plugins内four-tierrichclient新增.icd文件,定义一个solution利用WebApplicationManager打包richclientinstance利用OTW发布,RichClientProgramming,Exercise2,配置Eclipse开发、调试环境,TeamcenterClass,TCComponentTCComponentItemTCComponentItemRevisionTCComponentItemTypeTCComponentFolderTypeTCComponentUserTCComponentPersonTCComponentGroupTCComponentRoleTCComponentFormTCComponentBOMWindowTCComponentRevisionRuleTCComponentwhereReferencedwhereReferencedByTypeRelationgetChildrengetProperty,TeamcenterUIComponents,iTextFieldJCheckBoxJFileChooserJButtonJPanelJLabelJTextAreaLOVComboBox,LOVUIComponent,TCComponentListOfValuesJTable,GenericTableModelJDialogDateButtonJtree,TeamcneterHow-To获得TeamcenterClientsession,如果需要建立objects或是searchobjects,必须先获取目前client的session,我们可以通过以下的方式来获取ISessionServiceiss=AifrcpPlugin.getSessionService();TCSessionsession=(TCSession)iss.getSession(com.teamcenter.rac.kernel.TCSession);一般在Handler通过如下方法获取:AIFDesktopaifdesktop=AIFDesktop.getActiveDesktop().getDesktopManager().getActiveDesktop();application=aifdesktop.getCurrentApplication();session=(TCSession)application.getSession();,TeamcneterHow-TogetselecteditemsfromUI,从TeamcenterUI中,用户点选Itemorformorfolder,我们可以通过以下的方式得到选取的objectsStructuredSelectioniselection=(StructuredSelection)HandlerUtil.getCurrentSelection(event);Iteratorit=iselection.iterator();AIFComponentContextcompContext=(AIFComponentContext)it.next();TCComponenttccomp=(TCComponent)compContext.getComponent();也可以:AIFDesktopaifdesktop=AIFDesktop.getActiveDesktop().getDesktopManager().getActiveDesktop();application=aifdesktop.getCurrentApplication();AIFComponentContextaif=application.getTargetContexts();,TeamcneterHow-To建立Item、Form、orFolder,建立ItemorFormorFolder分别需要通过以下的方式来建立,例如TCComponentItemTypetccomponentItemType=(TCComponentItemType)session.getTypeComponent(Item);TCComponentItemtccomponentitem=tccomponentItemType.create(ITEMID,REVID,ITEMTYPE,OBJECTNAME,DESC,null);,TeamcneterHow-To获得Currentusersnewstufffolder,通过以下的方式,可以获取目前的sessionuser所属的newstufffolder,并将objects粘贴在这个folder下TCComponentFoldertcfolder=newTCComponentFolder();TCComponentFoldernewstuffFolder=tcfolder.getNewStuffFolder(session);newstuffFolder.add(contents,tccomponentitem);,Exercise3,请建立一个CreateItemAndProcesstHandler.java,并且可以达到以下的需求在menubar加入一个选单,增列一个CreateItemCommand的功能创建一个Item,请自行定义id、revid、objectname将新建立的item粘贴在newstufffolder,TeamcneterHow-Toset/getobjectsproperties,在设定objectsproperties时,必须注意当有大批量的properties要设定值时,最好采取以下的方式TCFormPropertyps=f.getAllFormProperties();/Getthepropertytosetps0.setStringValueData(“abc”);/Setsthevaluebutisnotsaved.ps1.setStringValueData(“def”);/Setsthevaluebutisnotsaved.f.setTCProperties(ps);/Nowissavedtothedb当properties数量不大时,则可以采用以下的方式TCFormPropertyp=f.getFormTCProperty(“my_prop_name”);/Getthepropertytosetp.setStringValue(“abc”);/Setit.Atthispointitissavedtothedb.针对不同型态的property,使用的method也会不一样,例如string、integer、orReference,TeamcneterHow-TofinduserbyID,可以用以下的方式来查询已知的UserTCComponentUserTypetccUserType=(TCComponentUserType)session.getTypeComponent(User);tccUser0=tccUserType.find(dbauser);,TeamcneterHow-Toset/getarrayproperty,Teamcenter中可以定义array型态的属性,可以通过以下的方式来获取或是设定属性值tcpropsi.setReferenceValueArrayData(tccUser);tcpropsi.getReferenceValueArray();,Exercise4,请建立一个SetAndGetPropsValue.java,并且可以达到以下的需求建立新的Item类,MyItem,并在MyItemRevision上定义两种类型的属性,一个是TypeReference(User),一个是Stringarray将BMIDE储存并布署到server搜寻到一个TCComponentUser,并将这个object的reference存放到新建的TypeReference属性中将自定的字符串array存放到新建的Stringarray中修改objectname以及objectdescription,自定义设定值必须使用setTCProperties做为最后的储存method,TeamcneterHow-Togetobjectsbyrelations,在Teamcenter中,对象与对象有关联的关系,例如whereReferenced,IMAN_reference,IMAN_specification,可以根据这样的关系,抓到关联的objects建议都使用getRelatedComponents,因为这个method不会受到preference的影响TCComponenttccomps=tccomp.getRelatedComponents();如果要抓取被引用objectsreferenced,则可以用以下的methodAIFComponentContexttccomps3=tccomp.whereReferenced();如果要抓取当前对象被哪些对象使用,则可以用以下的methodTCComponenttccomps2=tccomp.whereUsed(TCComponent.WHERE_USED_ALL);,TeamcneterHow-Toexport/importfiles,将localfiles存放到Teamcenter,必须通过Dataset的形式来储存,可以用以下的方式来实现TCComponentDatasetTypetcDatasettype=(TCComponentDatasetType)session.getTypeComponent(Text);TCComponentDatasettcDataset=tcDatasettype.create(textobjname,textobjdesc,Text);tcDataset.setFiles(newStringFULLFILEPATH,FILEFORMAT,newStringPlain,FILEREFERENCE);将Dataset中存放的files汇出到localdisk中TCComponentTcFiletcFiles=tcdataset.getTcFiles();tcFilesj.getFile(LOCATIONTOSTOREFILES);,Exercise5,请建立两个ExportFileHandler.java和ImportFileHandler.java,并且可以达到以下的需求Import两个dataset,一个是Text一个是MSExcel,并将localfiles储存到这两个dataset中将datasets粘贴到MyItemRevision下点选MyItemRevision,并将粘贴在下面的Dataset汇出到localdisk,RichClientProgrammingCreatingaView,Addaorg.eclipse.ui.viewsCreatedefinitions,RichClientProgrammingCreatingaView续1,SetactivepartidCommandonlybeactivatedwithCustomViewDefineacustomviewcommand,RichClientProgrammingCreatingaView续2,CreateaCustomViewhandler,Exercise6,建立一个CustomViewHandler.java显示出Hellowworld讯息窗口只有在用户点选了MyCustomView才会显现这个command建立一个CustomView.java可以显现在windows-view的选单中用户点选一个object时,可以通过getChild()打印出子对象在view中,RichClientProgrammingCreatingaRichClientApplicationandSendtoApplication(很少用到,了解即可),Defineacom.teamcenter.rac.aifrcp.applicationDefineaorg.eclipse.ui.perspectives,RichClientProgrammingCreatingaRichClientApplicationandSendtoApplication续1(很少用到,了解即可),DefineaSendtoapplicationmenuDefineahandlerfor“Sendtoapplication”,RichClientProgrammingCreatingaRichClientApplicationandSendtoApplication续2(很少用到,了解即可),Defineacommandfor“SendtoApplication”Defineadefinitionfor“SendtoApplication”请参考批注中的说明,Exercise7(很少用到,了解即可),建立一个CustomPerspective.java建立一个Sendtoapplication,Exercise7(很少用到,了解即可),利用前述的步骤,定义出如下的application,RichClientProgrammingCustomizeShortcutMenus,选择TCTree或TCTable上的component按鼠标右键弹出的菜单,即为shortcutmenu注册CustomizingPopupMenuCreateamenucontributionCreateacommandunderthemenucontribution,RichClientProgrammingCustomizetheToolbar,修改现有application的Toolbar(以MyTeamcenter示例)CreateamenucontributionCreateatoolbarunderthemenucontributionCreateacommandunderthetoolbar,Exercise8,在myteamcenter窗口中建立一建立一个toolbar按鈕在实现以下的需求弹出窗口显示选择的对象类型如果没有选择对象则提示错误,RichClientProgrammingCustomizeFormandPropertiesDisplay,Teamcenter支持以下四种方式的表单客户化Abstractrendering允许延伸AbstractRendering类编写表单显示。这是最有弹性的做法,同时也是最复杂且需要写程序的方法JavaBean(少用到)允许使用JavaBean与一个IDE(譬如Eclipse)去显示表单属性。每一个JavaBean知道如何取显示与保存指定的属性类型。这方法稍微复杂,但是仍旧需要编写程序XMLstylesheet(不经常用)允许利用PredefinedXMLstylesheet的方式订是表单的显示,包含显示的顺序与涂彩的方式Automaticforms不需要任何定义,系统自动显示所有的表单属性,包含继承下来的POMclass属性,RichClientProgrammingAutomaticForms,使用BMIDE定义表单的类属性,与类型使用BMIDE定义表单属性的显示名称,RichClientProgrammingFormsUsingXMLStyleSheet,使用BMIDE定义表单的类属性,与类型使用XMLRenderingStyleSheet数据集来定义表单属性显示的顺序与涂彩的方式,RichClientProgrammingFormsUsingXMLStyleSheet续1,ModifytheSummary/ViewerpaneinMyTeamcenter系统采用PredefinedXMLStyleSheet的方式显示对象的内容,利用XMLRenderingStyleSheet这类dataset控制对象的显示方式。一般对象有两种显示的设置:Summary显示摘要信息,Viewer显示所有属性信息表单对象有三种显示的设置:Summary显示摘要信息,Viewer显示表单专有属性信息,Properties显示所有属性信息XMLRenderingStyleSheet注册信息储存于Preference,属于DBA群组的使用者才有权限修改显示Property的注册语法.RENDERING=.REGISTEREDTO=显示Summary的注册语法.SUMMARYRENDERING=.SUMMARY_REGISTEREDTO=显示Form的注册语法.FORMRENDERING=.FORM_REGISTEREDTO=,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter变更Summary/Viewer显示步骤以DBA群组登入系统中,新增或选择XMLRenderingStyleSheet数据集切换到Viewer窗格编写XML的内容选择要注册的对象类型,并指定StylesheetType为Property、Form或SummaryXMLelements包含pageTitleformatfirstcolumnsecondcolumnpropertyseparatorall等DisplayFormatRichClient支援OneColumn与TwoColumnThinClient只支援OneColumn,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter,RichClientProgrammingFormsUsingXMLStyleSheet续2,ModifytheSummary/ViewerpaneinMyTeamcenter,RichClientProgrammingFormsUsingXMLStyleSheet续3,ModifytheSummary/ViewerpaneinMyTeamcenter每一个renderinghint所使用的JavaBeansclass定义在mon_.jar的packagecom.teamcenter.rac.stylesheet文件perties可自订renderinghint所使用的JavaBeansclass修改com.teamcenter.rac.stylesheet内文件stylesheet_perties语法rendering-hint.DEFINITION=rendering-hint_titled.DEFINITION=,RichClientProgrammingFormsUsingXMLStyleSheet续4,ViewerPane示例,RichClientProgrammingFormsExtendingAbstractRendering,使用BMIDE定义表单的类属性,与类型建立FormPanel注册FormPanel修改packagecom.teamcenter.rac.stylesheet内stylesheet_perties文件语法.FORMJAVARENDERING=在packagecom.customer.stylesheet建立FormPanel的class文件ExtendAbstractRenderingclassTwomethodsarerequiredtoimplement:loadRendering()andsaveRendering()Executegenregxml.bat,RichClientProgrammingFormsExtendingAbstractRendering续2,AbstractRenderingContructor.TogetformcomponentloadRendering.ToinitializeformUI.Whenuserclickonviewtabordoubleclickonform,themethodiscalled.saveRendering.Tosaveformdata.WhenuserclickonSavebutton,themethodiscalled.setRenderingReadWrite.Toenable/disableUIcomponentsintheform.,RichClientProgrammingFormsExtendingAbstractRendering续2,FormPanel的写法获取TCProperty由属性名称属于单一propertyTCComponentForm.getFormTCProperty(“property_name”)获取所有propertiesTCComponentForm.getAllFormProperties()获取TCProperty属性值getValue()或getValueArray()设定TCProperty属性值setValue()或setValueArray()设定属性值且立即保存setValueData()或setValueArrayData()设定属性值,但必须setTCProperty()或setTCProperties()才保存。一次保存所有的属性值,程序效能会比较好,RichClientProgrammingFormsExtendingAbstractRendering续3,FormPanel的写法接口上尽量使用系统提供的classpackagecom.teamcenter.rac.formpackagecom.teamcenter.rac.util,RichClientProgrammingFormsExtendingAbstractRendering续4,程序框架publicclassMyFormextendsAbstractRenderingpublicMyForm(TCComponentFormc)throwsException/加载时调用loadRendering();publicvoidloadRendering()throwsTCExceptionpublicvoidsaveRendering()/保存时自动调用,RichClientProgrammingFormsExtendingAbstractRendering续4,加载publicvoidloadRendering()throwsTCExceptionsetLayout(newVerticalLayout();/布局管理器JPanelmainPanel=newJPanel(newPropertyLayout();projectId=newJTextField(26);/控件serialNo=newJTextField(20);mainPanel.add(1.1.right.center,newJLabel(ProjectID);mainPanel.add(1.2.left.center,projectId);mainPanel.add(2.1.right.center,newJLabel(SerialNumber);mainPanel.add(2.2.left.center,serialNo);add(unbound.bind,mainPanel);piProperty=form.getFormTCProperty(“project_id”);/加载属性snProperty=form.getFormTCProperty(serial_number);projectId.setText(piProperty.getStringValue();serialNo.setText(snProperty.getStringValue();,RichClientProgrammingFormsExtendingAbstractRendering续5,加载publicvoidsaveRendering()piProperty.setStringValueData(projectId.getText();snProperty.setStringValueData(serialNo.getText();TCPropertyps=newTCProperty2;ps0=piProperty;ps1=snProperty;form.setTCProperties(ps);,RichClientProgrammingFormsUsingJavaBeans(了解即可),使用BMIDE定义表单的类属性,与类型建立FormPanel注册FormPanel修改packagecom.teamcenter.rac.stylesheet内stylesheet_perties文件语法.FORMJAVARENDERING=在packagecom.customer.forms建立Form的class文件ExtendJPanelclassimplementtheInterfacePropertyComponentandInterfaceBufferedPropertyComponentinterface,Exercise9,新增一个表单类型,并使用XMLstylesheet方式显示表单属性新增一个表单类型,并使用extendAbstractRendering方式显示表单属性使用iTextField,iComboBox在form的UI上,RichClientProgramming报表,POI包(操作Excel)org.apache.poi.hssf.util.HSSFWorkbookorg.apache.poi.hssf.util.HSSFSheetorg.apache.poi.hssf.util.HSSFROWorg.apache.poi.hssf.util.HSSFCell增加对poi包的引用plugin.xml-Runtime-libpoi.jar,RichClientProgramming报表,POI包(操作Excel)HSSFWorkbookwb=newHSSFWorkbook();HSSFSheetsheet=wb.createSheet(newsheet);HSSFRowrow=null;HSSFCellStylestyle=wb.createCellStyle();HSSFCellcell=row.createCell(short)1);cell.setCellValue(X);cell.setCellStyle(style);/Orangeforeground,foregroundbeingthefillforegroundnotthefontcolor.style=wb.createCellStyle();style.setFillForegroundColor(HSSFColor.ORANGE.index);style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);for(intx=0;x1000;x+)/Createarowandputsomecellsinit.Rowsare0based.row=sheet.createRow(short)k);for(inty=0;y100;y+)cell=row.createCell(short)k);cell.setCellValue(X);cell.setCellStyle(style);/WritetheoutputtoafileFileOutputStreamfileOut=newFileOutputStream(workbook.xls);wb.write(fileOut);fileOut.close();,RichClientProgramming报表,POI包(Excel-样式)/设置字体;HSSFFontfont=workbook.createFont();/设置字体大小;font.setFontHeightInPoints(short)15);/设置字体名字;font.setFontName(CourierNew);/设置样式;HSSFCellStylestyle=workbook.createCellStyle();/设置底边框;style.setBorderBottom(HSSFCellStyle.BORDER_THIN);/设置底边框颜色;style.setBottomBorderColor(HSSFColor.BLACK.index);/设置左边框;style.setBorderLeft(HSSFCellStyle.BORDER_THIN);/设置左边框颜色;style.setLeftBorderColor(HSSFColor.BLACK.index);/设置右边框;style.setBorderRight(HSSFCellStyle.BORDER_THIN);/设置右边框颜色;style.setRightBorderColor(HSSFColor.BLACK.index);/设置顶边框;style.setBorderTop(HSSFCellStyle.BORDER_THIN);/设置顶边框颜色;style.setTopBorderColor(HSSFColor.BLACK.index);/在样式用应用设置的字体;style.setFont(font);/设置自动换行;style.setWrapText(false);/设置水平对齐的样式为居中对齐;style.setAlignment(HSSFCellStyle.ALIGN_CENTER);/设置垂直对齐的样式为居中对齐;style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);,Exercise10,Myteamcenter中增加菜单生成excel前提条件:必须选择一个对象将选择的对象的名称输入到excel中在home下生成excel数据集,并将excel文件导入到数据集中对于没有安装excel的电脑能否正常生成报表?,RichClientProgrammingSWT开发简述,TC9.1中的界面开发将逐渐过渡到SWTSWT编程基础Display和Shell控件布局对话框,RichClientProgrammingSWT开发简述-Display和Shell,Display的创建:Displaydisplay=Display.getDefault();或者Displaydisplay=newDisplay();Shell的创建和配置:Shellshell=newShell(display);/创建一个窗口shell.setSize(100,100);/设置窗口尺寸shell.open();/打开窗口shell.layout();/布局,RichClientProgrammingSWT开发简述-控件,控件实例的构造:Control(Controlparent,intstyle);第一个参数指明了控件的父资源;第二个参数指明控件的样式。Labelname=newLabel(shell,SWT.NONE);SWT.SINGLE单行SWT.BORDER边框SWT.MULTI多行,控件的释放:Control.dispose();最好不要手动释放一个控件,而应该交由SWT系统自动释放。,RichClientProgrammingSWT开发简述-控件,Button、Label、TextListCombo对话框,RichClientProgrammingSWT开发简述-布局,标准的SWT布局类FillLayout:在容器中以相同的大小单行或单列的排列组件RowLayout:以单行或多行的方式使用几个选项(fill,wrap,spacing,justify,type)定制组件的排列方式GridLayout:类似于swing的GridLayout的方式以格子的方式排列组件FormLayout(SWT2.0的新特性):通过定义组件四个边的“粘贴”位置来排列组件,被引用的相对的组件可以父组件,也可以是同一容器中的其它组件。参考代码登入窗口,RichClientProgrammingSWT开发简述-布局,布局实施1.首先定义窗口和它的空白边Display.getDefault().dispose();/移去平台核心启动画面display=newDisplay();shell=newShell(display,SWT.TITLE);FormLayoutlayout=newFormLayout();layout.marginHeight=10;layout.marginWidth=20;shell.setLayout(layout);shell.setText(用户登录);。,RichClientProgrammingSWT开发简述-布局,布局实施2.创建窗口上的元素,其中下面的两个button由一个使用RowLayout的组件来包容。name=newLabel(shell,SWT.NONE);name.setText(用户名);nameText=newText(shell,SWT.SINGLE|SWT.BORDER);pass=newLabel(shell,SWT.NONE);pass.setText(密码);passText=newText(shell,SWT.SINGLE|SWT.BORDER);passText.setEchoChar(*);passText.setTabs(2);bottom=newComposite(shell,SWT.NONE);RowLayoutrowLayout=newRowLayout();rowLayout.justify=true;/justify定义组件在容器中分散开,效果类似于swing的FlowLayoutbottom.setLayout(rowLayout);。,RichClientProgrammingSWT开发简述-布局,布局实施2.创建窗口上的元素,其中下面的两个button由一个使用RowLayout的组件来包容。name=newLabel(shell,SWT.NONE);name.setText(用户名);nameText=newText(shell,SWT.SINGLE|SWT.BORDER);pass=newLabel(shell,SWT.NONE);pass.setText(密码);passText=newText(shell,SWT.SINGLE|SWT.BORDER);passText.setEchoChar(*);passText.setTabs(2);bottom=newComposite(shell,SWT.NONE);RowLayoutrowLayout=newRowLayout();rowLayout.justify=true;/justify定义组件在容器中分散开,效果类似于swing的FlowLayoutbottom.setLayout(rowLayout);。,RichClientProgrammingSWT开发简述-布局,布局实施3.定义name标签的位置。它的顶边离父组件(窗口shell)的空白边距离是父组件clientArea(除空白边以外的空间)高度(height)的15%,偏移的点数(points)为0。FormDatadata=newFormData();data.top=newFormAttachment(15,0);name.setLayoutData(data);。,RichClientProgrammingSWT开发简述-布局,布局实施4.定义name文本输入的位置。它的顶边在name标签的中心位置(这不是正确的表达,但程序是这样解释,事实上它的中心位置与name标签在同一条水平线上),左边距name标签的右边有10个点。data=newFormDa

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论