# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /Users/samuel/Documents/Java/NetBeans/main-golden/java.editor # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/netbeans/modules/editor/java/ExcludeCompletion.java --- src/org/netbeans/modules/editor/java/ExcludeCompletion.java Base (BASE) +++ src/org/netbeans/modules/editor/java/ExcludeCompletion.java Locally New @@ -0,0 +1,142 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Samuel Halliday + * + * Portions Copyrighted 2009 Sun Microsystems, Inc. + */ +package org.netbeans.modules.editor.java; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; +import java.util.prefs.Preferences; +import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.modules.java.editor.options.CodeCompletionPanel; + +/** + * A whitelist/blacklist of excluded classes and packages for the Java completer. + * Requested in RFE #125060. + * + * @author Samuel Halliday + */ +public final class ExcludeCompletion implements PreferenceChangeListener { + + private final Collection exclude = new ArrayList(); + private final Collection include = new ArrayList(); + private static volatile ExcludeCompletion singleton = null; + + /** + * Cheap operation to return the instance + * + * @return + */ + public static ExcludeCompletion getInstance() { + // lazy check without lock + if (singleton == null) + synchronized (ExcludeCompletion.class) { + if (singleton == null) { + Preferences preferences = + MimeLookup.getLookup(JavaKit.JAVA_MIME_TYPE).lookup(Preferences.class); + singleton = new ExcludeCompletion(preferences); + preferences.addPreferenceChangeListener(singleton); + } + } + assert singleton != null; + return singleton; + } + + private ExcludeCompletion(Preferences preferences) { + String blacklist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST, null); + String whitelist = preferences.get(CodeCompletionPanel.JAVA_COMPLETION_WHITELIST, null); + update(exclude, blacklist); + update(include, whitelist); + } + + /** + * @param fqn Fully Qualified Name + * @return + */ + public boolean isExcluded(final String fqn) { + //#122334: do not propose imports from the default package + if (fqn == null || fqn.length() == 0) + return true; + + if (include.size() > 0) + for (String entry : include) { + if (entry.length() > fqn.length()) { + if (entry.startsWith(fqn)) + return false; + } else if (fqn.startsWith(entry)) + return false; + } + + if (exclude.size() > 0) + for (String entry : exclude) { + if (entry.endsWith(".") && fqn.equals(entry.substring(0, entry.length() - 1))) // NOI18N + // exclude packages names (no trailing fullstop) + return true; + if (entry.length() > fqn.length()) + // fqn not long enough to filter yet + continue; + if (fqn.startsWith(entry)) + return true; + } + + return false; + } + + public void preferenceChange(PreferenceChangeEvent evt) { + if (evt == null) + return; + String key = evt.getKey(); + if (CodeCompletionPanel.JAVA_COMPLETION_BLACKLIST.equals(key)) + update(exclude, evt.getNewValue()); + else if (CodeCompletionPanel.JAVA_COMPLETION_WHITELIST.equals(key)) + update(include, evt.getNewValue()); + } + + private void update(Collection existing, String updated) { + existing.clear(); + if (updated == null || updated.length() == 0) + return; + String[] entries = updated.split(","); //NOI18N + for (String entry : entries) { + existing.add(entry); + } + } +} Index: src/org/netbeans/modules/editor/java/JavaCompletionProvider.java --- src/org/netbeans/modules/editor/java/JavaCompletionProvider.java Base (BASE) +++ src/org/netbeans/modules/editor/java/JavaCompletionProvider.java Locally Modified (Based On LOCAL) @@ -2728,10 +2728,13 @@ private void addPackages(Env env, String fqnPrefix, boolean inPkgStmt) { if (fqnPrefix == null) fqnPrefix = EMPTY; - for (String pkgName : env.getController().getClasspathInfo().getClassIndex().getPackageNames(fqnPrefix, true,EnumSet.allOf(ClassIndex.SearchScope.class))) - if (pkgName.length() > 0) + ExcludeCompletion excluder = ExcludeCompletion.getInstance(); + for (String pkgName : env.getController().getClasspathInfo().getClassIndex().getPackageNames(fqnPrefix, true,EnumSet.allOf(ClassIndex.SearchScope.class))){ + if (excluder.isExcluded(pkgName)) + continue; results.add(JavaCompletionItem.createPackageItem(pkgName, anchorOffset, inPkgStmt)); } + } private void addTypes(Env env, EnumSet kinds, DeclaredType baseType, Set toExclude, boolean insideNew) throws IOException { if (queryType == COMPLETION_ALL_QUERY_TYPE) { @@ -2807,7 +2810,11 @@ ClassIndex.NameKind kind = env.isCamelCasePrefix() ? Utilities.isCaseSensitive() ? ClassIndex.NameKind.CAMEL_CASE : ClassIndex.NameKind.CAMEL_CASE_INSENSITIVE : Utilities.isCaseSensitive() ? ClassIndex.NameKind.PREFIX : ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX; + ExcludeCompletion excluder = ExcludeCompletion.getInstance(); for(ElementHandle name : controller.getClasspathInfo().getClassIndex().getDeclaredTypes(prefix != null ? prefix : EMPTY, kind, EnumSet.allOf(ClassIndex.SearchScope.class))) { + String fqn = name.getQualifiedName(); + if (excluder.isExcluded(fqn)) + continue; LazyTypeCompletionItem item = LazyTypeCompletionItem.create(name, kinds, anchorOffset, controller.getSnapshot().getSource(), insideNew); if (item.isAnnonInner()) continue; Index: src/org/netbeans/modules/java/editor/imports/ComputeImports.java --- src/org/netbeans/modules/java/editor/imports/ComputeImports.java Base (BASE) +++ src/org/netbeans/modules/java/editor/imports/ComputeImports.java Locally Modified (Based On LOCAL) @@ -72,6 +72,7 @@ import org.netbeans.api.java.source.ClassIndex.NameKind; import org.netbeans.api.java.source.ElementHandle; import org.netbeans.api.java.source.support.CancellableTreePathScanner; +import org.netbeans.modules.editor.java.ExcludeCompletion; import org.netbeans.modules.java.editor.javadoc.JavadocImports; import org.openide.util.Union2; @@ -127,6 +128,7 @@ unresolvedNames.addAll(JavadocImports.computeUnresolvedImports(info)); + ExcludeCompletion excluder = ExcludeCompletion.getInstance(); for (String unresolved : unresolvedNames) { if (isCancelled()) return null; @@ -145,11 +147,11 @@ continue; } - //#122334: do not propose imports from the default package: - if (info.getElements().getPackageOf(te).getQualifiedName().length() != 0) { + String fqn = info.getElements().getPackageOf(te).getQualifiedName().toString(); + if (excluder.isExcluded(fqn)) + continue; classes.add(te); } - } Collections.sort(classes, new Comparator() { public int compare(TypeElement te1, TypeElement te2) { return (te1 == te2) ? 0 : te1.getQualifiedName().toString().compareTo(te2.getQualifiedName().toString()); Index: src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java --- src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java Base (BASE) +++ src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java Locally Modified (Based On LOCAL) @@ -321,7 +321,8 @@ private ImportVisitor (CompilationInfo info) { this.info = info; - currentPackage = info.getCompilationUnit().getPackageName().toString(); + ExpressionTree pkg = info.getCompilationUnit().getPackageName(); + currentPackage = pkg != null ? pkg.toString() : ""; imports = new ArrayList(); } Index: src/org/netbeans/modules/java/editor/javadoc/JavadocCompletionQuery.java --- src/org/netbeans/modules/java/editor/javadoc/JavadocCompletionQuery.java Base (BASE) +++ src/org/netbeans/modules/java/editor/javadoc/JavadocCompletionQuery.java Locally Modified (Based On LOCAL) @@ -94,6 +94,7 @@ import org.netbeans.api.java.source.TreeUtilities; import org.netbeans.api.lexer.Token; import org.netbeans.api.lexer.TokenSequence; +import org.netbeans.modules.editor.java.ExcludeCompletion; import org.netbeans.modules.editor.java.JavaCompletionItem; import org.netbeans.modules.editor.java.LazyTypeCompletionItem; import org.netbeans.modules.editor.java.Utilities; @@ -602,10 +603,13 @@ } } - for (String pkgName : jdctx.javac.getClasspathInfo().getClassIndex().getPackageNames(pkgPrefix, true, EnumSet.allOf(ClassIndex.SearchScope.class))) - if (pkgName.length() > 0) + ExcludeCompletion excluder = ExcludeCompletion.getInstance(); + for (String pkgName : jdctx.javac.getClasspathInfo().getClassIndex().getPackageNames(pkgPrefix, true, EnumSet.allOf(ClassIndex.SearchScope.class))){ + if (excluder.isExcluded(pkgName)) + continue; items.add(JavaCompletionItem.createPackageItem(pkgName, substitutionOffset, false)); } + } private void completeThrowsOrPkg(String fqn, String prefix, int substitutionOffset, JavadocContext jdctx) { final Elements elements = jdctx.javac.getElements(); @@ -1006,7 +1010,11 @@ // ClassIndex.NameKind kind = env.isCamelCasePrefix() ? // Utilities.isCaseSensitive() ? ClassIndex.NameKind.CAMEL_CASE : ClassIndex.NameKind.CAMEL_CASE_INSENSITIVE : // Utilities.isCaseSensitive() ? ClassIndex.NameKind.PREFIX : ClassIndex.NameKind.CASE_INSENSITIVE_PREFIX; + ExcludeCompletion excluder = ExcludeCompletion.getInstance(); for(ElementHandle name : controller.getClasspathInfo().getClassIndex().getDeclaredTypes(prefix, kind, EnumSet.allOf(ClassIndex.SearchScope.class))) { + String fqn = name.getQualifiedName(); + if (excluder.isExcluded(fqn)) + continue; LazyTypeCompletionItem item = LazyTypeCompletionItem.create(name, kinds, substitutionOffset, controller.getSnapshot().getSource(), false); // XXX item.isAnnonInner() is package private :-( // if (item.isAnnonInner()) Index: src/org/netbeans/modules/java/editor/options/Bundle.properties --- src/org/netbeans/modules/java/editor/options/Bundle.properties Base (BASE) +++ src/org/netbeans/modules/java/editor/options/Bundle.properties Locally Modified (Based On LOCAL) @@ -116,3 +116,17 @@ LBL_JavaCompletionLabel=Java Code Completion LBL_GuessMethodParameters=jCheckBox1 LBL_GuessMethodArgs=&Guess Filled Method Arguments +CodeCompletionPanel.javaCompletionExcluderLabel.text=Packages/classes: +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title3=Title 4 +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title2=Title 3 +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title1=Title 2 +CodeCompletionPanel.javaCompletionExcluderButton.text=Exclude +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title3_1=Title 4 +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title2_1=Title 3 +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title1_1=Title 2 +CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle=Exclude +CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0=Fully Qualified Name prefix +CodeCompletionPanel.javaCompletionExcluderAddButton.text=Add +CodeCompletionPanel.javaCompletionExcluderDeleteButton.text=Delete +CodeCompletionPanel.javaCompletionExcluderBackButton.text=Back +CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle=Include Index: src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.form --- src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.form Base (BASE) +++ src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.form Locally Modified (Based On LOCAL) @@ -1,6 +1,6 @@ -
+ @@ -18,15 +18,32 @@ + + + + + + + + + + - + + + + + + + + + - @@ -34,24 +51,41 @@ + - + + + + + + - - - - + + + + + + - + + + + + + + + + + @@ -66,16 +100,17 @@ - - - + - - + + - + + + + @@ -84,9 +119,6 @@ - - - @@ -97,9 +129,6 @@ - - - @@ -151,5 +180,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + + + + + + + + + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <ResourceString bundle="org/netbeans/modules/java/editor/options/Bundle.properties" key="CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Index: src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.java --- src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.java Base (BASE) +++ src/org/netbeans/modules/java/editor/options/CodeCompletionPanel.java Locally Modified (Based On LOCAL) @@ -38,13 +38,21 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.java.editor.options; +import java.awt.CardLayout; +import java.awt.Component; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.Vector; import java.util.prefs.Preferences; import javax.swing.JComponent; +import javax.swing.JTable; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; import org.netbeans.modules.options.editor.spi.PreferencesCustomizer; import org.openide.util.HelpCtx; @@ -52,16 +60,28 @@ * * @author Dusan Balek */ -public class CodeCompletionPanel extends javax.swing.JPanel implements DocumentListener { +public class CodeCompletionPanel extends javax.swing.JPanel implements DocumentListener, TableModelListener { public static final String JAVA_AUTO_POPUP_ON_IDENTIFIER_PART = "javaAutoPopupOnIdentifierPart"; //NOI18N public static final String JAVA_AUTO_COMPLETION_TRIGGERS = "javaAutoCompletionTriggers"; //NOI18N public static final String JAVA_COMPLETION_SELECTORS = "javaCompletionSelectors"; //NOI18N public static final String JAVADOC_AUTO_COMPLETION_TRIGGERS = "javadocAutoCompletionTriggers"; //NOI18N public static final String GUESS_METHOD_ARGUMENTS = "guessMethodArguments"; //NOI18N + public static final String JAVA_COMPLETION_WHITELIST = "javaCompletionWhitelist"; //NOI18N + public static final String JAVA_COMPLETION_BLACKLIST = "javaCompletionBlacklist"; //NOI18N - private Preferences preferences; + private final Preferences preferences; + private void initExcluderTable(JTable table, String pref) { + String[] entries = pref.split(","); //NOI18N + DefaultTableModel model = (DefaultTableModel) table.getModel(); + for (String entry : entries) { + if (entry.length() > 0) + model.addRow(new String[]{entry}); + } + model.addTableModelListener(this); + } + /** Creates new form FmtTabsIndents */ public CodeCompletionPanel(Preferences p) { initComponents(); @@ -71,6 +91,10 @@ javaAutoCompletionTriggersField.setText(preferences.get(JAVA_AUTO_COMPLETION_TRIGGERS, ".")); //NOI18N javaCompletionSelectorsField.setText(preferences.get(JAVA_COMPLETION_SELECTORS, ".,;:([+-=")); //NOI18N javadocAutoCompletionTriggersField.setText(preferences.get(JAVADOC_AUTO_COMPLETION_TRIGGERS, ".#@")); //NOI18N + String blacklist = preferences.get(JAVA_COMPLETION_BLACKLIST, "sun.,sunw."); //NOI18N + initExcluderTable(javaCompletionExcludeTable, blacklist); + String whitelist = preferences.get(JAVA_COMPLETION_WHITELIST, ""); //NOI18N + initExcluderTable(javaCompletionIncludeTable, whitelist); javaAutoCompletionTriggersField.getDocument().addDocumentListener(this); javaCompletionSelectorsField.getDocument().addDocumentListener(this); javadocAutoCompletionTriggersField.getDocument().addDocumentListener(this); @@ -97,6 +121,51 @@ update(e); } + // allows common excluder buttons to know which table to act on + private JTable getSelectedExcluderTable() { + Component selected = javaCompletionExcluderTab.getSelectedComponent(); + if (selected == javaCompletionExcludeScrollPane) + return javaCompletionExcludeTable; + else if (selected == javaCompletionIncludeScrollPane) + return javaCompletionIncludeTable; + else + throw new RuntimeException(selected.getName()); + } + + // listen to changes in the excluder lists, and do sanity checking on input + public void tableChanged(TableModelEvent e) { + DefaultTableModel model = (DefaultTableModel) e.getSource(); + String pref; + if (model == javaCompletionExcludeTable.getModel()) + pref = JAVA_COMPLETION_BLACKLIST; + else if (model == javaCompletionIncludeTable.getModel()) + pref = JAVA_COMPLETION_WHITELIST; + else + throw new RuntimeException(); + @SuppressWarnings("unchecked") + Vector> data = model.getDataVector(); + SortedSet entries = new TreeSet(); + for (Vector row : data) { + String entry = row.elementAt(0); + if (entry == null) + continue; + entry = entry.trim(); + if (entry.length() == 0) + continue; + // this could be checked by a custom editor + if (!entry.matches("[$\\w.]*")) //NOI18N + continue; + entries.add(entry); + } + StringBuilder builder = new StringBuilder(); + for (String entry : entries){ + if (builder.length() > 0) + builder.append(","); //NOI18N + builder.append(entry); + } + preferences.put(pref, builder.toString()); + } + /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is @@ -105,6 +174,7 @@ // //GEN-BEGIN:initComponents private void initComponents() { + javaCompletionPane = new javax.swing.JPanel(); guessMethodArguments = new javax.swing.JCheckBox(); javaAutoPopupOnIdentifierPart = new javax.swing.JCheckBox(); javaAutoCompletionTriggersLabel = new javax.swing.JLabel(); @@ -114,11 +184,22 @@ javadocAutoCompletionTriggersLabel = new javax.swing.JLabel(); javadocAutoCompletionTriggersField = new javax.swing.JTextField(); jSeparator1 = new javax.swing.JSeparator(); + javaCompletionExcluderLabel = new javax.swing.JLabel(); + javaCompletionExcluderButton = new javax.swing.JButton(); + javaCompletionExcluderPane = new javax.swing.JPanel(); + javaCompletionExcluderTab = new javax.swing.JTabbedPane(); + javaCompletionExcludeScrollPane = new javax.swing.JScrollPane(); + javaCompletionExcludeTable = new javax.swing.JTable(); + javaCompletionIncludeScrollPane = new javax.swing.JScrollPane(); + javaCompletionIncludeTable = new javax.swing.JTable(); + javaCompletionExcluderAddButton = new javax.swing.JButton(); + javaCompletionExcluderDeleteButton = new javax.swing.JButton(); + javaCompletionExcluderBackButton = new javax.swing.JButton(); setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + setLayout(new java.awt.CardLayout()); org.openide.awt.Mnemonics.setLocalizedText(guessMethodArguments, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "LBL_GuessMethodArgs")); // NOI18N - guessMethodArguments.setBorder(null); guessMethodArguments.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { guessMethodArgumentsActionPerformed(evt); @@ -126,7 +207,6 @@ }); org.openide.awt.Mnemonics.setLocalizedText(javaAutoPopupOnIdentifierPart, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "LBL_AutoPopupOnIdentifierPartBox")); // NOI18N - javaAutoPopupOnIdentifierPart.setBorder(null); javaAutoPopupOnIdentifierPart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { javaAutoPopupOnIdentifierPartActionPerformed(evt); @@ -146,63 +226,216 @@ javadocAutoCompletionTriggersField.setText(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javadocAutoCompletionTriggersField.text")); // NOI18N - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() + org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderLabel, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderLabel.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderButton.text")); // NOI18N + javaCompletionExcluderButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + javaCompletionExcluderButtonActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout javaCompletionPaneLayout = new org.jdesktop.layout.GroupLayout(javaCompletionPane); + javaCompletionPane.setLayout(javaCompletionPaneLayout); + javaCompletionPaneLayout.setHorizontalGroup( + javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionPaneLayout.createSequentialGroup() .addContainerGap() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE) + .add(javadocAutoCompletionTriggersLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(javadocAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(115, Short.MAX_VALUE)) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionPaneLayout.createSequentialGroup() + .addContainerGap() + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(guessMethodArguments) - .add(layout.createSequentialGroup() + .add(javaCompletionPaneLayout.createSequentialGroup() .add(javaAutoCompletionTriggersLabel) .add(34, 34, 34) .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(javaAutoPopupOnIdentifierPart) - .add(layout.createSequentialGroup() - .add(javaCompletionSelectorsLabel) + .add(jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE) + .add(javaCompletionPaneLayout.createSequentialGroup() + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(javaCompletionExcluderLabel) + .add(javaCompletionSelectorsLabel)) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionPaneLayout.createSequentialGroup() .add(30, 30, 30) .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(layout.createSequentialGroup() - .add(javadocAutoCompletionTriggersLabel) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(javadocAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addContainerGap()) + .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionPaneLayout.createSequentialGroup() + .add(23, 23, 23) + .add(javaCompletionExcluderButton))))) + .addContainerGap())) ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() + javaCompletionPaneLayout.setVerticalGroup( + javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionPaneLayout.createSequentialGroup() + .add(231, 231, 231) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(javadocAutoCompletionTriggersLabel) + .add(javadocAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(52, Short.MAX_VALUE)) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionPaneLayout.createSequentialGroup() .addContainerGap() .add(guessMethodArguments) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(javaAutoCompletionTriggersLabel) .add(javaAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(javaAutoPopupOnIdentifierPart) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(javaCompletionSelectorsLabel) .add(javaCompletionSelectorsField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(18, 18, 18) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(javaCompletionPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(javaCompletionExcluderButton) + .add(javaCompletionExcluderLabel)) + .add(44, 44, 44) .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(18, 18, 18) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(javadocAutoCompletionTriggersLabel) - .add(javadocAutoCompletionTriggersField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(30, Short.MAX_VALUE)) + .addContainerGap(94, Short.MAX_VALUE))) ); + + add(javaCompletionPane, "javaCompletion"); + + javaCompletionExcludeTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Fully Qualified Name prefix" + } + ) { + Class[] types = new Class [] { + java.lang.String.class + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + }); + javaCompletionExcludeTable.getTableHeader().setReorderingAllowed(false); + javaCompletionExcludeScrollPane.setViewportView(javaCompletionExcludeTable); + javaCompletionExcludeTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0")); // NOI18N + javaCompletionExcludeTable.getColumnModel().getColumn(0).setCellEditor(null); + + javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeScrollPane.TabConstraints.tabTitle"), javaCompletionExcludeScrollPane); // NOI18N + + javaCompletionIncludeTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + "Fully Qualified Name prefix" + } + ) { + Class[] types = new Class [] { + java.lang.String.class + }; + + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } + }); + javaCompletionIncludeTable.getTableHeader().setReorderingAllowed(false); + javaCompletionIncludeScrollPane.setViewportView(javaCompletionIncludeTable); + javaCompletionIncludeTable.getColumnModel().getColumn(0).setHeaderValue(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcludeTable.columnModel.title0")); // NOI18N + + javaCompletionExcluderTab.addTab(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionIncludeScrollPane.TabConstraints.tabTitle"), javaCompletionIncludeScrollPane); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderAddButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderAddButton.text")); // NOI18N + javaCompletionExcluderAddButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + javaCompletionExcluderAddButtonActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderDeleteButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderDeleteButton.text")); // NOI18N + javaCompletionExcluderDeleteButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + javaCompletionExcluderDeleteButtonActionPerformed(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(javaCompletionExcluderBackButton, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.javaCompletionExcluderBackButton.text")); // NOI18N + javaCompletionExcluderBackButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + javaCompletionExcluderBackButtonActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout javaCompletionExcluderPaneLayout = new org.jdesktop.layout.GroupLayout(javaCompletionExcluderPane); + javaCompletionExcluderPane.setLayout(javaCompletionExcluderPaneLayout); + javaCompletionExcluderPaneLayout.setHorizontalGroup( + javaCompletionExcluderPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, javaCompletionExcluderPaneLayout.createSequentialGroup() + .addContainerGap() + .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 298, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(javaCompletionExcluderPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionExcluderDeleteButton) + .add(javaCompletionExcluderAddButton) + .add(javaCompletionExcluderBackButton)) + .addContainerGap(26, Short.MAX_VALUE)) + ); + javaCompletionExcluderPaneLayout.setVerticalGroup( + javaCompletionExcluderPaneLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(javaCompletionExcluderPaneLayout.createSequentialGroup() + .addContainerGap() + .add(javaCompletionExcluderTab, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) + .addContainerGap()) + .add(javaCompletionExcluderPaneLayout.createSequentialGroup() + .add(59, 59, 59) + .add(javaCompletionExcluderAddButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(javaCompletionExcluderDeleteButton) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 137, Short.MAX_VALUE) + .add(javaCompletionExcluderBackButton) + .add(22, 22, 22)) + ); + + add(javaCompletionExcluderPane, "javaCompletionExcluder"); }// //GEN-END:initComponents private void javaAutoPopupOnIdentifierPartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaAutoPopupOnIdentifierPartActionPerformed - preferences.putBoolean(JAVA_AUTO_POPUP_ON_IDENTIFIER_PART, javaAutoPopupOnIdentifierPart.isSelected()); + preferences.putBoolean(JAVA_AUTO_POPUP_ON_IDENTIFIER_PART, javaAutoPopupOnIdentifierPart. + isSelected()); }//GEN-LAST:event_javaAutoPopupOnIdentifierPartActionPerformed private void guessMethodArgumentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guessMethodArgumentsActionPerformed preferences.putBoolean(GUESS_METHOD_ARGUMENTS, guessMethodArguments.isSelected()); }//GEN-LAST:event_guessMethodArgumentsActionPerformed + private void javaCompletionExcluderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderButtonActionPerformed + ((CardLayout) getLayout()).next(this); +}//GEN-LAST:event_javaCompletionExcluderButtonActionPerformed + + private void javaCompletionExcluderAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderAddButtonActionPerformed + JTable table = getSelectedExcluderTable(); + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int rows = model.getRowCount(); + model.setRowCount(rows + 1); + table.editCellAt(rows, 0); + table.requestFocus(); +}//GEN-LAST:event_javaCompletionExcluderAddButtonActionPerformed + + private void javaCompletionExcluderBackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderBackButtonActionPerformed + ((CardLayout) getLayout()).previous(this); + }//GEN-LAST:event_javaCompletionExcluderBackButtonActionPerformed + + private void javaCompletionExcluderDeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_javaCompletionExcluderDeleteButtonActionPerformed + JTable table = getSelectedExcluderTable(); + int row = table.getSelectedRow(); + if (row == -1) + return; + DefaultTableModel model = (DefaultTableModel) table.getModel(); + model.removeRow(row); + }//GEN-LAST:event_javaCompletionExcluderDeleteButtonActionPerformed + private void update(DocumentEvent e) { if (e.getDocument() == javaAutoCompletionTriggersField.getDocument()) preferences.put(JAVA_AUTO_COMPLETION_TRIGGERS, javaAutoCompletionTriggersField.getText()); @@ -218,6 +451,18 @@ private javax.swing.JTextField javaAutoCompletionTriggersField; private javax.swing.JLabel javaAutoCompletionTriggersLabel; private javax.swing.JCheckBox javaAutoPopupOnIdentifierPart; + private javax.swing.JScrollPane javaCompletionExcludeScrollPane; + private javax.swing.JTable javaCompletionExcludeTable; + private javax.swing.JButton javaCompletionExcluderAddButton; + private javax.swing.JButton javaCompletionExcluderBackButton; + private javax.swing.JButton javaCompletionExcluderButton; + private javax.swing.JButton javaCompletionExcluderDeleteButton; + private javax.swing.JLabel javaCompletionExcluderLabel; + private javax.swing.JPanel javaCompletionExcluderPane; + private javax.swing.JTabbedPane javaCompletionExcluderTab; + private javax.swing.JScrollPane javaCompletionIncludeScrollPane; + private javax.swing.JTable javaCompletionIncludeTable; + private javax.swing.JPanel javaCompletionPane; private javax.swing.JTextField javaCompletionSelectorsField; private javax.swing.JLabel javaCompletionSelectorsLabel; private javax.swing.JTextField javadocAutoCompletionTriggersField; @@ -226,7 +471,7 @@ private static class CodeCompletionPreferencesCusromizer implements PreferencesCustomizer { - private Preferences preferences; + private final Preferences preferences; private CodeCompletionPreferencesCusromizer(Preferences p) { preferences = p;