📄 tabbedpane.java
字号:
/*
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
author: Yuan yongfu lijin liyong lib 511,the College of Mathematics and Computer Science,HuNan Normal University,China
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
*/
/*
* TabbedPaneDemo.java requires one additional file: images/middle.gif.
*/
package edu.hunnu.webjetchecker.viewer.welcome;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.JTextArea;
import edu.hunnu.webjetchecker.MyFile;
import edu.hunnu.webjetchecker.config.Config;
import edu.hunnu.webjetchecker.convert.Bpel2Pi;
import edu.hunnu.webjetchecker.convert.Bpel2RemarkPi;
import edu.hunnu.webjetchecker.convert.Remark_Pi2Bpel;
import edu.hunnu.webjetchecker.propertytest.Bisimulation;
import edu.hunnu.webjetchecker.propertytest.Prover;
import edu.hunnu.webjetchecker.viewer.prover.ResultViewer;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class TabbedPane extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1L;
String s = ""; // 记录选取的文档的目录路径;
Choice muItem = new Choice();
private String title = "";// 警告框标题;
private String message = "";// 警告框内容;
JFrame frame = new JFrame("WebJetChecker ver1.0");
private MyFile specFile = null; // 用于互模拟验证的规范文件
private MyFile appliFile = null; // 用于互模拟验证的实施文件
private Bisimulation bisimulation = null;
private boolean bisimulationCompleteFlag = false; // 用于标识已经执行了互模拟操作,如果已经执行互模拟操作,其值置true,那么就可执行操作display了
private boolean filesIsBisiFlag = true;// 用于标识两个文件是否为互模拟。任何时刻选定的文件未执行互模拟验证之前,都假定其为互模拟的。
public TabbedPane() {
super(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon0 = createImageIcon("images/welcome.gif");
ImageIcon icon1 = createImageIcon("images/testProttery.gif");
ImageIcon icon2 = createImageIcon("images/bisimulation.gif");
JComponent panel0 = makeTextPanel("Welcome");
tabbedPane.addTab("Welcome", icon0, panel0, "Welcome for you");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_0);
JComponent panel1 = makeTextPanel("性质检验");
tabbedPane.addTab("性质检验", icon1, panel1, "Does nothing");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_1);
JComponent panel2 = makeTextPanel("互模拟");
tabbedPane.addTab("互模拟", icon2, panel2, "Does twice as much nothing");
tabbedPane.setMnemonicAt(2, KeyEvent.VK_2);
// welcome
JPanel panelTop_welcome = new JPanel(new BorderLayout());
ImageIcon iconSelectLib = createImageIcon("images/setPath.gif");
ImageIcon iconYuanliLib = createImageIcon("images/yuanli.gif");
JLabel selectLabel = new JLabel(iconYuanliLib);
JLabel label_welcome1 = new JLabel("点击下面按钮以配置mwb的路径(即选择名为sml的文件夹的存放目录)");
JButton selectLibButton = new JButton("modify");
JButton concelButton = new JButton("cancel");
JLabel labelUp = new JLabel(createImageIcon("images/hunnu.jpg"));
JPanel panelMiddle = new JPanel();
Config config1 = new Config();
final String changedBefore = config1.getMwb_path();
final TextField textField_wel = new TextField(changedBefore, 40);
JPanel tempPanel_up = new JPanel();
tempPanel_up.add(label_welcome1);
panelMiddle.add(tempPanel_up);
JPanel tempPanel_down = new JPanel();
tempPanel_down.add(textField_wel);
tempPanel_down.add(selectLibButton);
tempPanel_down.add(concelButton);
panelMiddle.add(tempPanel_down);
JPanel panelDown = new JPanel();
panelDown.add(new JLabel(" "));
panelDown.add(new JLabel("湖南师范大学数学与计算机科学学院科学计算实验室"));
JPanel panelLight = new JPanel();
panelLight
.add(new JLabel(
" "));
JPanel panelRight = new JPanel();
panelRight.add(new JLabel(" "));
// JLabel labelDown = new JLabel("湖南师范大学数学与计算机科学学院科学计算实验室");
// 以下为欢迎界面的布局
panelTop_welcome.add(labelUp, BorderLayout.PAGE_START);
panelMiddle.setPreferredSize(new Dimension(200, 100));
panelTop_welcome.add(panelMiddle, BorderLayout.CENTER);
panelTop_welcome.add(panelDown, BorderLayout.PAGE_END);
panelTop_welcome.add(panelLight, BorderLayout.LINE_START);
panelTop_welcome.add(panelRight, BorderLayout.LINE_END);
panel0.add(panelTop_welcome);
final JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
textField_wel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String path = textField_wel.getText();
// if (!path.substring(path.length() - 3).equals("mwb")) {
// JOptionPane optionPane = new JOptionPane("请选择正确的MWB安装目录",
// JOptionPane.ERROR_MESSAGE); // message Type
// JDialog dialog = optionPane.createDialog(frame, title);
// dialog.show();
// return;
// }
Config config2 = new Config();
config2.setMwb_path(path);
JOptionPane optionPane = new JOptionPane(
"The mwb's path have changed!",
JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
}
});
selectLibButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showOpenDialog(TabbedPane.this);
File directy = fc.getSelectedFile();
String path = null;
try {
path = directy.getPath();
// if (!path.substring(path.length() - 3).equals("mwb")) {
// JOptionPane optionPane = new JOptionPane(
// "请选择正确的MWB安装目录", JOptionPane.ERROR_MESSAGE); // message
// // Type
// JDialog dialog = optionPane.createDialog(frame, title);
// dialog.show();
// return;
// }
Config config3 = new Config();
config3.setMwb_path(path);
textField_wel.setText(config3.getMwb_path());
JOptionPane optionPane = new JOptionPane(
"The mwb's path have changed!",
JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
} catch (Exception e111) {
// TODO Auto-generated catch block
}
}
});
concelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Config config4 = new Config();
config4.setMwb_path(changedBefore);
textField_wel.setText(config4.getMwb_path());
JOptionPane optionPane = new JOptionPane(
"The mwb's path havn't change!",
JOptionPane.INFORMATION_MESSAGE);
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
}
});
/***********************************************************************
* 加入性质检验
*/
JPanel panelTop = new JPanel(new BorderLayout());
JPanel buttonPanel = new JPanel();
ImageIcon iconCheck = createImageIcon("images/excute.gif");
JButton bCheck = new JButton("check", iconCheck);
ImageIcon iconTrans = createImageIcon("images/trans.gif");
JButton bTrans = new JButton("BPEL4WS->Pi", iconTrans);
ImageIcon iconSelect = createImageIcon("images/select.gif");
JButton bSelect = new JButton("select", iconSelect);
muItem.add("*****action needed checked*****");
muItem.disable();
buttonPanel.add(bCheck);
buttonPanel.add(bTrans);
buttonPanel.add(bSelect);
buttonPanel.add(muItem);
Box baseBox = Box.createHorizontalBox();
Box box1 = Box.createVerticalBox();
Box box2 = Box.createVerticalBox();
box1.add(new JLabel("Pi-calculus"));
for (int i = 0; i < 10; i++) {
box1.add(new JLabel(" "));
}
box1.add(new JLabel("mu-calculus"));
final JTextArea tf1 = new JTextArea("", 15, 50);
final JTextArea tf2 = new JTextArea("", 5, 40);
JScrollPane scrollPane1 = new JScrollPane();
JScrollPane scrollPane2 = new JScrollPane();
box2.add(scrollPane1, BorderLayout.EAST);
box2.add(scrollPane2, BorderLayout.EAST);
scrollPane1.setViewportView(tf1);
scrollPane2.setViewportView(tf2);
baseBox.add(box1);
baseBox.add(box2);
panelTop.add(baseBox, BorderLayout.NORTH);
panelTop.add(buttonPanel, BorderLayout.SOUTH);
panel1.add(panelTop);
final FileDialog dlg2 = new FileDialog(frame, "选择BPEL4WS文件",
FileDialog.LOAD);
bSelect.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dlg2.setModal(true);
dlg2.setVisible(true);
s = dlg2.getDirectory() + dlg2.getFile();
if (!s.equals("nullnull")) {
tf1
.setText("You have selected a file of BPEL4WS,"
+ "\n"
+ "please click the botton \"BPEL4WS->Pi \" to trans BPEL4WS to pi-calculus!");
}
tf2.setText("");
}
});
// 将bpel源文件建模为pi演算模型
bTrans.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!(s.equals("nullnull") || s.equals(""))) {
final File file = new File(s);// 输入bpel文件的路径位置
Bpel2RemarkPi pr = new Bpel2RemarkPi(file);
Bpel2Pi rr = new Bpel2Pi(file);
final String pi_expression = rr.getResult();
String strTemp = "";
int noTemp = pi_expression.length();
for (int i = 0; i < (noTemp / 100); i++) {
for (int j = i * 100; j < (i + 1) * 100; j++) {
strTemp += pi_expression.substring(j, j + 1);
}
strTemp = strTemp + "\n";
}
if (noTemp / 100 * 100 != noTemp) {
for (int i = (noTemp / 100) * 100; i < noTemp; i++) {
strTemp += pi_expression.substring(i, i + 1);
}
}
tf1.setText(strTemp.substring(6));
tf2.setText("");
// ***************此处加入mu演算性质描述*************************
final ArrayList listAction = rr.getListAction();
int j = 0;
while (!listAction.get(j).equals("t")) {
j++;
}
for (int i = j + 1; i < listAction.size(); i++) {
if (listAction.get(i).equals("t")) {
listAction.remove(i);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -