mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-04 15:32:59 -08: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.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
@ -63,6 +64,16 @@ public class AbacusController implements PluginListener {
|
|||
*/
|
||||
private static final String ERR_EXCEPTION = "Exception Thrown";
|
||||
@FXML
|
||||
private TextArea macroOutputField;
|
||||
@FXML
|
||||
private Tab macroTab;
|
||||
@FXML
|
||||
private TextArea macroField;
|
||||
@FXML
|
||||
private Button inputButtonMacro;
|
||||
@FXML
|
||||
private Button stopButtonMacro;
|
||||
@FXML
|
||||
private TabPane coreTabPane;
|
||||
@FXML
|
||||
private Tab calculateTab;
|
||||
|
@ -90,7 +101,7 @@ public class AbacusController implements PluginListener {
|
|||
private ListView<ToggleablePlugin> enabledPluginView;
|
||||
@FXML
|
||||
private TextField computationLimitField;
|
||||
|
||||
private String macroOutputText;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private Abacus abacus;
|
||||
|
||||
private boolean stop;
|
||||
/**
|
||||
* Boolean which represents whether changes were made to the configuration.
|
||||
*/
|
||||
|
@ -276,6 +287,7 @@ public class AbacusController implements PluginListener {
|
|||
|
||||
@FXML
|
||||
public void performCalculation() {
|
||||
stop=false;
|
||||
inputButton.setDisable(true);
|
||||
stopButton.setDisable(false);
|
||||
calculationThread = new Thread(CALCULATION_RUNNABLE);
|
||||
|
@ -283,17 +295,51 @@ public class AbacusController implements PluginListener {
|
|||
computationLimitThread = new Thread(TIMER_RUNNABLE);
|
||||
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
|
||||
public void performStop(){
|
||||
if(calculationThread != null) {
|
||||
calculationThread.interrupt();
|
||||
calculationThread = null;
|
||||
stop = true;
|
||||
}
|
||||
if(computationLimitThread != null){
|
||||
computationLimitThread.interrupt();
|
||||
computationLimitThread = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -38,7 +38,7 @@ public class VariablePlugin extends Plugin {
|
|||
variableMap=new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
//variables = new ArrayList<>();
|
||||
|
|
|
@ -60,6 +60,62 @@
|
|||
</FlowPane>
|
||||
</GridPane>
|
||||
</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>
|
||||
</center>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user