Skip to content

Commit

Permalink
Fix init settings shown in UI are misleading (do not match default) #283
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed May 10, 2020
1 parent d8f6cee commit 70a77bd
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/main/java/gitflow/ui/GitflowInitOptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Arrays;
import java.util.List;

/**
Expand All @@ -30,13 +31,14 @@ public class GitflowInitOptionsDialog extends DialogWrapper {
private JTextField versionPrefixTextField;
private JTextField bugfixPrefixTextField;

public GitflowInitOptionsDialog(Project project, List<String> localBranches) {
private List<String> localBranches;

public GitflowInitOptionsDialog(Project project, List<String> _localBranches) {
super(project);
localBranches = _localBranches;

setTitle("Options for gitflow init");

productionBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
developmentBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
setLocalBranchesComboBox(false);

init();
useNonDefaultConfigurationCheckBox.addItemListener(new ItemListener() {
Expand All @@ -47,7 +49,19 @@ public void itemStateChanged(ItemEvent e) {
});
}

private void setLocalBranchesComboBox(boolean isNonDefault){
if (isNonDefault){
developmentBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
productionBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
} else {
developmentBranchComboBox.setModel(new CollectionComboBoxModel(Arrays.asList("develop")));
productionBranchComboBox.setModel(new CollectionComboBoxModel(Arrays.asList("master")));
}
}

private void enableFields(boolean enable) {
setLocalBranchesComboBox(enable);

productionBranchComboBox.setEnabled(enable);
developmentBranchComboBox.setEnabled(enable);
featurePrefixTextField.setEnabled(enable);
Expand Down

0 comments on commit 70a77bd

Please sign in to comment.