Class FilteringOutlinePopup
- java.lang.Object
-
- org.eclipse.jface.window.Window
-
- org.eclipse.jface.dialogs.PopupDialog
-
- org.eclipse.handly.ui.quickoutline.OutlinePopup
-
- org.eclipse.handly.ui.quickoutline.FilteringOutlinePopup
-
- All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider
- Direct Known Subclasses:
HandlyOutlinePopup
public abstract class FilteringOutlinePopup extends OutlinePopup
An abstract implementation of an outline popup that supports filtering based on a pattern inputed by the user.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classFilteringOutlinePopup.ElementMatcherA pattern-based element matcher for the outline popup.protected classFilteringOutlinePopup.FilteringOutlineTreeViewerExtendsOutlinePopup.OutlineTreeViewerto allow expanding any tree item when the pattern-based filter is active.protected static classFilteringOutlinePopup.StringMatcherA string pattern matcher that supports '*' and '?' wildcards.-
Nested classes/interfaces inherited from class org.eclipse.handly.ui.quickoutline.OutlinePopup
OutlinePopup.OutlineTreeViewer
-
-
Constructor Summary
Constructors Constructor Description FilteringOutlinePopup()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.swt.widgets.TextcreateFilterText(org.eclipse.swt.widgets.Composite parent)Creates the text control to be used for entering the filter pattern.protected java.util.function.Predicate<java.lang.Object>createPatternMatcher(java.lang.String pattern)Returns a new pattern matcher based on the given pattern.protected org.eclipse.swt.widgets.ControlcreateTitleControl(org.eclipse.swt.widgets.Composite parent)protected org.eclipse.swt.widgets.ControlcreateTitleMenuArea(org.eclipse.swt.widgets.Composite parent)protected org.eclipse.jface.viewers.TreeViewercreateTreeViewer(org.eclipse.swt.widgets.Composite parent)Creates a tree viewer for this outline popup.protected org.eclipse.swt.widgets.TextgetFilterText()Returns the filter text control of this outline popup.protected java.lang.ObjectgetFocalElement()Returns the current focal element for this outline popup.protected org.eclipse.swt.widgets.ControlgetFocusControl()protected java.util.function.Predicate<java.lang.Object>getPatternMatcher()Returns the current pattern matcher for this outline popup.voidinit(IOutlinePopupHost host, org.eclipse.jface.bindings.keys.KeyStroke invokingKeyStroke)Initializes this outline popup with the given host and, optionally, invoking keystroke.protected voidpatternMatcherUpdated()Notifies that the pattern matcher has been updated.protected voidselectFirstMatch()Selects the first element that matches the current filter pattern.protected voidsetTabOrder(org.eclipse.swt.widgets.Composite composite)protected voidupdatePatternMatcher(java.lang.String pattern)-
Methods inherited from class org.eclipse.handly.ui.quickoutline.OutlinePopup
changeOutlineMode, computeInitialSelection, computeInput, createDialogArea, getContentProvider, getCorrespondingElement, getDefaultLocation, getDialogSettings, getHost, getInitialSelection, getInvokingKeyListener, getInvokingKeyStroke, getLabelProvider, getSelectedElement, getTreeViewer, gotoSelectedElement, initDecorationContext, isAutoExpandable, revealInHost, shouldUseHashlookup, updateInfoText
-
Methods inherited from class org.eclipse.jface.dialogs.PopupDialog
adjustBounds, applyBackgroundColor, applyForegroundColor, close, configureShell, createContents, createInfoTextArea, fillDialogMenu, getBackground, getBackgroundColorExclusions, getDefaultSize, getForeground, getForegroundColorExclusions, getInitialLocation, getInitialSize, getPersistBounds, getPersistLocation, getPersistSize, hasInfoArea, hasTitleArea, open, saveDialogBounds, setInfoText, setTitleText, showDialogMenu
-
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, create, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
-
-
-
-
Method Detail
-
init
public void init(IOutlinePopupHost host, org.eclipse.jface.bindings.keys.KeyStroke invokingKeyStroke)
Initializes this outline popup with the given host and, optionally, invoking keystroke. This method must be called by clients before attempting toopenthe outline popup.This method may be extended by subclasses. Subclasses must call the superclass implementation.
OutlinePopupimplementation of this method sets the parent shell to the shell of the SWT control of the given host, creates all controls of the outline popup, including thetree viewer, initializes the tree viewer with thecontent- andlabelproviders as well as theinput, and sets theinitial selectionin the tree viewer and thetextin the popup's info area.FilteringOutlinePopupextends this method to add apattern matcherbased filter to the outline popup's tree viewer.- Overrides:
initin classOutlinePopup- Parameters:
host- the host of this outline popup (notnull)invokingKeyStroke- the keystroke for invoking this outline popup, ornullif none
-
getFilterText
protected final org.eclipse.swt.widgets.Text getFilterText()
Returns the filter text control of this outline popup.- Returns:
- the filter text control of this outline popup,
or
nullif it has not been created yet
-
getPatternMatcher
protected final java.util.function.Predicate<java.lang.Object> getPatternMatcher()
Returns the current pattern matcher for this outline popup.- Returns:
- the current pattern matcher for this outline popup,
or
nullif none - See Also:
updatePatternMatcher(String)
-
getFocusControl
protected org.eclipse.swt.widgets.Control getFocusControl()
- Overrides:
getFocusControlin classOutlinePopup
-
setTabOrder
protected void setTabOrder(org.eclipse.swt.widgets.Composite composite)
- Overrides:
setTabOrderin classOutlinePopup
-
createTreeViewer
protected org.eclipse.jface.viewers.TreeViewer createTreeViewer(org.eclipse.swt.widgets.Composite parent)
Creates a tree viewer for this outline popup. The viewer has no input, no content provider, a default label provider, no sorter, and no filters. This method is called once, when the popup's control is created.This implementation returns a new instance of
FilteringOutlinePopup.FilteringOutlineTreeViewer.- Overrides:
createTreeViewerin classOutlinePopup- Parameters:
parent- the parent composite (nevernull)- Returns:
- the created tree viewer (not
null)
-
createTitleMenuArea
protected org.eclipse.swt.widgets.Control createTitleMenuArea(org.eclipse.swt.widgets.Composite parent)
- Overrides:
createTitleMenuAreain classorg.eclipse.jface.dialogs.PopupDialog
-
createTitleControl
protected org.eclipse.swt.widgets.Control createTitleControl(org.eclipse.swt.widgets.Composite parent)
This implementation creates the
filter textcontrol. It usescreateFilterText(Composite)to create the control.- Overrides:
createTitleControlin classorg.eclipse.jface.dialogs.PopupDialog
-
createFilterText
protected org.eclipse.swt.widgets.Text createFilterText(org.eclipse.swt.widgets.Composite parent)
Creates the text control to be used for entering the filter pattern.This implementation creates a text control that:
- Invokes
updatePatternMatcher(String)when the text is modified. - Invokes
OutlinePopup.gotoSelectedElement()when the ENTER key is pressed. - Sets the keyboard focus to the tree viewer when the DOWN ARROW or UP ARROW key is pressed.
- Invokes
PopupDialog.close()when the ESC key is pressed.
If an
invoking keyis set, this implementation adds theinvoking key listenerto the created control.- Parameters:
parent- the parent composite (nevernull)- Returns:
- the created filter text control (not
null)
- Invokes
-
updatePatternMatcher
protected final void updatePatternMatcher(java.lang.String pattern)
Updates the current pattern matcher to an instancecreatedfor the given pattern andnotifiesof the update.- Parameters:
pattern- the pattern string (notnull)- See Also:
getPatternMatcher()
-
createPatternMatcher
protected java.util.function.Predicate<java.lang.Object> createPatternMatcher(java.lang.String pattern)
Returns a new pattern matcher based on the given pattern. May returnnullif no filtering is required.This implementation returns
nullif the pattern is an empty string. Otherwise, it appends '*' to the pattern if the pattern does not already end with '*', and returns anFilteringOutlinePopup.ElementMatcherbased on aFilteringOutlinePopup.StringMatcherfor the pattern. Case-insensitive matching is enabled if, and only if, the pattern is all lower-case.- Parameters:
pattern- the pattern string (notnull)- Returns:
- the created pattern matcher, or
nullif no filtering is required
-
patternMatcherUpdated
protected void patternMatcherUpdated()
Notifies that the pattern matcher has been updated.This implementation refreshes the tree viewer, expands all nodes of the tree, and
selectsthe first matching element.
-
selectFirstMatch
protected void selectFirstMatch()
Selects the first element that matches the current filter pattern.This implementation starts the search from the
focal element. If there is no focal element, the search is started from the root of the tree.
-
getFocalElement
protected java.lang.Object getFocalElement()
Returns the current focal element for this outline popup.This implementation returns the
initially selectedelement. Subclasses may override.- Returns:
- the current focal element for this outline popup,
or
nullif none
-
-