mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-09 21:05:46 -04:00
fixes a broken GUI test
This commit is contained in:
parent
723ec8b935
commit
1ae1b8d10e
@ -44,6 +44,7 @@ import java.io.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -181,7 +182,7 @@ public final class EditorFactory {
|
||||
public StringEditor(String value, Key<String> key) {
|
||||
if (key instanceof Key.LongString) {
|
||||
Key.LongString k = (Key.LongString) key;
|
||||
text = new JTextArea(k.getRows(), k.getColumns());
|
||||
text = addF1Traversal(new JTextArea(k.getRows(), k.getColumns()));
|
||||
final JScrollPane scrollPane = new JScrollPane(text);
|
||||
|
||||
if (k.getLineNumbers()) {
|
||||
@ -214,7 +215,7 @@ public final class EditorFactory {
|
||||
|
||||
setLabelAtTop(true);
|
||||
} else {
|
||||
text = new JTextField(10);
|
||||
text = addF1Traversal(new JTextField(10));
|
||||
compToAdd = text;
|
||||
}
|
||||
text.setText(value);
|
||||
@ -294,6 +295,20 @@ public final class EditorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds F1 as a focus traversal key to a text components.
|
||||
*
|
||||
* @param text The text component
|
||||
* @param <TC> the concrete type of the text component
|
||||
* @return the given text component
|
||||
*/
|
||||
public static <TC extends JTextComponent> TC addF1Traversal(TC text) {
|
||||
HashSet<AWTKeyStroke> set = new HashSet<>(text.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
|
||||
set.add(KeyStroke.getKeyStroke("F1"));
|
||||
text.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
|
||||
return text;
|
||||
}
|
||||
|
||||
private final static class IntegerEditor extends LabelEditor<Integer> {
|
||||
private static final IntegerValue[] DEFAULTS = createIntegerValues(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
|
||||
|
@ -24,6 +24,8 @@ import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static de.neemann.digital.gui.components.EditorFactory.addF1Traversal;
|
||||
|
||||
/**
|
||||
* Dialog to enter an expression.
|
||||
* Creates a new frame with a circuit generated from the entered expression.
|
||||
@ -42,7 +44,7 @@ public class ExpressionDialog extends JDialog {
|
||||
super(parent, Lang.get("expression"), false);
|
||||
|
||||
String exampleEquation = "(C ∨ B) ∧ (A ∨ C) ∧ (B ∨ !C) * (C + !A)";
|
||||
JTextArea text = new JTextArea(exampleEquation, 5, 40);
|
||||
JTextArea text = addF1Traversal(new JTextArea(exampleEquation, 5, 40));
|
||||
getContentPane().add(new JScrollPane(text), BorderLayout.CENTER);
|
||||
getContentPane().add(new JLabel(Lang.get("msg_enterAnExpression")), BorderLayout.NORTH);
|
||||
|
||||
|
@ -25,7 +25,8 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static de.neemann.digital.gui.components.EditorFactory.addF1Traversal;
|
||||
|
||||
/**
|
||||
* Dialog to show and edit the testing data source.
|
||||
@ -48,13 +49,9 @@ public class TestCaseDescriptionDialog extends JDialog {
|
||||
|
||||
String initialDataString = data.getDataString();
|
||||
|
||||
JTextArea text = new JTextArea(data.getDataString(), 30, 50);
|
||||
JTextArea text = addF1Traversal(new JTextArea(data.getDataString(), 30, 50));
|
||||
text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, Screen.getInstance().getFontSize()));
|
||||
|
||||
HashSet<AWTKeyStroke> set = new HashSet<>(text.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
|
||||
set.add(KeyStroke.getKeyStroke("F1"));
|
||||
text.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(text);
|
||||
getContentPane().add(scrollPane);
|
||||
scrollPane.setRowHeaderView(new TextLineNumber(text, 3));
|
||||
|
@ -212,7 +212,8 @@ public class TestInGUI extends TestCase {
|
||||
.press("ENTER")
|
||||
.press("control typed a")
|
||||
.type("a b + b c")
|
||||
.press("TAB", 2)
|
||||
.press("F1", 1)
|
||||
.press("TAB", 1)
|
||||
.press("SPACE")
|
||||
.delay(500)
|
||||
.add(new GuiTester.WindowCheck<>(Main.class,
|
||||
|
Loading…
x
Reference in New Issue
Block a user