Compare commits
26 Commits
Author | SHA1 | Date |
---|---|---|
![]() |
fc7596dfae | 5 months ago |
|
04aff3093f | 5 months ago |
|
0dfbaeede6 | 5 months ago |
|
d535b6aa82 | 5 months ago |
|
01187105a5 | 6 months ago |
|
bf5a9a54f9 | 6 months ago |
|
fd63bc99fd | 6 months ago |
|
3952e9fd98 | 6 months ago |
|
07dfccd9b6 | 6 months ago |
|
6276640680 | 6 months ago |
|
670784ab29 | 6 months ago |
|
abac41c543 | 6 months ago |
|
c54c85f5ed | 7 months ago |
|
317c9cc1b5 | 7 months ago |
|
7354160b9a | 7 months ago |
|
7b35c56dcf | 7 months ago |
|
afb644a5ad | 7 months ago |
|
cdffc110ed | 7 months ago |
|
abc24fee89 | 7 months ago |
|
56cde5eaed | 7 months ago |
|
53a9af372c | 7 months ago |
|
47864d8feb | 7 months ago |
|
4fb130a2eb | 7 months ago |
![]() |
9845db1b4a | 7 months ago |
![]() |
a1b1c57915 | 7 months ago |
|
2b243c95aa | 7 months ago |
@ -1 +0,0 @@
|
||||
/com/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
LD6_NewProdForm.FORMJAVARENDERING=com.langtech.plm.form.LD6_NewProdForm
|
@ -0,0 +1,72 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class CheckHeaderCellRenderer implements TableCellRenderer {
|
||||
DefaultTableModel tableModel;
|
||||
JTableHeader tableHeader;
|
||||
final JCheckBox selectBox;
|
||||
|
||||
public CheckHeaderCellRenderer(final JTable table) {
|
||||
this.tableModel = (DefaultTableModel) table.getModel();
|
||||
this.tableHeader = table.getTableHeader();
|
||||
selectBox = new JCheckBox(tableModel.getColumnName(0));
|
||||
selectBox.setSelected(false);
|
||||
tableHeader.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() > 0) {
|
||||
// 获得选中列
|
||||
int selectColumn = tableHeader.columnAtPoint(e.getPoint());
|
||||
if (selectColumn == 0) {
|
||||
boolean value = !selectBox.isSelected();
|
||||
selectBox.setSelected(value);
|
||||
// tableModel.selectAllOrNull(value);
|
||||
tableHeader.repaint();
|
||||
if(value) {
|
||||
for(int i=0;i<table.getRowCount();i++) {
|
||||
table.setValueAt("1", i, 0);
|
||||
}
|
||||
}else {
|
||||
for(int i=0;i<table.getRowCount();i++) {
|
||||
table.setValueAt("0", i, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
String valueStr = (String) value;
|
||||
JLabel label = new JLabel(valueStr);
|
||||
label.setHorizontalAlignment(SwingConstants.CENTER); // 表头标签剧中
|
||||
selectBox.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中
|
||||
selectBox.setBorderPainted(true);
|
||||
JComponent component = (column == 0) ? selectBox : label;
|
||||
|
||||
component.setForeground(tableHeader.getForeground());
|
||||
component.setBackground(tableHeader.getBackground());
|
||||
component.setFont(tableHeader.getFont());
|
||||
component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.PropertyLayout;
|
||||
|
||||
public class QDRWChooseDialog extends JFrame implements ActionListener {
|
||||
|
||||
|
||||
private JComboBox<String> objectComboBox = new JComboBox<String>();
|
||||
private JButton okButton = new JButton("确定");
|
||||
private JButton concelButton = new JButton("取消");
|
||||
private String[] strings;
|
||||
private AbstractAIFUIApplication app;
|
||||
private HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
|
||||
public QDRWChooseDialog(String[] strings,AbstractAIFUIApplication app) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.strings = strings;
|
||||
this.app = app;
|
||||
initUI();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void initUI() {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
this.setTitle("请选择变更模板");
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
JPanel topPanel = getTopPanel();
|
||||
|
||||
JPanel btnPanel = getBtnPanel();
|
||||
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
// this.add(pane,BorderLayout.CENTER);
|
||||
this.add(btnPanel, BorderLayout.SOUTH);
|
||||
this.setPreferredSize(new Dimension(350, 150));
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸
|
||||
int screenWidth = screenSize.width; // 获取屏幕宽度
|
||||
int screenHeight = screenSize.height; // 获取屏幕高度
|
||||
int x = (screenWidth - 350) / 2; // 计算Frame的左上角x坐标
|
||||
int y = (screenHeight - 150) / 2; // 计算Frame的左上角y坐标
|
||||
this.setLocation(x, y); // 设置Frame的位置
|
||||
|
||||
// this.setLocationRelativeTo(null);
|
||||
this.createActionEvent();
|
||||
this.pack();
|
||||
|
||||
// this.validate();
|
||||
this.setVisible(true);
|
||||
|
||||
// this.setAlwaysOnTop(true);
|
||||
|
||||
//设置下拉值
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
String[] split = strings[i].split("=");
|
||||
objectComboBox.addItem(split[0]);
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(split[1]);
|
||||
list.add(split[2]);
|
||||
list.add(split[3]);
|
||||
map.put(split[0], list);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加监听
|
||||
public void createActionEvent() {
|
||||
|
||||
this.okButton.addActionListener(this);
|
||||
this.concelButton.addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Object source = e.getSource();
|
||||
System.out.println("source==>+" + source);
|
||||
if (this.okButton.equals(source)) {
|
||||
String selectedItem = (String) objectComboBox.getSelectedItem();
|
||||
ArrayList<String> arrayList = map.get(selectedItem);
|
||||
new QDRWDialog((TCSession)app.getSession(),arrayList.get(0),arrayList.get(1),selectedItem,arrayList.get(2));
|
||||
System.out.println("newnewnwenew");
|
||||
this.dispose();
|
||||
} else if (this.concelButton.equals(source)) {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private JPanel getBtnPanel() {
|
||||
JPanel topPanel = new JPanel();
|
||||
topPanel.setLayout(new PropertyLayout());
|
||||
topPanel.add("1.1.center", new JLabel(""));
|
||||
topPanel.add("2.1.center", new JLabel(" "));
|
||||
topPanel.add("2.2.center", okButton);
|
||||
topPanel.add("2.3.center", new JLabel(""));
|
||||
topPanel.add("2.4.center", concelButton);
|
||||
topPanel.add("3.1.center", new JLabel(""));
|
||||
topPanel.add("4.1.center", new JLabel(""));
|
||||
return topPanel;
|
||||
}
|
||||
|
||||
// 查询部分
|
||||
private JPanel getTopPanel() {
|
||||
// TODO Auto-generated method stub
|
||||
JPanel topPanel = new JPanel();
|
||||
topPanel.setLayout(new PropertyLayout());
|
||||
topPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
topPanel.add("1.1.left.center", new JLabel(""));
|
||||
topPanel.add("2.1.left.center", new JLabel(""));
|
||||
topPanel.add("3.1.left.center", new JLabel(""));
|
||||
topPanel.add("4.1.left.center", new JLabel(""));
|
||||
|
||||
topPanel.add("5.1.left.center", new JLabel(" 变更模板:"));
|
||||
topPanel.add("5.2.left.center", objectComboBox);
|
||||
|
||||
return topPanel;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.JTable;
|
||||
|
||||
|
||||
public class QDRWTableColorRender extends TableColorRender {
|
||||
public LinkedHashMap<String,LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
|
||||
public LinkedHashMap<Integer, String> colorMap;
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component renderer = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
|
||||
String id = (String)table.getValueAt(row, 1);
|
||||
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id);
|
||||
//System.out.println("colorMap======"+colorMap.toString());
|
||||
for (Entry<Integer, String> map : colorMap.entrySet()) {
|
||||
Integer columnColor = map.getKey();
|
||||
if(column == columnColor) {
|
||||
//System.out.println("columnColor========"+columnColor);
|
||||
String prefValue = map.getValue();
|
||||
String[] split = prefValue.split("\\.");
|
||||
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[0]);
|
||||
String sjwcsj = "";
|
||||
String RWXDSJ = "";
|
||||
String jhjs = "";
|
||||
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
|
||||
if(arrayList.get(i).containsKey("SJWCSJ")) {
|
||||
sjwcsj = arrayList.get(i).get("SJWCSJ");
|
||||
}
|
||||
if(arrayList.get(i).containsKey("RWXDSJ")) {
|
||||
RWXDSJ = arrayList.get(i).get("RWXDSJ");
|
||||
}
|
||||
if(arrayList.get(i).containsKey("JHJS")) {
|
||||
jhjs = arrayList.get(i).get("JHJS");
|
||||
}
|
||||
}
|
||||
//System.out.println("sjwcsj========"+sjwcsj);
|
||||
//System.out.println("jhks========"+jhks);
|
||||
//System.out.println("jhjs========"+jhjs);
|
||||
if(sjwcsj != null && !sjwcsj.isEmpty()) {
|
||||
renderer.setBackground(Color.GREEN);
|
||||
}else {
|
||||
if(jhjs != null && !jhjs.isEmpty() && RWXDSJ != null && !RWXDSJ.isEmpty()) {
|
||||
if(isNotAfterCurrentDate(jhjs)) {
|
||||
renderer.setBackground(Color.RED);
|
||||
|
||||
|
||||
// System.out.println("row==="+row+"===column==="+column);
|
||||
}else {
|
||||
//setBackground(Color.YELLOW);
|
||||
renderer.setBackground(Color.GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNotAfterCurrentDate(String dateStr) {
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
try {
|
||||
// 解析字符串为 LocalDate 对象
|
||||
LocalDate inputDate = LocalDate.parse(dateStr, formatter);
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
// 比较两个日期
|
||||
return !inputDate.isAfter(currentDate); // 返回 true 如果输入日期 <= 当前日期
|
||||
|
||||
} catch (DateTimeParseException e) {
|
||||
// 处理解析异常
|
||||
System.out.println("Invalid date format: " + e.getMessage());
|
||||
return false; // 或者你也可以选择抛出异常,或者根据需求做其他处理
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
|
||||
public class RWFPHandler extends AbstractHandler {
|
||||
|
||||
private AbstractAIFUIApplication app;
|
||||
private TCSession session;
|
||||
// private InterfaceAIFComponent target;
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
app = AIFUtility.getCurrentApplication();
|
||||
session = (TCSession) app.getSession();
|
||||
// target = app.getTargetComponent();
|
||||
// if (target == null || !(target instanceof TCComponentFolder)) {
|
||||
// MessageBox.post(app.getDesktop(), "请选择系统总目录文件夹进行导入!", "导入位置选择", MessageBox.WARNING);
|
||||
// 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();
|
||||
if(target instanceof TCComponentItem) {
|
||||
TCComponentItem item = (TCComponentItem)target;
|
||||
String type = item.getType();
|
||||
try {
|
||||
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() {
|
||||
@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 {
|
||||
MessageBox.post(app.getDesktop(), "请选择正确对象!", "提示", MessageBox.WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
import com.teamcenter.rac.treetable.JTreeTable;
|
||||
|
||||
|
||||
public class TableCellCheckboxRenderer extends JCheckBox implements
|
||||
TableCellRenderer {
|
||||
private List<Integer> processRows;
|
||||
protected EventListenerList listenerList = new EventListenerList();
|
||||
protected ChangeEvent changeEvent = new ChangeEvent(this);
|
||||
//private TestTreeTableModel tableModel;
|
||||
|
||||
public List<Integer> getProcessRows() {
|
||||
return processRows;
|
||||
}
|
||||
|
||||
public void setProcessRows(List<Integer> processRows) {
|
||||
this.processRows = processRows;
|
||||
|
||||
}
|
||||
public TableCellCheckboxRenderer(final JTable table) {
|
||||
}
|
||||
public TableCellCheckboxRenderer(final JTreeTable table) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
// TODO Auto-generated method stub
|
||||
this.setHorizontalAlignment(SwingConstants.CENTER);// ±íÍ·±êÇ©¾çÖÐ
|
||||
// this.setBorderPainted(true);
|
||||
|
||||
if(value != null)
|
||||
{
|
||||
this.setSelected(value.toString().equals("1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setSelected(false);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.langtech.plm.bg;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class TableColorRender implements TableCellRenderer {
|
||||
//
|
||||
public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer();
|
||||
|
||||
//IntegerÁÐ String±êʶ ColorÑÕÉ«
|
||||
public HashMap<Integer, HashMap<String, Color>> allForegroundInfos = new HashMap<Integer, HashMap<String, Color>>();
|
||||
public HashMap<Integer, Integer> allFColorColumn = new HashMap<Integer, Integer>();
|
||||
|
||||
//IntegerÁÐ String±êʶ ColorÑÕÉ«
|
||||
public HashMap<Integer, HashMap<String, Color>> allBackgroundInfos = new HashMap<Integer, HashMap<String, Color>>();
|
||||
public HashMap<Integer, Integer> allBColorColumn = new HashMap<Integer, Integer>();
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
if (value != null && value instanceof String) {
|
||||
Color foreground = table.getForeground();
|
||||
Color background = table.getBackground();
|
||||
if (isSelected) {
|
||||
background = new Color(10, 36, 106);
|
||||
}
|
||||
|
||||
Boolean bSetFG = false;
|
||||
Integer infoCol = allFColorColumn.get(column);
|
||||
if (infoCol != null) {
|
||||
HashMap<String, Color> fgc = allForegroundInfos.get(infoCol);
|
||||
if (fgc != null) {
|
||||
String infoValue = table.getValueAt(row, infoCol).toString();
|
||||
Color color = fgc.get(infoValue);
|
||||
if (color != null) {
|
||||
foreground = color;
|
||||
bSetFG = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Boolean bSetBG = false;
|
||||
infoCol = allBColorColumn.get(column);
|
||||
if (infoCol != null) {
|
||||
HashMap<String, Color> bgc = allBackgroundInfos.get(infoCol);
|
||||
if (bgc != null) {
|
||||
String infoValue = table.getValueAt(row, infoCol).toString();
|
||||
Color color = bgc.get(infoValue);
|
||||
if (color != null) {
|
||||
background = color;
|
||||
bSetBG = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bSetFG && !bSetBG && isSelected) {
|
||||
foreground = Color.WHITE;
|
||||
}
|
||||
|
||||
renderer.setForeground(foreground);
|
||||
renderer.setBackground(background);
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.langtech.plm.modifyEffectiveTime;
|
||||
|
||||
import org.jdesktop.swingx.JXDatePicker;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.EventObject;
|
||||
|
||||
public class DatePickerEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
|
||||
private JXDatePicker datePicker;
|
||||
private JTable table;
|
||||
private int row;
|
||||
private int column;
|
||||
|
||||
public DatePickerEditor() {
|
||||
datePicker = new JXDatePicker();
|
||||
// 设置日期格式
|
||||
datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
|
||||
datePicker.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
fireEditingStopped();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
this.table = table;
|
||||
this.row = row;
|
||||
this.column = column;
|
||||
|
||||
System.out.println("getTableCellEditorComponent: "+value);
|
||||
if (value instanceof Date) {
|
||||
datePicker.setDate((Date) value);
|
||||
} else {
|
||||
datePicker.setDate(null);
|
||||
}
|
||||
return datePicker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
try {
|
||||
// 获取用户输入的文本
|
||||
String text = datePicker.getEditor().getText();
|
||||
|
||||
if (text.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 尝试将输入解析为日期
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||
format.setLenient(false); // 严格解析日期格式
|
||||
return format.parse(text);
|
||||
} catch (Exception e) {
|
||||
// 如果解析失败,打印错误信息并返回当前日期选择器的值
|
||||
System.err.println("Invalid date format: " + e.getMessage());
|
||||
}
|
||||
|
||||
// 返回日期选择器当前的值
|
||||
return datePicker.getDate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(EventObject anEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
System.out.println("stopCellEditing: " + datePicker.getDate());
|
||||
fireEditingStopped();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSelectCell(EventObject anEvent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelCellEditing() {
|
||||
super.cancelCellEditing();
|
||||
}
|
||||
}
|
@ -0,0 +1,265 @@
|
||||
package com.langtech.plm.modifyEffectiveTime;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import org.jdesktop.swingx.JXDatePicker;
|
||||
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.kernel.TCUserService;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class ModifyEffectiveTimeDialog extends JFrame implements Runnable {
|
||||
private JTable table;
|
||||
|
||||
private JButton okButton;
|
||||
private boolean flag;
|
||||
|
||||
private final String title;
|
||||
private final String[] columnNames;
|
||||
private Object[][] data;
|
||||
private int[] dateIndex;
|
||||
private boolean pass;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public ModifyEffectiveTimeDialog(String title, Object... args) {
|
||||
this.title = title;
|
||||
this.columnNames = (String[]) args[0];
|
||||
this.data = (Object[][]) args[1];
|
||||
this.dateIndex = (int[]) args[2];
|
||||
this.pass = (boolean) args[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
initUI();
|
||||
}
|
||||
|
||||
public void setWithHeight(int with, int height) {
|
||||
this.setSize(with, height);
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
this.setTitle(title);
|
||||
// 初始化所有信息
|
||||
initializationComponent();
|
||||
|
||||
// 添加内容到JFrame 并设置它的位置
|
||||
JPanel bottomPanel = getBottomPanel();
|
||||
// 创建表格和滚动条
|
||||
JPanel tableScrollPane = createTable();
|
||||
tableScrollPane.setPreferredSize(new Dimension(700, 200)); // 设置滚动条的大小
|
||||
|
||||
this.getContentPane().add(tableScrollPane, BorderLayout.CENTER);
|
||||
this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
|
||||
// 设置窗口居中
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
// 设置可见性
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void initializationComponent() {
|
||||
okButton = new JButton("应用");
|
||||
okButton.setEnabled(pass);
|
||||
}
|
||||
|
||||
public JPanel createTable() {
|
||||
JPanel panel = new JPanel(new BorderLayout(10, 10));
|
||||
panel.setBorder(new EmptyBorder(20, 20, 10, 20));
|
||||
|
||||
// 创建 DefaultTableModel 实例
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
if (column == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex == 1) {
|
||||
return Date.class;
|
||||
}
|
||||
return super.getColumnClass(columnIndex);
|
||||
}
|
||||
};
|
||||
table = new JTable(model);
|
||||
|
||||
// 设置行高
|
||||
table.setRowHeight(25); // 设置行高为30像素
|
||||
table.setFont(new Font("微软雅黑", Font.PLAIN, 12));
|
||||
// 禁用列重排序
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
// 禁用自动调整列宽
|
||||
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
// 设置表格填满视口高度
|
||||
// table.setFillsViewportHeight(true);
|
||||
|
||||
// 设置列宽
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
columnModel.getColumn(0).setPreferredWidth(300);
|
||||
columnModel.getColumn(1).setPreferredWidth(143);
|
||||
|
||||
table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 1));
|
||||
|
||||
// 自定义渲染器,使所有列居中对齐
|
||||
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER); // 设置文本居中对齐
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
// 应用居中对齐渲染器
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
columnModel.getColumn(i).setCellRenderer(centerRenderer);
|
||||
}
|
||||
|
||||
// 自定义渲染器
|
||||
TableCellRenderer dateRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column) -> {
|
||||
JXDatePicker datePicker = new JXDatePicker();
|
||||
if (value instanceof Date) {
|
||||
datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
|
||||
datePicker.setDate((Date) value);
|
||||
}
|
||||
return datePicker;
|
||||
};
|
||||
// 自定义编辑器
|
||||
TableCellEditor dateEditor = new DatePickerEditor();
|
||||
|
||||
// 为 IssueDate 和 MaterialDeliveryTime 列设置日期选择器
|
||||
for (int index : dateIndex) {
|
||||
// 设置渲染器和编辑器
|
||||
table.getColumnModel().getColumn(index).setCellRenderer(dateRenderer);
|
||||
table.getColumnModel().getColumn(index).setCellEditor(dateEditor);
|
||||
}
|
||||
|
||||
// 创建 JScrollPane 并设置水平滚动条始终可见
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
|
||||
// 添加表格到中心区域
|
||||
panel.add(scrollPane, BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
|
||||
public JPanel getBottomPanel() {
|
||||
// TODO Auto-generated method stub
|
||||
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
|
||||
bottomPanel.setBorder(BorderFactory.createEmptyBorder(-10, 0, 10, 0));
|
||||
bottomPanel.add(this.okButton);
|
||||
// 添加监听
|
||||
okButton.addActionListener(e -> {
|
||||
flag = true;
|
||||
List<String[]> tableData = getTableData();
|
||||
if (tableData != null) {
|
||||
tableData.forEach(rowData -> {
|
||||
System.out.println(Arrays.toString(rowData));
|
||||
});
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
MessageBox.post("修改成功! ", "Info", MessageBox.INFORMATION);
|
||||
this.dispose(); // 关闭窗口
|
||||
} else {
|
||||
MessageBox.post("生效时间不允许超出两行", "Error", MessageBox.ERROR);
|
||||
}
|
||||
});
|
||||
return bottomPanel;
|
||||
}
|
||||
|
||||
public List<String[]> getTableData() {
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
int rowCount = model.getRowCount();
|
||||
int columnCount = model.getColumnCount();
|
||||
|
||||
List<String[]> tableData = new ArrayList<>();
|
||||
|
||||
int count = 0;
|
||||
for (int row = 0; row < rowCount; row++) {
|
||||
Object obj = model.getValueAt(row, 1);
|
||||
if (obj instanceof Date && obj != null) {
|
||||
count++;
|
||||
if (count == 3) {
|
||||
flag = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setByPass(true);
|
||||
try {
|
||||
for (int row = 0; row < rowCount; row++) {
|
||||
String name = (String) model.getValueAt(row, 0);
|
||||
Object obj = model.getValueAt(row, 1);
|
||||
System.out.println("name: " + name + " || date: " + obj);
|
||||
TCComponentItemRevision rev = (TCComponentItemRevision) model.getValueAt(row, 2);
|
||||
rev.setDateProperty("ly6_deadline", (Date) obj);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
setByPass(false);
|
||||
return tableData;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setByPass(boolean pass) {
|
||||
TCUserService userservice = null;
|
||||
if (userservice == null) {
|
||||
userservice = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getUserService();
|
||||
}
|
||||
Object[] obj = new Object[1];
|
||||
obj[0] = "origin";
|
||||
try {
|
||||
if (pass) {
|
||||
userservice.call("CONNOR_open_bypass", obj);
|
||||
System.out.println("旁路已开启");
|
||||
} else {
|
||||
userservice.call("CONNOR_close_bypass", obj);
|
||||
System.out.println("旁路已关闭");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.langtech.plm.modifyEffectiveTime;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCPreferenceService;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class ModifyEffectiveTimeHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) app.getSession();
|
||||
|
||||
TCPreferenceService preferenceService = session.getPreferenceService();
|
||||
String[] preValues = preferenceService.getStringValues("LY__FormulaDeadLine_Config");
|
||||
if ((preValues != null && preValues.length < 3) || preValues == null) {
|
||||
MessageBox.post("LY__FormulaDeadLine_Config配置错误", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] types = preValues[0].split(";");
|
||||
String[] childTypes = preValues[1].split(";");
|
||||
String[] permissionPeo = preValues[2].split(";");
|
||||
|
||||
TCComponent targetComponent = (TCComponent)app.getTargetComponent();
|
||||
|
||||
String targetType = "";
|
||||
try {
|
||||
if(targetComponent instanceof TCComponentItemRevision) {
|
||||
targetType = targetComponent.getType();
|
||||
}else if(targetComponent instanceof TCComponentBOMLine) {
|
||||
targetType = ((TCComponentBOMLine) targetComponent).getItemRevision().getType();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean isExist = false;
|
||||
System.out.println("当前类型:" + targetType);
|
||||
for (String type : types) {
|
||||
System.out.println("当前配置类型:" + type);
|
||||
if (type.equals(targetType)) {
|
||||
isExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExist) {
|
||||
MessageBox.post("请选择指定类型的牌号版本执行修改配方生效日期功能", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean pass = false;
|
||||
String userName = session.getUserName();
|
||||
System.out.println("当前用户:" + userName);
|
||||
for (String name : permissionPeo) {
|
||||
System.out.println("当前配置用户:" + name);
|
||||
if (userName.equals(name)) {
|
||||
pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Object[][] data = null;
|
||||
try {
|
||||
List<TCComponentItemRevision> revList = getChildBom(session, targetComponent, childTypes);
|
||||
data = new Object[revList.size()][];
|
||||
|
||||
for (int i = 0; i < revList.size(); i++) {
|
||||
TCComponentItemRevision tempRev = revList.get(i);
|
||||
Object[] tempData = new Object[3];
|
||||
tempData[0] = tempRev.getProperty("object_string");
|
||||
tempData[1] = parseDate(tempRev.getProperty("ly6_deadline"));
|
||||
tempData[2] = tempRev;
|
||||
|
||||
data[i] = tempData;
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 表格列标题
|
||||
String[] columnNames = new String[] { "对象", "生效时间", "TCComponent" };
|
||||
int[] dateIndex = new int[] { 1 };
|
||||
ModifyEffectiveTimeDialog dialog = new ModifyEffectiveTimeDialog("修改配方生效时间", columnNames, data, dateIndex,
|
||||
pass);
|
||||
dialog.setWithHeight(500, 300);
|
||||
|
||||
new Thread(dialog).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<TCComponentItemRevision> getChildBom(TCSession session, TCComponent targetComponent,
|
||||
String[] childTypes) throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
TCComponentBOMLine topLine = null;
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent;
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
TCComponentBOMWindow view = winType.create(null);
|
||||
topLine = view.setWindowTopLine(rev.getItem(), rev, null, null);
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
topLine = ((TCComponentBOMLine) targetComponent);
|
||||
}
|
||||
|
||||
boolean hasChildren = topLine.hasChildren();
|
||||
List<TCComponentItemRevision> revList = new ArrayList<TCComponentItemRevision>();
|
||||
if (!hasChildren) {
|
||||
return revList;
|
||||
}
|
||||
|
||||
String revType = "";
|
||||
AIFComponentContext[] childrena = topLine.getChildren();
|
||||
for (AIFComponentContext children : childrena) {
|
||||
TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent();
|
||||
TCComponentItemRevision itemRevision = component.getItemRevision();
|
||||
// revType = itemRevision.getProperty("object_type");
|
||||
revType = itemRevision.getType();
|
||||
System.out.println("子类对象类型getType()获取的值:" + revType);
|
||||
for (String type : childTypes) {
|
||||
System.out.println("子类配置对象类型:" + type);
|
||||
if (revType.equals(type)) {
|
||||
revList.add(itemRevision);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return revList;
|
||||
}
|
||||
|
||||
public Date parseDate(String dateString) {
|
||||
if (dateString == null || dateString.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
try {
|
||||
return sdf.parse(dateString);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue