mirror of
https://github.com/DanilaFe/abacus
synced 2025-04-21 16:18:44 -07:00
add macros
This commit is contained in:
parent
b2a20226d3
commit
18b252afb1
@ -20,6 +20,7 @@ import org.nwapw.abacus.tree.TreeNode;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +64,16 @@ public class AbacusController implements PluginListener {
|
|||||||
*/
|
*/
|
||||||
private static final String ERR_EXCEPTION = "Exception Thrown";
|
private static final String ERR_EXCEPTION = "Exception Thrown";
|
||||||
@FXML
|
@FXML
|
||||||
|
private TextArea macroOutputField;
|
||||||
|
@FXML
|
||||||
|
private Tab macroTab;
|
||||||
|
@FXML
|
||||||
|
private TextArea macroField;
|
||||||
|
@FXML
|
||||||
|
private Button inputButtonMacro;
|
||||||
|
@FXML
|
||||||
|
private Button stopButtonMacro;
|
||||||
|
@FXML
|
||||||
private TabPane coreTabPane;
|
private TabPane coreTabPane;
|
||||||
@FXML
|
@FXML
|
||||||
private Tab calculateTab;
|
private Tab calculateTab;
|
||||||
@ -90,7 +101,7 @@ public class AbacusController implements PluginListener {
|
|||||||
private ListView<ToggleablePlugin> enabledPluginView;
|
private ListView<ToggleablePlugin> enabledPluginView;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField computationLimitField;
|
private TextField computationLimitField;
|
||||||
|
private String macroOutputText;
|
||||||
/**
|
/**
|
||||||
* The list of history entries, created by the users.
|
* The list of history entries, created by the users.
|
||||||
*/
|
*/
|
||||||
@ -112,7 +123,7 @@ public class AbacusController implements PluginListener {
|
|||||||
* The abacus instance used for changing the plugin configuration.
|
* The abacus instance used for changing the plugin configuration.
|
||||||
*/
|
*/
|
||||||
private Abacus abacus;
|
private Abacus abacus;
|
||||||
|
private boolean stop;
|
||||||
/**
|
/**
|
||||||
* Boolean which represents whether changes were made to the configuration.
|
* Boolean which represents whether changes were made to the configuration.
|
||||||
*/
|
*/
|
||||||
@ -276,6 +287,7 @@ public class AbacusController implements PluginListener {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void performCalculation() {
|
public void performCalculation() {
|
||||||
|
stop=false;
|
||||||
inputButton.setDisable(true);
|
inputButton.setDisable(true);
|
||||||
stopButton.setDisable(false);
|
stopButton.setDisable(false);
|
||||||
calculationThread = new Thread(CALCULATION_RUNNABLE);
|
calculationThread = new Thread(CALCULATION_RUNNABLE);
|
||||||
@ -283,17 +295,51 @@ public class AbacusController implements PluginListener {
|
|||||||
computationLimitThread = new Thread(TIMER_RUNNABLE);
|
computationLimitThread = new Thread(TIMER_RUNNABLE);
|
||||||
computationLimitThread.start();
|
computationLimitThread.start();
|
||||||
}
|
}
|
||||||
|
Runnable macroCalculate = new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
stop=false;
|
||||||
|
inputButtonMacro.setDisable(true);
|
||||||
|
stopButtonMacro.setDisable(false);
|
||||||
|
Scanner macroScanner = new Scanner(macroField.getText());
|
||||||
|
String next = "!";
|
||||||
|
macroOutputText="";
|
||||||
|
while(!stop&¯oScanner.hasNextLine()) {
|
||||||
|
next = macroScanner.nextLine().trim();
|
||||||
|
if(next.equals(""))
|
||||||
|
break;
|
||||||
|
inputField.setText(next);
|
||||||
|
calculationThread = new Thread(CALCULATION_RUNNABLE);
|
||||||
|
calculationThread.start();
|
||||||
|
computationLimitThread = new Thread(TIMER_RUNNABLE);
|
||||||
|
computationLimitThread.start();
|
||||||
|
while(calculationThread.isAlive()){}
|
||||||
|
//long b = System.currentTimeMillis();
|
||||||
|
//while(System.currentTimeMillis()-b<10000){}
|
||||||
|
macroOutputText +=outputText.getText()+"\n";
|
||||||
|
//next = macroScanner.nextLine().trim();
|
||||||
|
|
||||||
|
}
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
macroOutputField.setText(macroOutputText);
|
||||||
|
inputButtonMacro.setDisable(false);
|
||||||
|
stopButtonMacro.setDisable(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@FXML
|
||||||
|
public void macroCalculation(){
|
||||||
|
Thread macroThread = new Thread(macroCalculate);
|
||||||
|
macroThread.start();
|
||||||
|
}
|
||||||
@FXML
|
@FXML
|
||||||
public void performStop(){
|
public void performStop(){
|
||||||
if(calculationThread != null) {
|
if(calculationThread != null) {
|
||||||
calculationThread.interrupt();
|
calculationThread.interrupt();
|
||||||
calculationThread = null;
|
calculationThread = null;
|
||||||
|
stop = true;
|
||||||
}
|
}
|
||||||
if(computationLimitThread != null){
|
|
||||||
computationLimitThread.interrupt();
|
|
||||||
computationLimitThread = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -60,6 +60,62 @@
|
|||||||
</FlowPane>
|
</FlowPane>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab fx:id="macroTab" text="Macros" closable="false">
|
||||||
|
<BorderPane>
|
||||||
|
<padding>
|
||||||
|
<Insets top="10" bottom="10" left="10" right="10"/>
|
||||||
|
</padding>
|
||||||
|
<center>
|
||||||
|
<BorderPane>
|
||||||
|
<center>
|
||||||
|
<ScrollPane hbarPolicy="NEVER" vbarPolicy="NEVER" prefWidth="50" fitToWidth="true">
|
||||||
|
<SplitPane prefHeight="Infinity" >
|
||||||
|
<BorderPane prefHeight="Infinity">
|
||||||
|
<center>
|
||||||
|
<TextArea fx:id="macroField" wrapText="false" prefHeight="Infinity"/>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
|
<BorderPane prefHeight="Infinity">
|
||||||
|
<center>
|
||||||
|
<TextArea fx:id="macroOutputField" wrapText="false" text="aaa
aaaaa" editable="false" prefHeight="Infinity"/>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
|
</SplitPane>
|
||||||
|
</ScrollPane>
|
||||||
|
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<VBox>
|
||||||
|
|
||||||
|
<Button fx:id="inputButtonMacro" text="Calculate"
|
||||||
|
onAction="#macroCalculation" maxWidth="Infinity"/>
|
||||||
|
<Button fx:id="stopButtonMacro" text="Stop" onAction="#performStop" maxWidth="Infinity"/>
|
||||||
|
</VBox>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
||||||
|
<!--
|
||||||
|
<GridPane>
|
||||||
|
<padding>
|
||||||
|
<Insets top="10" bottom="10" left="10" right="10"/>
|
||||||
|
</padding>
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints percentWidth="100.0"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints percentHeight="85.0"/>
|
||||||
|
<RowConstraints/>
|
||||||
|
<RowConstraints/>
|
||||||
|
</rowConstraints>
|
||||||
|
<TextArea fx:id="macroField" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
|
||||||
|
<Button fx:id="inputButtonMacro" text="Calculate" maxWidth="Infinity"
|
||||||
|
onAction="#macroCalculation" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||||
|
<Button fx:id="stopButtonMacro" text="Stop" onAction="#performStop" maxWidth="Infinity"
|
||||||
|
disable="true" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||||
|
</GridPane>
|
||||||
|
-->
|
||||||
|
</Tab>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user