Skip to content

Commit 20df0ab

Browse files
committed
Merge branch 'release/0.7.3'
2 parents b41850b + 17686e4 commit 20df0ab

6 files changed

+112
-39
lines changed

build.gradle

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ compileJava {
88
}
99

1010
group 'gitflow4idea'
11-
version '0.7.2'
11+
version '0.7.3'
1212

1313
sourceCompatibility = JavaVersion.VERSION_1_8
1414
targetCompatibility = JavaVersion.VERSION_1_8
@@ -29,11 +29,19 @@ intellij {
2929
patchPluginXml {
3030
pluginId "Gitflow"
3131
pluginDescription 'Git Flow Integration'
32-
version '0.7.2'
32+
version '0.7.3'
3333
sinceBuild '201.0'
3434
untilBuild '201.*'
3535
changeNotes """
3636
37+
<H2>Changelog for 0.7.3</H2>
38+
<ul>
39+
<li>Implemented sorting and filtering of track branch dialog #290 (@mmopitz)</li>
40+
<li>Fix Version 0.7.2 causes that Active Tool Windows only is showed in one project if you have several open #301 (@tumb1er)</li>
41+
<li>Fix Unsupported Git Flow version Fix #302 (@opherv)</li>
42+
<li>Fix init settings shown in UI are misleading (do not match default) #283 (@opherv)</li>
43+
</ul>
44+
3745
<H2>Changelog for 0.7.2</H2>
3846
<ul>
3947
<li>Support for Idea build 200 #276 (@fabmars, @tumb1er )</li>

src/main/java/gitflow/GitflowImpl.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.jetbrains.annotations.NotNull;
88
import org.jetbrains.annotations.Nullable;
99

10+
import java.io.File;
1011
import java.lang.reflect.InvocationTargetException;
1112
import java.lang.reflect.Method;
1213
import java.util.ArrayList;
@@ -493,14 +494,7 @@ public GitCommandResult trackBugfix(@NotNull GitRepository repository,
493494

494495
@Override
495496
public GitCommandResult version(@NotNull Project project, GitLineHandlerListener... listeners) {
496-
//getProjectFile is null for default project.
497-
if (project.isDefault()) {
498-
throw new IllegalArgumentException("Cannot determine git flow version for default project");
499-
} else {
500-
assert project.getProjectFile() != null : "No project file for " + project;
501-
}
502-
503-
final GitLineHandler h = new GitLineHandler(project, project.getProjectFile().getParent(), GitflowCommand());
497+
final GitLineHandler h = new GitLineHandler(project, new File(project.getBasePath()), GitflowCommand());
504498

505499
h.addParameters("version");
506500

src/main/java/gitflow/ui/GitflowBranchChooseDialog.form

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,40 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="436" height="297"/>
6+
<xy x="48" y="54" width="436" height="388"/>
77
</constraints>
88
<properties/>
99
<border type="none"/>
1010
<children>
11-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
11+
<grid id="e3588" binding="branchPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1212
<margin top="0" left="0" bottom="0" right="0"/>
1313
<constraints>
1414
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
1515
</constraints>
1616
<properties/>
1717
<border type="none"/>
1818
<children>
19-
<component id="f89aa" class="javax.swing.JList" binding="branchList">
19+
<component id="20448" class="javax.swing.JTextField" binding="searchField" default-binding="true">
2020
<constraints>
21-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
22-
<minimum-size width="100" height="200"/>
23-
<preferred-size width="300" height="300"/>
21+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
22+
<preferred-size width="150" height="-1"/>
2423
</grid>
2524
</constraints>
2625
<properties/>
2726
</component>
27+
<scrollpane id="59ea8" binding="scrollpane">
28+
<constraints>
29+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
30+
</constraints>
31+
<properties/>
32+
<border type="none"/>
33+
<children>
34+
<component id="5974" class="javax.swing.JTable" binding="branchList">
35+
<constraints/>
36+
<properties/>
37+
</component>
38+
</children>
39+
</scrollpane>
2840
</children>
2941
</grid>
3042
</children>

src/main/java/gitflow/ui/GitflowBranchChooseDialog.java

+62-9
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,42 @@
66
import org.jetbrains.annotations.Nullable;
77

88
import javax.swing.*;
9+
import javax.swing.event.DocumentEvent;
10+
import javax.swing.event.DocumentListener;
11+
import javax.swing.table.DefaultTableModel;
12+
import javax.swing.table.TableRowSorter;
913
import java.util.List;
14+
import java.util.stream.IntStream;
1015

1116
/**
12-
* Dialog for choosing branches
17+
* Dialog for choosing branches
1318
*
1419
* @author Opher Vishnia / opherv.com / [email protected]
1520
*/
1621

1722
public class GitflowBranchChooseDialog extends DialogWrapper {
1823
private JPanel contentPane;
19-
private JList branchList;
20-
24+
private JTextField searchField;
25+
//using a single column table because it has built in sorting and filtering capabilities.
26+
private JTable branchList;
27+
private JScrollPane scrollpane;
28+
private JPanel branchPanel;
2129

2230
public GitflowBranchChooseDialog(Project project, List<String> branchNames) {
2331
super(project, true);
2432

2533
setModal(true);
2634

2735
setTitle("Choose Branch");
28-
branchList.setListData(branchNames.toArray());
29-
36+
initBranchList(branchNames);
3037
init();
3138
}
3239

3340
@Nullable
3441
@Override
3542
protected ValidationInfo doValidate() {
36-
if (branchList.getSelectedValue() == null){
37-
return new ValidationInfo("No branch selected!");
43+
if (branchList.getSelectedRow() == -1) {
44+
return new ValidationInfo("No branch selected!");
3845
} else {
3946
return null;
4047
}
@@ -46,7 +53,53 @@ protected JComponent createCenterPanel() {
4653
return contentPane;
4754
}
4855

49-
public String getSelectedBranchName(){
50-
return branchList.getSelectedValue().toString();
56+
public String getSelectedBranchName() {
57+
int selectedRow = branchList.getSelectedRow();
58+
return (String) branchList.getValueAt(selectedRow, 0);
59+
}
60+
61+
private void initBranchList(List<String> branchNames) {
62+
branchList.setTableHeader(null);
63+
DefaultTableModel model = (DefaultTableModel) branchList.getModel();
64+
//only one column. No Header.
65+
model.setColumnCount(1);
66+
for (String branchName : branchNames) {
67+
model.addRow(new String[]{branchName});
68+
}
69+
//sort on first (and only column)
70+
TableRowSorter<DefaultTableModel> rowSorter = new TableRowSorter<>();
71+
rowSorter.setModel(model);
72+
branchList.setRowSorter(rowSorter);
73+
branchList.getRowSorter().toggleSortOrder(0);
74+
//add filtering capabilities.
75+
searchField.getDocument().addDocumentListener(
76+
new DocumentListener() {
77+
@Override
78+
public void insertUpdate(DocumentEvent documentEvent) {
79+
filter();
80+
}
81+
82+
@Override
83+
public void removeUpdate(DocumentEvent documentEvent) {
84+
filter();
85+
}
86+
87+
@Override
88+
public void changedUpdate(DocumentEvent documentEvent) {
89+
filter();
90+
}
91+
92+
private void filter() {
93+
String text = searchField.getText();
94+
if (text.trim().length() == 0) {
95+
rowSorter.setRowFilter(null);
96+
} else {
97+
rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
98+
}
99+
}
100+
}
101+
);
51102
}
103+
104+
52105
}

src/main/java/gitflow/ui/GitflowInitOptionsDialog.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.swing.*;
1212
import java.awt.event.ItemEvent;
1313
import java.awt.event.ItemListener;
14+
import java.util.Arrays;
1415
import java.util.List;
1516

1617
/**
@@ -30,13 +31,14 @@ public class GitflowInitOptionsDialog extends DialogWrapper {
3031
private JTextField versionPrefixTextField;
3132
private JTextField bugfixPrefixTextField;
3233

33-
public GitflowInitOptionsDialog(Project project, List<String> localBranches) {
34+
private List<String> localBranches;
35+
36+
public GitflowInitOptionsDialog(Project project, List<String> _localBranches) {
3437
super(project);
38+
localBranches = _localBranches;
3539

3640
setTitle("Options for gitflow init");
37-
38-
productionBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
39-
developmentBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
41+
setLocalBranchesComboBox(false);
4042

4143
init();
4244
useNonDefaultConfigurationCheckBox.addItemListener(new ItemListener() {
@@ -47,7 +49,19 @@ public void itemStateChanged(ItemEvent e) {
4749
});
4850
}
4951

52+
private void setLocalBranchesComboBox(boolean isNonDefault){
53+
if (isNonDefault){
54+
developmentBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
55+
productionBranchComboBox.setModel(new CollectionComboBoxModel(localBranches));
56+
} else {
57+
developmentBranchComboBox.setModel(new CollectionComboBoxModel(Arrays.asList("develop")));
58+
productionBranchComboBox.setModel(new CollectionComboBoxModel(Arrays.asList("master")));
59+
}
60+
}
61+
5062
private void enableFields(boolean enable) {
63+
setLocalBranchesComboBox(enable);
64+
5165
productionBranchComboBox.setEnabled(enable);
5266
developmentBranchComboBox.setEnabled(enable);
5367
featurePrefixTextField.setEnabled(enable);

src/main/java/gitflow/ui/GitflowStatusBarWidgetFactory.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
package gitflow.ui;
22

3-
import com.intellij.openapi.progress.ProgressIndicator;
4-
import com.intellij.openapi.progress.Task;
53
import com.intellij.openapi.project.Project;
64
import com.intellij.openapi.util.Disposer;
75
import com.intellij.openapi.wm.StatusBar;
86
import com.intellij.openapi.wm.StatusBarWidget;
97
import com.intellij.openapi.wm.StatusBarWidgetFactory;
10-
import com.intellij.openapi.wm.WindowManager;
11-
import gitflow.GitflowVersionTester;
128
import org.jetbrains.annotations.Nls;
139
import org.jetbrains.annotations.NotNull;
1410

1511
public class GitflowStatusBarWidgetFactory implements StatusBarWidgetFactory {
16-
private GitflowWidget myGitflowWidget;
1712

1813
@NotNull
1914
@Override
@@ -36,16 +31,13 @@ public boolean isAvailable(@NotNull Project project) {
3631
@NotNull
3732
@Override
3833
public StatusBarWidget createWidget(@NotNull Project project) {
39-
if (myGitflowWidget == null) {
40-
myGitflowWidget = new GitflowWidget(project);
41-
}
42-
return myGitflowWidget;
34+
GitflowWidget gitflowWidget = new GitflowWidget(project);
35+
return gitflowWidget;
4336
}
4437

4538
@Override
4639
public void disposeWidget(@NotNull StatusBarWidget widget) {
4740
Disposer.dispose(widget);
48-
myGitflowWidget = null;
4941
}
5042

5143
@Override

0 commit comments

Comments
 (0)