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

📄 cplusmpi.java

📁 基于JAVA的并行程序编辑器研究与设计 并行编程在高性能计算领域的应用越来越广泛。国家863计划项目“网格服务环境结点建设及其支撑技术研究”的子课题 “用户开发环境研究”
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        down.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                downSelect = true;
            }
        });
        
        JButton cancel = new JButton("取消");
        cancel.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                findDialog.dispose();
            }
        });
        searchNext.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int a = 0,k = 0,b = 0;
                int FindStartPos = textPane.getCaretPosition();
                int begin = FindStartPos;
                String str,str1, str2, str3, str4, strA, strB;
                str1 = textPane.getText();
                str1 = str1.copyValueOf(DataCopy(str1.toCharArray()));
                str2 = str1.toLowerCase();
                str3 = findText.getText();
                str4 = str3.toLowerCase();
                
                if(matchcase.isSelected()) {
                    strA = str1;
                    strB = str3;
                }else {
                    strA = str2;
                    strB = str4;
                }
                if(findText.getText().equals(""))
                    JOptionPane.showMessageDialog(null,"请输入查找内容",
                            "提示",JOptionPane.WARNING_MESSAGE);
                else{
                    if(up.isSelected()){
                        if(textPane.getSelectedText() == null){
                            a = strA.lastIndexOf(strB, FindStartPos - 1);
                        } else{
                            a = strA.lastIndexOf(strB,
                                    FindStartPos - findText.getText().length() - 1);
                        }
                    }else if(down.isSelected()){
                        a = strA.indexOf(strB, FindStartPos);
                    }
                    if(a >  - 1) {
                        if(up.isSelected()){
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                        }else if(down.isSelected()){
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                            FindStartPos = textPane.getCaretPosition();
                        }
                        done = true;
                    }else {
                        JOptionPane.showMessageDialog(null,
                                "找不到您查找的内容!",
                                "并行程序编辑器",JOptionPane.INFORMATION_MESSAGE);
                        done = false;
                    }
                }
            }
        });
        
        done = false;
        JPanel bottomPanel = new JPanel();
        JPanel topPanel = new JPanel();
        
        JPanel direction = new JPanel();
        direction.setBorder(BorderFactory.createTitledBorder("方向"));
        direction.add(up);
        direction.add(down);
        
        topPanel.add(searchContentLabel);
        topPanel.add(findText);
        topPanel.add(searchNext);
        bottomPanel.add(matchcase);
        bottomPanel.add(direction);
        bottomPanel.add(cancel);
        
        con.add(topPanel);
        con.add(bottomPanel);
        
        findText.setText(textPane.getSelectedText());
        findText.select(0,findText.getText().length());
        
        findDialog.setSize(360,145);
        findDialog.setResizable(false);
        findDialog.setLocation(230,280);
        findDialog.setVisible(true);
    };
    private void searchNext(){
        textPane.requestFocus();
        String strs = textPane.getSelectedText();
        if(done){
            int a = 0;
            String str = textPane.getText();
            str = str.copyValueOf(DataCopy(str.toCharArray())).toString();
            if(downSelect){
                a = str.indexOf(strs, textPane.getCaretPosition());
                if(a >  - 1){
                    textPane.setCaretPosition(a);
                    int b = strs.length();
                    textPane.select(a, a + b);
                } else return;
            } else {
                a = str.lastIndexOf(strs,textPane.getCaretPosition()
                - textPane.getSelectedText().length() - 1);
                if(a > -1){
                textPane.setCaretPosition(a);
                int b = strs.length();
                textPane.select(a, a + b);
                } else return;
            }
        } else {
            search();
        }
    };
    private void replace(){
        textPane.requestFocus();
        final JDialog findDialog = new JDialog(this,"替换",true);
        Container con = findDialog.getContentPane();
        con.setLayout(new FlowLayout(FlowLayout.LEFT));
        
        JLabel searchContentLabel = new JLabel("查找内容(N) :");
        JLabel replaceContentLabel = new JLabel("替换为(P)  :");
        final JTextField findText = new JTextField(30);
        final JTextField replaceText = new JTextField(30);
        final JCheckBox matchcase  = new JCheckBox("区分大小写(C)");
        ButtonGroup bGroup = new ButtonGroup();
        final JRadioButton up = new JRadioButton("向上(U)");
        final JRadioButton down = new JRadioButton("向下(D)");
        down.setSelected(true);
        bGroup.add(up);
        bGroup.add(down);
        JButton searchNext = new JButton("查找下一个(F)");
        JButton replace = new JButton("替换(R)");
        final JButton replaceAll = new JButton("全部替换(A)");
        
        JButton cancel = new JButton("取消");
        cancel.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                findDialog.dispose();
            }
        });
        searchNext.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int a = 0,k = 0,b = 0;
                int FindStartPos = textPane.getCaretPosition();
                int begin = FindStartPos;
                String str,str1, str2, str3, str4, strA, strB;
                str1 = textPane.getText();
                str1 = str1.copyValueOf(DataCopy(str1.toCharArray()));
                str2 = str1.toLowerCase();
                str3 = findText.getText();
                str4 = str3.toLowerCase();
                
                if(matchcase.isSelected()) {
                    strA = str1;
                    strB = str3;
                }else {
                    strA = str2;
                    strB = str4;
                }
                if(findText.getText().equals(""))
                    JOptionPane.showMessageDialog(null,"请输入查找内容",
                            "提示",JOptionPane.WARNING_MESSAGE);
                else{
                    if(up.isSelected()){
                        if(textPane.getSelectedText() == null){
                            a = strA.lastIndexOf(strB, FindStartPos - 1);
                        } else{
                            a = strA.lastIndexOf(strB,
                                    FindStartPos - findText.getText().length() - 1);
                        }
                    }else if(down.isSelected()){
                        a = strA.indexOf(strB, FindStartPos);
                    }
                    if(a >  - 1) {
                        if(up.isSelected()){
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                        }else if(down.isSelected()){
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                            FindStartPos = textPane.getCaretPosition();
                        }
                    }else {
                        JOptionPane.showMessageDialog(null,
                                "找不到您查找的内容!",
                                "并行程序编辑器",JOptionPane.INFORMATION_MESSAGE);
                    }
                }
            }
        });
        replace.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                if(findText.getText().equals(""))
                    JOptionPane.showMessageDialog(null,"请输入查找内容",
                            "提示",JOptionPane.WARNING_MESSAGE);
                else{
                    if(replaceText.getText().length() == 0
                            && textPane.getSelectedText() != null)
                        textPane.replaceSelection("");
                    if(replaceText.getText().length() > 0
                            && textPane.getSelectedText() !=  null)
                        textPane.replaceSelection(replaceText.getText());
                }
                highShowPerformed();
            }
        });
        replaceAll.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                textPane.setCaretPosition(0);
                int a = 0,b = 0,replaceCount = 0;
                if(findText.getText().length() == 0) {
                    JOptionPane.showMessageDialog(findDialog,"请输入查找内容!",
                            "提示",JOptionPane.WARNING_MESSAGE);
                    findText.requestFocus(true);
                    return;
                }
                while( a >  - 1) {
                    int FindStartPos = textPane.getCaretPosition();
                    String str1, str2, str3, str4, strA, strB;
                    str1 = textPane.getText();
                    str1 = str1.copyValueOf(DataCopy(str1.toCharArray()));
                    str2 = str1.toLowerCase();
                    str3 = findText.getText();
                    str4 = str3.toLowerCase();
                    if(matchcase.isSelected()) {
                        strA = str1;
                        strB = str3;
                    }else {
                        strA = str2;
                        strB = str4;
                    }
                    if(up.isSelected()){
                        if(textPane.getSelectedText() == null){
                            a = strA.lastIndexOf(strB, FindStartPos - 1);
                        }else{
                            a = strA.lastIndexOf(strB,
                                    FindStartPos - findText.getText().length() - 1);
                        }
                    }else if(down.isSelected())	{
                        if(textPane.getSelectedText() == null){
                            a = strA.indexOf(strB, FindStartPos);
                        }else {
                            a = strA.indexOf(strB,
                                    FindStartPos - findText.getText().length()+1);
                        }
                    }
                    if(a >  - 1) {
                        if(up.isSelected()){
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                        }else if(down.isSelected()) {
                            textPane.setCaretPosition(a);
                            b = findText.getText().length();
                            textPane.select(a, a + b);
                        }
                    }else {
                        if(replaceCount == 0){
                            JOptionPane.showMessageDialog(findDialog,
                                    "找不到您查找的内容!",
                                    "并行程序编辑器",JOptionPane.INFORMATION_MESSAGE);
                        }else {
                            highShowPerformed();
                            JOptionPane.showMessageDialog(findDialog,
                                    "成功替换"+replaceCount+"个匹配内容!",
                                    "替换成功",JOptionPane.INFORMATION_MESSAGE);
                        }
                    }
                    if(replaceText.getText().length() == 0
                            && textPane.getSelectedText() != null){
                        textPane.replaceSelection("");
                        replaceCount++;
                    }
                    if(replaceText.getText().length() > 0
                            && textPane.getSelectedText() != null){
                        textPane.replaceSelection(replaceText.getText());
                        replaceCount++;
                    }
                }
            }
        });
        
        JPanel bottomPanel = new JPanel();
        JPanel centerPanel = new JPanel();
        JPanel topPanel = new JPanel();
        JPanel direction = new JPanel();
        direction.setBorder(BorderFactory.createTitledBorder("方向"));
        direction.add(up);
        direction.add(down);
        JPanel replacePanel = new JPanel();
        replacePanel.setLayout(new GridLayout(2,1));
        replacePanel.add(replace);
        replacePanel.add(replaceAll);
        topPanel.add(searchContentLabel);
        topPanel.add(findText);
        topPanel.add(searchNext);
        centerPanel.add(replaceContentLabel);
        centerPanel.add(replaceText);
        centerPanel.add(replacePanel);
        bottomPanel.add(matchcase);
        bottomPanel.add(direction);
        bottomPanel.add(cancel);
        con.add(topPanel);
        con.add(centerPanel);
        con.add(bottomPanel);
        
        findText.setText(textPane.getSelectedText());
        findText.select(0,findText.getText().length());
        
        findDialog.setSize(410,210);
        findDialog.setResizable(false);

⌨️ 快捷键说明

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