Class SJList<E>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.grid.Grid<Integer>
com.vaadin.swingbridge.surrogates.SJList<E>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.grid.Grid<Integer>>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<com.vaadin.flow.component.grid.Grid<Integer>>, com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.grid.Grid<Integer>>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.data.event.SortEvent.SortNotifier<com.vaadin.flow.component.grid.Grid<Integer>, com.vaadin.flow.component.grid.GridSortOrder<Integer>>, com.vaadin.flow.data.provider.HasDataGenerators<Integer>, com.vaadin.flow.data.provider.HasDataView<Integer, Void, com.vaadin.flow.component.grid.dataview.GridDataView<Integer>>, com.vaadin.flow.data.provider.HasLazyDataView<Integer, Void, com.vaadin.flow.component.grid.dataview.GridLazyDataView<Integer>>, com.vaadin.flow.data.provider.HasListDataView<Integer, com.vaadin.flow.component.grid.dataview.GridListDataView<Integer>>, ComponentMixin, ContainerMixin, JComponentMixin, Serializable, EventListener, ListDataListener, ListSelectionListener
public class SJList<E>
extends com.vaadin.flow.component.grid.Grid<Integer>
implements JComponentMixin, ListSelectionListener, ListDataListener
Surrogate for
JList (SD_sjlist). Extends Vaadin
Grid<Integer> — exactly SJTable's row-index identity,
narrowed to a single headerless column. Row indices are the Grid's
items, the installed ListModel is the single source of truth
(R_swing_is_truth), and the ListSelectionModel (also index-based) bridges
directly onto Vaadin Grid's Integer-keyed selection.
Why Grid, not VirtualList / ListBox
Grid is the only Vaadin list-shaped component whose native selection covers all three JDK modes through one call (Grid.setSelectionMode(Grid.SelectionMode)
— NONE/SINGLE/MULTI); VirtualList carries no selection
at all, and ListBox/MultiSelectListBox are two separate
classes (one per mode) a surrogate can't swap between at runtime. Picking
Grid also reuses SJTable's proven ListSelectionModel↔Grid
selection bridge verbatim and rides the existing SJScrollPane auto-scroll
guard (which already detects Grid content) for the universal
new JScrollPane(jlist) idiom. The cost — a checkbox column in
multi-select mode — is accepted per R_best_effort_behaviour/R_layouts_close_enough (see SD_sjlist). Duplicate
.equals() elements (which JList permits) are why the items stay
Integer indices, not E: Vaadin Grid keys items by
identity and would collide on equal values.
Vaadin-first rendering (R_vaadin_first)
Surrogate-layer code installs a VaadinRenderer<Integer>
via setRenderer(Renderer); the per-cell renderer reads through
to model.getElementAt(index) live. The JDK ListCellRenderer
surface (return type java.awt.Component clashes with our
hierarchy per D_event_port_policy) lives only on the emulator layer (:emulators.JList),
which bridges it into a Vaadin ComponentRenderer at the boundary
(D_jcombobox). Pure-surrogate users without setRenderer(Renderer) get a default
value.toString() Span renderer — fresh-per-call to dodge
Vaadin's DOM-adoption diff (D_jcombobox's lesson).
Double-click bridge (locationToIndex)
addMouseListener(SMouseListener) overrides the inherited mixin
wire (Grid dispatches item clicks, not component clicks, and
the item-click carries the row index). It subscribes
addItemClickListener and fires SMouseEvent.MOUSE_CLICKED
carrying the browser's click count — so a double-click arrives as
clickCount == 2, the canonical "double-click to open" idiom.
The clicked index is stashed in ListStateStore.clickIndexStash
around the fan-out so locationToIndex(Point) resolves correctly
during the user's mouseClicked handler (R_layouts_close_enough — no server-side
pixel→index map otherwise). Native Vaadin ItemClickListeners a
stage-3 user adds coexist untouched.
R_vaadin_first drop-and-WARN surface
layoutOrientation wrap modes (no Vaadin newspaper-flow list),
prototypeCellValue (sizing optimisation), dragEnabled
(cross-cutting DnD). visibleRowCount /
fixedCellWidth / fixedCellHeight / cell bounds /
indexToLocation are round-trip-only or null per R_layouts_close_enough (Vaadin Grid
virtualises and owns its own sizing).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.grid.Grid
com.vaadin.flow.component.grid.Grid.AbstractGridExtension<T>, com.vaadin.flow.component.grid.Grid.Column<T>, com.vaadin.flow.component.grid.Grid.DataCommunicatorBuilder<T,U>, com.vaadin.flow.component.grid.Grid.MultiSortPriority, com.vaadin.flow.component.grid.Grid.NestedNullBehavior, com.vaadin.flow.component.grid.Grid.SelectionMode, com.vaadin.flow.component.grid.Grid.SpringData, com.vaadin.flow.component.grid.Grid.UpdateQueue Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C>Nested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidOverrides the inheritedComponentMixinwire — Grid dispatches item clicks (carrying the row index), not generic component clicks.voidaddSelectionInterval(int anchor, int lead) voidvoidprotected ListSelectionModelvoidensureIndexIsVisible(int index) Scrolls so the row atindexis visible.intgetCellBounds(int index0, int index1) R_layouts_close_enough — no server-side cell bounds.booleanintintintCurrent JDK selection mode; used by the emulator for PCE old-value delivery.intintJDKgetSelectionModel(): ListSelectionModelcan't coexist with Vaadin Grid's same-namedgetSelectionModel(): GridSelectionModel<T>(unrelated return types).intintgetModel()intint[]Deliberate no-op — L&F key.booleanintindexToLocation(int index) R_layouts_close_enough — no server-side cell coordinates.voidvoidbooleanisSelectedIndex(int index) booleanintlocationToIndex(Point location) Returns the row index currently being click-dispatched (stashed byaddMouseListener(SMouseListener)'s item-click wire), or-1outside a click dispatch.voidremoveSelectionInterval(int index0, int index1) voidsetDragEnabled(boolean dragEnabled) voidsetFixedCellHeight(int height) voidsetFixedCellWidth(int width) voidsetLayoutOrientation(int layoutOrientation) voidsetListData(E[] listData) voidsetListData(Vector<E> listData) voidvoidsetPrototypeCellValue(E prototypeCellValue) voidsetRenderer(com.vaadin.flow.data.renderer.Renderer<Integer> renderer) Install a VaadinRenderer<Integer>for the list cells.voidsetSelectedIndex(int index) voidsetSelectedIndices(int[] indices) voidsetSelectedValue(Object anObject, boolean shouldScroll) Select the cell whose model element equalsanObject.voidsetSelectionAdjustedByOwner(boolean selectionAdjustedByOwner) Whether the code that owns this list's models shifts the selection across the model's inserts and removals itself, so this list only refreshes.voidsetSelectionBackground(Color selectionBackground) voidsetSelectionForeground(Color selectionForeground) voidsetSelectionInterval(int anchor, int lead) voidsetSelectionMode(int selectionMode) JDK selection-mode setter.voidsetSelectionModel(ListSelectionModel selectionModel) voidsetValueIsAdjusting(boolean b) voidsetVisibleRowCount(int visibleRowCount) voidMethods inherited from class com.vaadin.flow.component.grid.Grid
addCellFocusListener, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumn, addColumnReorderListener, addColumnResizeListener, addColumns, addComponentColumn, addContextMenu, addDataGenerator, addDragEndListener, addDragStartListener, addDropListener, addFirstHeaderRow, addItemClickListener, addItemDoubleClickListener, addSelectionListener, addSortListener, addThemeVariants, addValueProvider, appendFooterRow, appendHeaderRow, asMultiSelect, asSingleSelect, compareMaybeComparables, configureBeanType, createColumn, createColumnId, createDataCommunicator, createDefaultArrayUpdater, createEditor, createSortingComparator, deselect, deselectAll, getAriaLabel, getArrayUpdater, getBeanType, getColumnByInternalId, getColumnByKey, getColumnLayers, getColumnRendering, getColumns, getCompositeDataGenerator, getDataCommunicator, getDataProvider, getDefaultColumnFactory, getDefaultHeaderRow, getDragFilter, getDropFilter, getDropMode, getEditor, getEmptyStateComponent, getEmptyStateText, getFooterRows, getGenericDataView, getHeaderRows, getI18n, getLazyDataView, getListDataView, getNestedNullBehavior, getPageSize, getPartNameGenerator, getPropertySet, getSelectedItems, getSelectionMode, getSelectionModel, getSelectionPreservationMode, getSortOrder, getTooltipPosition, getUniqueKeyProperty, getUniqueKeyProvider, initConnector, insertColumnLayer, isAllRowsVisible, isColumnReorderingAllowed, isDetailsVisible, isDetailsVisibleOnClick, isMultiSort, isRowsDraggable, isTooltipMarkdownEnabled, onAttach, onDataProviderChange, onDetach, onEnabledStateChanged, prependFooterRow, prependHeaderRow, recalculateColumnWidths, refreshViewport, removeAllColumns, removeAllFooterRows, removeAllHeaderRows, removeColumn, removeColumnByKey, removeColumnLayer, removeColumns, removeFooterRow, removeHeaderRow, removeThemeVariants, scheduleScrollExecution, scrollToColumn, scrollToColumn, scrollToEnd, scrollToIndex, scrollToItem, scrollToStart, select, setAllRowsVisible, setAriaLabel, setColumnKey, setColumnOrder, setColumnOrder, setColumnRendering, setColumnReorderingAllowed, setColumns, setDataProvider, setDefaultMultiSortPriority, setDetailsVisible, setDetailsVisibleOnClick, setDragDataGenerator, setDragFilter, setDropFilter, setDropMode, setEmptyStateComponent, setEmptyStateText, setI18n, setItemDetailsRenderer, setItems, setItems, setItems, setItems, setItemSelectableProvider, setItemsPageable, setItemsPageable, setMultiSort, setMultiSort, setMultiSort, setMultiSort, setNestedNullBehavior, setPageSize, setPartNameGenerator, setRowsDraggable, setSelectionDragDetails, setSelectionMode, setSelectionModel, setSelectionPreservationMode, setSortableColumns, setTooltipGenerator, setTooltipMarkdownEnabled, setTooltipPosition, setUniqueKeyProperty, setUniqueKeyProvider, sort, updateSelectionModeOnClientMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.data.provider.HasLazyDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.data.provider.HasListDataView
setItems, setItemsMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, updateUI
-
Field Details
-
VERTICAL
public static final int VERTICAL- See Also:
-
VERTICAL_WRAP
public static final int VERTICAL_WRAP- See Also:
-
HORIZONTAL_WRAP
public static final int HORIZONTAL_WRAP- See Also:
-
-
Constructor Details
-
SJList
public SJList() -
SJList
-
SJList
-
SJList
-
-
Method Details
-
createDefaultSelectionModel
-
getModel
-
setModel
-
setListData
-
setListData
-
setRenderer
Install a VaadinRenderer<Integer>for the list cells. Replaces the single column. Migrated code at the surrogate stage uses this rather than the JDKListCellRenderersurface (which lives only on the emulator layer per D_event_port_policy + R_vaadin_first). -
setSelectionAdjustedByOwner
public void setSelectionAdjustedByOwner(boolean selectionAdjustedByOwner) Whether the code that owns this list's models shifts the selection across the model's inserts and removals itself, so this list only refreshes.falseby default: a list listening to its own model shifts its selection itself. An owner that does it on the thread the model fired on, as a JDKJList's UI does, sets it. -
intervalAdded
- Specified by:
intervalAddedin interfaceListDataListener
-
intervalRemoved
- Specified by:
intervalRemovedin interfaceListDataListener
-
contentsChanged
- Specified by:
contentsChangedin interfaceListDataListener
-
getListSelectionModel
JDKgetSelectionModel(): ListSelectionModelcan't coexist with Vaadin Grid's same-namedgetSelectionModel(): GridSelectionModel<T>(unrelated return types). Per R_vaadin_first the Vaadin shape wins at the surrogate; the emulator (:emulators.JList) keeps the JDK-shaped getter and reaches the model through this differently-named accessor. Same resolution SJTable uses. -
getJdkSelectionMode
public int getJdkSelectionMode()Current JDK selection mode; used by the emulator for PCE old-value delivery. Reconstructed from the selection model (the source of truth) rather than a redundant shadow field — R_vaadin_first. -
setSelectionModel
-
setSelectionMode
public void setSelectionMode(int selectionMode) JDK selection-mode setter. Validates per JDK contract, updates the underlyingListSelectionModel, and maps to Vaadin Grid'sGrid.SelectionMode: SINGLE → SINGLE; the two interval modes both map to MULTI (Vaadin Grid has no single-interval analog — theListSelectionModelstill enforces the JDK contract). -
valueChanged
- Specified by:
valueChangedin interfaceListSelectionListener
-
setSelectedIndex
public void setSelectedIndex(int index) -
setSelectedIndices
public void setSelectedIndices(int[] indices) -
getSelectedIndex
public int getSelectedIndex() -
getSelectedIndices
public int[] getSelectedIndices() -
getMinSelectionIndex
public int getMinSelectionIndex() -
getMaxSelectionIndex
public int getMaxSelectionIndex() -
isSelectedIndex
public boolean isSelectedIndex(int index) -
isSelectionEmpty
public boolean isSelectionEmpty() -
getAnchorSelectionIndex
public int getAnchorSelectionIndex() -
getLeadSelectionIndex
public int getLeadSelectionIndex() -
getSelectedValue
-
getSelectedValuesList
-
setSelectedValue
Select the cell whose model element equalsanObject.nullclears the selection.shouldScrolldrivesensureIndexIsVisible(int). -
setSelectionInterval
public void setSelectionInterval(int anchor, int lead) -
addSelectionInterval
public void addSelectionInterval(int anchor, int lead) -
removeSelectionInterval
public void removeSelectionInterval(int index0, int index1) -
clearSelection
public void clearSelection() -
getValueIsAdjusting
public boolean getValueIsAdjusting() -
setValueIsAdjusting
public void setValueIsAdjusting(boolean b) -
ensureIndexIsVisible
public void ensureIndexIsVisible(int index) Scrolls so the row atindexis visible. -
addMouseListener
Overrides the inheritedComponentMixinwire — Grid dispatches item clicks (carrying the row index), not generic component clicks. EachSMouseListenergets two Grid subscriptions, combined into oneRegistration:addItemClickListenerfiresSMouseEvent.MOUSE_CLICKEDcarrying the browser click count (single = 1), andaddItemDoubleClickListenerfires it withclickCount == 2— the canonical double-click-to-open signal.ItemDoubleClickEvent extends ItemClickEvent, so one translation path serves both. The clicked index is stashed around the fan-out forlocationToIndex(Point).A real browser double-click also fires the intervening single click (cc=1), which is AWT's escalation rather than an approximation of it: both deliver a full cc=1 dispatch then a full cc=2 one (measured on both sides, D_mouse_listener_bridge).
- Specified by:
addMouseListenerin interfaceComponentMixin
-
locationToIndex
Returns the row index currently being click-dispatched (stashed byaddMouseListener(SMouseListener)'s item-click wire), or-1outside a click dispatch. There is no server-side pixel→index map (R_layouts_close_enough), so the stash is the only honest answer; called from a usermouseClickedhandler — the dominant JList idiom — it returns the clicked row. -
indexToLocation
R_layouts_close_enough — no server-side cell coordinates. -
getCellBounds
R_layouts_close_enough — no server-side cell bounds. -
getLayoutOrientation
public int getLayoutOrientation() -
setLayoutOrientation
public void setLayoutOrientation(int layoutOrientation) -
getVisibleRowCount
public int getVisibleRowCount() -
setVisibleRowCount
public void setVisibleRowCount(int visibleRowCount) -
getFixedCellWidth
public int getFixedCellWidth() -
setFixedCellWidth
public void setFixedCellWidth(int width) -
getFixedCellHeight
public int getFixedCellHeight() -
setFixedCellHeight
public void setFixedCellHeight(int height) -
getPrototypeCellValue
-
setPrototypeCellValue
-
getSelectionForeground
-
setSelectionForeground
-
getSelectionBackground
-
setSelectionBackground
-
getDragEnabled
public boolean getDragEnabled() -
setDragEnabled
public void setDragEnabled(boolean dragEnabled) -
getUIClassID
Description copied from interface:JComponentMixinDeliberate no-op — L&F key.- Specified by:
getUIClassIDin interfaceJComponentMixin
-