From 0cda05d8477d7c7a38c299b156e7d22c02caa0db Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 28 Feb 2021 11:32:50 +0100 Subject: [PATCH] put disabling logic into refreshElements() --- .../TypeInferenceView.java | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 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 733315d..67b206e 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 @@ -87,6 +87,19 @@ public class TypeInferenceView extends VerticalLayout private void refreshElements() { unification.showStep(currentStep); tree.showStep(treeNumbers.get(currentStep)); + + if (currentStep == 0) { + controlPanel.setEnabledFirstStep(false); + controlPanel.setEnabledPreviousStep(false); + } else if (currentStep == unification.getStepCount() - 1) { + controlPanel.setEnabledNextStep(false); + controlPanel.setEnabledLastStep(false); + } else { + controlPanel.setEnabledNextStep(true); + controlPanel.setEnabledLastStep(true); + controlPanel.setEnabledFirstStep(true); + controlPanel.setEnabledPreviousStep(true); + } } @Override @@ -94,12 +107,6 @@ public class TypeInferenceView extends VerticalLayout int treeEnd = treeNumbers.indexOf(tree.getStepCount() - 1); currentStep = currentStep > treeEnd && tree.getStepCount() > 0 ? treeEnd : 0; refreshElements(); - if (currentStep == 0) { - controlPanel.setEnabledFirstStep(false); - controlPanel.setEnabledPreviousStep(false); - } - controlPanel.setEnabledNextStep(true); - controlPanel.setEnabledLastStep(true); } @Override @@ -107,12 +114,6 @@ public class TypeInferenceView extends VerticalLayout int treeEnd = treeNumbers.indexOf(tree.getStepCount() - 1); currentStep = currentStep < treeEnd ? treeEnd : unification.getStepCount() - 1; refreshElements(); - if (currentStep == unification.getStepCount() - 1) { - controlPanel.setEnabledNextStep(false); - controlPanel.setEnabledLastStep(false); - } - controlPanel.setEnabledFirstStep(true); - controlPanel.setEnabledPreviousStep(true); } @@ -120,24 +121,12 @@ public class TypeInferenceView extends VerticalLayout public void nextStepButton() { currentStep = currentStep < unification.getStepCount() - 1 ? currentStep + 1 : currentStep; refreshElements(); - if (currentStep == unification.getStepCount() - 1) { - controlPanel.setEnabledNextStep(false); - controlPanel.setEnabledLastStep(false); - } - controlPanel.setEnabledFirstStep(true); - controlPanel.setEnabledPreviousStep(true); } @Override public void previousStepButton() { currentStep = currentStep > 0 ? currentStep - 1 : currentStep; refreshElements(); - if (currentStep == 0) { - controlPanel.setEnabledFirstStep(false); - controlPanel.setEnabledPreviousStep(false); - } - controlPanel.setEnabledNextStep(true); - controlPanel.setEnabledLastStep(true); } @Override