mirror of
https://github.com/DanilaFe/abacus
synced 2026-01-15 11:25:20 +00:00
Format code.
This commit is contained in:
@@ -36,7 +36,7 @@ public class AbacusController implements PluginListener {
|
||||
* The text for the dialog that is shown if settings haven't been applied.
|
||||
*/
|
||||
private static final String APPLY_MSG_TEXT = "You have made changes to the configuration, however, you haven't pressed \"Apply\". " +
|
||||
"The changes to the configuration will not be present in the calculator until \"Apply\" is pressed.";
|
||||
"The changes to the configuration will not be present in the calculator until \"Apply\" is pressed.";
|
||||
/**
|
||||
* Constant string that is displayed if the text could not be lexed or parsed.
|
||||
*/
|
||||
@@ -110,15 +110,15 @@ public class AbacusController implements PluginListener {
|
||||
* Alerts the user if the changes they made
|
||||
* have not yet been applied.
|
||||
*/
|
||||
private void alertIfApplyNeeded(boolean ignorePrevious){
|
||||
if(changesMade && (!reloadAlertShown || ignorePrevious)) {
|
||||
private void alertIfApplyNeeded(boolean ignorePrevious) {
|
||||
if (changesMade && (!reloadAlertShown || ignorePrevious)) {
|
||||
reloadAlertShown = true;
|
||||
reloadAlert.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize(){
|
||||
public void initialize() {
|
||||
Callback<TableColumn<HistoryModel, String>, TableCell<HistoryModel, String>> cellFactory =
|
||||
param -> new CopyableCell<>();
|
||||
Callback<ListView<ToggleablePlugin>, ListCell<ToggleablePlugin>> pluginCellFactory =
|
||||
@@ -150,7 +150,7 @@ public class AbacusController implements PluginListener {
|
||||
outputColumn.setCellFactory(cellFactory);
|
||||
outputColumn.setCellValueFactory(cell -> cell.getValue().outputProperty());
|
||||
coreTabPane.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if(oldValue.equals(settingsTab)) alertIfApplyNeeded(true);
|
||||
if (oldValue.equals(settingsTab)) alertIfApplyNeeded(true);
|
||||
});
|
||||
|
||||
abacus = new Abacus();
|
||||
@@ -167,16 +167,16 @@ public class AbacusController implements PluginListener {
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void performCalculation(){
|
||||
private void performCalculation() {
|
||||
inputButton.setDisable(true);
|
||||
TreeNode constructedTree = abacus.parseString(inputField.getText());
|
||||
if(constructedTree == null){
|
||||
if (constructedTree == null) {
|
||||
outputText.setText(ERR_SYNTAX);
|
||||
inputButton.setDisable(false);
|
||||
return;
|
||||
}
|
||||
NumberInterface evaluatedNumber = abacus.evaluateTree(constructedTree);
|
||||
if(evaluatedNumber == null){
|
||||
if (evaluatedNumber == null) {
|
||||
outputText.setText(ERR_EVAL);
|
||||
inputButton.setDisable(false);
|
||||
return;
|
||||
@@ -189,7 +189,7 @@ public class AbacusController implements PluginListener {
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void performSaveAndReload(){
|
||||
private void performSaveAndReload() {
|
||||
performSave();
|
||||
performReload();
|
||||
changesMade = false;
|
||||
@@ -197,19 +197,19 @@ public class AbacusController implements PluginListener {
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void performReload(){
|
||||
private void performReload() {
|
||||
alertIfApplyNeeded(true);
|
||||
abacus.getPluginManager().reload();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void performSave(){
|
||||
private void performSave() {
|
||||
Configuration configuration = abacus.getConfiguration();
|
||||
configuration.setNumberImplementation(numberImplementationBox.getSelectionModel().getSelectedItem());
|
||||
Set<String> disabledPlugins = configuration.getDisabledPlugins();
|
||||
disabledPlugins.clear();
|
||||
for(ToggleablePlugin pluginEntry : enabledPlugins){
|
||||
if(!pluginEntry.isEnabled()) disabledPlugins.add(pluginEntry.getClassName());
|
||||
for (ToggleablePlugin pluginEntry : enabledPlugins) {
|
||||
if (!pluginEntry.isEnabled()) disabledPlugins.add(pluginEntry.getClassName());
|
||||
}
|
||||
configuration.saveTo(Abacus.CONFIG_FILE);
|
||||
changesMade = false;
|
||||
@@ -224,7 +224,7 @@ public class AbacusController implements PluginListener {
|
||||
String actualImplementation = configuration.getNumberImplementation();
|
||||
String toSelect = (numberImplementationOptions.contains(actualImplementation)) ? actualImplementation : "<default>";
|
||||
numberImplementationBox.getSelectionModel().select(toSelect);
|
||||
for(Class<?> pluginClass : abacus.getPluginManager().getLoadedPluginClasses()){
|
||||
for (Class<?> pluginClass : abacus.getPluginManager().getLoadedPluginClasses()) {
|
||||
String fullName = pluginClass.getName();
|
||||
ToggleablePlugin plugin = new ToggleablePlugin(!disabledPlugins.contains(fullName), fullName);
|
||||
plugin.enabledProperty().addListener(e -> changesMade = true);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.awt.datatransfer.StringSelection;
|
||||
/**
|
||||
* A cell that copies its value to the clipboard
|
||||
* when double clicked.
|
||||
*
|
||||
* @param <S> The type of the table view generic type.
|
||||
* @param <T> The type of the value contained in the cell.
|
||||
*/
|
||||
@@ -17,9 +18,9 @@ public class CopyableCell<S, T> extends TableCell<S, T> {
|
||||
/**
|
||||
* Creates a new copyable cell.
|
||||
*/
|
||||
public CopyableCell(){
|
||||
public CopyableCell() {
|
||||
addEventFilter(MouseEvent.MOUSE_CLICKED, event -> {
|
||||
if(event.getClickCount() == 2){
|
||||
if (event.getClickCount() == 2) {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard()
|
||||
.setContents(new StringSelection(getText()), null);
|
||||
}
|
||||
|
||||
@@ -26,11 +26,12 @@ public class HistoryModel {
|
||||
|
||||
/**
|
||||
* Creates a new history model with the given variables.
|
||||
* @param input the user input
|
||||
*
|
||||
* @param input the user input
|
||||
* @param parsed the parsed input
|
||||
* @param output the program output.
|
||||
*/
|
||||
public HistoryModel(String input, String parsed, String output){
|
||||
public HistoryModel(String input, String parsed, String output) {
|
||||
this.input = new SimpleStringProperty();
|
||||
this.parsed = new SimpleStringProperty();
|
||||
this.output = new SimpleStringProperty();
|
||||
@@ -41,13 +42,16 @@ public class HistoryModel {
|
||||
|
||||
/**
|
||||
* Gets the input property.
|
||||
*
|
||||
* @return the input property.
|
||||
*/
|
||||
public StringProperty inputProperty() {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input.
|
||||
*
|
||||
* @return the input.
|
||||
*/
|
||||
public String getInput() {
|
||||
@@ -56,13 +60,16 @@ public class HistoryModel {
|
||||
|
||||
/**
|
||||
* Gets the parsed input property.
|
||||
*
|
||||
* @return the parsed input property.
|
||||
*/
|
||||
public StringProperty parsedProperty() {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed input.
|
||||
*
|
||||
* @return the parsed input.
|
||||
*/
|
||||
public String getParsed() {
|
||||
@@ -71,13 +78,16 @@ public class HistoryModel {
|
||||
|
||||
/**
|
||||
* Gets the output property.
|
||||
*
|
||||
* @return the output property.
|
||||
*/
|
||||
public StringProperty outputProperty() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the program output.
|
||||
*
|
||||
* @return the output.
|
||||
*/
|
||||
public String getOutput() {
|
||||
|
||||
@@ -20,10 +20,11 @@ public class ToggleablePlugin {
|
||||
|
||||
/**
|
||||
* Creates a new toggleable plugin with the given properties.
|
||||
* @param enabled the enabled / disabled state at the beginning.
|
||||
*
|
||||
* @param enabled the enabled / disabled state at the beginning.
|
||||
* @param className the name of the class this plugin toggles.
|
||||
*/
|
||||
public ToggleablePlugin(boolean enabled, String className){
|
||||
public ToggleablePlugin(boolean enabled, String className) {
|
||||
this.enabled = new SimpleBooleanProperty();
|
||||
this.enabled.setValue(enabled);
|
||||
this.className = className;
|
||||
@@ -31,6 +32,7 @@ public class ToggleablePlugin {
|
||||
|
||||
/**
|
||||
* Gets the enabled property of this plugin.
|
||||
*
|
||||
* @return the enabled property.
|
||||
*/
|
||||
public BooleanProperty enabledProperty() {
|
||||
@@ -39,6 +41,7 @@ public class ToggleablePlugin {
|
||||
|
||||
/**
|
||||
* Checks if this plugin entry should be enabled.
|
||||
*
|
||||
* @return whether this plugin will be enabled.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
@@ -47,6 +50,7 @@ public class ToggleablePlugin {
|
||||
|
||||
/**
|
||||
* Gets the class name this plugin toggles.
|
||||
*
|
||||
* @return the class name that should be disabled.
|
||||
*/
|
||||
public String getClassName() {
|
||||
|
||||
Reference in New Issue
Block a user