Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="useDefaults" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Component id="content" pref="25" max="32767" attributes="0"/>
<Component id="content" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -128,6 +128,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="contentPreview" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="foldedSummary" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="showTooltip" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
Expand All @@ -141,6 +142,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="foldedSummary" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="showTooltip" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand All @@ -160,6 +163,13 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="showTooltip">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/editor/fold/ui/Bundle.properties" key="FoldOptionsPanel.showTooltip.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="useDefaults">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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();
Expand All @@ -154,6 +159,8 @@ public void actionPerformed(ActionEvent e) {
previewChanged();
} else if (o == foldedSummary) {
summaryChanged();
} else if (o == showTooltip) {
tooltipChanged();
}
}

Expand All @@ -170,13 +177,17 @@ 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)) {
contentPreview.setSelected(currentPreferences.getBoolean(FoldUtilitiesImpl.PREF_CONTENT_PREVIEW, true));
}
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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public static void register() {

private int viewFlags = 0;

private boolean showTooltip = true;

private final FoldHierarchyListener weakL;

public FoldViewFactory(View documentView) {
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading