diff --git a/editor.lib2/manifest.mf b/editor.lib2/manifest.mf --- a/editor.lib2/manifest.mf +++ b/editor.lib2/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.editor.lib2/1 -OpenIDE-Module-Implementation-Version: 29 +OpenIDE-Module-Implementation-Version: 30 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml OpenIDE-Module-Needs: org.netbeans.modules.editor.actions diff --git a/editor.lib2/src/org/netbeans/modules/editor/lib2/search/EditorFindSupport.java b/editor.lib2/src/org/netbeans/modules/editor/lib2/search/EditorFindSupport.java --- a/editor.lib2/src/org/netbeans/modules/editor/lib2/search/EditorFindSupport.java +++ b/editor.lib2/src/org/netbeans/modules/editor/lib2/search/EditorFindSupport.java @@ -57,6 +57,7 @@ import java.util.WeakHashMap; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.prefs.Preferences; import javax.swing.text.JTextComponent; import javax.swing.text.BadLocationException; import javax.swing.text.Caret; @@ -64,7 +65,10 @@ import javax.swing.text.PlainDocument; import javax.swing.text.Position; import org.netbeans.api.editor.EditorRegistry; +import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.api.editor.settings.FontColorNames; +import org.netbeans.api.editor.settings.SimpleValueNames; import org.netbeans.modules.editor.lib2.ComponentUtils; import org.netbeans.modules.editor.lib2.DocUtils; import org.netbeans.modules.editor.lib2.highlighting.BlockHighlighting; @@ -354,8 +358,11 @@ false ); } - - selectText(comp, pos, pos + len, back); + Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); + if (prefs.get(SimpleValueNames.EDITOR_SEARCH_TYPE, "default").equals("closing")) // NOI18N + ensureVisible(comp, pos, pos); + else + selectText(comp, pos, pos + len, back); return true; } } diff --git a/editor.search/nbproject/project.properties b/editor.search/nbproject/project.properties --- a/editor.search/nbproject/project.properties +++ b/editor.search/nbproject/project.properties @@ -1,3 +1,3 @@ javac.source=1.6 javac.compilerargs=-Xlint -Xlint:-serial -spec.version.base=1.1 +spec.version.base=1.2 diff --git a/editor.search/nbproject/project.xml b/editor.search/nbproject/project.xml --- a/editor.search/nbproject/project.xml +++ b/editor.search/nbproject/project.xml @@ -51,6 +51,15 @@ + org.netbeans.modules.editor.settings + + + + 1 + 1.40 + + + org.netbeans.modules.editor.util diff --git a/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java b/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java --- a/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java +++ b/editor.search/src/org/netbeans/modules/editor/search/ReplaceBar.java @@ -63,7 +63,6 @@ private static ReplaceBar replacebarInstance = null; private static final Logger LOG = Logger.getLogger(ReplaceBar.class.getName()); - private static final boolean CLOSE_ON_ENTER = Boolean.getBoolean("org.netbeans.modules.editor.search.closeOnEnter"); // NOI18N private static final Insets BUTTON_INSETS = new Insets(2, 1, 0, 1); private SearchBar searchBar; private final JComboBox replaceComboBox; @@ -245,9 +244,6 @@ @Override public void actionPerformed(ActionEvent e) { replace(); - if (CLOSE_ON_ENTER) { - looseFocus(); - } } }); } @@ -262,9 +258,6 @@ @Override public void actionPerformed(ActionEvent e) { replaceAll(); - if (CLOSE_ON_ENTER) { - looseFocus(); - } } }); } diff --git a/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java b/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java --- a/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java +++ b/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java @@ -39,10 +39,7 @@ */ package org.netbeans.modules.editor.search; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.Toolkit; +import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -52,7 +49,9 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; +import java.util.logging.LogRecord; import java.util.logging.Logger; +import java.util.prefs.Preferences; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.swing.*; @@ -63,6 +62,8 @@ import javax.swing.text.*; import org.netbeans.api.editor.EditorRegistry; import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.editor.mimelookup.MimePath; +import org.netbeans.api.editor.settings.SimpleValueNames; import org.netbeans.editor.BaseDocument; import org.netbeans.editor.BaseKit; import org.netbeans.editor.MultiKeymap; @@ -83,7 +84,6 @@ public final class SearchBar extends JPanel { private static SearchBar searchbarInstance = null; private static final Logger LOG = Logger.getLogger(SearchBar.class.getName()); - private static final boolean CLOSE_ON_ENTER = Boolean.getBoolean("org.netbeans.modules.editor.search.closeOnEnter"); // NOI18N private static final Insets BUTTON_INSETS = new Insets(2, 1, 0, 1); private static final Color NOT_FOUND = Color.RED.darker(); private static final Color INVALID_REGEXP = Color.red; @@ -110,8 +110,8 @@ private final JButton closeButton; private final SearchExpandMenu expandMenu; private Map findProps = EditorFindSupport.getInstance().getFindProperties(); - private boolean searched = false; private boolean popupMenuWasCanceled = false; + private Rectangle actualViewPort; public static SearchBar getInstance() { if (searchbarInstance == null) { @@ -226,6 +226,16 @@ makeBarExpandable(expandMenu); setVisible(false); + usageLogging(); + } + + private static void usageLogging() { + Logger logger = Logger.getLogger("org.netbeans.ui.metrics.editor"); // NOI18N + LogRecord rec = new LogRecord(Level.INFO, "USG_SEARCH_TYPE"); // NOI18N + Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); + rec.setParameters(new Object[] {prefs.get(SimpleValueNames.EDITOR_SEARCH_TYPE, "default")}); // NOI18N + rec.setLoggerName(logger.getName()); + logger.log(rec); } private void makeBarExpandable(SearchExpandMenu expMenu) { @@ -266,6 +276,8 @@ return; } hadFocusOnIncSearchTextField = false; + if (isClosingSearchType() && !ReplaceBar.getInstance(SearchBar.getInstance()).isVisible()) + looseFocus(); } }; } @@ -341,9 +353,6 @@ @Override public void actionPerformed(ActionEvent e) { findPrevious(); - if (CLOSE_ON_ENTER) { - looseFocus(); - } } }); } @@ -358,7 +367,7 @@ @Override public void actionPerformed(ActionEvent e) { findNext(); - if (CLOSE_ON_ENTER) { + if (isClosingSearchType() && !ReplaceBar.getInstance(SearchBar.getInstance()).isVisible()) { looseFocus(); } } @@ -381,12 +390,10 @@ @Override public void changedUpdate(DocumentEvent e) { - searched = false; } @Override public void insertUpdate(DocumentEvent e) { - searched = false; // text changed - attempt incremental search if (incSearchTextField.getText().length() > 3) { searchDelayTimer.setInitialDelay(SEARCH_DELAY_TIME_SHORT); @@ -396,7 +403,6 @@ @Override public void removeUpdate(DocumentEvent e) { - searched = false; // text changed - attempt incremental search if (incSearchTextField.getText().length() <= 3) { searchDelayTimer.setInitialDelay(SEARCH_DELAY_TIME_LONG); @@ -405,7 +411,7 @@ } }; } - + private JButton createCloseButton() { JButton button = CloseButtonFactory.createBigCloseButton(); button.addActionListener(new ActionListener() { @@ -565,17 +571,21 @@ @Override public void actionPerformed(ActionEvent e) { - if (CLOSE_ON_ENTER && !searched) { - findNext(); - } - if (!popupMenuWasCanceled) - looseFocus(); - else + if (!popupMenuWasCanceled) { + looseFocus(); + if (isClosingSearchType()) + getActualTextComponent().scrollRectToVisible(actualViewPort); + } else popupMenuWasCanceled = false; } }); } + private static boolean isClosingSearchType() { + Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); + return prefs.get(SimpleValueNames.EDITOR_SEARCH_TYPE, "default").equals("closing"); // NOI18N + } + public void gainFocus() { incSearchTextField.getDocument().removeDocumentListener(incSearchTextFieldListener); SearchComboBoxEditor.changeToOneLineEditorPane((JEditorPane) incSearchTextField); @@ -605,15 +615,14 @@ findPreviousButton.setEnabled(false); findNextButton.setEnabled(false); } - searched = false; + actualViewPort = getActualTextComponent().getVisibleRect(); } - + public void looseFocus() { hadFocusOnIncSearchTextField = false; if (!isVisible()) { return; } - org.netbeans.api.editor.completion.Completion.get().hideAll(); EditorFindSupport.getInstance().setBlockSearchHighlight(0, 0); EditorFindSupport.getInstance().incSearchReset(); EditorFindSupport.getInstance().setFocusedTextComponent(null); @@ -643,6 +652,8 @@ // search starting at current caret position int caretPosition = getActualTextComponent().getSelectionStart(); + if (isClosingSearchType()) + caretPosition = getActualTextComponent().getCaretPosition(); if (regexpCheckBox.isSelected()) { Pattern pattern; String patternErrorMsg = null; @@ -667,7 +678,6 @@ // text found - reset incremental search text field's foreground incSearchTextField.setForeground(DEFAULT_FG_COLOR); //NOI18N org.netbeans.editor.Utilities.setStatusText(getActualTextComponent(), "", StatusDisplayer.IMPORTANCE_INCREMENTAL_FIND); - searched = true; } else { // text not found - indicate error in incremental search // text field with red foreground @@ -701,7 +711,6 @@ if (findSupport.find(actualfindProps, !next) || empty) { // text found - reset incremental search text field's foreground incSearchTextField.setForeground(DEFAULT_FG_COLOR); //NOI18N - searched = true; } else { // text not found - indicate error in incremental search text field with red foreground incSearchTextField.setForeground(NOT_FOUND); @@ -744,7 +753,17 @@ selText = selText.substring(0, n); } incSearchTextField.setText(selText); - } + } else { + if (isClosingSearchType()) { + String findWhat = (String) EditorFindSupport.getInstance().getFindProperty(EditorFindSupport.FIND_WHAT); + if (findWhat != null && findWhat.length() > 0) { + incSearchTextField.getDocument().removeDocumentListener(incSearchTextFieldListener); + incSearchTextField.setText(findWhat); + incSearchTextField.getDocument().addDocumentListener(incSearchTextFieldListener); + } + } + + } } int blockSearchStartOffset = blockSearchVisible ? startSelection : 0; @@ -854,13 +873,6 @@ return regexpCheckBox; } - boolean isSearched() { - return searched; - } - - void setSearched(boolean searched) { - this.searched = searched; - } JComponent getExpandButton() { return expandMenu.getExpandButton(); diff --git a/editor.settings/apichanges.xml b/editor.settings/apichanges.xml --- a/editor.settings/apichanges.xml +++ b/editor.settings/apichanges.xml @@ -107,6 +107,20 @@ + + + Adding SimpleValueNames.EDITOR_SEARCH_TYPE + + + + + +

+ Adding new constant SimpleValueNames.EDITOR_SEARCH_TYPE. +

+
+ +
Adding SimpleValueNames.ON_SAVE_REMOVE_TRAILING_WHITESPACE diff --git a/editor.settings/manifest.mf b/editor.settings/manifest.mf --- a/editor.settings/manifest.mf +++ b/editor.settings/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.editor.settings/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/settings/Bundle.properties -OpenIDE-Module-Specification-Version: 1.39 +OpenIDE-Module-Specification-Version: 1.40 OpenIDE-Module-Needs: org.netbeans.api.editor.settings.implementation diff --git a/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java b/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java --- a/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java +++ b/editor.settings/src/org/netbeans/api/editor/settings/SimpleValueNames.java @@ -437,6 +437,16 @@ */ public static final String ON_SAVE_REMOVE_TRAILING_WHITESPACE = "on-save-remove-trailing-whitespace"; //NOI18N + /** + * Determines editor search type. + * Values: java.lang.String instances + *
    + *
  • default + *
  • closing + *
+ */ + public static final String EDITOR_SEARCH_TYPE = "editor-search-type"; //NOI18N + @PatchedPublic private SimpleValueNames() { // to prevent instantialization diff --git a/options.editor/manifest.mf b/options.editor/manifest.mf --- a/options.editor/manifest.mf +++ b/options.editor/manifest.mf @@ -2,6 +2,6 @@ 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.29 +OpenIDE-Module-Specification-Version: 1.30 AutoUpdate-Show-In-Client: false diff --git a/options.editor/nbproject/project.xml b/options.editor/nbproject/project.xml --- a/options.editor/nbproject/project.xml +++ b/options.editor/nbproject/project.xml @@ -100,7 +100,7 @@ 1 - 1.33 + 1.40
@@ -372,7 +372,7 @@ org.netbeans.modules.versioning.util org.netbeans.modules.web.project org.netbeans.spi.java.hints - org.netbeans.modules.java.hints.ui + org.netbeans.modules.java.hints.ui org.netbeans.modules.options.colors org.netbeans.modules.options.colors.spi org.netbeans.modules.options.editor.spi diff --git a/options.editor/src/org/netbeans/modules/options/generaleditor/Bundle.properties b/options.editor/src/org/netbeans/modules/options/generaleditor/Bundle.properties --- a/options.editor/src/org/netbeans/modules/options/generaleditor/Bundle.properties +++ b/options.editor/src/org/netbeans/modules/options/generaleditor/Bundle.properties @@ -108,6 +108,15 @@ CTL_Remove_Trailing_Whitespace=Remove Trailing Whitespace AN_Remove_Trailing_Whitespace=Remove Trailing Whitespace AD_Remove_Trailing_Whitespace=Remove Trailing Whitespace +CTL_Search=Search +AN_Search=Search +AD_Search=Search +CTL_Editor_Search_Type=Editor Search Type +AN_Editor_Search_Type=Editor Search Type +AD_Editor_Search_Type=Editor Search Type +EST_closing=Closing +EST_default=Default +Editor_Search_Type_Tooltip= In Closing type Enter accepts search match, Esc jumps to start. Both close searchbar. Default type closes searchbar by Esc or button. Enter means find a new instance. RTW_never=Never RTW_always=Always RTW_modified-lines=From Modified Lines Only diff --git a/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.form b/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.form --- a/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.form +++ b/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.form @@ -1,4 +1,4 @@ - +
@@ -21,57 +21,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -87,6 +36,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -139,7 +148,17 @@ - + + + + + + + + + + + @@ -241,5 +260,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java b/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java --- a/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java +++ b/options.editor/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java @@ -91,10 +91,16 @@ loc (lWhenSavingFiles, "When_Saving_Files"); loc (lRemoveTrailingWhitespace, "Remove_Trailing_Whitespace"); loc (cboRemoveTrailingWhitespace, "Remove_Trailing_Whitespace"); + loc (lSearch, "Search"); + loc (lEditorSearchType, "Editor_Search_Type"); + loc (cboEditorSearchType, "Editor_Search_Type"); cbUseCodeFolding.setMnemonic(NbBundle.getMessage (GeneralEditorPanel.class, "MNEMONIC_Use_Folding").charAt(0)); - cboRemoveTrailingWhitespace.setRenderer(new RemoveTrailingWhitespaceRenderer(cboRemoveTrailingWhitespace.getRenderer())); - cboRemoveTrailingWhitespace.setModel(new DefaultComboBoxModel(new Object [] { "never", "always", "modified-lines" })); //NOI18N + cboRemoveTrailingWhitespace.setRenderer(new OptionComboboxRenderer(cboRemoveTrailingWhitespace.getRenderer())); //NOI18N + cboRemoveTrailingWhitespace.setModel(new DefaultComboBoxModel(new Object [] { "RTW_never", "RTW_always", "RTW_modified-lines" })); //NOI18N + cboEditorSearchType.setRenderer(new OptionComboboxRenderer(cboEditorSearchType.getRenderer())); //NOI18N + cboEditorSearchType.setModel(new DefaultComboBoxModel(new Object [] { "EST_default", "EST_closing"})); //NOI18N + cboEditorSearchType.setToolTipText(NbBundle.getMessage(GeneralEditorPanel.class, "Editor_Search_Type_Tooltip")); } /** This method is called from within the constructor to @@ -124,6 +130,10 @@ lWhenSavingFiles = new javax.swing.JLabel(); lRemoveTrailingWhitespace = new javax.swing.JLabel(); cboRemoveTrailingWhitespace = new javax.swing.JComboBox(); + lEditorSearchType = new javax.swing.JLabel(); + jSeparator5 = new javax.swing.JSeparator(); + lSearch = new javax.swing.JLabel(); + cboEditorSearchType = new javax.swing.JComboBox(); setForeground(new java.awt.Color(99, 130, 191)); @@ -159,52 +169,18 @@ cboRemoveTrailingWhitespace.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + lEditorSearchType.setLabelFor(cboRemoveTrailingWhitespace); + lEditorSearchType.setText("Editor Search Type:"); + + lSearch.setText("Search"); + + cboEditorSearchType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lUseCodeFolding) - .addComponent(lCollapseByDefault) - .addComponent(lRemoveTrailingWhitespace)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lCamelCaseBehaviorExample) - .addComponent(cboRemoveTrailingWhitespace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbCamelCaseBehavior) - .addContainerGap(500, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbFoldImports) - .addContainerGap(580, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbFoldInnerClasses) - .addContainerGap(580, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbFoldMethods) - .addGap(18, 18, 18) - .addComponent(cbFoldTags) - .addContainerGap(333, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbUseCodeFolding) - .addContainerGap(720, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbFoldJavadocComments) - .addContainerGap(580, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGap(155, 155, 155) - .addComponent(cbFoldInitialComments) - .addContainerGap(580, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() .addComponent(lWhenSavingFiles) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 755, Short.MAX_VALUE)) @@ -216,6 +192,52 @@ .addComponent(lCodeFolding) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 792, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lUseCodeFolding) + .addComponent(lCollapseByDefault) + .addComponent(lRemoveTrailingWhitespace)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lCamelCaseBehaviorExample) + .addComponent(cboRemoveTrailingWhitespace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbCamelCaseBehavior)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbFoldImports)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbFoldInnerClasses)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbFoldMethods) + .addGap(18, 18, 18) + .addComponent(cbFoldTags)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbUseCodeFolding)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbFoldJavadocComments)) + .addGroup(layout.createSequentialGroup() + .addGap(155, 155, 155) + .addComponent(cbFoldInitialComments)) + .addGroup(layout.createSequentialGroup() + .addComponent(lSearch) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jSeparator5, javax.swing.GroupLayout.DEFAULT_SIZE, 813, Short.MAX_VALUE))) + .addContainerGap(24, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(lEditorSearchType) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cboEditorSearchType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cbFoldImports, cbFoldInitialComments, cbFoldInnerClasses, cbFoldJavadocComments, cbFoldMethods}); @@ -262,7 +284,15 @@ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lRemoveTrailingWhitespace) .addComponent(cboRemoveTrailingWhitespace, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(67, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(lSearch) + .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lEditorSearchType) + .addComponent(cboEditorSearchType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(59, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -276,15 +306,19 @@ private javax.swing.JCheckBox cbFoldMethods; private javax.swing.JCheckBox cbFoldTags; private javax.swing.JCheckBox cbUseCodeFolding; + private javax.swing.JComboBox cboEditorSearchType; private javax.swing.JComboBox cboRemoveTrailingWhitespace; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator3; private javax.swing.JSeparator jSeparator4; + private javax.swing.JSeparator jSeparator5; private javax.swing.JLabel lCamelCaseBehavior; private javax.swing.JLabel lCamelCaseBehaviorExample; private javax.swing.JLabel lCodeFolding; private javax.swing.JLabel lCollapseByDefault; + private javax.swing.JLabel lEditorSearchType; private javax.swing.JLabel lRemoveTrailingWhitespace; + private javax.swing.JLabel lSearch; private javax.swing.JLabel lUseCodeFolding; private javax.swing.JLabel lWhenSavingFiles; // End of variables declaration//GEN-END:variables @@ -327,6 +361,7 @@ cbCamelCaseBehavior.addActionListener (this); cbFoldTags.addActionListener (this); cboRemoveTrailingWhitespace.addActionListener(this); + cboEditorSearchType.addActionListener(this); } // init code folding @@ -351,6 +386,8 @@ // when saving files section cboRemoveTrailingWhitespace.setSelectedItem(model.getRemoveTrailingWhitespace()); + + cboEditorSearchType.setSelectedItem(model.getEditorSearchType()); updateEnabledState (); @@ -377,6 +414,8 @@ // when saving files section model.setRemoveTrailingWhitespace((String)cboRemoveTrailingWhitespace.getSelectedItem()); + + model.setEditorSearchType((String)cboEditorSearchType.getSelectedItem()); changed = false; } @@ -415,11 +454,11 @@ cbFoldTags.setEnabled(useCodeFolding); } - private static final class RemoveTrailingWhitespaceRenderer implements ListCellRenderer { + private static final class OptionComboboxRenderer implements ListCellRenderer { private final ListCellRenderer defaultRenderer; - public RemoveTrailingWhitespaceRenderer(ListCellRenderer defaultRenderer) { + public OptionComboboxRenderer(ListCellRenderer defaultRenderer) { this.defaultRenderer = defaultRenderer; } @@ -427,11 +466,10 @@ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return defaultRenderer.getListCellRendererComponent( list, - NbBundle.getMessage(GeneralEditorPanel.class, "RTW_" + value), //NOI18N + NbBundle.getMessage(GeneralEditorPanel.class, (String) value), index, isSelected, cellHasFocus); } - - } // End of RemoveTrailingWhitespaceRendererRenderer class + } } diff --git a/options.editor/src/org/netbeans/modules/options/generaleditor/Model.java b/options.editor/src/org/netbeans/modules/options/generaleditor/Model.java --- a/options.editor/src/org/netbeans/modules/options/generaleditor/Model.java +++ b/options.editor/src/org/netbeans/modules/options/generaleditor/Model.java @@ -133,6 +133,16 @@ Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); prefs.put(SimpleValueNames.ON_SAVE_REMOVE_TRAILING_WHITESPACE, value); } + + String getEditorSearchType() { + Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); + return prefs.get(SimpleValueNames.EDITOR_SEARCH_TYPE, "default"); + } + + void setEditorSearchType(String value) { + Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class); + prefs.put(SimpleValueNames.EDITOR_SEARCH_TYPE, value); + } // private helper methods ..................................................