Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(spoon-visualiser): bump Interacto to use the latest version on Central #3861

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spoon-visualisation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<dependency>
<groupId>io.github.interacto</groupId>
<artifactId>interacto-javafx</artifactId>
<version>3.4</version>
<version>4.3.1</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
Expand Down
1 change: 1 addition & 0 deletions spoon-visualisation/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
requires javafx.controls;
requires org.eclipse.jdt.core;
requires org.jetbrains.annotations;
requires java.desktop;

exports spoon.visualisation to javafx.graphics;
exports spoon.visualisation.instrument to javafx.fxml;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public void initialize(final URL url, final ResourceBundle res) {
@Override
protected void configureBindings() {
// On text change, the spoon tree is rebuilt
textInputBinder(i -> new UpdateSpoonTree(spoonAST, hideImplicit.isSelected(), "", treeLevel.getValue()))
textInputBinder()
.toProduce(i -> new UpdateSpoonTree(spoonAST, hideImplicit.isSelected(), "", treeLevel.getValue()))
.on(spoonCode)
.then((i, c) -> c.setCode(i.getWidget().getText()))
.bind();
Expand All @@ -101,17 +102,21 @@ protected void configureBindings() {
() -> new UpdateSpoonTree(spoonAST, hideImplicit.isSelected(), spoonCode.getText(), treeLevel.getValue());

// Checking the checkbox hides or shows the implicit elements
checkboxBinder(cmdsupplier)
checkboxBinder()
.toProduce(cmdsupplier)
.on(hideImplicit)
.bind();

// Selecting an item of the combo box recomputes the spoon tree using the new analysis level
comboboxBinder(cmdsupplier)
comboboxBinder()
.toProduce(cmdsupplier)
.on(treeLevel)
.bind();

// Clicking on a tree item selects the corresponding Java code
nodeBinder(new Click(), i -> {
nodeBinder()
.usingInteraction(Click::new)
.toProduce(i -> {
final SpoonTreeItem item = i.getSrcObject()
.filter(o -> o.getParent() instanceof TreeCell)
.map(o -> ((SpoonTreeItem) ((TreeCell<?>) o.getParent()).getTreeItem()))
Expand All @@ -124,12 +129,15 @@ protected void configureBindings() {

// Clicking in the text area (ie changing the caret position) selects (when relevant)
// the corresponding item in the Spoon tree
nodeBinder(new Click(), i -> new SelectCodeItem(spoonCode.getCaretPosition(), spoonAST))
nodeBinder()
.usingInteraction(Click::new)
.toProduce(i -> new SelectCodeItem(spoonCode.getCaretPosition(), spoonAST))
.on(spoonCode)
.bind();

// Clicking on the save button saves in a text file the text version of the Spoon tree
buttonBinder(i -> new SaveTreeText(getFileChooser().showSaveDialog(null), hideImplicit.isSelected(),
buttonBinder()
.toProduce(i -> new SaveTreeText(getFileChooser().showSaveDialog(null), hideImplicit.isSelected(),
spoonCode.getText(), treeLevel.getValue()))
.on(save)
.bind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package spoon.visualisation.spoon;

import io.github.interacto.command.library.OpenWebPage;
import java.awt.Desktop;
import java.net.URI;
import java.util.List;
import javafx.scene.control.Hyperlink;
Expand Down Expand Up @@ -72,8 +73,7 @@ TextFlow createStdTextFlow(final TreeNodeLabel label) {
// Clicking on the link opens the doc
// 'new Thread' because otherwise the app freezes (run in the UI thread)
classLink.setOnAction(evt -> new Thread(() -> {
final OpenWebPage cmd = new OpenWebPage();
cmd.setUri(URI.create(url));
final OpenWebPage cmd = new OpenWebPage(Desktop.getDesktop(), URI.create(url));
if(cmd.canDo()) {
cmd.doIt();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package spoon.visualisation.instrument;

import io.github.interacto.command.CmdHandler;
import io.github.interacto.command.CommandsRegistry;
import io.github.interacto.command.library.OpenWebPage;
import io.github.interacto.fsm.TimeoutTransition;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -105,8 +103,7 @@ void start(final Stage stage) throws IOException {

@BeforeEach
void setUp(final FxRobot robot) {
CommandsRegistry.INSTANCE.clear();
CommandsRegistry.INSTANCE.removeAllHandlers();
CommandsRegistry.getInstance().clear();
spoonAST = robot.lookup("#spoonAST").query();
spoonCode = robot.lookup("#spoonCode").query();
treeLevel = robot.lookup("#treeLevel").query();
Expand Down Expand Up @@ -207,22 +204,6 @@ void testNumberOfHyperlinks(final FxRobot robot) {
AssertionsForClassTypes.assertThat(hyperlinks.size()).isEqualTo(2);
}

@Disabled("Does not work on headless server")
@Test
void testClickHyperlink(final FxRobot robot) {
robot.clickOn(spoonCode).write("class Foo { }");
waitForTimeoutTransitions();
final CmdHandler handler = Mockito.mock(CmdHandler.class);
CommandsRegistry.INSTANCE.addHandler(handler);
final Set<Node> hyperlinks = robot.lookup(CoreMatchers.instanceOf(Hyperlink.class)).queryAll();
robot.clickOn(hyperlinks.iterator().next());
WaitForAsyncUtils.waitForFxEvents();
waitForThread("OPEN_SPOON_DOC_THREAD");

Mockito.verify(handler, Mockito.times(1)).onCmdExecuted(Mockito.any(OpenWebPage.class));
}


@Disabled("Does not work on headless servers")
@Test
void testSaveText(final FxRobot robot, @TempDir final Path tempDir) throws IOException {
Expand Down Expand Up @@ -451,4 +432,4 @@ public Stub2<CtClass<String>> bar() {
return null;
}

}
}