⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabbedpane.java

📁 这是我们参加06年全国开源软件的竞赛作品
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    final int len = listAction.size();
                    if (muItem.getItemCount() == 1) {
                        for (int i = 0; i < len; i++) {
                            if (!listAction.get(i).equals("t")) {
                                muItem.add((String) listAction.get(i));
                            }
                        }
                    }
                    muItem.enable();
                    muItem.addItemListener(new ItemListener() {
                        public void itemStateChanged(ItemEvent e) {
                            String selectItem = muItem.getSelectedItem();
                            int indexItem = listAction.indexOf(selectItem);
                            String tempStr1 = "";
                            for (int i = 0; i <= indexItem; i++) {
                                tempStr1 += "<" + listAction.get(i) + ">TT|";
                            }
                            tempStr1 = tempStr1.substring(0,
                                    tempStr1.length() - 1);

                            String temp = "";
                            String tempStr2 = "";
                            for (int i = 0; i <= indexItem - 1; i++) {
                                temp = (String) listAction.get(i);
                                if (temp.equals("t")) {
                                    tempStr2 += "[t]D&";
                                } else {
                                    if (temp.substring(0, 1).equals("'")) {
                                        tempStr2 += "[" + temp + "]Sigma x.D&";
                                    } else {
                                        tempStr2 += "[" + temp + "]Pi x.D&";
                                    }
                                }
                            }
                            tempStr2 = tempStr2.substring(0,
                                    tempStr2.length() - 1);

                            String mu = "mu D.(" + "(" + tempStr1 + ")" + "&"
                                    + "(" + tempStr2 + ")" + ")";
                            tf2.setText(mu);
                        }
                    });
                    // **********************************************************
                } else {
                    title = "error";
                    // message = "没有输入bpel源文件,请输入...";
                    message = "please select the BPEL source file...";
                    JOptionPane optionPane = new JOptionPane(message,
                            JOptionPane.ERROR_MESSAGE); // message Type
                    JDialog dialog = optionPane.createDialog(frame, title);
                    dialog.show();
                    System.out.println("没有输入bpel源文件,请输入...");
                }
            }
        });
        bCheck.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // 调用Result.java
                // 取出tf1中的内容,并将换行符去掉,组合成新的字符串
                String strText = "agent " + tf1.getText();
                String para1 = "";
                if (!strText.equals("agent ")) {
                    for (int i = 0; i < strText.length(); i++) {
                        if (!strText.substring(i, i + 1).equals("\n")) {
                            para1 += strText.substring(i, i + 1);
                        }
                    }
                    final File file = new File(s);
                    Bpel2RemarkPi pr = new Bpel2RemarkPi(file);
                    String para2 = tf2.getText();
                    if (para2.length() != 0) {
                        String command = para1 + "\n" + "prove "
                                + pr.getAgentHead() + " " + para2; // 检验命令,,,
                        Prover proverTest = new Prover(file);
                        String faultString = "";
                        try {
                            proverTest.propertyTest(command);// 验证过程,,,
                            faultString = proverTest.getPiFault();
                        } catch (Exception ex) {
                            ex.getStackTrace();
                        }

                        if (!faultString.equals("")) { // 如果返回的字符串不为空则说明不满足性质,返回的是错误的pi演算表达式!
                            try {
                                final File file1 = new File(s);
                                Remark_Pi2Bpel rp = new Remark_Pi2Bpel(file1);
                                Prover prover = new Prover(file);
                                String temp = (String) prover.pi2RemarkPi();
                                rp.pi2Bpel(temp, 1);
                            } catch (Exception ex) {
                                ex.getMessage();
                            }
                            int strNo = faultString.indexOf("@") + 1;
                            String str = "";
                            for (int i = 0; i < (strNo / 100); i++) {
                                for (int j = i * 100; j < (i + 1) * 100; j++) {
                                    str += faultString.substring(j, j + 1);
                                }
                                str = str + "\n";
                            }
                            if (strNo / 100 * 100 != strNo) {
                                for (int i = (strNo / 100) * 100; i < strNo - 1; i++) {
                                    str += faultString.substring(i, i + 1);
                                }
                            }

                            ResultViewer rv = new ResultViewer();
                            File tempFile = new File(s);
                            String sParent = tempFile.getParent()
                                    + "\\Property_" + tempFile.getName();
                            rv
                                    .init(
                                            "*********The Model is not satisfied to the given property!The pi expression slice is below :************\n"
                                                    + str, sParent);

                        } else {

                            ResultViewer rv = new ResultViewer();
                            rv
                                    .init(
                                            "**************The Model is satisfied to the given property!**************\n",
                                            s);
                        }
                    } else {
                        // 该处加入异常处理对话框

                        title = "error";
                        // message = "pi演算描述的模型和mu描述的性质不能为空,请输入...";
                        message = "pi-calculus or mu-calculus is empty,please input...";
                        JOptionPane optionPane = new JOptionPane(message,
                                JOptionPane.ERROR_MESSAGE); // message Type
                        JDialog dialog = optionPane.createDialog(frame, title);
                        dialog.show();
                    }
                } else {
                    // 该处加入异常处理对话框

                    title = "error";
                    // message = "pi演算描述的模型和mu描述的性质不能为空,请输入...";
                    message = "pi-calculus or mu-calculus is empty,please input...";
                    JOptionPane optionPane = new JOptionPane(message,
                            JOptionPane.ERROR_MESSAGE); // message Type
                    JDialog dialog = optionPane.createDialog(frame, title);
                    dialog.show();
                }

            }
        });

        /***********************************************************************
         * 加入互模拟检验
         */

        JPanel panelTop_bisi = new JPanel(new BorderLayout());
        JPanel buttonPanel2up = new JPanel();
        JPanel buttonPanel2down = new JPanel();
        JPanel buttonPanel2middle = new JPanel();// 用于填充buttonPanel2up与buttonPanel2down之间的空隙
        ImageIcon iconSpec = createImageIcon("images/spec.gif");
        JButton bspec = new JButton(" Specific File  ", iconSpec);
        bspec.setToolTipText("Choose the specific file");

        ImageIcon iconApplic = createImageIcon("images/applic.gif");
        JButton bapplic = new JButton("Application File", iconApplic);
        bapplic.setToolTipText("Choose the application file");

        ImageIcon iconRun = createImageIcon("images/excute.gif");
        JButton bexcute = new JButton("      Run      ", iconRun);
        bexcute.setToolTipText("Run the Bisimulation");

        ImageIcon iconSeePi = createImageIcon("images/seePi.gif");
        JButton bseepi = new JButton("   See  PI     ", iconSeePi);
        bseepi.setToolTipText("View the Pi expression");

        ImageIcon iconReturn = createImageIcon("images/return.gif");
        final JButton bdisplay = new JButton("  Return Path   ", iconReturn);
        bdisplay.setToolTipText("View the relatively retured path");

        buttonPanel2down.add(bspec);
        buttonPanel2down.add(bapplic);
        buttonPanel2down.add(bexcute);
        buttonPanel2down.add(bseepi);
        buttonPanel2down.add(bdisplay);

        Box baseBox2 = Box.createHorizontalBox();
        Box box1_bisi = Box.createVerticalBox();
        Box box2_bisi = Box.createVerticalBox();
        JLabel label1_bisi = new JLabel("检验规范");
        JLabel label2_bisi = new JLabel("实施文档");

        box2_bisi.add(label2_bisi);
        final TextField textField1_bisi = new TextField(40);
        textField1_bisi.setEditable(false);
        final TextField textField2_bisi = new TextField(40);
        textField2_bisi.setEditable(false);

        JPanel panelUpTop1 = new JPanel();
        JPanel panelUpTop2 = new JPanel();
        panelUpTop1.add(label1_bisi);
        panelUpTop1.add(textField1_bisi);
        box1_bisi.add(panelUpTop1);
        panelUpTop2.add(label2_bisi);
        panelUpTop2.add(textField2_bisi);
        box2_bisi.add(panelUpTop2);

        buttonPanel2middle.add(new JLabel("                    "));

        final JTextArea tf1_bisi = new JTextArea("", 22, 42);
        final JTextArea tf2_bisi = new JTextArea("", 22, 42);
        JScrollPane scrollPane1_bisi = new JScrollPane();
        final JScrollPane scrollPane2_bisi = new JScrollPane();
        box1_bisi.add(scrollPane1_bisi, BorderLayout.EAST);
        box2_bisi.add(scrollPane2_bisi, BorderLayout.EAST);
        scrollPane1_bisi.setViewportView(tf1_bisi);
        scrollPane2_bisi.setViewportView(tf2_bisi);

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                box1_bisi, box2_bisi);
        splitPane.setResizeWeight(0.5);
        splitPane.setOneTouchExpandable(true);
        buttonPanel2up.add(splitPane);

        panelTop_bisi.add(buttonPanel2up, BorderLayout.NORTH);
        panelTop_bisi.add(buttonPanel2middle, BorderLayout.CENTER);
        panelTop_bisi.add(buttonPanel2down, BorderLayout.SOUTH);
        panel2.add(panelTop_bisi);

        final FileDialog dlg1_bisi = new FileDialog(frame, "选择BPEL4WS文件或Pi表达式",
                FileDialog.LOAD);
        bspec.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                dlg1_bisi.setModal(true);
                dlg1_bisi.setVisible(true);
                String content = textField1_bisi.getText();// 面板当前的内容

                if (dlg1_bisi.getDirectory() == null
                        || dlg1_bisi.getDirectory().equals(""))
                    textField1_bisi.setText(content);

                else {
                    s = dlg1_bisi.getDirectory() + dlg1_bisi.getFile();
                    textField1_bisi.setText(s);
                    setBisimulationCompleteFlag(false);// 当重新选择规范文件或实施文件时,设置新的互模拟验证未执行完
                    specFile = new MyFile(s);// 根据选择的文件路径生成新的文件

                    try {
                        RandomAccessFile speci_file = new RandomAccessFile(
                                specFile, "r");
                        try {// 根据选择的文件的前若干个字符判断该规范文件是否bpel或pi表达式,并对相应的标志进行更新
                            if (speci_file.readLine().indexOf("agent") == -1)
                                specFile.setFileIsBpel(true);
                            else
                                specFile.setFileIsPi(true);

                            speci_file.close();

                        } catch (IOException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                    } catch (FileNotFoundException e0) {
                        e0.printStackTrace();
                    }

                    try {
                        MyActionListener myactionListener = new MyActionListener();
                        String str_Spec = myactionListener
                                .embellishFile(specFile);
                        if (specFile.getFileIsPi()) // 如果选择的规范文件是pi表达式,则对pi表达式进行分行显示在界面上
                        {
                            String strTemp = "";

                            int noTemp = str_Spec.length();
                            for (int i = 0; i < (noTemp / 200); i++) {
                                for (int j = i * 200; j < (i + 1) * 200; j++) {
                                    strTemp += str_Spec.substring(j, j + 1);
                                }
                                strTemp = strTemp + "\n";
                            }
                            str_Spec = strTemp;
                        }
                        tf1_bisi.setText(str_Spec);
                        tf1_bisi.validate();
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            }
        });

        final FileDialog dlg2_bisi = new FileDialog(frame, "选择BPEL4WS文件",
                FileDialog.LOAD);

        bapplic.addActionListener(new MyActionListener() {
            public void actionPerformed(ActionEvent e) {

                dlg2_bisi.setModal(true);
                dlg2_bisi.setVisible(true);
                String content = textField2_bisi.getText();// 面板当前内容
                if (dlg2_bisi.getDirectory() == null
                        || dlg2_bisi.getDirectory().equals(""))
                    textField2_bisi.setText(content);
                else {
                    String tempS = dlg2_bisi.getDirectory()
                            + dlg2_bisi.getFile();
                    textField2_bisi.setText(tempS);
                    appliFile = new MyFile(tempS);// 根据选择的实施文件生成新的文件
                    setBisimulationCompleteFlag(false);// 当重新选择规范文件或实施文件时,设置新的互模拟验证未执行完
                    try {
                        String str_Spec = embellishFile(appliFile);
                        tf2_bisi.setText(str_Spec);
                        tf2_bisi.validate();
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -