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 125060
Collapse All | Expand All

(-)a/java.editor/src/org/netbeans/modules/editor/java/JavaCompletionProvider.java (-3 / +6 lines)
Lines 2427-2433 Link Here
2427
                                    (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) &&
2427
                                    (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) &&
2428
                                    (!isStatic || e.getModifiers().contains(STATIC)) &&
2428
                                    (!isStatic || e.getModifiers().contains(STATIC)) &&
2429
                                    tu.isAccessible(scope, e, t) &&
2429
                                    tu.isAccessible(scope, e, t) &&
2430
                                    !Utilities.isExcluded(Utilities.getElementName(e.getEnclosingElement(), true) + "." + sn); //NOI18N
2430
                                    (!Utilities.isExcludeMethods() || !Utilities.isExcluded(Utilities.getElementName(e.getEnclosingElement(), true) + "." + sn)); //NOI18N
2431
                    }
2431
                    }
2432
                    return false;
2432
                    return false;
2433
                }
2433
                }
Lines 2614-2620 Link Here
2614
                                    isOfKindAndType(((ExecutableType)asMemberOf(e, t, types)).getReturnType(), e, kinds, baseType, scope, trees, types) &&
2614
                                    isOfKindAndType(((ExecutableType)asMemberOf(e, t, types)).getReturnType(), e, kinds, baseType, scope, trees, types) &&
2615
                                    (isSuperCall && e.getModifiers().contains(PROTECTED) || tu.isAccessible(scope, e, isSuperCall && enclType != null ? enclType : t)) &&
2615
                                    (isSuperCall && e.getModifiers().contains(PROTECTED) || tu.isAccessible(scope, e, isSuperCall && enclType != null ? enclType : t)) &&
2616
                                    (!isStatic || e.getModifiers().contains(STATIC)) &&
2616
                                    (!isStatic || e.getModifiers().contains(STATIC)) &&
2617
                                    !Utilities.isExcluded(Utilities.getElementName(e.getEnclosingElement(), true) + "." + sn); //NOI18N
2617
                                    (!Utilities.isExcludeMethods() || !Utilities.isExcluded(Utilities.getElementName(e.getEnclosingElement(), true) + "." + sn)); //NOI18N
2618
                        case CLASS:
2618
                        case CLASS:
2619
                        case ENUM:
2619
                        case ENUM:
2620
                        case INTERFACE:
2620
                        case INTERFACE:
Lines 2719-2725 Link Here
2719
            for(Element e : pe.getEnclosedElements()) {
2719
            for(Element e : pe.getEnclosedElements()) {
2720
                if (e.getKind().isClass() || e.getKind().isInterface()) {
2720
                if (e.getKind().isClass() || e.getKind().isInterface()) {
2721
                    String name = e.getSimpleName().toString();
2721
                    String name = e.getSimpleName().toString();
2722
                        if (startsWith(env, name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) && trees.isAccessible(scope, (TypeElement)e) && isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)) {
2722
                        if (startsWith(env, name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
2723
                        && trees.isAccessible(scope, (TypeElement)e)
2724
                        && isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
2725
                        && !Utilities.isExcluded(Utilities.getElementName(e, true))) {
2723
                            results.add(JavaCompletionItem.createTypeItem((TypeElement)e, (DeclaredType)e.asType(), anchorOffset, false, elements.isDeprecated(e), insideNew, isOfSmartType(env, e.asType(), smartTypes)));
2726
                            results.add(JavaCompletionItem.createTypeItem((TypeElement)e, (DeclaredType)e.asType(), anchorOffset, false, elements.isDeprecated(e), insideNew, isOfSmartType(env, e.asType(), smartTypes)));
2724
                    }
2727
                    }
2725
                }
2728
                }
(-)a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java (-28 / +43 lines)
Lines 56-61 Link Here
56
import com.sun.source.util.Trees;
56
import com.sun.source.util.Trees;
57
57
58
import java.util.*;
58
import java.util.*;
59
import java.util.concurrent.atomic.AtomicBoolean;
59
import java.util.concurrent.atomic.AtomicReference;
60
import java.util.concurrent.atomic.AtomicReference;
60
import java.util.prefs.PreferenceChangeEvent;
61
import java.util.prefs.PreferenceChangeEvent;
61
import java.util.prefs.PreferenceChangeListener;
62
import java.util.prefs.PreferenceChangeListener;
Lines 89-110 Link Here
89
 * @author Dusan Balek
90
 * @author Dusan Balek
90
 * @author Sam Halliday
91
 * @author Sam Halliday
91
 */
92
 */
92
public class Utilities {
93
public final class Utilities {
93
    
94
    
94
    private static final String CAPTURED_WILDCARD = "<captured wildcard>"; //NOI18N
95
    private static final String CAPTURED_WILDCARD = "<captured wildcard>"; //NOI18N
95
    private static final String ERROR = "<error>"; //NOI18N
96
    private static final String ERROR = "<error>"; //NOI18N
96
    private static final String UNKNOWN = "<unknown>"; //NOI18N
97
    private static final String UNKNOWN = "<unknown>"; //NOI18N
97
98
98
    private static boolean caseSensitive = true;
99
    private static volatile boolean caseSensitive = true;
99
    private static boolean showDeprecatedMembers = true;
100
    private static volatile boolean showDeprecatedMembers = true;
100
    private static boolean guessMethodArguments = true;
101
    private static volatile boolean guessMethodArguments = true;
101
    private static boolean autoPopupOnJavaIdentifierPart = true;
102
    private static volatile boolean autoPopupOnJavaIdentifierPart = true;
102
    private static String javaCompletionAutoPopupTriggers = null;
103
    private static volatile boolean javaCompletionExcluderMethods;
103
    private static String javaCompletionSelectors = null;
104
    private static volatile String javaCompletionAutoPopupTriggers = null;
104
    private static String javadocCompletionAutoPopupTriggers = null;
105
    private static volatile String javaCompletionSelectors = null;
106
    private static volatile String javadocCompletionAutoPopupTriggers = null;
105
    
107
    
106
    private static boolean inited;
108
    private static final AtomicBoolean inited = new AtomicBoolean(false);
107
    private static Preferences preferences;
109
    private static volatile Preferences preferences;
108
    private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() {
110
    private static final PreferenceChangeListener preferencesTracker = new PreferenceChangeListener() {
109
        public void preferenceChange(PreferenceChangeEvent evt) {
111
        public void preferenceChange(PreferenceChangeEvent evt) {
110
            String settingName = evt == null ? null : evt.getKey();
112
            String settingName = evt == null ? null : evt.getKey();
Lines 131-147 Link Here
131
            }
133
            }
132
            if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST.equals(settingName)) {
134
            if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST.equals(settingName)) {
133
                String blacklist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST, CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST_DEFAULT);
135
                String blacklist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST, CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST_DEFAULT);
134
                updateExcluder(exclude, blacklist);
136
                updateExcluder(excludeRef, blacklist);
135
            }
137
            }
136
            if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_WHITELIST.equals(settingName)) {
138
            if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_WHITELIST.equals(settingName)) {
137
                String whitelist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_WHITELIST, CodeCompletionPanel.JAVA_COMPLETION_WHITELIST_DEFAULT);
139
                String whitelist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_WHITELIST, CodeCompletionPanel.JAVA_COMPLETION_WHITELIST_DEFAULT);
138
                updateExcluder(include, whitelist);
140
                updateExcluder(includeRef, whitelist);
141
            }
142
            if (settingName == null || CodeCompletionPanel.JAVA_COMPLETION_EXCLUDER_METHODS.equals(settingName)) {
143
                javaCompletionExcluderMethods = preferences.getBoolean(CodeCompletionPanel.JAVA_COMPLETION_EXCLUDER_METHODS, CodeCompletionPanel.JAVA_COMPLETION_EXCLUDER_METHODS_DEFAULT);
139
            }
144
            }
140
        }
145
        }
141
    };
146
    };
142
    
147
    
143
    private static String cachedPrefix = null;
148
    private static volatile String cachedPrefix = null;
144
    private static Pattern cachedPattern = null;
149
    private static volatile Pattern cachedPattern = null;
145
    
150
    
146
    public static boolean startsWith(String theString, String prefix) {
151
    public static boolean startsWith(String theString, String prefix) {
147
        if (theString == null || theString.length() == 0 || ERROR.equals(theString))
152
        if (theString == null || theString.length() == 0 || ERROR.equals(theString))
Lines 225-232 Link Here
225
        return javadocCompletionAutoPopupTriggers;
230
        return javadocCompletionAutoPopupTriggers;
226
    }
231
    }
227
232
228
    static private volatile AtomicReference<Collection<String>> exclude;
233
    static private volatile AtomicReference<Collection<String>> excludeRef = new AtomicReference<Collection<String>>();
