?? 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 + -