Windchill MVC组件开发

  1. 注册Action
    通常是在WT_HOME/codebase/config/actions/custom-actionModels.xml在这里插入图片描述
    界面效果:
    在这里插入图片描述
  2. Action指向页面(第一步只是告知有这个入口,入口具体做的动作是action里面要做的)
    custom-actions.xml 文件中对三个搜索的子功能进行注册在这里插入图片描述
    MVC组件–table的注册到系统(jca-mvc.xml):
    在这里插入图片描述
  3. 前台页面引入windchill的MVC组件:
    在这里插入图片描述
    前台页面效果:
    在这里插入图片描述
  4. 对应后台代码
    在这里插入图片描述

数据处理方法:
在这里插入图片描述
组件定义,以及列定义的方法:

@Override
	public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException {
		if (log.isDebugEnabled()) {
			log.debug("WhereUsedTreeBuilder - Entering buildComponentConfig");
		}
		if (log.isTraceEnabled()) {
			log.trace("WhereUsedTreeBuilder.buildComponentConfig input params " + params);
		}
		String whereUsedTableID = "";
		NmHelperBean helper = ((JcaComponentParams) params).getHelperBean();
		NmCommandBean commandBean = (NmCommandBean) helper.getNmCommandBean();
		NmSessionBean sessionBean = helper.getNmSessionBean();
		ComponentConfigFactory factory = getComponentConfigFactory();
		JcaTreeConfig treeConfig = (JcaTreeConfig) factory.newTreeConfig();
		Object context = commandBean.getPageOid().getRef();

		// boolean configurable = false;
		// if the context object is in a project, set the table values appropriately (do
		// not show the drop down, and make the table view to "Latest" only
		if (EnterpriseHelper.isProjectLink((Persistable) context)) {
			whereUsedTableID = "whereUsed";
		}
		// if the context object is not in a project, set the table values appropriately
		// (show the drop down,
		// and make the table view to "Latest" and "All Revisions"
		else {
			whereUsedTableID = "whereUsed.view";
		}
		if (commandBean.getTextParameter("viewchange") != null) {
			sessionBean.removeAllNodes(commandBean, "whereUsed.view");
		}

		params.setAttribute("whereUsedTableID", whereUsedTableID);
		treeConfig.setId(whereUsedTableID);

		treeConfig.setShowCustomViewLink(false);
		treeConfig.setNodeColumn(DescriptorConstants.ColumnIdentifiers.NUMBER);
		treeConfig.setExpansionLevel(DescriptorConstants.TableTreeProperties.FULL_EXPAND);
		treeConfig.setTargetObject("contextObject");
		treeConfig.setLabel(messageWhereUsedResource.getMessage(PartListSearchResource.PRIVATE_CONSTANT_CS_6));
		treeConfig.setSelectable(true);
		treeConfig.setActionModel("whereUsedTablePart");
		log.debug("set Tree setSelectable & ExpansionLevel is true,NodeColumn is NUMBER.");

		// Define the columns present for when no view is used
		ColumnConfig col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.NUMBER, true);
		col.setWidth(200);
		col.setInfoPageLink(false);
		col.setDataUtilityId("whereUsedNumber");
		treeConfig.addComponent(col);
		
		col =factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.ORG_ID, false);
		treeConfig.addComponent(col);
		
		col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.NAME, true);
		col.setWidth(799);
		treeConfig.addComponent(col);
		
		col =factory.newColumnConfig("PL_NUMBER", true);
		col.setWidth(200);
		col.setDataUtilityId("PartListSearchDataUtility");
		treeConfig.addComponent(col);
		
		col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.VERSION, false);
		col.setDataUtilityId("PartListSearchDataUtility");
		col.setWidth(100);
		treeConfig.addComponent(col);
		
		col =factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.STATE, true);
		col.setWidth(100);
		treeConfig.addComponent(col);
		
		col = factory.newColumnConfig(DescriptorConstants.ColumnIdentifiers.CONTAINER_NAME, true);
		col.setWidth(200);
		col.setTargetObject("contained");
		treeConfig.addComponent(col);
		
		// end of column definition

		treeConfig.setHelpContext("WhereUsedTableHelp");
		treeConfig.setDataSourceMode(DataSourceMode.ASYNCHRONOUS);
		System.out.println("end of column definition," + treeConfig.getComponents());
		return treeConfig;
	}

节点数据处理的方法

@Override
	public void buildNodeData(Object node, ComponentResultProcessor resultProcessor) throws Exception {
		// special case for root nodes
		if (node == TreeNode.RootNode) {
			treeHandler = new WhereUsedTreeHandler(resultProcessor.getParams());
			if(treeHandler.getRootNodes()!=null) {
				// should fetch rootNodes and to ResultProcessor
				resultProcessor.addElements(treeHandler.getRootNodes()); 
			}
		} 
		// case for any other node
		else {
			List nodeList = new ArrayList();
			nodeList.add(node);
			if (treeHandler == null) {
				treeHandler = new WhereUsedTreeHandler(resultProcessor.getParams());
			}
			Map<Object, List> map = treeHandler.getNodes(nodeList);
			Set keySet = map.keySet();
			for (Object key : keySet) {
				resultProcessor.addElements(map.get(key));
			}
		}
	}

代码结构
6. 前后台对接,前台输入参数或者页面初始化,调用后台,数据加载到组件中
在这里插入图片描述
贴一下资源类给楼下留言的兄弟:

public final class PartListSearchResource extends WTListResourceBundle {
	
    /**
     * Where Used - typePicker Tag
     **/
    @RBEntry("PartList Search Tool")
    @RBComment("Used as the label for the Browser Window Title")
    public static final String PARTLIST_SEARCH = "0";
    
    /**
     * Where Used - typePicker Tag
     **/
    @RBEntry("Where Used")
    @RBComment("Used as the label for the Where Used table label")
    public static final String WHEREUSED_TABLELABEL = "1";

    @RBEntry("All Revisions")
    @RBComment("Used as the default view for the table")
    public static final String WHEREUSED_ALLVERSION = "2";

    @RBEntry("Latest")
    @RBComment("Used as the alternate view for the table, displaying the latest verion of relationships only")
    public static final String WHEREUSED_LATESTVERSION = "3";

    @RBEntry("Context")
    public static final String WHEREUSED_CONTEXT_COLUMN_HEADER = "4";
    
    @RBEntry("PartList Search By PartNumber")
    @RBComment("The text displayed on the Administrators sub tab under the PartList Search tab")
    public static final String PRIVATE_CONSTANT_CS_6 = "commonsearch.partlistsearchbynumber.description";
    
    @RBEntry("PartList Releaship BOM Search By PartList")
    @RBComment("The text displayed on the Administrators sub tab under the PartList Releaship BOM tab")
    public static final String PRIVATE_CONSTANT_CS_7 = "commonsearch.partlistsearchbybom.description";

    @RBEntry("Export PartList Releaship BOM By Container")
    @RBComment("The text displayed on the Administrators sub tab under the Export PartList tab")
    public static final String PRIVATE_CONSTANT_CS_8 = "commonsearch.partlistsearchexport.description";

    /**
     * Entries for WhereUsed Table display
     **/
    @RBEntry("Copy")
    public static final String OBJECT_WHERE_USED_COPY_TITLE = "OBJECT_WHERE_USED_COPY_TITLE";

    @RBEntry("Where Used")
    @RBComment("Used as the label for the Where Used table label")
    public static final String PRIVATE_CONSTANT_0 = "whereUsed.tableLabel.description";

    @RBEntry("Copy")
    @RBComment("Used as the tooltip for the Where Used copy action")
    public static final String PRIVATE_CONSTANT_1 = "object.whereused_copy.tooltip";

    @RBEntry("Copy Selected Object")
    public static final String PRIVATE_CONSTANT_2 = "object.whereused_copy.title";

    @RBEntry("Copy")
    public static final String PRIVATE_CONSTANT_3 = "object.whereused_copy.description";

    @RBEntry("copy.gif")
    @RBComment("DO NOT TRANSLATE")
    public static final String PRIVATE_CONSTANT_4 = "object.whereused_copy.icon";
}

最近又有用MVC组件开发,这里更新两个知识点