229
    static private volatile AtomicReference<Collection<String>> include;
234
    static private volatile AtomicReference<Collection<String>> includeRef = new AtomicReference<Collection<String>>();
230
235
231
    private static void updateExcluder(AtomicReference<Collection<String>> existing, String updated) {
236
    private static void updateExcluder(AtomicReference<Collection<String>> existing, String updated) {
232
        Collection<String> nue = new LinkedList<String>();
237
        Collection<String> nue = new LinkedList<String>();
Lines 236-242 Link Here
236
        }
241
        }
237
        String[] entries = updated.split(","); //NOI18N
242
        String[] entries = updated.split(","); //NOI18N
238
        for (String entry : entries) {
243
        for (String entry : entries) {
239
            if (entry != null && entry.length() != 0) {
244
            if (entry.length() != 0) {
240
                nue.add(entry);
245
                nue.add(entry);
241
            }
246
            }
242
        }
247
        }
Lines 244-261 Link Here
244
    }
249
    }
245
250
246
    /**
251
    /**
252
     * @return the user setting for whether the excluder should operate on methods
253
     */
254
    public static boolean isExcludeMethods(){
255
        lazyInit();
256
        return javaCompletionExcluderMethods;
257
    }
258
259
    /**
247
     * @param fqn Fully Qualified Name (including method names). Packages names are expected to
260
     * @param fqn Fully Qualified Name (including method names). Packages names are expected to
248
     * end in a trailing "."
261
     * end in a trailing "." except the default package.
249
     * @return
262
     * @return
250
     */
263
     */
