[hg] main-silver: #70775: "Match Case" option in the "Add Module...

  • From: Martin Kozeny < >
  • To:
  • Subject: [hg] main-silver: #70775: "Match Case" option in the "Add Module...
  • Date: Fri, 11 Jan 2013 12:36:00 -0800

changeset 5858451be2b7 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5858451be2b7
description:
        #70775: "Match Case" option in the "Add Module Dependency" dialog is 
now provided.

diffstat:

 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilter.java
               |   6 +-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.form
                |  20 ++++++-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
                |  30 +++++++++-
 
apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/Bundle.properties
                  |   1 +
 
apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilterTest.java
 |   6 +-
 5 files changed, 53 insertions(+), 10 deletions(-)

diffs (205 lines):

diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilter.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilter.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilter.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilter.java
@@ -82,8 +82,8 @@
     /**
      * Find matches for a search string.
      */
-    public Set<ModuleDependency> getMatches(String text) {
-        String textLC = text.toLowerCase(Locale.ENGLISH);
+    public Set<ModuleDependency> getMatches(String text, Boolean matchCase) {
+        String textLC = matchCase?text:text.toLowerCase(Locale.ENGLISH);
         List<Set<ModuleDependency>> matches = new 
ArrayList<Set<ModuleDependency>>(3);
         for (int i = 0; i < 3; i++) {
             // Within groups, just sort by module display name:
@@ -95,7 +95,7 @@
             }
             int matchLevel = 3;
             for (String tok : dep.getFilterTokens(dependingModuleCNB)) {
-                String token = tok.toLowerCase(Locale.ENGLISH);
+                String token = matchCase?tok:tok.toLowerCase(Locale.ENGLISH);
                 // Presort by relevance (#71995):
                 if (token.equals(textLC) || token.endsWith("." + textLC)) { 
// NOI18N
                     // Exact match (possibly after dot).
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.form
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.form
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.form
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.form
@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 
 <Form version="1.2" maxVersion="1.2" 
type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <Properties>
@@ -164,5 +164,23 @@
         </Constraint>
       </Constraints>
     </Component>
+    <Component class="javax.swing.JCheckBox" name="matchCaseValue">
+      <Properties>
+        <Property name="text" type="java.lang.String" 
editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+          <Connection 
code="org.openide.util.NbBundle.getMessage(AddModulePanel.class, 
&quot;CTL_MatchCase&quot;)" type="code"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" 
listener="java.awt.event.ActionListener" 
parameters="java.awt.event.ActionEvent" 
handler="matchCaseValueActionPerformed"/>
+      </Events>
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_InitCodePost" 
type="java.lang.String" 
value="matchCaseValue.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,
 0, 0, 0));"/>
+      </AuxValues>
+      <Constraints>
+        <Constraint 
layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" 
value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+          <GridBagConstraints gridX="1" gridY="1" gridWidth="0" 
gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="9" insetsLeft="0" 
insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+        </Constraint>
+      </Constraints>
+    </Component>
   </SubComponents>
 </Form>
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModulePanel.java
@@ -207,6 +207,7 @@
         filterValue.setEnabled(false);
         moduleList.setEnabled(false);
         showNonAPIModules.setEnabled(false);
+        matchCaseValue.setEnabled(false);
         final String lastFilter = filterValue.getText();
         filterValue.setText(UIUtil.WAIT_VALUE);
         moduleList.setModel(UIUtil.createListWaitModel());
@@ -223,6 +224,7 @@
                         moduleList.setEnabled(true);
                         filterValue.setEnabled(true);
                         showNonAPIModules.setEnabled(true);
+                        matchCaseValue.setEnabled(true);
                         filterValue.setText(lastFilter);
                         if (!FILTER_DESCRIPTION.equals(lastFilter)) {
                             search();
@@ -238,6 +240,7 @@
     
     private void showDescription() {
         StyledDocument doc = descValue.getStyledDocument();
+        final Boolean matchCase = matchCaseValue.isSelected();
         try {
             doc.remove(0, doc.getLength());
             ModuleDependency[] deps = getSelectedDependencies();
@@ -256,7 +259,7 @@
                 doc.insertString(doc.getLength(), 
getMessage("TEXT_matching_filter_contents"), bold);
                 doc.insertString(doc.getLength(), "\n", null); // NOI18N
                 if (filterText.length() > 0) {
-                    String filterTextLC = filterText.toLowerCase(Locale.US);
+                    String filterTextLC = 
matchCase?filterText:filterText.toLowerCase(Locale.US);
                     Style match = doc.addStyle(null, null);
                     match.addAttribute(StyleConstants.Background, new 
Color(246, 248, 139));
                     boolean isEven = false;
@@ -268,7 +271,7 @@
                     for (String hit : filterer.getMatchesFor(filterText, 
deps[0])) {
                         int loc = doc.getLength();
                         doc.insertString(loc, hit, (isEven ? even : null));
-                        int start = 
hit.toLowerCase(Locale.US).indexOf(filterTextLC);
+                        int start = 
(matchCase?hit:hit.toLowerCase(Locale.US)).indexOf(filterTextLC);
                         while (start != -1) {
                             doc.setCharacterAttributes(loc + start, 
filterTextLC.length(), match, true);
                             start = 
hit.toLowerCase(Locale.US).indexOf(filterTextLC, start + 1);
@@ -316,6 +319,7 @@
     private void search() {
         cancelFilterTask();
         final String text = filterValue.getText();
+        final Boolean matchCase = matchCaseValue.isSelected();
         if (text.length() == 0) {
             moduleList.setModel(universeModules);
             moduleList.setSelectedIndex(0);
@@ -327,7 +331,7 @@
                     if (_filterer == null) {
                         return;
                     }
-                    final Set<ModuleDependency> matches = 
_filterer.getMatches(text);
+                    final Set<ModuleDependency> matches = 
_filterer.getMatches(text, matchCase);
                     synchronized (AddModulePanel.this) {
                         filterTask = null;
                     }
@@ -407,6 +411,7 @@
         descValue = new javax.swing.JTextPane();
         showJavadocButton = new javax.swing.JButton();
         showNonAPIModules = new javax.swing.JCheckBox();
+        matchCaseValue = new javax.swing.JCheckBox();
 
         setBorder(javax.swing.BorderFactory.createEmptyBorder(6, 6, 6, 6));
         setPreferredSize(new java.awt.Dimension(500, 450));
@@ -504,6 +509,20 @@
         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
         gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0);
         add(showNonAPIModules, gridBagConstraints);
+
+        org.openide.awt.Mnemonics.setLocalizedText(matchCaseValue, 
org.openide.util.NbBundle.getMessage(AddModulePanel.class, "CTL_MatchCase"));
+        
matchCaseValue.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 
0));
+        matchCaseValue.addActionListener(new java.awt.event.ActionListener() 
{
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                matchCaseValueActionPerformed(evt);
+            }
+        });
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 1;
+        gridBagConstraints.gridy = 1;
+        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+        gridBagConstraints.insets = new java.awt.Insets(9, 0, 0, 0);
+        add(matchCaseValue, gridBagConstraints);
     }// </editor-fold>//GEN-END:initComponents
     
     private void showNonAPIModulesActionPerformed(java.awt.event.ActionEvent 
evt) {//GEN-FIRST:event_showNonAPIModulesActionPerformed
@@ -514,6 +533,10 @@
         HtmlBrowser.URLDisplayer.getDefault().showURL(currectJavadoc);
     }//GEN-LAST:event_showJavadoc
     
+    private void matchCaseValueActionPerformed(java.awt.event.ActionEvent 
evt) {//GEN-FIRST:event_matchCaseValueActionPerformed
+        fillUpUniverseModules();
+    }//GEN-LAST:event_matchCaseValueActionPerformed
+    
     
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JLabel descLabel;
@@ -521,6 +544,7 @@
     private javax.swing.JScrollPane descValueSP;
     private javax.swing.JLabel filter;
     javax.swing.JTextField filterValue;
+    private javax.swing.JCheckBox matchCaseValue;
     private javax.swing.JLabel moduleLabel;
     javax.swing.JList moduleList;
     private javax.swing.JScrollPane moduleSP;
diff --git 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/Bundle.properties
 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/Bundle.properties
--- 
a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/Bundle.properties
+++ 
b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/customizer/Bundle.properties
@@ -102,6 +102,7 @@
 TEXT_matching_filter_contents=Matching Filter Contents:
 TEXT_no_filter_specified=no filter specified
 CTL_ShowNonAPIModules=Show &Non-API Modules
+CTL_MatchCase=&Match Case
 
 
 # edit dependency detail and versioning panel
diff --git 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilterTest.java
 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilterTest.java
--- 
a/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilterTest.java
+++ 
b/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/ui/customizer/AddModuleFilterTest.java
@@ -104,13 +104,13 @@
 //    }
     
     public void testMatchStrings() throws Exception {
-        ModuleDependency dep = 
filter.getMatches("callablesys").iterator().next();
+        ModuleDependency dep = filter.getMatches("callablesys", 
false).iterator().next();
         
assertEquals(Collections.singleton("org.openide.util.actions.CallableSystemAction"),
 filter.getMatchesFor("callablesys", dep));
     }
     
     public void testMatchOrdering() throws Exception { // #71995
         List<String> matches = new ArrayList<String>();
-        for (ModuleDependency dep : filter.getMatches("systemaction")) {
+        for (ModuleDependency dep : filter.getMatches("systemaction", 
false)) {
             matches.add(dep.getModuleEntry().getCodeNameBase());
         }
         assertEquals(Arrays.asList(
@@ -122,7 +122,7 @@
     
     private void assertMatches(String text, String[] cnbs) {
         Set<String> matchedCNBs = new HashSet<String>();
-        for (ModuleDependency dep : filter.getMatches(text)) {
+        for (ModuleDependency dep : filter.getMatches(text, false)) {
             matchedCNBs.add(dep.getModuleEntry().getCodeNameBase());
         }
         assertEquals("correct matches for '" + text + "'", new 
HashSet<String>(Arrays.asList(cnbs)), matchedCNBs);

[hg] main-silver: #70775: "Match Case" option in the "Add Module...

Martin Kozeny 01/11/2013

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close