From 9966e43759133b6a02dc15a1164c7eea7981517b Mon Sep 17 00:00:00 2001 From: Johanna Stuber Date: Thu, 11 Feb 2021 09:44:08 +0100 Subject: [PATCH] fix first/last step with let tree; use trash symbol to delete a sinlge typeAssumption --- .../content/typeinferencecontent/TypeInferenceView.java | 6 ++++-- .../edu/kit/typicalc/view/main/TypeAssumptionField.java | 9 ++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java index 3f66b81..c70e1f8 100644 --- a/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java +++ b/src/main/java/edu/kit/typicalc/view/content/typeinferencecontent/TypeInferenceView.java @@ -76,13 +76,15 @@ public class TypeInferenceView extends VerticalLayout @Override public void firstStepButton() { - currentStep = currentStep > tree.getStepCount() && tree.getStepCount() > 0 ? tree.getStepCount() - 1 : 0; + int treeEnd = treeNumbers.indexOf(tree.getStepCount() - 1); + currentStep = currentStep > treeEnd && tree.getStepCount() > 0 ? treeEnd : 0; refreshElements(); } @Override public void lastStepButton() { - currentStep = currentStep < tree.getStepCount() - 1 ? tree.getStepCount() - 1 : unification.getStepCount() - 1; + int treeEnd = treeNumbers.indexOf(tree.getStepCount() - 1); + currentStep = currentStep < treeEnd ? treeEnd : unification.getStepCount() - 1; refreshElements(); } diff --git a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java index a85073e..43443dd 100644 --- a/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java +++ b/src/main/java/edu/kit/typicalc/view/main/TypeAssumptionField.java @@ -1,9 +1,5 @@ package edu.kit.typicalc.view.main; -import java.util.function.Consumer; - -import org.apache.commons.lang3.StringUtils; - import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.icon.Icon; @@ -12,6 +8,9 @@ import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.i18n.LocaleChangeEvent; import com.vaadin.flow.i18n.LocaleChangeObserver; +import org.apache.commons.lang3.StringUtils; + +import java.util.function.Consumer; /** * Represents a single type assumption. Each TypeAssumptionField is displayed in the TypeAssumptionsArea. @@ -56,7 +55,7 @@ public class TypeAssumptionField extends HorizontalLayout implements LocaleChang variableInputField.setLabel(getTranslation("root.variable")); typeInputField = new TextField(); typeInputField.setLabel(getTranslation("root.type")); - Icon minusIcon = new Icon(VaadinIcon.MINUS_CIRCLE); + Icon minusIcon = new Icon(VaadinIcon.TRASH); minusIcon.setId(MINUS_ICON_ID); Button deleteButton = new Button(minusIcon, event -> deleteSelf.accept(this)); deleteButton.setId(ASS_DELETE_BUTTON_ID);