251
    public static boolean isExcluded(final CharSequence fqn) {
264
    public static boolean isExcluded(final CharSequence fqn) {
252
        if (fqn == null || fqn.length() == 0 || fqn.equals(".")) { //NOI18N
265
        if (fqn == null || fqn.length() == 0) {
253
            return true;
266
            return true;
254
        }
267
        }
255
        lazyInit();
268
        lazyInit();
256
        String s = fqn.toString();
269
        String s = fqn.toString();
257
        if (!include.get().isEmpty()) {
270
        Collection<String> include = includeRef.get();
258
            for (String entry : include.get()) {
271
        Collection<String> exclude = excludeRef.get();
272
273
        if (include != null && !include.isEmpty()) {
274
            for (String entry : include) {
259
                if (entry.length() > fqn.length()) {
275
                if (entry.length() > fqn.length()) {
260
                    if (entry.startsWith(s)) {
276
                    if (entry.startsWith(s)) {
261
                        return false;
277
                        return false;
Lines 266-273 Link Here
266
            }
282
            }
267
        }
283
        }
268
284
269
        if (!exclude.get().isEmpty()) {
285
        if (exclude != null && !exclude.isEmpty()) {
270
            for (String entry : exclude.get()) {
286
            for (String entry : exclude) {
271
                if (entry.length() <= fqn.length() && s.startsWith(entry)) {
287
                if (entry.length() <= fqn.length() && s.startsWith(entry)) {
272
                    return true;
288
                    return true;
273
                }
289
                }
Lines 278-288 Link Here
278
    }
294
    }
279
295
280
    private static void lazyInit() {
296
    private static void lazyInit() {
281
        if (!inited) {
297
        if (inited.compareAndSet(false, true)) {
282
            inited = true;
283
            Collection<String> empty = Collections.emptySet();
284
            exclude = new AtomicReference<Collection<String>>(empty);
285
            include = new AtomicReference<Collection<String>>(empty);
286
            preferences = MimeLookup.getLookup(JavaKit.JAVA_MIME_TYPE).lookup(Preferences.class);
298
            preferences = MimeLookup.getLookup(JavaKit.JAVA_MIME_TYPE).lookup(Preferences.class);
287
            preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
299
            preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, preferencesTracker, preferences));
288
            preferencesTracker.preferenceChange(null);
300
            preferencesTracker.preferenceChange(null);
Lines 851-856 Link Here
851
863
852
        return found;
864
        return found;
853
    }
865
    }
866
867
    private Utilities() {
868
    }
854
    
869
    
855
    
870
    
856
}
871
}
(-)a/java.editor/src/org/netbeans/modules/java/editor/javadoc/JavadocCompletionQuery.java (-3 / +8 lines)
Lines 762-769 Link Here
762
//                                isOfKindAndType(asMemberOf(e, t, types), e, kinds, baseType, scope, trees, types) &&
762
//                                isOfKindAndType(asMemberOf(e, t, types), e, kinds, baseType, scope, trees, types) &&
763
                                tu.isAccessible(scope, e, t);
763
                                tu.isAccessible(scope, e, t);
764
                    case METHOD:
764
                    case METHOD:
765
                        return Utilities.startsWith(e.getSimpleName().toString(), prefix) &&
765
                        String sn = e.getSimpleName().toString();
766
                                (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e));
766
                        return Utilities.startsWith(sn, prefix) &&
767
                                (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) &&
768
                                (!Utilities.isExcludeMethods() || !Utilities.isExcluded(Utilities.getElementName(e.getEnclosingElement(), true) + "." + sn)); //NOI18N
767
//                                &&
769
//                                &&
768
//                                isOfKindAndType(((ExecutableType)asMemberOf(e, t, types)).getReturnType(), e, kinds, baseType, scope, trees, types) &&
770
//                                isOfKindAndType(((ExecutableType)asMemberOf(e, t, types)).getReturnType(), e, kinds, baseType, scope, trees, types) &&
769
//                                (isSuperCall && e.getModifiers().contains(PROTECTED) || tu.isAccessible(scope, e, isSuperCall && enclType != null ? enclType : t)) &&
771
//                                (isSuperCall && e.getModifiers().contains(PROTECTED) || tu.isAccessible(scope, e, isSuperCall && enclType != null ? enclType : t)) &&
Lines 1042-1048 Link Here
1042
        for(Element e : pe.getEnclosedElements()) {
1044
        for(Element e : pe.getEnclosedElements()) {
1043
            if (e.getKind().isClass() || e.getKind().isInterface()) {
1045
            if (e.getKind().isClass() || e.getKind().isInterface()) {
1044
                String name = e.getSimpleName().toString();
1046
                String name = e.getSimpleName().toString();
1045
                    if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e)) && trees.isAccessible(scope, (TypeElement)e) && isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)) {
1047
                    if (Utilities.startsWith(name, prefix) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(e))
1048
                        && trees.isAccessible(scope, (TypeElement)e)
1049
                        && isOfKindAndType(e.asType(), e, kinds, baseType, scope, trees, types)
1050
                        && !Utilities.isExcluded(Utilities.getElementName(e, true))) {
1046
                        items.add(JavadocCompletionItem.createTypeItem((TypeElement) e, substitutionOffset, false, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
1051
                        items.add(JavadocCompletionItem.createTypeItem((TypeElement) e, substitutionOffset, false, elements.isDeprecated(e)/*, isOfSmartType(env, e.asType(), smartTypes)*/));
1047
                }
1052
                }
1048
            }
1053
            }
(-)a/java.editor/src/org/netbeans/modules/java/editor/options/Bundle.properties (-5 / +10 lines)
Lines 124-133 Link Here
124
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title3_1=Title 4
124
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title3_1=Title 4
125
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title2_1=Title 3
125
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title2_1=Title 3
126
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title1_1=Title 2
126
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title1_1=Title 2
127
CodeCompletionPanel.javaCompletionExcluderAddButton.text=Add
128
CodeCompletionPanel.javaCompletionExcluderRemoveButton.text=Remove
129
CodeCompletionPanel.javaCompletionExcluderCloseButton.text=Close
130
CodeCompletionPanel.javaCompletionExcluderEditButton.text=Edit
127
CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle=Exclude
131
CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle=Exclude
128
CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0=Fully Qualified Name prefix
129
CodeCompletionPanel.javaCompletionExcluderAddButton.text=Add
130
CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle=Include
132
CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle=Include
131
CodeCompletionPanel.javaCompletionExcluderRemoveButton.text=Remove
133
CodeCompletionPanel.javaCompletionExcluderDialogCancelButton.text=Cancel
132
CodeCompletionPanel.javaCompletionExcluderFrame.title=Java Completion Excluder
134
CodeCompletionPanel.javaCompletionExcluderDialogTextField.text=
133
CodeCompletionPanel.javaCompletionExcluderCloseButton.text=Close
135
CodeCompletionPanel.javaCompletionExcluderDialogOkButton.text=OK
136
CodeCompletionPanel.javaCompletionExcluderDialogLabel.text=<html>Enter prefix for fully qualified packages, classes or methods. Wildcards are accepted, but will be ignored. Examples:<br> <code>sun, sun., sun.*, java.lang.Object.wait</code></html>
137
CodeCompletionPanel.javaCompletionExcluderMethodsCheckBox.text=Apply rules to methods
138
CodeCompletionPanel.javaCompletionExcluderDialog1.title=Java Completion Excluder
(-)a/java.editor/src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.form (-61 / +137 lines)
Lines 2-32 Link Here
2
2
3
<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <NonVisualComponents>
4
  <NonVisualComponents>
5
    <Container class="javax.swing.JFrame" name="javaCompletionExcluderFrame">
5
    <Container class="javax.swing.JDialog" name="javaCompletionExcluderDialog2">
6
      <Properties>
6
      <Properties>
7
        <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
7
        <Property name="modal" type="boolean" value="true"/>
8
          <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderFrame.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
9
        </Property>
10
        <Property name="alwaysOnTop" type="boolean" value="true"/>
11
        <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
12
          <Dimension value="[409, 233]"/>
13
        </Property>
14
        <Property name="undecorated" type="boolean" value="true"/>
8
        <Property name="undecorated" type="boolean" value="true"/>
15
      </Properties>
9
      </Properties>
16
10
17
      <Layout>
11
      <Layout>
18
        <DimensionLayout dim="0">
12
        <DimensionLayout dim="0">
19
          <Group type="103" groupAlignment="0" attributes="0">
13
          <Group type="103" groupAlignment="0" attributes="0">
14
              <Group type="102" alignment="0" attributes="0">
15
                  <EmptySpace max="-2" attributes="0"/>
16
                  <Group type="103" groupAlignment="1" max="-2" attributes="0">
17
                      <Component id="javaCompletionExcluderDialogLabel" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
18
                      <Component id="javaCompletionExcluderDialogTextField" alignment="0" pref="307" max="32767" attributes="1"/>
19
                  </Group>
20
                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
21
                  <Group type="103" groupAlignment="0" max="-2" attributes="0">
22
                      <Component id="javaCompletionExcluderDialogOkButton" max="32767" attributes="1"/>
23
                      <Component id="javaCompletionExcluderDialogCancelButton" alignment="0" max="32767" attributes="1"/>
24
                  </Group>
25
                  <EmptySpace max="32767" attributes="0"/>
26
              </Group>
27
          </Group>
28
        </DimensionLayout>
29
        <DimensionLayout dim="1">
30
          <Group type="103" groupAlignment="0" attributes="0">
20
              <Group type="102" alignment="1" attributes="0">
31
              <Group type="102" alignment="1" attributes="0">
32
                  <Group type="103" groupAlignment="1" attributes="0">
33
                      <Group type="102" attributes="0">
34
                          <EmptySpace max="-2" attributes="0"/>
35
                          <Component id="javaCompletionExcluderDialogLabel" min="-2" max="-2" attributes="0"/>
36
                          <EmptySpace max="32767" attributes="0"/>
37
                      </Group>
38
                      <Group type="102" alignment="1" attributes="0">
39
                          <EmptySpace max="-2" attributes="0"/>
40
                          <Component id="javaCompletionExcluderDialogCancelButton" min="-2" max="-2" attributes="0"/>
41
                          <EmptySpace max="-2" attributes="0"/>
42
                      </Group>
43
                  </Group>
44
                  <Group type="103" groupAlignment="3" attributes="0">
45
                      <Component id="javaCompletionExcluderDialogTextField" alignment="3" min="-2" max="-2" attributes="0"/>
46
                      <Component id="javaCompletionExcluderDialogOkButton" alignment="3" min="-2" max="-2" attributes="0"/>
47
                  </Group>
48
                  <EmptySpace min="-2" pref="61" max="-2" attributes="0"/>
49
              </Group>
50
          </Group>
51
        </DimensionLayout>
52
      </Layout>
53
      <SubComponents>
54
        <Component class="javax.swing.JTextField" name="javaCompletionExcluderDialogTextField">
55
          <Properties>
56
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
57
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderDialogTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
58
            </Property>
59
          </Properties>
60
          <Events>
61
            <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="javaCompletionExcluderDialogTextFieldKeyTyped"/>
62
          </Events>
63
        </Component>
64
        <Component class="javax.swing.JButton" name="javaCompletionExcluderDialogOkButton">
65
          <Properties>
66
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
67
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderDialogOkButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
68
            </Property>
69
          </Properties>
70
          <Events>
71
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderDialogOkButtonActionPerformed"/>
72
          </Events>
73
        </Component>
74
        <Component class="javax.swing.JLabel" name="javaCompletionExcluderDialogLabel">
75
          <Properties>
76
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
77
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderDialogLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
78
            </Property>
79
          </Properties>
80
        </Component>
81
        <Component class="javax.swing.JButton" name="javaCompletionExcluderDialogCancelButton">
82
          <Properties>
83
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
84
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderDialogCancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
85
            </Property>
86
          </Properties>
87
          <Events>
88
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderDialogCancelButtonActionPerformed"/>
89
          </Events>
90
        </Component>
91
      </SubComponents>
92
    </Container>
93
    <Container class="javax.swing.JDialog" name="javaCompletionExcluderDialog1">
94
      <Properties>
95
        <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
96
          <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderDialog1.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
97
        </Property>
98
        <Property name="modal" type="boolean" value="true"/>
99
      </Properties>
100
101
      <Layout>
102
        <DimensionLayout dim="0">
103
          <Group type="103" groupAlignment="0" attributes="0">
104
              <Group type="102" attributes="0">
21
                  <EmptySpace max="-2" attributes="0"/>
105
                  <EmptySpace max="-2" attributes="0"/>
22
                  <Component id="javaCompletionExcluderTab" min="-2" pref="298" max="-2" attributes="0"/>
106
                  <Group type="103" groupAlignment="0" attributes="0">
23
                  <EmptySpace max="-2" attributes="0"/>
107
                      <Group type="102" attributes="0">
24
                  <Group type="103" groupAlignment="0" max="-2" attributes="0">
108
                          <Component id="javaCompletionExcluderTab" min="-2" pref="298" max="-2" attributes="0"/>
25
                      <Component id="javaCompletionExcluderCloseButton" min="0" pref="0" max="32767" attributes="1"/>
109
                          <EmptySpace max="-2" attributes="0"/>
26
                      <Component id="javaCompletionExcluderRemoveButton" alignment="0" max="32767" attributes="1"/>
110
                          <Group type="103" groupAlignment="0" max="-2" attributes="0">
27
                      <Component id="javaCompletionExcluderAddButton" alignment="0" max="32767" attributes="1"/>
111
                              <Component id="javaCompletionExcluderEditButton" max="32767" attributes="1"/>
112
                              <Component id="javaCompletionExcluderRemoveButton" alignment="0" max="32767" attributes="1"/>
113
                              <Component id="javaCompletionExcluderAddButton" alignment="0" max="32767" attributes="1"/>
114
                          </Group>
115
                      </Group>
116
                      <Group type="102" alignment="0" attributes="0">
117
                          <Component id="javaCompletionExcluderMethodsCheckBox" min="-2" max="-2" attributes="0"/>
118
                          <EmptySpace min="-2" pref="125" max="-2" attributes="0"/>
119
                          <Component id="javaCompletionExcluderCloseButton" pref="93" max="32767" attributes="1"/>
120
                      </Group>
28
                  </Group>
121
                  </Group>
29
                  <EmptySpace pref="10" max="32767" attributes="0"/>
122
                  <EmptySpace max="32767" attributes="0"/>
30
              </Group>
123
              </Group>
31
          </Group>
124
          </Group>
32
        </DimensionLayout>
125
        </DimensionLayout>
Lines 37-50 Link Here
37
                      <Group type="102" attributes="0">
130
                      <Group type="102" attributes="0">
38
                          <EmptySpace max="-2" attributes="0"/>
131
                          <EmptySpace max="-2" attributes="0"/>
39
                          <Component id="javaCompletionExcluderTab" min="-2" pref="221" max="-2" attributes="0"/>
132
                          <Component id="javaCompletionExcluderTab" min="-2" pref="221" max="-2" attributes="0"/>
133
                          <EmptySpace max="-2" attributes="0"/>
134
                          <Group type="103" groupAlignment="3" attributes="0">
135
                              <Component id="javaCompletionExcluderMethodsCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
136
                              <Component id="javaCompletionExcluderCloseButton" alignment="3" min="-2" max="-2" attributes="0"/>
137
                          </Group>
40
                      </Group>
138
                      </Group>
41
                      <Group type="102" alignment="0" attributes="0">
139
                      <Group type="102" alignment="0" attributes="0">
42
                          <EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
140
                          <EmptySpace min="-2" pref="59" max="-2" attributes="0"/>
43
                          <Component id="javaCompletionExcluderAddButton" min="-2" max="-2" attributes="0"/>
141
                          <Component id="javaCompletionExcluderAddButton" min="-2" max="-2" attributes="0"/>
44
                          <EmptySpace max="-2" attributes="0"/>
142
                          <EmptySpace max="-2" attributes="0"/>
143
                          <Component id="javaCompletionExcluderEditButton" min="-2" max="-2" attributes="0"/>
144
                          <EmptySpace max="-2" attributes="0"/>
45
                          <Component id="javaCompletionExcluderRemoveButton" min="-2" max="-2" attributes="0"/>
145
                          <Component id="javaCompletionExcluderRemoveButton" min="-2" max="-2" attributes="0"/>
46
                          <EmptySpace min="-2" pref="63" max="-2" attributes="0"/>
47
                          <Component id="javaCompletionExcluderCloseButton" min="-2" max="-2" attributes="0"/>
48
                      </Group>
146
                      </Group>
49
                  </Group>
147
                  </Group>
50
                  <EmptySpace max="32767" attributes="0"/>
148
                  <EmptySpace max="32767" attributes="0"/>
Lines 73-100 Link Here
73
171
74
              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
172
              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
75
              <SubComponents>
173
              <SubComponents>
76
                <Component class="javax.swing.JTable" name="javaCompletionExcludeTable">
174
                <Component class="javax.swing.JList" name="javaCompletionExcludeJlist">
77
                  <Properties>
78
                    <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
79
                      <Table columnCount="1" rowCount="0">
80
                        <Column editable="true" title="Fully Qualified Name prefix" type="java.lang.String"/>
81
                      </Table>
82
                    </Property>
83
                    <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
84
                      <TableColumnModel selectionModel="0">
85
                        <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
86
                          <Title editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
87
                            <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
88
                          </Title>
89
                          <Editor/>
90
                          <Renderer/>
91
                        </Column>
92
                      </TableColumnModel>
93
                    </Property>
94
                    <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
95
                      <TableHeader reorderingAllowed="false" resizingAllowed="true"/>
96
                    </Property>
97
                  </Properties>
98
                </Component>
175
                </Component>
99
              </SubComponents>
176
              </SubComponents>
100
            </Container>
177
            </Container>
Lines 114-141 Link Here
114
191
115
              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
192
              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
116
              <SubComponents>
193
              <SubComponents>
117
                <Component class="javax.swing.JTable" name="javaCompletionIncludeTable">
194
                <Component class="javax.swing.JList" name="javaCompletionIncludeJlist">
118
                  <Properties>
119
                    <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
120
                      <Table columnCount="1" rowCount="0">
121
                        <Column editable="true" title="Fully Qualified Name prefix" type="java.lang.String"/>
122
                      </Table>
123
                    </Property>
124
                    <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
125
                      <TableColumnModel selectionModel="0">
126
                        <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
127
                          <Title editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
128
                            <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
129
                          </Title>
130
                          <Editor/>
131
                          <Renderer/>
132
                        </Column>
133
                      </TableColumnModel>
134
                    </Property>
135
                    <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
136
                      <TableHeader reorderingAllowed="false" resizingAllowed="true"/>
137
                    </Property>
138
                  </Properties>
139
                </Component>
195
                </Component>
140
              </SubComponents>
196
              </SubComponents>
141
            </Container>
197
            </Container>
Lines 169-174 Link Here
169
          </Properties>
225
          </Properties>
170
          <Events>
226
          <Events>
171
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderCloseButtonActionPerformed"/>
227
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderCloseButtonActionPerformed"/>
228
          </Events>
229
        </Component>
230
        <Component class="javax.swing.JButton" name="javaCompletionExcluderEditButton">
231
          <Properties>
232
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
233
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderEditButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
234
            </Property>
235
          </Properties>
236
          <Events>
237
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderEditButtonActionPerformed"/>
238
          </Events>
239
        </Component>
240
        <Component class="javax.swing.JCheckBox" name="javaCompletionExcluderMethodsCheckBox">
241
          <Properties>
242
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
243
              <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcluderMethodsCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
244
            </Property>
245
          </Properties>
246
          <Events>
247
            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="javaCompletionExcluderMethodsCheckBoxActionPerformed"/>
172
          </Events>
248
          </Events>
173
        </Component>
249
        </Component>
174
      </SubComponents>
250
      </SubComponents>
(-)a/java.editor/src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.java (-184 / +279 lines)
Lines 42-59 Link Here
42
package org.netbeans.modules.java.editor.options;
42
package org.netbeans.modules.java.editor.options;
43
43
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.util.Arrays;
46
import java.util.Collection;
47
import java.util.TreeSet;
48
import java.util.Vector;
49
import java.util.prefs.Preferences;
45
import java.util.prefs.Preferences;
46
import javax.swing.DefaultListModel;
50
import javax.swing.JComponent;
47
import javax.swing.JComponent;
51
import javax.swing.JTable;
48
import javax.swing.JList;
52
import javax.swing.event.DocumentEvent;
49
import javax.swing.event.DocumentEvent;
53
import javax.swing.event.DocumentListener;
50
import javax.swing.event.DocumentListener;
54
import javax.swing.event.TableModelEvent;
55
import javax.swing.event.TableModelListener;
56
import javax.swing.table.DefaultTableModel;
57
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
51
import org.netbeans.modules.options.editor.spi.PreferencesCustomizer;
58
import org.openide.util.HelpCtx;
52
import org.openide.util.HelpCtx;
59
53
Lines 62-68 Link Here
62
 * @author Dusan Balek
56
 * @author Dusan Balek
63
 * @author Sam Halliday
57
 * @author Sam Halliday
64
 */
58
 */
65
public class CodeCompletionPanel extends javax.swing.JPanel implements DocumentListener, TableModelListener {
59
public class CodeCompletionPanel extends javax.swing.JPanel implements DocumentListener {
66
60
67
    public static final String JAVA_AUTO_POPUP_ON_IDENTIFIER_PART = "javaAutoPopupOnIdentifierPart"; //NOI18N
61
    public static final String JAVA_AUTO_POPUP_ON_IDENTIFIER_PART = "javaAutoPopupOnIdentifierPart"; //NOI18N
68
    public static final boolean JAVA_AUTO_POPUP_ON_IDENTIFIER_PART_DEFAULT = false;
62
    public static final boolean JAVA_AUTO_POPUP_ON_IDENTIFIER_PART_DEFAULT = false;
Lines 78-96 Link Here
78
    public static final String JAVA_COMPLETION_WHITELIST_DEFAULT = ""; //NOI18N
72
    public static final String JAVA_COMPLETION_WHITELIST_DEFAULT = ""; //NOI18N
79
    public static final String JAVA_COMPLETION_BLACKLIST = "javaCompletionBlacklist"; //NOI18N
73
    public static final String JAVA_COMPLETION_BLACKLIST = "javaCompletionBlacklist"; //NOI18N
80
    public static final String JAVA_COMPLETION_BLACKLIST_DEFAULT = ""; //NOI18N
74
    public static final String JAVA_COMPLETION_BLACKLIST_DEFAULT = ""; //NOI18N
75
    public static final String JAVA_COMPLETION_EXCLUDER_METHODS = "javaCompletionExcluderMethods"; //NOI18N
76
    public static final boolean JAVA_COMPLETION_EXCLUDER_METHODS_DEFAULT = false;
77
78
    private static final String JAVA_FQN_REGEX = "[$\\w._]*";
81
79
82
    private final Preferences preferences;
80
    private final Preferences preferences;
83
81
84
    private void initExcluderTable(JTable table, String pref) {
82
    // editing is null if a new entry is to be created, otherwise the entry to be replaced
85
        String[] entries = pref.split(","); //NOI18N
83
    private volatile String editing;
86
        DefaultTableModel model = (DefaultTableModel) table.getModel();
87
        for (String entry : entries) {
88
            if (entry.length() > 0) {
89
                model.addRow(new String[]{entry});
90
            }
91
        }
92
        model.addTableModelListener(this);
93
    }
94
84
95
    /** Creates new form FmtTabsIndents */
85
    /** Creates new form FmtTabsIndents */
96
    public CodeCompletionPanel(Preferences p) {
86
    public CodeCompletionPanel(Preferences p) {
Lines 100-120 Link Here
100
        javaAutoPopupOnIdentifierPart.setSelected(preferences.getBoolean(JAVA_AUTO_POPUP_ON_IDENTIFIER_PART, JAVA_AUTO_POPUP_ON_IDENTIFIER_PART_DEFAULT));
90
        javaAutoPopupOnIdentifierPart.setSelected(preferences.getBoolean(JAVA_AUTO_POPUP_ON_IDENTIFIER_PART, JAVA_AUTO_POPUP_ON_IDENTIFIER_PART_DEFAULT));
101
        javaAutoCompletionTriggersField.setText(preferences.get(JAVA_AUTO_COMPLETION_TRIGGERS, JAVA_AUTO_COMPLETION_TRIGGERS_DEFAULT));
91
        javaAutoCompletionTriggersField.setText(preferences.get(JAVA_AUTO_COMPLETION_TRIGGERS, JAVA_AUTO_COMPLETION_TRIGGERS_DEFAULT));
102
        javaCompletionSelectorsField.setText(preferences.get(JAVA_COMPLETION_SELECTORS, JAVA_COMPLETION_SELECTORS_DEFAULT));
92
        javaCompletionSelectorsField.setText(preferences.get(JAVA_COMPLETION_SELECTORS, JAVA_COMPLETION_SELECTORS_DEFAULT));
103
        javadocAutoCompletionTriggersField.setText(preferences.get(JAVADOC_AUTO_COMPLETION_TRIGGERS, JAVADOC_AUTO_COMPLETION_TRIGGERS_DEFAULT));
93
        javadocAutoCompletionTriggersField.setText(preferences.get(JAVADOC_AUTO_COMPLETION_TRIGGERS, JAVADOC_AUTO_COMPLETION_TRIGGERS_DEFAULT));        
104
        String blacklist = preferences.get(JAVA_COMPLETION_BLACKLIST, JAVA_COMPLETION_BLACKLIST_DEFAULT);
94
        String blacklist = preferences.get(JAVA_COMPLETION_BLACKLIST, JAVA_COMPLETION_BLACKLIST_DEFAULT);
105
        initExcluderTable(javaCompletionExcludeTable, blacklist);
95
        initExcluderList(javaCompletionExcludeJlist, blacklist);
106
        String whitelist = preferences.get(JAVA_COMPLETION_WHITELIST, JAVA_COMPLETION_WHITELIST_DEFAULT);
96
        String whitelist = preferences.get(JAVA_COMPLETION_WHITELIST, JAVA_COMPLETION_WHITELIST_DEFAULT);
107
        initExcluderTable(javaCompletionIncludeTable, whitelist);
97
        initExcluderList(javaCompletionIncludeJlist, whitelist);
98
        javaCompletionExcluderMethodsCheckBox.setSelected(preferences.getBoolean(JAVA_COMPLETION_EXCLUDER_METHODS, JAVA_COMPLETION_EXCLUDER_METHODS_DEFAULT));
99
        javaCompletionExcluderDialog2.getRootPane().setDefaultButton(javaCompletionExcluderDialogOkButton);
100
101
        // can't NetBeans visual editor do these automatically?
102
        javaCompletionExcluderDialog1.pack();
103
        javaCompletionExcluderDialog1.setLocationRelativeTo(this);
104
        javaCompletionExcluderDialog2.pack();
105
        javaCompletionExcluderDialog2.setLocationRelativeTo(this);
106
108
        javaAutoCompletionTriggersField.getDocument().addDocumentListener(this);
107
        javaAutoCompletionTriggersField.getDocument().addDocumentListener(this);
109
        javaCompletionSelectorsField.getDocument().addDocumentListener(this);
108
        javaCompletionSelectorsField.getDocument().addDocumentListener(this);
110
        javadocAutoCompletionTriggersField.getDocument().addDocumentListener(this);
109
        javadocAutoCompletionTriggersField.getDocument().addDocumentListener(this);
110
    }
111
112
    private void initExcluderList(JList jList, String list) {
113
        DefaultListModel model = new DefaultListModel();
114
        String [] entries = list.split(","); //NOI18N
115
        for (String entry : entries){
116
            if (entry.length() != 0)
117
                model.addElement(entry);
118
        }
119
        jList.setModel(model);
120
    }
121
122
    // existing is null if add is required
123
    private void openExcluderEditor() {
124
        assert !javaCompletionExcluderDialog2.isVisible();
125
        javaCompletionExcluderDialogTextField.setText(editing);
126
        javaCompletionExcluderDialog2.setVisible(true);
127
        javaCompletionExcluderDialogTextField.requestFocus();
111
    }
128
    }
112
    
129
    
113
    public static PreferencesCustomizer.Factory getCustomizerFactory() {
130
    public static PreferencesCustomizer.Factory getCustomizerFactory() {
114
        return new PreferencesCustomizer.Factory() {
131
        return new PreferencesCustomizer.Factory() {
115
132
116
            public PreferencesCustomizer create(Preferences preferences) {
133
            public PreferencesCustomizer create(Preferences preferences) {
117
                return new CodeCompletionPreferencesCusromizer(preferences);
134
                return new CodeCompletionPreferencesCustomizer(preferences);
118
            }
135
            }
119
        };
136
        };
120
    }
137
    }
Lines 131-190 Link Here
131
        update(e);
148
        update(e);
132
    }
149
    }
133
150
134
    // allows common excluder buttons to know which table to act on
135
    private JTable getSelectedExcluderTable() {
136
        Component selected = javaCompletionExcluderTab.getSelectedComponent();
137
        if (selected == javaCompletionExcludeScrollPane) {
138
            return javaCompletionExcludeTable;
139
        } else if (selected == javaCompletionIncludeScrollPane) {
140
            return javaCompletionIncludeTable;
141
        } else {
142
            throw new RuntimeException(selected.getName());
143
        }
144
    }
145
146
    // listen to changes in the excluder lists, and do sanity checking on input
147
    public void tableChanged(TableModelEvent e) {
148
        DefaultTableModel model = (DefaultTableModel) e.getSource();
149
        String pref;
150
        if (model == javaCompletionExcludeTable.getModel()) {
151
            pref = JAVA_COMPLETION_BLACKLIST;
152
        } else if (model == javaCompletionIncludeTable.getModel()) {
153
            pref = JAVA_COMPLETION_WHITELIST;
154
        } else {
155
            throw new RuntimeException();
156
        }
157
        @SuppressWarnings("unchecked")
158
        Vector<Vector<String>> data = model.getDataVector();
159
        Collection<String> entries = new TreeSet<String>();
160
        for (Vector<String> row : data) {
161
            String entry = row.elementAt(0);
162
            if (entry == null) {
163
                continue;
164
            }
165
            // users can enter wildcards, which is the same as the raw prefix
166
            if (entry.contains("*"))
167
                entry = entry.replaceAll("\\*", "");
168
            entry = entry.trim();
169
            if (entry.length() == 0) {
170
                continue;
171
            }
172
            // this could be checked by a custom editor on input
173
            if (!entry.matches("[$\\w._]*")) { //NOI18N
174
                continue;
175
            }
176
            entries.add(entry);
177
        }
178
        StringBuilder builder = new StringBuilder();
179
        for (String entry : entries) {
180
            if (builder.length() > 0) {
181
                builder.append(","); //NOI18N
182
            }
183
            builder.append(entry);
184
        }
185
        preferences.put(pref, builder.toString());
186
    }
187
188
    /** This method is called from within the constructor to
151
    /** This method is called from within the constructor to
189
     * initialize the form.
152
     * initialize the form.
190
     * WARNING: Do NOT modify this code. The content of this method is
153
     * WARNING: Do NOT modify this code. The content of this method is
Lines 193-207 Link Here
193
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
156
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
194
    private void initComponents() {
157
    private void initComponents() {
195
158
196
        javaCompletionExcluderFrame = new javax.swing.JFrame();
159
        javaCompletionExcluderDialog2 = new javax.swing.JDialog();
160
        javaCompletionExcluderDialogTextField = new javax.swing.JTextField();
161
        javaCompletionExcluderDialogOkButton = new javax.swing.JButton();
162
        javaCompletionExcluderDialogLabel = new javax.swing.JLabel();
163
        javaCompletionExcluderDialogCancelButton = new javax.swing.JButton();
164
        javaCompletionExcluderDialog1 = new javax.swing.JDialog();
197
        javaCompletionExcluderTab = new javax.swing.JTabbedPane();
165
        javaCompletionExcluderTab = new javax.swing.JTabbedPane();
198
        javaCompletionExcludeScrollPane = new javax.swing.JScrollPane();
166
        javaCompletionExcludeScrollPane = new javax.swing.JScrollPane();
199
        javaCompletionExcludeTable = new javax.swing.JTable();
167
        javaCompletionExcludeJlist = new javax.swing.JList();
200
        javaCompletionIncludeScrollPane = new javax.swing.JScrollPane();
168
        javaCompletionIncludeScrollPane = new javax.swing.JScrollPane();
201
        javaCompletionIncludeTable = new javax.swing.JTable();
169
        javaCompletionIncludeJlist = new javax.swing.JList();
202
        javaCompletionExcluderAddButton = new javax.swing.JButton();
170
        javaCompletionExcluderAddButton = new javax.swing.JButton();
203
        javaCompletionExcluderRemoveButton = new javax.swing.JButton();
171
        javaCompletionExcluderRemoveButton = new javax.swing.JButton();
204
        javaCompletionExcluderCloseButton = new javax.swing.JButton();
172
        javaCompletionExcluderCloseButton = new javax.swing.JButton();
173
        javaCompletionExcluderEditButton = new javax.swing.JButton();
174
        javaCompletionExcluderMethodsCheckBox = new javax.swing.JCheckBox();
205
        javaCompletionPane = new javax.swing.JPanel();
175
        javaCompletionPane = new javax.swing.JPanel();
206
        guessMethodArguments = new javax.swing.JCheckBox();
176
        guessMethodArguments = new javax.swing.JCheckBox();
207
        javaAutoPopupOnIdentifierPart = new javax.swing.JCheckBox();
177
        javaAutoPopupOnIdentifierPart = new javax.swing.JCheckBox();
Lines 215-266 Link Here
215
        javaCompletionExcluderLabel = new javax.swing.JLabel();
185
        javaCompletionExcluderLabel = new javax.swing.JLabel();
216
        javaCompletionExcluderButton = new javax.swing.JButton();
186
        javaCompletionExcluderButton = new javax.swing.JButton();
217
187
218
        javaCompletionExcluderFrame.setTitle(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderFrame.title")); // NOI18N
188
        javaCompletionExcluderDialog2.setModal(true);
219
        javaCompletionExcluderFrame.setAlwaysOnTop(true);
189
        javaCompletionExcluderDialog2.setUndecorated(true);
220
        javaCompletionExcluderFrame.setMinimumSize(new java.awt.Dimension(409, 233));
221
        javaCompletionExcluderFrame.setUndecorated(true);
222
190
223
        javaCompletionExcludeTable.setModel(new javax.swing.table.DefaultTableModel(
191
        javaCompletionExcluderDialogTextField.setText(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDialogTextField.text")); // NOI18N
224
            new Object [][] {
192
        javaCompletionExcluderDialogTextField.addKeyListener(new java.awt.event.KeyAdapter() {
225
193
            public void keyTyped(java.awt.event.KeyEvent evt) {
226
            },
194
                javaCompletionExcluderDialogTextFieldKeyTyped(evt);
227
            new String [] {
228
                "Fully Qualified Name prefix"
229
            }
230
        ) {
231
            Class[] types = new Class [] {
232
                java.lang.String.class
233
            };
234
235
            public Class getColumnClass(int columnIndex) {
236
                return types [columnIndex];
237
            }
195
            }
238
        });
196
        });
239
        javaCompletionExcludeTable.getTableHeader().setReorderingAllowed(false);
197
240
        javaCompletionExcludeScrollPane.setViewportView(javaCompletionExcludeTable);
198
        org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderDialogOkButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDialogOkButton.text")); // NOI18N
241
        javaCompletionExcludeTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0")); // NOI18N
199
        javaCompletionExcluderDialogOkButton.addActionListener(new java.awt.event.ActionListener() {
200
            public void actionPerformed(java.awt.event.ActionEvent evt) {
201
                javaCompletionExcluderDialogOkButtonActionPerformed(evt);
202
            }
203
        });
204
205
        org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderDialogLabel, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDialogLabel.text")); // NOI18N
206
207
        org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderDialogCancelButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDialogCancelButton.text")); // NOI18N
208
        javaCompletionExcluderDialogCancelButton.addActionListener(new java.awt.event.ActionListener() {
209
            public void actionPerformed(java.awt.event.ActionEvent evt) {
210
                javaCompletionExcluderDialogCancelButtonActionPerformed(evt);
211
            }
212
        });
213
214
        org.jdesktop.layout.GroupLayout javaCompletionExcluderDialog2Layout = new org.jdesktop.layout.GroupLayout(javaCompletionExcluderDialog2.getContentPane());
215
        javaCompletionExcluderDialog2.getContentPane().setLayout(javaCompletionExcluderDialog2Layout);
216
        javaCompletionExcluderDialog2Layout.setHorizontalGroup(
217
            javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
218
            .add(javaCompletionExcluderDialog2Layout.createSequentialGroup()
219
                .addContainerGap()
220
                .add(javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
221
                    .add(org.jdesktop.layout.GroupLayout.LEADING, javaCompletionExcluderDialogLabel, 0, 0, Short.MAX_VALUE)
222
                    .add(org.jdesktop.layout.GroupLayout.LEADING, javaCompletionExcluderDialogTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE))
223
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
224
                .add(javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
225
                    .add(javaCompletionExcluderDialogOkButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
226
                    .add(javaCompletionExcluderDialogCancelButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
227
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
228
        );
229
        javaCompletionExcluderDialog2Layout.setVerticalGroup(
230
            javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
231
            .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionExcluderDialog2Layout.createSequentialGroup()
232
                .add(javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
233
                    .add(javaCompletionExcluderDialog2Layout.createSequentialGroup()
234
                        .addContainerGap()
235
                        .add(javaCompletionExcluderDialogLabel)
236
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
237
                    .add(javaCompletionExcluderDialog2Layout.createSequentialGroup()
238
                        .addContainerGap()
239
                        .add(javaCompletionExcluderDialogCancelButton)
240
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
241
                .add(javaCompletionExcluderDialog2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
242
                    .add(javaCompletionExcluderDialogTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
243
                    .add(javaCompletionExcluderDialogOkButton))
244
                .add(61, 61, 61))
245
        );
246
247
        javaCompletionExcluderDialog1.setTitle(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDialog1.title")); // NOI18N
248
        javaCompletionExcluderDialog1.setModal(true);
249
250
        javaCompletionExcludeScrollPane.setViewportView(javaCompletionExcludeJlist);
242
251
243
        javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle"), javaCompletionExcludeScrollPane); // NOI18N
252
        javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle"), javaCompletionExcludeScrollPane); // NOI18N
244
253
245
        javaCompletionIncludeTable.setModel(new javax.swing.table.DefaultTableModel(
254
        javaCompletionIncludeScrollPane.setViewportView(javaCompletionIncludeJlist);
246
            new Object [][] {
247
248
            },
249
            new String [] {
250
                "Fully Qualified Name prefix"
251
            }
252
        ) {
253
            Class[] types = new Class [] {
254
                java.lang.String.class
255
            };
256
257
            public Class getColumnClass(int columnIndex) {
258
                return types [columnIndex];
259
            }
260
        });
261
        javaCompletionIncludeTable.getTableHeader().setReorderingAllowed(false);
262
        javaCompletionIncludeScrollPane.setViewportView(javaCompletionIncludeTable);
263
        javaCompletionIncludeTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0")); // NOI18N
264
255
265
        javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle"), javaCompletionIncludeScrollPane); // NOI18N
256
        javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle"), javaCompletionIncludeScrollPane); // NOI18N
266
257
Lines 285-318 Link Here
285
            }
276
            }
286
        });
277
        });
287
278
288
        org.jdesktop.layout.GroupLayout javaCompletionExcluderFrameLayout = new org.jdesktop.layout.GroupLayout(javaCompletionExcluderFrame.getContentPane());
279
        org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderEditButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderEditButton.text")); // NOI18N
289
        javaCompletionExcluderFrame.getContentPane().setLayout(javaCompletionExcluderFrameLayout);
280
        javaCompletionExcluderEditButton.addActionListener(new java.awt.event.ActionListener() {
290
        javaCompletionExcluderFrameLayout.setHorizontalGroup(
281
            public void actionPerformed(java.awt.event.ActionEvent evt) {
291
            javaCompletionExcluderFrameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
282
                javaCompletionExcluderEditButtonActionPerformed(evt);
292
            .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionExcluderFrameLayout.createSequentialGroup()
283
            }
284
        });
285
286
        org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderMethodsCheckBox, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderMethodsCheckBox.text")); // NOI18N
287
        javaCompletionExcluderMethodsCheckBox.addActionListener(new java.awt.event.ActionListener() {
288
            public void actionPerformed(java.awt.event.ActionEvent evt) {
289
                javaCompletionExcluderMethodsCheckBoxActionPerformed(evt);
290
            }
291
        });
292
293
        org.jdesktop.layout.GroupLayout javaCompletionExcluderDialog1Layout = new org.jdesktop.layout.GroupLayout(javaCompletionExcluderDialog1.getContentPane());
294
        javaCompletionExcluderDialog1.getContentPane().setLayout(javaCompletionExcluderDialog1Layout);
295
        javaCompletionExcluderDialog1Layout.setHorizontalGroup(
296
            javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
297
            .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
293
                .addContainerGap()
298
                .addContainerGap()
294
                .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 298, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
299
                .add(javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
295
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
300
                    .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
296
                .add(javaCompletionExcluderFrameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
301
                        .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 298, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
297
                    .add(javaCompletionExcluderCloseButton, 0, 0, Short.MAX_VALUE)
302
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
298
                    .add(javaCompletionExcluderRemoveButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
303
                        .add(javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
299
                    .add(javaCompletionExcluderAddButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
304
                            .add(javaCompletionExcluderEditButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
300
                .addContainerGap(10, Short.MAX_VALUE))
305
                            .add(javaCompletionExcluderRemoveButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
306
                            .add(javaCompletionExcluderAddButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
307
                    .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
308
                        .add(javaCompletionExcluderMethodsCheckBox)
309
                        .add(125, 125, 125)
310
                        .add(javaCompletionExcluderCloseButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 93, Short.MAX_VALUE)))
311
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
301
        );
312
        );
302
        javaCompletionExcluderFrameLayout.setVerticalGroup(
313
        javaCompletionExcluderDialog1Layout.setVerticalGroup(
303
            javaCompletionExcluderFrameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
314
            javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
304
            .add(javaCompletionExcluderFrameLayout.createSequentialGroup()
315
            .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
305
                .add(javaCompletionExcluderFrameLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
316
                .add(javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
306
                    .add(javaCompletionExcluderFrameLayout.createSequentialGroup()
317
                    .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
307
                        .addContainerGap()
318
                        .addContainerGap()
308
                        .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 221, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
319
                        .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 221, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
309
                    .add(javaCompletionExcluderFrameLayout.createSequentialGroup()
320
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
321
                        .add(javaCompletionExcluderDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
322
                            .add(javaCompletionExcluderMethodsCheckBox)
323
                            .add(javaCompletionExcluderCloseButton)))
324
                    .add(javaCompletionExcluderDialog1Layout.createSequentialGroup()
310
                        .add(59, 59, 59)
325
                        .add(59, 59, 59)
311
                        .add(javaCompletionExcluderAddButton)
326
                        .add(javaCompletionExcluderAddButton)
312
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
327
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
313
                        .add(javaCompletionExcluderRemoveButton)
328
                        .add(javaCompletionExcluderEditButton)
314
                        .add(63, 63, 63)
329
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
315
                        .add(javaCompletionExcluderCloseButton)))
330
                        .add(javaCompletionExcluderRemoveButton)))
316
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
331
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
317
        );
332
        );
318
333
Lines 361-367 Link Here
361
            .add(javaCompletionPaneLayout.createSequentialGroup()
376
            .add(javaCompletionPaneLayout.createSequentialGroup()
362
                .addContainerGap()
377
                .addContainerGap()
363
                .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
378
                .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
364
                    .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
379
                    .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
365
                    .add(javaCompletionPaneLayout.createSequentialGroup()
380
                    .add(javaCompletionPaneLayout.createSequentialGroup()
366
                        .add(javadocAutoCompletionTriggersLabel)
381
                        .add(javadocAutoCompletionTriggersLabel)
367
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
382
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
Lines 371-394 Link Here
371
                .add(javaCompletionPaneLayout.createSequentialGroup()
386
                .add(javaCompletionPaneLayout.createSequentialGroup()
372
                    .addContainerGap()
387
                    .addContainerGap()
373
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
388
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
374
                    .add(guessMethodArguments)
389
                        .add(guessMethodArguments)
375
                        .add(javaCompletionPaneLayout.createSequentialGroup()
390
                        .add(javaCompletionPaneLayout.createSequentialGroup()
376
                        .add(javaAutoCompletionTriggersLabel)
391
                            .add(javaAutoCompletionTriggersLabel)
377
                        .add(34, 34, 34)
392
                            .add(34, 34, 34)
378
                        .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
393
                            .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
379
                    .add(javaAutoPopupOnIdentifierPart)
394
                        .add(javaAutoPopupOnIdentifierPart)
380
                        .add(javaCompletionPaneLayout.createSequentialGroup()
395
                        .add(javaCompletionPaneLayout.createSequentialGroup()
381
                            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
396
                            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
382
                                .add(javaCompletionExcluderLabel)
397
                                .add(javaCompletionExcluderLabel)
383
                                .add(javaCompletionSelectorsLabel))
398
                                .add(javaCompletionSelectorsLabel))
384
                            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
399
                            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
385
                                .add(javaCompletionPaneLayout.createSequentialGroup()
400
                                .add(javaCompletionPaneLayout.createSequentialGroup()
386
                        .add(30, 30, 30)
401
                                    .add(30, 30, 30)
387
                        .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
402
                                    .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
388
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionPaneLayout.createSequentialGroup()
403
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionPaneLayout.createSequentialGroup()
389
                                    .add(23, 23, 23)
404
                                    .add(23, 23, 23)
390
                                    .add(javaCompletionExcluderButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
405
                                    .add(javaCompletionExcluderButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
391
                    .addContainerGap(25, Short.MAX_VALUE)))
406
                    .addContainerGap(199, Short.MAX_VALUE)))
392
        );
407
        );
393
        javaCompletionPaneLayout.setVerticalGroup(
408
        javaCompletionPaneLayout.setVerticalGroup(
394
            javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
409
            javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
Lines 402-419 Link Here
402
                .addContainerGap(23, Short.MAX_VALUE))
417
                .addContainerGap(23, Short.MAX_VALUE))
403
            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
418
            .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
404
                .add(javaCompletionPaneLayout.createSequentialGroup()
419
                .add(javaCompletionPaneLayout.createSequentialGroup()
405
                .addContainerGap()
420
                    .addContainerGap()
406
                    .add(guessMethodArguments, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
421
                    .add(guessMethodArguments, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
407
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
422
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
408
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
423
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
409
                    .add(javaAutoCompletionTriggersLabel)
424
                        .add(javaAutoCompletionTriggersLabel)
410
                    .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
425
                        .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
411
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
426
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
412
                .add(javaAutoPopupOnIdentifierPart)
427
                    .add(javaAutoPopupOnIdentifierPart)
413
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
428
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
414
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
429
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
415
                    .add(javaCompletionSelectorsLabel)
430
                        .add(javaCompletionSelectorsLabel)
416
                    .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
431
                        .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
417
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
432
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
418
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
433
                    .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
419
                        .add(javaCompletionExcluderButton)
434
                        .add(javaCompletionExcluderButton)
Lines 442-479 Link Here
442
}//GEN-LAST:event_guessMethodArgumentsActionPerformed
457
}//GEN-LAST:event_guessMethodArgumentsActionPerformed
443
458
444
	private void javaCompletionExcluderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderButtonActionPerformed
459
	private void javaCompletionExcluderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderButtonActionPerformed
445
        if (javaCompletionExcluderFrame.isVisible())
460
        assert !javaCompletionExcluderDialog1.isVisible();
446
            return;
461
        javaCompletionExcluderDialog1.setVisible(true);
447
        javaCompletionExcluderFrame.pack();
448
        javaCompletionExcluderFrame.setLocationRelativeTo(this);
449
        javaCompletionExcluderFrame.setVisible(true);
450
}//GEN-LAST:event_javaCompletionExcluderButtonActionPerformed
462
}//GEN-LAST:event_javaCompletionExcluderButtonActionPerformed
451
463
464
    // allows common excluder buttons to know which table to act on
465
    private JList getSelectedExcluderList() {
466
        Component selected = javaCompletionExcluderTab.getSelectedComponent();
467
        if (selected == javaCompletionExcludeScrollPane) {
468
            return javaCompletionExcludeJlist;
469
        } else if (selected == javaCompletionIncludeScrollPane) {
470
            return javaCompletionIncludeJlist;
471
        } else {
472
            throw new RuntimeException(selected.getName());
473
        }
474
    }
475
452
	private void javaCompletionExcluderAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderAddButtonActionPerformed
476
	private void javaCompletionExcluderAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderAddButtonActionPerformed
453
        JTable table = getSelectedExcluderTable();
477
        openExcluderEditor();
454
        DefaultTableModel model = (DefaultTableModel) table.getModel();
455
        int rows = model.getRowCount();
456
        model.setRowCount(rows + 1);
457
        table.editCellAt(rows, 0);
458
        table.requestFocus();
459
}//GEN-LAST:event_javaCompletionExcluderAddButtonActionPerformed
478
}//GEN-LAST:event_javaCompletionExcluderAddButtonActionPerformed
460
479
461
    private void javaCompletionExcluderRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderRemoveButtonActionPerformed
480
    private void javaCompletionExcluderRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderRemoveButtonActionPerformed
462
        JTable table = getSelectedExcluderTable();
481
        JList list = getSelectedExcluderList();
463
        int[] rows = table.getSelectedRows();
482
        int[] rows = list.getSelectedIndices();
464
        if (rows.length == 0)
483
        DefaultListModel model = (DefaultListModel) list.getModel();
465
            return;
466
        // remove rows in descending order: row numbers change when a row is removed
484
        // remove rows in descending order: row numbers change when a row is removed
467
        Arrays.sort(rows);
468
        DefaultTableModel model = (DefaultTableModel) table.getModel();
469
        for (int row = rows.length - 1; row >= 0; row--) {
485
        for (int row = rows.length - 1; row >= 0; row--) {
470
            model.removeRow(rows[row]);
486
            model.remove(rows[row]);
471
        }
487
        }
472
}//GEN-LAST:event_javaCompletionExcluderRemoveButtonActionPerformed
488
}//GEN-LAST:event_javaCompletionExcluderRemoveButtonActionPerformed
473
489
474
    private void javaCompletionExcluderCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderCloseButtonActionPerformed
490
    private void javaCompletionExcluderCloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderCloseButtonActionPerformed
475
        javaCompletionExcluderFrame.setVisible(false);
491
        javaCompletionExcluderDialog1.setVisible(false);
476
    }//GEN-LAST:event_javaCompletionExcluderCloseButtonActionPerformed
492
    }//GEN-LAST:event_javaCompletionExcluderCloseButtonActionPerformed
493
494
    private void javaCompletionExcluderEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderEditButtonActionPerformed
495
        JList list = getSelectedExcluderList();
496
        int index = list.getSelectedIndex();
497
        if (index == -1)
498
            return;
499
        DefaultListModel model = (DefaultListModel) list.getModel();
500
        editing = (String) model.getElementAt(index);
501
        openExcluderEditor();
502
}//GEN-LAST:event_javaCompletionExcluderEditButtonActionPerformed
503
504
    private void javaCompletionExcluderMethodsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderMethodsCheckBoxActionPerformed
505
        preferences.putBoolean(JAVA_COMPLETION_EXCLUDER_METHODS, javaCompletionExcluderMethodsCheckBox.isSelected());
506
}//GEN-LAST:event_javaCompletionExcluderMethodsCheckBoxActionPerformed
507
508
    private void javaCompletionExcluderDialogOkButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogOkButtonActionPerformed
509
        JList list = getSelectedExcluderList();
510
        String text = javaCompletionExcluderDialogTextField.getText();
511
        DefaultListModel model = (DefaultListModel) list.getModel();
512
        int index = model.size();
513
        if (editing != null){
514
            // if this was an "edit" rather than "add", then remove the old entry first
515
            index = model.indexOf(editing);
516
            model.remove(index);
517
            editing = null;
518
        }
519
        String[] entries = text.split(","); // NOI18N
520
        for (String entry : entries) {
521
            // strip wildcards
522
            if (entry.contains("*"))
523
                entry = entry.replaceAll("\\*", "");
524
            entry = entry.trim();
525
            if (entry.length() != 0 && entry.matches(JAVA_FQN_REGEX)){
526
                model.insertElementAt(entry, index);
527
                index++;
528
            }
529
        }
530
        StringBuilder builder = new StringBuilder();
531
        for (int i = 0 ; i < model.size() ; i++) {
532
            String entry = (String) model.getElementAt(i);
533
            if (builder.length() > 0) {
534
                builder.append(","); //NOI18N
535
            }
536
            builder.append(entry);
537
        }
538
        String pref;
539
        if (list == javaCompletionExcludeJlist)
540
            pref = JAVA_COMPLETION_BLACKLIST;
541
        else if (list == javaCompletionIncludeJlist)
542
            pref = JAVA_COMPLETION_WHITELIST;
543
        else
544
            throw new RuntimeException(list.getName());
545
        
546
        preferences.put(pref, builder.toString());
547
        javaCompletionExcluderDialog2.setVisible(false);
548
        javaCompletionExcluderDialogTextField.setText(null);
549
    }//GEN-LAST:event_javaCompletionExcluderDialogOkButtonActionPerformed
550
551
    private void javaCompletionExcluderDialogCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogCancelButtonActionPerformed
552
        javaCompletionExcluderDialog2.setVisible(false);
553
        javaCompletionExcluderDialogTextField.setText(null);
554
        editing = null;
555
    }//GEN-LAST:event_javaCompletionExcluderDialogCancelButtonActionPerformed
556
557
    private void javaCompletionExcluderDialogTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDialogTextFieldKeyTyped
558
        char c = evt.getKeyChar();
559
        // could use javax.lang.model.SourceVersion.isIdentifier if we had Java 6
560
        if (c != ' ' && c != ',' && c != '*' && !String.valueOf(c).matches(JAVA_FQN_REGEX)) {
561
            getToolkit().beep();
562
            evt.consume();
563
        }
564
    }//GEN-LAST:event_javaCompletionExcluderDialogTextFieldKeyTyped
477
565
478
    private void update(DocumentEvent e) {
566
    private void update(DocumentEvent e) {
479
        if (e.getDocument() == javaAutoCompletionTriggersField.getDocument())
567
        if (e.getDocument() == javaAutoCompletionTriggersField.getDocument())
Lines 490-506 Link Here
490
    private javax.swing.JTextField javaAutoCompletionTriggersField;
578
    private javax.swing.JTextField javaAutoCompletionTriggersField;
491
    private javax.swing.JLabel javaAutoCompletionTriggersLabel;
579
    private javax.swing.JLabel javaAutoCompletionTriggersLabel;
492
    private javax.swing.JCheckBox javaAutoPopupOnIdentifierPart;
580
    private javax.swing.JCheckBox javaAutoPopupOnIdentifierPart;
581
    private javax.swing.JList javaCompletionExcludeJlist;
493
    private javax.swing.JScrollPane javaCompletionExcludeScrollPane;
582
    private javax.swing.JScrollPane javaCompletionExcludeScrollPane;
494
    private javax.swing.JTable javaCompletionExcludeTable;
495
    private javax.swing.JButton javaCompletionExcluderAddButton;
583
    private javax.swing.JButton javaCompletionExcluderAddButton;
496
    private javax.swing.JButton javaCompletionExcluderButton;
584
    private javax.swing.JButton javaCompletionExcluderButton;
497
    private javax.swing.JButton javaCompletionExcluderCloseButton;
585
    private javax.swing.JButton javaCompletionExcluderCloseButton;
498
    private javax.swing.JFrame javaCompletionExcluderFrame;
586
    private javax.swing.JDialog javaCompletionExcluderDialog1;
587
    private javax.swing.JDialog javaCompletionExcluderDialog2;
588
    private javax.swing.JButton javaCompletionExcluderDialogCancelButton;
589
    private javax.swing.JLabel javaCompletionExcluderDialogLabel;
590
    private javax.swing.JButton javaCompletionExcluderDialogOkButton;
591
    private javax.swing.JTextField javaCompletionExcluderDialogTextField;
592
    private javax.swing.JButton javaCompletionExcluderEditButton;
499
    private javax.swing.JLabel javaCompletionExcluderLabel;
593
    private javax.swing.JLabel javaCompletionExcluderLabel;
594
    private javax.swing.JCheckBox javaCompletionExcluderMethodsCheckBox;
500
    private javax.swing.JButton javaCompletionExcluderRemoveButton;
595
    private javax.swing.JButton javaCompletionExcluderRemoveButton;
501
    private javax.swing.JTabbedPane javaCompletionExcluderTab;
596
    private javax.swing.JTabbedPane javaCompletionExcluderTab;
597
    private javax.swing.JList javaCompletionIncludeJlist;
502
    private javax.swing.JScrollPane javaCompletionIncludeScrollPane;
598
    private javax.swing.JScrollPane javaCompletionIncludeScrollPane;
503
    private javax.swing.JTable javaCompletionIncludeTable;
504
    private javax.swing.JPanel javaCompletionPane;
599
    private javax.swing.JPanel javaCompletionPane;
505
    private javax.swing.JTextField javaCompletionSelectorsField;
600
    private javax.swing.JTextField javaCompletionSelectorsField;
506
    private javax.swing.JLabel javaCompletionSelectorsLabel;
601
    private javax.swing.JLabel javaCompletionSelectorsLabel;
Lines 508-518 Link Here
508
    private javax.swing.JLabel javadocAutoCompletionTriggersLabel;
603
    private javax.swing.JLabel javadocAutoCompletionTriggersLabel;
509
    // End of variables declaration//GEN-END:variables
604
    // End of variables declaration//GEN-END:variables
510
    
605
    
511
    private static class CodeCompletionPreferencesCusromizer implements PreferencesCustomizer {
606
    private static class CodeCompletionPreferencesCustomizer implements PreferencesCustomizer {
512
607
513
        private final Preferences preferences;
608
        private final Preferences preferences;
514
609
515
        private CodeCompletionPreferencesCusromizer(Preferences p) {
610
        private CodeCompletionPreferencesCustomizer(Preferences p) {
516
            preferences = p;
611
            preferences = p;
517
        }
612
        }
518
613

Return to bug 125060