diff --git a/ide/db.sql.editor/nbproject/project.xml b/ide/db.sql.editor/nbproject/project.xml index b17121685e30..d4f99343d05a 100644 --- a/ide/db.sql.editor/nbproject/project.xml +++ b/ide/db.sql.editor/nbproject/project.xml @@ -157,6 +157,15 @@ <specification-version>1.27</specification-version> </run-dependency> </dependency> + <dependency> + <code-name-base>org.netbeans.modules.options.editor</code-name-base> + <build-prerequisite/> + <compile-dependency/> + <run-dependency> + <release-version>1</release-version> + <specification-version>1.88</specification-version> + </run-dependency> + </dependency> <dependency> <code-name-base>org.netbeans.modules.projectapi</code-name-base> <build-prerequisite/> diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/OptionsUtils.java b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/OptionsUtils.java index b39d11b36afb..dd8a1f9c9d7f 100644 --- a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/OptionsUtils.java +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/OptionsUtils.java @@ -32,7 +32,9 @@ */ public final class OptionsUtils { // package visible to allow access from unit tests - static final String PAIR_CHARACTERS_COMPLETION = "pair-characters-completion"; + public static final String PAIR_CHARACTERS_COMPLETION = "pair-characters-completion"; //NOI18N + public static final String SQL_AUTO_COMPLETION_SUBWORDS = "sql-completion-subwords"; //NOI18N + public static final boolean SQL_AUTO_COMPLETION_SUBWORDS_DEFAULT = false; private static final AtomicBoolean INITED = new AtomicBoolean(false); private static final PreferenceChangeListener PREFERENCES_TRACKER = new PreferenceChangeListener() { @@ -40,17 +42,20 @@ public final class OptionsUtils { public void preferenceChange(PreferenceChangeEvent evt) { String settingName = evt == null ? null : evt.getKey(); - if (settingName == null - || PAIR_CHARACTERS_COMPLETION.equals(settingName)) { - pairCharactersCompletion = preferences.getBoolean( - PAIR_CHARACTERS_COMPLETION, true); + if (settingName == null || PAIR_CHARACTERS_COMPLETION.equals(settingName)) { + pairCharactersCompletion = preferences.getBoolean(PAIR_CHARACTERS_COMPLETION, true); } + + if (settingName == null || SQL_AUTO_COMPLETION_SUBWORDS.equals(settingName)) { + sqlCompletionSubwords = preferences.getBoolean(SQL_AUTO_COMPLETION_SUBWORDS, SQL_AUTO_COMPLETION_SUBWORDS_DEFAULT); } + } }; private static Preferences preferences; private static boolean pairCharactersCompletion = true; + private static boolean sqlCompletionSubwords = SQL_AUTO_COMPLETION_SUBWORDS_DEFAULT; private OptionsUtils() { } @@ -65,6 +70,16 @@ public static boolean isPairCharactersCompletion() { return pairCharactersCompletion; } + /** + * Option: "Subword Completion" + * + * @return true if code completion should be subword based + */ + public static boolean isSqlCompletionSubwords() { + lazyInit(); + return sqlCompletionSubwords; + } + private static void lazyInit() { if (INITED.compareAndSet(false, true)) { preferences = MimeLookup.getLookup(SQLLanguageConfig.mimeType).lookup(Preferences.class); diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/completion/SQLCompletionItems.java b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/completion/SQLCompletionItems.java index f191d95f0ef4..b9411aed70f3 100644 --- a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/completion/SQLCompletionItems.java +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/completion/SQLCompletionItems.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -38,6 +39,7 @@ import org.netbeans.modules.db.metadata.model.api.Tuple; import org.netbeans.modules.db.metadata.model.api.View; import org.netbeans.modules.db.sql.analyzer.QualIdent; +import org.netbeans.modules.db.sql.editor.OptionsUtils; import org.netbeans.modules.db.sql.editor.api.completion.SQLCompletionResultSet; import org.netbeans.modules.db.sql.editor.api.completion.SubstitutionHandler; import org.netbeans.spi.editor.completion.CompletionResultSet; @@ -48,7 +50,7 @@ */ public class SQLCompletionItems implements Iterable<SQLCompletionItem> { - private final List<SQLCompletionItem> items = new ArrayList<SQLCompletionItem>(); + private final List<SQLCompletionItem> items = new ArrayList<>(); private final Quoter quoter; private final SubstitutionHandler substitutionHandler; @@ -67,32 +69,28 @@ public void addKeywords(String prefix, final int substitutionOffset, String... k } public Set<String> addCatalogs(Metadata metadata, Set<String> restrict, String prefix, final boolean quote, final int substitutionOffset) { - Set<String> result = new TreeSet<String>(); - filterMetadata(metadata.getCatalogs(), restrict, prefix, new Handler<Catalog>() { - public void handle(Catalog catalog) { - String catalogName = catalog.getName(); - items.add(SQLCompletionItem.catalog( - catalogName, - doQuote(catalogName, quote), - substitutionOffset, - substitutionHandler)); - } + Set<String> result = new TreeSet<>(); + filterMetadata(metadata.getCatalogs(), restrict, prefix, (Catalog catalog) -> { + String catalogName = catalog.getName(); + items.add(SQLCompletionItem.catalog( + catalogName, + doQuote(catalogName, quote), + substitutionOffset, + substitutionHandler)); }); return result; } public Set<String> addSchemas(Catalog catalog, Set<String> restrict, String prefix, final boolean quote, final int substitutionOffset) { - Set<String> result = new TreeSet<String>(); - filterMetadata(catalog.getSchemas(), restrict, prefix, new Handler<Schema>() { - public void handle(Schema schema) { - if (!schema.isSynthetic()) { - String schemaName = schema.getName(); - items.add(SQLCompletionItem.schema( - schemaName, - doQuote(schemaName, quote), - substitutionOffset, - substitutionHandler)); - } + Set<String> result = new TreeSet<>(); + filterMetadata(catalog.getSchemas(), restrict, prefix, (Schema schema) -> { + if (!schema.isSynthetic()) { + String schemaName = schema.getName(); + items.add(SQLCompletionItem.schema( + schemaName, + doQuote(schemaName, quote), + substitutionOffset, + substitutionHandler)); } }); return result; @@ -110,17 +108,15 @@ private void addTables(Schema schema, QualIdent fullyTypedIdent, Set<String> res final String schema4display = fullyTypedIdent == null ? "" : fullyTypedIdent.getSimpleName () + '.'; // NOI18N final int ownOffset = fullyTypedIdent == null ? substitutionOffset : substitutionOffset - (fullyTypedIdent.getSimpleName ().length () + 1); - filterMetadata(schema.getTables(), restrict, prefix, new Handler<Table>() { - public void handle(Table table) { - String tableName = table.getName(); - items.add(SQLCompletionItem.table( - tableName, - doQuote(tableName, quote), - ownOffset, - ownHandler ? + filterMetadata(schema.getTables(), restrict, prefix, (Table table) -> { + String tableName = table.getName(); + items.add(SQLCompletionItem.table( + tableName, + doQuote(tableName, quote), + ownOffset, + ownHandler ? new ExtendedSubstitutionHandler (substitutionHandler, schema4display, " (") // NOI18N : substitutionHandler)); - } }); } @@ -136,26 +132,22 @@ private void addViews(Schema schema, QualIdent fullyTypedIdent, Set<String> rest final String schema4display = fullyTypedIdent == null ? "" : fullyTypedIdent.getSimpleName () + '.'; // NOI18N final int ownOffset = fullyTypedIdent == null ? substitutionOffset : substitutionOffset - (fullyTypedIdent.getSimpleName ().length () + 1); - filterMetadata(schema.getViews(), restrict, prefix, new Handler<View>() { - public void handle(View view) { - String viewName = view.getName(); - items.add(SQLCompletionItem.view( - viewName, - doQuote(viewName, quote), - ownOffset, - ownHandler ? + filterMetadata(schema.getViews(), restrict, prefix, (View view) -> { + String viewName = view.getName(); + items.add(SQLCompletionItem.view( + viewName, + doQuote(viewName, quote), + ownOffset, + ownHandler ? new ExtendedSubstitutionHandler (substitutionHandler, schema4display, " (") // NOI18N : substitutionHandler)); - } }); } public void addAliases(Map<String, QualIdent> aliases, String prefix, final boolean quote, final int substitutionOffset) { - filterMap(aliases, null, prefix, new ParamHandler<String, QualIdent>() { - public void handle(String alias, QualIdent tableName) { - // Issue 145173: do not quote aliases. - items.add(SQLCompletionItem.alias(alias, tableName, alias, substitutionOffset, substitutionHandler)); - } + filterMap(aliases, null, prefix, (String alias, QualIdent tableName) -> { + // Issue 145173: do not quote aliases. + items.add(SQLCompletionItem.alias(alias, tableName, alias, substitutionOffset, substitutionHandler)); }); } @@ -170,7 +162,7 @@ public void addColumns(Tuple tuple, String prefix, final boolean quote, final in private void addColumns(final Tuple tuple, QualIdent fullyTypedIdent, String prefix, final boolean quote, final int substitutionOffset, final boolean ownHandler) { Schema schema = tuple.getParent(); Catalog catalog = schema.getParent(); - List<String> parts = new ArrayList<String>(3); + List<String> parts = new ArrayList<>(3); if (!catalog.isDefault()) { parts.add(catalog.getName()); } @@ -183,20 +175,18 @@ private void addColumns(final Tuple tuple, QualIdent fullyTypedIdent, String pre fullyTypedIdent.getFirstQualifier () + '.' + fullyTypedIdent.getSecondQualifier (); // NOI18N final int ownOffset = fullyTypedIdent == null ? substitutionOffset : substitutionOffset - (fullyTypedIdent.getFirstQualifier ().length () + fullyTypedIdent.getSecondQualifier ().length () + 2); - filterMetadata(tuple.getColumns(), null, prefix, new Handler<Column>() { - public void handle(Column column) { - String columnName = column.getName(); - items.add(SQLCompletionItem.column ( - tuple instanceof View, - qualTableName, - columnName, - column.getTypeName(), - doQuote(columnName, quote), - ownOffset, - ownHandler ? + filterMetadata(tuple.getColumns(), null, prefix, (Column column) -> { + String columnName = column.getName(); + items.add(SQLCompletionItem.column ( + tuple instanceof View, + qualTableName, + columnName, + column.getTypeName(), + doQuote(columnName, quote), + ownOffset, + ownHandler ? new ExtendedSubstitutionHandler (substitutionHandler, table4display + " (", null) // NOI18N : substitutionHandler)); - } }); } @@ -208,6 +198,7 @@ public void fill(SQLCompletionResultSet resultSet) { resultSet.addAllItems(items); } + @Override public Iterator<SQLCompletionItem> iterator() { return items.iterator(); } @@ -224,8 +215,18 @@ private static boolean startsWithIgnoreCase(String text, String prefix) { return text.regionMatches(true, 0, prefix, 0, prefix.length()); } + private static boolean containsIgnoreCase(String text, String prefix) { + return text.toLowerCase(Locale.ROOT).contains(prefix.toLowerCase(Locale.ROOT)); + } + private static boolean filter(String string, String prefix) { - return prefix == null || startsWithIgnoreCase(string, prefix); + if(prefix == null) { + return true; + } else if (OptionsUtils.isSqlCompletionSubwords()) { + return containsIgnoreCase(string, prefix); + } else { + return startsWithIgnoreCase(string, prefix); + } } private static <P> void filterMap(Map<String, P> strings, Set<String> restrict, String prefix, ParamHandler<String, P> handler) { @@ -267,6 +268,7 @@ public ExtendedSubstitutionHandler (SubstitutionHandler handler, String prefix, this.prefix = prefix == null ? "" : prefix; this.postfix = postfix == null ? "" : postfix; } + @Override public void substituteText (JTextComponent component, int offset, String text) { original.substituteText (component, offset, prefix + text + postfix); } diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/resources/layer.xml b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/resources/layer.xml index d989aafb01aa..20b703cea207 100644 --- a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/resources/layer.xml +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/resources/layer.xml @@ -158,5 +158,23 @@ <file name="x-sql" url="SQLExample"/> </folder> </folder> + + <folder name="Editor"> + <folder name="CodeCompletion"> + <folder name="text"> + <folder name="x-sql"> + <file name="JavaSpecific.instance"> + <attr name="instanceOf" stringvalue="org.netbeans.modules.options.editor.spi.PreferencesCustomizer$Factory"/> + <attr name="instanceCreate" methodvalue="org.netbeans.modules.db.sql.editor.ui.options.CodeCompletionPanel.getCustomizerFactory"/> + <attr name="position" intvalue="100"/> + </file> + <file name="JavaSpecificCustomCustomizer.instance"> + <attr name="instanceCreate" newvalue="org.netbeans.modules.db.sql.editor.ui.options.CodeCompletionPanel$CustomCustomizerImpl"/> + <attr name="position" intvalue="110"/> + </file> + </folder> + </folder> + </folder> + </folder> </folder> </filesystem> diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/Bundle.properties b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/Bundle.properties new file mode 100644 index 000000000000..abd96b731e72 --- /dev/null +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/Bundle.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +CodeCompletionPanel.sqlAutoCompletionSubwords.toolTipText= +CodeCompletionPanel.sqlAutoCompletionSubwords.text=&Subword completion diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.form b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.form new file mode 100644 index 000000000000..307c8a6ba3b9 --- /dev/null +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.form @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<!-- + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + +--> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JCheckBox" name="sqlAutoCompletionSubwords"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/netbeans/modules/db/sql/editor/ui/options/Bundle.properties" key="CodeCompletionPanel.sqlAutoCompletionSubwords.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="org/netbeans/modules/db/sql/editor/ui/options/Bundle.properties" key="CodeCompletionPanel.sqlAutoCompletionSubwords.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sqlAutoCompletionSubwordsActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="6" insetsBottom="6" insetsRight="6" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.Box$Filler" name="filler1"> + <Properties> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32767, 32767]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.Glue"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> diff --git a/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.java b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.java new file mode 100644 index 000000000000..dd52e5c96fd0 --- /dev/null +++ b/ide/db.sql.editor/src/org/netbeans/modules/db/sql/editor/ui/options/CodeCompletionPanel.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.netbeans.modules.db.sql.editor.ui.options; + +import java.util.HashMap; +import java.util.Map; +import java.util.prefs.Preferences; +import javax.swing.JComponent; +import org.netbeans.modules.options.editor.spi.PreferencesCustomizer; +import org.openide.util.HelpCtx; + +import static org.netbeans.modules.db.sql.editor.OptionsUtils.SQL_AUTO_COMPLETION_SUBWORDS; +import static org.netbeans.modules.db.sql.editor.OptionsUtils.SQL_AUTO_COMPLETION_SUBWORDS_DEFAULT; + +public class CodeCompletionPanel extends javax.swing.JPanel { + private final Preferences preferences; + + private final Map<String, Object> id2Saved = new HashMap<>(); + + /** Creates new form FmtTabsIndents */ + @SuppressWarnings("this-escape") + public CodeCompletionPanel(Preferences p) { + initComponents(); + preferences = p; + sqlAutoCompletionSubwords.setSelected(preferences.getBoolean(SQL_AUTO_COMPLETION_SUBWORDS, SQL_AUTO_COMPLETION_SUBWORDS_DEFAULT)); + + id2Saved.put(SQL_AUTO_COMPLETION_SUBWORDS, sqlAutoCompletionSubwords.isSelected()); + } + + public static PreferencesCustomizer.Factory getCustomizerFactory() { + return CodeCompletionPreferencesCustomizer::new; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + sqlAutoCompletionSubwords = new javax.swing.JCheckBox(); + filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767)); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + setLayout(new java.awt.GridBagLayout()); + + org.openide.awt.Mnemonics.setLocalizedText(sqlAutoCompletionSubwords, org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.sqlAutoCompletionSubwords.text")); // NOI18N + sqlAutoCompletionSubwords.setToolTipText(org.openide.util.NbBundle.getMessage(CodeCompletionPanel.class, "CodeCompletionPanel.sqlAutoCompletionSubwords.toolTipText")); // NOI18N + sqlAutoCompletionSubwords.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + sqlAutoCompletionSubwordsActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(6, 6, 6, 6); + add(sqlAutoCompletionSubwords, gridBagConstraints); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(filler1, gridBagConstraints); + }// </editor-fold>//GEN-END:initComponents + + private void sqlAutoCompletionSubwordsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sqlAutoCompletionSubwordsActionPerformed + preferences.putBoolean(SQL_AUTO_COMPLETION_SUBWORDS, sqlAutoCompletionSubwords.isSelected()); + }//GEN-LAST:event_sqlAutoCompletionSubwordsActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.Box.Filler filler1; + private javax.swing.JCheckBox sqlAutoCompletionSubwords; + // End of variables declaration//GEN-END:variables + + private static class CodeCompletionPreferencesCustomizer implements PreferencesCustomizer { + + private final Preferences preferences; + private CodeCompletionPanel component; + + private CodeCompletionPreferencesCustomizer(Preferences p) { + preferences = p; + } + + @Override + public String getId() { + throw new UnsupportedOperationException("Not supported yet."); //NOI18N + } + + @Override + public String getDisplayName() { + throw new UnsupportedOperationException("Not supported yet."); //NOI18N + } + + @Override + public HelpCtx getHelpCtx() { + return new HelpCtx("netbeans.optionsDialog.editor.codeCompletion.sql"); //NOI18N + } + + @Override + public JComponent getComponent() { + if (component == null) { + component = new CodeCompletionPanel(preferences); + } + return component; + } + } + + String getSavedValue(String key) { + return id2Saved.get(key).toString(); + } + + public static final class CustomCustomizerImpl extends PreferencesCustomizer.CustomCustomizer { + + @Override + public String getSavedValue(PreferencesCustomizer customCustomizer, String key) { + if (customCustomizer instanceof CodeCompletionPreferencesCustomizer) { + return ((CodeCompletionPanel) customCustomizer.getComponent()).getSavedValue(key); + } + return null; + } + } +} diff --git a/ide/options.editor/manifest.mf b/ide/options.editor/manifest.mf index 285ed895e6df..61e56f39824f 100644 --- a/ide/options.editor/manifest.mf +++ b/ide/options.editor/manifest.mf @@ -2,6 +2,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.options.editor/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/options/editor/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/options/editor/mf-layer.xml -OpenIDE-Module-Specification-Version: 1.87 +OpenIDE-Module-Specification-Version: 1.88 AutoUpdate-Show-In-Client: false diff --git a/ide/options.editor/nbproject/project.xml b/ide/options.editor/nbproject/project.xml index 2ba0ae7734ab..917da4fb1353 100644 --- a/ide/options.editor/nbproject/project.xml +++ b/ide/options.editor/nbproject/project.xml @@ -353,6 +353,7 @@ <friend>org.netbeans.modules.cnd.completion</friend> <friend>org.netbeans.modules.cnd.editor</friend> <friend>org.netbeans.modules.csl.api</friend> + <friend>org.netbeans.modules.db.sql.editor</friend> <friend>org.netbeans.modules.diff</friend> <friend>org.netbeans.modules.editor.indent.project</friend> <friend>org.netbeans.modules.groovy.grailsproject</friend>