Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Dec 7, 2023
1 parent e9f73a2 commit 93a12eb
Show file tree
Hide file tree
Showing 28 changed files with 86 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-arlington-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: |
git fetch origin arlington:arlington
git checkout -b test-branch arlington
- name: Configure user nameF
- name: Configure user name
run: |
git config user.name "Git User"
git config user.email "[email protected]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void shouldCreateXmlReportsInGivenDirectory() throws Exception {
List<Future<ValidationResult>> futureResult = startValidation(fileToValidate, numberOfThreads);
List<ValidationResult> validationResults = getValidationResult(futureResult);

Boolean isExpectedResults = compareResultsFromDifferentThreads(validationResults);
boolean isExpectedResults = compareResultsFromDifferentThreads(validationResults);

assertTrue(isExpectedResults);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.concurrent.Callable;

public class CallableValidatorForTest implements Callable<ValidationResult> {
private File fileToValidate;
private final File fileToValidate;

public CallableValidatorForTest(File fileToValidate) {
this.fileToValidate = fileToValidate;
Expand Down
3 changes: 0 additions & 3 deletions gui/src/main/java/org/verapdf/apps/Applications.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ private static boolean areDirectoryFilesWritable(File directory) {
if (files == null) {
return Files.isWritable(directory.toPath());
}
if (files.length == 0) {
return true;
}
for (String fileName : files) {
if (!Files.isWritable(new File(directory + File.separator + fileName).toPath())) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions gui/src/main/java/org/verapdf/apps/SoftwareUpdaterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

public class SoftwareUpdaterImpl implements SoftwareUpdater {
private final static Logger logger = Logger.getLogger(SoftwareUpdaterImpl.class.getCanonicalName());
private final static String latestGF = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:greenfield-apps&core=gav&rows=20&wt=xml";
private final static String latestPDFBox = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:pdfbox-apps&core=gav&rows=20&wt=xml";
private final static String latestGF = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:greenfield-apps&core=gav&rows=1&wt=xml";
private final static String latestPDFBox = "https://search.maven.org/solrsearch/select?q=g:org.verapdf.apps+AND+a:pdfbox-apps&core=gav&rows=1&wt=xml";
private final String currentVersion = Applications.getAppDetails().getVersion();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private ApplicationUtils() {
*
* @param toFilter
* the list of files to filter, can not be null
* @return an immutable list of the filtered files, i.e. all PDF extenstions
* @return an immutable list of the filtered files, i.e. all PDF extensions
* @throws IllegalArgumentException
* when toFilter is null
*/
Expand Down
2 changes: 0 additions & 2 deletions gui/src/main/java/org/verapdf/cli/CliConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
package org.verapdf.cli;

import java.util.Arrays;
import java.util.List;

/**
* @author <a href="mailto:[email protected]">Carl Wilson</a>
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/java/org/verapdf/cli/VeraPdfCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void main(final String[] args) throws VeraPDFException {
long maxMemory = heapUsage.getMax() / MEGABYTE;
long usedMemory = heapUsage.getUsed() / MEGABYTE;
System.out.format(",%s\n", message); //$NON-NLS-1$
System.out.format("Memory Use: %sM/%sM\n", Long.valueOf(usedMemory), Long.valueOf(maxMemory)); //$NON-NLS-1$
System.out.format("Memory Use: %sM/%sM\n", usedMemory, maxMemory); //$NON-NLS-1$
System.out.format(
"To increase the memory available to the JVM please assign the JAVA_OPTS environment variable.\n"); //$NON-NLS-1$
System.out.format("The examples below increase the maximum heap available to the JVM to 2GB:\n"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ public class MultiThreadProcessor {

private int filesQuantity;

private File veraPDFStarterPath;
private List<String> veraPDFParameters;
private final File veraPDFStarterPath;
private final List<String> veraPDFParameters;
private OutputStream os;
private OutputStream errorStream;
private final OutputStream errorStream;

private ReportWriter reportWriter;
private MultiThreadProcessingHandler processingHandler;
private final ReportWriter reportWriter;
private final MultiThreadProcessingHandler processingHandler;

private boolean isFirstReport = true;
private boolean isHTMLReport;
private File xmlReport;
private String wikiPath;
private final String wikiPath;

private ExitCodes currentExitCode = ExitCodes.VALID;
private CountDownLatch latch;
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/java/org/verapdf/gui/AboutPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AboutPanel extends JPanel {

static final Logger logger = Logger.getLogger(AboutPanel.class.getCanonicalName());

private JButton okButton;
private final JButton okButton;
JDialog dialog;

AboutPanel() throws IOException {
Expand Down
24 changes: 12 additions & 12 deletions gui/src/main/java/org/verapdf/gui/CheckerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class CheckerPanel extends JPanel {
private static final Map<String, PDFAFlavour> FLAVOURS_MAP = new HashMap<>();
private static final String emptyString = ""; //$NON-NLS-1$

private JFileChooser pdfChooser;
private JFileChooser xmlChooser;
private JFileChooser htmlChooser;
private JFileChooser policyChooser;
private final JFileChooser pdfChooser;
private final JFileChooser xmlChooser;
private final JFileChooser htmlChooser;
private final JFileChooser policyChooser;
private List<File> pdfsToProcess;
private JTextField chosenPDF;
private JTextField chosenProfile;
Expand Down Expand Up @@ -346,7 +346,7 @@ private void setupChooseFlavourLabel(final GridBagLayout gbl, final GridBagConst
this.add(chooseFlavourLabel);
}

private void setupChooseFlavourBox(final GridBagLayout gbl, final GridBagConstraints gbc) throws IOException {
private void setupChooseFlavourBox(final GridBagLayout gbl, final GridBagConstraints gbc) {
Vector<String> availableFlavours = new Vector<>();
availableFlavours.add(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT);
availableFlavours.add(GUIConstants.AUTO_FLAVOUR_COMBOBOX_TEXT);
Expand Down Expand Up @@ -401,7 +401,7 @@ private void setupChosenProfileTextField(final GridBagLayout gbl, final GridBagC
if (!this.profilePath.toString().isEmpty()) {
this.chosenProfile.setText(this.profilePath.toString());
} else {
this.chosenProfile.setText(GUIConstants.CHOOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT);
this.chosenProfile.setText(GUIConstants.CHOSEN_PROFILE_TEXTFIELD_DEFAULT_TEXT);
}
}

Expand All @@ -420,8 +420,8 @@ private void setupProfileButton(final GridBagLayout gbl, final GridBagConstraint
this.chooseFlavour.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) {
if (CheckerPanel.this.chooseFlavour.getSelectedItem()
.equals(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT)) {
if (GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT
.equals(CheckerPanel.this.chooseFlavour.getSelectedItem())) {
chooseProfile.setEnabled(true);
CheckerPanel.this.chosenProfile.setEnabled(true);
CheckerPanel.this.targetProfile.setActive(true);
Expand Down Expand Up @@ -913,7 +913,7 @@ private PDFAFlavour getCurrentFlavour() {
private boolean isExecute() {
return (this.pdfsToProcess != null
&& (!this.profilePath.toString().isEmpty()
|| !this.chooseFlavour.getSelectedItem().equals(GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT))
|| !GUIConstants.CUSTOM_PROFILE_COMBOBOX_TEXT.equals(this.chooseFlavour.getSelectedItem()))
&& (this.processTypes.getSelectedItem() != ProcessType.POLICY || this.policy != null));
}

Expand All @@ -939,7 +939,7 @@ void setPolicyFile(File policy) {
}
}

private class ProcessingTypeRenderer extends JLabel implements ListCellRenderer<ProcessType> {
private static class ProcessingTypeRenderer extends JLabel implements ListCellRenderer<ProcessType> {

/**
*
Expand All @@ -966,11 +966,11 @@ public class PanelDropTargetListener extends DropTargetAdapter {
private static final String UNSUPPORTED_FLAVOUR = "Unsupported flavour error.";
private static final String CASTING_ERROR = "Casting transfer to files type error.";

private int acceptableFilesCount;
private final int acceptableFilesCount;

private List<File> selectedFiles = new ArrayList<>();

private String[] acceptableExtensions;
private final String[] acceptableExtensions;

public PanelDropTargetListener(int acceptableFilesCount, String...acceptableExtensions) {
this.acceptableFilesCount = acceptableFilesCount;
Expand Down
4 changes: 2 additions & 2 deletions gui/src/main/java/org/verapdf/gui/FeaturesConfigPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ public class FeaturesConfigPanel extends JPanel {
*/
private static final long serialVersionUID = -6602264333993164990L;

private JButton okButton;
private final JButton okButton;
boolean ok;
JDialog dialog;
private EnumMap<FeatureObjectType, JCheckBox> featureGrid = new EnumMap<>(FeatureObjectType.class);
private final EnumMap<FeatureObjectType, JCheckBox> featureGrid = new EnumMap<>(FeatureObjectType.class);

FeaturesConfigPanel() {
setBorder(new EmptyBorder(GUIConstants.EMPTY_BORDER_INSETS, GUIConstants.EMPTY_BORDER_INSETS,
Expand Down
4 changes: 2 additions & 2 deletions gui/src/main/java/org/verapdf/gui/LogoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class LogoPanel extends JPanel {
private static final long serialVersionUID = -3623071197419943686L;

private final transient BufferedImage logo;
private int borderWidth;
private Color background;
private final int borderWidth;
private final Color background;

LogoPanel(String logoName, Color backgroundColor, int borderWidth) throws IOException {
this.borderWidth = borderWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public class PDFValidationApplication extends JFrame {

private AboutPanel aboutPanel;
private SettingsPanel settingsPanel;
private FeaturesConfigPanel featuresPanel;
private final FeaturesConfigPanel featuresPanel;
private CheckerPanel checkerPanel;
private VeraAppConfig config;
private PolicyPanel policyConfig;
private final VeraAppConfig config;
private final PolicyPanel policyConfig;

private PDFValidationApplication(double frameScale) {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
Expand Down Expand Up @@ -369,7 +369,7 @@ public static void main(String[] args) {
double frameScale = 1;
if (args.length > 1 && "--frameScale".equals(args[0]) && args[1] != null) {
try {
frameScale = Double.valueOf(args[1]);
frameScale = Double.parseDouble(args[1]);
} catch (NumberFormatException e) {
e.printStackTrace();
}
Expand Down
8 changes: 4 additions & 4 deletions gui/src/main/java/org/verapdf/gui/PartnersPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class PartnersPanel extends JPanel {
*/
private static final long serialVersionUID = -5926089530817358566L;
private final transient BufferedImage partnersLogo;
private Color background;
private JLabel consortium;
private JLabel preforma;
private JLabel version;
private final Color background;
private final JLabel consortium;
private final JLabel preforma;
private final JLabel version;

PartnersPanel(String logoName, Color backgroundColor) throws IOException {
try (InputStream is = getClass().getClassLoader().getResourceAsStream(logoName)) {
Expand Down
32 changes: 16 additions & 16 deletions gui/src/main/java/org/verapdf/gui/PolicyPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ public class PolicyPanel extends JPanel {

private File policyFile;

private JButton okButton;
private final JButton okButton;
private JDialog dialog;
private boolean ok;
private JPanel mainPanel;
private JPanel assertionsPanel;
private LayoutManager mainPanelLayout;
private JScrollPane scrollPane;
private final JPanel mainPanel;
private final JPanel assertionsPanel;
private final LayoutManager mainPanelLayout;
private final JScrollPane scrollPane;

private List<JComboBox<FeatureObjectType>> featureTypes;
private List<JTextField> arguments;
private List<JComboBox<Feature>> features;
private List<JComboBox<SchematronOperation>> operations;
private List<JButton> removeLineButtons;
private List<JPanel> layoutPanels;
private final List<JComboBox<FeatureObjectType>> featureTypes;
private final List<JTextField> arguments;
private final List<JComboBox<Feature>> features;
private final List<JComboBox<SchematronOperation>> operations;
private final List<JButton> removeLineButtons;
private final List<JPanel> layoutPanels;

private JPanel buttonPanel;
private JButton addLineButton;
private final JPanel buttonPanel;
private final JButton addLineButton;

public PolicyPanel() {
setPreferredSize(
Expand Down Expand Up @@ -448,7 +448,7 @@ private static Insets getDefaultInsets() {
return new Insets(2, 2, 2, 2);
}

private class FeatureObjectTypeRenderer extends JLabel implements ListCellRenderer<FeatureObjectType> {
private static class FeatureObjectTypeRenderer extends JLabel implements ListCellRenderer<FeatureObjectType> {
private static final long serialVersionUID = -8167306132255766422L;

@Override
Expand All @@ -472,7 +472,7 @@ private static void setOptimalSizeForComboBox(Component component) {
GUIConstants.PREFERRED_POLICY_WINDOW_ELEMENT_HEIGHT));
}

private class FeatureRenderer extends JLabel implements ListCellRenderer<Feature> {
private static class FeatureRenderer extends JLabel implements ListCellRenderer<Feature> {
private static final long serialVersionUID = 1669321048267902682L;

@Override
Expand All @@ -487,7 +487,7 @@ public Component getListCellRendererComponent(JList<? extends Feature> list, Fea
}
}

private class OperationsRenderer extends JLabel implements ListCellRenderer<SchematronOperation> {
private static class OperationsRenderer extends JLabel implements ListCellRenderer<SchematronOperation> {
private static final long serialVersionUID = 8259625674253427340L;

@Override
Expand Down
23 changes: 11 additions & 12 deletions gui/src/main/java/org/verapdf/gui/SettingsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ class SettingsPanel extends JPanel {
'|', '+', '\0', '%' };

private static final long serialVersionUID = -5688021756073449469L;
private JButton okButton;
private final JButton okButton;
boolean ok;
JDialog dialog;
private JTextField numberOfFailed;
private JTextField numberOfFailedDisplay;
private JCheckBox hidePassedRules;
private JCheckBox logs;
private JCheckBox showErrorMessages;
private JTextField fixMetadataPrefix;
private final JTextField numberOfFailed;
private final JTextField numberOfFailedDisplay;
private final JCheckBox hidePassedRules;
private final JCheckBox logs;
private final JCheckBox showErrorMessages;
private final JTextField fixMetadataPrefix;
private PDFAFlavour currentDefaultFlavour;
JTextField fixMetadataFolder;
JFileChooser folderChooser;
private JTextField profilesWikiPath;
private final JTextField profilesWikiPath;
private static final Map<String, PDFAFlavour> FLAVOURS_MAP = new HashMap<>();
private static final Map<String, Integer> LOGGING_LEVELS_MAP = new HashMap<>();
private JComboBox<String> chooseDefaultFlavour;
private JComboBox<String> chooseLoggingLevel;
private final JComboBox<String> chooseDefaultFlavour;
private final JComboBox<String> chooseLoggingLevel;

SettingsPanel(final ConfigManager config) throws IOException {
setBorder(new EmptyBorder(GUIConstants.EMPTY_BORDER_INSETS, GUIConstants.EMPTY_BORDER_INSETS,
Expand Down Expand Up @@ -182,14 +182,13 @@ public void keyReleased(KeyEvent e) {
panel.add(this.profilesWikiPath);

panel.add(new JLabel("Default flavour:"));
Vector<String> availableFlavours = new Vector<>();
SortedSet<String> sortedFlavours = new TreeSet<>();
for (PDFAFlavour flavour : Profiles.getVeraProfileDirectory().getPDFAFlavours()) {
String flavourReadableText = CheckerPanel.getFlavourReadableText(flavour);
sortedFlavours.add(flavourReadableText);
FLAVOURS_MAP.put(flavourReadableText, flavour);
}
availableFlavours.addAll(sortedFlavours);
Vector<String> availableFlavours = new Vector<>(sortedFlavours);
this.chooseDefaultFlavour = new JComboBox<>(availableFlavours);
this.chooseDefaultFlavour.setOpaque(true);
ChooseFlavourRenderer renderer = new ChooseFlavourRenderer();
Expand Down
14 changes: 7 additions & 7 deletions gui/src/main/java/org/verapdf/gui/ValidateWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class ValidateWorker extends SwingWorker<ValidateWorker.ValidateWorkerSummary, I
private static final String ERROR_IN_CREATING_TEMP_FILE = "Can't create temporary file for XML report"; //$NON-NLS-1$
private static final String ERROR_IN_OBTAINING_POLICY_FEATURES = "Can't obtain enabled features from policy files"; //$NON-NLS-1$

private List<File> pdfs;
private ValidationProfile customProfile;
private File policy;
private CheckerPanel parent;
private ConfigManager configManager;
private final List<File> pdfs;
private final ValidationProfile customProfile;
private final File policy;
private final CheckerPanel parent;
private final ConfigManager configManager;
private File xmlReport = null;
private File htmlReport = null;
private ValidateWorkerSummary validateWorkerSummary = null;
Expand Down Expand Up @@ -203,8 +203,8 @@ private static int countFailedPolicyJobs(File xmlReport) throws XPathExpressionE
return failedPolicyJobsCount;
}

public class ValidateWorkerSummary {
private BatchSummary batchSummary;
public static class ValidateWorkerSummary {
private final BatchSummary batchSummary;
private int policyNonCompliantJobCount = -1;

public ValidateWorkerSummary(BatchSummary batchSummary, int policyNonCompliantJobCount) {
Expand Down
2 changes: 1 addition & 1 deletion gui/src/main/java/org/verapdf/gui/utils/DialogUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public final class DialogUtils {

private DialogUtils() {
throw new AssertionError("Shoul'd never happen."); //$NON-NLS-1$
throw new AssertionError("Should never happen."); //$NON-NLS-1$
}

public static void errorDialog(final Component parent, final String message) {
Expand Down
Loading

0 comments on commit 93a12eb

Please sign in to comment.