第一个:如果table中的某个列需要做特殊处理,则需要自己定义一个DataUtility类,并且将这个DataUtility类注册到系统中
在这里插入图片描述
下面的截图是表格初始化的时候,指定哪些列需要用自己客制化的DataUtility类对该列的值做特殊处理
在这里插入图片描述
然后下面的图是自己对那些列需要做客制化处理的动作:
在这里插入图片描述
一般来说客制化的这个类要么是对值做显示的处理,权限的处理,要么是组件客制化
效果图如下:
在这里插入图片描述
上面部分的组件是一个搜索的组件,下面的组件是一个搜索结果的table
搜索条件主要包含三类:文本框,下拉的combox,日期组件,我都贴一小段代码作为例子
先讲下拉的,因为最有可能用到:
在这里插入图片描述
在这里插入图片描述
日期组件:
在这里插入图片描述
在这里插入图片描述
显示的列增加一些action操作按钮(编辑/查看/删除/提交),一种是后台写button,一种是icon类型
在这里插入图片描述

在这里插入图片描述
icon类型的显得更简洁明了:

private Object createButtonCommentByAction(String columnId, ExperienceSharingBean rowObject) {
		boolean isEditable=rowObject.isEditable();
		String formOid = rowObject.getExpOid();
		GUIComponentArray componentArray = new GUIComponentArray();
		IconComponent button4View = new IconComponent("netmarkets/images/info.gif");
		button4View.addJsAction("onclick", "viewExp('"+formOid+"')");

		IconComponent button4Edit = new IconComponent("netmarkets/images/edit.gif");
		button4Edit.addJsAction("onclick", "editExp('"+formOid+"')");

		IconComponent button4Obsolete = new IconComponent("netmarkets/images/delete.gif");
		button4Obsolete.addJsAction("onclick", "obsoleteExp('"+formOid+"')");

		IconComponent button4Monitor = new IconComponent("netmarkets/images/checkpoint.gif");
		button4Monitor.addJsAction("onclick", "monitorExp('"+formOid+"')");
//		componentArray.addGUIComponent(button4Monitor);

		componentArray.addGUIComponent(button4View);
		componentArray.addGUIComponent(button4Edit);
		componentArray.addGUIComponent(button4Obsolete);
		if(isEditable){
			button4Edit.setEnabled(true);
			if("RELEASED".equals(rowObject.getState())){
				button4Obsolete.setEnabled(false);
			}
		}

		return componentArray;
	}

icon的效果图如下:
在这里插入图片描述

按钮的名称,是否可用,是否可编辑,以及点击按钮要做的动作都可以在后台定义好
比如我四个按钮对应的四个js事件,我定义好后,在页面去实现这四个方法就好
在这里插入图片描述

PS:目前我找到的是我们系统自己配置了一个相关的配置文件,
1)添加我业务模块定义的DataUtility类,
2)windchill shell中执行如下命令把服务注册到系统中:xconfmanager -p

第二个:windchill 10后的分页搜索都是系统自带的,不需要像10以前那样,自己在后台写分页搜索
要实现分页,你需要check两个东西,一个是系统的首选项配置,table默认的结果集是多少条,
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

另外一个是by用户的,进入首选项,然后看看table的结果集是多少条,不得不提的一点是,这个配置是针对整个系统全局的一个配置。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 11
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
Windchill MVC(Model-View-Controller)组件是PTC公司开发的一种用于风寒平台的软件架构模式。MVC是一种常见的软件开发模式,它将一个应用程序分为三个核心部分:模型(Model)、视图(View)和控制(Controller)。 在Windchill MVC组件中,模型是应用程序的核心部分,负责处理数据和业务逻辑。模型是一个独立于用户界面的组件,它封装了应用程序的核心数据和相关操作。模型通常包含访问数据库、处理数据验证和计算等功能。 视图是用户界面的组件,负责展示模型中的数据给用户。视图向用户提供了一个交互界面,通过它用户可以与模型进行交互。视图通常包含了用户界面的布局、样式和交互元素。 控制是模型和视图之间的协调者,负责处理用户的输入和响应。控制接收用户的输入,并将其传递给相应的模型进行处理,然后更新视图以反映模型的状态和结果。控制还负责将模型和视图解耦,使它们可以独立于彼此进行修改和扩展。 Windchill MVC组件的使用有助于提高软件的可维护性和可扩展性。通过将应用程序分成不同的组件,每个组件都负责特定的功能,便于团队的协作开发和代码重用。此外,MVC的分层结构还能够使软件的不同部分相对独立,使得改变一个组件不会对其他组件造成影响。 总之,Windchill MVC组件是一种软件架构模式,将应用程序分为模型、视图和控制三个部分,提高了软件的可维护性和可扩展性。它适用于在风寒平台上开发的软件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值