Skip to content

Commit

Permalink
Add method in enum to get boolean value of button state
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubhamr837 committed Mar 31, 2021
1 parent efa0e49 commit e3f43c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
6 changes: 1 addition & 5 deletions src/main/java/org/opendatakit/suitcase/ui/PullPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions src/main/java/org/opendatakit/suitcase/ui/PushPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/opendatakit/suitcase/utils/ButtonState.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit e3f43c6

Please sign in to comment.