Skip to content

Commit

Permalink
automate typing of text
Browse files Browse the repository at this point in the history
  • Loading branch information
zavfel committed Oct 24, 2016
1 parent 40105f8 commit 6a2022a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/harmony/mastermind/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@
import harmony.mastermind.logic.commands.ListCommand;
import harmony.mastermind.model.UserPrefs;
import harmony.mastermind.model.task.ReadOnlyTask;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.Transition;
import javafx.application.Platform;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.Node;
Expand All @@ -56,6 +62,7 @@
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
* The Main Window. Provides the basic application layout containing a menu bar
Expand Down Expand Up @@ -84,6 +91,7 @@ public class MainWindow extends UiPart {
private static final KeyCombination CTRL_THREE = new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.CONTROL_DOWN);
private static final KeyCombination CTRL_FOUR = new KeyCodeCombination(KeyCode.DIGIT4, KeyCombination.CONTROL_DOWN);
private static final KeyCombination CTRL_FIVE = new KeyCodeCombination(KeyCode.DIGIT5, KeyCombination.CONTROL_DOWN);
private static final KeyCombination CTRL_ZERO = new KeyCodeCombination(KeyCode.DIGIT0, KeyCombination.CONTROL_DOWN);

public static final int MIN_HEIGHT = 600;
public static final int MIN_WIDTH = 460;
Expand Down Expand Up @@ -736,6 +744,8 @@ private void handleKeyPressed(KeyEvent event) {
updateTab(ListCommand.MESSAGE_SUCCESS_DEADLINES);
}else if (CTRL_FIVE.match(event)) {
updateTab(ListCommand.MESSAGE_SUCCESS_ARCHIVES);
}else if (CTRL_ZERO.match(event)) {
addTask.play();
}
}

Expand Down Expand Up @@ -880,4 +890,19 @@ private void restoreNextCommandText() {
commandField.setText("");
}
}

//template for automating demo
final Animation addTask = new Transition() {
{
setCycleDuration(Duration.millis(4000));
}
String content = "add r/'weekly 2 'meet up with school mates' sd/'friday 6pm' ed/'friday 10pm'";

protected void interpolate(double frac) {
final int length = content.length();
final int n = Math.round(length * (float) frac);
commandField.setText(content.substring(0, n));
commandField.positionCaret(n);
}
};
}

0 comments on commit 6a2022a

Please sign in to comment.