From e3f43c68edb209a7d6f5cb954f45ba794d5adc7d Mon Sep 17 00:00:00 2001 From: shubhamr837 Date: Wed, 31 Mar 2021 12:13:44 +0530 Subject: [PATCH] Add method in enum to get boolean value of button state --- .../org/opendatakit/suitcase/ui/PullPanel.java | 6 +----- .../org/opendatakit/suitcase/ui/PushPanel.java | 16 ++-------------- .../opendatakit/suitcase/utils/ButtonState.java | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/opendatakit/suitcase/ui/PullPanel.java b/src/main/java/org/opendatakit/suitcase/ui/PullPanel.java index 32083a2..ba7d00b 100644 --- a/src/main/java/org/opendatakit/suitcase/ui/PullPanel.java +++ b/src/main/java/org/opendatakit/suitcase/ui/PullPanel.java @@ -126,11 +126,7 @@ public void actionPerformed(ActionEvent e) { } public void setsPullButtonState(ButtonState pullButtonState) { - if (pullButtonState == ButtonState.ENABLED) { - sPullButton.setEnabled(true); - } else if (pullButtonState == ButtonState.DISABLED) { - sPullButton.setEnabled(false); - } + sPullButton.setEnabled(pullButtonState.getButtonStateBooleanValue()); } @Override diff --git a/src/main/java/org/opendatakit/suitcase/ui/PushPanel.java b/src/main/java/org/opendatakit/suitcase/ui/PushPanel.java index cff0bb9..4cab106 100644 --- a/src/main/java/org/opendatakit/suitcase/ui/PushPanel.java +++ b/src/main/java/org/opendatakit/suitcase/ui/PushPanel.java @@ -136,20 +136,8 @@ public void actionPerformed(ActionEvent e) { } public void setButtonsState(ButtonState pushButtonState , ButtonState resetButtonState) { - if(pushButtonState== ButtonState.ENABLED) { - sPushButton.setEnabled(true); - } - else if(pushButtonState== ButtonState.DISABLED) - { - sPushButton.setEnabled(false); - } - if(resetButtonState== ButtonState.ENABLED) { - sResetButton.setEnabled(true); - } - else if(resetButtonState== ButtonState.DISABLED) - { - sResetButton.setEnabled(false); - } + sPushButton.setEnabled(pushButtonState.getButtonStateBooleanValue()); + sResetButton.setEnabled(resetButtonState.getButtonStateBooleanValue()); } @Override diff --git a/src/main/java/org/opendatakit/suitcase/utils/ButtonState.java b/src/main/java/org/opendatakit/suitcase/utils/ButtonState.java index 908b666..633090b 100644 --- a/src/main/java/org/opendatakit/suitcase/utils/ButtonState.java +++ b/src/main/java/org/opendatakit/suitcase/utils/ButtonState.java @@ -1,6 +1,16 @@ package org.opendatakit.suitcase.utils; public enum ButtonState { - ENABLED, - DISABLED + ENABLED(true), + DISABLED(false); + + boolean state; + + public boolean getButtonStateBooleanValue() { + return this.state; + } + + ButtonState(boolean b) { + this.state = b; + } }