refactor(plm): 优化 MpartDialog 界面渲染和事件处理

- 添加界面初始化时的强制刷新逻辑
- 优化鼠标事件处理,提高代码可读性和维护性
- 添加异常捕获,提高代码的健壮性
main
熊朝柱 1 month ago
parent 2ff6943a1c
commit 3b81992024

@ -164,6 +164,7 @@ public class MpartDialog extends JFrame implements ActionListener {
this.setLayout(new BorderLayout());
JPanel topPanel = getTopPanel();
System.out.println("topPanel is null? " + (topPanel == null));
JPanel btnPanel = getBtnPanel();
@ -184,6 +185,11 @@ public class MpartDialog extends JFrame implements ActionListener {
// this.validate();
this.setVisible(true);
//强制刷新界面
this.revalidate();
this.repaint();
String groupID = getGroupID();
System.out.println("groupID==========" + groupID);
String factory = "";
@ -286,7 +292,7 @@ public class MpartDialog extends JFrame implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
System.out.println("source==>+" + source);
@ -542,6 +548,7 @@ public class MpartDialog extends JFrame implements ActionListener {
}
}
if(errMsg.length() > 0) {
MessageBox.post(errMsg.toString(), "提示 ", MessageBox.INFORMATION);
KUtil.setByPass(false);
@ -578,10 +585,7 @@ public class MpartDialog extends JFrame implements ActionListener {
}
}
// if (tempMrevList.size() == 0) {
// MessageBox.post(eId + "对象未创建MPart", "提示 ", MessageBox.INFORMATION);
// return;
// } else
if (tempMrevList.size() == 1) {
// 把M放bom下
addList.put(tempMrevList.get(0),sl);
@ -806,7 +810,7 @@ public class MpartDialog extends JFrame implements ActionListener {
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@ -833,7 +837,7 @@ public class MpartDialog extends JFrame implements ActionListener {
"com.teamcenter.rac.pse.PSEPerspective",
new InterfaceAIFComponent[] { table2RevList.get(t_part2.getSelectedRow()).getItem() });
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
@ -850,7 +854,7 @@ public class MpartDialog extends JFrame implements ActionListener {
try {
userName = user.getUserName()+"_"+user.getUserId();
} catch (TCException e1) {
// TODO Auto-generated catch block
MessageBox.post("请选择用户!", "提示 ", MessageBox.INFORMATION);
return;
}
@ -899,6 +903,7 @@ public class MpartDialog extends JFrame implements ActionListener {
}
private JPanel getTablePanel() {
try {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(1100, 600));
tm_part = new DefaultTableModel();
@ -1081,7 +1086,7 @@ public class MpartDialog extends JFrame implements ActionListener {
// String[] ld_taskNature = session.getPreferenceService().getStringValues("ld_taskNature");// 任务性质
// String[] ld_taskDifficulty = session.getPreferenceService().getStringValues("ld_taskDifficulty");// 难易程度
// String[] ld_urgency = session.getPreferenceService().getStringValues("ld_urgency");// 紧急程度
//
//
// Map<String, Double> ld_taskNatureMap = new HashMap<String, Double>();
// Map<String, Double> ld_taskDifficultyMap = new HashMap<String, Double>();
// Map<String, Double> ld_urgencyMap = new HashMap<String, Double>();
@ -1093,20 +1098,20 @@ public class MpartDialog extends JFrame implements ActionListener {
// ld_taskNatureMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox1.addItem(split[0]);
// }
//
//
// for (int i = 0; i < ld_taskDifficulty.length; i++) {
// String[] split = ld_taskDifficulty[i].split("=");
// ld_taskDifficultyMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox2.addItem(split[0]);
// }
//
//
// for (int i = 0; i < ld_urgency.length; i++) {
// String[] split = ld_urgency[i].split("=");
// ld_urgencyMap.put(split[0], Double.parseDouble(split[1]));
// jComboBox3.addItem(split[0]);
// }
//
//
// // 添加鼠标监听器
// t_part.addMouseListener(new MouseAdapter() {
// @Override
@ -1134,10 +1139,17 @@ public class MpartDialog extends JFrame implements ActionListener {
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
} catch (Exception e) {
// TODO: handle exception
System.out.println("查询部分左边panel渲染异常错误信息如下"+e.getMessage());
e.printStackTrace();
}
return null;
}
//获取右边的panel
private JPanel getTablePanel2() {
try {
JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200, 600));
tm_part2 = new DefaultTableModel();
@ -1216,7 +1228,7 @@ public class MpartDialog extends JFrame implements ActionListener {
// });
// 设置第一列的单元格渲染器和编辑器
//
//
// // 添加鼠标监听器
// t_part.addMouseListener(new MouseAdapter() {
// @Override
@ -1244,6 +1256,12 @@ public class MpartDialog extends JFrame implements ActionListener {
panel.setBorder(BorderFactory.createLoweredBevelBorder());
return panel;
} catch (Exception e) {
// TODO: handle exception
System.out.println("查询部分右边panel渲染异常错误信息如下"+e.getMessage());
e.printStackTrace();
}
return null;
}
public String getGroupID() throws TCException {

Loading…
Cancel
Save