|
|
|
@ -1,145 +1,189 @@
|
|
|
|
|
package com.connor.jd.plm.dialogs;
|
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.swing.Box;
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
import javax.swing.JComboBox;
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
|
|
|
|
|
|
|
|
import com.connor.jd.operations.ExcelOperation;
|
|
|
|
|
import com.connor.jd.plm.utils.JDMethodUtil;
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFApplication;
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFDialog;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentDataset;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentProjectSmartFolder;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentTcFile;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
import com.teamcenter.rac.util.ButtonLayout;
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
|
|
public class QTXJCDialog extends AbstractAIFDialog {
|
|
|
|
|
import javafx.application.Application;
|
|
|
|
|
import javafx.scene.Scene;
|
|
|
|
|
import javafx.scene.control.Button;
|
|
|
|
|
import javafx.scene.control.ComboBox;
|
|
|
|
|
import javafx.scene.control.Label;
|
|
|
|
|
import javafx.scene.control.TextField;
|
|
|
|
|
import javafx.scene.layout.Pane;
|
|
|
|
|
import javafx.stage.FileChooser;
|
|
|
|
|
import javafx.stage.FileChooser.ExtensionFilter;
|
|
|
|
|
import javafx.stage.Stage;
|
|
|
|
|
|
|
|
|
|
public class QTXJCDialog extends Application {
|
|
|
|
|
|
|
|
|
|
private AbstractAIFApplication app;
|
|
|
|
|
private TCSession session;
|
|
|
|
|
private JLabel road = new JLabel();
|
|
|
|
|
private JComboBox<String> pjsName = new JComboBox<String>();
|
|
|
|
|
private TextField road = null;
|
|
|
|
|
private ComboBox<String> pjsName = null;
|
|
|
|
|
private List<String> sfList = new ArrayList<String>();
|
|
|
|
|
private TCComponent[] com;
|
|
|
|
|
private String type;
|
|
|
|
|
|
|
|
|
|
public QTXJCDialog(AbstractAIFApplication app, List<String> sfList, TCComponent[] com, TCSession session,
|
|
|
|
|
String type) throws TCException {
|
|
|
|
|
this.app = app;
|
|
|
|
|
public QTXJCDialog(List<String> sfList, TCComponent[] com, TCSession session, String type) throws TCException {
|
|
|
|
|
|
|
|
|
|
this.sfList = sfList;
|
|
|
|
|
this.com = com;
|
|
|
|
|
this.session = session;
|
|
|
|
|
this.type = type;
|
|
|
|
|
initUI();
|
|
|
|
|
// initUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initUI() {
|
|
|
|
|
this.setAutoRequestFocus(true);
|
|
|
|
|
this.setPreferredSize(new Dimension(360, 150));
|
|
|
|
|
this.setResizable(false);
|
|
|
|
|
|
|
|
|
|
JLabel pjStage = new JLabel("项目阶段");
|
|
|
|
|
pjsName.addItem("");
|
|
|
|
|
@Override
|
|
|
|
|
public void start(Stage arg0) throws Exception {
|
|
|
|
|
Stage primaryStage = new Stage();
|
|
|
|
|
Pane root = new Pane();
|
|
|
|
|
Label pjStage = new Label("项目阶段");
|
|
|
|
|
pjStage.setLayoutX(37.0);
|
|
|
|
|
pjStage.setLayoutY(51.0);
|
|
|
|
|
pjsName = new ComboBox<String>();
|
|
|
|
|
pjsName.setLayoutX(89.0);
|
|
|
|
|
pjsName.setLayoutY(47.0);
|
|
|
|
|
pjsName.setPrefSize(161.0, 23.0);
|
|
|
|
|
pjsName.setValue("");
|
|
|
|
|
pjsName.getItems().add("");
|
|
|
|
|
for (int i = 0; i < sfList.size(); i++) {
|
|
|
|
|
pjsName.addItem(sfList.get(i));
|
|
|
|
|
pjsName.getItems().add(sfList.get(i));
|
|
|
|
|
}
|
|
|
|
|
JLabel roadLabel = new JLabel("路径");
|
|
|
|
|
|
|
|
|
|
JButton open = new JButton("...");
|
|
|
|
|
open.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
openBtn();
|
|
|
|
|
}
|
|
|
|
|
Label roadLabel = new Label("路径");
|
|
|
|
|
roadLabel.setLayoutX(37.0);
|
|
|
|
|
roadLabel.setLayoutY(107.0);
|
|
|
|
|
road = new TextField();
|
|
|
|
|
road.setLayoutX(89.0);
|
|
|
|
|
road.setLayoutY(103.0);
|
|
|
|
|
road.setDisable(true);
|
|
|
|
|
Button open = new Button("选择");
|
|
|
|
|
open.setLayoutX(263.0);
|
|
|
|
|
open.setLayoutY(103.0);
|
|
|
|
|
open.setOnAction((arg) -> {
|
|
|
|
|
openBtn(primaryStage);
|
|
|
|
|
});
|
|
|
|
|
JButton export = new JButton("导出");
|
|
|
|
|
export.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
exportBtn();
|
|
|
|
|
}
|
|
|
|
|
Button export = new Button("导出");
|
|
|
|
|
export.setLayoutX(89.0);
|
|
|
|
|
export.setLayoutY(158.0);
|
|
|
|
|
export.setPrefSize(48.0, 23.0);
|
|
|
|
|
export.setOnAction((arg) -> {
|
|
|
|
|
exportBtn();
|
|
|
|
|
});
|
|
|
|
|
JButton out = new JButton("取消");
|
|
|
|
|
out.addActionListener(new ActionListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
dispose();
|
|
|
|
|
}
|
|
|
|
|
Button out = new Button("取消");
|
|
|
|
|
out.setLayoutX(208.0);
|
|
|
|
|
out.setLayoutY(158.0);
|
|
|
|
|
out.setPrefSize(48.0, 23.0);
|
|
|
|
|
out.setOnAction((arg) -> {
|
|
|
|
|
primaryStage.close();
|
|
|
|
|
});
|
|
|
|
|
JPanel flow1 = new JPanel();
|
|
|
|
|
Box b1 = Box.createHorizontalBox();
|
|
|
|
|
flow1.add(b1);
|
|
|
|
|
// b1.add(Box.createHorizontalStrut(20));
|
|
|
|
|
b1.add(pjStage);
|
|
|
|
|
b1.add(Box.createHorizontalStrut(50));
|
|
|
|
|
b1.add(pjsName);
|
|
|
|
|
JPanel flow2 = new JPanel();
|
|
|
|
|
Box b2 = Box.createHorizontalBox();
|
|
|
|
|
flow2.add(b2);
|
|
|
|
|
b2.add(Box.createHorizontalStrut(20));
|
|
|
|
|
b2.add(roadLabel);
|
|
|
|
|
b2.add(Box.createHorizontalStrut(20));
|
|
|
|
|
b2.add(road);
|
|
|
|
|
b2.add(Box.createHorizontalStrut(80));
|
|
|
|
|
b2.add(open);
|
|
|
|
|
JPanel btn = new JPanel(new ButtonLayout());
|
|
|
|
|
btn.add(export);
|
|
|
|
|
btn.add(out);
|
|
|
|
|
JPanel center = new JPanel(new BorderLayout());
|
|
|
|
|
center.add(flow1, BorderLayout.NORTH);
|
|
|
|
|
center.add(flow2, BorderLayout.CENTER);
|
|
|
|
|
center.add(btn, BorderLayout.SOUTH);
|
|
|
|
|
this.add(center, "Center");
|
|
|
|
|
root.getChildren().add(pjStage);
|
|
|
|
|
root.getChildren().add(pjsName);
|
|
|
|
|
root.getChildren().add(roadLabel);
|
|
|
|
|
root.getChildren().add(road);
|
|
|
|
|
root.getChildren().add(open);
|
|
|
|
|
root.getChildren().add(export);
|
|
|
|
|
root.getChildren().add(out);
|
|
|
|
|
|
|
|
|
|
this.pack();
|
|
|
|
|
this.centerToScreen();
|
|
|
|
|
this.showDialog();
|
|
|
|
|
Scene scene = new Scene(root, 338.0, 207);
|
|
|
|
|
primaryStage.setScene(scene);
|
|
|
|
|
primaryStage.setResizable(false);
|
|
|
|
|
primaryStage.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private void initUI() {
|
|
|
|
|
// this.setAutoRequestFocus(true);
|
|
|
|
|
// this.setPreferredSize(new Dimension(360, 150));
|
|
|
|
|
// this.setResizable(false);
|
|
|
|
|
//
|
|
|
|
|
// JLabel pjStage = new JLabel("项目阶段");
|
|
|
|
|
// pjsName.addItem("");
|
|
|
|
|
// for (int i = 0; i < sfList.size(); i++) {
|
|
|
|
|
// pjsName.addItem(sfList.get(i));
|
|
|
|
|
// }
|
|
|
|
|
// JLabel roadLabel = new JLabel("路径");
|
|
|
|
|
//
|
|
|
|
|
// JButton open = new JButton("...");
|
|
|
|
|
// open.addActionListener(new ActionListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// openBtn();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// JButton export = new JButton("导出");
|
|
|
|
|
// export.addActionListener(new ActionListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// exportBtn();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// JButton out = new JButton("取消");
|
|
|
|
|
// out.addActionListener(new ActionListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void actionPerformed(ActionEvent e) {
|
|
|
|
|
// dispose();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// JPanel flow1 = new JPanel();
|
|
|
|
|
// Box b1 = Box.createHorizontalBox();
|
|
|
|
|
// flow1.add(b1);
|
|
|
|
|
// // b1.add(Box.createHorizontalStrut(20));
|
|
|
|
|
// b1.add(pjStage);
|
|
|
|
|
// b1.add(Box.createHorizontalStrut(50));
|
|
|
|
|
// b1.add(pjsName);
|
|
|
|
|
// JPanel flow2 = new JPanel();
|
|
|
|
|
// Box b2 = Box.createHorizontalBox();
|
|
|
|
|
// flow2.add(b2);
|
|
|
|
|
// b2.add(Box.createHorizontalStrut(20));
|
|
|
|
|
// b2.add(roadLabel);
|
|
|
|
|
// b2.add(Box.createHorizontalStrut(20));
|
|
|
|
|
// b2.add(road);
|
|
|
|
|
// b2.add(Box.createHorizontalStrut(80));
|
|
|
|
|
// b2.add(open);
|
|
|
|
|
// JPanel btn = new JPanel(new ButtonLayout());
|
|
|
|
|
// btn.add(export);
|
|
|
|
|
// btn.add(out);
|
|
|
|
|
// JPanel center = new JPanel(new BorderLayout());
|
|
|
|
|
// center.add(flow1, BorderLayout.NORTH);
|
|
|
|
|
// center.add(flow2, BorderLayout.CENTER);
|
|
|
|
|
// center.add(btn, BorderLayout.SOUTH);
|
|
|
|
|
// this.add(center, "Center");
|
|
|
|
|
//
|
|
|
|
|
// this.pack();
|
|
|
|
|
// this.centerToScreen();
|
|
|
|
|
// this.showDialog();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
String roadName = null;
|
|
|
|
|
|
|
|
|
|
private void openBtn() {
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
// chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
|
|
|
chooser.setDialogTitle("请选择要保存的文件夹");
|
|
|
|
|
// chooser.showDialog(new JLabel(), "确定");
|
|
|
|
|
|
|
|
|
|
FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel工作簿(*.xlsx)", "xlsx");
|
|
|
|
|
chooser.setFileFilter(filter);
|
|
|
|
|
chooser.showSaveDialog(null);
|
|
|
|
|
// File file = chooser.getSelectedFile();
|
|
|
|
|
private void openBtn(Stage primaryStage) {
|
|
|
|
|
FileChooser chooser = new FileChooser();
|
|
|
|
|
chooser.setTitle("请选择要保存的文件夹");
|
|
|
|
|
chooser.getExtensionFilters().addAll(new ExtensionFilter("Excel工作簿(*.xlsx)", "xlsx"));
|
|
|
|
|
File getfile = chooser.showSaveDialog(primaryStage);
|
|
|
|
|
try {
|
|
|
|
|
if (chooser.getSelectedFile().getAbsolutePath() != null) {
|
|
|
|
|
String filePath = chooser.getSelectedFile().getAbsolutePath() + ".xlsx";
|
|
|
|
|
if (getfile.getAbsolutePath() != null) {
|
|
|
|
|
String filePath = getfile.getAbsolutePath() + ".xlsx";
|
|
|
|
|
roadName = filePath;
|
|
|
|
|
if (filePath.length() > 10) {
|
|
|
|
|
road.setText(filePath.substring(0, 10) + "...");
|
|
|
|
|
if (filePath.length() > 25) {
|
|
|
|
|
road.setText(filePath.substring(0, 25) + "...");
|
|
|
|
|
} else {
|
|
|
|
|
road.setText(filePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exportBtn() {
|
|
|
|
@ -153,7 +197,7 @@ public class QTXJCDialog extends AbstractAIFDialog {
|
|
|
|
|
System.out.println(outpath);
|
|
|
|
|
|
|
|
|
|
File file = getExcle(jdname, type);
|
|
|
|
|
String sel = (String) pjsName.getSelectedItem();
|
|
|
|
|
String sel = pjsName.getSelectionModel().getSelectedItem();
|
|
|
|
|
Map<String, List<TCComponent>> jfw = new HashMap<String, List<TCComponent>>();
|
|
|
|
|
if (sel.equals("")) {
|
|
|
|
|
for (int i = 0; i < sfList.size(); i++) {
|
|
|
|
@ -192,7 +236,7 @@ public class QTXJCDialog extends AbstractAIFDialog {
|
|
|
|
|
ExcelOperation.writeExcel(file, outpath, jfw);
|
|
|
|
|
System.out.println("µ¼³ö³É¹¦");
|
|
|
|
|
MessageBox.post("µ¼³ö³É¹¦", "ÐÅÏ¢", MessageBox.INFORMATION);
|
|
|
|
|
dispose();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -200,6 +244,10 @@ public class QTXJCDialog extends AbstractAIFDialog {
|
|
|
|
|
File fmsFile = null;
|
|
|
|
|
String allpuid = JDMethodUtil.getPrefStr(ssx, session);
|
|
|
|
|
String[] relpuid = allpuid.split(";");
|
|
|
|
|
if (relpuid.length != 3) {
|
|
|
|
|
MessageBox.post("请联系管理员检查首选项", "错误", MessageBox.ERROR);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
String puid = null;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "GT":
|
|
|
|
@ -241,45 +289,5 @@ public class QTXJCDialog extends AbstractAIFDialog {
|
|
|
|
|
}
|
|
|
|
|
return fmsFile;
|
|
|
|
|
}
|
|
|
|
|
// @Override
|
|
|
|
|
// public void start(Stage arg0) throws Exception {
|
|
|
|
|
// Stage primaryStage = new Stage();
|
|
|
|
|
// Pane root = new Pane();
|
|
|
|
|
// Label pjStage = new Label("项目阶段");
|
|
|
|
|
// pjStage.setLayoutX(37.0);
|
|
|
|
|
// pjStage.setLayoutY(51.0);
|
|
|
|
|
// ComboBox pjsName = new ComboBox();
|
|
|
|
|
// pjsName.setLayoutX(94.0);
|
|
|
|
|
// pjsName.setLayoutY(47.0);
|
|
|
|
|
// pjsName.setValue("");
|
|
|
|
|
// Label roadLabel = new Label("路径");
|
|
|
|
|
// roadLabel.setLayoutX(37.0);
|
|
|
|
|
// roadLabel.setLayoutY(107.0);
|
|
|
|
|
// Label road = new Label();
|
|
|
|
|
// road.setLayoutX(94.0);
|
|
|
|
|
// road.setLayoutY(107.0);
|
|
|
|
|
// Button open = new Button("...");
|
|
|
|
|
// open.setLayoutX(190.0);
|
|
|
|
|
// open.setLayoutY(103.0);
|
|
|
|
|
// Button export = new Button("导出");
|
|
|
|
|
// export.setLayoutX(67.0);
|
|
|
|
|
// export.setLayoutY(158.0);
|
|
|
|
|
// Button out = new Button("取消");
|
|
|
|
|
// out.setLayoutX(169.0);
|
|
|
|
|
// out.setLayoutY(158.0);
|
|
|
|
|
//
|
|
|
|
|
// root.getChildren().add(pjStage);
|
|
|
|
|
// root.getChildren().add(pjsName);
|
|
|
|
|
// root.getChildren().add(roadLabel);
|
|
|
|
|
// root.getChildren().add(road);
|
|
|
|
|
// root.getChildren().add(open);
|
|
|
|
|
// root.getChildren().add(export);
|
|
|
|
|
// root.getChildren().add(out);
|
|
|
|
|
//
|
|
|
|
|
// Scene scene = new Scene(root, 290, 207);
|
|
|
|
|
// primaryStage.setScene(scene);
|
|
|
|
|
// primaryStage.setResizable(false);
|
|
|
|
|
// primaryStage.show();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|