Lines 45-50
Link Here
|
45 |
package org.netbeans.modules.git.ui.history; |
45 |
package org.netbeans.modules.git.ui.history; |
46 |
|
46 |
|
47 |
import java.awt.Color; |
47 |
import java.awt.Color; |
|
|
48 |
import java.awt.Component; |
48 |
import javax.swing.event.DocumentEvent; |
49 |
import javax.swing.event.DocumentEvent; |
49 |
import javax.swing.event.DocumentListener; |
50 |
import javax.swing.event.DocumentListener; |
50 |
import org.openide.util.NbBundle; |
51 |
import org.openide.util.NbBundle; |
Lines 73-80
Link Here
|
73 |
import javax.swing.AbstractAction; |
74 |
import javax.swing.AbstractAction; |
74 |
import javax.swing.Action; |
75 |
import javax.swing.Action; |
75 |
import javax.swing.BoxLayout; |
76 |
import javax.swing.BoxLayout; |
|
|
77 |
import javax.swing.ComboBoxModel; |
76 |
import javax.swing.DefaultComboBoxModel; |
78 |
import javax.swing.DefaultComboBoxModel; |
|
|
79 |
import javax.swing.DefaultListCellRenderer; |
77 |
import javax.swing.Icon; |
80 |
import javax.swing.Icon; |
|
|
81 |
import javax.swing.JList; |
78 |
import javax.swing.KeyStroke; |
82 |
import javax.swing.KeyStroke; |
79 |
import javax.swing.SwingUtilities; |
83 |
import javax.swing.SwingUtilities; |
80 |
import javax.swing.Timer; |
84 |
import javax.swing.Timer; |
Lines 88-101
Link Here
|
88 |
import org.netbeans.modules.git.client.GitProgressSupport; |
92 |
import org.netbeans.modules.git.client.GitProgressSupport; |
89 |
import org.netbeans.modules.git.ui.history.SearchHistoryTopComponent.DiffResultsViewFactory; |
93 |
import org.netbeans.modules.git.ui.history.SearchHistoryTopComponent.DiffResultsViewFactory; |
90 |
import org.netbeans.modules.git.ui.history.SummaryView.GitLogEntry; |
94 |
import org.netbeans.modules.git.ui.history.SummaryView.GitLogEntry; |
|
|
95 |
import org.netbeans.modules.git.ui.repository.RepositoryInfo; |
91 |
import org.netbeans.modules.versioning.history.AbstractSummaryView.SummaryViewMaster.SearchHighlight; |
96 |
import org.netbeans.modules.versioning.history.AbstractSummaryView.SummaryViewMaster.SearchHighlight; |
92 |
import org.netbeans.modules.versioning.util.VCSKenaiAccessor; |
97 |
import org.netbeans.modules.versioning.util.VCSKenaiAccessor; |
|
|
98 |
import org.openide.util.WeakListeners; |
93 |
|
99 |
|
94 |
/** |
100 |
/** |
95 |
* Contains all components of the Search History panel. |
101 |
* Contains all components of the Search History panel. |
96 |
* |
102 |
* |
97 |
* @author Maros Sandor |
103 |
* @author Maros Sandor |
98 |
*/ |
104 |
*/ |
|
|
105 |
@NbBundle.Messages({ |
106 |
"SearchHistoryPanel.filter.allbranches=All Branches" |
107 |
}) |
99 |
class SearchHistoryPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener, DocumentListener, ActionListener { |
108 |
class SearchHistoryPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener, DocumentListener, ActionListener { |
100 |
|
109 |
|
101 |
private final File[] roots; |
110 |
private final File[] roots; |
Lines 124-129
Link Here
|
124 |
private DiffResultsViewFactory diffViewFactory; |
133 |
private DiffResultsViewFactory diffViewFactory; |
125 |
private boolean searchStarted; |
134 |
private boolean searchStarted; |
126 |
private String currentBranch; |
135 |
private String currentBranch; |
|
|
136 |
private Object currentBranchFilter = ALL_BRANCHES_FILTER; |
137 |
private final RepositoryInfo info; |
138 |
private static final String ALL_BRANCHES_FILTER = Bundle.SearchHistoryPanel_filter_allbranches(); |
127 |
|
139 |
|
128 |
enum FilterKind { |
140 |
enum FilterKind { |
129 |
ALL(null, NbBundle.getMessage(SearchHistoryPanel.class, "Filter.All")), //NOI18N |
141 |
ALL(null, NbBundle.getMessage(SearchHistoryPanel.class, "Filter.All")), //NOI18N |
Lines 147-155
Link Here
|
147 |
private final Timer filterTimer; |
159 |
private final Timer filterTimer; |
148 |
|
160 |
|
149 |
/** Creates new form SearchHistoryPanel */ |
161 |
/** Creates new form SearchHistoryPanel */ |
150 |
public SearchHistoryPanel(File repository, File [] roots, SearchCriteriaPanel criteria) { |
162 |
public SearchHistoryPanel(File repository, RepositoryInfo info, File [] roots, SearchCriteriaPanel criteria) { |
151 |
this.roots = roots; |
163 |
this.roots = roots; |
152 |
this.repository = repository; |
164 |
this.repository = repository; |
|
|
165 |
this.info = info; |
153 |
this.criteria = criteria; |
166 |
this.criteria = criteria; |
154 |
this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory(); |
167 |
this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory(); |
155 |
criteriaVisible = true; |
168 |
criteriaVisible = true; |
Lines 160-165
Link Here
|
160 |
filterTimer.setRepeats(false); |
173 |
filterTimer.setRepeats(false); |
161 |
filterTimer.stop(); |
174 |
filterTimer.stop(); |
162 |
setupComponents(); |
175 |
setupComponents(); |
|
|
176 |
info.addPropertyChangeListener(WeakListeners.propertyChange(this, info)); |
163 |
aquaBackgroundWorkaround(); |
177 |
aquaBackgroundWorkaround(); |
164 |
refreshComponents(true); |
178 |
refreshComponents(true); |
165 |
} |
179 |
} |
Lines 253-258
Link Here
|
253 |
fileInfoCheckBox.setSelected(GitModuleConfig.getDefault().getShowFileInfo()); |
267 |
fileInfoCheckBox.setSelected(GitModuleConfig.getDefault().getShowFileInfo()); |
254 |
|
268 |
|
255 |
criteria.btnSelectBranch.addActionListener(this); |
269 |
criteria.btnSelectBranch.addActionListener(this); |
|
|
270 |
cmbBranch.setRenderer(new DefaultListCellRenderer() { |
271 |
|
272 |
@Override |
273 |
public Component getListCellRendererComponent (JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
274 |
if (value instanceof GitBranch) { |
275 |
value = ((GitBranch) value).getName(); |
276 |
} |
277 |
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
278 |
} |
279 |
|
280 |
}); |
281 |
refreshBranchFilterModel(); |
256 |
} |
282 |
} |
257 |
|
283 |
|
258 |
private ExplorerManager explorerManager; |
284 |
private ExplorerManager explorerManager; |
Lines 263-268
Link Here
|
263 |
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this); |
289 |
TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, this); |
264 |
if (tc == null) return; |
290 |
if (tc == null) return; |
265 |
tc.setActivatedNodes((Node[]) evt.getNewValue()); |
291 |
tc.setActivatedNodes((Node[]) evt.getNewValue()); |
|
|
292 |
} else if (RepositoryInfo.PROPERTY_BRANCHES.equals(evt.getPropertyName())) { |
293 |
refreshBranchFilterModel(); |
266 |
} |
294 |
} |
267 |
} |
295 |
} |
268 |
|
296 |
|
Lines 375-380
Link Here
|
375 |
// did user change this setting and cleared the branch field? |
403 |
// did user change this setting and cleared the branch field? |
376 |
GitModuleConfig.getDefault().setSearchOnlyCurrentBranchEnabled(criteria.getBranch() != null); |
404 |
GitModuleConfig.getDefault().setSearchOnlyCurrentBranchEnabled(criteria.getBranch() != null); |
377 |
} |
405 |
} |
|
|
406 |
updateBranchFilter(criteria.getBranch()); |
378 |
try { |
407 |
try { |
379 |
currentSearch = new SearchExecutor(this); |
408 |
currentSearch = new SearchExecutor(this); |
380 |
currentSearch.start(Git.getInstance().getRequestProcessor(repository), repository, NbBundle.getMessage(SearchExecutor.class, "MSG_Search_Progress", repository)); //NOI18N |
409 |
currentSearch.start(Git.getInstance().getRequestProcessor(repository), repository, NbBundle.getMessage(SearchExecutor.class, "MSG_Search_Progress", repository)); //NOI18N |
Lines 436-441
Link Here
|
436 |
tbDiff = new javax.swing.JToggleButton(); |
465 |
tbDiff = new javax.swing.JToggleButton(); |
437 |
jSeparator2 = new javax.swing.JSeparator(); |
466 |
jSeparator2 = new javax.swing.JSeparator(); |
438 |
jSeparator3 = new javax.swing.JToolBar.Separator(); |
467 |
jSeparator3 = new javax.swing.JToolBar.Separator(); |
|
|
468 |
jSeparator4 = new javax.swing.JToolBar.Separator(); |
469 |
lblBranch = new javax.swing.JLabel(); |
470 |
cmbBranch = new javax.swing.JComboBox(); |
439 |
jSeparator1 = new javax.swing.JToolBar.Separator(); |
471 |
jSeparator1 = new javax.swing.JToolBar.Separator(); |
440 |
lblFilter = new javax.swing.JLabel(); |
472 |
lblFilter = new javax.swing.JLabel(); |
441 |
cmbFilterKind = new javax.swing.JComboBox(); |
473 |
cmbFilterKind = new javax.swing.JComboBox(); |
Lines 502-507
Link Here
|
502 |
} |
534 |
} |
503 |
}); |
535 |
}); |
504 |
jToolBar1.add(fileInfoCheckBox); |
536 |
jToolBar1.add(fileInfoCheckBox); |
|
|
537 |
jToolBar1.add(jSeparator4); |
538 |
|
539 |
lblBranch.setLabelFor(cmbBranch); |
540 |
org.openide.awt.Mnemonics.setLocalizedText(lblBranch, org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "branchLabel.text")); // NOI18N |
541 |
lblBranch.setToolTipText(org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "branchLabel.TTtext")); // NOI18N |
542 |
lblBranch.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); |
543 |
jToolBar1.add(lblBranch); |
544 |
|
545 |
cmbBranch.addActionListener(new java.awt.event.ActionListener() { |
546 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
547 |
cmbBranchActionPerformed(evt); |
548 |
} |
549 |
}); |
550 |
jToolBar1.add(cmbBranch); |
505 |
jToolBar1.add(jSeparator1); |
551 |
jToolBar1.add(jSeparator1); |
506 |
|
552 |
|
507 |
org.openide.awt.Mnemonics.setLocalizedText(lblFilter, org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "filterLabel.text")); // NOI18N |
553 |
org.openide.awt.Mnemonics.setLocalizedText(lblFilter, org.openide.util.NbBundle.getMessage(SearchHistoryPanel.class, "filterLabel.text")); // NOI18N |
Lines 595-600
Link Here
|
595 |
} |
641 |
} |
596 |
}//GEN-LAST:event_cmbFilterKindActionPerformed |
642 |
}//GEN-LAST:event_cmbFilterKindActionPerformed |
597 |
|
643 |
|
|
|
644 |
private void cmbBranchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbBranchActionPerformed |
645 |
Object filter = cmbBranch.getSelectedItem(); |
646 |
boolean refresh = filter != currentBranchFilter; |
647 |
if (refresh) { |
648 |
currentBranchFilter = filter; |
649 |
filterTimer.restart(); |
650 |
} |
651 |
}//GEN-LAST:event_cmbBranchActionPerformed |
652 |
|
598 |
@Override |
653 |
@Override |
599 |
public void insertUpdate(DocumentEvent e) { |
654 |
public void insertUpdate(DocumentEvent e) { |
600 |
documentChanged(e); |
655 |
documentChanged(e); |
Lines 654-666
Link Here
|
654 |
final javax.swing.JButton bPrev = new javax.swing.JButton(); |
709 |
final javax.swing.JButton bPrev = new javax.swing.JButton(); |
655 |
private javax.swing.JButton bSearch; |
710 |
private javax.swing.JButton bSearch; |
656 |
private javax.swing.ButtonGroup buttonGroup1; |
711 |
private javax.swing.ButtonGroup buttonGroup1; |
|
|
712 |
private javax.swing.JComboBox cmbBranch; |
657 |
private javax.swing.JComboBox cmbFilterKind; |
713 |
private javax.swing.JComboBox cmbFilterKind; |
658 |
private org.netbeans.modules.versioning.history.LinkButton expandCriteriaButton; |
714 |
private org.netbeans.modules.versioning.history.LinkButton expandCriteriaButton; |
659 |
final javax.swing.JCheckBox fileInfoCheckBox = new javax.swing.JCheckBox(); |
715 |
final javax.swing.JCheckBox fileInfoCheckBox = new javax.swing.JCheckBox(); |
660 |
private javax.swing.JToolBar.Separator jSeparator1; |
716 |
private javax.swing.JToolBar.Separator jSeparator1; |
661 |
private javax.swing.JSeparator jSeparator2; |
717 |
private javax.swing.JSeparator jSeparator2; |
662 |
private javax.swing.JToolBar.Separator jSeparator3; |
718 |
private javax.swing.JToolBar.Separator jSeparator3; |
|
|
719 |
private javax.swing.JToolBar.Separator jSeparator4; |
663 |
private javax.swing.JToolBar jToolBar1; |
720 |
private javax.swing.JToolBar jToolBar1; |
|
|
721 |
private javax.swing.JLabel lblBranch; |
664 |
private javax.swing.JLabel lblFilter; |
722 |
private javax.swing.JLabel lblFilter; |
665 |
private javax.swing.JLabel lblFilterContains; |
723 |
private javax.swing.JLabel lblFilterContains; |
666 |
private javax.swing.JPanel resultsPanel; |
724 |
private javax.swing.JPanel resultsPanel; |
Lines 759-764
Link Here
|
759 |
|| contains(rev.getTags(), filterText); |
817 |
|| contains(rev.getTags(), filterText); |
760 |
} |
818 |
} |
761 |
} |
819 |
} |
|
|
820 |
Object selectedBranchFilter = currentBranchFilter; |
821 |
if (visible && selectedBranchFilter instanceof GitBranch) { |
822 |
visible = rev.getLog().getBranches().containsKey(((GitBranch) currentBranchFilter).getName()); |
823 |
} |
762 |
return visible; |
824 |
return visible; |
763 |
} |
825 |
} |
764 |
|
826 |
|
Lines 862-865
Link Here
|
862 |
this.diffViewFactory = fac; |
924 |
this.diffViewFactory = fac; |
863 |
} |
925 |
} |
864 |
} |
926 |
} |
|
|
927 |
|
928 |
private void refreshBranchFilterModel () { |
929 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
930 |
model.addElement(ALL_BRANCHES_FILTER); |
931 |
for (Map.Entry<String, GitBranch> e : info.getBranches().entrySet()) { |
932 |
GitBranch b = e.getValue(); |
933 |
if (b.getName() != GitBranch.NO_BRANCH) { |
934 |
model.addElement(b); |
935 |
if (currentBranchFilter instanceof GitBranch && b.getName().equals(((GitBranch) currentBranchFilter).getName())) { |
936 |
currentBranchFilter = b; |
937 |
} |
938 |
} |
939 |
} |
940 |
cmbBranch.setModel(model); |
941 |
cmbBranch.setSelectedItem(currentBranchFilter); |
942 |
} |
943 |
|
944 |
private void updateBranchFilter (String branch) { |
945 |
currentBranchFilter = ALL_BRANCHES_FILTER; |
946 |
if (branch != null) { |
947 |
ComboBoxModel model = cmbBranch.getModel(); |
948 |
for (int i = 0; i < model.getSize(); ++i) { |
949 |
Object filter = model.getElementAt(i); |
950 |
if (filter instanceof GitBranch && branch.equals(((GitBranch) filter).getName())) { |
951 |
currentBranchFilter = filter; |
952 |
break; |
953 |
} |
954 |
} |
955 |
} |
956 |
cmbBranch.setSelectedItem(currentBranchFilter); |
957 |
} |
865 |
} |
958 |
} |