parent
2f680a47fb
commit
7a424249b5
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateNPIprojectOnQuotationHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateNPIprojectOnQuotationAction action = new CreateNPIprojectOnQuotationAction(application, null, null);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package com.connor.ferrorTech.metal;
|
||||
|
||||
import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
UploadDialog uploadDialog = new UploadDialog(null);
|
||||
uploadDialog.initUi();
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.batchDownload;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class BatchDownloadHandler extends AbstractHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI","VF5xmwjj","Folder"}, "Folder");
|
||||
if(judgeSingleSelectComponent) {
|
||||
BatchDownloadDialog dialog = new BatchDownloadDialog(application);
|
||||
new Thread(dialog).start();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,172 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.bomProcess;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentProcessType;
|
||||
import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
|
||||
import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
|
||||
|
||||
public class ApprovalOfBomProcessHandler extends AbstractHandler {
|
||||
|
||||
private TCComponentFolder[] targetFolders;
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
TCSession tcSession = (TCSession) application.getSession();
|
||||
String errorName = "";
|
||||
try {
|
||||
errorName = judgeFolder(application);
|
||||
|
||||
if (errorName != null && !errorName.isEmpty()) {
|
||||
MessageBox.post(errorName + " Is Not Target Folder !", "error", MessageBox.ERROR);
|
||||
} else {
|
||||
List<TCComponent> list = getFilesWithCcp(targetFolders);
|
||||
TCComponent[] publicItems = filterTComponent(list);
|
||||
|
||||
// String preferenceValue = TcUtil.getPreferenceValue(tcSession, "VF5BOM_PROCESS_RELEASE");
|
||||
// if (preferenceValue != null && !preferenceValue.isEmpty() && publicItems != null
|
||||
// && publicItems.length > 0) {
|
||||
|
||||
if (publicItems != null && publicItems.length > 0) {
|
||||
// CreateProcess(tcSession, publicItems, preferenceValue);
|
||||
// MessageBox.post("Public Successful !", "Info", MessageBox.INFORMATION);
|
||||
|
||||
// new NewProcessCommand(AIFUtility.getActiveDesktop(), application, publicItems);
|
||||
NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application,
|
||||
publicItems);
|
||||
cmd.executeModeless();
|
||||
} else {
|
||||
MessageBox.post("Preference configuration error or failure to find VF5ccp, VF5gy objects", "error",
|
||||
MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TCComponent[] filterTComponent(List<TCComponent> list) {
|
||||
List<TCComponentItemRevision> newList = new ArrayList<>();
|
||||
if (list != null && list.size() > 0) {
|
||||
try {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TCComponentItem item = (TCComponentItem) list.get(i);
|
||||
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
|
||||
TCComponent[] releaseList = latestItemRevision.getRelatedComponents("release_status_list");
|
||||
if (releaseList != null && releaseList.length > 0) {
|
||||
continue;
|
||||
} else {
|
||||
newList.add(latestItemRevision);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return newList.toArray(new TCComponent[newList.size()]);
|
||||
}
|
||||
|
||||
public void CreateProcess(TCSession session, TCComponent[] targets, String processName) throws TCException {
|
||||
try {
|
||||
System.out.println("number : " + targets.length);
|
||||
|
||||
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
|
||||
TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
|
||||
.getTypeComponent("EPMTaskTemplate");
|
||||
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
|
||||
int[] number = new int[targets.length];
|
||||
for (int i = 0; i < targets.length; i++) {
|
||||
number[i] = 1;
|
||||
}
|
||||
if (taskTemplate != null) {
|
||||
String name = targets[0].getProperty("object_string");
|
||||
processType.create(processName + ":" + name, "", taskTemplate, targets, number);
|
||||
}
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String judgeFolder(AbstractAIFApplication application) throws TCException {
|
||||
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
|
||||
|
||||
if (targetComponents != null && targetComponents.length > 0) {
|
||||
targetFolders = new TCComponentFolder[targetComponents.length];
|
||||
for (int i = 0; i < targetComponents.length; i++) {
|
||||
if (!targetComponents[i].getType().equals("VF5xmwjj")) {
|
||||
return ((TCComponentFolder) targetComponents[i]).getStringProperty("object_name");
|
||||
} else {
|
||||
targetFolders[i] = (TCComponentFolder) targetComponents[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("Please Select Folder !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<TCComponent> getFilesWithCcp(TCComponentFolder[] targetFolders) {
|
||||
List<TCComponent> result = new ArrayList<>();
|
||||
try {
|
||||
for (TCComponentFolder targetFolder : targetFolders) {
|
||||
traverseDirectory(targetFolder, result);
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归遍历目录及其子目录
|
||||
*
|
||||
* @param directory 目录文件对象
|
||||
* @param result 存储符合条件的文件列表
|
||||
* @throws TCException
|
||||
*/
|
||||
private void traverseDirectory(TCComponentFolder targetFolder, List<TCComponent> result) throws TCException {
|
||||
TCComponent[] childItems = targetFolder.getTCProperty("contents").getReferenceValueArray();
|
||||
|
||||
if (childItems != null && childItems.length > 0) {
|
||||
for (TCComponent childItem : childItems) {
|
||||
if (childItem.getType().equals("Folder")) {
|
||||
traverseDirectory((TCComponentFolder) childItem, result);
|
||||
} else if (childItem.getType().equals("VF5ccp")) {
|
||||
result.add(childItem);
|
||||
// 这里可能会有问题,测试没问题,待有问题检查这里
|
||||
TCComponent[] gyGx = childItem.getRelatedComponents("VF5gygx");
|
||||
for (TCComponent tcComponent : childItems) {
|
||||
if (tcComponent.getStringProperty("object_type").equals("VF5gy")) {
|
||||
result.add(tcComponent);
|
||||
}
|
||||
}
|
||||
} else if (childItem.getType().equals("VF5gy")) {
|
||||
result.add(childItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.changeManagement.createProblemReport.CreateProblemReportDialog;
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||
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.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateChangeRequestFormHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
InterfaceAIFComponent targetComponent = application.getTargetComponent();
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
|
||||
try {
|
||||
String type = targetComponent.getType();
|
||||
System.out.println("type : " + type);
|
||||
|
||||
TCComponentFolder folder = null;
|
||||
TCComponentItemRevision rev = null;
|
||||
if (targetComponent instanceof TCComponentFolder) {
|
||||
if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) {
|
||||
folder = (TCComponentFolder) targetComponent;
|
||||
} else {
|
||||
MessageBox.post("请选择文件夹!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
} else if (targetComponent instanceof TCComponentItemRevision) {
|
||||
if (type.equals("VF5wtbgRevision")) {
|
||||
rev = (TCComponentItemRevision) targetComponent;
|
||||
} else {
|
||||
MessageBox.post("请选择问题报告版本对象!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("请选择文件夹或问题报告版本对象!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
JLabel[] jLabels = new JLabel[] { new JLabel("名称") };
|
||||
JComponent[] jComponents = new JComponent[] { new JTextField(14) };
|
||||
|
||||
CreateChangeRequestFormDialog searchTemplate = new CreateChangeRequestFormDialog("创建变更申请单",
|
||||
new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev);
|
||||
new Thread(searchTemplate).start();
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,448 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createECO;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import com.connor.ferrorTech.metal.changeManagement.createECR.CustomTableCellRenderer;
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ChangeNoticeFormCreateDialog extends JFrame implements Runnable {
|
||||
|
||||
private final String title;
|
||||
private AbstractAIFApplication application;
|
||||
private InterfaceAIFComponent targetComponent;
|
||||
|
||||
private final JLabel[] jLabels;
|
||||
private final JComponent[] jComponents;
|
||||
private JButton confirmButton;
|
||||
private JButton cancelButton;
|
||||
private JButton addButton;
|
||||
private JButton removeButton;
|
||||
|
||||
private JTable leftTable;
|
||||
private JTable rightTable;
|
||||
private String[][] leftData;
|
||||
private String[][] rightData;
|
||||
|
||||
public ChangeNoticeFormCreateDialog(AbstractAIFApplication application, String title, Object... args) {
|
||||
int count = 0;
|
||||
this.title = title;
|
||||
this.application = application;
|
||||
jLabels = (JLabel[]) args[count++];
|
||||
jComponents = (JComponent[]) args[count++];
|
||||
leftData = (String[][]) args[count];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
targetComponent = application.getTargetComponent();
|
||||
initUI();
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
this.setTitle(title);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setSize(780, 450); // 设置窗口大小
|
||||
this.setLayout(new BorderLayout()); // 设置布局
|
||||
|
||||
initializationButton();
|
||||
|
||||
try {
|
||||
JPanel topPanel = createTopPanel();
|
||||
JPanel centerPanel = createCenterPanel();
|
||||
|
||||
JPanel southPanel = createSouthPanel();
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
this.add(centerPanel, BorderLayout.CENTER);
|
||||
this.add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setVisible(true);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void initializationButton() {
|
||||
confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
confirmButton.setPreferredSize(new Dimension(95, 25));
|
||||
confirmButton.addActionListener(e -> {
|
||||
String name = ((JTextField) jComponents[0]).getText();
|
||||
String reason = ((JTextField) jComponents[1]).getText();
|
||||
if (name.length() >= 40) {
|
||||
JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
} else {
|
||||
this.dispose();
|
||||
if (name != null && name.isEmpty()) {
|
||||
name = "MECO";
|
||||
}
|
||||
doTask(name, reason);
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
cancelButton.setPreferredSize(new Dimension(95, 25));
|
||||
cancelButton.addActionListener(e -> {
|
||||
this.dispose();
|
||||
});
|
||||
|
||||
addButton = new JButton("Add>>");
|
||||
addButton.setPreferredSize(new Dimension(110, 25));
|
||||
addButton.addActionListener(e -> {
|
||||
moveRight();
|
||||
});
|
||||
|
||||
removeButton = new JButton("<<Remove");
|
||||
removeButton.setPreferredSize(new Dimension(110, 25));
|
||||
removeButton.addActionListener(e -> {
|
||||
moveLeft();
|
||||
});
|
||||
}
|
||||
|
||||
public JPanel createTopPanel() throws Exception {
|
||||
JPanel topPanel = new JPanel(new GridBagLayout());
|
||||
topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
|
||||
Font serif = new Font("Serif", Font.BOLD, 13);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridy = 0;
|
||||
gbc.insets = new Insets(5, 20, 5, 20);
|
||||
int count = 0;
|
||||
for (int i = 0; i < jLabels.length; i++) {
|
||||
gbc.gridx = count++;
|
||||
jLabels[i].setFont(serif);
|
||||
topPanel.add(jLabels[i], gbc);
|
||||
gbc.gridx = count++;
|
||||
jComponents[i].setFont(serif);
|
||||
if (targetComponent.getProperty("object_type").equals("VF5bgpsd") && i == 1) {
|
||||
TCComponentItem tcItem = (TCComponentItem) targetComponent;
|
||||
String reason = tcItem.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev")
|
||||
.getProperty("vf5bgyy");
|
||||
((JTextField) jComponents[i]).setText(reason);
|
||||
}
|
||||
topPanel.add(jComponents[i], gbc);
|
||||
}
|
||||
return topPanel;
|
||||
}
|
||||
|
||||
private JPanel createSouthPanel() {
|
||||
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
|
||||
southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
|
||||
southPanel.add(confirmButton);
|
||||
southPanel.add(cancelButton);
|
||||
return southPanel;
|
||||
}
|
||||
|
||||
public JPanel createCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
centerPanel.add(createLeftPanel(), BorderLayout.WEST);
|
||||
centerPanel.add(createCenterButton(), BorderLayout.CENTER);
|
||||
centerPanel.add(createRightPanel(), BorderLayout.EAST);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public JPanel createLeftPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
|
||||
|
||||
DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[] { "Column" }) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return leftData.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return leftData[rowIndex][1];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
leftTable = new JTable(tableModel);
|
||||
|
||||
leftTable.setTableHeader(null);
|
||||
leftTable.setShowGrid(false);
|
||||
leftTable.setRowHeight(22);
|
||||
leftTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
|
||||
leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
|
||||
|
||||
centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public JPanel createCenterButton() {
|
||||
JPanel jPanel = new JPanel(new GridBagLayout());
|
||||
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.anchor = GridBagConstraints.LINE_START;
|
||||
gbc.insets = new Insets(-30, 5, 30, 5);// 边距
|
||||
jPanel.add(addButton, gbc);
|
||||
gbc.insets = new Insets(0, 5, 10, 5);// 边距
|
||||
gbc.gridy = 1;
|
||||
jPanel.add(removeButton, gbc);
|
||||
return jPanel;
|
||||
}
|
||||
|
||||
public JPanel createRightPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
|
||||
|
||||
rightData = new String[][] {};
|
||||
|
||||
DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[] { "Column" }) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rightData.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
|
||||
return rightData[rowIndex][1];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
rightTable = new JTable(tableModel);
|
||||
rightTable.setTableHeader(null);
|
||||
rightTable.setShowGrid(false);
|
||||
rightTable.setRowHeight(22);
|
||||
rightTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
|
||||
rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
|
||||
|
||||
centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public void moveRight() {
|
||||
int[] selectedRows = leftTable.getSelectedRows();
|
||||
if (selectedRows.length == 0) {
|
||||
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String[][] newRightData = new String[rightData.length + selectedRows.length][];
|
||||
System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
|
||||
|
||||
for (int i = 0; i < selectedRows.length; i++) {
|
||||
newRightData[rightData.length + i] = leftData[selectedRows[i]];
|
||||
}
|
||||
|
||||
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
|
||||
rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
|
||||
rightData = newRightData;
|
||||
|
||||
String[][] newLeftData = new String[leftData.length - selectedRows.length][];
|
||||
int newIndex = 0;
|
||||
for (int i = 0; i < leftData.length; i++) {
|
||||
boolean isSelected = false;
|
||||
for (int selectedRow : selectedRows) {
|
||||
if (i == selectedRow) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSelected) {
|
||||
newLeftData[newIndex++] = leftData[i];
|
||||
}
|
||||
}
|
||||
|
||||
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
|
||||
leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
|
||||
leftData = newLeftData;
|
||||
}
|
||||
|
||||
public void moveLeft() {
|
||||
int[] selectedRows = rightTable.getSelectedRows();
|
||||
if (selectedRows.length == 0) {
|
||||
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String[][] newLeftData = new String[leftData.length + selectedRows.length][];
|
||||
System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
|
||||
|
||||
for (int i = 0; i < selectedRows.length; i++) {
|
||||
newLeftData[leftData.length + i] = rightData[selectedRows[i]];
|
||||
}
|
||||
|
||||
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
|
||||
leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
|
||||
leftData = newLeftData;
|
||||
|
||||
String[][] newRightData = new String[rightData.length - selectedRows.length][];
|
||||
int newIndex = 0;
|
||||
for (int i = 0; i < rightData.length; i++) {
|
||||
boolean isSelected = false;
|
||||
for (int selectedRow : selectedRows) {
|
||||
if (i == selectedRow) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSelected) {
|
||||
newRightData[newIndex++] = rightData[i];
|
||||
}
|
||||
}
|
||||
|
||||
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
|
||||
rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
|
||||
rightData = newRightData;
|
||||
}
|
||||
|
||||
public void doTask(String name, String reason) {
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
|
||||
int selectedRow = rightTable.getRowCount();
|
||||
String[] uid = null;
|
||||
if (selectedRow > 0) {
|
||||
String[][] selectItems = new String[selectedRow][];
|
||||
uid = new String[selectItems.length];
|
||||
for (int i = 0; i < selectedRow; i++) {
|
||||
String[] selectedItem = rightData[i];
|
||||
selectItems[i] = selectedItem;
|
||||
System.out.println("Selected Item: " + Arrays.toString(selectedItem));
|
||||
}
|
||||
|
||||
for (int i = 0; i < selectItems.length; i++) {
|
||||
uid[i] = selectItems[i][0];
|
||||
}
|
||||
}
|
||||
|
||||
TCComponentFolder xmwjj = null;
|
||||
boolean isECR = false;
|
||||
if (targetComponent instanceof TCComponentFolder) {
|
||||
xmwjj = (TCComponentFolder) targetComponent;
|
||||
} else if (targetComponent instanceof TCComponentItem) {
|
||||
TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast((TCComponent) targetComponent, "Folder",
|
||||
"CHANGE DATA");
|
||||
if (changeFolder == null) {
|
||||
System.out.println("out Folder is null");
|
||||
}
|
||||
xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
|
||||
isECR = true;
|
||||
}
|
||||
try {
|
||||
if (xmwjj == null) {
|
||||
throw new CustomException("xmwjj is null !");
|
||||
}
|
||||
setByFolder(xmwjj, uid, session, name, reason, isECR);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setByFolder(TCComponentFolder xmwjj, String[] uid, TCSession session, String name, String reason,
|
||||
boolean isECR) throws Exception {
|
||||
TCComponent[] components = xmwjj.getRelatedComponents("contents");
|
||||
TCComponentFolder changeFolder = null;
|
||||
for (TCComponent tcComponent : components) {
|
||||
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
|
||||
changeFolder = (TCComponentFolder) tcComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TCComponentItemRevision revision = null;
|
||||
if (changeFolder != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
|
||||
String localTime = formatter.format(LocalDateTime.now());
|
||||
System.out.println("当前时间:" + localTime);
|
||||
int maxNumber = 0;
|
||||
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision",
|
||||
new String[] { "ID" }, new String[] { "MECO-" + localTime + "-*" });
|
||||
if(queryList !=null) {
|
||||
for (InterfaceAIFComponent result : queryList) {
|
||||
String[] id = result.getProperty("item_id").split("-");
|
||||
if (id != null && id.length == 3) {
|
||||
int localNo = Integer.parseInt(id[id.length - 1]);
|
||||
if (localNo > maxNumber) {
|
||||
maxNumber = localNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String itemId = (maxNumber + 1) + "";
|
||||
int count = 2 - itemId.length();
|
||||
for (int i = 0; i < count; i++) {
|
||||
itemId = "0" + itemId;
|
||||
}
|
||||
System.out.println("itemId : "+itemId);
|
||||
|
||||
TCComponentItem newItem = (TCComponentItem) TcUtil.createComponent(application,
|
||||
new String[] { "MECO-" + localTime + "-" + itemId, "", name }, "VF5bgtzd", "Item");
|
||||
revision = newItem.getLatestItemRevision();
|
||||
TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
|
||||
form.setStringProperty("vf5bgyy", reason);
|
||||
changeFolder.add("contents", newItem);
|
||||
|
||||
if (isECR) {
|
||||
revision.add("VF5bgpsdgx", (TCComponent) targetComponent);
|
||||
}
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
|
||||
} else {
|
||||
throw new CustomException("changeFolder is null !");
|
||||
}
|
||||
|
||||
if (revision != null && uid != null & uid.length > 0) {
|
||||
TCComponent[] revList = session.stringToComponent(uid);
|
||||
revision.add("VF5ggqdxgx", revList);
|
||||
} else {
|
||||
throw new CustomException("revision is null !");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,218 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createECO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||
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.TCComponentFolder;
|
||||
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 ChangeNoticeFormCreateHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
TCComponent targetItem = judgeAndGetSingleSelectComponent(application);
|
||||
|
||||
try {
|
||||
if (targetItem != null) {
|
||||
JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
|
||||
JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
|
||||
|
||||
TCComponentFolder xmwjj = null;
|
||||
if (targetItem instanceof TCComponentFolder) {
|
||||
xmwjj = (TCComponentFolder) targetItem;
|
||||
} else if (targetItem instanceof TCComponentItem) {
|
||||
TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast(targetItem, "Folder",
|
||||
"CHANGE DATA");
|
||||
|
||||
if (changeFolder == null) {
|
||||
throw new CustomException("changeFolder is null !");
|
||||
}
|
||||
xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
|
||||
}
|
||||
|
||||
if (xmwjj == null) {
|
||||
throw new CustomException("xmwjj is null !");
|
||||
}
|
||||
List<TCComponentItemRevision> revisionList = null;
|
||||
revisionList = getCcpItemRevision(application, xmwjj);
|
||||
if (revisionList == null) {
|
||||
throw new CustomException("revisionList is null !");
|
||||
}
|
||||
String[][] data = getData(revisionList);
|
||||
ChangeNoticeFormCreateDialog searchTemplate = new ChangeNoticeFormCreateDialog(application,
|
||||
"Create ECO", jLabels, jComponents, data);
|
||||
new Thread(searchTemplate).start();
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TCComponent getLast(TCComponent targetComponent, String type, String name) {
|
||||
if (targetComponent != null) {
|
||||
try {
|
||||
AIFComponentContext[] parent = targetComponent.whereReferenced();
|
||||
for (int i = 0; i < parent.length; i++) {
|
||||
InterfaceAIFComponent component = (TCComponent) parent[i].getComponent();
|
||||
if (component.getType().equals(type) && component.getProperty("object_name").equals(name)) {
|
||||
return (TCComponent) parent[i].getComponent();
|
||||
}
|
||||
}
|
||||
System.out.println("Type is not exist !\n" + type);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("TargetComponent Is Null !");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) {
|
||||
InterfaceAIFComponent targetComponent = application.getTargetComponent();
|
||||
try {
|
||||
if (targetComponent instanceof TCComponentItem
|
||||
&& ((TCComponentItem)targetComponent).getStringProperty("object_type").equals("VF5bgpsd")) {
|
||||
return (TCComponent) targetComponent;
|
||||
} else if (targetComponent instanceof TCComponentFolder
|
||||
&& ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("VF5xmwjj")) {
|
||||
return (TCComponent) targetComponent;
|
||||
}
|
||||
MessageBox.post("The Following Is Not A Specify Type !\n" + targetComponent.getUid(), "Error",
|
||||
MessageBox.ERROR);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String[][] getData(List<TCComponentItemRevision> revisionList) throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
String[][] data = new String[revisionList.size()][];
|
||||
if (revisionList != null && revisionList.size() > 0) {
|
||||
int count = 0;
|
||||
String name = "";
|
||||
for (TCComponentItemRevision itemRevison : revisionList) {
|
||||
String type = itemRevison.getStringProperty("object_type");
|
||||
String[] rowData = new String[2];
|
||||
String uid = itemRevison.getUid();
|
||||
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
|
||||
String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
|
||||
name = wlbm + "-" + itemRevison.getStringProperty("object_name") + ";"
|
||||
+ itemRevison.getStringProperty("item_revision_id");
|
||||
} else if (type.equals("VF5gyRevision")) {
|
||||
name = itemRevison.getStringProperty("item_id") + "-" + itemRevison.getStringProperty("object_name")
|
||||
+ ";" + itemRevison.getStringProperty("item_revision_id");
|
||||
}
|
||||
rowData[0] = uid;
|
||||
rowData[1] = name;
|
||||
data[count++] = rowData;
|
||||
}
|
||||
return data;
|
||||
} else {
|
||||
return new String[][] {};
|
||||
}
|
||||
}
|
||||
|
||||
public List<TCComponentItemRevision> getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj)
|
||||
throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
// 创建视图
|
||||
TCComponentBOMWindow view = winType.create(null);
|
||||
// 发送BOM args:item对象 版本对象 ...
|
||||
|
||||
List<TCComponentItemRevision> revList = new ArrayList<>();
|
||||
|
||||
TCComponent[] components = xmwjj.getRelatedComponents("contents");
|
||||
TCComponentFolder materialFolder = null;
|
||||
TCComponentFolder porFolder = null;
|
||||
for (TCComponent tcComponent : components) {
|
||||
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
|
||||
materialFolder = (TCComponentFolder) tcComponent;
|
||||
} else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("POR")) {
|
||||
porFolder = (TCComponentFolder) tcComponent;
|
||||
}
|
||||
}
|
||||
|
||||
if (materialFolder != null) {
|
||||
TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
|
||||
for (TCComponent tcItem : materialChildren) {
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
|
||||
TCComponentItem ccpItem = (TCComponentItem) tcItem;
|
||||
TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
|
||||
|
||||
revList.add(ccpItemRev);
|
||||
getBcpRevision(revList, view, ccpItem, ccpItemRev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomException("materialFolder is null ! ");
|
||||
}
|
||||
|
||||
if (porFolder != null) {
|
||||
TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
|
||||
for (TCComponent tcItem : porChildren) {
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
|
||||
TCComponentItem gyItem = (TCComponentItem) tcItem;
|
||||
TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
|
||||
revList.add(gyItemRev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomException("porFolder is null ! ");
|
||||
}
|
||||
return revList;
|
||||
}
|
||||
|
||||
public void getBcpRevision(List<TCComponentItemRevision> revList, TCComponentBOMWindow view,
|
||||
TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
|
||||
TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
|
||||
|
||||
boolean hasChildren = bomLine.hasChildren();
|
||||
if (hasChildren) {
|
||||
AIFComponentContext[] childrena = bomLine.getChildren();
|
||||
for (AIFComponentContext children : childrena) {
|
||||
// 强转为TCComponentBOMLine类型
|
||||
TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
|
||||
if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
|
||||
revList.add(bcpItemRev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,406 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createECR;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ChangeApplyFormCreateDialog extends JFrame implements Runnable {
|
||||
|
||||
private final String title;
|
||||
private AbstractAIFApplication application;
|
||||
|
||||
private final JLabel[] jLabels;
|
||||
private final JComponent[] jComponents;
|
||||
private JButton confirmButton;
|
||||
private JButton cancelButton;
|
||||
private JButton addButton;
|
||||
private JButton removeButton;
|
||||
|
||||
private JTable leftTable;
|
||||
private JTable rightTable;
|
||||
private String[][] leftData;
|
||||
private String[][] rightData;
|
||||
|
||||
public ChangeApplyFormCreateDialog(AbstractAIFApplication application,String title, Object... args) {
|
||||
int count = 0;
|
||||
this.title = title;
|
||||
this.application =application;
|
||||
jLabels = (JLabel[]) args[count++];
|
||||
jComponents = (JComponent[]) args[count++];
|
||||
leftData = (String[][]) args[count];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
initUI();
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
this.setTitle(title);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setSize(780, 450); // 设置窗口大小
|
||||
this.setLayout(new BorderLayout()); // 设置布局
|
||||
|
||||
initializationButton();
|
||||
|
||||
JPanel topPanel = createTopPanel();
|
||||
|
||||
JPanel centerPanel = createCenterPanel();
|
||||
|
||||
JPanel southPanel = createSouthPanel();
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
this.add(centerPanel, BorderLayout.CENTER);
|
||||
this.add(southPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void initializationButton() {
|
||||
confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
confirmButton.setPreferredSize(new Dimension(95, 25));
|
||||
confirmButton.addActionListener(e -> {
|
||||
String name = ((JTextField) jComponents[0]).getText();
|
||||
String reason = ((JTextField) jComponents[1]).getText();
|
||||
if(name.length()>=40){
|
||||
JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}else{
|
||||
this.dispose();
|
||||
try {
|
||||
if(name !=null && name.isEmpty()) {
|
||||
name = "MECR";
|
||||
}
|
||||
doTask(name,reason);
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
cancelButton.setPreferredSize(new Dimension(95, 25));
|
||||
cancelButton.addActionListener(e -> {
|
||||
this.dispose();
|
||||
});
|
||||
|
||||
addButton = new JButton("Add>>");
|
||||
addButton.setPreferredSize(new Dimension(110, 25));
|
||||
addButton.addActionListener(e -> {
|
||||
moveRight();
|
||||
});
|
||||
|
||||
removeButton = new JButton("<<Remove");
|
||||
removeButton.setPreferredSize(new Dimension(110, 25));
|
||||
removeButton.addActionListener(e -> {
|
||||
moveLeft();
|
||||
});
|
||||
}
|
||||
|
||||
public JPanel createTopPanel() {
|
||||
JPanel topPanel = new JPanel(new GridBagLayout());
|
||||
topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
|
||||
Font serif = new Font("Serif", Font.BOLD, 13);
|
||||
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridy = 0;
|
||||
gbc.insets = new Insets(5, 20, 5, 20);
|
||||
int count = 0;
|
||||
for (int i = 0; i < jLabels.length; i++) {
|
||||
gbc.gridx = count++;
|
||||
jLabels[i].setFont(serif);
|
||||
topPanel.add(jLabels[i], gbc);
|
||||
gbc.gridx = count++;
|
||||
jComponents[i].setFont(serif);
|
||||
topPanel.add(jComponents[i], gbc);
|
||||
}
|
||||
return topPanel;
|
||||
}
|
||||
|
||||
private JPanel createSouthPanel() {
|
||||
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
|
||||
southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
|
||||
southPanel.add(confirmButton);
|
||||
southPanel.add(cancelButton);
|
||||
return southPanel;
|
||||
}
|
||||
|
||||
public JPanel createCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
centerPanel.add(createLeftPanel(), BorderLayout.WEST);
|
||||
centerPanel.add(createCenterButton(), BorderLayout.CENTER);
|
||||
centerPanel.add(createRightPanel(), BorderLayout.EAST);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public JPanel createLeftPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
|
||||
|
||||
DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[]{"Column"}) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return leftData.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
return leftData[rowIndex][1];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
leftTable = new JTable(tableModel);
|
||||
|
||||
leftTable.setTableHeader(null);
|
||||
leftTable.setShowGrid(false);
|
||||
leftTable.setRowHeight(22);
|
||||
leftTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
|
||||
leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
|
||||
|
||||
centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public JPanel createCenterButton() {
|
||||
JPanel jPanel = new JPanel(new GridBagLayout());
|
||||
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
gbc.gridx = 0;
|
||||
gbc.gridy = 0;
|
||||
gbc.anchor = GridBagConstraints.LINE_START;
|
||||
gbc.insets = new Insets(-30, 5, 30, 5);// 边距
|
||||
jPanel.add(addButton, gbc);
|
||||
gbc.insets = new Insets(0, 5, 10, 5);// 边距
|
||||
gbc.gridy = 1;
|
||||
jPanel.add(removeButton, gbc);
|
||||
return jPanel;
|
||||
}
|
||||
|
||||
public JPanel createRightPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
|
||||
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
|
||||
|
||||
rightData = new String[][]{};
|
||||
|
||||
DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[]{"Column"}) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rightData.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||
|
||||
return rightData[rowIndex][1];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
rightTable = new JTable(tableModel);
|
||||
rightTable.setTableHeader(null);
|
||||
rightTable.setShowGrid(false);
|
||||
rightTable.setRowHeight(22);
|
||||
rightTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
|
||||
rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
|
||||
|
||||
centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public void moveRight() {
|
||||
int[] selectedRows = leftTable.getSelectedRows();
|
||||
if (selectedRows.length == 0) {
|
||||
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String[][] newRightData = new String[rightData.length + selectedRows.length][];
|
||||
System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
|
||||
|
||||
for (int i = 0; i < selectedRows.length; i++) {
|
||||
newRightData[rightData.length + i] = leftData[selectedRows[i]];
|
||||
}
|
||||
|
||||
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
|
||||
rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
|
||||
rightData = newRightData;
|
||||
|
||||
String[][] newLeftData = new String[leftData.length - selectedRows.length][];
|
||||
int newIndex = 0;
|
||||
for (int i = 0; i < leftData.length; i++) {
|
||||
boolean isSelected = false;
|
||||
for (int selectedRow : selectedRows) {
|
||||
if (i == selectedRow) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSelected) {
|
||||
newLeftData[newIndex++] = leftData[i];
|
||||
}
|
||||
}
|
||||
|
||||
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
|
||||
leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
|
||||
leftData = newLeftData;
|
||||
}
|
||||
|
||||
public void moveLeft() {
|
||||
int[] selectedRows = rightTable.getSelectedRows();
|
||||
if (selectedRows.length == 0) {
|
||||
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String[][] newLeftData = new String[leftData.length + selectedRows.length][];
|
||||
System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
|
||||
|
||||
for (int i = 0; i < selectedRows.length; i++) {
|
||||
newLeftData[leftData.length + i] = rightData[selectedRows[i]];
|
||||
}
|
||||
|
||||
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
|
||||
leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
|
||||
leftData = newLeftData;
|
||||
|
||||
String[][] newRightData = new String[rightData.length - selectedRows.length][];
|
||||
int newIndex = 0;
|
||||
for (int i = 0; i < rightData.length; i++) {
|
||||
boolean isSelected = false;
|
||||
for (int selectedRow : selectedRows) {
|
||||
if (i == selectedRow) {
|
||||
isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSelected) {
|
||||
newRightData[newIndex++] = rightData[i];
|
||||
}
|
||||
}
|
||||
|
||||
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
|
||||
rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
|
||||
rightData = newRightData;
|
||||
}
|
||||
|
||||
|
||||
public void doTask(String name,String reason) throws Exception {
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
|
||||
int selectedRow = rightTable.getRowCount();
|
||||
String[] uid = null;
|
||||
if (selectedRow > 0) {
|
||||
String[][] selectItems = new String[selectedRow][];
|
||||
uid = new String[selectItems.length];
|
||||
for (int i = 0; i < selectedRow; i++) {
|
||||
String[] selectedItem = rightData[i];
|
||||
selectItems[i] = selectedItem;
|
||||
System.out.println("Selected Item: " + Arrays.toString(selectedItem));
|
||||
}
|
||||
for (int i = 0; i < selectItems.length; i++) {
|
||||
uid[i] = selectItems[i][0];
|
||||
}
|
||||
}
|
||||
|
||||
TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
|
||||
new String[] { "VF5xmwjj" }, "Folder");
|
||||
|
||||
TCComponent[] components = xmwjj.getRelatedComponents("contents");
|
||||
TCComponentFolder changeFolder = null;
|
||||
for (TCComponent tcComponent : components) {
|
||||
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
|
||||
changeFolder = (TCComponentFolder) tcComponent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TCComponentItemRevision revision = null;
|
||||
if(changeFolder!=null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
|
||||
String localTime = formatter.format(LocalDateTime.now());
|
||||
System.out.println("当前时间:" + localTime);
|
||||
int maxNumber = 0;
|
||||
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision", new String[] {"ID"}, new String[] {"MECR-"+localTime+"-*"});
|
||||
for (InterfaceAIFComponent result : queryList) {
|
||||
String[] id = result.getProperty("item_id").split("-");
|
||||
if(id !=null && id.length==3){
|
||||
int localNo = Integer.parseInt(id[id.length-1]);
|
||||
if(localNo>maxNumber) {
|
||||
maxNumber = localNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
String itemId = (maxNumber+1) + "";
|
||||
int count = 2 - itemId.length();
|
||||
for (int i = 0; i < count; i++) {
|
||||
itemId = "0"+itemId;
|
||||
}
|
||||
|
||||
TCComponentItem newItem = (TCComponentItem)TcUtil.createComponent(application
|
||||
, new String[] {"MECR-"+localTime+"-"+itemId,"",name}, "VF5bgpsd", "Item");
|
||||
revision = newItem.getLatestItemRevision();
|
||||
TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
|
||||
form.setStringProperty("vf5bgyy", reason);
|
||||
changeFolder.add("contents", newItem);
|
||||
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
}else {
|
||||
throw new CustomException("changeFolder is null !");
|
||||
}
|
||||
|
||||
if(revision!=null && uid!=null & uid.length>0) {
|
||||
TCComponent[] revList = session.stringToComponent(uid);
|
||||
revision.add("VF5ggqdxgx", revList);
|
||||
}else {
|
||||
throw new CustomException("revision is null !");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createECR;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||
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.TCComponentFolder;
|
||||
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 ChangeApplyFormCreateHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
|
||||
new String[] { "VF5xmwjj" }, "Folder");
|
||||
|
||||
try {
|
||||
if (xmwjj != null) {
|
||||
JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
|
||||
JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
|
||||
|
||||
List<TCComponentItemRevision> revisionList = getCcpItemRevision(application, xmwjj);
|
||||
|
||||
String[][] data = getData(revisionList);
|
||||
|
||||
ChangeApplyFormCreateDialog searchTemplate = new ChangeApplyFormCreateDialog(application,"Create ECR", jLabels,
|
||||
jComponents,data);
|
||||
new Thread(searchTemplate).start();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String[][] getData(List<TCComponentItemRevision> revisionList) throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
String[][] data = new String[revisionList.size()][];
|
||||
if(revisionList!=null && revisionList.size()>0) {
|
||||
int count = 0 ;
|
||||
String name = "";
|
||||
for (TCComponentItemRevision itemRevison : revisionList) {
|
||||
String type = itemRevison.getStringProperty("object_type");
|
||||
String[] rowData = new String[2];
|
||||
String uid = itemRevison.getUid();
|
||||
if(type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
|
||||
String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
|
||||
name = wlbm +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
|
||||
}else if(type.equals("VF5gyRevision")) {
|
||||
name = itemRevison.getStringProperty("item_id") +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
|
||||
}
|
||||
rowData[0] = uid;
|
||||
rowData[1] = name;
|
||||
data[count++] = rowData;
|
||||
}
|
||||
return data;
|
||||
}else {
|
||||
return new String[][] {};
|
||||
}
|
||||
}
|
||||
|
||||
public List<TCComponentItemRevision> getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj) throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
|
||||
// 创建视图
|
||||
TCComponentBOMWindow view = winType.create(null);
|
||||
// 发送BOM args:item对象 版本对象 ...
|
||||
|
||||
List<TCComponentItemRevision> revList = new ArrayList<>();
|
||||
|
||||
TCComponent[] components = xmwjj.getRelatedComponents("contents");
|
||||
TCComponentFolder materialFolder = null;
|
||||
TCComponentFolder porFolder = null;
|
||||
for (TCComponent tcComponent : components) {
|
||||
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
|
||||
materialFolder = (TCComponentFolder) tcComponent;
|
||||
} else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
|
||||
&& tcComponent.getStringProperty("object_name").equals("POR")) {
|
||||
porFolder = (TCComponentFolder) tcComponent;
|
||||
}
|
||||
}
|
||||
|
||||
if (materialFolder != null) {
|
||||
TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
|
||||
for (TCComponent tcItem : materialChildren) {
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
|
||||
TCComponentItem ccpItem = (TCComponentItem) tcItem;
|
||||
TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
|
||||
|
||||
revList.add(ccpItemRev);
|
||||
getBcpRevision(revList, view, ccpItem, ccpItemRev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomException("materialFolder is null ! ");
|
||||
}
|
||||
|
||||
if (porFolder != null) {
|
||||
TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
|
||||
for (TCComponent tcItem : porChildren) {
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
|
||||
TCComponentItem gyItem = (TCComponentItem) tcItem;
|
||||
TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
|
||||
revList.add(gyItemRev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomException("porFolder is null ! ");
|
||||
}
|
||||
return revList;
|
||||
}
|
||||
|
||||
public void getBcpRevision(List<TCComponentItemRevision> revList, TCComponentBOMWindow view,
|
||||
TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
|
||||
TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
|
||||
|
||||
boolean hasChildren = bomLine.hasChildren();
|
||||
if (hasChildren) {
|
||||
AIFComponentContext[] childrena = bomLine.getChildren();
|
||||
for (AIFComponentContext children : childrena) {
|
||||
// 强转为TCComponentBOMLine类型
|
||||
TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
|
||||
if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
|
||||
revList.add(bcpItemRev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createECR;
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
|
||||
public class CustomTableCellRenderer extends DefaultTableCellRenderer {
|
||||
private final Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
|
||||
private final Border focusBorder = new LineBorder(Color.YELLOW, 1);
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
JComponent c = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
if (isSelected) {
|
||||
c.setBorder(focusBorder);
|
||||
} else {
|
||||
c.setBorder(noFocusBorder);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createNotification;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm.CreateChangeRequestFormDialog;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateNotificationHandler extends AbstractHandler {
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
InterfaceAIFComponent targetComponent = application.getTargetComponent();
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
|
||||
try {
|
||||
String type = targetComponent.getType();
|
||||
System.out.println("type : " + type);
|
||||
|
||||
TCComponentFolder folder = null;
|
||||
TCComponentItemRevision rev = null;
|
||||
if (targetComponent instanceof TCComponentFolder) {
|
||||
if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) {
|
||||
folder = (TCComponentFolder) targetComponent;
|
||||
} else {
|
||||
MessageBox.post("请选择文件夹!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
} else if (targetComponent instanceof TCComponentItemRevision) {
|
||||
if (type.equals("VF5bgpsdRevision")) {
|
||||
rev = (TCComponentItemRevision) targetComponent;
|
||||
} else {
|
||||
MessageBox.post("请选择变更申请单版本对象!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("请选择文件夹或变更申请单版本对象!", "Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
JLabel[] jLabels = new JLabel[] { new JLabel("名称") };
|
||||
JComponent[] jComponents = new JComponent[] { new JTextField(14) };
|
||||
|
||||
CreateNotificationDialog searchTemplate = new CreateNotificationDialog("创建变更通知单",
|
||||
new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev);
|
||||
new Thread(searchTemplate).start();
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.connor.ferrorTech.metal.changeManagement.createProblemReport;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
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.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateProblemReportHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
|
||||
TCComponentFolder targetItem = (TCComponentFolder) judgeAndGetSingleSelectComponent(application);
|
||||
|
||||
try {
|
||||
if (targetItem != null) {
|
||||
JLabel[] jLabels = new JLabel[] { new JLabel("名称")};
|
||||
JComponent[] jComponents = new JComponent[] { new JTextField(14)};
|
||||
|
||||
CreateProblemReportDialog searchTemplate = new CreateProblemReportDialog("创建问题报告", new int[]{400, 200, 5, 5}, jLabels, jComponents,session,targetItem);
|
||||
new Thread(searchTemplate).start();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) {
|
||||
InterfaceAIFComponent targetComponent = application.getTargetComponent();
|
||||
try {
|
||||
if (targetComponent instanceof TCComponentFolder
|
||||
&& ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("Folder")) {
|
||||
return (TCComponent) targetComponent;
|
||||
}
|
||||
MessageBox.post("请选择文件夹类型 !", "Error",
|
||||
MessageBox.ERROR);
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
|
||||
public class CreateInternalDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0){
|
||||
AbstractAIFApplication application =AIFUtility.getCurrentApplication();
|
||||
CommonAction commonAction = new CommonAction(application,"VF5idgx","VF5nbtz","Internal Drawing","-ID");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateProcessControlHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CommonAction commonAction = new CommonAction(application, "VF5pcgx", "VF5procctrl","Process Control","-PC");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CommonAction implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private TCComponentItemRevision[] tarRevs;
|
||||
|
||||
private String revReference;
|
||||
private String itemType;
|
||||
private String itemName;
|
||||
private String ruleName;
|
||||
|
||||
public CommonAction(AbstractAIFApplication application, String revReference, String type, String name,
|
||||
String ruleName) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.revReference = revReference;
|
||||
this.itemType = type;
|
||||
this.ruleName = ruleName;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean revFlag = false;
|
||||
try {
|
||||
revFlag = isCcpRevision();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!revFlag) {
|
||||
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
|
||||
} else if (tarRevs == null && tarRevs.length == 0) {
|
||||
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
|
||||
} else {
|
||||
Map<String, String> nullMap = isExistNull();
|
||||
if (nullMap.isEmpty()) {
|
||||
System.out.println("enter createNbtzItem()");
|
||||
createNbtzItem();
|
||||
} else {
|
||||
StringBuffer str = new StringBuffer("");
|
||||
Set<String> keySet = nullMap.keySet();
|
||||
for (String key : keySet) {
|
||||
int count = 0;
|
||||
if (count == 0) {
|
||||
str.append("\n" + key + " | " + nullMap.get(key));
|
||||
} else if (count == keySet.size() - 1) {
|
||||
str.append(key + " | " + nullMap.get(key) + "\n");
|
||||
} else {
|
||||
str.append(key + " | " + nullMap.get(key));
|
||||
}
|
||||
}
|
||||
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCcpRevision() throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
|
||||
System.out.println("length: " + targetComponents.length);
|
||||
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
|
||||
for (InterfaceAIFComponent targetComponent : targetComponents) {
|
||||
System.out.println("enter judge");
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
|
||||
System.out.println("false");
|
||||
return false;
|
||||
} else {
|
||||
System.out.println("true");
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
try {
|
||||
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
|
||||
return false;
|
||||
} else {
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("tempComponents.size: " + tempComponents.size());
|
||||
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, String> isExistNull() {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
for (InterfaceAIFComponent targetComponent : tarRevs) {
|
||||
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
|
||||
try {
|
||||
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
|
||||
if (property.isEmpty()) {
|
||||
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("isExistNull is error !");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
public void createNbtzItem() {
|
||||
try {
|
||||
System.out.println("tarRevs: "+tarRevs.length);
|
||||
if (tarRevs != null && tarRevs.length > 0) {
|
||||
boolean flag = true;
|
||||
for (TCComponentItemRevision targetRev : tarRevs) {
|
||||
if (judgeIsExist(targetRev)) {
|
||||
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = targetRevForm[0].getStringProperty("vf5khth");
|
||||
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
|
||||
|
||||
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
|
||||
if (tzItem != null) {
|
||||
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
|
||||
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
newTcItemRevForm[0].setStringProperty("vf5khth", property);
|
||||
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
|
||||
|
||||
targetRev.add(revReference, tzItem);
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(flag) {
|
||||
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
|
||||
}else {
|
||||
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
|
||||
if(targetRev!=null) {
|
||||
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
|
||||
System.out.println("item: " + targetRev.getStringProperty("object_name"));
|
||||
if (tzReferences != null && tzReferences.length > 0) {
|
||||
for (int i = 0; i < tzReferences.length; i++) {
|
||||
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
|
||||
System.out.println("it's exist!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
throw new CustomException("targetRev is null");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateRedlineDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CommonAction commonAction = new CommonAction(application, "VF5rdgx", "VF5jctz","Redline Drawing","-RD");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateRawMaterialDrawingAction implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private TCComponentItemRevision[] tarRevs;
|
||||
|
||||
private String revReference;
|
||||
private String itemType;
|
||||
private String itemName;
|
||||
private String ruleName;
|
||||
|
||||
public CreateRawMaterialDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
|
||||
String ruleName) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.revReference = revReference;
|
||||
this.itemType = type;
|
||||
this.ruleName = ruleName;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean revFlag = false;
|
||||
try {
|
||||
revFlag = isCcpRevision();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!revFlag) {
|
||||
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
|
||||
} else if (tarRevs == null && tarRevs.length == 0) {
|
||||
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
|
||||
} else {
|
||||
Map<String, String> nullMap = isExistNull();
|
||||
if (nullMap.isEmpty()) {
|
||||
System.out.println("enter createNbtzItem()");
|
||||
createNbtzItem();
|
||||
} else {
|
||||
StringBuffer str = new StringBuffer("");
|
||||
Set<String> keySet = nullMap.keySet();
|
||||
for (String key : keySet) {
|
||||
int count = 0;
|
||||
if (count == 0) {
|
||||
str.append("\n" + key + " | " + nullMap.get(key));
|
||||
} else if (count == keySet.size() - 1) {
|
||||
str.append(key + " | " + nullMap.get(key) + "\n");
|
||||
} else {
|
||||
str.append(key + " | " + nullMap.get(key));
|
||||
}
|
||||
}
|
||||
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCcpRevision() throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
|
||||
System.out.println("length: " + targetComponents.length);
|
||||
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
|
||||
for (InterfaceAIFComponent targetComponent : targetComponents) {
|
||||
System.out.println("enter judge");
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
|
||||
System.out.println("false");
|
||||
return false;
|
||||
} else {
|
||||
System.out.println("true");
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
try {
|
||||
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
|
||||
return false;
|
||||
} else {
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("tempComponents.size: " + tempComponents.size());
|
||||
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, String> isExistNull() {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
for (InterfaceAIFComponent targetComponent : tarRevs) {
|
||||
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
|
||||
try {
|
||||
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
|
||||
if (property.isEmpty()) {
|
||||
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("isExistNull is error !");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
public void createNbtzItem() {
|
||||
try {
|
||||
System.out.println("tarRevs: "+tarRevs.length);
|
||||
if (tarRevs != null && tarRevs.length > 0) {
|
||||
boolean flag = true;
|
||||
for (TCComponentItemRevision targetRev : tarRevs) {
|
||||
if (judgeIsExist(targetRev)) {
|
||||
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = targetRevForm[0].getStringProperty("vf5khth");
|
||||
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
|
||||
|
||||
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
|
||||
if (tzItem != null) {
|
||||
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
|
||||
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
newTcItemRevForm[0].setStringProperty("vf5khth", property);
|
||||
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
|
||||
|
||||
targetRev.add(revReference, tzItem);
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(flag) {
|
||||
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
|
||||
}else {
|
||||
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
|
||||
if(targetRev!=null) {
|
||||
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
|
||||
System.out.println("item: " + targetRev.getStringProperty("object_name"));
|
||||
if (tzReferences != null && tzReferences.length > 0) {
|
||||
for (int i = 0; i < tzReferences.length; i++) {
|
||||
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
|
||||
System.out.println("it's exist!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
throw new CustomException("targetRev is null");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateRawMaterialDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateRawMaterialDrawingAction commonAction = new CreateRawMaterialDrawingAction(application, "VF5rmgx", "VF5ycltz","Raw Material Drawing","-RM");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,194 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentBOMLine;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateSubPartsDrawingAction implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private TCComponentItemRevision[] tarRevs;
|
||||
|
||||
private String revReference;
|
||||
private String itemType;
|
||||
private String itemName;
|
||||
private String ruleName;
|
||||
|
||||
public CreateSubPartsDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
|
||||
String ruleName) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.revReference = revReference;
|
||||
this.itemType = type;
|
||||
this.ruleName = ruleName;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean revFlag = false;
|
||||
try {
|
||||
revFlag = isCcpRevision();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!revFlag) {
|
||||
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
|
||||
} else if (tarRevs == null && tarRevs.length == 0) {
|
||||
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
|
||||
} else {
|
||||
Map<String, String> nullMap = isExistNull();
|
||||
if (nullMap.isEmpty()) {
|
||||
System.out.println("enter createNbtzItem()");
|
||||
createNbtzItem();
|
||||
} else {
|
||||
StringBuffer str = new StringBuffer("");
|
||||
Set<String> keySet = nullMap.keySet();
|
||||
for (String key : keySet) {
|
||||
int count = 0;
|
||||
if (count == 0) {
|
||||
str.append("\n" + key + " | " + nullMap.get(key));
|
||||
} else if (count == keySet.size() - 1) {
|
||||
str.append(key + " | " + nullMap.get(key) + "\n");
|
||||
} else {
|
||||
str.append(key + " | " + nullMap.get(key));
|
||||
}
|
||||
}
|
||||
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCcpRevision() throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
|
||||
System.out.println("length: " + targetComponents.length);
|
||||
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
|
||||
for (InterfaceAIFComponent targetComponent : targetComponents) {
|
||||
System.out.println("enter judge");
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
|
||||
System.out.println("false");
|
||||
return false;
|
||||
} else {
|
||||
System.out.println("true");
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
try {
|
||||
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
|
||||
return false;
|
||||
} else {
|
||||
tempComponents.add(tempComponentRev);
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("tempComponents.size: " + tempComponents.size());
|
||||
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, String> isExistNull() {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
for (InterfaceAIFComponent targetComponent : tarRevs) {
|
||||
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
|
||||
try {
|
||||
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
|
||||
if (property.isEmpty()) {
|
||||
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("isExistNull is error !");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
public void createNbtzItem() {
|
||||
try {
|
||||
System.out.println("tarRevs: "+tarRevs.length);
|
||||
if (tarRevs != null && tarRevs.length > 0) {
|
||||
boolean flag = true;
|
||||
for (TCComponentItemRevision targetRev : tarRevs) {
|
||||
if (judgeIsExist(targetRev)) {
|
||||
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
String property = targetRevForm[0].getStringProperty("vf5khth");
|
||||
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
|
||||
|
||||
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
|
||||
if (tzItem != null) {
|
||||
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
|
||||
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
newTcItemRevForm[0].setStringProperty("vf5khth", property);
|
||||
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
|
||||
|
||||
targetRev.add(revReference, tzItem);
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(flag) {
|
||||
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
|
||||
}else {
|
||||
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
|
||||
if(targetRev!=null) {
|
||||
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
|
||||
System.out.println("item: " + targetRev.getStringProperty("object_name"));
|
||||
if (tzReferences != null && tzReferences.length > 0) {
|
||||
for (int i = 0; i < tzReferences.length; i++) {
|
||||
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
|
||||
System.out.println("it's exist!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
throw new CustomException("targetRev is null");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateSubPartsDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateSubPartsDrawingAction commonAction = new CreateSubPartsDrawingAction(application, "VF5spgx", "VF5bcptz","Sub-Parts Drawing","-SP");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateSetupSheetHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CommonAction commonAction = new CommonAction(application, "VF5ssgx", "VF5setupsheet","Setup Sheet","-SS");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateReworkInstructionHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateReworkInstructionAction commonAction = new CreateReworkInstructionAction(application, "VF5rwigx", "VF5rwi","Rework Work Instruction","-RWI-");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,225 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
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.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
/**
|
||||
* used: HncFile || IprocessDrawing || JpreMillDrawing
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class GxTemplateAction implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private TCComponentItemRevision[] gyRevs;
|
||||
private TCComponentItemRevision[] gxRevs;
|
||||
|
||||
private String revReference;
|
||||
private String itemType;
|
||||
private String itemName;
|
||||
private String ruleName;
|
||||
|
||||
public GxTemplateAction(AbstractAIFApplication application, String revReference, String type, String name,
|
||||
String ruleName) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.revReference = revReference;
|
||||
this.itemType = type;
|
||||
this.itemName = name;
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
gyRevs = judgeSelectRevision(application);
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
|
||||
}
|
||||
if (gyRevs != null) {
|
||||
Map<String, String> nullMap = null;
|
||||
String[] pnValue = null;
|
||||
try {
|
||||
pnValue = new String[gyRevs.length];
|
||||
nullMap = isExistNull(pnValue);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (nullMap != null && nullMap.isEmpty()) {
|
||||
createNbtzItem(pnValue);
|
||||
} else {
|
||||
StringBuffer str = new StringBuffer("");
|
||||
Set<String> keySet = nullMap.keySet();
|
||||
for (String key : keySet) {
|
||||
int count = 0;
|
||||
if (count == 0) {
|
||||
str.append("\n" + key + " | " + nullMap.get(key));
|
||||
} else if (count == keySet.size() - 1) {
|
||||
str.append(key + " | " + nullMap.get(key) + "\n");
|
||||
} else {
|
||||
str.append(key + " | " + nullMap.get(key));
|
||||
}
|
||||
}
|
||||
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
|
||||
InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
|
||||
List<TCComponentItemRevision> gyRevList = new ArrayList<>();
|
||||
List<TCComponentItemRevision> gxRevList = new ArrayList<>();
|
||||
try {
|
||||
for (InterfaceAIFComponent targetComponent : selectComponents) {
|
||||
TCComponentItemRevision tempComponentRev = null;
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
} else {
|
||||
MessageBox.post(
|
||||
"Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
|
||||
"Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
gxRevList.add(tempComponentRev);
|
||||
TCComponent[] whereUsed = tempComponentRev.whereUsed((short) 0);
|
||||
TCComponentItemRevision gyRev = null;
|
||||
if (whereUsed != null && whereUsed.length > 0) {
|
||||
for (TCComponent tcItem : whereUsed) {
|
||||
System.out.println("tcItem : " + tcItem.getStringProperty("object_name"));
|
||||
System.out.println("tcItem : " + tcItem.getStringProperty("object_type"));
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
|
||||
gyRev = (TCComponentItemRevision) tcItem;
|
||||
gyRevList.add(gyRev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (gyRev == null) {
|
||||
throw new CustomException(
|
||||
tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
|
||||
}
|
||||
}else {
|
||||
throw new CustomException(
|
||||
tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
|
||||
}
|
||||
}
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
gxRevs = gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
|
||||
return gyRevList.toArray(new TCComponentItemRevision[gyRevList.size()]);
|
||||
}
|
||||
|
||||
public Map<String, String> isExistNull(String pnValue[]) throws TCException {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
for (TCComponentItemRevision gyItemRev : gyRevs) {
|
||||
int count = 0;
|
||||
TCComponentForm formItem = null;
|
||||
TCComponent[] ccpItems = gyItemRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
|
||||
for (TCComponent ccpItem : ccpItems) {
|
||||
String type = ccpItem.getStringProperty("object_type");
|
||||
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision") ) {
|
||||
TCComponent[] referenceValueArray = ccpItem.getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
formItem = (TCComponentForm) referenceValueArray[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (formItem != null) {
|
||||
String wlbm = formItem.getStringProperty("vf5wlbm");
|
||||
pnValue[count++] = wlbm;
|
||||
if (wlbm !=null && (wlbm.isEmpty() || wlbm.equals("null"))) {
|
||||
errorMap.put(gyItemRev.getStringProperty("item_id"), gyItemRev.getStringProperty("object_name"));
|
||||
}
|
||||
} else {
|
||||
System.out.println("cannot get form item !");
|
||||
}
|
||||
}
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
|
||||
TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
|
||||
String localId = itemRev.getStringProperty("item_id");
|
||||
TCComponentBOMLine bomLine = null;
|
||||
TCComponentBOMWindow view = null;
|
||||
if (whereUsed != null && whereUsed.length > 0) {
|
||||
TCComponentItemRevision itemType = (TCComponentItemRevision) whereUsed[0];
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
|
||||
view = winType.create(null);
|
||||
|
||||
bomLine = view.setWindowTopLine(itemType.getItem(), itemType, null, null);
|
||||
} else {
|
||||
MessageBox.post("The current object is not referenced !", "error", MessageBox.ERROR);
|
||||
}
|
||||
|
||||
if (bomLine != null && bomLine.hasChildren()) {
|
||||
AIFComponentContext[] childrena = bomLine.getChildren();
|
||||
for (int i = 0; i < childrena.length; i++) {
|
||||
TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
|
||||
if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
|
||||
return i + 1 + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void createNbtzItem(String[] pnValue) {
|
||||
for (TCComponentItemRevision targetRev : gxRevs) {
|
||||
int count = 0;
|
||||
try {
|
||||
TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
|
||||
boolean flag = true;
|
||||
if (tzReferences != null && tzReferences.length > 0) {
|
||||
for (int i = 0; i < tzReferences.length; i++) {
|
||||
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem tzItem = tzType.create(pnValue[count++] + ruleName, "", itemType, itemName, "",
|
||||
null);
|
||||
if (tzItem != null) {
|
||||
targetRev.add(revReference, tzItem);
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
} else {
|
||||
MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateNcFileHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ncgx", "VF5ncfile","NC File","-NC");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateProcessDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pdgx", "VF5gytz","Process Drawing","-PD");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreatePreMillDrawingHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pmgx", "VF5yjgtz","Pre-Mill Drawing","-PM");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.apache.commons.compress.harmony.unpack200.bytecode.forms.LocalForm;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateJitFixtureDialog extends AbstractAIFDialog {
|
||||
private AbstractAIFApplication application;
|
||||
|
||||
private String title;
|
||||
private int[] sizes;
|
||||
private JLabel[] jLabels;
|
||||
private JComponent[] jComponents;
|
||||
|
||||
private JButton okButton;
|
||||
private JButton celButton;
|
||||
|
||||
private Map<String, Map<String, String>> lovMap;
|
||||
|
||||
public CreateJitFixtureDialog(AbstractAIFApplication application, String title, Object... args) {
|
||||
super(true);
|
||||
int count = 0;
|
||||
this.title = title;
|
||||
this.application = application;
|
||||
this.sizes = (int[]) args[count++];
|
||||
this.jLabels = (JLabel[]) args[count++];
|
||||
this.jComponents = (JComponent[]) args[count++];
|
||||
this.lovMap = (Map<String, Map<String, String>>) args[count];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
initUI();
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
this.setTitle(title);
|
||||
this.setSize(sizes[0], sizes[1]);
|
||||
initializationComponent();
|
||||
JScrollPane centerPanel = getCenterPanel();
|
||||
JPanel bottomPanel = getBottomPanel();
|
||||
|
||||
this.getContentPane().add(centerPanel, BorderLayout.CENTER);
|
||||
this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void initializationComponent() {
|
||||
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
}
|
||||
|
||||
private JScrollPane getCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints customLayout = new GridBagConstraints();
|
||||
for (int i = 0; i < jLabels.length; i++) {
|
||||
customLayout.insets = new Insets(5, 30, 5, 20);
|
||||
customLayout.gridx = 0;
|
||||
customLayout.weightx = 0;
|
||||
customLayout.anchor = GridBagConstraints.LINE_START;
|
||||
jLabels[i].setFont(new Font("΢ÈíÑźÚ", Font.BOLD, 13));
|
||||
centerPanel.add(jLabels[i], customLayout);
|
||||
|
||||
customLayout.insets = new Insets(5, 3, 5, 30);
|
||||
customLayout.gridx = 1;
|
||||
customLayout.weightx = 0;
|
||||
customLayout.fill = GridBagConstraints.HORIZONTAL;
|
||||
JComponent jComponent = jComponents[i];
|
||||
jComponent.setFont(new Font("΢ÈíÑźÚ", Font.BOLD, 15));
|
||||
centerPanel.add(jComponent, customLayout);
|
||||
}
|
||||
return new JScrollPane(centerPanel);
|
||||
}
|
||||
|
||||
private JPanel getBottomPanel() {
|
||||
// TODO Auto-generated method stub
|
||||
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
|
||||
bottomPanel.setBorder(BorderFactory.createEmptyBorder(sizes[2], 0, sizes[3], 0));
|
||||
bottomPanel.add(this.okButton);
|
||||
bottomPanel.add(this.celButton);
|
||||
okButton.addActionListener(e -> {
|
||||
boolean confirmed = confirmFunction();
|
||||
if (confirmed) {
|
||||
this.dispose();
|
||||
}
|
||||
});
|
||||
celButton.addActionListener(e -> {
|
||||
this.dispose();
|
||||
});
|
||||
return bottomPanel;
|
||||
}
|
||||
|
||||
public boolean confirmFunction() {
|
||||
String[] inputValue = new String[jComponents.length];
|
||||
for (int i = 0; i < jComponents.length; i++) {
|
||||
if (jComponents[i] instanceof JTextField) {
|
||||
inputValue[i] = ((JTextField) jComponents[i]).getText();
|
||||
} else if (jComponents[i] instanceof JComboBox) {
|
||||
JComboBox comboBox = (JComboBox) jComponents[i];
|
||||
Object selectedItem = comboBox.getSelectedItem();
|
||||
inputValue[i] = (selectedItem != null) ? selectedItem.toString() : "";
|
||||
}
|
||||
}
|
||||
try {
|
||||
createItem(inputValue);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createItem(String[] inputValue) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find Jit_Fixture Flow",
|
||||
new String[] { "ID" }, new String[] { "MJF*" });
|
||||
int maxFlowNo = 0;
|
||||
for (InterfaceAIFComponent tcItem : queryList) {
|
||||
String itemId = tcItem.getProperty("item_id");
|
||||
String[] split = itemId.split("-");
|
||||
if (split != null && split.length > 2) {
|
||||
int localFlowNo = Integer.parseInt(split[2]);
|
||||
if (localFlowNo >= maxFlowNo) {
|
||||
maxFlowNo = localFlowNo;
|
||||
}
|
||||
}
|
||||
}
|
||||
String strMaxFlowNo = (maxFlowNo + 1) + "";
|
||||
int addZero = 5 - strMaxFlowNo.length();
|
||||
for (int i = 0; i < addZero; i++) {
|
||||
strMaxFlowNo = "0" + strMaxFlowNo;
|
||||
}
|
||||
|
||||
String realProcess = lovMap.get("VF5gxlxlov").get(inputValue[0]);
|
||||
String name = inputValue[inputValue.length - 1].isEmpty() ? "Jit-Fixture Drawing"
|
||||
: inputValue[inputValue.length - 1];
|
||||
String itemId = "MJF-" + realProcess + inputValue[1] + "-" + strMaxFlowNo + "-"
|
||||
+ inputValue[inputValue.length - 2];
|
||||
|
||||
System.out.println("itemId : "+itemId);
|
||||
|
||||
TCComponentItem newComponent = (TCComponentItem) TcUtil.createComponent(application,
|
||||
new String[] { itemId, "", name }, "VF5gzjtz", "Item");
|
||||
if (newComponent != null) {
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
} else {
|
||||
MessageBox.post("Created Failed !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
((TCComponentFolder) application.getTargetComponent()).add("contents", newComponent);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CreateJitFixtureHandler extends AbstractHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"Folder","VF5xmwjj"}, "Folder");
|
||||
if(judgeSingleSelectComponent) {
|
||||
String[] enLabelName = new String[]{
|
||||
"Process", "Process Sequence", "Property","Name"
|
||||
};
|
||||
JLabel[] jLabels = new JLabel[enLabelName.length];
|
||||
JComponent[] jComponents = new JComponent[enLabelName.length];
|
||||
Map<Integer, String[]> map = new HashMap<>();
|
||||
|
||||
Map<String, Map<String, String>> lovMap = new HashMap<String,Map<String, String>>();
|
||||
map.put(0, SwingUtil.getKeyValue("VF5gxlxlov", lovMap));
|
||||
map.put(1, TcUtil.getPreferenceValues((TCSession)application.getSession(), "VF5ProcessSequence"));
|
||||
|
||||
for (int i = 0; i < enLabelName.length; i++) {
|
||||
if (map.containsKey(i)) {
|
||||
jComponents[i] = new JComboBox<>(map.get(i));
|
||||
} else {
|
||||
jComponents[i] = new JTextField(14);
|
||||
}
|
||||
jLabels[i] = new JLabel(enLabelName[i]);
|
||||
}
|
||||
|
||||
CreateJitFixtureDialog dialog = new CreateJitFixtureDialog(application,"create Jit-Fixture Drawing", new int[]{430, 400,5,5},jLabels, jComponents,lovMap);
|
||||
new Thread(dialog).start();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
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.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class CreateToolingListAction implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private InterfaceAIFComponent[] targetComponents;
|
||||
|
||||
private String revReference;
|
||||
private String itemType;
|
||||
private String itemName;
|
||||
private String ruleName;
|
||||
|
||||
private String[][] idList;
|
||||
|
||||
public CreateToolingListAction(AbstractAIFApplication application, String revReference, String type, String name,
|
||||
String ruleName) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.revReference = revReference;
|
||||
this.itemType = type;
|
||||
this.itemName = name;
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
targetComponents = judgeSelectRevision(application);
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (targetComponents != null) {
|
||||
Map<String, String> nullMap = null;
|
||||
try {
|
||||
nullMap = isExistNull();
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (nullMap != null && nullMap.isEmpty()) {
|
||||
createNbtzItem();
|
||||
} else {
|
||||
StringBuffer str = new StringBuffer("");
|
||||
Set<String> keySet = nullMap.keySet();
|
||||
for (String key : keySet) {
|
||||
int count = 0;
|
||||
if (count == 0) {
|
||||
str.append("\n" + key + " | " + nullMap.get(key));
|
||||
} else if (count == keySet.size() - 1) {
|
||||
str.append(key + " | " + nullMap.get(key) + "\n");
|
||||
} else {
|
||||
str.append(key + " | " + nullMap.get(key));
|
||||
}
|
||||
}
|
||||
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
|
||||
InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
|
||||
List<TCComponentItemRevision> gxRevList = new ArrayList<>();
|
||||
try {
|
||||
for (InterfaceAIFComponent targetComponent : selectComponents) {
|
||||
TCComponentItemRevision tempComponentRev = null;
|
||||
if (targetComponent instanceof TCComponentItemRevision) {
|
||||
tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
} else if (targetComponent instanceof TCComponentBOMLine) {
|
||||
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
}
|
||||
|
||||
if (tempComponentRev != null
|
||||
&& tempComponentRev.getStringProperty("object_type").equals("VF5gxRevision")) {
|
||||
gxRevList.add(tempComponentRev);
|
||||
} else {
|
||||
MessageBox.post(
|
||||
"Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
|
||||
"Error", MessageBox.ERROR);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
|
||||
}
|
||||
|
||||
public Map<String, String> isExistNull() throws TCException {
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
|
||||
SwingUtil.getKeyValue("VF5gxlxlov", lovMap);
|
||||
idList = new String[targetComponents.length][3];
|
||||
for (InterfaceAIFComponent targetComponent : targetComponents) {
|
||||
int count = 0;
|
||||
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
|
||||
TCComponent ccpForm = null;
|
||||
String pnValue = "";
|
||||
String processValue = "";
|
||||
String sequenceValue = getBomLineRowNumber((TCComponentItemRevision) targetRev);
|
||||
TCComponentItemRevision gyRev = null;
|
||||
TCComponent[] whereUsed = targetRev.whereUsed((short) 0);
|
||||
if (whereUsed != null && whereUsed.length > 0) {
|
||||
for (TCComponent tcItem : whereUsed) {
|
||||
if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
|
||||
gyRev = (TCComponentItemRevision) tcItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
|
||||
}
|
||||
if (gyRev != null) {
|
||||
TCComponent[] ccpItems = gyRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
|
||||
String type ="";
|
||||
for (TCComponent ccpItem : ccpItems) {
|
||||
type = ccpItem.getStringProperty("object_type");
|
||||
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
|
||||
ccpForm = ccpItem.getRelatedComponent("IMAN_master_form_rev");
|
||||
pnValue = ccpForm.getStringProperty("vf5wlbm");
|
||||
|
||||
TCComponent gxForm = targetRev.getRelatedComponent("IMAN_master_form_rev");
|
||||
String gxlx = gxForm.getStringProperty("vf5gxlx");
|
||||
System.out.println("gxForm(vf5gxlx) : " + gxlx);
|
||||
processValue = gxlx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomException(
|
||||
targetRev.getStringProperty("object_name") + " : parent's item is not exist !");
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"pnValue:" + pnValue + " | processValue:" + processValue + " | sequenceValue:" + sequenceValue);
|
||||
idList[count][0] = pnValue;
|
||||
idList[count][1] = processValue;
|
||||
idList[count++][2] = sequenceValue;
|
||||
|
||||
if (ccpForm != null) {
|
||||
String property = ccpForm.getStringProperty("vf5wlbm");
|
||||
if (property.isEmpty()) {
|
||||
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
|
||||
}
|
||||
} else {
|
||||
System.out.println("cannot get form item !");
|
||||
}
|
||||
}
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
|
||||
TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
|
||||
String localId = itemRev.getStringProperty("item_id");
|
||||
TCComponentBOMLine bomLine = null;
|
||||
TCComponentBOMWindow view = null;
|
||||
if (whereUsed != null && whereUsed.length > 0) {
|
||||
TCComponentItemRevision tempItemRev = (TCComponentItemRevision) whereUsed[0];
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
|
||||
view = winType.create(null);
|
||||
|
||||
bomLine = view.setWindowTopLine(tempItemRev.getItem(), tempItemRev, null, null);
|
||||
} else {
|
||||
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
|
||||
}
|
||||
|
||||
if (bomLine != null && bomLine.hasChildren()) {
|
||||
AIFComponentContext[] childrena = bomLine.getChildren();
|
||||
for (int i = 0; i < childrena.length; i++) {
|
||||
TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
|
||||
if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
|
||||
return i + 1 + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void createNbtzItem() {
|
||||
for (InterfaceAIFComponent targetComponent : targetComponents) {
|
||||
int count = 0;
|
||||
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
|
||||
try {
|
||||
TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
|
||||
boolean flag = true;
|
||||
if (tzReferences != null && tzReferences.length > 0) {
|
||||
for (int i = 0; i < tzReferences.length; i++) {
|
||||
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem tzItem = tzType.create(
|
||||
idList[count][0] + ruleName + idList[count][1] + idList[count++][2], "", itemType, itemName,
|
||||
"", null);
|
||||
if (tzItem != null) {
|
||||
targetRev.add(revReference, tzItem);
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
} else {
|
||||
MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
|
||||
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateToolingListHandler extends AbstractHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateToolingListAction commonAction = new CreateToolingListAction(application, "VF5tlgx", "VF5tl","ToolList","-TL-");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.LTinspectionPlan;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class InspectionPlanHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ipgx", "VF5ip","In-Process Inspection Plan","-IP");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateStandardInstructionHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateToolingListAction commonAction = new CreateToolingListAction(
|
||||
application, "VF5swigx", "VF5swi","Standard Work Instruction","-SWI-");
|
||||
new Thread(commonAction).start();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,326 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dialog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentDataset;
|
||||
import com.teamcenter.rac.kernel.TCComponentDatasetType;
|
||||
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;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class UploadDocumentsDialog extends AbstractAIFDialog {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private JLabel selectUploadLabel;
|
||||
private JComponent uploadInput;
|
||||
|
||||
private JButton importButton;
|
||||
private JButton okButton;
|
||||
private JButton celButton;
|
||||
|
||||
private TCComponentDatasetType pdfType;
|
||||
private TCComponentDatasetType dwgType;
|
||||
private TCComponentDatasetType docType;
|
||||
private TCComponentDatasetType docxType;
|
||||
private TCComponentDatasetType xlsType;
|
||||
private TCComponentDatasetType xlsxType;
|
||||
private TCComponentDatasetType defaultType;
|
||||
|
||||
public UploadDocumentsDialog(AbstractAIFApplication application) {
|
||||
super(true);
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) this.application.getSession();
|
||||
}
|
||||
|
||||
public void initializationComponent() {
|
||||
selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
|
||||
uploadInput = new JTextField(14);
|
||||
|
||||
importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
|
||||
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
|
||||
SwingUtilities.getWindowAncestor(importButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
pdfType = (TCComponentDatasetType) tcSession.getTypeComponent("PDF");
|
||||
dwgType = (TCComponentDatasetType) tcSession.getTypeComponent("VF5CAD");
|
||||
docType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWord");
|
||||
docxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWordX");
|
||||
xlsType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcel");
|
||||
xlsxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcelX");
|
||||
defaultType = (TCComponentDatasetType) tcSession.getTypeComponent("Dataset");
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
initUi();
|
||||
}
|
||||
|
||||
/**
|
||||
* ³õʼ»¯½çÃæ
|
||||
*/
|
||||
public void initUi() {
|
||||
initializationComponent();
|
||||
this.setTitle(ConstantPool.EN_TITLE_UPLOAD_PATH);
|
||||
|
||||
this.setLayout(null);
|
||||
|
||||
selectUploadLabel.setBounds(30, 40, 80, 25);
|
||||
this.add(selectUploadLabel);
|
||||
|
||||
uploadInput.setBounds(110, 40, 150, 25);
|
||||
this.add(uploadInput);
|
||||
|
||||
importButton.setBounds(280, 40, 90, 25);
|
||||
|
||||
importButton.addActionListener(e -> {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
fileChooser.setMultiSelectionEnabled(false);
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
|
||||
fileChooser.setFileFilter(filter);
|
||||
|
||||
int result = fileChooser.showOpenDialog(this);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
this.add(importButton, BorderLayout.EAST);
|
||||
|
||||
okButton.setBounds(80, 90, 100, 25);
|
||||
celButton.setBounds(200, 90, 100, 25);
|
||||
|
||||
okButton.addActionListener(e -> {
|
||||
String path = ((JTextField) uploadInput).getText();
|
||||
if (path.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
|
||||
} else {
|
||||
File file = new File(path);
|
||||
if (!file.exists() || !file.isDirectory()) {
|
||||
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
|
||||
} else {
|
||||
this.dispose();
|
||||
uploadDrawings(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
celButton.addActionListener(e -> {
|
||||
this.setVisible(false);
|
||||
this.disposeDialog();
|
||||
});
|
||||
this.add(okButton);
|
||||
this.add(celButton);
|
||||
this.pack();
|
||||
this.setSize(410, 190);
|
||||
this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void uploadDrawings(File file) {
|
||||
List<File> localFiles = getFilesInDirectory(file.getAbsolutePath());
|
||||
|
||||
// for (File localFile : localFiles) {
|
||||
// System.out.println("Found file: " + localFile.getAbsolutePath());
|
||||
// }
|
||||
try {
|
||||
addDataSet(localFiles);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
System.out.println("123");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean createDataSet(TCComponentItemRevision rev, File localFile) throws TCException {
|
||||
String fileName = localFile.getName();
|
||||
String[] split = fileName.split("\\.");
|
||||
System.out.println("ÀàÐÍ: " + split[1]);
|
||||
String type = "";
|
||||
String tool = "";
|
||||
TCComponentDatasetType tempType = null;
|
||||
if (split != null && split.length == 2) {
|
||||
switch (split[1].toLowerCase()) {
|
||||
case "pdf": {
|
||||
type = "PDF";
|
||||
tool = "PDF_Reference";
|
||||
tempType = pdfType;
|
||||
break;
|
||||
}
|
||||
case "dwg": {
|
||||
type = "VF5CAD";
|
||||
tool = "VF5dwg";
|
||||
tempType = dwgType;
|
||||
break;
|
||||
}
|
||||
case "doc": {
|
||||
type = "MSWord";
|
||||
tool = "word";
|
||||
tempType = docType;
|
||||
break;
|
||||
}
|
||||
case "docx": {
|
||||
type = "MSWordX";
|
||||
tool = "word";
|
||||
tempType = docxType;
|
||||
break;
|
||||
}
|
||||
case "xls": {
|
||||
type = "MSExcel";
|
||||
tool = "excel";
|
||||
tempType = xlsType;
|
||||
break;
|
||||
}
|
||||
case "xlsx": {
|
||||
type = "MSExcelX";
|
||||
tool = "excel";
|
||||
tempType = xlsxType;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
type = "CAEAnalysisDS";
|
||||
tool = "CAEAnaysisData";
|
||||
tempType = defaultType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TCComponentDataset tempData = tempType.create(fileName, "", type);
|
||||
try {
|
||||
tempData.setFiles(new String[] { localFile.getAbsolutePath() }, new String[] { tool });
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return false;
|
||||
}
|
||||
if (tempData != null) {
|
||||
rev.add("IMAN_specification", tempData);
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("Folder Name Is Error !");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addDataSet(List<File> localFiles) throws TCException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
int successfulCount = 0;
|
||||
int failedCount = 0;
|
||||
int notFoundCount = 0;
|
||||
|
||||
// StringBuffer successfulData = new StringBuffer("");
|
||||
StringBuffer failedData = new StringBuffer("");
|
||||
StringBuffer notFoundData = new StringBuffer("");
|
||||
for (File localFile : localFiles) {
|
||||
String fileName = localFile.getName();
|
||||
String queryValue = fileName.substring(0,
|
||||
fileName.lastIndexOf(".") == -1 ? fileName.length() : fileName.lastIndexOf("."));
|
||||
System.out.println("fileName : " + fileName);
|
||||
System.out.println("queryValue : " + queryValue);
|
||||
InterfaceAIFComponent[] resultComponents = queryItem(queryValue);
|
||||
if (resultComponents != null && resultComponents.length > 0) {
|
||||
TCComponentItemRevision queryRev = null;
|
||||
if (resultComponents[0] instanceof TCComponentItem) {
|
||||
queryRev = ((TCComponentItem) resultComponents[0]).getLatestItemRevision();
|
||||
} else if (resultComponents[0] instanceof TCComponentItemRevision) {
|
||||
queryRev = (TCComponentItemRevision) resultComponents[0];
|
||||
}
|
||||
|
||||
if (resultComponents[0] != null) {
|
||||
if (createDataSet(queryRev, localFile)) {
|
||||
// successfulData.append(fileName);
|
||||
// successfulData.append(" ");
|
||||
successfulCount++;
|
||||
} else {
|
||||
failedData.append(fileName);
|
||||
failedData.append(" ");
|
||||
failedCount++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notFoundData.append(fileName);
|
||||
notFoundData.append(" ");
|
||||
notFoundCount++;
|
||||
}
|
||||
}
|
||||
StringBuffer resultData = new StringBuffer("");
|
||||
resultData.append("Successful: ");
|
||||
resultData.append(successfulCount);
|
||||
resultData.append("\n");
|
||||
|
||||
resultData.append("Failed: ");
|
||||
resultData.append(failedCount);
|
||||
resultData.append(" ->");
|
||||
resultData.append(failedData);
|
||||
resultData.append("\n");
|
||||
|
||||
resultData.append("Not Found Rev: ");
|
||||
resultData.append(notFoundCount);
|
||||
resultData.append(" ->");
|
||||
resultData.append(notFoundData);
|
||||
resultData.append("\n");
|
||||
|
||||
MessageBox.post(resultData.toString(), "Info", MessageBox.INFORMATION);
|
||||
}
|
||||
|
||||
public InterfaceAIFComponent[] queryItem(String itemId) {
|
||||
try {
|
||||
return tcSession.search("MU_Find ItemRevision", new String[] { "ID" }, new String[] { itemId });
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<File> getFilesInDirectory(String directoryPath) {
|
||||
List<File> filesList = new ArrayList<>();
|
||||
|
||||
File directory = new File(directoryPath);
|
||||
|
||||
if (!directory.exists() || !directory.isDirectory()) {
|
||||
System.out.println("The specified path is not a valid directory: " + directoryPath);
|
||||
return filesList;
|
||||
}
|
||||
|
||||
File[] filesAndDirs = directory.listFiles();
|
||||
|
||||
if (filesAndDirs != null) {
|
||||
for (File file : filesAndDirs) {
|
||||
if (file.isFile()) {
|
||||
filesList.add(file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Failed to list files in the directory: " + directoryPath);
|
||||
}
|
||||
|
||||
return filesList;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
|
||||
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class UploadDocumentsHandler extends AbstractHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI"}, "Folder");
|
||||
if(judgeSingleSelectComponent) {
|
||||
UploadDocumentsDialog dialog = new UploadDocumentsDialog(application);
|
||||
|
||||
new Thread(dialog).start();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ApprovalofDocumentsDialog extends JFrame implements Runnable {
|
||||
|
||||
private final String title;
|
||||
|
||||
private JButton okButton;
|
||||
private JButton cancelButton;
|
||||
private JCheckBox allCheck;
|
||||
|
||||
private String[] columnNames;
|
||||
private Object[][] data;
|
||||
private JTable table;
|
||||
private AbstractAIFApplication application;
|
||||
|
||||
public ApprovalofDocumentsDialog(AbstractAIFApplication application ,String title, Object... args) {
|
||||
int count = 0;
|
||||
this.title = title;
|
||||
this.application = application;
|
||||
columnNames = (String[]) args[count++];
|
||||
data = (Object[][]) args[count];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
initUI();
|
||||
}
|
||||
|
||||
public void initializationButton() {
|
||||
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
okButton.addActionListener(e -> {
|
||||
try {
|
||||
doTask();
|
||||
} catch (TCException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
cancelButton.addActionListener(e -> {
|
||||
this.dispose();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
// 设置窗口居中
|
||||
this.setTitle(title);
|
||||
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setSize(600, 400); // 设置窗口大小
|
||||
this.setLayout(new BorderLayout()); // 设置布局
|
||||
this.setLocationRelativeTo(null);
|
||||
|
||||
initializationButton();
|
||||
|
||||
JPanel topPanel = createTopPanel();
|
||||
JPanel centerPanel = createCenterPanel();
|
||||
JPanel bottomPanel = createBottomPanel();
|
||||
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
this.add(centerPanel, BorderLayout.CENTER);
|
||||
this.add(bottomPanel, BorderLayout.SOUTH);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private JPanel createTopPanel() {
|
||||
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
|
||||
topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
allCheck = new JCheckBox("AllSelect");
|
||||
allCheck.addActionListener(e -> {
|
||||
if (allCheck.isSelected()) {
|
||||
for (int i = 0; i < table.getRowCount(); i++) {
|
||||
table.setValueAt(true, i, columnNames.length - 2);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < table.getRowCount(); i++) {
|
||||
table.setValueAt(false, i, columnNames.length - 2);
|
||||
}
|
||||
}
|
||||
});
|
||||
topPanel.add(allCheck);
|
||||
|
||||
return topPanel;
|
||||
}
|
||||
|
||||
public JPanel createCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
|
||||
// centerPanel.setBorder(BorderFactory.createTitledBorder(childTitle));
|
||||
centerPanel.setPreferredSize(new Dimension(400, 200));
|
||||
|
||||
DefaultTableModel model = new DefaultTableModel(data, columnNames) {
|
||||
@Override
|
||||
public boolean isCellEditable(int row, int column) {
|
||||
return column != -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex == columnNames.length - 1) {
|
||||
return Boolean.class;
|
||||
}
|
||||
return String.class;
|
||||
}
|
||||
};
|
||||
table = new JTable(model);
|
||||
table.setRowHeight(18);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.setAutoCreateRowSorter(true);
|
||||
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
table.setRowHeight(20);
|
||||
|
||||
table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 2));
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
TableCellRenderer selectRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column) -> {
|
||||
JCheckBox checkBox = new JCheckBox();
|
||||
|
||||
if (value instanceof Boolean) {
|
||||
checkBox.setSelected((Boolean) value);
|
||||
} else if (value instanceof String) {
|
||||
checkBox.setSelected(Boolean.parseBoolean((String) value));
|
||||
} else {
|
||||
checkBox.setSelected(false);
|
||||
}
|
||||
|
||||
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
return checkBox;
|
||||
};
|
||||
|
||||
for (int i = 0; i < columnModel.getColumnCount(); i++) {
|
||||
columnModel.getColumn(i).setCellRenderer(centerRenderer);
|
||||
}
|
||||
columnModel.getColumn(columnNames.length - 2).setCellRenderer(selectRenderer);
|
||||
|
||||
table.getModel().addTableModelListener(e -> {
|
||||
if (e.getType() == TableModelEvent.UPDATE) {
|
||||
int column = e.getColumn();
|
||||
if (column == columnNames.length - 2) {
|
||||
boolean allSelected = true;
|
||||
for (int i = 0; i < table.getRowCount(); i++) {
|
||||
boolean selected = (boolean) table.getValueAt(i, column);
|
||||
if (!selected) {
|
||||
allSelected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
allCheck.setSelected(allSelected);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
scrollPane.setPreferredSize(new Dimension(400, 150));
|
||||
centerPanel.add(scrollPane, BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public JPanel createBottomPanel() {
|
||||
// 创建底部面板,包含按钮
|
||||
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 60, 10));
|
||||
bottomPanel.add(okButton);
|
||||
bottomPanel.add(cancelButton);
|
||||
return bottomPanel;
|
||||
}
|
||||
|
||||
public void doTask() throws TCException {
|
||||
int rowCount = table.getRowCount();
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
|
||||
int selectedRowCount = 0;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
Object value = model.getValueAt(table.convertRowIndexToModel(i), columnNames.length - 1);
|
||||
boolean isSelected = false;
|
||||
if (value instanceof Boolean) {
|
||||
isSelected = (Boolean) value;
|
||||
} else if (value instanceof String) {
|
||||
isSelected = Boolean.parseBoolean((String) value);
|
||||
}
|
||||
if (isSelected) {
|
||||
selectedRowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
TCSession session = (TCSession) application.getSession();
|
||||
String[][] selectedData = new String[selectedRowCount][model.getColumnCount()];
|
||||
List<TCComponent> list = new ArrayList<>();
|
||||
int index = 0;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
int modelIndex = table.convertRowIndexToModel(i);
|
||||
boolean isSelected = (Boolean) model.getValueAt(modelIndex, columnNames.length - 1);
|
||||
if (isSelected) {
|
||||
String[] rowData = new String[model.getColumnCount()];
|
||||
for (int j = 0; j < model.getColumnCount(); j++) {
|
||||
Object value = model.getValueAt(modelIndex, j);
|
||||
if (value instanceof String) {
|
||||
rowData[j] = (String) value;
|
||||
} else if (value instanceof Boolean) {
|
||||
rowData[j] = value.toString();
|
||||
} else {
|
||||
rowData[j] = value == null ? "" : value.toString();
|
||||
}
|
||||
}
|
||||
selectedData[index++] = rowData;
|
||||
System.out.println("Selected Row Data: " + Arrays.toString(rowData));
|
||||
list.add((TCComponent) session.stringToComponent(rowData[rowData.length - 2]));
|
||||
}
|
||||
}
|
||||
|
||||
TCComponent[] tcRev = list.toArray(new TCComponent[list.size()]);
|
||||
// TcUtil.CreateProcess(session, tcRev, TcUtil.getPreferenceValue(session, "VF5JSWJSPLC"));
|
||||
if (selectedData.length == 0) {
|
||||
System.out.println("No rows selected");
|
||||
}
|
||||
NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application, tcRev);
|
||||
cmd.executeModeless();
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.material.finishedProducts;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class FinishedProductsCreateHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
|
||||
"计量单位", "计划默认属性", "备注" };
|
||||
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
|
||||
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
|
||||
"Unit", "Plan default attributes", "Remarks" };
|
||||
|
||||
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
|
||||
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
|
||||
|
||||
JLabel[] jLabels = new JLabel[enLabelName.length];
|
||||
JComponent[] jComponents = new JComponent[enLabelName.length];
|
||||
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
|
||||
Map<Integer, String[]> map = new HashMap<>();
|
||||
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
|
||||
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
|
||||
map.put(enLabelName.length - 3, inHouse);
|
||||
map.put(enLabelName.length - 2, eas);
|
||||
|
||||
for (int i = 0; i < enLabelName.length; i++) {
|
||||
if (map.containsKey(i)) {
|
||||
jComponents[i] = new JComboBox<>(map.get(i));
|
||||
} else {
|
||||
jComponents[i] = new JTextField(14);
|
||||
}
|
||||
jLabels[i] = new JLabel(enLabelName[i]);
|
||||
}
|
||||
System.out.println("In house :" + inHouse);
|
||||
for (String inhouse : inHouse) {
|
||||
if (inhouse.equals("In-House Production")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
|
||||
}
|
||||
}
|
||||
for (String ea : eas) {
|
||||
if (ea.equals("EA")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> keySet = lovMap.keySet();
|
||||
for (String key : keySet) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
str.append(key);
|
||||
str.append(" ==> ");
|
||||
Map<String, String> map2 = lovMap.get(key);
|
||||
Set<String> keySet2 = map2.keySet();
|
||||
for (String key2 : keySet2) {
|
||||
String value2 = map2.get(key2);
|
||||
str.append("( ");
|
||||
str.append(key2);
|
||||
str.append(" || ");
|
||||
str.append(value2);
|
||||
str.append(" )");
|
||||
}
|
||||
System.out.println(str.toString());
|
||||
}
|
||||
|
||||
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create finished products",
|
||||
"finishedProducts", jLabels, jComponents, prop, lovMap);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,435 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.material.finishedProducts;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.connor.ferrorTech.metal.constant.ConstantPool;
|
||||
import com.connor.ferrorTech.metal.importMaterial.MaterialPropertyBean;
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
import com.teamcenter.rac.commands.open.OpenCommand;
|
||||
import com.teamcenter.rac.kernel.TCComponent;
|
||||
import com.teamcenter.rac.kernel.TCComponentFolder;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
import com.teamcenter.rac.util.Registry;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ProductsCreateFrame extends JFrame implements Runnable {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private String title;
|
||||
private String objectName;
|
||||
private JLabel[] jLabels;
|
||||
private JComponent[] jComponents;
|
||||
private String[] prop;
|
||||
private Map<String, Map<String, String>> lovMap;
|
||||
|
||||
private JButton okButton;
|
||||
private JButton celButton;
|
||||
private JButton queryButton;
|
||||
|
||||
private String url;
|
||||
private String sapCheck;
|
||||
private String soaRetrunType;
|
||||
private Map<String,String> map;
|
||||
|
||||
private TCComponentFolder targetFolder;
|
||||
|
||||
public ProductsCreateFrame(AbstractAIFApplication application, String title, String objectName, Object... args) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.title = title;
|
||||
this.objectName = objectName;
|
||||
this.jLabels = (JLabel[]) args[0];
|
||||
this.jComponents = (JComponent[]) args[1];
|
||||
this.prop = (String[]) args[2];
|
||||
this.lovMap = (Map<String, Map<String, String>>) args[3];
|
||||
|
||||
map = new HashMap<String,String>();
|
||||
map.put("finishedProducts","VF5ccp");
|
||||
map.put("semiFinishedProducts","VF5bcp");
|
||||
map.put("material","VF5cl");
|
||||
}
|
||||
|
||||
public void initUI() {
|
||||
this.setTitle(title);
|
||||
this.setSize(600, 570);
|
||||
// 初始化组件
|
||||
initializationComponent();
|
||||
// 添加内容到JFrame 并设置它的位置
|
||||
JScrollPane centerPanel = getCenterPanel();
|
||||
JPanel bottomPanel = getBottomPanel();
|
||||
|
||||
this.getContentPane().add(centerPanel, 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(ConstantPool.EN_BUTTON_CONFIRM);
|
||||
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
|
||||
queryButton = new JButton("Query");
|
||||
}
|
||||
|
||||
public JScrollPane getCenterPanel() {
|
||||
JPanel centerPanel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints customLayout = new GridBagConstraints();
|
||||
|
||||
// 添加第一个JLabel和JTextField
|
||||
customLayout.insets = new Insets(5, 30, 5, 20); // 边距
|
||||
customLayout.gridx = 0;
|
||||
customLayout.weightx = 0;
|
||||
customLayout.anchor = GridBagConstraints.LINE_START;
|
||||
jLabels[0].setFont(new Font("微软雅黑", Font.BOLD, 13));
|
||||
centerPanel.add(jLabels[0], customLayout);
|
||||
|
||||
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
|
||||
customLayout.gridx = 1;
|
||||
customLayout.fill = GridBagConstraints.HORIZONTAL;
|
||||
JComponent jComponent = jComponents[0];
|
||||
jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
centerPanel.add(jComponent, customLayout);
|
||||
|
||||
// 将queryButton放在第一个输入框的右边
|
||||
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
|
||||
customLayout.gridx = 2;
|
||||
customLayout.fill = GridBagConstraints.HORIZONTAL;
|
||||
queryButton.setFont(new Font("微软雅黑", Font.BOLD, 12));
|
||||
centerPanel.add(queryButton, customLayout);
|
||||
|
||||
// 添加剩余的JLabel和JTextField
|
||||
for (int i = 1; i < jLabels.length; i++) {
|
||||
customLayout.insets = new Insets(5, 30, 5, 20); // 边距
|
||||
customLayout.gridx = 0;
|
||||
customLayout.gridy = i; // 设置垂直位置
|
||||
customLayout.weightx = 0;
|
||||
customLayout.anchor = GridBagConstraints.LINE_START;
|
||||
jLabels[i].setFont(new Font("微软雅黑", Font.BOLD, 13));
|
||||
centerPanel.add(jLabels[i], customLayout);
|
||||
|
||||
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
|
||||
customLayout.gridx = 1;
|
||||
customLayout.fill = GridBagConstraints.HORIZONTAL;
|
||||
jComponent = jComponents[i];
|
||||
jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15));
|
||||
centerPanel.add(jComponent, customLayout);
|
||||
}
|
||||
|
||||
// 创建具有滚动功能的JPanel
|
||||
return new JScrollPane(centerPanel);
|
||||
}
|
||||
|
||||
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);
|
||||
bottomPanel.add(this.celButton);
|
||||
// 添加监听
|
||||
okButton.addActionListener(e -> {
|
||||
this.dispose(); // 关闭窗口
|
||||
confirmFunction();
|
||||
});
|
||||
celButton.addActionListener(e -> {
|
||||
this.dispose(); // 关闭窗口
|
||||
});
|
||||
queryButton.addActionListener(e->{
|
||||
try {
|
||||
queryItem();
|
||||
} catch (Exception e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
return bottomPanel;
|
||||
}
|
||||
|
||||
public void queryItem() throws Exception {
|
||||
// TODO 校验物料编码是否为空
|
||||
JTextField codeField = (JTextField)jComponents[0];
|
||||
String codeName = codeField.getText();
|
||||
if(codeName.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this, "Please fill in the material code!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
InterfaceAIFComponent[] results = tcSession.search("MU_Find Part",new String[] {"vf5wlbm"}, new String[]{codeName});
|
||||
|
||||
// 存在则提示已经存在该物料,并打开查询到的物料。
|
||||
if(results!=null && results.length>0) {
|
||||
JOptionPane.showMessageDialog(this, "The material already exists!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
this.dispose();
|
||||
TCComponent target = (TCComponent) results[0];
|
||||
com.teamcenter.rac.common.Activator.getDefault()
|
||||
.openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
|
||||
com.teamcenter.rac.common.Activator.getDefault().openComponents(
|
||||
"com.teamcenter.rac.ui.perspectives.navigatorPerspective",
|
||||
new InterfaceAIFComponent[]{target});
|
||||
}
|
||||
//如果不存在则调用SAP物料接口获取对应物料信息
|
||||
String[] sapUrls = tcSession.getPreferenceService().getStringValues("SAP_url");
|
||||
if(sapUrls!=null && sapUrls.length>0) {
|
||||
url = sapUrls[0];
|
||||
}else {
|
||||
JOptionPane.showMessageDialog(this, "SAP_url preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
sapCheck = tcSession.getPreferenceService().getStringValue("SAP_check");
|
||||
if(sapCheck.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this, "SAP_check preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
MaterialPropertyBean materialInfo = materialInfoBySap(codeName);
|
||||
if(materialInfo == null) {
|
||||
JOptionPane.showMessageDialog(this, "SAP does not exist for this material!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
}else {
|
||||
System.out.println("get info :"+materialInfo.toString());
|
||||
String selectType = map.get(objectName);
|
||||
soaRetrunType = materialInfo.getMaterialType();
|
||||
if(!selectType.equals(soaRetrunType)) {
|
||||
JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
JTextField nameField = (JTextField)jComponents[1];
|
||||
nameField.setText(materialInfo.getObjectName());
|
||||
|
||||
JComboBox<String> unitBox =(JComboBox) jComponents[jComponents.length-3];
|
||||
unitBox.setSelectedItem(materialInfo.getVf5dw());
|
||||
|
||||
JComboBox<String> planBox =(JComboBox) jComponents[jComponents.length-2];
|
||||
planBox.setSelectedItem(materialInfo.getVf5jhmrsx());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean confirmFunction() {
|
||||
Map<String, String> propMap = SwingUtil.getJComponentValue(prop, jComponents);
|
||||
String selectType = map.get(objectName);
|
||||
System.out.println("selectType : "+selectType);
|
||||
if(soaRetrunType!=null && !soaRetrunType.isEmpty() && !selectType.equals(soaRetrunType)) {
|
||||
JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
createItem(selectType, propMap);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void createItem(String itemType, Map<String, String> propMap) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
TCComponentItemType ccpType = (TCComponentItemType) this.tcSession.getTypeComponent(itemType);
|
||||
TCComponentItem ccpItem = ccpType.create(ccpType.getNewID(), "", itemType, propMap.get("object_name"), "",
|
||||
null);
|
||||
TCComponent[] referenceValueArray = ccpItem.getLatestItemRevision().getTCProperty("IMAN_master_form_rev")
|
||||
.getReferenceValueArray();
|
||||
TCComponent form = referenceValueArray[0];
|
||||
Set<String> keySet = propMap.keySet();
|
||||
for (String key : keySet) {
|
||||
if (key.equals("vf5jhmrsx")) {
|
||||
form.setProperty(key,lovMap.get("VF5jhmrsx").get(propMap.get(key)));
|
||||
} else {
|
||||
form.setProperty(key, propMap.get(key));
|
||||
}
|
||||
}
|
||||
targetFolder.add("contents", ccpItem);
|
||||
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
|
||||
} catch (TCException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
|
||||
String itemType = targetComponent.getType();
|
||||
if (targetComponent instanceof TCComponentFolder
|
||||
&& (itemType.equals("VF5NPI") || itemType.equals("VF5xmwjj") || itemType.equals("Folder"))) {
|
||||
targetFolder = (TCComponentFolder) targetComponent;
|
||||
initUI();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "not Folder or type error", "Warning", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询构建器查询物料
|
||||
*
|
||||
* @param materialCode
|
||||
* @return
|
||||
*/
|
||||
public boolean queryMaterial(String materialCode) {
|
||||
|
||||
try {
|
||||
TCComponent[] materialObjects = tcSession.search("FTH_Find PartRevisionBywlbm", new String[] { "fth4wlbm" },
|
||||
new String[] { materialCode });
|
||||
if (materialObjects.length >= 1) {
|
||||
TCComponent com = materialObjects[0];
|
||||
// 打开对象
|
||||
Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open");
|
||||
OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand",
|
||||
new Object[] { AIFUtility.getActiveDesktop(), com });
|
||||
localOpenCommand.executeModeless();
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sap接口连接
|
||||
*
|
||||
* @param param
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String sapConnect(String param, String code) {
|
||||
String result = null;
|
||||
HttpsURLConnection connection = null;
|
||||
try {
|
||||
String[] split = sapCheck.split(":");
|
||||
// 基本认证用户名和密码
|
||||
String basicAuth = "Basic "
|
||||
+ new String(Base64.getEncoder().encode((split[0] + ":" + split[1]).getBytes()));
|
||||
|
||||
// 创建URL对象
|
||||
URL urlObj = null;
|
||||
if (code != null && code != "") {
|
||||
urlObj = new URL(url + "/" + param + "/" + code);
|
||||
} else {
|
||||
urlObj = new URL(url + "/" + param);
|
||||
}
|
||||
|
||||
// 打开连接
|
||||
connection = (HttpsURLConnection) urlObj.openConnection();
|
||||
// 添加认证头
|
||||
connection.setRequestProperty("Authorization", basicAuth);
|
||||
|
||||
// 设置请求方法为GET
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
// 接收响应码
|
||||
int responseCode = connection.getResponseCode();
|
||||
System.out.println("Response Code: " + responseCode);
|
||||
|
||||
// 读取响应内容
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
result = response.toString();
|
||||
// 打印结果
|
||||
System.out.println(response.toString());
|
||||
} catch (Exception e) {
|
||||
e.getStackTrace();
|
||||
System.out.println(e.getStackTrace());
|
||||
} finally {
|
||||
// 关闭连接
|
||||
connection.disconnect();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过SAP接口获取物料信息
|
||||
*/
|
||||
public MaterialPropertyBean materialInfoBySap(String materialCode) {
|
||||
MaterialPropertyBean materiaPorptry = new MaterialPropertyBean();
|
||||
// 通过接口获取物料信息
|
||||
String value = sapConnect("Product", materialCode);
|
||||
System.out.println("物料信息json:" + value);
|
||||
if (value != null) {
|
||||
JSONObject jsonObject = new JSONObject(value);
|
||||
materiaPorptry.setVf5wlbm(jsonObject.getString("Product"));
|
||||
System.out.println("物料编码:" + jsonObject.getString("Product"));
|
||||
if ("FERT".equals(jsonObject.getString("ProductType"))) {
|
||||
materiaPorptry.setMaterialType("VF5ccp");
|
||||
} else if ("HALB".equals(jsonObject.getString("ProductType"))) {
|
||||
materiaPorptry.setMaterialType("VF5bcp");
|
||||
} else if ("ROH".equals(jsonObject.getString("ProductType"))) {
|
||||
materiaPorptry.setMaterialType("VF5cl");
|
||||
}
|
||||
String dw = jsonObject.getString("BaseUnit");
|
||||
if("ST".equals(dw)) {
|
||||
materiaPorptry.setVf5dw("PC");
|
||||
}else {
|
||||
materiaPorptry.setVf5dw(dw);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// 物料描述信息
|
||||
String value3 = sapConnect("ProductDescription(Product='" + materialCode + "',Language='EN')", "");
|
||||
if (value3 != null) {
|
||||
System.out.println("物料描述类型json:" + value3);
|
||||
JSONObject jsonObject = new JSONObject(value3);
|
||||
materiaPorptry.setObjectName(jsonObject.getString("ProductDescription"));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// 物料采购类型
|
||||
String value2 = sapConnect("ProductPlantSupplyPlanning(Product='" + materialCode + "',Plant='5410')", "");
|
||||
if (value2 != null) {
|
||||
System.out.println("物料采购类型json:" + value2);
|
||||
JSONObject jsonObject = new JSONObject(value2);
|
||||
if ("E".equals(jsonObject.getString("ProcurementType"))) {
|
||||
materiaPorptry.setVf5jhmrsx("In-House Production");
|
||||
} else if ("F".equals(jsonObject.getString("ProcurementType"))) {
|
||||
materiaPorptry.setVf5jhmrsx("External Procurement");
|
||||
} else if ("X".equals(jsonObject.getString("ProcurementType"))) {
|
||||
materiaPorptry.setVf5jhmrsx("Both Procurement Type");
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return materiaPorptry;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
finishedProductsDialog.0=Create Finished Products
|
||||
finishedProductsDialog.1=Material code
|
||||
finishedProductsDialog.2=Material name
|
||||
finishedProductsDialog.3=Customer drawing number
|
||||
finishedProductsDialog.4=Material
|
||||
finishedProductsDialog.5=Specification
|
||||
finishedProductsDialog.6=Part size
|
||||
finishedProductsDialog.7=Material size
|
||||
finishedProductsDialog.8=Surface requirements
|
||||
finishedProductsDialog.9=Cutting method
|
||||
finishedProductsDialog.10=Unit
|
||||
finishedProductsDialog.11=Plan default attributes
|
||||
finishedProductsDialog.12=Remarks
|
@ -1,72 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.material.material;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class MaterialCreateHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
|
||||
"计量单位", "计划默认属性", "备注" };
|
||||
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
|
||||
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
|
||||
"Unit", "Plan default attributes", "Remarks" };
|
||||
|
||||
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
|
||||
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
|
||||
|
||||
JLabel[] jLabels = new JLabel[enLabelName.length];
|
||||
JComponent[] jComponents = new JComponent[enLabelName.length];
|
||||
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
|
||||
Map<Integer, String[]> map = new HashMap<>();
|
||||
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
|
||||
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
|
||||
map.put(enLabelName.length - 3, inHouse);
|
||||
map.put(enLabelName.length - 2, eas);
|
||||
|
||||
for (int i = 0; i < enLabelName.length; i++) {
|
||||
if (map.containsKey(i)) {
|
||||
jComponents[i] = new JComboBox<>(map.get(i));
|
||||
} else {
|
||||
jComponents[i] = new JTextField(14);
|
||||
}
|
||||
jLabels[i] = new JLabel(enLabelName[i]);
|
||||
}
|
||||
System.out.println("In house :" + inHouse);
|
||||
for (String inhouse : inHouse) {
|
||||
if (inhouse.equals("In-House Production")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
|
||||
}
|
||||
}
|
||||
for (String ea : eas) {
|
||||
if (ea.equals("EA")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
|
||||
}
|
||||
}
|
||||
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create materials", "material", jLabels,
|
||||
jComponents, prop, lovMap);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.material.semiFinishedProducts;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
|
||||
import com.connor.ferrorTech.metal.util.SwingUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aifrcp.AIFUtility;
|
||||
|
||||
public class SemiFinishedProductsCreateHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
|
||||
"计量单位", "计划默认属性", "备注" };
|
||||
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
|
||||
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
|
||||
"Unit", "Plan default attributes", "Remarks" };
|
||||
|
||||
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
|
||||
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
|
||||
|
||||
JLabel[] jLabels = new JLabel[enLabelName.length];
|
||||
JComponent[] jComponents = new JComponent[enLabelName.length];
|
||||
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
|
||||
Map<Integer, String[]> map = new HashMap<>();
|
||||
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
|
||||
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
|
||||
map.put(enLabelName.length - 3, inHouse);
|
||||
map.put(enLabelName.length - 2, eas);
|
||||
|
||||
for (int i = 0; i < enLabelName.length; i++) {
|
||||
if (map.containsKey(i)) {
|
||||
jComponents[i] = new JComboBox<>(map.get(i));
|
||||
} else {
|
||||
jComponents[i] = new JTextField(14);
|
||||
}
|
||||
jLabels[i] = new JLabel(enLabelName[i]);
|
||||
}
|
||||
System.out.println("In house :" + inHouse);
|
||||
for (String inhouse : inHouse) {
|
||||
if (inhouse.equals("In-House Production")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
|
||||
}
|
||||
}
|
||||
for (String ea : eas) {
|
||||
if (ea.equals("EA")) {
|
||||
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
|
||||
}
|
||||
}
|
||||
|
||||
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create semi-finished products",
|
||||
"semiFinishedProducts", jLabels, jComponents, prop, lovMap);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,115 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import com.connor.ferrorTech.metal.exception.CustomException;
|
||||
import com.connor.ferrorTech.metal.util.TcUtil;
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
||||
import com.teamcenter.rac.kernel.DeepCopyInfo;
|
||||
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.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCException;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
import com.teamcenter.rac.util.MessageBox;
|
||||
|
||||
public class ClassificationProcessesOperation extends AbstractAIFOperation {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
private String[][] tableData;
|
||||
|
||||
public ClassificationProcessesOperation(AbstractAIFApplication application,String[][] tableData) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.tableData = tableData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
TCComponentBOMLine targetBomLine = judgeSingleSelectRevision(application, new String[]{"VF5gyRevision"});
|
||||
if(targetBomLine!=null) {
|
||||
copyItem(targetBomLine,tableData);
|
||||
}else {
|
||||
MessageBox.post("获取目标BOM失败!", "Error", MessageBox.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public void copyItem(TCComponentBOMLine targetBomLine,String[][] data) throws TCException {
|
||||
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
|
||||
TCComponentBOMWindow view = winType.create(null);
|
||||
|
||||
// String[] formProp = new String[] {
|
||||
// "vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
|
||||
// };
|
||||
// String[] bomProp = new String[] {
|
||||
// "VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
|
||||
// };
|
||||
view.lock();
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
String[] rowData = data[i];
|
||||
String uid = rowData[rowData.length-1];
|
||||
TCComponent gxComponent = this.tcSession.stringToComponent(uid);
|
||||
if(gxComponent instanceof TCComponentItemRevision) {
|
||||
TCComponentItemRevision gxItemRev = (TCComponentItemRevision)gxComponent;
|
||||
String name = gxItemRev.getStringProperty("object_name");
|
||||
TCComponentItemType typeComponent = (TCComponentItemType) this.tcSession
|
||||
.getTypeComponent(gxItemRev.getItem().getStringProperty("object_type"));
|
||||
TCComponentItem newItem = gxItemRev.saveAsItem(typeComponent.getNewID(), "", name, "", true,(DeepCopyInfo[]) null);
|
||||
|
||||
TCComponentBOMLine newBomLine = targetBomLine.add(newItem,newItem.getLatestItemRevision(),null,false,"");
|
||||
|
||||
// TCComponent gxRevForm = gxItemRev.getRelatedComponent("IMAN_master_form_rev");
|
||||
// for (int j = 0; j < bomProp.length; j++) {
|
||||
// String prop = gxRevForm.getStringProperty(formProp[j]);
|
||||
// System.out.println(bomProp[j] + " : " + prop);
|
||||
// newBomLine.setProperty(bomProp[j], prop);
|
||||
// }
|
||||
flag =true;
|
||||
}
|
||||
}
|
||||
if(flag) {
|
||||
MessageBox.post("添加成功!", "Info", MessageBox.INFORMATION);
|
||||
}else {
|
||||
MessageBox.post("添加失败!", "Rrror", MessageBox.ERROR);
|
||||
}
|
||||
view.save();
|
||||
view.unlock();
|
||||
}
|
||||
|
||||
public TCComponentBOMLine judgeSingleSelectRevision(AbstractAIFApplication application,
|
||||
String[] revType) {
|
||||
InterfaceAIFComponent targetComponent = application.getTargetComponent();
|
||||
try {
|
||||
TCComponentItemRevision tempComponentRev = null;
|
||||
if (targetComponent instanceof TCComponentBOMLine) {
|
||||
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
|
||||
}else if(targetComponent instanceof TCComponentItemRevision) {
|
||||
tempComponentRev = (TCComponentItemRevision) targetComponent;
|
||||
}else {
|
||||
throw new CustomException("请选择正确的版本!");
|
||||
}
|
||||
|
||||
if (tempComponentRev != null && revType != null && revType.length > 0) {
|
||||
for (int i = 0; i < revType.length; i++) {
|
||||
if (tempComponentRev.getType().equals(revType[i])) {
|
||||
return (TCComponentBOMLine)targetComponent;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("tempComponentRev or revType is null !");
|
||||
}
|
||||
} catch (TCException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.processManagement.createProcesses;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.AbstractAIFOperation;
|
||||
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.TCComponentForm;
|
||||
import com.teamcenter.rac.kernel.TCComponentItem;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
||||
import com.teamcenter.rac.kernel.TCComponentItemType;
|
||||
import com.teamcenter.rac.kernel.TCComponentType;
|
||||
import com.teamcenter.rac.kernel.TCSession;
|
||||
|
||||
public class CreateProcessesOperation extends AbstractAIFOperation {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
private TCSession tcSession;
|
||||
|
||||
private Map<String, String> propMap;
|
||||
|
||||
public CreateProcessesOperation(AbstractAIFApplication application, Map<String, String> propMap) {
|
||||
this.application = application;
|
||||
this.tcSession = (TCSession) application.getSession();
|
||||
this.propMap = propMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOperation() throws Exception {
|
||||
TCComponentItemType typeComponent = (TCComponentItemType) tcSession.getTypeComponent("VF5gx");
|
||||
TCComponentItem item = typeComponent.create(typeComponent.getNewID(), "", "VF5gx", propMap.get("object_name"),
|
||||
"", null);
|
||||
TCComponentItemRevision itemRevision = item.getLatestItemRevision();
|
||||
TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev");
|
||||
System.out.println("item uid : " + item.getUid());
|
||||
|
||||
TCComponentBOMLine targetBomLine = (TCComponentBOMLine) this.application.getTargetComponent();
|
||||
TCComponentBOMLine bomLine = targetBomLine.add(item, itemRevision, null, false, "");
|
||||
|
||||
Set<String> keySet = propMap.keySet();
|
||||
for (String key : keySet) {
|
||||
System.out.println("µ±Ç°ÊôÐÔÖµ=> key:"+key + " || value: "+propMap.get(key));
|
||||
if (key.equals("object_name")) {
|
||||
continue;
|
||||
}
|
||||
form.setStringProperty(key, propMap.get(key));
|
||||
|
||||
if (key.equals("vf5gxlx") || key.equals("vf5gzzxsj")) {
|
||||
continue;
|
||||
}
|
||||
bomLine.setProperty(capitalizeFirstTwo(key), propMap.get(key));
|
||||
}
|
||||
targetBomLine.save();
|
||||
}
|
||||
|
||||
public String capitalizeFirstTwo(String input) {
|
||||
if (input == null || input.length() < 2) {
|
||||
return input == null ? "" : input.toUpperCase();
|
||||
}
|
||||
return input.substring(0, 2).toUpperCase() + input.substring(2);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||
|
||||
public class CreateClientFileAction extends AbstractAIFAction {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
public CreateClientFileAction(AbstractAIFApplication application, Frame frame, String param) {
|
||||
super(application, frame, param);
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
CreateClientFileDialog dialog = new CreateClientFileDialog(this.application);
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateClientFileHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateClientFileAction action = new CreateClientFileAction(application, null, null);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
customerProfilesDialog.0=Create Customer Profiles
|
||||
customerProfilesDialog.1=Customer name
|
||||
customerProfilesDialog.2=Customer abbreviation
|
||||
customerProfilesDialog.3=Contact person
|
||||
customerProfilesDialog.4=Telephone number
|
||||
customerProfilesDialog.5=Account manager
|
||||
customerProfilesDialog.6=Customer industry
|
||||
customerProfilesDialog.7=Business unit/company
|
||||
customerProfilesDialog.8=Type
|
||||
customerProfilesDialog.9=Status
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateQuotationDrawingsHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateQuotationDrawingsAction action = new CreateQuotationDrawingsAction(application, null, null);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
|
||||
|
||||
import java.awt.Frame;
|
||||
|
||||
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
||||
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
|
||||
|
||||
public class CreateQuotationProjectAction extends AbstractAIFAction {
|
||||
|
||||
private AbstractAIFApplication application;
|
||||
public CreateQuotationProjectAction(AbstractAIFApplication application, Frame frame, String param) {
|
||||
super(application, frame, param);
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
CreateQuotationProjectDialog dialog = new CreateQuotationProjectDialog(this.application);
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateQuotationProjectHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateQuotationProjectAction action = new CreateQuotationProjectAction(application, null, null);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
quotationProjectsDialog.0=Create Quotation Projects
|
||||
quotationProjectsDialog.1=Project name
|
||||
quotationProjectsDialog.2=Quotation drawing number
|
||||
quotationProjectsDialog.3=Annual demand
|
||||
quotationProjectsDialog.4=Target price
|
||||
quotationProjectsDialog.5=Customer expects quotation completion date
|
||||
quotationProjectsDialog.6=Customer name
|
||||
quotationProjectsDialog.7=Whether surveying product
|
||||
quotationProjectsDialog.8=Salesperson
|
||||
quotationProjectsDialog.9=Emergency status
|
||||
quotationProjectsDialog.10=Technical requirements
|
||||
quotationProjectsDialog.11=Remarks
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateTechnicalHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
|
||||
CreateTechnicalDialog createTechnicalDialog = new CreateTechnicalDialog(application);
|
||||
new Thread(createTechnicalDialog).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class CreateExternalQuotationHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
CreateExternalQuotationDialog action = new CreateExternalQuotationDialog(application);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings;
|
||||
|
||||
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.aifrcp.AIFUtility;
|
||||
|
||||
public class UploadHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
|
||||
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
|
||||
UploadDialog action = new UploadDialog(application);
|
||||
|
||||
new Thread(action).start();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue