Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
281,400
void () { myListModel.clear(); for (Pair<T, Boolean> pair : myWorkingList) { myListModel.addElement(createCheckBox(pair.first, pair.second)); } }
refresh
281,401
CheckBoxList () { return myList; }
getList
281,402
void (final KeyEvent e) { if (preprocessEventForTextField(e)) return; super.processKeyEvent(e); }
processKeyEvent
281,403
void (MouseEvent e) { TextUI ui = getUI(); //noinspection unchecked if (ui instanceof Condition && ((Condition)ui).value(e)) return; if (e.getID() == MouseEvent.MOUSE_PRESSED && e.getX() < JBUIScale.scale(28) && myModel.myFullList.size() > 0) { myTextField.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); if (e.getClickCount() == 1) { showPopup(); } } else { myTextField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); } super.processMouseEvent(e); }
processMouseEvent
281,404
Rectangle (Rectangle bounds) { Integer gap = (Integer)getClientProperty("JTextField.Search.GapEmptyText"); if (gap != null) { bounds.x += gap; bounds.width -= 2 * gap; } return bounds; }
getEmptyTextComponentBounds
281,405
String () { if (myPopup != null && myPopup.isVisible()) return null; return super.getToolTipText(); }
getToolTipText
281,406
String (MouseEvent event) { if (myPopup != null && myPopup.isVisible()) return null; return super.getToolTipText(event); }
getToolTipText
281,407
void (FocusEvent e) { onFocusLost(); super.focusLost(e); }
focusLost
281,408
void (FocusEvent e) { onFocusGained(); super.focusGained(e); }
focusGained
281,409
void (ActionEvent e) { if (!myModel.myFullList.contains(getText())) addCurrentTextToHistory(); if (myModel.getSize() < 2) return; myCurrentHistoryIndex--; if (myCurrentHistoryIndex < 0) myCurrentHistoryIndex = myModel.getSize() - 1; setText(myModel.getElementAt(myCurrentHistoryIndex)); }
actionPerformed
281,410
void (ActionEvent e) { if (!myModel.myFullList.contains(getText())) addCurrentTextToHistory(); if (myModel.getSize() < 2) return; myCurrentHistoryIndex++; if (myCurrentHistoryIndex > myModel.getSize() - 1) myCurrentHistoryIndex = 0; setText(myModel.getElementAt(myCurrentHistoryIndex)); }
actionPerformed
281,411
void () { super.addNotify(); if (toClearTextOnEscape()) { ActionManager actionManager = ActionManager.getInstance(); if (actionManager != null) { ActionUtil.wrap(IdeActions.ACTION_CLEAR_TEXT).registerCustomShortcutSet(CommonShortcuts.ESCAPE, this); } } }
addNotify
281,412
boolean () { return ApplicationManager.getApplication() != null; }
toClearTextOnEscape
281,413
void () { }
onFieldCleared
281,414
void () { addCurrentTextToHistory(); }
onFocusLost
281,415
void () { }
onFocusGained
281,416
void (DocumentListener listener) { getTextEditor().getDocument().addDocumentListener(listener); }
addDocumentListener
281,417
void (DocumentListener listener) { getTextEditor().getDocument().removeDocumentListener(listener); }
removeDocumentListener
281,418
void (final KeyListener listener) { getTextEditor().addKeyListener(listener); }
addKeyboardListener
281,419
void (int historySize) { if (historySize <= 0) throw new IllegalArgumentException("history size must be a positive number"); myHistorySize = historySize; }
setHistorySize
281,420
void (List<String> aHistory) { myModel.setItems(aHistory); }
setHistory
281,421
List<String> () { final int itemsCount = myModel.getSize(); final List<String> history = new ArrayList<>(itemsCount); for (int i = 0; i < itemsCount; i++) { history.add(myModel.getElementAt(i)); } return history; }
getHistory
281,422
void (String aText) { getTextEditor().setText(aText); }
setText
281,423
String () { return getTextEditor().getText(); }
getText
281,424
void () { super.removeNotify(); hidePopup(); }
removeNotify
281,425
void () { if (myModel.addElement(getText()) && myHistoryPropertyName != null) { PropertiesComponent.getInstance().setValue(myHistoryPropertyName, StringUtil.join(getHistory(), "\n")); } }
addCurrentTextToHistory
281,426
void (String item) { }
historyItemChosen
281,427
void () { getTextEditor().selectAll(); }
selectText
281,428
JBTextField () { return myTextField; }
getTextEditor
281,429
boolean () { return myTextField.requestFocusInWindow(); }
requestFocusInWindow
281,430
void () { IdeFocusManager.getGlobalInstance() .doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(getTextEditor(), true)); }
requestFocus
281,431
void (String historyPropertyName) { myHistoryPropertyName = historyPropertyName; myTextField.putClientProperty("JTextField.Search.InplaceHistory", myHistoryPropertyName); reset(); }
setHistoryPropertyName
281,432
void () { if (myHistoryPropertyName == null) return; final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); final String history = propertiesComponent.getValue(myHistoryPropertyName); if (history != null) { final String[] items = history.split("\n"); ArrayList<String> result = new ArrayList<>(); for (String item : items) { if (item != null && item.length() > 0) { result.add(item); } } setHistory(result); } else { setEmptyHistory(); } setSelectedItem(""); }
reset
281,433
void () { }
setEmptyHistory
281,434
String (int index) { return myFullList.get(index); }
getElementAt
281,435
int () { return Math.min(myHistorySize, myFullList.size()); }
getSize
281,436
boolean (String item) { final String newItem = item.trim(); if (newItem.isEmpty()) { return false; } final int length = myFullList.size(); int index = -1; for (int i = 0; i < length; i++) { if (StringUtil.equalsIgnoreCase(myFullList.get(i), newItem)) { index = i; break; } } if (index == 0) { // item is already at the top of the list return false; } if (index > 0) { // move item to top of the list myFullList.remove(index); } else if (myFullList.size() >= myHistorySize && myFullList.size() > 0) { // trim list myFullList.remove(myFullList.size() - 1); } insertElementAt(newItem, 0); return true; }
addElement
281,437
void (String item, int index) { myFullList.add(index, item); fireContentsChanged(); }
insertElementAt
281,438
String () { return mySelectedItem; }
getSelectedItem
281,439
void (String anItem) { mySelectedItem = anItem; }
setSelectedItem
281,440
void () { fireContentsChanged(this, -1, -1); updatePopup(); }
fireContentsChanged
281,441
void (List<String> aList) { myFullList = new ArrayList<>(aList); fireContentsChanged(); }
setItems
281,442
void () { if (myPopup != null) { myPopup.cancel(); myPopup = null; } }
hidePopup
281,443
Runnable (final JList list) { return () -> { final String value = (String)list.getSelectedValue(); getTextEditor().setText(value != null ? value : ""); addCurrentTextToHistory(); }; }
createItemChosenCallback
281,444
void () { addCurrentTextToHistory(); if (myPopup != null && myPopup.isVisible()) return; if (historyPopupEnabled) { doShowPopup(); } }
showPopup
281,445
void () { if (myPopup != null && myPopup.isVisible()) { hidePopup(); doShowPopup(); } }
updatePopup
281,446
void () { if (ApplicationManager.getApplication() != null && JBPopupFactory.getInstance() != null && isShowing()) { final JList<String> list = new JBList<>(myModel); final Runnable chooseRunnable = createItemChosenCallback(list); myPopup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setMovable(false) .setRequestFocus(true) .setItemChosenCallback(chooseRunnable) .setSelectionMode(ListSelectionModel.SINGLE_SELECTION) .setAccessibleName(UIBundle.message("search.text.field.history.popup.accessible.name")) .createPopup(); AlignedPopup.showUnderneathWithoutAlignment(myPopup, getPopupLocationComponent()); } }
doShowPopup
281,447
Component () { return this; }
getPopupLocationComponent
281,448
void (final String s) { getTextEditor().setText(s); }
setSelectedItem
281,449
int () { return myModel.myFullList.indexOf(getText()); }
getSelectedIndex
281,450
void (KeyEvent e) { super.processKeyEvent(e); }
processKeyEvent
281,451
void (KeyEvent e) { myTextField.processKeyEvent(e); }
keyEventToTextField
281,452
boolean (KeyEvent e) { if (SHOW_HISTORY_KEYSTROKE.equals(KeyStroke.getKeyStrokeForEvent(e))) { showPopup(); return true; } return false; }
preprocessEventForTextField
281,453
void (@NotNull AnActionEvent event) { SearchTextField search = event.getData(KEY); if (search != null) { search.selectText(); search.requestFocus(); } }
actionPerformed
281,454
void (@NotNull AnActionEvent e) { e.getPresentation().setEnabledAndVisible(e.getData(KEY) != null); }
update
281,455
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
281,456
ActionUpdateThread () { return ActionUpdateThread.EDT; }
getActionUpdateThread
281,457
void (Color color) { originalColor = color; if (color != null && !myBackground.equals(color)) { //noinspection UseJBColor color = new Color(UIUtil.getGrayFilter().filterRGB(0, 0, color.getRGB())); } super.setColor(color); }
setColor
281,458
void (AttributedCharacterIterator iterator, float x, float y) { setTextColor(); super.drawString(iterator, x, y); }
drawString
281,459
void (AttributedCharacterIterator iterator, int x, int y) { setTextColor(); super.drawString(iterator, x, y); }
drawString
281,460
void (String s, float x, float y) { setTextColor(); super.drawString(s, x, y); }
drawString
281,461
void (String str, int x, int y) { setTextColor(); super.drawString(str, x, y); }
drawString
281,462
void (char[] data, int offset, int length, int x, int y) { setTextColor(); super.drawChars(data, offset, length, x, y); }
drawChars
281,463
void () { if (originalColor != null && !myBackground.equals(originalColor)) { //noinspection UseJBColor super.setColor(new Color(UIUtil.getTextGrayFilter().filterRGB(0, 0, originalColor.getRGB()))); } }
setTextColor
281,464
Graphics () { return new Grayer((Graphics2D)super.create(), myBackground); }
create
281,465
RelativeFont (String family) { return family.equals(myFamily) ? this : new RelativeFont(family, myStyle, mySize); }
family
281,466
RelativeFont (int style) { return null != myStyle && myStyle == style ? this : new RelativeFont(myFamily, style, mySize); }
style
281,467
RelativeFont () { float size = mySize == null ? 1f : mySize; return new RelativeFont(myFamily, myStyle, size * MULTIPLIER); }
large
281,468
RelativeFont () { float size = mySize == null ? 1f : mySize; return new RelativeFont(myFamily, myStyle, size / MULTIPLIER); }
small
281,469
RelativeFont (@NonNls @NotNull String propertyName, int defaultOffset) { return fromResource(propertyName, defaultOffset, MINIMUM_FONT_SIZE); }
fromResource
281,470
RelativeFont (@NonNls @NotNull String propertyName, int defaultOffset, float minSize) { int offset = JBUI.getInt(propertyName, defaultOffset); return offset == 0 ? this : scale(offset, minSize); }
fromResource
281,471
RelativeFont (int offset) { return scale(offset, MINIMUM_FONT_SIZE); }
scale
281,472
RelativeFont (int offset, float minSize) { float multiplier = (float)Math.pow(MULTIPLIER, offset); return new RelativeFont(myFamily, myStyle, mySize != null ? mySize * multiplier : multiplier, minSize); }
scale
281,473
Font (Font font) { if (font == null) return null; boolean isSizeConsidered = false; boolean isOriginalFontUIResource = font instanceof UIResource; if (null != myFamily && !myFamily.equals(font.getFamily(ENGLISH))) { int style = null != myStyle ? myStyle : font.getStyle(); font = new Font(myFamily, style, font.getSize()); } else if (null != myStyle && myStyle != font.getStyle()) { isSizeConsidered = true; font = mySize != null ? font.deriveFont(myStyle, Math.max(mySize * font.getSize2D(), myMinimumSize)) : font.deriveFont(myStyle); } if (mySize != null && !isSizeConsidered) { font = font.deriveFont(Math.max(mySize * font.getSize2D(), myMinimumSize)); } if (font != null && isOriginalFontUIResource && !(font instanceof UIResource)) { font = new FontUIResource(font); } return font; }
derive
281,474
void (PropertyChangeEvent event) { if (!(event.getNewValue() instanceof MyFont) && (event.getSource() instanceof Component component) && PROPERTY.equals(event.getPropertyName())) { Font font = derive(event.getNewValue() instanceof Font ? (Font)event.getNewValue() : component.getFont()); if (font != null) { component.setFont(new MyFont(font)); } } }
propertyChange
281,475
JPanel (final JTable table, final RowEditableTableModel tableModel, boolean addMnemonics) { JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); buttonsPanel.setLayout(new GridBagLayout()); GridBagConstraints gbConstraints = new GridBagConstraints(); gbConstraints.gridwidth = GridBagConstraints.REMAINDER; gbConstraints.fill = GridBagConstraints.HORIZONTAL; gbConstraints.insets = new Insets(2, 4, 2, 4); final JButton addButton = new JButton(); addButton.setText(addMnemonics ? UIBundle.message("row.add") : UIBundle.message("row.add.without.mnemonic")); addButton.setDefaultCapable(false); buttonsPanel.add(addButton, gbConstraints); final JButton removeButton = new JButton(); removeButton.setText(addMnemonics ? UIBundle.message("row.remove") : UIBundle.message("row.remove.without.mnemonic")); removeButton.setDefaultCapable(false); buttonsPanel.add(removeButton, gbConstraints); final JButton upButton = new JButton(); upButton.setText(addMnemonics ? UIBundle.message("row.move.up") : UIBundle.message("row.move.up.without.mnemonic")); upButton.setDefaultCapable(false); buttonsPanel.add(upButton, gbConstraints); final JButton downButton = new JButton(); downButton.setText(addMnemonics ? UIBundle.message("row.move.down") : UIBundle.message("row.move.down.without.mnemonic")); downButton.setDefaultCapable(false); buttonsPanel.add(downButton, gbConstraints); gbConstraints.weighty = 1; buttonsPanel.add(new JPanel(), gbConstraints); addButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TableUtil.stopEditing(table); tableModel.addRow(); final int index = tableModel.getRowCount() - 1; table.editCellAt(index, 0); table.setRowSelectionInterval(index, index); table.setColumnSelectionInterval(0, 0); table.getParent().repaint(); final Component editorComponent = table.getEditorComponent(); if (editorComponent != null) { final Rectangle bounds = editorComponent.getBounds(); table.scrollRectToVisible(bounds); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(editorComponent, true)); } } } ); removeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount()) { tableModel.removeRow(index); if (index < tableModel.getRowCount()) { table.setRowSelectionInterval(index, index); } else { if (index > 0) { table.setRowSelectionInterval(index - 1, index - 1); } } updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); } table.getParent().repaint(); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); } } ); upButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 < index && index < tableModel.getRowCount()) { tableModel.exchangeRows(index, index - 1); table.setRowSelectionInterval(index - 1, index - 1); } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); } } ); downButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount() - 1) { tableModel.exchangeRows(index, index + 1); table.setRowSelectionInterval(index + 1, index + 1); } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); } } ); table.getSelectionModel().addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); } } ); updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); return buttonsPanel; }
createButtonsTable
281,476
void (ActionEvent e) { TableUtil.stopEditing(table); tableModel.addRow(); final int index = tableModel.getRowCount() - 1; table.editCellAt(index, 0); table.setRowSelectionInterval(index, index); table.setColumnSelectionInterval(0, 0); table.getParent().repaint(); final Component editorComponent = table.getEditorComponent(); if (editorComponent != null) { final Rectangle bounds = editorComponent.getBounds(); table.scrollRectToVisible(bounds); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(editorComponent, true)); } }
actionPerformed
281,477
void (ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount()) { tableModel.removeRow(index); if (index < tableModel.getRowCount()) { table.setRowSelectionInterval(index, index); } else { if (index > 0) { table.setRowSelectionInterval(index - 1, index - 1); } } updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); } table.getParent().repaint(); IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); }
actionPerformed
281,478
void (ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 < index && index < tableModel.getRowCount()) { tableModel.exchangeRows(index, index - 1); table.setRowSelectionInterval(index - 1, index - 1); } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); }
actionPerformed
281,479
void (ActionEvent e) { TableUtil.stopEditing(table); int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount() - 1) { tableModel.exchangeRows(index, index + 1); table.setRowSelectionInterval(index + 1, index + 1); } IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(table, true)); }
actionPerformed
281,480
void (ListSelectionEvent e) { updateButtons(table, tableModel, addButton, removeButton, upButton, downButton); }
valueChanged
281,481
void (JTable table, final RowEditableTableModel tableModel, final JButton addButton, final JButton removeButton, final JButton upButton, final JButton downButton) { if (table.isEnabled()) { int index = table.getSelectedRow(); if (0 <= index && index < tableModel.getRowCount()) { removeButton.setEnabled(true); upButton.setEnabled(index > 0); downButton.setEnabled(index < tableModel.getRowCount() - 1); } else { removeButton.setEnabled(false); upButton.setEnabled(false); downButton.setEnabled(false); } addButton.setEnabled(true); } }
updateButtons
281,482
void () { final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList) .disableUpAction() .disableDownAction() .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { addElement(findItemToAdd()); } }); customizeDecorator(decorator); setLayout(new BorderLayout()); add(decorator.createPanel(), BorderLayout.CENTER); if (myTitle != null) { @SuppressWarnings("DialogTitleCapitalization") var outerBorder = IdeBorderFactory.createTitledBorder( myTitle, false, JBInsets.emptyInsets() ).setShowLine(false); setBorder(new CompoundBorder(outerBorder, getBorder())); } }
initPanel
281,483
void (AnActionButton button) { addElement(findItemToAdd()); }
run
281,484
void (ToolbarDecorator decorator) { }
customizeDecorator
281,485
StatusText () { return myList.getEmptyText(); }
getEmptyText
281,486
void (@Nullable T itemToAdd) { if (itemToAdd != null){ myListModel.addElement(itemToAdd); myList.setSelectedValue(itemToAdd, true); } }
addElement
281,487
String () { return myTitle; }
getLabelText
281,488
JButton[] () { return new JButton[]{new JButton(CommonBundle.message("button.add")), new JButton(CommonBundle.message("button.delete"))}; }
createButtons
281,489
JComponent () { if (!myListModel.isEmpty()) myList.setSelectedIndex(0); return ScrollPaneFactory.createScrollPane(myList); }
createMainComponent
281,490
ListCellRenderer () { return new DefaultListCellRenderer(); }
getListCellRenderer
281,491
Border () { return JBUI.Borders.empty(TOP_INSET, 0, BOTTOM_INSET, 0); }
createEmptyBorder
281,492
boolean () { return false; }
isSelectable
281,493
void () { super.updateUI(); updateLabelFont(); }
updateUI
281,494
void (boolean focusable) { myLabel.setFocusable(focusable); remove(myLabel); remove(mySeparator); addComponents(focusable); if (focusable) { if (labelFocusListener == null) { labelFocusListener = new FocusListener() { @Override public void focusGained(FocusEvent e) { setLabelBorder(true); } @Override public void focusLost(FocusEvent e) { setLabelBorder(false); } }; myLabel.addFocusListener(labelFocusListener); setLabelBorder(false); } } else { if (labelFocusListener != null) { myLabel.removeFocusListener(labelFocusListener); labelFocusListener = null; } myLabel.setBorder(null); } }
setLabelFocusable
281,495
void (FocusEvent e) { setLabelBorder(true); }
focusGained
281,496
void (FocusEvent e) { setLabelBorder(false); }
focusLost
281,497
JBLabel () { return new JBLabel(); }
createLabel
281,498
void (boolean focused) { myLabel.setBorder(TitleSelectionBorder.getLabelBorder(focused)); }
setLabelBorder
281,499
void (boolean focusable) { if (focusable) { add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); add(mySeparator, new GridBagConstraints(1, 0, GridBagConstraints.REMAINDER, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.insets(TOP_INSET + SEPARATOR_TOP_INSET / 2, 0, BOTTOM_INSET - SEPARATOR_TOP_INSET / 2, SEPARATOR_RIGHT_INSET), 0, 0)); setBorder(null); } else { add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); add(mySeparator, new GridBagConstraints(1, 0, GridBagConstraints.REMAINDER, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.insets(SEPARATOR_TOP_INSET, SEPARATOR_LEFT_INSET, 0, SEPARATOR_RIGHT_INSET), 0, 0)); setBorder(createEmptyBorder()); } }
addComponents