package de.wwwu.awolf.view.services; import de.wwwu.awolf.model.Line; import de.wwwu.awolf.presenter.Presenter; import de.wwwu.awolf.presenter.algorithms.Algorithm; import javafx.beans.property.BooleanProperty; import javafx.concurrent.Service; import javafx.concurrent.Task; public class ButtonClickService extends Service { private final BooleanProperty startButtonDisabled; private Algorithm.Type type; public ButtonClickService(Algorithm.Type algorithmType, BooleanProperty startButtonDisabled) { this.startButtonDisabled = startButtonDisabled; this.type = algorithmType; } @Override protected Task createTask() { return new Task() { @Override protected Boolean call() throws Exception { try { Line line = Presenter.getInstance().executeAlgorithmByType(type, startButtonDisabled); if (line != null) { return true; } } catch (IllegalArgumentException e) { return true; } return false; } }; } }