📄 tabbedpane.java
字号:
}
}
}
});
bexcute.addActionListener(new MyActionListener() {
public void actionPerformed(ActionEvent e) {
// 调用Result.java
// 取出tf1中的内容,并将换行符去掉,组合成新的字符串
if (specFile == null) { // 如果规范文件为空
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Special at first....",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else if (appliFile == null) {// 如果实施文件为空
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Application....",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else if (specFile != null && appliFile != null) {// 如果规范和实施文件都存在,可以进行互模拟验证了!
// 第一步:将选择的规范和实施文件转化为Pi表达式,并在工具的对应位置显示出来
bisimulation = new Bisimulation(specFile, appliFile);
int i = bisimulation.execute();
if (i == 0) {
setFilesIsBisiFlag(false);
JOptionPane optionPane = new JOptionPane(
"The two files are unBisimulation!",
JOptionPane.INFORMATION_MESSAGE); // message
// Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
setBisimulationCompleteFlag(true);
} else if (i == 1) {
setFilesIsBisiFlag(true);
setBisimulationCompleteFlag(true);
JOptionPane optionPane = new JOptionPane(
"The two files are Bisimulation!",
JOptionPane.INFORMATION_MESSAGE); // message
// Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
} else if (i == 2) {
JOptionPane optionPane = new JOptionPane(
"There have an error in executing bisimulation!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
} else if (i == 3) {
JOptionPane optionPane = new JOptionPane(
"The file 'command.str' is null!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
} else if (i == 4) {
JOptionPane optionPane = new JOptionPane(
"There is an exception which has been catch!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
} else if (i == 5) {
JOptionPane optionPane = new JOptionPane(
"P or Q one is null at least!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
}
}
}
}); // end AddActionListener
bseepi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (specFile == null) {
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Special...",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else if (appliFile == null) {
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Application....",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else {
if (!getBisimulationCompleteFlag()) // 提示用户该操作必须在执行完操作"Bisimulation"之后进行
{
JOptionPane optionPane = new JOptionPane(
"Please execute the Bisimulation operation at first!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
}
tf1_bisi.setText(bisimulation.getSpecPi());
tf2_bisi.setText(bisimulation.getAppliPi());
}
}
});// end addActionListener
bdisplay.addActionListener(new MyActionListener() {
public void actionPerformed(ActionEvent e) {
if (specFile == null) {
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Special...",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else if (appliFile == null) {
JOptionPane optionPane = new JOptionPane(
"Please choose the BPEL4WS of Application....",
JOptionPane.WARNING_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
} else {
if (!getBisimulationCompleteFlag()) // 提示用户该操作必须在执行完操作"Bisimulation"之后进行
{
JOptionPane optionPane = new JOptionPane(
"Please execute the Bisimulation operation at first!",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
}
if (filesIsBisiFlag) // 当两个文件是互模拟时,该按钮的动作失效!
{
JOptionPane optionPane = new JOptionPane(
"The two files are bisimulation",
JOptionPane.ERROR_MESSAGE); // message Type
JDialog dialog = optionPane.createDialog(frame, title);
dialog.show();
return;
}
if (specFile.getFileIsBpel()) {// 如果实施文件是BPEL
String path_Special = "";
StringTokenizer tempStringTokenizer = new StringTokenizer(
((File) specFile).getAbsolutePath(), "\\");
int tokenCount = tempStringTokenizer.countTokens();
for (int i = 1; i < tokenCount; i++)
path_Special += tempStringTokenizer.nextToken()
+ "\\";
path_Special += "Bisi_"
+ tempStringTokenizer.nextToken();
File file_Spec = new File(path_Special);
String str_Spec = null;
try {
str_Spec = embellishFile(file_Spec);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (str_Spec == null)
str_Spec = "there has a exception!";
// tf1_bisi.setText("");
// final JTextPane lyTextPane = new JTextPane();
// Document doc = lyTextPane.getDocument();
// Document doc = tf1_bisi.getDocument();
// MyIdentifierPath myidentifierPath = new
// MyIdentifierPath();
// doc =
// myidentifierPath.identifier(doc,str_Spec,"<!--slice
// begin of NOT bisimulation procedure-->");
// scrollPane2_bisi.setViewportView(lyTextPane);
// tf1_bisi.setDocument(doc);
// tf1_bisi.setVisible(true);
tf1_bisi.setText(str_Spec);
tf1_bisi.setVisible(true);
// tf1_bisi.validate();
} else {
// 如果规范文件是Pi表达式,就不改变工具中窗口的内容
}
String path_Application = "";
StringTokenizer tempStringTokenizer1 = new StringTokenizer(
((File) appliFile).getAbsolutePath(), "\\");
int tokenCount1 = tempStringTokenizer1.countTokens();
for (int i = 1; i < tokenCount1; i++)
path_Application += tempStringTokenizer1.nextToken()
+ "\\";
path_Application += "Bisi_"
+ tempStringTokenizer1.nextToken();
File file_Appl = new File(path_Application);
String str_Appl = null;
try {
str_Appl = embellishFile(file_Appl);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (str_Appl == null)
str_Appl = "there has a exception!";
tf2_bisi.setText(str_Appl);
tf2_bisi.validate();
}
}
});
// *****************************
// Add the tabbed pane to this panel.
add(tabbedPane);
// Uncomment the following line to use scrolling tabs.
// tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
protected JComponent makeTextPanel(String text) {
JPanel panel = new JPanel(false);
// JLabel filler = new JLabel(text);
// filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
// panel.add(filler);
return panel;
}
/** Returns an ImageIcon, or null if the path was invalid. */
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = TabbedPane.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
/**
* Create the GUI and show it. For thread safety, this method should be
* invoked from the event-dispatching thread.
*/
private static void createAndShowGUI() {
// Create and set up the window.
JFrame frame = new JFrame("WebJetchecker");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create and set up the content pane.
JComponent newContentPane = new TabbedPane();
newContentPane.setOpaque(true); // content panes must be opaque
frame.getContentPane().add(new TabbedPane(), BorderLayout.CENTER);
// Display the window.
frame.pack();
frame.setVisible(true);
}
public void setFilesIsBisiFlag(boolean f) {
this.filesIsBisiFlag = f;
}
public boolean getFilesIsBisiFlag() {
return this.filesIsBisiFlag;
}
public void setBisimulationCompleteFlag(boolean f) {
this.bisimulationCompleteFlag = f;
}
public boolean getBisimulationCompleteFlag() {
return this.bisimulationCompleteFlag;
}
public static void main(String[] args) {
// Schedule a job for the event-dispatching thread:
// creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
}
public String embellishFile(File file) throws IOException {
String str = null;
RandomAccessFile ra = null;
String s = "";
try {
ra = new RandomAccessFile(file, "r");
long lengthFile = ra.length();
int pos = 0;
ra.seek(0);
while (ra.getFilePointer() < lengthFile) {
ra.seek(ra.getFilePointer());
s = ra.readLine();
str += s + "\n";
}
ra.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -