20250421备份:流程属性变更+旧版D转EBOM功能

main
熊朝柱 2 months ago
parent a48ce2f229
commit b4143b5322

@ -9,10 +9,10 @@
<command name="图号申请" id="DrawingNoApplyHandler"/>
<!-- <command name="申请物料编码" id="WlbmApplyHandler"/> -->
<command id="CodeApplyHandler" name="物料编码申请"/>
<command name="DBOM转EBOM" categoryId="com.connor.ml.tcm.outfile.commands.category" id="DBOMtoEBOM"> </command>
<command name="DBOM转EBOM" categoryId="com.connor.ml.tcm.outfile.commands.category" id="DBOMtoEBOM"> </command>
<command name="依据设计创建物料" id="DesignToPartHandler"/>
<command name="标准化审核" id="StandardHandler"/>
<command name="编辑节点属性" id="ProcessAttriChangeHandler"/>
<!-- <command name="编辑节点属性" id="ProcessAttriChangeHandler"/>-->
<command name="用户登录设置" id="LoginIPSetHandler"/>
</extension>
<extension point="org.eclipse.ui.handlers">
@ -22,7 +22,7 @@
<handler commandId="CodeApplyHandler" class="com.connor.jingdiao.handlers.CodeApplyHandler"/>
<handler commandId="DesignToPartHandler" class="com.connor.jingdiao.handlers.DesignToPartHandler"/>
<handler commandId="StandardHandler" class="com.connor.jingdiao.handlers.StandardHandler"/>
<handler commandId="ProcessAttriChangeHandler" class="com.connor.processAttributeModification.ProcessAttriChangeHandler"/>
<!-- <handler commandId="ProcessAttriChangeHandler" class="com.connor.processAttributeModification.ProcessAttriChangeHandler"/>-->
<handler commandId="LoginIPSetHandler" class="com.connor.jingdiao.handlers.LoginIPSetHandler"/>
<handler class="com.connor.jd.erp.erpIntegrationHandler" commandId="erpIntegrationHandler"/>
<handler class="com.connor.jd.derive.deriveCenterHandler" commandId="deriveCenterHandler"/>
@ -36,10 +36,10 @@
</command>
BOM转换 -->
<command commandId="DBOMtoEBOM" style="push"/>
<command commandId="DBOMtoEBOM" style="push"/>
<command commandId="CodeApplyHandler" style="push"> </command>
<command commandId="StandardHandler" style="push"> </command>
<command commandId="ProcessAttriChangeHandler" style="push"> </command>
<!-- <command commandId="ProcessAttriChangeHandler" style="push"> </command>-->
<command commandId="erpIntegrationHandler" style="push"> </command>
<command commandId="deriveCenterHandler" style="push"> </command>
<command commandId="deriveMBOMHandler" style="push"> </command>

