diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/Bundle.properties b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/Bundle.properties index 1e1d530d0777..6b315aafe2fd 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/Bundle.properties +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/Bundle.properties @@ -48,6 +48,7 @@ FoldOptionsPanel.foldedSummary.text=Show summary FoldOptionsPanel.enableFolds.text=Enable Code Folding FoldOptionsPanel.contentPreview.text=Content preview FoldOptionsPanel.langLabel.text=Language: +FoldOptionsPanel.showTooltip.text=Show tooltip # Highlighting options: color names code-folding-bar=Code Folding Bar diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/DefaultFoldingOptions.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/DefaultFoldingOptions.java index d1221a1060f4..6657f54d9276 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/DefaultFoldingOptions.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/DefaultFoldingOptions.java @@ -293,7 +293,8 @@ private void fireChanged(String pk) { boolean changed = preferences.getBoolean(SimpleValueNames.CODE_FOLDING_ENABLE, true) != prefs.getBoolean(SimpleValueNames.CODE_FOLDING_ENABLE, true) || preferences.getBoolean(FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS, true) != prefs.getBoolean(FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS, true) || preferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true) != prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true) - || preferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true) != prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true); + || preferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true) != prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true) + || preferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true) != prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true); for (JCheckBox cb : controls) { changed |= isFoldTypeChanged((FoldType) cb.getClientProperty("type"), prefs); // NOI18N } diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.form b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.form index 86069cb7488d..b9aaf2f1a1f3 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.form +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.form @@ -72,10 +72,10 @@ - + - + @@ -128,6 +128,7 @@ + @@ -141,6 +142,8 @@ + + @@ -160,6 +163,13 @@ + + + + + + + diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java index 0487324dfbcf..3d73a6ddd93a 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldOptionsPanel.java @@ -87,6 +87,7 @@ public Component getListCellRendererComponent(JList list, Object value, int inde langSelect.addActionListener(this); contentPreview.addActionListener(this); foldedSummary.addActionListener(this); + showTooltip.addActionListener(this); // preferences should be set as a reaction to index selection } @@ -142,6 +143,10 @@ private void summaryChanged() { currentPreferences.putBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, foldedSummary.isSelected()); } + private void tooltipChanged() { + currentPreferences.putBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, showTooltip.isSelected()); + } + @Override public void actionPerformed(ActionEvent e) { Object o = e.getSource(); @@ -154,6 +159,8 @@ public void actionPerformed(ActionEvent e) { previewChanged(); } else if (o == foldedSummary) { summaryChanged(); + } else if (o == showTooltip) { + tooltipChanged(); } } @@ -170,6 +177,7 @@ public void preferenceChange(PreferenceChangeEvent evt) { enableFolds.setSelected(enabled); contentPreview.setEnabled(enabled); foldedSummary.setEnabled(enabled); + showTooltip.setEnabled(enabled); useDefaults.setEnabled(enabled); } if (k == null || k.equals(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW)) { @@ -177,6 +185,9 @@ public void preferenceChange(PreferenceChangeEvent evt) { } if (k == null || k.equals(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY)) { foldedSummary.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true)); + } + if (k == null || k.equals(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP)) { + showTooltip.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true)); } // must not replicate defaults over current settings if unspecified key arrives. if (FoldUtilitiesImpl.PREF_OVERRIDE_DEFAULTS.equals(k)) { @@ -187,15 +198,20 @@ public void preferenceChange(PreferenceChangeEvent evt) { parentPrefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true)); currentPreferences.putBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, parentPrefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true)); + currentPreferences.putBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, + parentPrefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true)); } else { currentPreferences.remove(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW); currentPreferences.remove(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY); + currentPreferences.remove(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP); } } contentPreview.setEnabled(b); foldedSummary.setEnabled(b); + showTooltip.setEnabled(b); contentPreview.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true)); foldedSummary.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true)); + showTooltip.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true)); } } finally { ignoreEnableTrigger = false; @@ -297,6 +313,7 @@ private void initComponents() { jPanel1 = new javax.swing.JPanel(); contentPreview = new javax.swing.JCheckBox(); foldedSummary = new javax.swing.JCheckBox(); + showTooltip = new javax.swing.JCheckBox(); useDefaults = new javax.swing.JCheckBox(); org.openide.awt.Mnemonics.setLocalizedText(langLabel, org.openide.util.NbBundle.getMessage(FoldOptionsPanel.class, "FoldOptionsPanel.langLabel.text")); // NOI18N @@ -316,6 +333,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { org.openide.awt.Mnemonics.setLocalizedText(foldedSummary, org.openide.util.NbBundle.getMessage(FoldOptionsPanel.class, "FoldOptionsPanel.foldedSummary.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(showTooltip, org.openide.util.NbBundle.getMessage(FoldOptionsPanel.class, "FoldOptionsPanel.showTooltip.text")); // NOI18N + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( @@ -324,7 +343,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(contentPreview) - .addComponent(foldedSummary)) + .addComponent(foldedSummary) + .addComponent(showTooltip)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( @@ -334,7 +354,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(contentPreview) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(foldedSummary) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(showTooltip) + .addContainerGap()) ); org.openide.awt.Mnemonics.setLocalizedText(useDefaults, org.openide.util.NbBundle.getMessage(FoldOptionsPanel.class, "FoldOptionsPanel.useDefaults.text")); // NOI18N @@ -376,7 +398,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(useDefaults) .addGap(12, 12, 12) - .addComponent(content, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE) + .addComponent(content, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) @@ -408,6 +430,7 @@ private void useDefaultsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F private javax.swing.JPanel jPanel1; private javax.swing.JLabel langLabel; private javax.swing.JComboBox langSelect; + private javax.swing.JCheckBox showTooltip; private javax.swing.JCheckBox useDefaults; // End of variables declaration//GEN-END:variables } diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldUtilitiesImpl.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldUtilitiesImpl.java index 4a8679b485d0..f638694bc85e 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldUtilitiesImpl.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldUtilitiesImpl.java @@ -49,4 +49,9 @@ public class FoldUtilitiesImpl { */ public static final String PREF_CONTENT_SUMMARY = "code-folding-content.summary"; // NOI18N + /** + * Preference key for "Show tooltip" display option (default: true). + */ + public static final String PREF_CONTENT_TOOLTIP = "code-folding-content.tooltip"; // NOI18N + } diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldView.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldView.java index be58eb8355de..10f9ca512488 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldView.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldView.java @@ -104,6 +104,8 @@ final class FoldView extends EditorView { private AttributeSet selectedColors; private int options; + + private boolean showTooltip; /** * Coloring that will be used for code folding icons displayed in editor @@ -116,7 +118,13 @@ final class FoldView extends EditorView { public static final String COLORING_PLACEHOLDER_BORDER = "code-folding-border"; // NOI18N - public FoldView(JTextComponent textComponent, Fold fold, FontColorSettings colorSettings, int options) { + public FoldView( + JTextComponent textComponent, + Fold fold, + FontColorSettings colorSettings, + int options, + boolean showTooltip + ) { super(null); int offset = fold.getStartOffset(); int len = fold.getEndOffset() - offset; @@ -128,6 +136,7 @@ public FoldView(JTextComponent textComponent, Fold fold, FontColorSettings color this.selectedColors = colorSettings.getFontColors(FontColorNames.SELECTION_COLORING); this.foldingBorderColors = colorSettings.getFontColors(COLORING_PLACEHOLDER_BORDER); this.options = options; + this.showTooltip = showTooltip; } @Override @@ -320,6 +329,10 @@ public int getNextVisualPositionFromChecked(int offset, Bias bias, Shape alloc, @Override public JComponent getToolTip(double x, double y, Shape allocation) { + if (!showTooltip) { + return null; + } + Container container = getContainer(); if (container instanceof JEditorPane) { JEditorPane editorPane = (JEditorPane) getContainer(); diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java index 9dbdefcf70aa..27aca8dff0b1 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldViewFactory.java @@ -110,6 +110,8 @@ public static void register() { private int viewFlags = 0; + private boolean showTooltip = true; + private final FoldHierarchyListener weakL; public FoldViewFactory(View documentView) { @@ -139,13 +141,15 @@ public FoldViewFactory(View documentView) { prefs = lkp.lookup(Preferences.class); prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs)); - initViewFlags(); + initFlags(); } - private void initViewFlags() { + private void initFlags() { viewFlags = (prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true) ? 1 : 0) | (prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_SUMMARY, true) ? 2 : 0); + + showTooltip = prefs.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP, true); } @Override @@ -157,8 +161,9 @@ public void resultChanged(LookupEvent ev) { public void preferenceChange(PreferenceChangeEvent evt) { String k = evt.getKey(); if (FoldUtilitiesImpl.PREF_CONTENT_PREVIEW.equals(k) || - FoldUtilitiesImpl.PREF_CONTENT_SUMMARY.equals(k)) { - initViewFlags(); + FoldUtilitiesImpl.PREF_CONTENT_SUMMARY.equals(k) || + FoldUtilitiesImpl.PREF_CONTENT_TOOLTIP.equals(k)) { + initFlags(); final Document d = document(); if (d != null) { d.render(new Runnable() { @@ -229,7 +234,7 @@ public EditorView createView(int startOffset, int limitOffset, boolean forcedLim EditorView origView, int nextOrigViewOffset) { assert (startOffset == foldStartOffset) : "startOffset=" + startOffset + " != foldStartOffset=" + foldStartOffset; // NOI18N if (fold.getEndOffset() <= limitOffset || !forcedLimit) { - return new FoldView(textComponent(), fold, colorSettings, viewFlags); + return new FoldView(textComponent(), fold, colorSettings, viewFlags, showTooltip); } else { return null; } diff --git a/ide/editor.fold/src/org/netbeans/modules/editor/fold/FoldUtilitiesImpl.java b/ide/editor.fold/src/org/netbeans/modules/editor/fold/FoldUtilitiesImpl.java index 055d58358eac..03d6cc14b67e 100644 --- a/ide/editor.fold/src/org/netbeans/modules/editor/fold/FoldUtilitiesImpl.java +++ b/ide/editor.fold/src/org/netbeans/modules/editor/fold/FoldUtilitiesImpl.java @@ -68,6 +68,11 @@ public final class FoldUtilitiesImpl { */ public static final String PREF_CONTENT_SUMMARY = "code-folding-content.summary"; // NOI18N + /** + * Preference key for "Show tooltip" display option (default: true). + */ + public static final String PREF_CONTENT_TOOLTIP = "code-folding-content.tooltip"; // NOI18N + private FoldUtilitiesImpl() { // No instances }