# HG changeset patch # Parent ba3800151f9cb604bd27de2216ee31b91a46362b diff --git a/editor.lib/src/org/netbeans/editor/PopupManager.java b/editor.lib/src/org/netbeans/editor/PopupManager.java --- a/editor.lib/src/org/netbeans/editor/PopupManager.java +++ b/editor.lib/src/org/netbeans/editor/PopupManager.java @@ -101,6 +101,11 @@ then popup will be placed above cursor. */ public static final Placement BelowPreferred = new Placement("BelowPreferred"); //NOI18N + /** + * Place the popup on a fixed point of the view, measured from top-left corner + */ + public static final Placement FixedPoint = new Placement("TopLeft"); + /** Place popup inside the scrollbar's viewport */ public static final HorizontalBounds ViewPortBounds = new HorizontalBounds("ViewPort"); //NOI18N @@ -197,7 +202,7 @@ if (bounds != null){ // Convert to layered pane's coordinates - if (horizontalBounds == ScrollBarBounds){ + if (horizontalBounds == ScrollBarBounds && placement != FixedPoint){ bounds.x = 0; } @@ -288,7 +293,9 @@ Rectangle viewBounds = ((JViewport)viewParent).getViewRect(); Rectangle translatedCursorBounds = (Rectangle)cursorBounds.clone(); - translatedCursorBounds.translate(-viewBounds.x, -viewBounds.y); + if (placement != FixedPoint) { + translatedCursorBounds.translate(-viewBounds.x, -viewBounds.y); + } ret = computeBounds(popup, viewBounds.width, viewBounds.height, translatedCursorBounds, placement, horizontalBounds); @@ -416,12 +423,17 @@ } if (popupBounds != null) { - //place popup according to caret position and Placement - popupBounds.x = Math.min(cursorBounds.x, viewWidth - popupBounds.width); + if (placement == FixedPoint) { + popupBounds.x = cursorBounds.x; + popupBounds.y = cursorBounds.y; + } else { + //place popup according to caret position and Placement + popupBounds.x = Math.min(cursorBounds.x, viewWidth - popupBounds.width); - popupBounds.y = (placement == Above || placement == AbovePreferred) - ? (aboveCursorHeight - popupBounds.height) - : belowCursorY; + popupBounds.y = (placement == Above || placement == AbovePreferred) + ? (aboveCursorHeight - popupBounds.height) + : belowCursorY; + } } return popupBounds; diff --git a/editor.lib/src/org/netbeans/editor/SideBarFactory.java b/editor.lib/src/org/netbeans/editor/SideBarFactory.java --- a/editor.lib/src/org/netbeans/editor/SideBarFactory.java +++ b/editor.lib/src/org/netbeans/editor/SideBarFactory.java @@ -46,6 +46,7 @@ import javax.swing.JComponent; import javax.swing.text.JTextComponent; +import org.netbeans.spi.editor.mimelookup.MimeLocation; /** * This interface should implement all components that need to be added @@ -53,6 +54,7 @@ * * @author Martin Roskanin */ +@MimeLocation(subfolderName="SideBar") public interface SideBarFactory { public JComponent createSideBar(JTextComponent target); diff --git a/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java b/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java --- a/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java +++ b/editor.lib/src/org/netbeans/editor/ext/ToolTipSupport.java @@ -284,6 +284,33 @@ } /** + * Sets the tooltip. The tooltip will be positioned at the given coordinates relative to either the scroller + * (with {@link PopupManager#ScrollBarBounds} or the viewport {@link PopupManager#ViewPortBounds}. Position + * of caret in the editor is completely ignored. + * + * @param toolTip the tooltip component + * @param horizontalBounds positioning relative to the viewport or scrollbar (scroller) + * @param placeAt x,y coordinates to place the tooltip + * @param horizontalAdjustment horizontal inset between tooltip component and the tooltip floater + * @param verticalAdjustment vertical inset between tooltip component and the tooltip floater + * @param flags various flags, see FLAG_* constants in this class. + * + * @since 3.26 + */ + public void setToolTip( + JComponent toolTip, + PopupManager.HorizontalBounds horizontalBounds, + Point placeAt, + int horizontalAdjustment, + int verticalAdjustment, + int flags + ) { + setToolTip(toolTip, horizontalBounds, PopupManager.FixedPoint, + placeAt, horizontalAdjustment, verticalAdjustment, + flags); + } + + /** * @Since 2.10 */ public void setToolTip( @@ -294,6 +321,20 @@ int verticalAdjustment, int flags ) { + setToolTip(toolTip, horizontalBounds, placement, + null, horizontalAdjustment, verticalAdjustment, + flags); + } + + private void setToolTip( + JComponent toolTip, + PopupManager.HorizontalBounds horizontalBounds, + PopupManager.Placement placement, + Point placeAt, + int horizontalAdjustment, + int verticalAdjustment, + int flags + ) { JComponent oldToolTip = this.toolTip; if (LOG.isLoggable(Level.FINE)) { @@ -315,11 +356,16 @@ } if (status >= STATUS_VISIBILITY_ENABLED) { - if (oldToolTip == this.toolTip && this.toolTip.getClientProperty(LAST_TOOLTIP_POSITION) != null) { - ensureVisibility((Point) this.toolTip.getClientProperty(LAST_TOOLTIP_POSITION)); + Point pt; + + if (placeAt != null) { + pt = placeAt; + } else if (oldToolTip == this.toolTip && this.toolTip.getClientProperty(LAST_TOOLTIP_POSITION) != null) { + pt = (Point)this.toolTip.getClientProperty(LAST_TOOLTIP_POSITION); } else { - ensureVisibility(getLastMouseEventPoint()); + pt = getLastMouseEventPoint(); } + ensureVisibility(pt); } firePropertyChange(PROP_TOOL_TIP, oldToolTip, this.toolTip); @@ -691,7 +737,7 @@ int pos = component.viewToModel(toolTipPosition); Rectangle cursorBounds = null; - if (pos >= 0) { + if (placement != PopupManager.FixedPoint && pos >= 0) { try { cursorBounds = component.modelToView(pos); extendBounds(cursorBounds); 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 @@ -446,6 +446,18 @@ * */ public static final String EDITOR_SEARCH_TYPE = "editor-search-type"; //NOI18N + + /** + * Show brace matching outline in the sidebar of the editor. + * Values: Boolean instances. + */ + public static final String BRACE_SHOW_OUTLINE = "editor-brace-outline"; // NOI18N + + /** + * Show tooltips if the brace start line is hidden (outside the screen). + * Values: Boolean instances. + */ + public static final String BRACE_FIRST_TOOLTIP = "editor-brace-first-tooltip"; // NOI18N @PatchedPublic private SimpleValueNames() { diff --git a/editor/src/org/netbeans/modules/editor/NbEditorUI.java b/editor/src/org/netbeans/modules/editor/NbEditorUI.java --- a/editor/src/org/netbeans/modules/editor/NbEditorUI.java +++ b/editor/src/org/netbeans/modules/editor/NbEditorUI.java @@ -230,7 +230,15 @@ //border! - Tim scroller.setBorder(empty); scroller.setViewportBorder(empty); - + + if (component.getClientProperty("nbeditorui.vScrollPolicy") != null) { + scroller.setVerticalScrollBarPolicy( + (Integer)component.getClientProperty("nbeditorui.vScrollPolicy")); + } + if (component.getClientProperty("nbeditorui.hScrollPolicy") != null) { + scroller.setHorizontalScrollBarPolicy( + (Integer)component.getClientProperty("nbeditorui.hScrollPolicy")); + } // extComponent will be a panel JComponent ec = new JPanel(new BorderLayout()); ec.putClientProperty(JTextComponent.class, component);