📄 framemain.java
字号:
this.jButton7.setEnabled(false);
this.jButton8.setEnabled(true);
}
if (!(jButton8.isEnabled())) {
this.jButton8.setEnabled(true);
}
this.jTree1.setSelectedTreeItem(false, waypointPos);
}
void jButton1_actionPerformed(ActionEvent e) {
this.protectOnlyReadGPSWaypoint();
}
private void getWaypoint() {
DownloadData cctd = new DownloadData(this, true);
cctd.start();
}
public void saveEnter(CaretEvent e) {
if (e.getSource().equals(this.jTextField1)) {
String name = jTextField1.getText();
ItemValue iv = new ItemValue();
if (iv.getPosition("track") == null) {
return;
}
int[] pos = iv.getPosition("track");
if (pos.length == 0) {
return;
}
Node node = iv.getTracks(pos[tracksPos]);
ItemValue.setTracksName(node, name);
}
}
public void catchReadException(Exception e) {
this.readFile.setDpHide();
this.readFile = null;
JOptionPane.showMessageDialog(this,
"文件不能打开,其原因可能是:\n1.文件格式不对.\n2.打开了错误的文件.\n具体错误如下:\n"
+ e.getMessage(), "打开文件错误", JOptionPane.ERROR_MESSAGE);
this.reset();
}
void jButton3_actionPerformed(ActionEvent e) {
String name = jTextField1.getText();
String number = jTextField2.getText();
String grade = jComboBox1.getSelectedItem().toString();
String type = jComboBox2.getSelectedItem().toString();
String width = jTextField3.getText();
String structure = jTextArea1.getText();
String status = jTextArea2.getText();
String t1 = jTextField4.getText();
String t2 = jTextField5.getText();
String t3 = jTextField13.getText();
String t4 = jTextField14.getText();
String t5 = jCB_Jishu.getSelectedItem() + "";
// String t6 = jTextField16.getText();
// String t7 = jTextField17.getText();
String t6 = "";
if (df1.getDate() != null) {
t6 = df1.getDate().toString();
}
String t7 = "";
if (df2.getDate() != null) {
t7 = df2.getDate().toString();
}
String yanghu = this.jP_Yanghu.getText();
String luji = this.jTF_Luji.getText();
String gaijian = "";
if (df3.getDate() != null) {
gaijian = df3.getDate().toString();
}
if (ItemValue.getPosition("track") == null) {
return;
}
int[] pos = ItemValue.getPosition("track");
if (pos.length == 0) {
return;
}
Node node = ItemValue.getTracks(pos[tracksPos]);
ItemValue.setTracksName(node, name);
ItemValue.setTracksNumber(node, number);
ItemValue.setTracksGrade(node, grade);
ItemValue.setTracksType(node, type);
ItemValue.setTracksWidth(node, width);
ItemValue.setTracksStructure(node, structure);
ItemValue.setTracksStatus(node, status);
ItemValue.setTracksT1(node, t1);
ItemValue.setTracksT2(node, t2);
ItemValue.setTracksT3(node, t3);
ItemValue.setTracksT4(node, t4);
ItemValue.setTracksT5(node, t5);
ItemValue.setTracksT6(node, t6);
ItemValue.setTracksT7(node, t7);
ItemValue.setTracks_construct(node, this.constructSelect.getText());
ItemValue.setTracks_jiaotongbu(node, yanghu, luji, gaijian);
dataSave = false;
this.memoryShow(true, false);
}
public void jButton10_actionPerformed(ActionEvent e) {
this.dataSave = this.directSaveFile(this);
}
public boolean directSaveFile(JFrame jf) {
File f = new File(ItemValue.fileChoosePath);
ItemValue.fileSavePath = f.getAbsolutePath();
CreateFile cf = new CreateFile(f);
Document d1 = GarminGMLDoc.d;
Element root1 = GarminGMLDoc.root;
// ItemValue.getRidOfTracksAndWaypointIDNew();
// cf.memoryToFile(GarminGMLDoc.printDoc());
if (ItemValue.encrypt == true) {
try {
cf.memoryToFile(Encryption.encryptFromString(GarminGMLDoc
.printDoc(), Encryption.key));
} catch (Exception ex) {
}
} else {
try {
cf.memoryToFile(GarminGMLDoc.printDoc());
} catch (Exception ex1) {
System.err.println(ex1.getMessage() + " --Class FrameMain");
}
}
GarminGMLDoc.d = d1;
GarminGMLDoc.root = root1;
JOptionPane.showMessageDialog(jf, "gps File Saved OK!",
"GPS Information", JOptionPane.INFORMATION_MESSAGE);
return true;
}
public static boolean SaveFile(JFrame jf) {
boolean haveOK = false;
JFileChooser fileDialog = new JFileChooser();
if (!(ItemValue.fileSavePath.equals(""))) {
fileDialog.setCurrentDirectory(new File(ItemValue.fileSavePath));
}
fileDialog.setSelectedFile(new File(ItemValue.fileName));
int result = fileDialog.showSaveDialog(jf);
File f = fileDialog.getSelectedFile();
if (result == JFileChooser.APPROVE_OPTION) {
if ((!f.canWrite()) && (f.exists())) {
int i = JOptionPane.showConfirmDialog(jf,
"文件属性为只读或者正在使用!\r\n是否要重新保存?", "GPS Information",
JOptionPane.OK_CANCEL_OPTION);
if (i == 0) {
return SaveFile(jf);
}
} else {
ItemValue.fileSavePath = f.getAbsolutePath();
CreateFile cf = new CreateFile(f);
Document d1 = GarminGMLDoc.d;
Element root1 = GarminGMLDoc.root;
// ItemValue.getRidOfTracksAndWaypointIDNew();
// cf.memoryToFile(GarminGMLDoc.printDoc());
if (ItemValue.encrypt == true) {
try {
cf.memoryToFile(Encryption.encryptFromString(
GarminGMLDoc.printDoc(), Encryption.key));
} catch (Exception ex) {
}
} else {
try {
cf.memoryToFile(GarminGMLDoc.printDoc());
} catch (Exception ex1) {
System.err.println(ex1.getMessage()
+ " --Class FrameMain");
}
}
GarminGMLDoc.d = d1;
GarminGMLDoc.root = root1;
haveOK = true;
JOptionPane.showMessageDialog(jf, "gps File Saved OK!",
"GPS Information", JOptionPane.INFORMATION_MESSAGE);
}
}
return haveOK;
}
void jCheckBox1_itemStateChanged(ItemEvent e) {
setJihuaButton();
}
private CLFrame clf = null;
JButton jButtonWaypointDeleteAll = new JButton();
ConstructSelect constructSelect = new ConstructSelect(this);
JButton jButton_jihua = new JButton();
JLabel jLabel28 = new JLabel();
JLabel jLabel_licheng = new JLabel();
// CunPanal cunpanel = new CunPanal(this);
JButton jB_showXZC = new JButton();
JLabel jLabel29 = new JLabel();
JLabel jLabel30 = new JLabel();
YanghuPanal jP_Yanghu = new YanghuPanal();
NumberTextField jTF_Luji = new NumberTextField();
JLabel jLabel31 = new JLabel();
JLabel jLabel32 = new JLabel();
JMenuItem jMenuItem12 = new JMenuItem();
JMenu jMenu5 = new JMenu();
JMenuItem jMenuItem13 = new JMenuItem();
JMenuItem jMenuItem14 = new JMenuItem();
// JishuPanal jPanel_Jishu = new JishuPanal();
void setCLFrame(CLFrame clf) {
this.clf = clf;
}
void jButton9_actionPerformed(ActionEvent e) {
String name = jTextField7.getText();
String X = jTextField8.getText();
String Y = jTextField9.getText();
String Z = jTextField10.getText();
String Time = jTextField11.getText();
String RS = jComboBox3.getSelectedItem() + "";
String RWa = jTextField6.getText();
String RWb = jTextField12.getText();
String KP = jComboBox5.getSelectedItem() + "";
if (ItemValue.getPosition("waypoint") == null) {
return;
}
int[] pos = ItemValue.getPosition("waypoint");
if (pos.length == 0) {
return;
}
Node node = ItemValue.getTracks(pos[waypointPos]);
ItemValue.setWaypointName(node, name);
// ItemValue.setWaypointX(node,X);//因为横纵高坐标不需要编辑
// ItemValue.setWaypointY(node,Y);
// ItemValue.setWaypointZ(node,Z);
ItemValue.setWaypointTime(node, Time);
ItemValue.setWaypointRS(node, RS);
ItemValue.setWaypointRWa(node, RWa);
ItemValue.setWaypointRWb(node, RWb);
ItemValue.setWaypointKP(node, KP);
if (KP.equals(WptType.W1XingZhengCun)) {
this.jtb_qiaoliang = null;
this.jtb_suidao = null;
this.jtb_dukou = null;
} else if (KP.equals(WptType.W3QiaoLiang)) {
this.jtb_xzc = null;
this.jtb_suidao = null;
this.jtb_dukou = null;
} else if (KP.equals(WptType.W4SuiDao)) {
this.jtb_xzc = null;
this.jtb_qiaoliang = null;
this.jtb_dukou = null;
} else if (KP.equals(WptType.W6DuKou)) {
this.jtb_xzc = null;
this.jtb_qiaoliang = null;
this.jtb_suidao = null;
}
ItemValue.setWaypointXZC(node, this.jtb_xzc);
ItemValue.setWaypointQiaoliang(node, this.jtb_qiaoliang);
ItemValue.setWaypointSuidao(node, this.jtb_suidao);
ItemValue.setWaypointDukou(node, this.jtb_dukou);
// ItemValue.setWaypoint_xzc(node,this.cunpanel.get_xzc());
// ItemValue.setWaypoint_renkou(node,this.cunpanel.get_renkou());
// ItemValue.setWaypoint_shouru(node,this.cunpanel.get_shouru());
// ItemValue.setWaypoint_jingji(node,this.cunpanel.get_jingji());
dataSave = false;
int temp_pos = this.waypointPos;
this.memoryShow(false, true);
this.isInit = true;
this.setWaypoint(temp_pos);
this.jTree1.setSelectedTreeItem(false, waypointPos);
// this.memoryShow();
// this.jTree1.tree.expandRow(2);
if (this.clf != null) {
clf.jPanelCut.resetWaypointCombobox();
clf.jPanelCut.init();
clf.jPanelCut.jComboBox_itemStateChanged(null);
}
}
void jCheckBox2_itemStateChanged(ItemEvent e) {
setJihuaButton();
System.out.println("setJihuaButton();");
}
void setButton1_2Enabled(boolean Enable) {
this.jButton1.setEnabled(Enable);
this.jButton2.setEnabled(Enable);
}
void jButton2_actionPerformed(ActionEvent e) {
this.protectOnlyReadGPSTracks();
}
private void getTracks() {
DownloadData cctd = new DownloadData(this, false);
cctd.start();
}
private void protectOnlyReadGPSTracks() {
if (ItemValue.tracksNum == 0) {
this.getTracks();
} else {
// 弹出选择窗口
int i = JOptionPane.showConfirmDialog(this,
"是否附加在该文件之后?\n建议不要附加,以保存数据的独立性", "询问是否附加",
JOptionPane.YES_NO_OPTION);
// 如果选择附加,直接打开文件
if (i == 0) {
this.getTracks();
} else {
// 如果选择不附加,本次操作取消,如果要要重新读取,请重新开始之后,再读取数据。
JOptionPane.showMessageDialog(this,
"本次操作取消.\n如果要要重新读取,请\"重新开始\"之后,再读取数据。", "本次操作取消",
JOptionPane.OK_OPTION);
}
}
}
private void protectOnlyReadGPSWaypoint() {
if (ItemValue.waypointNum == 0) {
this.getWaypoint();
} else {
// 弹出选择窗口
int i = JOptionPane.showConfirmDialog(this,
"是否附加在该文件之后?\n建议不要附加,以保存数据的独立性", "询问是否附加",
JOptionPane.YES_NO_OPTION);
// 如果选择附加,直接打开文件
if (i == 0) {
this.getWaypoint();
} else {
// 如果选择不附加,本次操作取消,如果要要重新读取,请重新开始之后,再读取数据。
JOptionPane.showMessageDialog(this,
"本次操作取消.\n如果要要重新读取,请\"重新开始\"之后,再读取数据。", "本次操作取消",
JOptionPane.OK_OPTION);
}
}
}
void jMenuItem6_actionPerformed(ActionEvent e) {
DownloadData cctd = new DownloadData(this, false);
cctd.start();
}
void jMenuItem5_actionPerformed(ActionEvent e) {
DownloadData cctd = new DownloadData(this, true);
cctd.start();
}
void jMenuItem4_actionPerformed(ActionEvent e) {
jButton10_actionPerformed(e);
}
void jButton11_actionPerformed(ActionEvent e) {
/*
* JFileChooser fileDialog = new JFileChooser(); ExcelFilter filter =
* new ExcelFilter(); fileDialog.setFileFilter(filter); int result =
* fileDialog.showSaveDialog(this); if (result ==
* JFileChooser.APPROVE_OPTION) { File f = fileDialog.getSelectedFile();
* new CreateExcelLast(f,this).start(); }
*/
DialogToExcel dte = new DialogToExcel();
dte.show();
}
void close_Frame(WindowEvent e) {
if (this.dataSave == false) {
int i = JOptionPane.showConfirmDialog(this, "保存GPS数据吗?");
if (i == 0) {
jButton10_actionPerformed(null);
System.exit(0);
// this.
} else if (i == 1) {
System.exit(0);
}
} else {
System.exit(0);
}
// JOptionPane.showMessageDialog(this,"Save test!");
}
void jMenuItem1_actionPerformed(ActionEvent e) {
// System.out.println(GarminGMLDoc.printStucture(GarminGMLDoc.d));
// CreateFile cf = new CreateFile(new File("c:\\GPSStruct.txt"));
// cf.setEncode("GB2312");
// cf.memoryToFile(GarminGMLDoc.printStucture(GarminGMLDoc.d));
// XYZOutput output = new XYZOutput();
// output.output("D:\\gps.txt");
/**
* 帮助
*/
try {
Runtime.getRuntime().exec("cmd /c index.htm");
} catch (Exception ex) {
ex.printStackTrace();
}
/**
* 打印内存
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -