• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1207

13 Sep 2025 11:58PM UTC coverage: 2.895% (-0.006%) from 2.901%
#1207

push

jiangxincode
fix #569: 可能在完全初始化子类之前逃逸了 'this'

0 of 32 new or added lines in 22 files covered. (0.0%)

9 existing lines in 8 files now uncovered.

248 of 8567 relevant lines covered (2.89%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/file/OsConvertPanel.java
1
package edu.jiangxin.apktoolbox.file;
2

3
import edu.jiangxin.apktoolbox.file.core.OsPatternConvert;
4
import edu.jiangxin.apktoolbox.swing.extend.EasyPanel;
5
import edu.jiangxin.apktoolbox.swing.extend.FileListPanel;
6
import edu.jiangxin.apktoolbox.utils.Constants;
7
import edu.jiangxin.apktoolbox.utils.FileUtils;
8
import org.apache.commons.lang3.StringUtils;
9

10
import javax.swing.*;
11
import java.awt.*;
12
import java.awt.event.ActionEvent;
13
import java.awt.event.ActionListener;
14
import java.io.File;
15
import java.util.ArrayList;
16
import java.util.List;
17
import java.util.Set;
18
import java.util.TreeSet;
19

20
/**
21
 * @author jiangxin
22
 * @author 2019-04-12
23
 *
24
 */
25
public class OsConvertPanel extends EasyPanel {
26
    private static final long serialVersionUID = 1L;
27

28
    private FileListPanel srcPanel;
29

30
    private JPanel optionPanel;
31

32
    private JTextField suffixTextField;
33

34
    private JCheckBox recursiveCheckBox;
35

36
    private JComboBox<String> typeComboBox;
37

38
    private JPanel operationPanel;
39

40
    public OsConvertPanel() throws HeadlessException {
41
        super();
×
42
    }
×
43

44
    @Override
45
    public void initUI() {
46
        BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
×
47
        setLayout(boxLayout);
×
48

49
        createSrcPanel();
×
50
        add(srcPanel);
×
51
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
52

53
        createOptionPanel();
×
54
        add(optionPanel);
×
55
        add(Box.createVerticalStrut(Constants.DEFAULT_Y_BORDER));
×
56

57
        createOperationPanel();
×
58
        add(operationPanel);
×
59
    }
×
60

61
    private void createOperationPanel() {
62
        operationPanel = new JPanel();
×
63
        operationPanel.setLayout(new BoxLayout(operationPanel, BoxLayout.X_AXIS));
×
64

65
        JButton convertButton = new JButton("Convert");
×
66
        convertButton.addActionListener(new ConvertButtonActionListener());
×
67

68
        operationPanel.add(convertButton);
×
69
    }
×
70

71
    private void createOptionPanel() {
72
        optionPanel = new JPanel();
×
73
        optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
×
74

75
        JLabel suffixLabel = new JLabel("Suffix:");
×
76
        suffixTextField = new JTextField();
×
77
        suffixTextField.setToolTipText("an array of extensions, ex. {\"java\",\"xml\"}. If this parameter is empty, all files are returned.");
×
78
        suffixTextField.setText(conf.getString("osconvert.suffix"));
×
79
        optionPanel.add(suffixLabel);
×
80
        optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
81
        optionPanel.add(suffixTextField);
×
82
        optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
83

84
        recursiveCheckBox = new JCheckBox("Recursive");
×
85
        recursiveCheckBox.setSelected(true);
×
86
        optionPanel.add(recursiveCheckBox);
×
87
        optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
88

89
        JLabel typeLabel = new JLabel("Type:");
×
90
        typeComboBox = new JComboBox<>();
×
91
        typeComboBox.addItem("Convert to UNIX(LF Only)");
×
92
        typeComboBox.addItem("Convert to Macintosh(CR Only)");
×
93
        typeComboBox.addItem("Convert to Windows(CR+LF)");
×
94

95
        optionPanel.add(typeLabel);
×
96
        optionPanel.add(Box.createHorizontalStrut(Constants.DEFAULT_X_BORDER));
×
97
        optionPanel.add(typeComboBox);
×
98
    }
×
99

100
    private void createSrcPanel() {
101
        srcPanel = new FileListPanel();
×
NEW
102
        srcPanel.initialize();
×
UNCOV
103
    }
×
104

105
    private final class ConvertButtonActionListener implements ActionListener {
×
106
        @Override
107
        public void actionPerformed(ActionEvent e) {
108
            conf.setProperty("osconvert.suffix", suffixTextField.getText());
×
109
            List<File> fileList = new ArrayList<>();
×
110
            for (File file : srcPanel.getFileList()) {
×
111
                String[] extensions = null;
×
112
                if (StringUtils.isNotEmpty(suffixTextField.getText())) {
×
113
                    extensions = suffixTextField.getText().split(",");
×
114
                }
115
                fileList.addAll(FileUtils.listFiles(file, extensions, recursiveCheckBox.isSelected()));
×
116
            }
×
117
            Set<File> fileSet = new TreeSet<>(fileList);
×
118
            fileList.clear();
×
119
            fileList.addAll(fileSet);
×
120
            OsPatternConvert.osConvertFiles(fileList, convertShowNameToPattern(typeComboBox.getSelectedItem().toString()));
×
121
            logger.info("convert finish");
×
122
        }
×
123
    }
124

125
    private String convertShowNameToPattern(String showName) {
126
        switch (showName) {
×
127
            case "Convert to UNIX(LF Only)":
128
                return "tounix";
×
129
            case "Convert to Macintosh(CR Only)":
130
                return "tomac";
×
131
            case "Convert to Windows(CR+LF)":
132
                return "towindows";
×
133
        }
134
        return "towindows";
×
135
    }
136
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc