Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
282,200
ToolbarDecorator (AnActionButton @NotNull ... actions) { for (AnActionButton action : actions) { if (action != null) { addExtraAction(action); } } return this; }
addExtraActions
282,201
ToolbarDecorator (ActionToolbarPosition position) { myToolbarPosition = position; return this; }
setToolbarPosition
282,202
ToolbarDecorator (AnActionButtonRunnable action) { myAddActionEnabled = action != null; myAddAction = action; return this; }
setAddAction
282,203
ToolbarDecorator (AnActionButtonRunnable action) { myEditActionEnabled = action != null; myEditAction = action; return this; }
setEditAction
282,204
ToolbarDecorator (AnActionButtonRunnable action) { myRemoveActionEnabled = action != null; myRemoveAction = action; return this; }
setRemoveAction
282,205
ToolbarDecorator (AnActionButtonRunnable action) { myUpActionEnabled = action != null; myUpAction = action; return this; }
setMoveUpAction
282,206
ToolbarDecorator (AnActionButtonRunnable action) { myDownActionEnabled = action != null; myDownAction = action; return this; }
setMoveDownAction
282,207
ToolbarDecorator (@ActionText String name) { myAddName = name; return this; }
setAddActionName
282,208
ToolbarDecorator (@ActionText String name) { myEditName = name; return this; }
setEditActionName
282,209
ToolbarDecorator (@ActionText String name) { myRemoveName = name; return this; }
setRemoveActionName
282,210
ToolbarDecorator (@ActionText String name) { myMoveUpName = name; return this; }
setMoveUpActionName
282,211
ToolbarDecorator (@ActionText String name) { myMoveDownName = name; return this; }
setMoveDownActionName
282,212
ToolbarDecorator (AnActionButtonUpdater updater) { myAddActionUpdater = updater; return this; }
setAddActionUpdater
282,213
ToolbarDecorator (AnActionButtonUpdater updater) { myRemoveActionUpdater = updater; return this; }
setRemoveActionUpdater
282,214
ToolbarDecorator (AnActionButtonUpdater updater) { myEditActionUpdater = updater; return this; }
setEditActionUpdater
282,215
ToolbarDecorator (AnActionButtonUpdater updater) { myMoveUpActionUpdater = updater; return this; }
setMoveUpActionUpdater
282,216
ToolbarDecorator (AnActionButtonUpdater updater) { myMoveDownActionUpdater = updater; return this; }
setMoveDownActionUpdater
282,217
ToolbarDecorator () { myForcedDnD = true; return this; }
setForcedDnD
282,218
ToolbarDecorator (@NotNull ActionGroup actionGroup) { AnAction[] actions = actionGroup.getChildren(null); for (AnAction action : actions) { if (!(action instanceof Separator)) { addExtraAction(AnActionButton.fromAction(action)); } } return this; }
setActionGroup
282,219
ToolbarDecorator (Dimension size) { myPreferredSize = size; return this; }
setPreferredSize
282,220
ToolbarDecorator (Dimension size) { myMinimumSize = size; return this; }
setMinimumSize
282,221
ToolbarDecorator (int rowCount) { return this;//do nothing by default }
setVisibleRowCount
282,222
ToolbarDecorator (Icon addIcon) { myAddIcon = addIcon; return this; }
setAddIcon
282,223
JPanel () { CommonActionsPanel.Buttons[] buttons = getButtons(); JComponent contextComponent = getComponent(); UIUtil.putClientProperty(contextComponent, JBViewport.FORCE_VISIBLE_ROW_COUNT_KEY, true); myActionsPanel = new CommonActionsPanel(this, contextComponent, myToolbarPosition, myExtraActions.toArray(AnAction.EMPTY_ARRAY), myButtonComparator, myAddName, myRemoveName, myMoveUpName, myMoveDownName, myEditName, myAddIcon, buttons); JScrollPane scrollPane = null; if (contextComponent instanceof JTree || contextComponent instanceof JTable || contextComponent instanceof JList) { // add scroll pane to supported components only scrollPane = new JBScrollPane(contextComponent) { @Override public Dimension getPreferredSize() { Dimension preferredSize = super.getPreferredSize(); if (!isPreferredSizeSet()) { setPreferredSize(new Dimension(0, preferredSize.height)); } return preferredSize; } }; scrollPane.setBorder(JBUI.Borders.empty()); scrollPane.setViewportBorder(JBUI.Borders.empty()); if (myPreferredSize != null) { scrollPane.setPreferredSize(myPreferredSize); } if (myMinimumSize != null) { scrollPane.setMinimumSize(myMinimumSize); } } JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { super.addNotify(); updateButtons(); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); contextComponent.setEnabled(enabled); } }; panel.add(scrollPane != null ? scrollPane : contextComponent, BorderLayout.CENTER); panel.add(myActionsPanel, getPlacement(myToolbarPosition)); installUpdaters(); updateButtons(); installDnD(); panel.putClientProperty(DECORATOR_KEY, Boolean.TRUE); panel.putClientProperty(ActionToolbar.ACTION_TOOLBAR_PROPERTY_KEY, myActionsPanel.getComponent(0)); panel.putClientProperty(DslComponentProperty.LABEL_FOR, contextComponent); panel.putClientProperty(DslComponentProperty.VERTICAL_COMPONENT_GAP, new VerticalComponentGap(true, true)); panel.putClientProperty(DslComponentProperty.VISUAL_PADDINGS, UnscaledGaps.EMPTY); panel.setBorder(myPanelBorder != null ? myPanelBorder : IdeBorderFactory.createBorder(SideBorder.ALL)); Border scrollPaneBorder = null; if (scrollPane != null && (myScrollPaneBorder != null || myPanelBorder instanceof EmptyBorder)) { // if the panel border is empty, the scrollpane shall get one anyway scrollPaneBorder = myScrollPaneBorder != null ? myScrollPaneBorder : IdeBorderFactory.createBorder(SideBorder.ALL); scrollPane.setBorder(scrollPaneBorder); } if ((myToolbarBorder == null || myToolbarBorder instanceof EmptyBorder) && scrollPaneBorder == null || scrollPaneBorder instanceof EmptyBorder) { myToolbarBorder = new CustomLineBorder( myToolbarPosition == ActionToolbarPosition.BOTTOM ? 1 : 0, myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0, myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0, myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0); } myActionsPanel.setBorder(myToolbarBorder != null ? myToolbarBorder : JBUI.Borders.empty()); return panel; }
createPanel
282,224
Dimension () { Dimension preferredSize = super.getPreferredSize(); if (!isPreferredSizeSet()) { setPreferredSize(new Dimension(0, preferredSize.height)); } return preferredSize; }
getPreferredSize
282,225
void () { super.addNotify(); updateButtons(); }
addNotify
282,226
void (boolean enabled) { super.setEnabled(enabled); contextComponent.setEnabled(enabled); }
setEnabled
282,227
void () { installUpdater(myAddActionEnabled, myAddAction, myAddActionUpdater, CommonActionsPanel.Buttons.ADD); installUpdater(myEditActionEnabled, myEditAction, myEditActionUpdater, CommonActionsPanel.Buttons.EDIT); installUpdater(myRemoveActionEnabled, myRemoveAction, myRemoveActionUpdater, CommonActionsPanel.Buttons.REMOVE); installUpdater(myUpActionEnabled, myUpAction, myMoveUpActionUpdater, CommonActionsPanel.Buttons.UP); installUpdater(myDownActionEnabled, myDownAction, myMoveDownActionUpdater, CommonActionsPanel.Buttons.DOWN); }
installUpdaters
282,228
void ( boolean isEnabled, @Nullable AnActionButtonRunnable anActionButtonRunnable, @Nullable AnActionButtonUpdater updater, CommonActionsPanel.Buttons button ) { if (isEnabled && anActionButtonRunnable != null && updater != null) { final var anActionButton = myActionsPanel.getAnActionButton(button); if (anActionButton != null) { anActionButton.addCustomUpdater(updater); } } }
installUpdater
282,229
void () { if ((myForcedDnD || (myUpAction != null && myUpActionEnabled && myDownAction != null && myDownActionEnabled)) && !ApplicationManager.getApplication().isHeadlessEnvironment() && isModelEditable()) { installDnDSupport(); } }
installDnD
282,230
Object (@NotNull ActionToolbarPosition position) { return switch (position) { case TOP -> BorderLayout.NORTH; case LEFT -> BorderLayout.WEST; case BOTTOM -> BorderLayout.SOUTH; case RIGHT -> BorderLayout.EAST; }; }
getPlacement
282,231
void () { if (myAddAction != null) { myAddAction.run(panel.getAnActionButton(CommonActionsPanel.Buttons.ADD)); } }
doAdd
282,232
void () { if (myEditAction != null) { myEditAction.run(panel.getAnActionButton(CommonActionsPanel.Buttons.EDIT)); } }
doEdit
282,233
void () { if (myRemoveAction != null) { myRemoveAction.run(panel.getAnActionButton(CommonActionsPanel.Buttons.REMOVE)); } }
doRemove
282,234
void () { if (myUpAction != null) { myUpAction.run(panel.getAnActionButton(CommonActionsPanel.Buttons.UP)); } }
doUp
282,235
void () { if (myDownAction != null) { myDownAction.run(panel.getAnActionButton(CommonActionsPanel.Buttons.DOWN)); } }
doDown
282,236
void (final @NotNull Tree tree, JComponent mainComponent, CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) { removeTreeListeners(mainComponent); tree.setCellRenderer(cellRenderer); tree.setRootVisible(false); tree.setShowsRootHandles(true); TreeUtil.installActions(tree); KeyListener keyListener = setupKeyListener(tree, mainComponent); ClickListener clickListener = setupMouseListener(tree, mainComponent, cellRenderer); ComponentUtil.putClientProperty(mainComponent, TREE_LISTENERS_REMOVER, () -> { mainComponent.removeKeyListener(keyListener); clickListener.uninstall(mainComponent); }); }
initTree
282,237
void (Tree tree, CheckedTreeNode node, boolean checked) { changeNodeState(node, checked); adjustParentsAndChildren(node, checked); tree.repaint(); // notify model listeners about model change final TreeModel model = tree.getModel(); model.valueForPathChanged(new TreePath(node.getPath()), node.getUserObject()); }
setNodeState
282,238
void (Tree tree, CheckedTreeNode node) { setNodeState(tree, node, !node.isChecked()); }
toggleNode
282,239
void (final CheckedTreeNode node, final boolean checked) { if (!checked) { if (myCheckPolicy.uncheckParentWithUncheckedChild) { TreeNode parent = node.getParent(); while (parent != null) { if (parent instanceof CheckedTreeNode) { changeNodeState((CheckedTreeNode)parent, false); } parent = parent.getParent(); } } if (myCheckPolicy.uncheckChildrenWithUncheckedParent) { uncheckChildren(node); } } else { if (myCheckPolicy.checkChildrenWithCheckedParent) { checkChildren(node); } if (myCheckPolicy.checkParentWithCheckedChild) { TreeNode parent = node.getParent(); while (parent != null) { if (parent instanceof CheckedTreeNode) { changeNodeState((CheckedTreeNode)parent, true); } parent = parent.getParent(); } } } }
adjustParentsAndChildren
282,240
void (final CheckedTreeNode node, final boolean checked) { if (node.isChecked() != checked) { myEventDispatcher.getMulticaster().beforeNodeStateChanged(node); node.setChecked(checked); myEventDispatcher.getMulticaster().nodeStateChanged(node); } }
changeNodeState
282,241
void (final CheckedTreeNode node) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final Object o = children.nextElement(); if (!(o instanceof CheckedTreeNode child)) continue; changeNodeState(child, false); uncheckChildren(child); } }
uncheckChildren
282,242
void (final CheckedTreeNode node) { final Enumeration children = node.children(); while (children.hasMoreElements()) { final Object o = children.nextElement(); if (!(o instanceof CheckedTreeNode child)) continue; changeNodeState(child, true); checkChildren(child); } }
checkChildren
282,243
KeyListener (final Tree tree, final JComponent mainComponent) { KeyListener listener = new KeyAdapter() { @Override public void keyPressed(@NotNull KeyEvent e) { if (isToggleEvent(e, mainComponent)) { TreePath treePath = tree.getLeadSelectionPath(); if (treePath == null) return; final Object o = treePath.getLastPathComponent(); if (!(o instanceof CheckedTreeNode firstNode)) return; if (!firstNode.isEnabled()) return; toggleNode(tree, firstNode); boolean checked = firstNode.isChecked(); TreePath[] selectionPaths = tree.getSelectionPaths(); for (int i = 0; selectionPaths != null && i < selectionPaths.length; i++) { final TreePath selectionPath = selectionPaths[i]; final Object o1 = selectionPath.getLastPathComponent(); if (!(o1 instanceof CheckedTreeNode node)) continue; setNodeState(tree, node, checked); } e.consume(); } } }; mainComponent.addKeyListener(listener); return listener; }
setupKeyListener
282,244
void (@NotNull KeyEvent e) { if (isToggleEvent(e, mainComponent)) { TreePath treePath = tree.getLeadSelectionPath(); if (treePath == null) return; final Object o = treePath.getLastPathComponent(); if (!(o instanceof CheckedTreeNode firstNode)) return; if (!firstNode.isEnabled()) return; toggleNode(tree, firstNode); boolean checked = firstNode.isChecked(); TreePath[] selectionPaths = tree.getSelectionPaths(); for (int i = 0; selectionPaths != null && i < selectionPaths.length; i++) { final TreePath selectionPath = selectionPaths[i]; final Object o1 = selectionPath.getLastPathComponent(); if (!(o1 instanceof CheckedTreeNode node)) continue; setNodeState(tree, node, checked); } e.consume(); } }
keyPressed
282,245
boolean (KeyEvent e, JComponent mainComponent) { return e.getKeyCode() == KeyEvent.VK_SPACE && SpeedSearchSupply.getSupply(mainComponent) == null; }
isToggleEvent
282,246
ClickListener (final Tree tree, JComponent mainComponent, final CheckboxTreeBase.CheckboxTreeCellRendererBase cellRenderer) { ClickListener listener = new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent e, int clickCount) { int row = tree.getRowForLocation(e.getX(), e.getY()); if (row < 0) return false; final Object o = tree.getPathForRow(row).getLastPathComponent(); if (!(o instanceof CheckedTreeNode node)) return false; Rectangle rowBounds = tree.getRowBounds(row); cellRenderer.setBounds(rowBounds); cellRenderer.validate(); Rectangle checkBounds = cellRenderer.myCheckbox.getBounds(); checkBounds.setLocation(rowBounds.getLocation()); if (checkBounds.height == 0) checkBounds.height = checkBounds.width = rowBounds.height; if (checkBounds.contains(e.getPoint()) && cellRenderer.myCheckbox.isVisible()) { if (node.isEnabled()) { toggleNode(tree, node); tree.setSelectionRow(row); return true; } } else if (clickCount > 1 && clickCount % 2 == 0) { myEventDispatcher.getMulticaster().mouseDoubleClicked(node); return true; } return false; } }; listener.installOn(mainComponent); return listener; }
setupMouseListener
282,247
boolean (@NotNull MouseEvent e, int clickCount) { int row = tree.getRowForLocation(e.getX(), e.getY()); if (row < 0) return false; final Object o = tree.getPathForRow(row).getLastPathComponent(); if (!(o instanceof CheckedTreeNode node)) return false; Rectangle rowBounds = tree.getRowBounds(row); cellRenderer.setBounds(rowBounds); cellRenderer.validate(); Rectangle checkBounds = cellRenderer.myCheckbox.getBounds(); checkBounds.setLocation(rowBounds.getLocation()); if (checkBounds.height == 0) checkBounds.height = checkBounds.width = rowBounds.height; if (checkBounds.contains(e.getPoint()) && cellRenderer.myCheckbox.isVisible()) { if (node.isEnabled()) { toggleNode(tree, node); tree.setSelectionRow(row); return true; } } else if (clickCount > 1 && clickCount % 2 == 0) { myEventDispatcher.getMulticaster().mouseDoubleClicked(node); return true; } return false; }
onClick
282,248
void (JComponent mainComponent) { Runnable remover = ComponentUtil.getClientProperty(mainComponent, TREE_LISTENERS_REMOVER); if (remover != null) remover.run(); }
removeTreeListeners
282,249
void (CheckedTreeNode node) { if (node.isLeaf()) { Object userObject = node.getUserObject(); if (node.isChecked() && userObject != null && nodeType.isAssignableFrom(userObject.getClass())) { //noinspection unchecked final T value = (T)userObject; if (filter != null && !filter.accept(value)) return; nodes.add(value); } } else { for (int i = 0; i < node.getChildCount(); i++) { final TreeNode child = node.getChildAt(i); if (child instanceof CheckedTreeNode) { collect((CheckedTreeNode)child); } } } }
collect
282,250
void (ActionEvent e) { if (getCheckboxColumn() == -1) return; int[] selectedRows = myEntryTable.getSelectedRows(); boolean currentlyMarked = true; for (int selectedRow : selectedRows) { if (selectedRow < 0 || !myEntryTable.isCellEditable(selectedRow, getCheckboxColumn())) { return; } currentlyMarked &= ((Boolean)myEntryTable.getValueAt(selectedRow, getCheckboxColumn())).booleanValue(); } for (int selectedRow : selectedRows) { myEntryTable.setValueAt(currentlyMarked ? Boolean.FALSE : Boolean.TRUE, selectedRow, getCheckboxColumn()); } }
actionPerformed
282,251
void () { TableColumnModel columnModel = myEntryTable.getColumnModel(); TableColumn checkboxColumn = columnModel.getColumn(getCheckboxColumn()); if (myCheckboxColumnName.isEmpty()) { TableUtil.setupCheckboxColumn(checkboxColumn, columnModel.getColumnMargin()); } else { int width = myEntryTable.getFontMetrics(myEntryTable.getFont()) .stringWidth(" " + myCheckboxColumnName + " ") + 4; checkboxColumn.setWidth(width); checkboxColumn.setPreferredWidth(width); checkboxColumn.setMaxWidth(width); checkboxColumn.setMinWidth(width); } }
setCheckboxColumnWidth
282,252
JTable () { return myEntryTable; }
getEntryTable
282,253
void () { while (myModel.getRowCount() > 0) { myModel.removeRow(0); } }
clear
282,254
void (T orderEntry) { int rowCount = myModel.getRowCount(); for (int i = 0; i < rowCount; i++) { if (myModel.getValueAt(i) == orderEntry) { myModel.removeRow(i); return; } } }
remove
282,255
void (@NotNull T orderEntry) { Object[] row = getCheckboxColumn() == -1 ? new Object[]{orderEntry} : new Object[]{Boolean.valueOf(isChecked(orderEntry)), orderEntry}; myModel.addRow(row); }
add
282,256
void (@NotNull Collection<? extends T> orderEntries) { for (T orderEntry : orderEntries) { add(orderEntry); } }
addAll
282,257
int () { return myModel.myEntryColumn; }
getEntryColumn
282,258
int () { return myModel.myCheckboxColumn; }
getCheckboxColumn
282,259
int () { return myColumnCount; }
getColumnCount
282,260
boolean (int row, int column) { return column == myCheckboxColumn && isCheckable(getValueAt(row)); }
isCellEditable
282,261
void (Object value, int row, int column) { super.setValueAt(value, row, column); if (column == myCheckboxColumn) { setChecked(getValueAt(row), ((Boolean)value).booleanValue()); } }
setValueAt
282,262
T (int row) { return (T) getValueAt(row, myEntryColumn); }
getValueAt
282,263
T (int row) { return myModel.getValueAt(row); }
getValueAt
282,264
void (TreeSelectionEvent e) { updateButtons(); }
valueChanged
282,265
void (PropertyChangeEvent evt) { updateButtons(); }
propertyChange
282,266
void () { final EditableTreeModel model = (EditableTreeModel)myTree.getModel(); myAddAction = new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final TreePath path = myTree.getSelectionPath(); final DefaultMutableTreeNode selected = path == null ? (DefaultMutableTreeNode)myTree.getModel().getRoot() : (DefaultMutableTreeNode)path.getLastPathComponent(); final Object selectedNode = selected.getUserObject(); myTree.stopEditing(); Object element; if (model instanceof DefaultTreeModel && myProducer != null) { element = myProducer.createElement(); if (element == null) return; } else { element = null; } DefaultMutableTreeNode parent = selected; if ((selectedNode instanceof SimpleNode && ((SimpleNode)selectedNode).isAlwaysLeaf()) || !selected.getAllowsChildren()) { parent = (DefaultMutableTreeNode)selected.getParent(); } if (parent != null) { parent.insert(new DefaultMutableTreeNode(element), parent.getChildCount()); } final TreePath createdPath = model.addNode(new TreePath(parent.getPath())); if (path != null) { TreeUtil.selectPath(myTree, createdPath); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTree, true)); } } }; myRemoveAction = new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { myTree.stopEditing(); if (myTree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION) { final TreePath path = myTree.getSelectionPath(); if (path != null) { model.removeNode(path); } } else { final TreePath[] paths = myTree.getSelectionPaths(); if (paths != null && paths.length > 0) { model.removeNodes(Arrays.asList(paths)); } } } }; }
createDefaultTreeActions
282,267
void (AnActionButton button) { final TreePath path = myTree.getSelectionPath(); final DefaultMutableTreeNode selected = path == null ? (DefaultMutableTreeNode)myTree.getModel().getRoot() : (DefaultMutableTreeNode)path.getLastPathComponent(); final Object selectedNode = selected.getUserObject(); myTree.stopEditing(); Object element; if (model instanceof DefaultTreeModel && myProducer != null) { element = myProducer.createElement(); if (element == null) return; } else { element = null; } DefaultMutableTreeNode parent = selected; if ((selectedNode instanceof SimpleNode && ((SimpleNode)selectedNode).isAlwaysLeaf()) || !selected.getAllowsChildren()) { parent = (DefaultMutableTreeNode)selected.getParent(); } if (parent != null) { parent.insert(new DefaultMutableTreeNode(element), parent.getChildCount()); } final TreePath createdPath = model.addNode(new TreePath(parent.getPath())); if (path != null) { TreeUtil.selectPath(myTree, createdPath); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTree, true)); } }
run
282,268
void (AnActionButton button) { myTree.stopEditing(); if (myTree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION) { final TreePath path = myTree.getSelectionPath(); if (path != null) { model.removeNode(path); } } else { final TreePath[] paths = myTree.getSelectionPaths(); if (paths != null && paths.length > 0) { model.removeNodes(Arrays.asList(paths)); } } }
run
282,269
JComponent () { return myComponent; }
getComponent
282,270
void () { getActionsPanel().setEnabled(CommonActionsPanel.Buttons.REMOVE, myTree.getSelectionPath() != null); }
updateButtons
282,271
ToolbarDecorator (int rowCount) { myTree.setVisibleRowCount(rowCount); return this; }
setVisibleRowCount
282,272
boolean () { return myTree.getModel() instanceof EditableModel; }
isModelEditable
282,273
void () { RowsDnDSupport.install(myTree, (EditableModel)myTree.getModel()); }
installDnDSupport
282,274
void (@NotNull JList<?> list, int index) { LOG.assertTrue(index >= 0); LOG.assertTrue(index < list.getModel().getSize()); ensureIndexIsVisible(list, index, 0); list.setSelectedIndex(index); }
selectItem
282,275
void (@NotNull JList<?> list) { int size = list.getModel().getSize(); if (size == 0) { list.clearSelection(); return; } int selectedIndex = list.getSelectedIndex(); if (selectedIndex < 0 || selectedIndex >= size) { // fit index to [0, size-1] range selectedIndex = 0; } selectItem(list, selectedIndex); }
ensureSelectionExists
282,276
void (JList<?> list) { int visible = getVisibleRowCount(list); ListSelectionModel selectionModel = list.getSelectionModel(); if (visible <= 0) { moveHome(list); return; } int size = list.getModel().getSize(); int decrement = visible - 1; int index = Math.max(list.getSelectedIndex() - decrement, 0); int top = list.getFirstVisibleIndex() - decrement; if (top < 0) { top = 0; } int bottom = top + visible - 1; if (bottom >= size) { bottom = size - 1; } //list.clearSelection(); Rectangle cellBounds = list.getCellBounds(top, bottom); if (cellBounds == null) { moveHome(list); return; } list.scrollRectToVisible(cellBounds); selectionModel.setSelectionInterval(index,index); list.ensureIndexIsVisible(index); }
movePageUp
282,277
void (@NotNull JList<?> list) { int visible = getVisibleRowCount(list); if (visible <= 0) { moveEnd(list); return; } int size = list.getModel().getSize(); int increment = visible - 1; int index = Math.min(list.getSelectedIndex() + increment, size - 1); int top = list.getFirstVisibleIndex() + increment; int bottom = top + visible - 1; if (bottom >= size) { bottom = size - 1; } //list.clearSelection(); Rectangle cellBounds = list.getCellBounds(top, bottom); if (cellBounds == null) { moveEnd(list); return; } list.scrollRectToVisible(cellBounds); list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
movePageDown
282,278
void (@NotNull JList<?> list) { list.setSelectedIndex(0); list.ensureIndexIsVisible(0); }
moveHome
282,279
void (@NotNull JList<?> list) { int index = list.getModel().getSize() - 1; list.setSelectedIndex(index); list.ensureIndexIsVisible(index); }
moveEnd
282,280
void (@NotNull JList<?> list, int index, int moveDirection) { _ensureIndexIsVisible(list, index, moveDirection, list.getModel().getSize()); }
ensureIndexIsVisible
282,281
void (@NotNull JTable table, int index, int moveDirection) { _ensureIndexIsVisible(table, index, moveDirection, table.getRowCount()); }
ensureIndexIsVisible
282,282
void (@NotNull JComponent c, int index, int moveDirection, int size) { int visible = visibleRowCount(c); int top; int bottom; if (moveDirection == 0) { top = index - (visible - 1) / ROW_PADDING; bottom = top + visible - 1; } else if (moveDirection < 0) { top = index - ROW_PADDING; bottom = index; } else { top = index; bottom = index + ROW_PADDING; } if (top < 0) { top = 0; } if (bottom >= size) { bottom = size - 1; } _ensureRangeIsVisible(c, top, bottom); }
_ensureIndexIsVisible
282,283
void (@NotNull JList<?> list, int top, int bottom) { int size = list.getModel().getSize(); if (top < 0) { top = 0; } if (bottom >= size) { bottom = size - 1; } Rectangle cellBounds = list.getCellBounds(top, bottom); if (cellBounds != null) { cellBounds.x = 0; list.scrollRectToVisible(cellBounds); } }
ensureRangeIsVisible
282,284
void (@NotNull JComponent c, int top, int bottom) { if (c instanceof JList) { ensureRangeIsVisible((JList<?>)c, top, bottom); } else if (c instanceof JTable table) { Rectangle cellBounds = getCellBounds(table, top, bottom); cellBounds.x = 0; table.scrollRectToVisible(cellBounds); } }
_ensureRangeIsVisible
282,285
boolean (@NotNull JList<?> list, int index) { int first = list.getFirstVisibleIndex(); int last = list.getLastVisibleIndex(); if (first < 0 || last < 0 || index < first || index > last) { return false; } if (index > first && index < last) { return true; } return list.getVisibleRect().contains(list.getCellBounds(index, index)); }
isIndexFullyVisible
282,286
int (@NotNull JList<?> list) { return list.getLastVisibleIndex() - list.getFirstVisibleIndex() + 1; }
getVisibleRowCount
282,287
void (@NotNull JList<?> list, @JdkConstants.InputEventMask int modifiers) { moveDown(list, modifiers, UISettings.getInstance().getCycleScrolling()); }
moveDown
282,288
void (@NotNull JList<?> list, @JdkConstants.InputEventMask int modifiers, boolean cycleScrolling) { _moveDown(list, list.getSelectionModel(), modifiers, list.getModel().getSize(), cycleScrolling); }
moveDown
282,289
void (@NotNull ListSelectionModel selectionModel, int indexToSelect, @JdkConstants.InputEventMask int modifiers) { if (selectionModel.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) { selectionModel.setSelectionInterval(indexToSelect,indexToSelect); } else { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) == 0) { selectionModel.setSelectionInterval(indexToSelect, indexToSelect); } else { selectionModel.addSelectionInterval(indexToSelect, indexToSelect); } } }
selectOrAddSelection
282,290
void (@NotNull JList<?> list) { installActions(list, null); }
installActions
282,291
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { installActions(list, focusParent, UISettings.getInstance().getCycleScrolling()); }
installActions
282,292
void (final @NotNull JList<?> list, @Nullable JComponent focusParent, boolean cycleScrolling) { ActionMap actionMap = list.getActionMap(); setupScrollingActions(list, actionMap, cycleScrolling); actionMap.put(MOVE_HOME_ID, new MoveAction(MOVE_HOME_ID, list)); actionMap.put(MOVE_END_ID, new MoveAction(MOVE_END_ID, list)); maybeInstallDefaultShortcuts(list); installMoveUpAction(list, focusParent, cycleScrolling); installMoveDownAction(list, focusParent, cycleScrolling); installMovePageUpAction(list, focusParent); installMovePageDownAction(list, focusParent); if (!(focusParent instanceof JTextComponent)) { installMoveHomeAction(list, focusParent); installMoveEndAction(list, focusParent); } }
installActions
282,293
void (@NotNull JComponent list, ActionMap actionMap, boolean cycleScrolling) { actionMap.put(SCROLL_UP_ACTION_ID, new MoveAction(SCROLL_UP_ACTION_ID, list, cycleScrolling)); actionMap.put(SCROLL_DOWN_ACTION_ID, new MoveAction(SCROLL_DOWN_ACTION_ID, list, cycleScrolling)); actionMap.put(SELECT_PREVIOUS_ROW_ACTION_ID, new MoveAction(SELECT_PREVIOUS_ROW_ACTION_ID, list, cycleScrolling)); actionMap.put(SELECT_NEXT_ROW_ACTION_ID, new MoveAction(SELECT_NEXT_ROW_ACTION_ID, list, cycleScrolling)); actionMap.put(SELECT_LAST_ROW_ACTION_ID, new MoveAction(SELECT_LAST_ROW_ACTION_ID, list, cycleScrolling)); actionMap.put(SELECT_FIRST_ROW_ACTION_ID, new MoveAction(SELECT_FIRST_ROW_ACTION_ID, list, cycleScrolling)); }
setupScrollingActions
282,294
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { if (focusParent != null && focusParent != list) { focusParent.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.isShiftDown()) { if (e.getKeyCode() == KeyEvent.VK_DOWN) { list.dispatchEvent(e); e.consume(); } if (e.getKeyCode() == KeyEvent.VK_UP) { list.dispatchEvent(e); e.consume(); } } } }); } }
redirectExpandSelection
282,295
void (KeyEvent e) { if (e.isShiftDown()) { if (e.getKeyCode() == KeyEvent.VK_DOWN) { list.dispatchEvent(e); e.consume(); } if (e.getKeyCode() == KeyEvent.VK_UP) { list.dispatchEvent(e); e.consume(); } } }
keyPressed
282,296
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { new ListMoveEndAction(focusParent, list); }
installMoveEndAction
282,297
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { new ListMoveHomeAction(focusParent, list); }
installMoveHomeAction
282,298
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { new ListMovePageDownAction(focusParent, list); }
installMovePageDownAction
282,299
void (@NotNull JList<?> list, @Nullable JComponent focusParent) { new ListMovePageUpAction(focusParent, list); }
installMovePageUpAction