This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 216833
Collapse All | Expand All

(-)a/jumpto/nbproject/project.properties (-54 / +54 lines)
Lines 1-54 Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
2
#
3
# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
3
# Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
4
#
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
6
# Other names may be trademarks of their respective owners.
7
#
7
#
8
# The contents of this file are subject to the terms of either the GNU
8
# The contents of this file are subject to the terms of either the GNU
9
# General Public License Version 2 only ("GPL") or the Common
9
# General Public License Version 2 only ("GPL") or the Common
10
# Development and Distribution License("CDDL") (collectively, the
10
# Development and Distribution License("CDDL") (collectively, the
11
# "License"). You may not use this file except in compliance with the
11
# "License"). You may not use this file except in compliance with the
12
# License. You can obtain a copy of the License at
12
# License. You can obtain a copy of the License at
13
# http://www.netbeans.org/cddl-gplv2.html
13
# http://www.netbeans.org/cddl-gplv2.html
14
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
14
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
# specific language governing permissions and limitations under the
15
# specific language governing permissions and limitations under the
16
# License.  When distributing the software, include this License Header
16
# License.  When distributing the software, include this License Header
17
# Notice in each file and include the License file at
17
# Notice in each file and include the License file at
18
# nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
18
# nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
19
# particular file as subject to the "Classpath" exception as provided
19
# particular file as subject to the "Classpath" exception as provided
20
# by Oracle in the GPL Version 2 section of the License file that
20
# by Oracle in the GPL Version 2 section of the License file that
21
# accompanied this code. If applicable, add the following below the
21
# accompanied this code. If applicable, add the following below the
22
# License Header, with the fields enclosed by brackets [] replaced by
22
# License Header, with the fields enclosed by brackets [] replaced by
23
# your own identifying information:
23
# your own identifying information:
24
# "Portions Copyrighted [year] [name of copyright owner]"
24
# "Portions Copyrighted [year] [name of copyright owner]"
25
#
25
#
26
# Contributor(s):
26
# Contributor(s):
27
#
27
#
28
# The Original Software is the Accelerators module.
28
# The Original Software is the Accelerators module.
29
# The Initial Developer of the Original Software is Andrei Badea.
29
# The Initial Developer of the Original Software is Andrei Badea.
30
# Portions Copyright 2005-2006 Andrei Badea.
30
# Portions Copyright 2005-2006 Andrei Badea.
31
# All Rights Reserved.
31
# All Rights Reserved.
32
#
32
#
33
# If you wish your version of this file to be governed by only the CDDL
33
# If you wish your version of this file to be governed by only the CDDL
34
# or only the GPL Version 2, indicate your decision by adding
34
# or only the GPL Version 2, indicate your decision by adding
35
# "[Contributor] elects to include this software in this distribution
35
# "[Contributor] elects to include this software in this distribution
36
# under the [CDDL or GPL Version 2] license." If you do not indicate a
36
# under the [CDDL or GPL Version 2] license." If you do not indicate a
37
# single choice of license, a recipient has the option to distribute
37
# single choice of license, a recipient has the option to distribute
38
# your version of this file under either the CDDL, the GPL Version 2 or
38
# your version of this file under either the CDDL, the GPL Version 2 or
39
# to extend the choice of license to its licensees as provided above.
39
# to extend the choice of license to its licensees as provided above.
40
# However, if you add GPL Version 2 code and therefore, elected the GPL
40
# However, if you add GPL Version 2 code and therefore, elected the GPL
41
# Version 2 license, then the option applies only if the new code is
41
# Version 2 license, then the option applies only if the new code is
42
# made subject to such option by the copyright holder.
42
# made subject to such option by the copyright holder.
43
#
43
#
44
# Contributor(s): Andrei Badea
44
# Contributor(s): Andrei Badea
45
45
46
javac.compilerargs=-Xlint:unchecked
46
javac.compilerargs=-Xlint:unchecked
47
javac.source=1.6
47
javac.source=1.6
48
makenbm.override.license=LICENSE
48
makenbm.override.license=LICENSE
49
nbm.module.author=Andrei Badea, Petr Hrebejk
49
nbm.module.author=Andrei Badea, Petr Hrebejk
50
spec.version.base=1.29.0
50
spec.version.base=1.29.0
51
51
52
test.config.stableBTD.includes=**/*Test.class
52
test.config.stableBTD.includes=**/*Test.class
53
test.config.stableBTD.excludes=\
53
test.config.stableBTD.excludes=\
54
    **/GoToTypeActionTest.class
54
    **/GoToTypeActionTest.class
(-)a/jumpto/src/org/netbeans/modules/jumpto/type/GoToPanel.form (-1 / +1 lines)
Lines 1-4 Link Here
1
<?xml version="1.1" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.4" maxVersion="1.4" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <Properties>
4
  <Properties>
