Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
283,500
AccessibleContext () { if (accessibleContext == null) { accessibleContext = new AccessibleJBTable(); } return accessibleContext; }
getAccessibleContext
283,501
Accessible (int r, int c) { if (r >= 0 && c < 0) c = 0; if (r < 0 && c >= 0) r = 0; return super.getAccessibleAt(r, c); }
getAccessibleAt
283,502
Accessible (int i) { if (i < 0 || i >= getAccessibleChildrenCount()) { return null; } else { int column = getAccessibleColumnAtIndex(i); int row = getAccessibleRowAtIndex(i); return new AccessibleJBTableCell(JBTable.this, row, column, getAccessibleIndexAt(row, column)); } }
getAccessibleChild
283,503
Accessible (Point p) { int column = columnAtPoint(p); int row = rowAtPoint(p); if ((column != -1) && (row != -1)) { return getAccessibleChild(getAccessibleIndexAt(row, column)); } return null; }
getAccessibleAt
283,504
Component () { return JBTable.this .getCellRenderer(myRow, myColumn) .getTableCellRendererComponent(JBTable.this, getValueAt(myRow, myColumn), false, false, myRow, myColumn); }
getCurrentComponent
283,505
AccessibleContext () { Component c = getCurrentComponent(); if (c instanceof Accessible) { return c.getAccessibleContext(); } // Note: don't call "super" as 1) we know for sure the cell is not accessible // and 2) the super implementation is incorrect anyway return null; }
getCurrentAccessibleContext
283,506
void () { if (UIUtil.isUnderWin10LookAndFeel() && getModel() instanceof AbstractTableModel && rollOverCell != null) { TableCellRenderer cellRenderer = getCellRenderer(rollOverCell.row, rollOverCell.column); if (cellRenderer != null) { Object value = getValueAt(rollOverCell.row, rollOverCell.column); boolean selected = isCellSelected(rollOverCell.row, rollOverCell.column); Component rc = cellRenderer.getTableCellRendererComponent(this, value, selected, hasFocus(), rollOverCell.row, rollOverCell.column); if (rc instanceof JCheckBox) { ((JCheckBox)rc).putClientProperty(UIUtil.CHECKBOX_ROLLOVER_PROPERTY, null); } } if (getModel() instanceof AbstractTableModel) { ((AbstractTableModel)getModel()).fireTableCellUpdated(rollOverCell.row, rollOverCell.column); } rollOverCell = null; } }
resetRollOverCell
283,507
boolean (@NotNull JTable table, int columnIndex) { if (columnIndex >=0 && columnIndex < table.getColumnCount()) { return SpaceKeyListener.install(table, columnIndex); } return false; }
setupCheckboxShortcut
283,508
boolean (@NotNull JTable table, int columnIndex) { for (KeyListener listener : table.getKeyListeners()) { if (listener instanceof SpaceKeyListener) return false; } table.addKeyListener(new SpaceKeyListener(table, columnIndex)); return true; }
install
283,509
void (KeyEvent e) { int[] rows = myTable.getSelectedRows(); if (rows.length == 0 || e.getKeyCode() != KeyEvent.VK_SPACE || myTable.isEditing() || e.getModifiersEx() != 0) return; SpeedSearchSupply supply = SpeedSearchSupply.getSupply(myTable); if (supply != null && supply.isPopupActive()) return; for (int row : rows) { if (myTable.editCellAt(row, myColumnIndex)) { if (myTable.getCellEditor() instanceof DefaultCellEditor defaultCellEditor && defaultCellEditor.getComponent() instanceof JCheckBox checkBox) { checkBox.setSelected(!checkBox.isSelected()); } stopEditing(myTable); e.consume(); } } }
keyPressed
283,510
void (@NotNull PropertiesComponent propertyComponent, @NotNull String prefix, @NotNull JTable table) { TableColumnModel model = table.getTableHeader().getColumnModel(); int columnCount = model.getColumnCount(); boolean[] storedColumns = new boolean[columnCount]; Arrays.fill(storedColumns, false); for (int i = 0; i < columnCount; i++) { TableColumn column = model.getColumn(i); propertyComponent.setValue(prefix + widthPropertyName(i), String.valueOf(column.getWidth())); int modelIndex = column.getModelIndex(); propertyComponent.setValue(prefix + orderPropertyName(i), String.valueOf(modelIndex)); if (storedColumns[modelIndex]) { LOG.error("columnCount: " + columnCount + " current: " + i + " modelINdex: " + modelIndex); } storedColumns[modelIndex] = true; } }
store
283,511
void (@NotNull PropertiesComponent propertyComponent, @NotNull String prefix, @NotNull TableColumnModel columns) { for (int i = 0; i < columns.getColumnCount(); i++) { propertyComponent.setValue(prefix + widthPropertyName(i), String.valueOf(columns.getColumn(i).getWidth())); } }
storeWidth
283,512
void (@NotNull BiConsumer<? super String, ? super String> consumer, @NotNull TableColumnModel columns) { for (int i = 0; i < columns.getColumnCount(); i++) { consumer.accept(widthPropertyName(i), String.valueOf(columns.getColumn(i).getWidth())); } }
storeWidth
283,513
void (@NotNull PropertiesComponent propertyComponent, @NotNull String prefix, JTable table) { TableColumnModel columnModel = table.getTableHeader().getColumnModel(); int index = 0; List<String> columnIndices = new ArrayList<>(); while (true) { String order = propertyComponent.getValue(prefix + orderPropertyName(index)); if (order == null) { break; } columnIndices.add(order); index++; if (index == table.getColumnCount()) break; } index = 0; for (String columnIndex : columnIndices) { int modelColumnIndex = indexByModelIndex(columnModel, Integer.parseInt(columnIndex)); if (modelColumnIndex > 0 && modelColumnIndex < columnModel.getColumnCount()) { columnModel.moveColumn(modelColumnIndex, index); } index++; } for (int i = 0; i < columnIndices.size(); i++) { String width = propertyComponent.getValue(prefix + widthPropertyName(i)); if (width != null && width.length() > 0) { try { columnModel.getColumn(i).setPreferredWidth(Integer.parseInt(width)); } catch(NumberFormatException e) { LOG.error("Bad width: " + width + " at column: "+ i + " from: " + prefix + " actual columns count: " + columnModel.getColumnCount() + " info count: " + columnIndices.size(), e); } } } }
restore
283,514
void (@NotNull PropertiesComponent propertyComponent, @NotNull String prefix, TableColumnModel columns) { restoreWidth(s -> propertyComponent.getValue(prefix + s), columns); }
restoreWidth
283,515
void (@NotNull Function<? super String, String> map, TableColumnModel columns) { for (int index = 0; true; index++) { String widthValue = map.fun(widthPropertyName(index)); if (widthValue == null) { break; } try { columns.getColumn(index).setPreferredWidth(Integer.parseInt(widthValue)); } catch (NumberFormatException e) { LOG.error("Bad width: " + widthValue + " at column: " + index + " from: " + map, e); } } }
restoreWidth
283,516
int (TableColumnModel model, int index) { for (int i = 0; i < model.getColumnCount(); i++) if (model.getColumn(i).getModelIndex() == index) return i; LOG.error("Total: " + model.getColumnCount() + " index: " + index); return index; }
indexByModelIndex
283,517
DockManager (@NotNull Project project) { return project.getService(DockManager.class); }
getInstance
283,518
boolean () { return this != DENY; }
canAccept
283,519
boolean (@NotNull MouseEvent e) { handleDoubleClickOrEnter(getClosestPathForLocation(e.getX(), e.getY()), e); return false; }
onDoubleClick
283,520
void (TreeSelectionEvent e) { if (!myIgnoreSelectionChange && hasSingleSelection()) { getNodeFor(getSelectionPath()).handleSelection(SimpleTree.this); } }
valueChanged
283,521
void (KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER && hasSingleSelection()) { handleDoubleClickOrEnter(getSelectionPath(), e); } if (e.getKeyCode() == KeyEvent.VK_F2 && e.getModifiers() == 0) { e.consume(); // ignore start editing by F2 } }
keyPressed
283,522
void (final TreeUIHelper helper) { helper.installTreeSpeedSearch(this); }
configureUiHelper
283,523
void (ActionGroup aPopupGroup, String aPlace) { myPopupGroup = aPopupGroup; myPlace = aPlace; }
setPopupGroup
283,524
SimpleNode (int row) { return getNodeFor(getPathForRow(row)); }
getNodeFor
283,525
SimpleNode (TreePath aPath) { SimpleNode node = TreeUtil.getLastUserObject(SimpleNode.class, aPath); return node != null ? node : NULL_NODE; }
getNodeFor
283,526
boolean () { final TreePath selection = super.getSelectionPath(); return selection == null || getNodeFor(selection) == NULL_NODE; }
isSelectionEmpty
283,527
SimpleNode[] () { List<SimpleNode> result = new ArrayList<>(); TreePath[] selectionPaths = getSelectionPaths(); if (selectionPaths != null) { SimpleNode lastNode = null; for (TreePath selectionPath : selectionPaths) { SimpleNode nodeFor = getNodeFor(selectionPath); if (lastNode != null && lastNode.getClass() != nodeFor.getClass()) { return new SimpleNode[0]; } result.add(nodeFor); lastNode = nodeFor; } } return result.toArray(new SimpleNode[0]); }
getSelectedNodesIfUniform
283,528
void (Graphics g) { super.paintChildren(g); g.setColor(UIManager.getColor("Tree.line")); for (int row = 0; row < getRowCount(); row++) { final TreePath path = getPathForRow(row); if (!getNodeFor(path).shouldHaveSeparator()) { continue; } final Rectangle bounds = getRowBounds(row); int x = (int)bounds.getMaxX(); int y = (int)(bounds.getY() + bounds.height / 2); g.drawLine(x, y, getWidth() - 5, y); } }
paintChildren
283,529
void (int row) { setSelectionRow(row); }
doClick
283,530
void () { if (isEditing()) { cellEditor.cancelCellEditing(); doStopEditing(); } }
cancelEditing
283,531
void (ChangeEvent e) { doStopEditing(); }
editingStopped
283,532
void (ChangeEvent e) { doStopEditing(); }
editingCanceled
283,533
JComponent () { return myEditorComponent; }
getEditorComponent
283,534
boolean () { return myEditorComponent != null; }
isEditing
283,535
TreePath () { if (isEditing()) { return getPathForRow(myEditingRow); } return super.getEditingPath(); }
getEditingPath
283,536
boolean (TreePath path) { return true; }
isPathEditable
283,537
boolean () { return true; }
paintNodes
283,538
void (Graphics g) { super.paintComponent(g); if (isEditing()) { Rectangle editedNodeRect = getRowBounds(myEditingRow); if (editedNodeRect == null) return; g.setColor(getBackground()); g.fillRect(editedNodeRect.x, editedNodeRect.y, editedNodeRect.width, editedNodeRect.height); } }
paintComponent
283,539
void (TreeCellEditor aCellEditor) { if (cellEditor != null) { cellEditor.removeCellEditorListener(this); } super.setCellEditor(aCellEditor); if (cellEditor != null) { cellEditor.addCellEditorListener(this); } }
setCellEditor
283,540
boolean () { boolean result = isEditing(); if (result) { if (!cellEditor.stopCellEditing()) { cellEditor.cancelCellEditing(); } doStopEditing(); } return result; }
stopEditing
283,541
void (final TreePath path) { if (path != null && isVisible(path)) { if (isEditing() && !stopEditing()) { return; } startEditing(path); } }
startEditingAtPath
283,542
void (final TreePath path) { CellEditor editor = getCellEditor(); if (editor != null && editor.isCellEditable(null) && isPathEditable(path)) { getSelectionModel().clearSelection(); getSelectionModel().setSelectionPath(path); myEditingRow = getRowForPath(path); myEditorComponent = (JComponent)getCellEditor() .getTreeCellEditorComponent(this, path.getLastPathComponent(), isPathSelected(path), isExpanded(path), treeModel.isLeaf(path.getLastPathComponent()), myEditingRow); putEditor(path); if (myEditorComponent.isFocusable()) { myEditorComponent.requestFocusInWindow(); } SwingUtilities.invokeLater(() -> scrollPathToVisible(path)); } }
startEditing
283,543
void (TreePath path) { add(myEditorComponent); Rectangle nodeBounds = getPathBounds(path); Dimension editorPrefSize = myEditorComponent.getPreferredSize(); if (editorPrefSize.height > nodeBounds.height) { nodeBounds.y -= (editorPrefSize.height - nodeBounds.height) / 2; nodeBounds.height = editorPrefSize.height; } myEditorComponent.setBounds(nodeBounds); }
putEditor
283,544
void () { if (isEditing()) { remove(myEditorComponent); myEditorComponent = null; setSelectionRow(myEditingRow); myEditingRow = INVALID; repaint(); } }
doStopEditing
283,545
void (TreePath path) { myIgnoreSelectionChange = true; super.addSelectionPath(path); myIgnoreSelectionChange = false; }
addSelectionPath
283,546
void (TreePath[] path) { myIgnoreSelectionChange = true; super.addSelectionPaths(path); myIgnoreSelectionChange = false; }
addSelectionPaths
283,547
boolean (TreePath path) { TreePath[] selectionPaths = getSelectionPaths(); return selectionPaths != null && ArrayUtil.contains(path, selectionPaths); }
isSelected
283,548
boolean () { return getSelectionRows() != null && getSelectionRows().length > 1; }
isMultipleSelection
283,549
void (final TreePath treePath, final InputEvent e) { Runnable runnable = () -> getNodeFor(treePath).handleDoubleClickOrEnter(this, e); ApplicationManager.getApplication().invokeLater(runnable, ModalityState.stateForComponent(this)); }
handleDoubleClickOrEnter
283,550
void (final MouseEvent e) { SwingUtilities.invokeLater(() -> JBPopupMenu.showByEvent(e, myPlace, myPopupGroup)); }
invokeContextMenu
283,551
void (MouseEvent e) { invokePopup(e); }
mousePressed
283,552
void (MouseEvent e) { invokePopup(e); }
mouseReleased
283,553
void (MouseEvent e) { invokePopup(e); }
mouseClicked
283,554
void (final MouseEvent e) { if (e.isPopupTrigger() && insideTreeItemsArea(e)) { selectPathUnderCursorIfNeeded(e); if (myPopupGroup != null) { invokeContextMenu(e); } } }
invokePopup
283,555
void (final MouseEvent e) { TreePath pathForLocation = getClosestPathForLocation(e.getX(), e.getY()); if (!isSelected(pathForLocation)) { setSelectionPath(pathForLocation); } }
selectPathUnderCursorIfNeeded
283,556
boolean (MouseEvent e) { Rectangle rowBounds = getRowBounds(getRowCount() - 1); if (rowBounds == null) { return false; } double lastItemBottomLine = rowBounds.getMaxY(); return e.getY() <= lastItemBottomLine; }
insideTreeItemsArea
283,557
boolean () { return !isSelectionEmpty() && getSelectionPaths().length == 1; }
hasSingleSelection
283,558
DefaultTreeModel () { return (DefaultTreeModel)getModel(); }
getBuilderModel
283,559
NodeRenderer () { return (NodeRenderer)getCellRenderer(); }
getRenderer
283,560
String () { return getClass().getName() + '#' + System.identityHashCode(this); }
toString
283,561
void (int rows) { myMinHeightInRows = rows; }
setMinSizeInRows
283,562
Dimension () { Dimension superSize = super.getMinimumSize(); if (myMinHeightInRows == -1) return superSize; int rowCount = getRowCount(); if (rowCount == 0) return superSize; double rowHeight = getRowBounds(0).getHeight(); return new Dimension(superSize.width, (int)(rowHeight * myMinHeightInRows)); }
getMinimumSize
283,563
void (final KeyEvent e) { super.processKeyEvent(e); }
processKeyEvent
283,564
String () { return String.valueOf(getUserObject()); }
getText
283,565
void (TreeModelEvent event) { TreePath path = event.getTreePath(); if (path == null) return; if (!myTree.isVisible(path) || !myTree.isExpanded(path)) return; for (Object child : event.getChildren()) { SimpleNode node = TreeUtil.getUserObject(SimpleNode.class, child); if (node != null && node.isAutoExpandNode()) { TreeUtil.promiseExpand(myTree, event.getTreePath().pathByAddingChild(child)); } } }
treeNodesInserted
283,566
boolean (NodeDescriptor nodeDescriptor) { return ((SimpleNode) nodeDescriptor).isAlwaysShowPlus(); }
isAlwaysShowPlus
283,567
boolean (NodeDescriptor nodeDescriptor) { return ((SimpleNode) nodeDescriptor).isAutoExpandNode(); }
isAutoExpandNode
283,568
void () { updateFromRoot(false); }
updateFromRoot
283,569
void (boolean rebuild) { if (rebuild) { cleanUpStructureCaches(); } if (EventQueue.isDispatchThread()) { super.queueUpdate(); } else { ApplicationManager.getApplication().invokeLater(() -> { if (!isDisposed()) { super.queueUpdate(); } }); } }
updateFromRoot
283,570
DefaultMutableTreeNode (final NodeDescriptor childDescr) { return new PatchedDefaultMutableTreeNode(childDescr); }
createChildNode
283,571
void () { if (!(getTreeStructure() instanceof SimpleTreeStructure)) return; ((SimpleTreeStructure)getTreeStructure()).clearCaches(); }
cleanUpStructureCaches
283,572
SimpleTreeBuilder () { initRootNode(); return this; }
initRoot
283,573
int (final int w1, final int w2) { return w1 - w2; }
compareWeights
283,574
int (NodeDescriptor o1, NodeDescriptor o2) { final int w1 = getWeight(o1); final int w2 = getWeight(o2); if (myCompareToString && w1 == w2) { return compareToString(o1, o2); } int weights = compareWeights(w1, w2); return weights != 0 ? weights : o1.getIndex() - o2.getIndex(); }
compare
283,575
int (final NodeDescriptor o1) { return o1.getWeight(); }
getWeight
283,576
int (final int w1, final int w2) { return w2 - w1; }
compareWeights
283,577
int (final NodeDescriptor first, final NodeDescriptor second) { return StringUtil.naturalCompare(first.toString(), second.toString()); }
compareToString
283,578
void () { }
onChildrenBuilt
283,579
void () { myChildren = null; }
cleanUpCache
283,580
SimpleNode (int index) { return getChildAt(index); }
getChildToHighlightAt
283,581
String () { return getName(); }
toString
283,582
int () { return 10; }
getWeight
283,583
SimpleTextAttributes () { return new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, getColor(), JBColor.RED); }
getErrorAttributes
283,584
SimpleTextAttributes () { Color color = getColor(); // the most common case is no color, regular attributes, avoid memory allocation in this case return color == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color); }
getPlainAttributes
283,585
void (@NotNull PresentationData presentation) { Object newElement = updateElement(); if (getElement() != newElement) { presentation.setChanged(true); } if (newElement == null) return; doUpdate(presentation); fillFallbackProperties(presentation); }
update
283,586
void (PresentationData presentation) { fillFallbackText(presentation); fillFallbackIcon(presentation); fillFallbackColor(presentation); }
fillFallbackProperties
283,587
void (PresentationData presentation) { var text = getColoredTextAsPlainText(presentation); if (text == null) { text = presentation.getPresentableText(); } if (text == null) { text = myName; } presentation.setPresentableText(text); }
fillFallbackText
283,588
void (PresentationData presentation) { if (presentation.getIcon(false) == null) { presentation.setIcon(myClosedIcon); } }
fillFallbackIcon
283,589
void (PresentationData presentation) { if (presentation.getForcedTextForeground() == null) { presentation.setForcedTextForeground(myColor); } }
fillFallbackColor
283,590
void (String aText) { clearColoredText(); getTemplatePresentation().addText(new ColoredFragment(aText, getPlainAttributes())); }
setPlainText
283,591
void () { getTemplatePresentation().clearText(); }
clearColoredText
283,592
void (String aText, SimpleTextAttributes aAttributes) { getTemplatePresentation().addText(new ColoredFragment(aText, null, aAttributes)); }
addColoredFragment
283,593
void (@NotNull PresentationData presentation) { }
doUpdate
283,594
Object () { return this; }
getElement
283,595
SimpleNode () { return (SimpleNode)getParentDescriptor(); }
getParent
283,596
int (SimpleNode child) { final SimpleNode[] kids = getChildren(); return ArrayUtil.indexOf(kids, child); }
getIndex
283,597
void (SimpleTree tree) { }
handleSelection
283,598
void (SimpleTree tree, InputEvent inputEvent) { }
handleDoubleClickOrEnter
283,599
LeafState () { if (isAlwaysShowPlus()) return LeafState.NEVER; if (isAlwaysLeaf()) return LeafState.ALWAYS; return LeafState.DEFAULT; }
getLeafState