--- a/git/nbproject/project.xml Thu Sep 12 15:49:58 2013 +0200
+++ a/git/nbproject/project.xml Thu Sep 12 15:55:33 2013 +0200
@@ -20,7 +20,7 @@
1
- 1.12
+ 1.14
--- a/git/src/org/netbeans/modules/git/HistoryRegistry.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/HistoryRegistry.java Thu Sep 12 15:55:33 2013 +0200
@@ -87,7 +87,7 @@
crit.setFollowRenames(true);
crit.setIncludeMerges(false);
try {
- GitRevisionInfo[] history = client.log(crit, pm);
+ GitRevisionInfo[] history = client.log(crit, false, pm);
if (!pm.isCanceled() && history.length > 0) {
for (File f : files) {
logs.put(f, Arrays.asList(history));
--- a/git/src/org/netbeans/modules/git/client/GitClient.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/client/GitClient.java Thu Sep 12 15:55:33 2013 +0200
@@ -95,7 +95,7 @@
private final boolean handleAuthenticationIssues;
private static final int CLEANUP_TIME = 15000;
private static final List unusedClients = new LinkedList();
- private static RequestProcessor.Task cleanTask = Git.getInstance().getRequestProcessor().create(new CleanTask());
+ private static final RequestProcessor.Task cleanTask = Git.getInstance().getRequestProcessor().create(new CleanTask());
/**
* Set of commands that do not need to run under repository lock
@@ -564,12 +564,13 @@
}, "log"); //NOI18N
}
- public GitRevisionInfo[] log (final SearchCriteria searchCriteria, final ProgressMonitor monitor) throws GitException.MissingObjectException, GitException {
+ public GitRevisionInfo[] log (final SearchCriteria searchCriteria, final boolean fetchAffectedBranches,
+ final ProgressMonitor monitor) throws GitException.MissingObjectException, GitException {
return new CommandInvoker().runMethod(new Callable() {
@Override
public GitRevisionInfo[] call () throws Exception {
- return delegate.log(searchCriteria, monitor);
+ return delegate.log(searchCriteria, fetchAffectedBranches, monitor);
}
}, "log"); //NOI18N
}
--- a/git/src/org/netbeans/modules/git/ui/history/Bundle.properties Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/Bundle.properties Thu Sep 12 15:55:33 2013 +0200
@@ -152,3 +152,5 @@
TT_Branch=Find only commits from a specific branch. Leave blank to see commits from all branches.
SearchCriteriaPanel.btnSelectBranch.TTtext=Select branch you wish to search
SearchCriteriaPanel.btnSelectBranch.text=...
+branchLabel.text=&Branch:
+branchLabel.TTtext=Select a branch to show only commits being part of the branch
--- a/git/src/org/netbeans/modules/git/ui/history/SearchExecutor.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/SearchExecutor.java Thu Sep 12 15:55:33 2013 +0200
@@ -152,7 +152,7 @@
List search (int limit, GitClient client, ProgressMonitor monitor) throws GitException {
sc.setLimit(limit);
List retval = Collections.emptyList();
- GitRevisionInfo[] messages = client.log(sc, monitor);
+ GitRevisionInfo[] messages = client.log(sc, true, monitor);
if (!monitor.isCanceled()) {
RepositoryInfo info = RepositoryInfo.getInstance(getRepositoryRoot());
retval = appendResults(messages, info.getBranches().values(), info.getTags().values(), monitor);
--- a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryAction.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryAction.java Thu Sep 12 15:55:33 2013 +0200
@@ -79,10 +79,11 @@
public static void openSearch(final File repository, final File[] roots, final String contextName) {
final String title = NbBundle.getMessage(SearchHistoryTopComponent.class, "LBL_SearchHistoryTopComponent.title", contextName);
final String activeBranch = getActiveBranchName(repository);
+ final RepositoryInfo info = RepositoryInfo.getInstance(repository);
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
- SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, roots);
+ SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, info, roots);
tc.setBranch(activeBranch);
tc.setDisplayName(title);
tc.open();
@@ -96,10 +97,11 @@
public static void openSearch (final File repository, final File root, final String contextName, final String commitId) {
final String title = NbBundle.getMessage(SearchHistoryTopComponent.class, "LBL_SearchHistoryTopComponent.title", contextName);
+ final RepositoryInfo info = RepositoryInfo.getInstance(repository);
Mutex.EVENT.readAccess(new Runnable() {
@Override
public void run () {
- SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, new File[] { root });
+ SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, info, new File[] { root });
tc.setDisplayName(title);
tc.open();
tc.requestActive();
@@ -111,10 +113,11 @@
public static void openSearch (final File repository, final File root, final String contextName, final int lineNumber) {
final String title = NbBundle.getMessage(SearchHistoryTopComponent.class, "LBL_SearchHistoryTopComponent.title", contextName);
+ final RepositoryInfo info = RepositoryInfo.getInstance(repository);
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
- SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, root, new SearchHistoryTopComponent.DiffResultsViewFactory() {
+ SearchHistoryTopComponent tc = new SearchHistoryTopComponent(repository, info, root, new SearchHistoryTopComponent.DiffResultsViewFactory() {
@Override
DiffResultsView createDiffResultsView(SearchHistoryPanel panel, List results) {
return new DiffResultsViewForLine(panel, results, lineNumber);
--- a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryPanel.form Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryPanel.form Thu Sep 12 15:55:33 2013 +0200
@@ -180,6 +180,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryPanel.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryPanel.java Thu Sep 12 15:55:33 2013 +0200
@@ -45,6 +45,7 @@
package org.netbeans.modules.git.ui.history;
import java.awt.Color;
+import java.awt.Component;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.openide.util.NbBundle;
@@ -73,8 +74,11 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BoxLayout;
+import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
+import javax.swing.JList;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
@@ -88,14 +92,19 @@
import org.netbeans.modules.git.client.GitProgressSupport;
import org.netbeans.modules.git.ui.history.SearchHistoryTopComponent.DiffResultsViewFactory;
import org.netbeans.modules.git.ui.history.SummaryView.GitLogEntry;
+import org.netbeans.modules.git.ui.repository.RepositoryInfo;
import org.netbeans.modules.versioning.history.AbstractSummaryView.SummaryViewMaster.SearchHighlight;
import org.netbeans.modules.versioning.util.VCSKenaiAccessor;
+import org.openide.util.WeakListeners;
/**
* Contains all components of the Search History panel.
*
* @author Maros Sandor
*/
+@NbBundle.Messages({
+ "SearchHistoryPanel.filter.allbranches=All Branches"
+})
class SearchHistoryPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener, DocumentListener, ActionListener {
private final File[] roots;
@@ -124,6 +133,9 @@
private DiffResultsViewFactory diffViewFactory;
private boolean searchStarted;
private String currentBranch;
+ private Object currentBranchFilter = ALL_BRANCHES_FILTER;
+ private final RepositoryInfo info;
+ private static final String ALL_BRANCHES_FILTER = Bundle.SearchHistoryPanel_filter_allbranches();
enum FilterKind {
ALL(null, NbBundle.getMessage(SearchHistoryPanel.class, "Filter.All")), //NOI18N
@@ -147,9 +159,10 @@
private final Timer filterTimer;
/** Creates new form SearchHistoryPanel */
- public SearchHistoryPanel(File repository, File [] roots, SearchCriteriaPanel criteria) {
+ public SearchHistoryPanel(File repository, RepositoryInfo info, File [] roots, SearchCriteriaPanel criteria) {
this.roots = roots;
this.repository = repository;
+ this.info = info;
this.criteria = criteria;
this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory();
criteriaVisible = true;
@@ -160,6 +173,7 @@
filterTimer.setRepeats(false);
filterTimer.stop();
setupComponents();
+ info.addPropertyChangeListener(WeakListeners.propertyChange(this, info));
aquaBackgroundWorkaround();
refreshComponents(true);
}
@@ -253,6 +267,18 @@
fileInfoCheckBox.setSelected(GitModuleConfig.getDefault().getShowFileInfo());
criteria.btnSelectBranch.addActionListener(this);
+ cmbBranch.setRenderer(new DefaultListCellRenderer() {
+
+ @Override
+ public Component getListCellRendererComponent (JList> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value instanceof GitBranch) {
+ value = ((GitBranch) value).getName();
+ }
+ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+
+ });
+ refreshBranchFilterModel();
}
private ExplorerManager explorerManager;
@@ -263,6 +289,8 @@
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this);
if (tc == null) return;
tc.setActivatedNodes((Node[]) evt.getNewValue());
+ } else if (RepositoryInfo.PROPERTY_BRANCHES.equals(evt.getPropertyName())) {
+ refreshBranchFilterModel();
}
}
@@ -375,6 +403,7 @@
// did user change this setting and cleared the branch field?
GitModuleConfig.getDefault().setSearchOnlyCurrentBranchEnabled(criteria.getBranch() != null);
}
+ updateBranchFilter(criteria.getBranch());
try {
currentSearch = new SearchExecutor(this);
currentSearch.start(Git.getInstance().getRequestProcessor(repository), repository, NbBundle.getMessage(SearchExecutor.class, "MSG_Search_Progress", repository)); //NOI18N
@@ -436,6 +465,9 @@
tbDiff = new javax.swing.JToggleButton();
jSeparator2 = new javax.swing.JSeparator();
jSeparator3 = new javax.swing.JToolBar.Separator();
+ jSeparator4 = new javax.swing.JToolBar.Separator();
+ lblBranch = new javax.swing.JLabel();
+ cmbBranch = new javax.swing.JComboBox();
jSeparator1 = new javax.swing.JToolBar.Separator();
lblFilter = new javax.swing.JLabel();
cmbFilterKind = new javax.swing.JComboBox();
@@ -502,6 +534,20 @@
}
});
jToolBar1.add(fileInfoCheckBox);
+ jToolBar1.add(jSeparator4);
+
+ lblBranch.setLabelFor(cmbBranch);
+ org.openide.awt.Mnemonics.setLocalizedText(lblBranch, org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "branchLabel.text")); // NOI18N
+ lblBranch.setToolTipText(org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "branchLabel.TTtext")); // NOI18N
+ lblBranch.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
+ jToolBar1.add(lblBranch);
+
+ cmbBranch.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbBranchActionPerformed(evt);
+ }
+ });
+ jToolBar1.add(cmbBranch);
jToolBar1.add(jSeparator1);
org.openide.awt.Mnemonics.setLocalizedText(lblFilter, org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "filterLabel.text")); // NOI18N
@@ -595,6 +641,15 @@
}
}//GEN-LAST:event_cmbFilterKindActionPerformed
+ private void cmbBranchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbBranchActionPerformed
+ Object filter = cmbBranch.getSelectedItem();
+ boolean refresh = filter != currentBranchFilter;
+ if (refresh) {
+ currentBranchFilter = filter;
+ filterTimer.restart();
+ }
+ }//GEN-LAST:event_cmbBranchActionPerformed
+
@Override
public void insertUpdate(DocumentEvent e) {
documentChanged(e);
@@ -654,13 +709,16 @@
final javax.swing.JButton bPrev = new javax.swing.JButton();
private javax.swing.JButton bSearch;
private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.JComboBox cmbBranch;
private javax.swing.JComboBox cmbFilterKind;
private org.netbeans.modules.versioning.history.LinkButton expandCriteriaButton;
final javax.swing.JCheckBox fileInfoCheckBox = new javax.swing.JCheckBox();
private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JToolBar.Separator jSeparator3;
+ private javax.swing.JToolBar.Separator jSeparator4;
private javax.swing.JToolBar jToolBar1;
+ private javax.swing.JLabel lblBranch;
private javax.swing.JLabel lblFilter;
private javax.swing.JLabel lblFilterContains;
private javax.swing.JPanel resultsPanel;
@@ -759,6 +817,10 @@
|| contains(rev.getTags(), filterText);
}
}
+ Object selectedBranchFilter = currentBranchFilter;
+ if (visible && selectedBranchFilter instanceof GitBranch) {
+ visible = rev.getLog().getBranches().containsKey(((GitBranch) currentBranchFilter).getName());
+ }
return visible;
}
@@ -862,4 +924,35 @@
this.diffViewFactory = fac;
}
}
+
+ private void refreshBranchFilterModel () {
+ DefaultComboBoxModel model = new DefaultComboBoxModel();
+ model.addElement(ALL_BRANCHES_FILTER);
+ for (Map.Entry e : info.getBranches().entrySet()) {
+ GitBranch b = e.getValue();
+ if (b.getName() != GitBranch.NO_BRANCH) {
+ model.addElement(b);
+ if (currentBranchFilter instanceof GitBranch && b.getName().equals(((GitBranch) currentBranchFilter).getName())) {
+ currentBranchFilter = b;
+ }
+ }
+ }
+ cmbBranch.setModel(model);
+ cmbBranch.setSelectedItem(currentBranchFilter);
+ }
+
+ private void updateBranchFilter (String branch) {
+ currentBranchFilter = ALL_BRANCHES_FILTER;
+ if (branch != null) {
+ ComboBoxModel model = cmbBranch.getModel();
+ for (int i = 0; i < model.getSize(); ++i) {
+ Object filter = model.getElementAt(i);
+ if (filter instanceof GitBranch && branch.equals(((GitBranch) filter).getName())) {
+ currentBranchFilter = filter;
+ break;
+ }
+ }
+ }
+ cmbBranch.setSelectedItem(currentBranchFilter);
+ }
}
--- a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryTopComponent.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/history/SearchHistoryTopComponent.java Thu Sep 12 15:55:33 2013 +0200
@@ -51,32 +51,28 @@
import java.awt.BorderLayout;
import java.util.List;
import org.netbeans.modules.git.GitModuleConfig;
+import org.netbeans.modules.git.ui.repository.RepositoryInfo;
@TopComponent.Description(persistenceType=TopComponent.PERSISTENCE_NEVER, preferredID="Git.SearchHistoryTopComponent")
public class SearchHistoryTopComponent extends TopComponent {
private SearchHistoryPanel shp;
private SearchCriteriaPanel scp;
- private File[] files;
- private File repository;
-
- public SearchHistoryTopComponent () {
+ private final File[] files;
+ private final File repository;
+ private final RepositoryInfo info;
+
+ public SearchHistoryTopComponent (File repository, RepositoryInfo info, File[] files) {
+ this.repository = repository;
+ this.info = info;
+ this.files = files;
getAccessibleContext().setAccessibleName(NbBundle.getMessage(SearchHistoryTopComponent.class, "ACSN_SearchHistoryT_Top_Component")); // NOI18N
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SearchHistoryTopComponent.class, "ACSD_SearchHistoryT_Top_Component")); // NOI18N
- }
-
- public SearchHistoryTopComponent (File repository, File[] files) {
- this();
- this.repository = repository;
- this.files = files;
initComponents();
}
- SearchHistoryTopComponent (File repository, File file, DiffResultsViewFactory fac) {
- this();
- this.repository = repository;
- this.files = new File[] { file };
- initComponents();
+ SearchHistoryTopComponent (File repository, RepositoryInfo info, File file, DiffResultsViewFactory fac) {
+ this(repository, info, new File[] { file });
shp.setDiffResultsViewFactory(fac);
}
@@ -108,7 +104,7 @@
private void initComponents () {
setLayout(new BorderLayout());
scp = new SearchCriteriaPanel();
- shp = new SearchHistoryPanel(repository, files, scp);
+ shp = new SearchHistoryPanel(repository, info, files, scp);
add(shp);
}
--- a/git/src/org/netbeans/modules/git/ui/push/PushAction.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/push/PushAction.java Thu Sep 12 15:55:33 2013 +0200
@@ -389,7 +389,7 @@
if (crit != null) {
final GitProgressSupport supp = this;
try {
- GitRevisionInfo[] revisions = client.log(crit, new ProgressMonitor() {
+ GitRevisionInfo[] revisions = client.log(crit, false, new ProgressMonitor() {
@Override
public boolean isCanceled () {
return supp.isCanceled();
--- a/git/src/org/netbeans/modules/git/ui/rebase/RebaseAction.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/rebase/RebaseAction.java Thu Sep 12 15:55:33 2013 +0200
@@ -481,7 +481,7 @@
SearchCriteria crit = new SearchCriteria();
crit.setRevisionFrom(revisionFrom);
crit.setRevisionTo(revisionTo);
- GitRevisionInfo[] log = client.log(crit, pm);
+ GitRevisionInfo[] log = client.log(crit, false, pm);
return convertToEntries(log);
}
--- a/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/repository/RepositoryBrowserPanel.java Thu Sep 12 15:55:33 2013 +0200
@@ -1109,7 +1109,7 @@
crit.setRevisionFrom(id);
crit.setRevisionTo(trackedBranch.getId());
}
- GitRevisionInfo[] revs = client.log(crit, GitUtils.NULL_PROGRESS_MONITOR);
+ GitRevisionInfo[] revs = client.log(crit, false, GitUtils.NULL_PROGRESS_MONITOR);
int diff = (revs.length - 1);
if (info.getRevision().equals(trackedBranch.getId())) {
tt = NbBundle.getMessage(RepositoryBrowserPanel.class, diff == 1
--- a/git/src/org/netbeans/modules/git/ui/repository/RevisionListPanel.java Thu Sep 12 15:49:58 2013 +0200
+++ a/git/src/org/netbeans/modules/git/ui/repository/RevisionListPanel.java Thu Sep 12 15:55:33 2013 +0200
@@ -367,7 +367,7 @@
if (rev != null) {
criteria.setRevisionTo(rev.getCommitId());
}
- final GitRevisionInfo[] revs = client.log(criteria, listHistoryMonitor);
+ final GitRevisionInfo[] revs = client.log(criteria, false, listHistoryMonitor);
if (!isCanceled()) {
finished = true;
EventQueue.invokeLater(new Runnable() {