mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-04 18:08:31 -08:00
Add configuration object to Abacus.
This commit is contained in:
parent
acf3d85584
commit
1ce9fc6b1c
|
@ -1,5 +1,6 @@
|
||||||
package org.nwapw.abacus;
|
package org.nwapw.abacus;
|
||||||
|
|
||||||
|
import org.nwapw.abacus.config.ConfigurationObject;
|
||||||
import org.nwapw.abacus.function.Operator;
|
import org.nwapw.abacus.function.Operator;
|
||||||
import org.nwapw.abacus.number.NumberInterface;
|
import org.nwapw.abacus.number.NumberInterface;
|
||||||
import org.nwapw.abacus.plugin.ClassFinder;
|
import org.nwapw.abacus.plugin.ClassFinder;
|
||||||
|
@ -12,6 +13,7 @@ import org.nwapw.abacus.tree.TreeNode;
|
||||||
import org.nwapw.abacus.window.Window;
|
import org.nwapw.abacus.window.Window;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +23,11 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class Abacus implements PluginListener {
|
public class Abacus implements PluginListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The file used for saving and loading configuration.
|
||||||
|
*/
|
||||||
|
public static final File CONFIG_FILE = new File("config.yml");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main Abacus UI.
|
* The main Abacus UI.
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +47,10 @@ public class Abacus implements PluginListener {
|
||||||
* The reducer used to evaluate the tree.
|
* The reducer used to evaluate the tree.
|
||||||
*/
|
*/
|
||||||
private NumberReducer numberReducer;
|
private NumberReducer numberReducer;
|
||||||
|
/**
|
||||||
|
* The configuration loaded from a file.
|
||||||
|
*/
|
||||||
|
private ConfigurationObject configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the Abacus calculator.
|
* Creates a new instance of the Abacus calculator.
|
||||||
|
@ -48,6 +59,8 @@ public class Abacus implements PluginListener {
|
||||||
pluginManager = new PluginManager(this);
|
pluginManager = new PluginManager(this);
|
||||||
mainUi = new Window(this);
|
mainUi = new Window(this);
|
||||||
numberReducer = new NumberReducer(this);
|
numberReducer = new NumberReducer(this);
|
||||||
|
configuration = new ConfigurationObject(CONFIG_FILE);
|
||||||
|
configuration.save(CONFIG_FILE);
|
||||||
|
|
||||||
pluginManager.addListener(this);
|
pluginManager.addListener(this);
|
||||||
pluginManager.addInstantiated(new StandardPlugin(pluginManager));
|
pluginManager.addInstantiated(new StandardPlugin(pluginManager));
|
||||||
|
@ -95,6 +108,14 @@ public class Abacus implements PluginListener {
|
||||||
return numberReducer;
|
return numberReducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the configuration object associated with this instance.
|
||||||
|
* @return the configuration object.
|
||||||
|
*/
|
||||||
|
public ConfigurationObject getConfiguration() {
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a string into a tree structure using the main
|
* Parses a string into a tree structure using the main
|
||||||
* tree builder.
|
* tree builder.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user