@ -4,10 +4,8 @@ import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
@ -15,6 +13,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
@ -229,52 +229,33 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
try {
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
String status = nodeBean.getRefreshStatus();
if(!status.equals("属性发布") && !status.equals("流程中") && !status.isEmpty()
&& getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}else if(!acs.checkAccessorsPrivilege(user, nodeBean.getTcComponent(), "WRITE")
&& getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}
if(getTopRefresh(node)) {
MessageBox.post("上层已勾选发布或无权限的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
// if(getTopProcessRefresh(node)) {
// MessageBox.post("上层已勾选流程中的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
// return;
// }
if(parentNode != null) {
// DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
// NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject();
// if(!rootNodeBean.getDbom().equals("顶层") && !getTop(node) && nodeBean.getLabel().equals("0") ) {
// MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR);
// return;
// }
}
// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
//TODO 勾选事件
if(nodeBean.getLabel().equals("0")) {
String status = nodeBean.getRefreshStatus();
boolean access = !acs.checkAccessorsPrivilege(user, nodeBean.getTcComponent(), "WRITE")
|| !status.equals("属性发布") && !status.equals("流程中") && !status.isEmpty();
if(access && getChildRefresh(parentNode, false)) {
MessageBox.post("下层已勾选,上层不允许勾选已发布或没权限对象!", "错误", MessageBox.ERROR);
return;
}
if(getTopRefresh(node)) {
MessageBox.post("上层已勾选发布或无权限的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
//判断同一层是否已勾选
if(parentNode != null) {
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i);
// for (DefaultMutableTreeTableNode childNode : backMap.get(parentNode)) {
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty() && !nodeBean.getEbom().isEmpty()) {
MessageBox.post("同一层级只允许选中一个!", "错误", MessageBox.ERROR);
MessageBox.post(this, "同一层级只允许选中一个!", "错误", MessageBox.ERROR);
return;
}
}
}
nodeBean.setLabel("1");
if(parentNode != null)
if(!access && parentNode != null)
autoCheck(parentNode, "1");
//isHaveBom(node, nodeBean.getEbomId(), "1", itemType);
}else if(nodeBean.getLabel().equals("1")) {
@ -283,9 +264,10 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
autoCheck(parentNode, "0");
//isHaveBom(node, nodeBean.getEbomId(), "0", itemType);
}
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
this.repaint();
// Robot robot = new Robot();
// robot.keyPress(KeyEvent.VK_TAB);
// robot.keyRelease(KeyEvent.VK_TAB);
} catch (Exception e2) {
// : handle exception
e2.printStackTrace();
@ -445,22 +427,23 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
boolean change = true;
NodeBean eBean = null;
for (int j = 0; j < node.getChildCount(); j++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i);
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) node.getChildAt(j);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(!childBean.getEbom().isEmpty()) {
if(eBean == null) {
if(val.equals("0")) {
childBean.setLabel(val);
}else if(eBean == null) {
eBean = childBean;
}else {
change = false;
}
}else if(!childBean.getDbom().isEmpty()) {
autoCheck(childNode, val);
}
}
System.out.println("autoCheck" + bean.getDbom() + "==" + change + "==" + eBean + ">>" + val);
if(eBean != null && (change || val.equals("0"))) {
if(val.equals("1") && eBean != null && change) {
eBean.setLabel(val);
}
autoCheck(node, val);
}
}
}
@ -724,18 +707,20 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
if(num == null || num.isEmpty() || num.equals("0")) {
num = "1";
}
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
// TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
TCComponentItemRevision pRev = childNodeBean.getpRev();
System.out.println("pRev" + pRev);
if(dbom.isPacked() && bomValMap.containsKey(pRev)) {
List<BomValBean> list = bomValMap.get(pRev);
childMap.put(latestItemRevision, list);
childMap.put(nodeComp, list);
}else if(childMap.containsKey(nodeComp)) {//TODO lidy20250221
childMap.get(nodeComp).add(pValBean);
}else {
//TODO lidy20241211
// lidy20241211
List<BomValBean> list = new ArrayList<>();
list.add(pValBean);
childMap.put(latestItemRevision, list);
childMap.put(nodeComp, list);
}
TCComponent tcComponent = childNodeBean.getTcComponent();
@ -808,7 +793,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
TCComponentBOMLine topline = bomWindow.setWindowTopLine(topLineItem,
topLineItem.getLatestItemRevision(), null, null);
bomWindow.lock();
recreateBom2(topLineItem, map2, topline);
recreateBom2(topLineItem, map2, topline, bomWindow);
}catch(Exception e) {
e.printStackTrace();
}
@ -821,6 +806,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
}
/**
* BOM
* @param bomWindow
*
* @param item
* @param itemlists
@ -828,7 +814,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
*/
@SuppressWarnings("deprecation")
private void recreateBom2(TCComponentItem topItem,
Map<TCComponentItemRevision, List<BomValBean>> map2,TCComponentBOMLine topline)
Map<TCComponentItemRevision, List<BomValBean>> map2, TCComponentBOMLine topline, TCComponentBOMWindow bomWindow)
throws Exception {
// TCComponentBOMWindow bomWindow = null;
try {
@ -836,6 +822,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
topline.lock();
System.out.println("items==>" + items.toString());
List<TCComponentBOMLine> bomLines = new ArrayList<TCComponentBOMLine>();
Set<TCComponentItemRevision> set = map2.keySet();
if (topline.hasChildren()) {
System.out.println(topItem);
@ -861,12 +848,19 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
bomLines.add(bLine);
}
}
}else if(set.size() > 0) {//lidy20250225 不包含BOM视图版本无法设置精确
TCComponentItemRevision rev = (TCComponentItemRevision) set.toArray()[0];
TCComponentItem item = rev.getItem();
TCComponentBOMLine line = topline.add(item, rev, null, false, "");
bomWindow.save();
line.cut();
bomWindow.save();
}
String maxSeq = "";
System.out.println("topline===>" + topline);
topline.setPrecision(true);
for(TCComponentItemRevision rev : map2.keySet()) {
for(TCComponentItemRevision rev : set) {
List<BomValBean> list = map2.get(rev);
System.out.println("list===>" + list.toString());
for(BomValBean bean : list) {
@ -888,7 +882,7 @@ public class DbomTransitionToEbomDialog extends JFrame implements ActionListener
add.unlock();
if(bomStructMap.containsKey(item)) {
Map<TCComponentItemRevision, List<BomValBean>> map3 = bomStructMap.get(item);
recreateBom2(item, map3, add);
recreateBom2(item, map3, add, bomWindow);
}
}

@ -66,6 +66,7 @@ import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
public class ProcessAttriChangeDialog extends JDialog {
@ -81,6 +82,10 @@ public class ProcessAttriChangeDialog extends JDialog {
private JButton closeBtn;
private JTable impTable;
private DefaultTableModel impModel;
/**
*
*/
private JPanel propertyPanel;
private ArrayList<TCComponentItemRevision> revlist;
/**
* [rev,object_name]
@ -120,22 +125,35 @@ public class ProcessAttriChangeDialog extends JDialog {
* @param task
* @param ruleOpsMap key()valueString[]String["item/rev","object_name"]
* @param cols
* @param chooseRows2
* @throws Exception
*/
public ProcessAttriChangeDialog(TCSession session, TCComponent[] models, TCComponentTask task, LinkedHashMap<String, String[]> ruleOpsMap, int[] cols)
public ProcessAttriChangeDialog(
TCSession session,
TCComponent[] models,
TCComponentTask task,
LinkedHashMap<String, String[]> ruleOpsMap,
int[] cols, List<Integer> chooseRowsA,
List<TCComponentItemRevision> targetRevisionA)
throws Exception {
super(AIFUtility.getActiveDesktop());
this.session = session;
this.modelsF = models;
this.taskF = task;
this.ruleOpsMapF = ruleOpsMap;
System.out.println("开始遍历存放首选项Jd_Standard_UI_Process_Attribute的信息的构造函数入参ruleOpsMap");
for (String key : ruleOpsMap.keySet()){
System.out.println(key+":"+Arrays.toString(ruleOpsMap.get(key)));
this.chooseRows = chooseRowsA;
this.targetRevision = targetRevisionA;
if (chooseRowsA != null && chooseRowsA.size()>0) {
System.out.println("构造函数ProcessAttriChangeDialog的入参chooseRowsA:"+chooseRowsA.toString());
}else {
if (this.chooseRows != null) {
System.out.println("this.chooseRows:["+this.chooseRows.size()+"]");
}
System.out.println("构造函数ProcessAttriChangeDialog的入参chooseRowsA为空");
}
this.colsF = cols;
this.argMap = getHandlerArgs(task);
initUi( modelsF, taskF, ruleOpsMapF, colsF,null);
initUi( modelsF, taskF, ruleOpsMapF, colsF,chooseRowsA);
}
/**
@ -148,7 +166,10 @@ public class ProcessAttriChangeDialog extends JDialog {
* @param chooseRows
* @throws Exception
*/
private void initUi(TCComponent[] models, TCComponentTask task, LinkedHashMap<String, String[]> ruleOpsMapI, int[] cols, List<Integer> chooseRows2) throws Exception {
private void initUi(TCComponent[] models,
TCComponentTask task,
LinkedHashMap<String, String[]> ruleOpsMapI,
int[] cols, List<Integer> chooseRows2) throws Exception {
// this.chooseRows.addAll(chooseRows2);
if (chooseRows2 != null && chooseRows2.size()>0) {
System.out.println("当前选中行="+Arrays.toString(chooseRows2.toArray()));
@ -159,95 +180,7 @@ public class ProcessAttriChangeDialog extends JDialog {
System.out.println("开始初始化/刷新面板···");
setTitle("编辑节点属性");
remarkBtn = new JButton("修改属性");
remarkBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {//修改属性按钮
System.out.println("触发修改属性事件~");
try {
// chooseRow = impTable.getSelectedRow();
System.out.println("当前选中行:" + impTable.getSelectedRow());
for (int i = 0; i < chooseRows.size(); i++) {
System.out.println("修改属性-选中行:" + chooseRows.get(i));
}
if(chooseRows.size() <= 0) {
MessageBox.post(ProcessAttriChangeDialog.this, "请选择要编辑的行!", "ERROR", MessageBox.ERROR);
return;
}
for (String key : textAreaMap.keySet()){
// String text = textAreaMap.get(key).getText();//获取输入框中的值
//
Object component = textAreaMap.get(key);
String text = getValueByAreaType(component);
if (text == null){
System.out.println("info获取输入框组件值异常");
}
String showAttr = argMap.get(key);//获取流程参数的value
if(text.getBytes().length > 1024) {
MessageBox.post(ProcessAttriChangeDialog.this, showAttr+"属性填写长度过长,无法修改!", "ERROR", MessageBox.ERROR);
return;
}else {
//获取列数
for (int t = 0; t < tableHeaderList.size(); t++){
if (tableHeaderList.get(t).equals(showAttr)){
for (int i = 0; i < chooseRows.size(); i++) {
impTable.setValueAt(text, chooseRows.get(i), t);
}
break;
}
}
}
}
for (int i = 0; i < chooseRows.size(); i++) {
TCComponentItemRevision rev = revlist.get(chooseRows.get(i));
TCComponentItem item = rev.getItem();
if(mark[0].equals("item") && item.isCheckedOut()) {
MessageBox.post(ProcessAttriChangeDialog.this, item+" 已签出,无法修改!", "ERROR", MessageBox.ERROR);
return;
}else if(mark[0].equals("rev") && rev.isCheckedOut()) {
MessageBox.post(ProcessAttriChangeDialog.this, rev+" 已签出,无法修改!", "E RROR", MessageBox.ERROR);
return;
}
MethodUtil.openByPass(session);
if(mark[0].equals("item")) {
for (String key : textAreaMap.keySet()){
// String value = textAreaMap.get(key).getText();
Object component = textAreaMap.get(key);
String inputValue = getValueByAreaType(component);
if (inputValue == null){
System.out.println("info获取输入框组件值异常");
}
item.setProperty(key, inputValue);
}
}else if(mark[0].equals("rev")) {
for (String key : textAreaMap.keySet()){
// String value = textAreaMap.get(key).getText();
Object component = textAreaMap.get(key);
String inputValue = getValueByAreaType(component);
if (inputValue == null){
System.out.println("info获取输入框组件值异常");
}
rev.setProperty(key, inputValue);
}
}
}
MethodUtil.closeByPass(session);
}catch(Exception e1) {
e1.printStackTrace();
MessageBox.post(ProcessAttriChangeDialog.this, "错误:"+e1.getMessage(), "ERROR", MessageBox.ERROR);
}finally {
try {
MethodUtil.closeByPass(session);
}catch(Exception e1) {
e1.printStackTrace();
}
}
}
});
exportBtn = new JButton("导出Excel");
closeBtn = new JButton("关闭");
JPanel btnPanel = new JPanel(new FlowLayout());
@ -255,7 +188,6 @@ public class ProcessAttriChangeDialog extends JDialog {
btnPanel.add(exportBtn);
btnPanel.add(closeBtn);
// JPanel topPanel = new JPanel(new BorderLayout());
if (topPanel == null) {
topPanel = new JPanel(new BorderLayout());
@ -269,86 +201,87 @@ public class ProcessAttriChangeDialog extends JDialog {
return;
}
// 创建属性面板
JPanel propertyPanel = new JPanel(new PropertyLayout());
int k = 0;
for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上
k++;
String value = this.argMap.get(key);//属性显示名称
System.out.println("流程配置信息Key: " + key + ", Value: " + value);
String labLocation = String.valueOf(k)+".1.left.top";
String fieldLocation = String.valueOf(k)+".2.left.top";
propertyPanel.add(labLocation,new JLabel(value));
//TODO 逻辑重构:根据不同属性类型,渲染不同的输入框
String[] attrs = ruleOpsMapI.get(value);
if (attrs == null || attrs.length == 0){
System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!");
}
String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中
System.out.println("====================================================================");
if (this.targetRevision != null && this.targetRevision.size() > 0){
System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···");
//当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上
TCComponentItem targetItem = this.targetRevision.get(0).getItem();
//根据属性名称获取属性所属对象类型item/rev
String itemType = attrs[0];//item/rev
String propertyName = attrs[1];//属性真实名称
if (itemType.equals("item")){
currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值
}else {
currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值
}
//
if (isLovType(propertyName)){
System.out.println("属性【"+propertyName+"】类型为LOV");
Map<String, String> lovList = getUnitValue_display(session,propertyName);
// 创建下拉列表组件
JComboBox<String> comboBox = new JComboBox<>();
// 将lovList中的value值添加到下拉列表
for (String lovValue : lovList.values()) {
comboBox.addItem(lovValue);
}
// 设置默认显示值假设defaultValue是您希望默认显示的选项
comboBox.setSelectedItem(currentAttributeValue);
propertyPanel.add(fieldLocation, comboBox);
this.textAreaMap.put(propertyName, comboBox); //
}else {//
System.out.println("属性【"+ propertyName+"】类型非LOV ");
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
JScrollPane scrollPane = new JScrollPane(textArea);
System.out.println("KUMA属性=" + value);
if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度
System.out.println("KUMA:特殊字段特殊处理!");
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textArea.setRows(3);
scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸
}
//赋值到textArea输入框中
textArea.setText(currentAttributeValue);
propertyPanel.add(fieldLocation, scrollPane);
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
propertyPanel = new JPanel(new PropertyLayout());
// int k = 0;
// for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上
// k++;
// String value = this.argMap.get(key);//属性显示名称
// System.out.println("流程配置信息Key: " + key + ", Value: " + value);
// String labLocation = String.valueOf(k)+".1.left.top";
// String fieldLocation = String.valueOf(k)+".2.left.top";
// propertyPanel.add(labLocation,new JLabel(value));
//
// //TODO 逻辑重构:根据不同属性类型,渲染不同的输入框
// String[] attrs = ruleOpsMapI.get(value);
// if (attrs == null || attrs.length == 0){
// System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!");
// }
// String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中
// System.out.println("====================================================================");
// if (this.targetRevision != null && this.targetRevision.size() > 0){
// System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···");
//
// //当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上
// TCComponentItem targetItem = this.targetRevision.get(0).getItem();
// //根据属性名称获取属性所属对象类型item/rev
// String itemType = attrs[0];//item/rev
// String propertyName = attrs[1];//属性真实名称
// if (itemType.equals("item")){
// currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值
//
// }else {
// currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值
//
// }
// //
// if (isLovType(propertyName)){
// System.out.println("属性【"+propertyName+"】类型为LOV");
//
// Map<String, String> lovList = getUnitValue_display(session,propertyName);
// // 创建下拉列表组件
// JComboBox<String> comboBox = new JComboBox<>();
//
// // 将lovList中的value值添加到下拉列表
// for (String lovValue : lovList.values()) {
// comboBox.addItem(lovValue);
// }
// // 设置默认显示值假设defaultValue是您希望默认显示的选项
// comboBox.setSelectedItem(currentAttributeValue);
// propertyPanel.add(fieldLocation, comboBox);
// this.textAreaMap.put(propertyName, comboBox); //
// }else {//
// System.out.println("属性【"+ propertyName+"】类型非LOV ");
//
// JTextArea textArea = new JTextArea(); // 创建JTextArea
// textArea.setColumns(20); // 设置输入框宽度
// textArea.setLineWrap(true); // 启用自动换行
// textArea.setWrapStyleWord(true); // 按单词换行
// JScrollPane scrollPane = new JScrollPane(textArea);
// System.out.println("KUMA属性=" + value);
// if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度
// System.out.println("KUMA:特殊字段特殊处理!");
// scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// textArea.setRows(3);
// scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸
// }
// //赋值到textArea输入框中
// textArea.setText(currentAttributeValue);
// propertyPanel.add(fieldLocation, scrollPane);
// this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
// }
//
// }else {
// System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
// //渲染默认组件
// JTextArea textArea = new JTextArea(); // 创建JTextArea
// textArea.setColumns(20); // 设置输入框宽度
// textArea.setLineWrap(true); // 启用自动换行
// textArea.setWrapStyleWord(true); // 按单词换行
// propertyPanel.add(fieldLocation, new JScrollPane(textArea));
// this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
// }
// }
}else {
System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
//渲染默认组件
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
propertyPanel.add(fieldLocation, new JScrollPane(textArea));
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}
// 将属性面板放置在中心位置btnPanel 放置在南边(底部)
topPanel.add(propertyPanel, BorderLayout.CENTER);
topPanel.add(btnPanel, BorderLayout.SOUTH);
@ -356,6 +289,7 @@ public class ProcessAttriChangeDialog extends JDialog {
topPanel.revalidate();
topPanel.repaint();
//处理表格表头
String[] tableHeader = new String[ruleOpsMapI.size() + 1];
tableHeader[0] = "序号";
int h = 1;
@ -383,56 +317,7 @@ public class ProcessAttriChangeDialog extends JDialog {
impTable.setModel(impModel);
impTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
impTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {//单机鼠标
System.out.println("触发单击选中事件~");
try {
// chooseRow= impTable.getSelectedRows();
int[] selectedRows = impTable.getSelectedRows();
if(selectedRows.length <= 0) {
System.out.println("当前未选中任何对象 ");
return;
}
//选中行
// List<Integer> chooseRowTemp = new ArrayList<Integer>();
chooseRows.clear();//放入新的选中行前,清空选中行集合
targetRevision.clear();
System.out.println("当前选中行:");
for (int i = 0; i < selectedRows.length; i++) {
//选中行序号之一
int selectPartRowNum = selectedRows[i];
System.out.println("=>"+selectPartRowNum+" ;");
if (revlist != null && revlist.size() > 0) {
TCComponentItemRevision selectRevision = revlist.get(selectPartRowNum);//根据选中行的序号从revlist中获取该行对应的版本对象
if (selectRevision != null) {
targetRevision.add(selectRevision);
chooseRows.add(selectPartRowNum);
}
}else {
System.out.println("版本list为空");
}
}
if (targetRevision != null && targetRevision.size() > 0) {
System.out.println("二次渲染前的选中行:"+Arrays.toString(chooseRows.toArray()));
initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows);
System.out.println("二次渲染后的选中行:"+Arrays.toString(chooseRows.toArray()));
}
} catch (Exception e1) {
e1.printStackTrace();
MessageBox.post(ProcessAttriChangeDialog.this, "错误:" + e1.getMessage(), "ERROR", MessageBox.ERROR);
}
}
});
for (int i = 1; i < impModel.getColumnCount(); i++) {
TableColumn col = impTable.getColumnModel().getColumn(i);
col.setCellRenderer(new TextAreaRenderer());
@ -444,7 +329,7 @@ public class ProcessAttriChangeDialog extends JDialog {
// for (MouseListener listener : impTable.getMouseListeners()) {
// impTable.removeMouseListener(listener);
// }
// addActionListener(models, cols);
addActionListener(models, cols);
setLayout(new BorderLayout());
topPanel.setPreferredSize(new Dimension(260, getHeight())); // 设置宽度
@ -461,13 +346,13 @@ public class ProcessAttriChangeDialog extends JDialog {
//如果有选中行设置table的选中对应行状态
if (chooseRows != null && chooseRows.size() > 0) {
System.out.println("重新加载组件完成当前已选中行开始设置table选中状态");
List<Integer> uniqueRows = new ArrayList<>(new HashSet<>(chooseRows2)); // 去重
List<Integer> uniqueRows = new ArrayList<>(new HashSet<>(chooseRows)); // 去重
Collections.sort(uniqueRows); // 排序
for (int row : uniqueRows) {
impTable.addRowSelectionInterval(row, row);
}
}else{
System.out.println("当前未选中任何行重新加载组件后无需设置table选中状态");
System.out.println("重新加载组件完成!当前未选中任何行重新加载组件后无需设置table选中状态");
}
}
@ -486,6 +371,7 @@ public class ProcessAttriChangeDialog extends JDialog {
if (lov.length > 0)
return true;
} catch (TCException e) {
System.out.println("获取LOV异常");
e.printStackTrace();
}
return false;
@ -638,6 +524,106 @@ public class ProcessAttriChangeDialog extends JDialog {
}
}
/**
* Panel
* @throws TCException
*
*/
private void updatePropertyPanel(LinkedHashMap<String, String[]> ruleOpsMapI) throws TCException {
System.out.println("触发updatePropertyPanel方法~");
//1.更新前先清空属性Panel
propertyPanel.removeAll();
topPanel.remove(propertyPanel);
propertyPanel = new JPanel(new PropertyLayout());
int k = 0;
for (String key : this.argMap.keySet()) {//将流程配置的属性逐个渲染到看板上
k++;
String value = this.argMap.get(key);//属性显示名称
System.out.println("流程配置信息Key: " + key + ", Value: " + value);
String labLocation = String.valueOf(k)+".1.left.top";
String fieldLocation = String.valueOf(k)+".2.left.top";
propertyPanel.add(labLocation,new JLabel(value));
//TODO 逻辑重构:根据不同属性类型,渲染不同的输入框
String[] attrs = ruleOpsMapI.get(value);
if (attrs == null || attrs.length == 0){
System.out.println("info根据属性显示字段【"+value+"】获取属性信息失败,请检查相关首选项配置!");
}
String currentAttributeValue = null;//当前属性的值,用于渲染到看板输入框中
System.out.println("====================================================================");
if (this.targetRevision != null && this.targetRevision.size() > 0){
System.out.println("info已选中对象开始根据选中对象的属性类型渲染组件···");
//当选中多个对象时,默认将当前选中的第一个对象属性作为默认值渲染到属性编辑看板上
TCComponentItem targetItem = this.targetRevision.get(0).getItem();
//根据属性名称获取属性所属对象类型item/rev
String itemType = attrs[0];//item/rev
String propertyName = attrs[1];//属性真实名称
if (itemType.equals("item")){
currentAttributeValue = targetItem.getProperty(propertyName);//获取当前属性的值
}else {
currentAttributeValue = targetRevision.get(0).getProperty(propertyName);//获取当前属性的值
}
//
if (isLovType(propertyName)){
System.out.println("属性【"+propertyName+"】类型为LOV");
Map<String, String> lovList = getUnitValue_display(session,propertyName);
// 创建下拉列表组件
JComboBox<String> comboBox = new JComboBox<>();
// 将lovList中的value值添加到下拉列表
for (String lovValue : lovList.values()) {
comboBox.addItem(lovValue);
}
// 设置默认显示值假设defaultValue是您希望默认显示的选项
comboBox.setSelectedItem(currentAttributeValue);
propertyPanel.add(fieldLocation, comboBox);
this.textAreaMap.put(propertyName, comboBox); //
}else {//
System.out.println("属性【"+ propertyName+"】类型非LOV ");
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
JScrollPane scrollPane = new JScrollPane(textArea);
System.out.println("KUMA属性=" + value);
if (value != null && (value.trim().contains("备注") || "备注".equals(value.trim()))){//备注特殊处理:加高度
System.out.println("KUMA:特殊字段特殊处理!");
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textArea.setRows(3);
scrollPane.setPreferredSize(scrollPane.getPreferredSize()); // 设置 JScrollPane 的首选尺寸
}
//赋值到textArea输入框中
textArea.setText(currentAttributeValue);
propertyPanel.add(fieldLocation, scrollPane);
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}else {
System.out.println("info未选中任何行无法获取选中对象渲染默认组件···");
//渲染默认组件
JTextArea textArea = new JTextArea(); // 创建JTextArea
textArea.setColumns(20); // 设置输入框宽度
textArea.setLineWrap(true); // 启用自动换行
textArea.setWrapStyleWord(true); // 按单词换行
propertyPanel.add(fieldLocation, new JScrollPane(textArea));
this.textAreaMap.put(key, textArea); // 将JTextArea保存到Map中
}
}
topPanel.add(propertyPanel, BorderLayout.CENTER);
topPanel.revalidate();
topPanel.repaint();//更新属性Panel
}
/**
*
* @param models
@ -649,18 +635,27 @@ public class ProcessAttriChangeDialog extends JDialog {
public void mouseClicked(MouseEvent e) {//单机鼠标
System.out.println("触发单击选中事件~");
try {
// chooseRow= impTable.getSelectedRows();
int[] selectedRows = impTable.getSelectedRows();
int length = selectedRows.length;
if(selectedRows.length <= 0) {
System.out.println("当前未选中任何对象 ");
if(length <= 0) {
System.out.println("当前选中行的长度为:"+length+",未选中任何对象 ");
return;
}else {
System.out.println("当前选中行:"+ArrayUtil.toString(selectedRows));
}
//选中行
// List<Integer> chooseRowTemp = new ArrayList<Integer>();
chooseRows.clear();//放入新的选中行前,清空选中行集合
targetRevision.clear();
if (chooseRows != null && chooseRows.size() > 0) {
chooseRows.clear();//放入新的选中行前,清空选中行集合
}else {
chooseRows = new ArrayList<Integer> ();
}
if (targetRevision != null && targetRevision.size() > 0) {
targetRevision.clear();
}else {
targetRevision = new ArrayList<TCComponentItemRevision>();
}
System.out.println("当前选中行:");
@ -683,7 +678,10 @@ public class ProcessAttriChangeDialog extends JDialog {
if (targetRevision != null && targetRevision.size() > 0) {
System.out.println("二次渲染前的选中行:"+Arrays.toString(chooseRows.toArray()));
initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows);
// initUi(modelsF, taskF, ruleOpsMapF, colsF, chooseRows);
// ProcessAttriChangeDialog.this.dispose();
// new ProcessAttriChangeDialog(session, models, taskF, ruleOpsMapF, colsF, chooseRows, targetRevision);
updatePropertyPanel(ruleOpsMapF);
System.out.println("二次渲染后的选中行:"+Arrays.toString(chooseRows.toArray()));
}

@ -70,7 +70,7 @@ public class ProcessAttriChangeHandler extends AbstractHandler implements IHandl
MessageBox.post(desktop, "首选项j6_Standard_puid配置不正确", "ERROR", MessageBox.ERROR);//QiAAAI4S5kSPsC
return null;
}
new ProcessAttriChangeDialog(session, datasets, task, ruleOpsMap, cols);
new ProcessAttriChangeDialog(session, datasets, task, ruleOpsMap, cols, null, null);
}catch(Exception e) {
e.printStackTrace();
MessageBox.post(desktop, "错误:"+e.getMessage(), "ERROR", MessageBox.ERROR);

Loading…
Cancel
Save