(-)a/jumpto/src/org/netbeans/modules/jumpto/type/GoToPanel.java (-1 / +4 lines)
Lines 563-568 Link Here
563
                }
563
                }
564
            dialog.oldText = text;
564
            dialog.oldText = text;
565
            dialog.contentProvider.setListModel(dialog,text);            
565
            dialog.contentProvider.setListModel(dialog,text);            
566
            
567
            //recreate the renderer because the renderer needs the current text for highlighting
568
            dialog.matchesList.setCellRenderer( dialog.contentProvider.getListCellRenderer( dialog.matchesList ) );
566
        }
569
        }
567
                                         
570
                                         
568
    }
571
    }
Lines 579-583 Link Here
579
        public boolean hasValidContent ();
582
        public boolean hasValidContent ();
580
                
583
                
581
    }
584
    }
582
    
585
583
}
586
}
(-)a/jumpto/src/org/netbeans/modules/jumpto/type/GoToTypeAction.java (-7 / +29 lines)
Lines 11-17 Link Here
11
 * Development and Distribution License("CDDL") (collectively, the
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
14
 * http://www.netbeans.org/cddl-gplv2.
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
17
 * License.  When distributing the software, include this License Header
Lines 47-53 Link Here
47
import org.netbeans.spi.jumpto.type.SearchType;
47
import org.netbeans.spi.jumpto.type.SearchType;
48
import org.netbeans.spi.jumpto.type.TypeProvider;
48
import org.netbeans.spi.jumpto.type.TypeProvider;
49
import org.netbeans.spi.jumpto.type.TypeDescriptor;
49
import org.netbeans.spi.jumpto.type.TypeDescriptor;
50
import java.awt.BorderLayout;
51
import java.awt.Component;
50
import java.awt.Component;
52
import java.awt.Color;
51
import java.awt.Color;
53
import java.awt.Container;
52
import java.awt.Container;
Lines 69-74 Link Here
69
import java.util.Arrays;
68
import java.util.Arrays;
70
import java.util.Collection;
69
import java.util.Collection;
71
import java.util.Collections;
70
import java.util.Collections;
71
import java.util.EnumSet;
72
import java.util.List;
72
import java.util.List;
73
import java.util.logging.Level;
73
import java.util.logging.Level;
74
import java.util.logging.Logger;
74
import java.util.logging.Logger;
Lines 220-226 Link Here
220
    
220
    
221
    @Override
221
    @Override
222
    public ListCellRenderer getListCellRenderer( JList list ) {
222
    public ListCellRenderer getListCellRenderer( JList list ) {
223
        return new Renderer( list );        
223
        
224
        String searchText="";
225
        if (null!=panel && null!=panel.nameField){
226
            searchText=panel.nameField.getText();
227
        }
228
        
229
        return new Renderer( list , searchText, nameKind);        
224
    }
230
    }
225
    
231
    
226
    
232
    
Lines 638-647 Link Here
638
        private Color fgSelectionColor;
644
        private Color fgSelectionColor;
639
        
645
        
640
        private JList jList;
646
        private JList jList;
647
        private final String searchText;
648
        private final ITypeNameFormatter typeNameFormatter;
641
649
642
        @SuppressWarnings("LeakingThisInConstructor")
650
        @SuppressWarnings("LeakingThisInConstructor")
643
        public Renderer( JList list ) {
651
        public Renderer( JList list, String searchText , SearchType nameKind) {
644
            
652
            this.searchText=searchText;
645
            jList = list;
653
            jList = list;
646
            
654
            
647
            Container container = list.getParent();
655
            Container container = list.getParent();
Lines 713-719 Link Here
713
                            );
721
                            );
714
            bgSelectionColor = list.getSelectionBackground();
722
            bgSelectionColor = list.getSelectionBackground();
715
            fgSelectionColor = list.getSelectionForeground();        
723
            fgSelectionColor = list.getSelectionForeground();        
724
            
725
            EnumSet<SearchType> caseInsensitivTypes = EnumSet.of(SearchType.CASE_INSENSITIVE_EXACT_NAME, SearchType.CASE_INSENSITIVE_PREFIX, SearchType.CASE_INSENSITIVE_REGEXP);
726
            boolean caseSensitive=!caseInsensitivTypes.contains(nameKind);
727
728
            
729
            this.typeNameFormatter = new HighlightingTypeNameFormatter(fgColor, bgColor,caseSensitive);
716
        }
730
        }
731
732
717
        
733
        
