main
李建辉 6 months ago
parent fd63bc99fd
commit bf5a9a54f9

@ -109,7 +109,7 @@ public class QDRWChooseDialog extends JFrame implements ActionListener {
if (this.okButton.equals(source)) { if (this.okButton.equals(source)) {
String selectedItem = (String) objectComboBox.getSelectedItem(); String selectedItem = (String) objectComboBox.getSelectedItem();
ArrayList<String> arrayList = map.get(selectedItem); ArrayList<String> arrayList = map.get(selectedItem);
new QDRWDialog((TCSession)app.getSession(),arrayList.get(0),arrayList.get(1)); new QDRWDialog((TCSession)app.getSession(),arrayList.get(0),arrayList.get(1),selectedItem);
System.out.println("newnewnwenew"); System.out.println("newnewnwenew");
this.dispose(); this.dispose();
} else if (this.concelButton.equals(source)) { } else if (this.concelButton.equals(source)) {

@ -117,11 +117,13 @@ public class QDRWDialog extends JFrame implements ActionListener {
private QDRWTableColorRender QDRWTableColorRender; private QDRWTableColorRender QDRWTableColorRender;
LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap; LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
private Connection conn = null; private Connection conn = null;
public QDRWDialog(TCSession session, String pref, String taskName) { private String tamplateName;
public QDRWDialog(TCSession session, String pref, String taskName,String tamplateName) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.session = session; this.session = session;
this.pref = pref; this.pref = pref;
this.taskName = taskName; this.taskName = taskName;
this.tamplateName = tamplateName;
initUI(); initUI();
} }
@ -560,10 +562,7 @@ public class QDRWDialog extends JFrame implements ActionListener {
condition += "and JHJS <= '" + jhwcSStr + "' "; condition += "and JHJS <= '" + jhwcSStr + "' ";
} }
if (ids == null || ids.isEmpty()) {
MessageBox.post("请填写条件!", "提示", 2);
return;
}
if (ids != null && !ids.isEmpty()) { if (ids != null && !ids.isEmpty()) {
if (ids.contains(";")) { if (ids.contains(";")) {
@ -602,7 +601,11 @@ public class QDRWDialog extends JFrame implements ActionListener {
fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1);
System.out.println("fieldsSql==========" + fieldsSql); System.out.println("fieldsSql==========" + fieldsSql);
//System.out.println("condition===================" + condition); //System.out.println("condition===================" + condition);
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + condition; if (condition == null || condition.isEmpty()) {
MessageBox.post("请填写条件!", "提示", 2);
return;
}
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where TEMPLATENAME = '"+tamplateName+ "' " + condition;
System.out.println("sqlIdString=========" + sqlIdString); System.out.println("sqlIdString=========" + sqlIdString);
conn = getConn(); conn = getConn();
PreparedStatement stmt = null; PreparedStatement stmt = null;
@ -647,6 +650,10 @@ public class QDRWDialog extends JFrame implements ActionListener {
String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition; String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition;
System.out.println("sqlString======" + sqlString); System.out.println("sqlString======" + sqlString);
if(lastCondition.isEmpty()) {
MessageBox.post("未查到数据!", "提示", 2);
return;
}else {
try { try {
stmt = conn.prepareStatement(sqlString); stmt = conn.prepareStatement(sqlString);
ResultSet result = stmt.executeQuery(); ResultSet result = stmt.executeQuery();
@ -704,6 +711,8 @@ public class QDRWDialog extends JFrame implements ActionListener {
} catch (SQLException e1) { } catch (SQLException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
}
try { try {
if (stmt != null) { if (stmt != null) {

@ -118,12 +118,20 @@ public class QDRWRWFPDialog extends JFrame implements ActionListener {
return; return;
} }
for (int i = 0; i < cfdj.length; i++) { for (int i = 0; i < cfdj.length; i++) {
String[] split = cfdj[i].split("="); String[] split = cfdj[i].split("=");
cfdjPref.put(split[0],split[1]); if(split[0].equals(type)) {
cfdJComboBox.addItem(split[0]); String[] split2 = split[1].split(";");
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("\\|");
cfdjPref.put(split3[0],split3[1]);
cfdJComboBox.addItem(split3[0]);
}
break;
} }
}
//获取首选项匹配的类型 //获取首选项匹配的类型
String[] fields = session.getPreferenceService().getStringValues("Connor_ECRECNForm_Datbase_Config"); String[] fields = session.getPreferenceService().getStringValues("Connor_ECRECNForm_Datbase_Config");
if (fields == null || fields.length <= 0) { if (fields == null || fields.length <= 0) {

@ -55,7 +55,6 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo; import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
@ -86,7 +85,8 @@ public class RWFPDialog extends JFrame implements ActionListener {
private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>(); private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>();
private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>(); private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>();
private LinkedHashMap<Integer, Integer> widtheMap = new LinkedHashMap<Integer, Integer>(); private LinkedHashMap<Integer, Integer> widtheMap = new LinkedHashMap<Integer, Integer>();
//public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100, 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 }; // public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100,
// 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 };
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private DefaultTableModel dtm1; private DefaultTableModel dtm1;
private JButton yyButton = new JButton("应用"); private JButton yyButton = new JButton("应用");
@ -97,19 +97,29 @@ public class RWFPDialog extends JFrame implements ActionListener {
private static ArrayList<String> dateConnList = new ArrayList<String>(); private static ArrayList<String> dateConnList = new ArrayList<String>();
private String type; private String type;
private String id; private String id;
private String objectString;
private boolean readOnly;
private ArrayList<Integer> canWriteColume = new ArrayList<Integer>(); private ArrayList<Integer> canWriteColume = new ArrayList<Integer>();
public RWFPDialog(TCSession session,String type,String id) { public RWFPDialog(TCSession session, String type, String id, String objectString, boolean readOnly) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.session = session; this.session = session;
this.type = type; this.type = type;
this.id = id; this.id = id;
this.objectString = objectString;
this.readOnly = readOnly;
initUI(); initUI();
} }
public void initUI() { public void initUI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
this.setTitle("任务分配表");
if(readOnly) {
yyButton.setEnabled(false);
tzsjButton.setEnabled(false);
}
this.setTitle(objectString+"变更任务分配表");
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
String[] cfdj = session.getPreferenceService().getStringValues("Connor_ChangeTaskForm_TriggerLevelMapping"); String[] cfdj = session.getPreferenceService().getStringValues("Connor_ChangeTaskForm_TriggerLevelMapping");
@ -119,9 +129,18 @@ public class RWFPDialog extends JFrame implements ActionListener {
} }
for (int i = 0; i < cfdj.length; i++) { for (int i = 0; i < cfdj.length; i++) {
String[] split = cfdj[i].split("="); String[] split = cfdj[i].split("=");
cfdjPref.put(split[0],split[1]); if(split[0].equals(type)) {
cfdJComboBox.addItem(split[0]); String[] split2 = split[1].split(";");
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("\\|");
cfdjPref.put(split3[0],split3[1]);
cfdJComboBox.addItem(split3[0]);
}
break;
}
} }
//获取首选项匹配的类型 //获取首选项匹配的类型
@ -172,6 +191,11 @@ public class RWFPDialog extends JFrame implements ActionListener {
System.out.println("fieldsMap====="+fieldsMap); System.out.println("fieldsMap====="+fieldsMap);
System.out.println("positionMap====="+lovPositionMap); System.out.println("positionMap====="+lovPositionMap);
System.out.println("widtheMap====="+widtheMap); System.out.println("widtheMap====="+widtheMap);
if(fieldsMap.size() == 0) {
MessageBox.post("该类型未匹配到首选项!", "提示 ", MessageBox.INFORMATION);
return;
}
Collection<String> valuesCollection = fieldsMap.values(); Collection<String> valuesCollection = fieldsMap.values();
// 将集合转换为数组 // 将集合转换为数组
@ -258,7 +282,6 @@ public class RWFPDialog extends JFrame implements ActionListener {
} }
} }
public void createActionEvent() { public void createActionEvent() {
this.yyButton.addActionListener(this); this.yyButton.addActionListener(this);
this.gbButton.addActionListener(this); this.gbButton.addActionListener(this);
@ -272,7 +295,7 @@ public class RWFPDialog extends JFrame implements ActionListener {
topPanel.setLayout(new PropertyLayout()); topPanel.setLayout(new PropertyLayout());
topPanel.add("1.1.left.center", new JLabel("触发等级 ")); topPanel.add("1.1.left.center", new JLabel("触发等级 "));
topPanel.add("1.2.left.center",cfdJComboBox); topPanel.add("1.2.left.center", cfdJComboBox);
topPanel.add("1.3.left.center", new JLabel(" 触发时间 ")); topPanel.add("1.3.left.center", new JLabel(" 触发时间 "));
cfsjButton = new DateButton(null, "yyyy-MM-dd", false, false, false); cfsjButton = new DateButton(null, "yyyy-MM-dd", false, false, false);
@ -310,12 +333,12 @@ public class RWFPDialog extends JFrame implements ActionListener {
for (Entry<Integer, String> map : lovPositionMap.entrySet()) { for (Entry<Integer, String> map : lovPositionMap.entrySet()) {
JComboBox<String> jComboBox = new JComboBox<String>(); JComboBox<String> jComboBox = new JComboBox<String>();
String value = map.getValue(); String value = map.getValue();
if(value.contains(",")) { if (value.contains(",")) {
String[] split = value.split(","); String[] split = value.split(",");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
jComboBox.addItem(split[i]); jComboBox.addItem(split[i]);
} }
}else { } else {
jComboBox.addItem(value); jComboBox.addItem(value);
} }
table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox)); table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox));
@ -365,10 +388,10 @@ public class RWFPDialog extends JFrame implements ActionListener {
dtm1 = new DefaultTableModel(values, titleNames) { dtm1 = new DefaultTableModel(values, titleNames) {
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
if(canWriteColume.size() > 0) { if (canWriteColume.size() > 0) {
for (int i = 0; i < canWriteColume.size(); i++) { for (int i = 0; i < canWriteColume.size(); i++) {
if(canWriteColume.get(i) == column) { if (canWriteColume.get(i) == column) {
System.out.println("row=========="+row); System.out.println("row==========" + row);
return true; return true;
} }
} }
@ -389,32 +412,31 @@ public class RWFPDialog extends JFrame implements ActionListener {
if (source.equals(this.gbButton)) { if (source.equals(this.gbButton)) {
dispose(); dispose();
} } else if (source.equals(this.yyButton)) {
else if(source.equals(this.yyButton)){ // 保存数据
//保存数据
Connection conn = getConn(); Connection conn = getConn();
PreparedStatement stmt = null; PreparedStatement stmt = null;
for(int i = 0; i < table.getRowCount(); i++){ for (int i = 0; i < table.getRowCount(); i++) {
StringBuilder updateSql = new StringBuilder(); StringBuilder updateSql = new StringBuilder();
updateSql.append("update LY_CHANGETASSKFORM_DETAILS set "); updateSql.append("update LY_CHANGETASSKFORM_DETAILS set ");
for (Entry<String, Integer> map : positionFieldMap.entrySet()) { for (Entry<String, Integer> map : positionFieldMap.entrySet()) {
updateSql.append(map.getKey()); updateSql.append(map.getKey());
String valueAt = (String)table.getValueAt(i,map.getValue()); String valueAt = (String) table.getValueAt(i, map.getValue());
if(valueAt == null || valueAt.isEmpty()) { if (valueAt == null || valueAt.isEmpty()) {
updateSql.append("="); updateSql.append("=");
updateSql.append("null,"); updateSql.append("null,");
}else { } else {
updateSql.append("='"); updateSql.append("='");
updateSql.append(table.getValueAt(i,map.getValue())); updateSql.append(table.getValueAt(i, map.getValue()));
updateSql.append("',"); updateSql.append("',");
} }
} }
//去掉最后一个, // 去掉最后一个,
updateSql.deleteCharAt(updateSql.length() - 1); updateSql.deleteCharAt(updateSql.length() - 1);
updateSql.append(" where ID='"+id+"' and XH='"+table.getValueAt(i,0)+"'"); updateSql.append(" where ID='" + id + "' and XH='" + table.getValueAt(i, 0) + "'");
try { try {
stmt = conn.prepareStatement(updateSql.toString()); stmt = conn.prepareStatement(updateSql.toString());
System.out.println("updateSql========="+updateSql.toString()); System.out.println("updateSql=========" + updateSql.toString());
stmt.execute(); stmt.execute();
} catch (SQLException e1) { } catch (SQLException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -423,94 +445,92 @@ public class RWFPDialog extends JFrame implements ActionListener {
} }
try { try {
if(stmt != null) { if (stmt != null) {
stmt.close(); stmt.close();
} }
if(conn != null) { if (conn != null) {
conn.close(); conn.close();
} }
} catch (SQLException e1) { } catch (SQLException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
}else if(source.equals(this.tzsjButton)){ } else if (source.equals(this.tzsjButton)) {
gsPrefTopLine = new ArrayList<String>(); gsPrefTopLine = new ArrayList<String>();
String selectedItem = (String)cfdJComboBox.getSelectedItem(); String selectedItem = (String) cfdJComboBox.getSelectedItem();
if(selectedItem == null || selectedItem.isEmpty()) { if (selectedItem == null || selectedItem.isEmpty()) {
MessageBox.post("请选择触发等级!", "提示", 2); MessageBox.post("请选择触发等级!", "提示", 2);
return; return;
} }
Date date = cfsjButton.getDate(); Date date = cfsjButton.getDate();
if(date == null) { if (date == null) {
MessageBox.post("请选择触发时间!", "提示", 2); MessageBox.post("请选择触发时间!", "提示", 2);
return; return;
} }
String cfsjDate = dateFormat.format(date); String cfsjDate = dateFormat.format(date);
String pref = cfdjPref.get(selectedItem); String pref = cfdjPref.get(selectedItem);
if(pref == null || pref.isEmpty()) { if (pref == null || pref.isEmpty()) {
MessageBox.post("未配置触发等级相关的首选项!", "提示", 2); MessageBox.post("未配置触发等级相关的首选项!", "提示", 2);
return; return;
} }
String[] calculateTime = session.getPreferenceService().getStringValues(pref); String[] calculateTime = session.getPreferenceService().getStringValues(pref);
if (calculateTime == null || calculateTime.length <= 0) { if (calculateTime == null || calculateTime.length <= 0) {
MessageBox.post("请配置首选项“"+pref+"”", "提示 ", MessageBox.INFORMATION); MessageBox.post("请配置首选项“" + pref + "”", "提示 ", MessageBox.INFORMATION);
return; return;
} }
for (int i = 0; i < calculateTime.length; i++) { for (int i = 0; i < calculateTime.length; i++) {
String[] split = calculateTime[i].split("\\|"); String[] split = calculateTime[i].split("\\|");
if(i == 0) { if (i == 0) {
for (int j = 0; j < split.length; j++) { for (int j = 0; j < split.length; j++) {
gsPrefTopLine.add(split[j]); gsPrefTopLine.add(split[j]);
} }
}else { } else {
gsPrefMap.put(split[0],calculateTime[i]); gsPrefMap.put(split[0], calculateTime[i]);
} }
} }
System.out.println(positionFieldMap+"==================positionFieldMap"); System.out.println(positionFieldMap + "==================positionFieldMap");
System.out.println("gsPrefTopLine----------------"+gsPrefTopLine.size()); System.out.println("gsPrefTopLine----------------" + gsPrefTopLine.size());
Integer xh = positionFieldMap.get(gsPrefTopLine.get(0)); Integer xh = positionFieldMap.get(gsPrefTopLine.get(0));
//表里table 开始计算 // 表里table 开始计算
for(int i = 0; i < table.getRowCount(); i++){ for (int i = 0; i < table.getRowCount(); i++) {
String xhStr = table.getValueAt(i, xh).toString(); String xhStr = table.getValueAt(i, xh).toString();
String gsStr = gsPrefMap.get(xhStr); String gsStr = gsPrefMap.get(xhStr);
if(gsStr != null && !gsStr.isEmpty() ) { if (gsStr != null && !gsStr.isEmpty()) {
String[] split = gsStr.split("\\|"); String[] split = gsStr.split("\\|");
for (int j = 1; j < gsPrefTopLine.size(); j++) { for (int j = 1; j < gsPrefTopLine.size(); j++) {
//如果有值 // 如果有值
System.out.println("gsPrefTopLine.get(j)========"+gsPrefTopLine.get(j)); System.out.println("gsPrefTopLine.get(j)========" + gsPrefTopLine.get(j));
Integer colume = positionFieldMap.get(gsPrefTopLine.get(j)); Integer colume = positionFieldMap.get(gsPrefTopLine.get(j));
if(colume != null) { if (colume != null) {
System.out.println(positionFieldMap.get(gsPrefTopLine.get(j))+"=================positionFieldMap.get(gsPrefTopLine.get(j))"); System.out.println(positionFieldMap.get(gsPrefTopLine.get(j))
//处理公式 + "=================positionFieldMap.get(gsPrefTopLine.get(j))");
// 处理公式
String gs = split[j]; String gs = split[j];
System.out.println("gs========"+gs); System.out.println("gs========" + gs);
if(gs.equals("N")) { if (gs.equals("N")) {
table.setValueAt(cfsjDate,i, colume); table.setValueAt(cfsjDate, i, colume);
}else { } else {
String[] split2 = gs.split("N"); String[] split2 = gs.split("N");
String time = calculateDate(cfsjDate, Integer.parseInt(split2[1])); String time = calculateDate(cfsjDate, Integer.parseInt(split2[1]));
System.out.println("time============"+time); System.out.println("time============" + time);
table.setValueAt(time,i, colume); table.setValueAt(time, i, colume);
} }
} }
} }
} }
} }
//调用应用按钮 // 调用应用按钮
yyButton.doClick(); yyButton.doClick();
MessageBox.post("调整时间完成!", "提示", 2); MessageBox.post("调整时间完成!", "提示", 2);
} }

@ -31,18 +31,65 @@ public class RWFPHandler extends AbstractHandler {
// MessageBox.post(app.getDesktop(), "请选择系统总目录文件夹进行导入!", "导入位置选择", MessageBox.WARNING); // MessageBox.post(app.getDesktop(), "请选择系统总目录文件夹进行导入!", "导入位置选择", MessageBox.WARNING);
// return null; // return null;
// } // }
//ÅжÏÊÇ·ñ¿É±à¼­
boolean readOnly = true;
String userId = "";
try {
userId = session.getUser().getUserId();
} catch (TCException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
String[] templates = session.getPreferenceService().getStringValues("Connor_TaskForm_ChangeDateButton_User");
if(templates != null && templates.length > 0 && userId != null && !userId.isEmpty()) {
if(templates[0].contains(userId)) {
readOnly = false;
}
}
final boolean readOnlyFinal = readOnly;
InterfaceAIFComponent target = app.getTargetComponent(); InterfaceAIFComponent target = app.getTargetComponent();
if(target instanceof TCComponentItem) { if(target instanceof TCComponentItem) {
TCComponentItem item = (TCComponentItem)target; TCComponentItem item = (TCComponentItem)target;
String type = item.getType(); String type = item.getType();
try { try {
String id = item.getStringProperty("item_id"); String id = item.getStringProperty("item_id");
String objectString = item.getStringProperty("object_string");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
new RWFPDialog(session,type,id,objectString,readOnlyFinal);
//d.setModal(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else if(target instanceof TCComponentItemRevision){
TCComponentItemRevision rev = (TCComponentItemRevision)target;
TCComponentItem item = null;
try {
item = rev.getItem();
} catch (TCException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
String type = item.getType();
try {
String id = item.getStringProperty("item_id");
String objectString = item.getStringProperty("object_string");
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
new RWFPDialog(session,type,id); new RWFPDialog(session,type,id,objectString,readOnlyFinal);
//d.setModal(true); //d.setModal(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -54,6 +101,7 @@ public class RWFPHandler extends AbstractHandler {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
}else { }else {
MessageBox.post(app.getDesktop(), "请选择正确对象!", "提示", MessageBox.WARNING); MessageBox.post(app.getDesktop(), "请选择正确对象!", "提示", MessageBox.WARNING);
return null; return null;

@ -17,11 +17,14 @@ public class CheckBoxTreeNodeSelectionListener extends MouseAdapter
int y = event.getY(); int y = event.getY();
int row = tree.getRowForLocation(x, y); int row = tree.getRowForLocation(x, y);
TreePath path = tree.getPathForRow(row); TreePath path = tree.getPathForRow(row);
System.out.println(path);
if(path != null) if(path != null)
{ {
CheckBoxTreeNode node = (CheckBoxTreeNode)path.getLastPathComponent(); CheckBoxTreeNode node = (CheckBoxTreeNode)path.getLastPathComponent();
System.out.println(node);
if(node != null) if(node != null)
{ {
boolean isSelected = !node.isSelected(); boolean isSelected = !node.isSelected();
node.setSelected(isSelected); node.setSelected(isSelected);
((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node); ((DefaultTreeModel)tree.getModel()).nodeStructureChanged(node);

@ -7,6 +7,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import javax.swing.JButton; import javax.swing.JButton;
@ -44,7 +46,7 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
private JTree jtree; private JTree jtree;
private JButton okButton; private JButton okButton;
private JButton celButton; private JButton celButton;
private HashMap<String, String> preMap = new HashMap<String, String>(); private HashMap<String, ArrayList<String>> preMap = new HashMap<String, ArrayList<String>>();
public static final String preName = "connor_LY6_FolderTemp"; public static final String preName = "connor_LY6_FolderTemp";
@ -90,7 +92,11 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
if(prefVal.contains("=")) { if(prefVal.contains("=")) {
String[] split = prefVal.split("="); String[] split = prefVal.split("=");
modelBox.addItem(split[0]); modelBox.addItem(split[0]);
preMap.put(split[0], split[1]); ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add(split[1]);
arrayList.add(split[2]);
arrayList.add(split[3]);
preMap.put(split[0], arrayList);
} }
} }
} }
@ -131,7 +137,8 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
* @param tree * @param tree
*/ */
private void initTree(JTree tree){ private void initTree(JTree tree){
String puid = preMap.get(modelBox.getSelectedItem()); ArrayList<String> list = preMap.get(modelBox.getSelectedItem());
String puid = list.get(0);
TCComponent component; TCComponent component;
try { try {
component = session.stringToComponent(puid); component = session.stringToComponent(puid);
@ -214,18 +221,19 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String name = nameField.getText(); String name = nameField.getText();
ArrayList<String> list = preMap.get(modelBox.getSelectedItem());
if (name.isEmpty()) { if (name.isEmpty()) {
MessageBox.post("请填写项目名称!", "提示 ", MessageBox.INFORMATION); MessageBox.post("请填写项目名称!", "提示 ", MessageBox.INFORMATION);
} else { } else {
TCComponentFolderType folderType; TCComponentFolderType folderType;
try { try {
KUtil.setByPass(true); KUtil.setByPass(true);
folderType = (TCComponentFolderType) session.getTypeComponent("LD6_CusProdFolder"); folderType = (TCComponentFolderType) session.getTypeComponent(list.get(1));
TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), name); TCComponentFolder folder = KUtil.createFolderBySOA(folderType.getTypeName(), name);
//TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder"); //TCComponentFolder folder = folderType.create(name, "", "LD6_CusProdFolder");
target.add("contents", folder); target.add("contents", folder);
CheckBoxTreeNode root = (CheckBoxTreeNode) jtree.getModel().getRoot(); CheckBoxTreeNode root = (CheckBoxTreeNode) jtree.getModel().getRoot();
createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent("LD6_ProjMaFolder"),true); createFolderStruct(root,folder,(TCComponentFolderType) session.getTypeComponent(list.get(2)),true);
KUtil.setByPass(false); KUtil.setByPass(false);
disposeDialog(); disposeDialog();
} catch (Exception e1) { } catch (Exception e1) {
@ -239,6 +247,15 @@ public class CreateProjectStructDialog extends AbstractAIFDialog{
if(event.getStateChange() == ItemEvent.SELECTED) { if(event.getStateChange() == ItemEvent.SELECTED) {
//重新刷新树 //重新刷新树
jtree.setModel(null); jtree.setModel(null);
// 获取并移除所有的 MouseListener
MouseListener[] mouseListeners = jtree.getMouseListeners();
for (MouseListener listener : mouseListeners) {
jtree.removeMouseListener(listener);
}
// 重新验证和重绘
jtree.revalidate();
jtree.repaint();
initTree(jtree); initTree(jtree);
}else if(event.getStateChange() == ItemEvent.DESELECTED){ }else if(event.getStateChange() == ItemEvent.DESELECTED){

@ -1,5 +1,18 @@
package com.langtech.plm.mpart; package com.langtech.plm.mpart;
/**
* ===============================================================================
* Copyright (c) 2012-2024 CONNOR lijh. Unpublished - All Rights Reserved
* ===============================================================================
* File description: Mpart
*
* ===============================================================================
* DATE Name Description of Change
*
* ===============================================================================
*/
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
@ -1094,6 +1107,7 @@ public class MpartDialog extends JFrame implements ActionListener {
return panel; return panel;
} }
//获取右边的panel
private JPanel getTablePanel2() { private JPanel getTablePanel2() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.setPreferredSize(new Dimension(200, 600)); panel.setPreferredSize(new Dimension(200, 600));
@ -1239,6 +1253,7 @@ public class MpartDialog extends JFrame implements ActionListener {
return formattedNumber; return formattedNumber;
} }
//创建流程
public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException { public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException {
try { try {
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");

@ -1,77 +1,117 @@
package com.langtech.plm.template; //package com.langtech.plm.template;
//
import org.eclipse.core.commands.AbstractHandler; //import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; //import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; //import org.eclipse.core.commands.ExecutionException;
//
import com.teamcenter.rac.aif.AbstractAIFApplication; //import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; //import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility; //import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentItemRevision; //import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentSchedule; //import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentScheduleTask; //import com.teamcenter.rac.kernel.TCComponentSchedule;
import com.teamcenter.rac.kernel.TCSession; //import com.teamcenter.rac.kernel.TCComponentScheduleTask;
import com.teamcenter.rac.util.MessageBox; //import com.teamcenter.rac.kernel.TCException;
//import com.teamcenter.rac.kernel.TCSession;
public class TemplateHandler extends AbstractHandler{ //import com.teamcenter.rac.util.MessageBox;
//
//public class TemplateHandler extends AbstractHandler{
@Override //
public Object execute(ExecutionEvent arg0) throws ExecutionException { //
AbstractAIFApplication app = AIFUtility.getCurrentApplication(); // @Override
TCSession session = (TCSession) app.getSession(); // public Object execute(ExecutionEvent arg0) throws ExecutionException {
try { // AbstractAIFApplication app = AIFUtility.getCurrentApplication();
// TCSession session = (TCSession) app.getSession();
// try {
//
new Thread() { //
@Override //
public void run() { // new Thread() {
InterfaceAIFComponent targetComponent = app.getTargetComponent(); // @Override
// public void run() {
if(targetComponent instanceof TCComponentItemRevision) { // InterfaceAIFComponent targetComponent = app.getTargetComponent();
try { //
String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject"); // String type = targetComponent.getType();
String types = ""; // System.out.println("type==========="+type);
if(pref.length > 0) { // if(targetComponent instanceof TCComponentItemRevision) {
types = pref[0]; // try {
}else { // String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject");
MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2); // String types = "";
return; // if(pref.length > 0) {
} // types = pref[0];
// }else {
TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent; // MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2);
String object_type = rev.getStringProperty("object_type"); // return;
if(types.contains(object_type)) { // }
new TemplateDialog(session,rev,object_type); //
}else { // TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent;
MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2); // String object_type = rev.getStringProperty("object_type");
return; // if(types.contains(object_type)) {
} // new TemplateDialog(session,rev,object_type);
// }else {
// MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2);
// return;
// }
} catch (Exception e) { //
// TODO Auto-generated catch block //
e.printStackTrace(); //
} //
}else { // } catch (Exception e) {
MessageBox.post("请选择版本对象!","提示",2); // // TODO Auto-generated catch block
return; // e.printStackTrace();
} // }
// }else if(type.equals("Mfg0BvrOperation")){
// TCComponent com = (TCComponent) targetComponent;
} // try {
}.start(); // TCComponent rev = com.getRelatedComponent("bl_line_object");
// if(rev instanceof TCComponentItemRevision) {
} catch (Exception e) { // try {
// TODO: handle exception // String[] pref = session.getPreferenceService().getStringValues("LY6_MEOP_TemplateObject");
e.printStackTrace(); // String types = "";
} // if(pref.length > 0) {
// types = pref[0];
return null; // }else {
} // MessageBox.post("请配置首选项LY6_MEOP_TemplateObject","提示",2);
// return;
// }
} //
// TCComponentItemRevision revision = (TCComponentItemRevision)rev;
// String object_type = rev.getStringProperty("object_type");
// if(types.contains(object_type)) {
// new TemplateDialog(session,revision,object_type);
// }else {
// MessageBox.post("请选择首选项LY6_MEOP_TemplateObject中匹配的对象","提示",2);
// return;
// }
//
//
//
//
// } catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// } catch (TCException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }else {
// MessageBox.post("请选择版本对象!","提示",2);
// return;
// }
//
//
// }
// }.start();
//
// } catch (Exception e) {
// // TODO: handle exception
// e.printStackTrace();
// }
//
// return null;
// }
//
//
//}

Loading…
Cancel
Save