/** * Validates form, PHPCS script and standards * * @return boolean */ boolean valid() { boolean isValid; // Gets PHPCS version, if "?" then, valid PHPCS were not found if (command.getVersion().equals("?")) { isValid = false; statusTextLabel.setText("Invalid CodeSniffer script"); } else { // Gets available standards List<String> availableStandards = command.getAvailableStandards(); options = new CodeSnifferOptions(availableStandards); if (availableStandards.isEmpty()) { isValid = false; statusTextLabel.setText("No code standards found"); } else { isValid = true; } } return isValid; }
/** Refresh current form Validates if PHPCS is installed and loads latest code standards */ void refresh() { String csPath = codeSnifferTextField.getText(); command.setShellScript(csPath); if (valid()) { store(true); statusTextLabel.setText("Activated"); statusTextLabel.setForeground(new Color(16, 110, 0)); inputBoxStandard.setEnabled(true); checkBoxShowWarnings.setEnabled(true); // Updates inputs with new provided data (if any) fillForm(); } else { inputBoxStandard.setEnabled(false); checkBoxShowWarnings.setEnabled(false); checkBoxShowWarnings.setSelected(false); statusTextLabel.setForeground(Color.RED); } versionTextLabel.setText(command.getVersion()); }