718
        public @Override Component getListCellRendererComponent( JList list,
734
        public @Override Component getListCellRendererComponent( JList list,
719
                                                       Object value,
735
                                                       Object value,
Lines 749-757 Link Here
749
            
765
            
750
            if ( value instanceof TypeDescriptor ) {
766
            if ( value instanceof TypeDescriptor ) {
751
                long time = System.currentTimeMillis();
767
                long time = System.currentTimeMillis();
752
                TypeDescriptor td = (TypeDescriptor)value;                
768
                TypeDescriptor td = (TypeDescriptor)value;     
769
                
753
                jlName.setIcon(td.getIcon());
770
                jlName.setIcon(td.getIcon());
754
                jlName.setText(td.getTypeName());
771
772
                String typeName = td.getTypeName();
773
                
774
                String formattedTypeName = typeNameFormatter.formatTypeName(typeName, searchText);
775
                
776
                jlName.setText(String.format("<html>%s</html>", formattedTypeName));
755
                jlPkg.setText(td.getContextName());
777
                jlPkg.setText(td.getContextName());
756
                setProjectName(jlPrj, td.getProjectName());
778
                setProjectName(jlPrj, td.getProjectName());
757
                jlPrj.setIcon(td.getProjectIcon());
779
                jlPrj.setIcon(td.getProjectIcon());
(-)a/jumpto/src/org/netbeans/modules/jumpto/type/HighlightingTypeNameFormatter.java (+137 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.jumpto.type;
43
44
import java.awt.Color;
45
import java.util.ArrayList;
46
import java.util.Arrays;
47
import java.util.BitSet;
48
import java.util.List;
49
50
/**
51
 *
52
 * @author Bender
53
 */
54
class HighlightingTypeNameFormatter implements ITypeNameFormatter {
55
56
    private static final String FORMATPATTERN = "<span style=\"background-color:%s; font-weight:bold; color:%s\">%s</span>";
57
    private final boolean caseSensitive;
58
    private String formatPattern;
59
60
    HighlightingTypeNameFormatter(Color bgColor, Color fgColor, boolean caseSensitive) {
61
        String bgColorHighlight = Integer.toHexString(bgColor.getRGB()).substring(2);
62
        String fgColorHighlight = Integer.toHexString(fgColor.getRGB()).substring(2);
63
        formatPattern = String.format(FORMATPATTERN, bgColorHighlight, fgColorHighlight, "%s");
64
        this.caseSensitive = caseSensitive;
65
    }
66
67
    List<String> splitByCamelCaseAndWildcards(String searchText) {
68
        //AbcDeFGhiJo -> [Abc, De, F, Ghi, Jo]
69
        StringBuilder sb = new StringBuilder(searchText.length());
70
        for (char c : searchText.toCharArray()) {
71
            if (Character.isUpperCase(c)) {
72
                //add magic split marker into text before the uppercase char
73
                //example: AbcDeFGhiJo -> &Abc&De&F&Ghi&Jo
74
                sb.append("&");
75
                sb.append(c);
76
            } else {
77
                sb.append(c);
78
            }
79
        }
80
        //split by camelcase (using the split marker) or the wildcards *,?
81
        String[] split = sb.toString().split("[&|\\*|\\?]");
82
        return Arrays.asList(split);
83
    }
84
85
    @Override
86
    public String formatTypeName(String typeName, String textToFind) {
87
88
        if (null == textToFind || "".equals(textToFind)) {
89
            return typeName;
90
        }
91
        BitSet bitSet = new BitSet(typeName.length());
92
        List<String> parts = splitByCamelCaseAndWildcards(textToFind);
93
94
        String convertedTypeName = caseSensitive ? typeName : typeName.toLowerCase();
95
        //mark the chars to be highlighted
96
        int startIndex = 0;
97
        for (String camelCasePart : parts) {
98
99
            int indexOf = convertedTypeName.indexOf(caseSensitive ? camelCasePart : camelCasePart.toLowerCase(), startIndex);
100
            if (indexOf != -1) {
101
102
                //mark the chars 
103
                bitSet.set(indexOf, indexOf + camelCasePart.length(), true);
104
            } else {
105
                break;
106
            }
107
            startIndex = indexOf + camelCasePart.length();
108
        }
109
110
        //highlight the marked chars via  tags
111
        StringBuilder formattedTypeName = new StringBuilder();
112
        int i = 0;
113
        while (i < typeName.toCharArray().length) {
114
115
            boolean isMarked = bitSet.get(i);
116
117
            if (isMarked) {
118
                int numberOfContinuousHighlights = bitSet.nextClearBit(i) - i;
119
                String part = typeName.substring(i, i + numberOfContinuousHighlights);
120
                formattedTypeName.append(String.format(formatPattern, part));
121
                i += numberOfContinuousHighlights;
122
            } else {
123
                formattedTypeName.append(typeName.charAt(i));
124
                i++;
125
            }
126
        }
127
        return formattedTypeName.toString();
128
    }
129
130
    /**
131
     * Allow to inject a pattern, so it can be tested easier.
132
     * @param pattern 
133
     */
134
    void setFormatPattern(String pattern) {
135
        this.formatPattern = pattern;
136
    }
137
}
(-)a/jumpto/src/org/netbeans/modules/jumpto/type/ITypeNameFormatter.java (+53 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.jumpto.type;
43
44
import java.awt.Color;
45
46
/**
47
 *
48
 * @author Bender
49
 */
50
interface ITypeNameFormatter {
51
52
    String formatTypeName(String typeName, String textToFind);
53
}
(-)a/jumpto/test/unit/src/org/netbeans/modules/jumpto/type/HighlightingTypeNameFormatterTest.java (+117 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.jumpto.type;
43
44
import java.awt.Color;
45
import java.util.List;
46
import org.junit.Test;
47
import static org.junit.Assert.*;
48
import org.junit.Before;
49
50
/**
51
 *
52
 * @author markiewb
53
 */
54
public class HighlightingTypeNameFormatterTest {
55
56
    private Color fg = Color.WHITE;
57
    private Color bg = Color.BLACK;
58
    private HighlightingTypeNameFormatter cut;
59
60
    @Before
61
    public void before() {
62
        cut = new HighlightingTypeNameFormatter(fg, bg, true);
63
        cut.setFormatPattern("[%s]");
64
    }
65
66
    /**
67
     * Test of formatTypeName method, of class HighlightingTypeNameFormatter.
68
     */
69
    @Test
70
    public void testFormatTypeName_CamelCase() {
71
        String typeName = "AbstractDummyBarTest";
72
73
        assertEquals("[AbstractDummyBarTest]", cut.formatTypeName(typeName, "AbstractDummyBarTest"));
74
        assertEquals("[Abstra]ct[D]ummy[B]arTest", cut.formatTypeName(typeName, "AbstraDB"));
75
        assertEquals("[A]bstract[Dum]my[B]arTest", cut.formatTypeName(typeName, "ADumB"));
76
        assertEquals("[A]bstract[D]ummy[Ba]rTest", cut.formatTypeName(typeName, "ADBa"));
77
        assertEquals("[A]bstract[D]ummy[B]ar[Test]", cut.formatTypeName(typeName, "ADBTest"));
78
        assertEquals("[Ab]stract[Du]mmy[B]ar[Test]", cut.formatTypeName(typeName, "AbDuBTest"));
79
    }
80
81
    @Test
82
    public void testFormatTypeName_NullOrEmpty() {
83
        String typeName = "AbstractDummyBarTest";
84
        assertEquals("AbstractDummyBarTest", cut.formatTypeName(typeName, null));
85
        assertEquals("AbstractDummyBarTest", cut.formatTypeName(typeName, ""));
86
    }
87
88
    @Test
89
    public void testFormatTypeName_Wildcard_CaseSensitive() {
90
        cut = new HighlightingTypeNameFormatter(fg, bg, true);
91
        cut.setFormatPattern("[%s]");
92
        String typeName = "AbstractDummyBarTest";
93
94
        assertEquals("[A]bstractDummyBar[Test]", cut.formatTypeName(typeName, "A*Test"));
95
        assertEquals("[A]bstractDummy[B]ar[Test]", cut.formatTypeName(typeName, "A*B*Test"));
96
        assertEquals("[A]bstractDummy[BarTest]", cut.formatTypeName(typeName, "A*Bar*Test"));
97
    }
98
99
    @Test
100
    public void testFormatTypeName_Wildcard_CaseInSensitive() {
101
        cut = new HighlightingTypeNameFormatter(fg, bg, false);
102
        cut.setFormatPattern("[%s]");
103
        String typeName = "AbstractDummyBarTest";
104
105
        assertEquals("[A]bstractDummyBar[Test]", cut.formatTypeName(typeName, "A*Test"));
106
        assertEquals("[Ab]stractDummyBar[Test]", cut.formatTypeName(typeName, "A*B*Test"));
107
        assertEquals("[A]bstractDummy[BarTest]", cut.formatTypeName(typeName, "A*Bar*Test"));
108
    }
109
110
    @Test
111
    public void testFormatTypeName_FullFormat() {
112
        cut = new HighlightingTypeNameFormatter(fg, bg, false);
113
        String typeName = "AbstractDummyBarTest";
114
115
        assertEquals("<span style=\"background-color:ffffff; font-weight:bold; color:000000\">A</span>bstract<span style=\"background-color:ffffff; font-weight:bold; color:000000\">D</span>ummy<span style=\"background-color:ffffff; font-weight:bold; color:000000\">B</span>ar<span style=\"background-color:ffffff; font-weight:bold; color:000000\">Test</span>", cut.formatTypeName(typeName, "ADBTest"));
116
    }
117
}

Return to bug 216833