mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
Avoid referring directly to RSyntaxTextArea, at least in the names
This commit is contained in:
parent
96b7c5ec6b
commit
03283bb098
@ -1,17 +1,17 @@
|
||||
package processing.app;
|
||||
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
|
||||
import javax.swing.undo.CannotRedoException;
|
||||
import javax.swing.undo.CannotUndoException;
|
||||
import javax.swing.undo.UndoableEdit;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
public class CaretAwareUndoableEdit implements UndoableEdit {
|
||||
|
||||
private final UndoableEdit undoableEdit;
|
||||
private final int caretPosition;
|
||||
|
||||
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, RSyntaxTextArea textArea) {
|
||||
public CaretAwareUndoableEdit(UndoableEdit undoableEdit, SketchTextArea textArea) {
|
||||
this.undoableEdit = undoableEdit;
|
||||
this.caretPosition = textArea.getCaretPosition();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ package processing.app;
|
||||
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
@ -65,7 +65,7 @@ public class AutoformatProducesOneUndoActionTest extends AbstractGUITest {
|
||||
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
||||
menuToolsAutoFormat.requireEnabled();
|
||||
|
||||
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture editor = window.textArea("editor");
|
||||
editor.setText(SOURCE_BEFORE);
|
||||
|
||||
editor.setCaretPosition(29); // right before the first // (double slash)
|
||||
|
@ -31,7 +31,7 @@ package processing.app;
|
||||
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@ -42,7 +42,7 @@ public class AutoformatSavesCaretPositionTest extends AbstractGUITest {
|
||||
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
||||
menuToolsAutoFormat.requireEnabled();
|
||||
|
||||
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture editor = window.textArea("editor");
|
||||
editor.setText("void setup() {\n" +
|
||||
" // put your setup code here, to run once:\n" +
|
||||
"\n" +
|
||||
|
@ -31,7 +31,7 @@ package processing.app;
|
||||
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@ -42,7 +42,7 @@ public class AutoformatTest extends AbstractGUITest {
|
||||
JMenuItemFixture menuToolsAutoFormat = window.menuItem("menuToolsAutoFormat");
|
||||
menuToolsAutoFormat.requireEnabled();
|
||||
|
||||
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture editor = window.textArea("editor");
|
||||
editor.setText("void setup() {\n" +
|
||||
"// put your setup code here, to run once:\n" +
|
||||
"int foo[] = { 1, 2, 3, 4, 5};\n" +
|
||||
|
@ -38,7 +38,7 @@ import org.fest.swing.edt.GuiQuery;
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
||||
|
||||
@ -47,7 +47,7 @@ public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
||||
JMenuItemFixture menuEditUndo = window.menuItem("menuEditUndo");
|
||||
menuEditUndo.requireDisabled();
|
||||
|
||||
RSyntaxTextAreaFixture jEditTextArea = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture jEditTextArea = window.textArea("editor");
|
||||
String previousText = jEditTextArea.getText();
|
||||
|
||||
jEditTextArea.selectAll();
|
||||
|
@ -33,7 +33,7 @@ import org.fest.swing.core.KeyPressInfo;
|
||||
import org.fest.swing.finder.WindowFinder;
|
||||
import org.fest.swing.fixture.DialogFixture;
|
||||
import org.junit.Test;
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
@ -44,7 +44,7 @@ public class HittingEscapeOnCloseConfirmationDialogTest extends AbstractGUITest
|
||||
|
||||
@Test
|
||||
public void shouldJustCloseTheDialog() throws Exception {
|
||||
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture editor = window.textArea("editor");
|
||||
editor.setText("test");
|
||||
|
||||
window.close();
|
||||
|
@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
public class ReduceIndentWith1CharOnLastLineTest extends AbstractGUITest {
|
||||
|
||||
@ -42,7 +42,7 @@ public class ReduceIndentWith1CharOnLastLineTest extends AbstractGUITest {
|
||||
public void shouldJustCloseTheDialog() throws Exception {
|
||||
JMenuItemFixture menuDecreaseIndent = window.menuItem("menuDecreaseIndent");
|
||||
|
||||
RSyntaxTextAreaFixture editor = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture editor = window.textArea("editor");
|
||||
editor.setText("void loop()\n{\n Serial.begin(9600)\n}");
|
||||
|
||||
editor.selectAll();
|
||||
|
@ -31,7 +31,7 @@ package processing.app;
|
||||
|
||||
import org.fest.swing.fixture.JMenuItemFixture;
|
||||
import org.junit.Test;
|
||||
import processing.app.helpers.RSyntaxTextAreaFixture;
|
||||
import processing.app.helpers.SketchTextAreaFixture;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@ -44,14 +44,14 @@ public class ReplacingTextGeneratesTwoUndoActionsTest extends AbstractGUITest {
|
||||
JMenuItemFixture menuEditRedo = window.menuItem("menuEditRedo");
|
||||
menuEditRedo.requireDisabled();
|
||||
|
||||
RSyntaxTextAreaFixture RSyntaxTextArea = window.RSyntaxTextArea("editor");
|
||||
SketchTextAreaFixture textArea = window.textArea("editor");
|
||||
|
||||
RSyntaxTextArea.setText("fake text");
|
||||
textArea.setText("fake text");
|
||||
|
||||
menuEditUndo.requireEnabled();
|
||||
menuEditUndo.click();
|
||||
|
||||
assertEquals("", RSyntaxTextArea.getText());
|
||||
assertEquals("", textArea.getText());
|
||||
|
||||
menuEditRedo.requireEnabled();
|
||||
menuEditRedo.click();
|
||||
|
@ -30,9 +30,8 @@
|
||||
package processing.app.helpers;
|
||||
|
||||
import org.fest.swing.fixture.FrameFixture;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
|
||||
import processing.app.Editor;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
|
||||
public class ArduinoFrameFixture extends FrameFixture {
|
||||
|
||||
@ -43,8 +42,8 @@ public class ArduinoFrameFixture extends FrameFixture {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture RSyntaxTextArea(String name) {
|
||||
return new RSyntaxTextAreaFixture(robot, (RSyntaxTextArea) this.robot.finder().find(new RSyntaxTextAreaComponentMatcher(name)));
|
||||
public SketchTextAreaFixture textArea(String name) {
|
||||
return new SketchTextAreaFixture(robot, (SketchTextArea) this.robot.finder().find(new SketchTextAreaComponentMatcher(name)));
|
||||
}
|
||||
|
||||
public Editor getEditor() {
|
||||
|
@ -34,24 +34,24 @@ import org.fest.swing.core.Robot;
|
||||
import org.fest.swing.driver.JComponentDriver;
|
||||
import org.fest.swing.edt.GuiActionRunner;
|
||||
import org.fest.swing.edt.GuiQuery;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
|
||||
public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||
public class SketchTextAreaComponentDriver extends JComponentDriver {
|
||||
|
||||
public RSyntaxTextAreaComponentDriver(Robot robot) {
|
||||
public SketchTextAreaComponentDriver(Robot robot) {
|
||||
super(robot);
|
||||
}
|
||||
|
||||
public void enterText(RSyntaxTextArea target, String text) {
|
||||
public void enterText(SketchTextArea target, String text) {
|
||||
focusAndWaitForFocusGain(target);
|
||||
robot.enterText(text);
|
||||
}
|
||||
|
||||
public void setText(final RSyntaxTextArea target, final String text) {
|
||||
public void setText(final SketchTextArea target, final String text) {
|
||||
focusAndWaitForFocusGain(target);
|
||||
GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||
GuiActionRunner.execute(new GuiQuery<SketchTextArea>() {
|
||||
|
||||
protected RSyntaxTextArea executeInEDT() {
|
||||
protected SketchTextArea executeInEDT() {
|
||||
target.setText(text);
|
||||
return target;
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
public String getText(final RSyntaxTextArea target) {
|
||||
public String getText(final SketchTextArea target) {
|
||||
focusAndWaitForFocusGain(target);
|
||||
return GuiActionRunner.execute(new GuiQuery<String>() {
|
||||
|
||||
@ -71,10 +71,10 @@ public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||
});
|
||||
}
|
||||
|
||||
public RSyntaxTextArea selectAll(final RSyntaxTextArea target) {
|
||||
return GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||
public SketchTextArea selectAll(final SketchTextArea target) {
|
||||
return GuiActionRunner.execute(new GuiQuery<SketchTextArea>() {
|
||||
|
||||
protected RSyntaxTextArea executeInEDT() {
|
||||
protected SketchTextArea executeInEDT() {
|
||||
target.selectAll();
|
||||
return target;
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||
});
|
||||
}
|
||||
|
||||
public Integer getCaretPosition(final RSyntaxTextArea target) {
|
||||
public Integer getCaretPosition(final SketchTextArea target) {
|
||||
focusAndWaitForFocusGain(target);
|
||||
return GuiActionRunner.execute(new GuiQuery<Integer>() {
|
||||
|
||||
@ -93,11 +93,11 @@ public class RSyntaxTextAreaComponentDriver extends JComponentDriver {
|
||||
});
|
||||
}
|
||||
|
||||
public void setCaretPosition(final RSyntaxTextArea target, final int caretPosition) {
|
||||
public void setCaretPosition(final SketchTextArea target, final int caretPosition) {
|
||||
focusAndWaitForFocusGain(target);
|
||||
GuiActionRunner.execute(new GuiQuery<RSyntaxTextArea>() {
|
||||
GuiActionRunner.execute(new GuiQuery<SketchTextArea>() {
|
||||
|
||||
protected RSyntaxTextArea executeInEDT() {
|
||||
protected SketchTextArea executeInEDT() {
|
||||
target.setCaretPosition(caretPosition);
|
||||
return target;
|
||||
}
|
@ -30,21 +30,21 @@
|
||||
|
||||
package processing.app.helpers;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import org.fest.swing.core.ComponentMatcher;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
|
||||
public class RSyntaxTextAreaComponentMatcher implements ComponentMatcher {
|
||||
import java.awt.*;
|
||||
|
||||
public class SketchTextAreaComponentMatcher implements ComponentMatcher {
|
||||
|
||||
private final String name;
|
||||
|
||||
public RSyntaxTextAreaComponentMatcher(String name) {
|
||||
public SketchTextAreaComponentMatcher(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Component component) {
|
||||
return component instanceof RSyntaxTextArea && name.equals(component.getName());
|
||||
return component instanceof SketchTextArea && name.equals(component.getName());
|
||||
}
|
||||
}
|
@ -32,51 +32,51 @@ package processing.app.helpers;
|
||||
|
||||
import org.fest.swing.core.Robot;
|
||||
import org.fest.swing.fixture.ComponentFixture;
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import processing.app.syntax.SketchTextArea;
|
||||
|
||||
public class RSyntaxTextAreaFixture extends ComponentFixture {
|
||||
public class SketchTextAreaFixture extends ComponentFixture {
|
||||
|
||||
private final RSyntaxTextAreaComponentDriver driver;
|
||||
private final SketchTextAreaComponentDriver driver;
|
||||
|
||||
public RSyntaxTextAreaFixture(Robot robot, Class type) {
|
||||
public SketchTextAreaFixture(Robot robot, Class type) {
|
||||
super(robot, type);
|
||||
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||
this.driver = new SketchTextAreaComponentDriver(robot);
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture(Robot robot, String name, Class type) {
|
||||
public SketchTextAreaFixture(Robot robot, String name, Class type) {
|
||||
super(robot, name, type);
|
||||
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||
this.driver = new SketchTextAreaComponentDriver(robot);
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture(Robot robot, RSyntaxTextArea target) {
|
||||
public SketchTextAreaFixture(Robot robot, SketchTextArea target) {
|
||||
super(robot, target);
|
||||
this.driver = new RSyntaxTextAreaComponentDriver(robot);
|
||||
this.driver = new SketchTextAreaComponentDriver(robot);
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture enterText(String text) {
|
||||
driver.enterText((RSyntaxTextArea) target, text);
|
||||
public SketchTextAreaFixture enterText(String text) {
|
||||
driver.enterText((SketchTextArea) target, text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture setText(String text) {
|
||||
driver.setText((RSyntaxTextArea) target, text);
|
||||
public SketchTextAreaFixture setText(String text) {
|
||||
driver.setText((SketchTextArea) target, text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return driver.getText((RSyntaxTextArea) target);
|
||||
return driver.getText((SketchTextArea) target);
|
||||
}
|
||||
|
||||
public RSyntaxTextAreaFixture selectAll() {
|
||||
driver.selectAll((RSyntaxTextArea) target);
|
||||
public SketchTextAreaFixture selectAll() {
|
||||
driver.selectAll((SketchTextArea) target);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getCaretPosition() {
|
||||
return driver.getCaretPosition((RSyntaxTextArea) target);
|
||||
return driver.getCaretPosition((SketchTextArea) target);
|
||||
}
|
||||
|
||||
public void setCaretPosition(int caretPosition) {
|
||||
driver.setCaretPosition((RSyntaxTextArea) target, caretPosition);
|
||||
driver.setCaretPosition((SketchTextArea) target, caretPosition);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user