Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
281,900
Component (JList<? extends T> list, T value, int index, boolean selected, boolean hasFocus) { clear(); setFont(list.getFont()); mySelected = selected; myForeground = isEnabled() ? list.getForeground() : UIUtil.getLabelDisabledForeground(); mySelectionForeground = list.getSelectionForeground(); if (UIUtil.isUnderWin10LookAndFeel()) { setBackground(selected ? list.getSelectionBackground() : list.getBackground()); } else { setBackground(selected ? list.getSelectionBackground() : null); } setPaintFocusBorder(hasFocus); customizeCellRenderer(list, value, index, selected, hasFocus); return this; }
getListCellRendererComponent
281,901
void (@NotNull String fragment, @NotNull SimpleTextAttributes attributes, boolean isMainText) { if (mySelected) { super.append(fragment, new SimpleTextAttributes(attributes.getStyle(), mySelectionForeground), isMainText); } else if (attributes.getFgColor() == null) { super.append(fragment, attributes.derive(-1, myForeground, null, null), isMainText); } else { super.append(fragment, attributes, isMainText); } }
append
281,902
void () { // no need for this in a renderer }
revalidateAndRepaint
281,903
Dimension () { // There is a bug in BasicComboPopup. It does not add renderer into CellRendererPane, // so font can be null here. Font oldFont = getFont(); if (oldFont == null) { setFont(UIUtil.getListFont()); } Dimension result = super.getPreferredSize(); if (oldFont == null) { setFont(null); } return UIUtil.updateListRowHeight(result); }
getPreferredSize
281,904
void () { JComponent mainComponent = createMainComponent(); JButton[] buttons = createButtons(); @Nls String labelText = getLabelText(); if (labelText != null) { setBorder(IdeBorderFactory.createTitledBorder(labelText, false)); } add( mainComponent, new GridBagConstraints(0, 1, 1, buttons.length == 0 ? 1 : buttons.length, 1, 1, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, buttons.length == 0 ? 0 : 4), 0, 0) ); for (int i = 0; i < buttons.length; i++) { JButton button = buttons[i]; add( button, new GridBagConstraints(1, 1 + i, 1, 1, 0, (i == buttons.length - 1 ? 1 : 0), GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 4, 0), 0, 0) ); } }
initPanel
281,905
void () { super.createComponent(); TextFieldWithBrowseButton.MyDoClickAction doClickAction = getDoClickAction(); if (doClickAction != null) { doClickAction.registerShortcut(myComboBox); } myComboBox.setMaximumRowCount(8); myComboBox.setEditable(true); final JTextField editorComponent = (JTextField)myComboBox.getEditor().getEditorComponent(); editorComponent.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(@NotNull DocumentEvent e) { final String text = getText(); if (!Comparing.equal(text, oldText, true)) { oldText = text; final Runnable changeListener = getChangeListener(); if (changeListener != null) { changeListener.run(); } } } }); }
createComponent
281,906
void (@NotNull DocumentEvent e) { final String text = getText(); if (!Comparing.equal(text, oldText, true)) { oldText = text; final Runnable changeListener = getChangeListener(); if (changeListener != null) { changeListener.run(); } } }
textChanged
281,907
String () { final Object selectedItem = myComboBox.isEditable()? myComboBox.getEditor().getItem() : myComboBox.getSelectedItem(); return selectedItem instanceof String ? (String)selectedItem : null; }
getText
281,908
void (String text) { myComboBox.setSelectedItem(text); }
setText
281,909
JComboBox () { return myComboBox; }
getComboBox
281,910
void (Object[] items) { myComboBox.removeAllItems(); for (Object item : items) { myComboBox.addItem(item); } }
setItems
281,911
void (@NlsContexts.ListItem String text) { JComboBox comboBox = getComboBox(); int n = comboBox.getItemCount(); boolean found = false; for (int i = 0; i < n; i++) { String item = (String)comboBox.getItemAt(i); if (Comparing.strEqual(item, text)) { found = true; break; } } if (!found) { comboBox.addItem(text); } comboBox.getEditor().setItem(text); setText(text); }
addItemSetText
281,912
IdeUICustomization () { return ApplicationManager.getApplication().getService(IdeUICustomization.class); }
getInstance
281,913
String () { return UIBundle.message("tool.window.name.version.control"); }
getVcsToolWindowName
281,914
boolean (@NotNull MouseEvent event, int clickCount) { if (clickCount == 2 && event.getButton() == MouseEvent.BUTTON1) { return onDoubleClick(event); } return false; }
onClick
281,915
void (final @NotNull JTable table, final @NotNull EditableModel model) { if (GraphicsEnvironment.isHeadless()) return; table.setDragEnabled(true); installImpl(table, model); }
install
281,916
void (final @NotNull JList list, final @NotNull EditableModel model) { if (GraphicsEnvironment.isHeadless()) return; list.setDragEnabled(true); installImpl(list, model); }
install
281,917
void (final @NotNull JTree tree, final @NotNull EditableModel model) { if (GraphicsEnvironment.isHeadless()) return; tree.setDragEnabled(true); installImpl(tree, model); }
install
281,918
void (final @NotNull JComponent component, final @NotNull EditableModel model) { component.setTransferHandler(new TransferHandler(null)); SmoothAutoScroller.installDropTargetAsNecessary(component); DnDSupport.createBuilder(component) .setBeanProvider(info -> { final Point p = info.getPoint(); return new DnDDragStartBean(new RowDragInfo(component, getRow(component, p))); }) .setTargetChecker(new DnDTargetChecker() { @Override public boolean update(DnDEvent event) { final Object o = event.getAttachedObject(); if (! (o instanceof RowDragInfo) || ((RowDragInfo)o).component != component) { event.setDropPossible(false, ""); return true; } event.setDropPossible(true); int oldIndex = ((RowDragInfo)o).row; int newIndex = getRow(component, event.getPoint()); if (newIndex == -1) { event.setDropPossible(false, ""); return true; } Rectangle cellBounds = getCellBounds(component, newIndex); if (model instanceof RefinedDropSupport) { RefinedDropSupport.Position position = ((RefinedDropSupport)model).isDropInto(component, oldIndex, newIndex) ? INTO : (event.getPoint().y < cellBounds.y + cellBounds.height / 2) ? ABOVE : BELOW; boolean canDrop = ((RefinedDropSupport)model).canDrop(oldIndex, newIndex, position); event.setDropPossible(canDrop); if (canDrop && oldIndex != newIndex) { switch (position) { case INTO: event.setHighlighting(new RelativeRectangle(component, cellBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE); break; case BELOW: cellBounds.y += cellBounds.height; case ABOVE: cellBounds.y -= -1; cellBounds.height = 2; event.setHighlighting(new RelativeRectangle(component, cellBounds), DnDEvent.DropTargetHighlightingType.FILLED_RECTANGLE); break; } } else { event.hideHighlighter(); } } else if (oldIndex != newIndex) { // Drag&Drop always starts with new==old and we shouldn't display 'rejecting' cursor if they are equal boolean canExchange = model.canExchangeRows(oldIndex, newIndex); if (canExchange) { if (oldIndex < newIndex) { cellBounds.y += cellBounds.height - 2; } RelativeRectangle rectangle = new RelativeRectangle(component, cellBounds); rectangle.getDimension().height = 2; event.setDropPossible(true); event.setHighlighting(rectangle, DnDEvent.DropTargetHighlightingType.FILLED_RECTANGLE); } else { event.setDropPossible(false); } } return true; } }) .setDropHandler(new DnDDropHandler() { @Override public void drop(DnDEvent event) { final Object o = event.getAttachedObject(); final Point p = event.getPoint(); if (o instanceof RowDragInfo && ((RowDragInfo)o).component == component) { int oldIndex = ((RowDragInfo)o).row; if (oldIndex == -1) return; int newIndex = getRow(component, p); if (newIndex == -1) { newIndex = getRowCount(component) - 1; } if (oldIndex != newIndex) { if (model instanceof RefinedDropSupport) { Rectangle cellBounds = getCellBounds(component, newIndex); RefinedDropSupport.Position position = ((RefinedDropSupport)model).isDropInto(component, oldIndex, newIndex) ? INTO : (event.getPoint().y < cellBounds.y + cellBounds.height / 2) ? ABOVE : BELOW; if (((RefinedDropSupport)model).canDrop(oldIndex, newIndex, position)) { ((RefinedDropSupport)model).drop(oldIndex, newIndex, position); } } else { if (model.canExchangeRows(oldIndex, newIndex)) { model.exchangeRows(oldIndex, newIndex); setSelectedRow(component, newIndex); } } } } event.hideHighlighter(); } }) .install(); }
installImpl
281,919
boolean (DnDEvent event) { final Object o = event.getAttachedObject(); if (! (o instanceof RowDragInfo) || ((RowDragInfo)o).component != component) { event.setDropPossible(false, ""); return true; } event.setDropPossible(true); int oldIndex = ((RowDragInfo)o).row; int newIndex = getRow(component, event.getPoint()); if (newIndex == -1) { event.setDropPossible(false, ""); return true; } Rectangle cellBounds = getCellBounds(component, newIndex); if (model instanceof RefinedDropSupport) { RefinedDropSupport.Position position = ((RefinedDropSupport)model).isDropInto(component, oldIndex, newIndex) ? INTO : (event.getPoint().y < cellBounds.y + cellBounds.height / 2) ? ABOVE : BELOW; boolean canDrop = ((RefinedDropSupport)model).canDrop(oldIndex, newIndex, position); event.setDropPossible(canDrop); if (canDrop && oldIndex != newIndex) { switch (position) { case INTO: event.setHighlighting(new RelativeRectangle(component, cellBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE); break; case BELOW: cellBounds.y += cellBounds.height; case ABOVE: cellBounds.y -= -1; cellBounds.height = 2; event.setHighlighting(new RelativeRectangle(component, cellBounds), DnDEvent.DropTargetHighlightingType.FILLED_RECTANGLE); break; } } else { event.hideHighlighter(); } } else if (oldIndex != newIndex) { // Drag&Drop always starts with new==old and we shouldn't display 'rejecting' cursor if they are equal boolean canExchange = model.canExchangeRows(oldIndex, newIndex); if (canExchange) { if (oldIndex < newIndex) { cellBounds.y += cellBounds.height - 2; } RelativeRectangle rectangle = new RelativeRectangle(component, cellBounds); rectangle.getDimension().height = 2; event.setDropPossible(true); event.setHighlighting(rectangle, DnDEvent.DropTargetHighlightingType.FILLED_RECTANGLE); } else { event.setDropPossible(false); } } return true; }
update
281,920
void (DnDEvent event) { final Object o = event.getAttachedObject(); final Point p = event.getPoint(); if (o instanceof RowDragInfo && ((RowDragInfo)o).component == component) { int oldIndex = ((RowDragInfo)o).row; if (oldIndex == -1) return; int newIndex = getRow(component, p); if (newIndex == -1) { newIndex = getRowCount(component) - 1; } if (oldIndex != newIndex) { if (model instanceof RefinedDropSupport) { Rectangle cellBounds = getCellBounds(component, newIndex); RefinedDropSupport.Position position = ((RefinedDropSupport)model).isDropInto(component, oldIndex, newIndex) ? INTO : (event.getPoint().y < cellBounds.y + cellBounds.height / 2) ? ABOVE : BELOW; if (((RefinedDropSupport)model).canDrop(oldIndex, newIndex, position)) { ((RefinedDropSupport)model).drop(oldIndex, newIndex, position); } } else { if (model.canExchangeRows(oldIndex, newIndex)) { model.exchangeRows(oldIndex, newIndex); setSelectedRow(component, newIndex); } } } } event.hideHighlighter(); }
drop
281,921
int (JComponent component, Point point) { if (component instanceof JTable) { return ((JTable)component).rowAtPoint(point); } else if (component instanceof JList) { return ((JList<?>)component).locationToIndex(point); } else if (component instanceof JTree) { return ((JTree)component).getClosestRowForLocation(point.x, point.y); } else { throw new IllegalArgumentException("Unsupported component: " + component); } }
getRow
281,922
int (JComponent component) { if (component instanceof JTable) { return ((JTable)component).getRowCount(); } else if (component instanceof JList) { return ((JList)component).getModel().getSize(); } else if (component instanceof JTree) { return ((JTree)component).getRowCount(); } else { throw new IllegalArgumentException("Unsupported component: " + component); } }
getRowCount
281,923
Rectangle (JComponent component, int row) { if (component instanceof JTable) { Rectangle rectangle = ((JTable)component).getCellRect(row, 0, true); rectangle.width = component.getWidth(); return rectangle; } else if (component instanceof JList) { return ((JList<?>)component).getCellBounds(row, row); } else if (component instanceof JTree) { return ((JTree)component).getRowBounds(row); } else { throw new IllegalArgumentException("Unsupported component: " + component); } }
getCellBounds
281,924
void (JComponent component, int row) { if (component instanceof JTable) { ((JTable)component).getSelectionModel().setSelectionInterval(row, row); } else if (component instanceof JList) { ((JList<?>)component).setSelectedIndex(row); } else if (component instanceof JTree) { ((JTree)component).setSelectionRow(row); } else { throw new IllegalArgumentException("Unsupported component: " + component); } }
setSelectedRow
281,925
record (JComponent component, int row) { }
RowDragInfo
281,926
void (@Nls String text, TextAttributes attributes) { int startOffset = myBuffer.length(); myBuffer.append(text); if (attributes != null) { myHighlightedRegions.add(new HighlightedRegion(startOffset, myBuffer.length(), attributes)); } }
appendText
281,927
void (char[] text, TextAttributes attributes) { int startOffset = myBuffer.length(); myBuffer.append(text); if (attributes != null) { myHighlightedRegions.add(new HighlightedRegion(startOffset, myBuffer.length(), attributes)); } }
appendText
281,928
boolean (Object o) { if (!(o instanceof HighlightedText highlightedText)) return false; return StringUtil.equals(myBuffer, highlightedText.myBuffer) && myHighlightedRegions.equals(highlightedText.myHighlightedRegions); }
equals
281,929
void (HighlightableComponent renderer) { renderer.setText(myBuffer.toString()); for (HighlightedRegion info : myHighlightedRegions) { renderer.addHighlighter(info.startOffset, info.endOffset, info.textAttributes); } }
applyToComponent
281,930
void (boolean hideLine) { myHideLine = hideLine; }
setHideLine
281,931
Dimension () { Dimension size; if (getCaption() == null) { size = new Dimension(Math.max(myPrefWidth, 0), 0); } else { size = getLabelSize(myLabelInsets); } if (!myHideLine) size.height += lineInsets.top + lineInsets.bottom + 1; JBInsets.addTo(size, getInsets()); return size; }
getPreferredElementSize
281,932
void (Graphics g) { g.setColor(getForeground()); Rectangle bounds = new Rectangle(getWidth(), getHeight()); JBInsets.removeFrom(bounds, getInsets()); if (!myHideLine) { paintLine(g, bounds); int lineHeight = lineInsets.top + lineInsets.bottom + 1; bounds.y += lineHeight; bounds.height -= lineHeight; } String caption = getCaption(); if (caption != null) { bounds.x += myLabelInsets.left; bounds.width -= myLabelInsets.left + myLabelInsets.right; bounds.y += myLabelInsets.top; bounds.height -= myLabelInsets.top + myLabelInsets.bottom; Rectangle iconR = new Rectangle(); Rectangle textR = new Rectangle(); FontMetrics fm = g.getFontMetrics(); String label = layoutCompoundLabel(fm, caption, null, CENTER, LEFT, CENTER, LEFT, bounds, iconR, textR, 0); UISettings.setupAntialiasing(g); g.setColor(getTextForeground()); g.drawString(label, textR.x, textR.y + fm.getAscent()); } }
paintComponent
281,933
void (Graphics g, Rectangle bounds) { int x = bounds.x + lineInsets.left; int width = bounds.width - lineInsets.left - lineInsets.right; int y = bounds.y + lineInsets.top; FILL.paint((Graphics2D)g, x, y, width, 1, null); }
paintLine
281,934
void (@NotNull AnActionEvent e) { boolean state = !isSelected(e); setSelected(e, state); Presentation presentation = e.getPresentation(); Toggleable.setSelected(presentation, state); }
actionPerformed
281,935
void (@NotNull AnActionEvent e) { boolean selected = isSelected(e); Toggleable.setSelected(e.getPresentation(), selected); }
updateButton
281,936
void (@NotNull HyperlinkEvent e) { URL url = e.getURL(); if (url != null) { BrowserUtil.browse(url); // e.getURL() provides href with base URL if <base> tag is added in a document } else { BrowserUtil.browse(e.getDescription()); } }
hyperlinkActivated
281,937
AnActionButton (@NotNull Listener listener, String name, @NotNull Icon icon) { return new AddButton(listener, name == null ? getText() : name, icon); }
createButton
281,938
AnActionButton (@NotNull Listener listener, String name, @NotNull Icon icon) { return new RemoveButton(listener, name == null ? getText() : name, icon); }
createButton
281,939
AnActionButton (@NotNull Listener listener, String name, @NotNull Icon icon) { return new EditButton(listener, name == null ? getText() : name, icon); }
createButton
281,940
AnActionButton (@NotNull Listener listener, String name, @NotNull Icon icon) { return new UpButton(listener, name == null ? getText() : name, icon); }
createButton
281,941
AnActionButton (@NotNull Listener listener, String name, @NotNull Icon icon) { return new DownButton(listener, name == null ? getText() : name, icon); }
createButton
281,942
Icon () { return myIcon; }
getIcon
281,943
ActionToolbar () { return myToolbar; }
getToolbar
281,944
void (JComponent label, ActionToolbarPosition position) { removeAll(); add(label, ToolbarDecorator.getPlacement(position)); if (position == ActionToolbarPosition.LEFT) add(myToolbar.getComponent(), BorderLayout.EAST); else if (position == ActionToolbarPosition.RIGHT) add(myToolbar.getComponent(), BorderLayout.WEST); else add(myToolbar.getComponent(), BorderLayout.CENTER); }
setToolbarLabel
281,945
void () { if (getBackground() != null && !getBackground().equals(UIUtil.getPanelBackground())) { SwingUtilities.updateComponentTreeUI(this.getParent()); } for (AnAction button : myActions) { ShortcutSet shortcut; if (button instanceof AnActionButton anActionButton) { shortcut = anActionButton.getShortcut(); } else { shortcut = button.getShortcutSet(); } if (shortcut != null) { if (button instanceof MyActionButton && myCustomShortcuts != null) { ShortcutSet customShortCut = myCustomShortcuts.get(((MyActionButton)button).myButton); if (customShortCut != null) { shortcut = customShortCut; } } button.registerCustomShortcutSet(shortcut, myToolbar.getTargetComponent()); if (button instanceof RemoveButton) { registerDeleteHook((MyActionButton)button); } } } super.addNotify(); // call after all to construct actions tooltips properly }
addNotify
281,946
void (final MyActionButton removeButton) { new AnAction(IdeBundle.messagePointer("action.Anonymous.text.delete.hook")) { @Override public void actionPerformed(@NotNull AnActionEvent e) { removeButton.actionPerformed(e); } @Override public boolean isDumbAware() { return removeButton.isDumbAware(); } @Override public void update(@NotNull AnActionEvent e) { final JComponent contextComponent = removeButton.getContextComponent(); if (contextComponent instanceof JTable && ((JTable)contextComponent).isEditing()) { e.getPresentation().setEnabled(false); return; } final SpeedSearchSupply supply = SpeedSearchSupply.getSupply(contextComponent); if (supply != null && supply.isPopupActive()) { e.getPresentation().setEnabled(false); return; } removeButton.update(e); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } }.registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), removeButton.getContextComponent()); }
registerDeleteHook
281,947
void (@NotNull AnActionEvent e) { removeButton.actionPerformed(e); }
actionPerformed
281,948
boolean () { return removeButton.isDumbAware(); }
isDumbAware
281,949
void (@NotNull AnActionEvent e) { final JComponent contextComponent = removeButton.getContextComponent(); if (contextComponent instanceof JTable && ((JTable)contextComponent).isEditing()) { e.getPresentation().setEnabled(false); return; } final SpeedSearchSupply supply = SpeedSearchSupply.getSupply(contextComponent); if (supply != null && supply.isPopupActive()) { e.getPresentation().setEnabled(false); return; } removeButton.update(e); }
update
281,950
ActionUpdateThread () { return ActionUpdateThread.EDT; }
getActionUpdateThread
281,951
void (Buttons button, boolean enabled) { AnAction b = myButtons.get(button); if (b instanceof AnActionButton anActionButton) { anActionButton.setEnabled(enabled); } }
setEnabled
281,952
void (@NotNull Buttons button, ShortcutSet @Nullable ... shortcutSets) { if (shortcutSets != null) { if (myCustomShortcuts == null) myCustomShortcuts = new EnumMap<>(Buttons.class); myCustomShortcuts.put(button, new CompositeShortcutSet(shortcutSets)); } else { if (myCustomShortcuts != null) { myCustomShortcuts.remove(button); if (myCustomShortcuts.isEmpty()) { myCustomShortcuts = null; } } } }
setCustomShortcuts
281,953
ActionToolbarPosition () { return myPosition; }
getPosition
281,954
RelativePoint (@NotNull AnAction action, @Nullable Component contextComponent) { var c = contextComponent; ActionToolbar toolbar = null; while (c != null && (c = c.getParent()) != null) { if (c instanceof JComponent && (toolbar = (ActionToolbar)((JComponent)c).getClientProperty(ActionToolbar.ACTION_TOOLBAR_PROPERTY_KEY)) != null) { break; } } if (toolbar instanceof JComponent) { RelativePoint preferredPoint = computePreferredPopupPoint((JComponent)toolbar, action); if (preferredPoint != null) return preferredPoint; } return null; }
getPreferredPopupPoint
281,955
ShortcutSet () { return getCommonShortcut(myButton); }
getShortcut
281,956
void (@NotNull AnActionEvent e) { e.getPresentation().setEnabled( isEnabled() && isContextComponentShowingAndEnabled() && isContextComponentStateAllowingAction() && isEventAllowingAction(e) ); }
updateButton
281,957
boolean () { final var component = getContextComponent(); return component != null && component.isShowing() && component.isEnabled(); }
isContextComponentShowingAndEnabled
281,958
boolean () { final var c = getContextComponent(); if (c instanceof JTable || c instanceof JList) { final ListSelectionModel model = c instanceof JTable ? ((JTable)c).getSelectionModel() : ((JList<?>)c).getSelectionModel(); final int size = c instanceof JTable ? ((JTable)c).getRowCount() : ((JList<?>)c).getModel().getSize(); final int min = model.getMinSelectionIndex(); final int max = model.getMaxSelectionIndex(); return isEnabled(size, min, max); } else { return true; } }
isContextComponentStateAllowingAction
281,959
boolean (AnActionEvent e) { return true; }
isEventAllowingAction
281,960
ActionUpdateThread () { return ActionUpdateThread.EDT; }
getActionUpdateThread
281,961
boolean (int size, int min, int max) { return true; }
isEnabled
281,962
void (@NotNull AnActionEvent e) { myListener.doAdd(); }
actionPerformed
281,963
boolean (int size, int min, int max) { return size > 0; }
isEnabled
281,964
void (@NotNull AnActionEvent e) { myListener.doRemove(); }
actionPerformed
281,965
boolean (AnActionEvent e) { final var c = getContextComponent(); final var inputEvent = e.getInputEvent(); if ( inputEvent instanceof KeyEvent && c instanceof JTable && ((JTable)c).isEditing() && !(inputEvent.getComponent() instanceof ActionButtonComponent) // action button active in any case in the toolbar ) { return false; } else { return true; } }
isEventAllowingAction
281,966
boolean (int size, int min, int max) { return size > 0 && min == max && min >= 0; }
isEnabled
281,967
void (@NotNull AnActionEvent e) { myListener.doEdit(); }
actionPerformed
281,968
boolean (int size, int min, int max) { return size > 0 && min >= 1; }
isEnabled
281,969
void (@NotNull AnActionEvent e) { myListener.doUp(); }
actionPerformed
281,970
boolean (int size, int min, int max) { return size > 0 && max < size-1; }
isEnabled
281,971
void (@NotNull AnActionEvent e) { myListener.doDown(); }
actionPerformed
281,972
ShortcutSet (@NotNull Buttons button) { return switch (button) { case ADD -> CommonShortcuts.getNewForDialogs(); case EDIT -> CustomShortcutSet.fromString("ENTER"); case REMOVE -> CustomShortcutSet.fromString(SystemInfo.isMac ? "meta BACK_SPACE" : "alt DELETE"); case UP -> CommonShortcuts.MOVE_UP; case DOWN -> CommonShortcuts.MOVE_DOWN; }; }
getCommonShortcut
281,973
void (String name, Component comp) { super.addLayoutComponent(name, comp); myMap.put(name, comp); }
addLayoutComponent
281,974
void (Component comp) { stopSwipeIfNeeded(); super.removeLayoutComponent(comp); for (Iterator<Map.Entry<String, Component>> iterator = myMap.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry<String, Component> entry = iterator.next(); if (entry.getValue() == comp) { iterator.remove(); break; } } }
removeLayoutComponent
281,975
void (Container parent) { if (!myTimer.isRunning()) { super.layoutContainer(parent); } }
layoutContainer
281,976
void (final @NotNull Container parent, final @NotNull String name, @NotNull SwipeDirection direction) { swipe(parent, name, direction, null); }
swipe
281,977
void (final @NotNull Container parent, final @NotNull String name, @NotNull SwipeDirection direction, final @Nullable Runnable onDone) { stopSwipeIfNeeded(); mySwipeFrom = findVisible(parent); mySwipeTo = myMap.get(name); if (mySwipeTo == null) return; Application app = ApplicationManager.getApplication(); if (mySwipeFrom == null || mySwipeFrom == mySwipeTo || (app != null && app.isUnitTestMode())) { super.show(parent, name); if (onDone != null) { onDone.run(); } return; } final boolean isForward; if (direction == SwipeDirection.AUTO) { boolean b = true; for (Component component : myMap.values()) { if (component == mySwipeFrom || component == mySwipeTo) { b = component == mySwipeFrom; break; } } isForward = b; } else { isForward = direction == SwipeDirection.FORWARD; } final double[] linearProgress = new double[1]; linearProgress[0] = 0; final long startTime = System.currentTimeMillis(); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long timePassed = System.currentTimeMillis() - startTime; if (timePassed >= mySwipeTime) { Component currentFocusComponent = IdeFocusManager.getGlobalInstance().getFocusedDescendantFor(parent); show(parent, name); if (currentFocusComponent != null) currentFocusComponent.requestFocusInWindow(); if (onDone != null) { onDone.run(); } return; } linearProgress[0] = MathUtil.clamp((float)timePassed / mySwipeTime, 0, 1); double naturalProgress = (1 - Math.cos(Math.PI * linearProgress[0])) / 2; Rectangle bounds = new Rectangle(parent.getWidth(), parent.getHeight()); JBInsets.removeFrom(bounds, parent.getInsets()); Rectangle r = new Rectangle(bounds); int x = (int)((naturalProgress * r.width)); r.translate(isForward ? -x : x, 0); mySwipeFrom.setBounds(r); Rectangle r2 = new Rectangle(bounds); r2.translate(isForward ? r2.width - x : x - r2.width, 0); mySwipeTo.setVisible(true); mySwipeTo.setBounds(r2); parent.repaint(); } }; for (ActionListener actionListener : myTimer.getActionListeners()) { myTimer.removeActionListener(actionListener); } myTimer.addActionListener(listener); myTimer.start(); }
swipe
281,978
void (ActionEvent e) { long timePassed = System.currentTimeMillis() - startTime; if (timePassed >= mySwipeTime) { Component currentFocusComponent = IdeFocusManager.getGlobalInstance().getFocusedDescendantFor(parent); show(parent, name); if (currentFocusComponent != null) currentFocusComponent.requestFocusInWindow(); if (onDone != null) { onDone.run(); } return; } linearProgress[0] = MathUtil.clamp((float)timePassed / mySwipeTime, 0, 1); double naturalProgress = (1 - Math.cos(Math.PI * linearProgress[0])) / 2; Rectangle bounds = new Rectangle(parent.getWidth(), parent.getHeight()); JBInsets.removeFrom(bounds, parent.getInsets()); Rectangle r = new Rectangle(bounds); int x = (int)((naturalProgress * r.width)); r.translate(isForward ? -x : x, 0); mySwipeFrom.setBounds(r); Rectangle r2 = new Rectangle(bounds); r2.translate(isForward ? r2.width - x : x - r2.width, 0); mySwipeTo.setVisible(true); mySwipeTo.setBounds(r2); parent.repaint(); }
actionPerformed
281,979
void () { if (myTimer.isRunning()) { myTimer.stop(); mySwipeFrom = null; if (mySwipeTo != null) { mySwipeTo.setVisible(false); mySwipeTo = null; } } }
stopSwipeIfNeeded
281,980
void (Container parent) { stopSwipeIfNeeded(); super.first(parent); }
first
281,981
void (Container parent) { stopSwipeIfNeeded(); super.next(parent); }
next
281,982
void (Container parent) { stopSwipeIfNeeded(); super.previous(parent); }
previous
281,983
void (Container parent) { stopSwipeIfNeeded(); super.last(parent); }
last
281,984
void (Container parent, String name) { stopSwipeIfNeeded(); super.show(parent, name); }
show
281,985
void (ActionEvent e) { cursor[0]--; if (cursor[0] < 0) { cursor[0] = 9; } cardLayout.swipe(centerPanel, "page" + cursor[0], SwipeDirection.BACKWARD); }
actionPerformed
281,986
void (ActionEvent e) { cursor[0] = (cursor[0] + 1) % 10; cardLayout.swipe(centerPanel, "page" + cursor[0], SwipeDirection.FORWARD); }
actionPerformed
281,987
Component (String id) { return myMap.get(id); }
findComponentById
281,988
List<AnAction> (@NotNull List<? extends AnAction> actions, @NotNull DataContext context) { final SortedList<AnAction> result = new SortedList<>(ACTION_BUTTONS_SORTER); result.addAll(actions); return result; }
promote
281,989
void (Component c, Graphics g, int x, int y, int width, int height) { Point textLoc = new Point(); Border border = getBorder(); if (getTitle() == null || getTitle().length() == 0) { if (border != null) { border.paintBorder(c, g, x, y, width, height); } return; } Rectangle grooveRect = new Rectangle(x + EDGE_SPACING, y + EDGE_SPACING, width - (EDGE_SPACING * 2), height - (EDGE_SPACING * 2)); Font font = g.getFont(); Color color = g.getColor(); g.setFont(getFont(c)); FontMetrics fm = g.getFontMetrics(); int fontHeight = fm.getHeight(); int descent = fm.getDescent(); int ascent = fm.getAscent(); int diff; int stringWidth = fm.stringWidth(getTitle()); Insets insets; if (border != null) { insets = border.getBorderInsets(c); } else { insets = new Insets(0, 0, 0, 0); } int titlePos = getTitlePosition(); switch (titlePos) { case ABOVE_TOP -> { diff = ascent + descent + (Math.max(EDGE_SPACING, TEXT_SPACING * 2) - EDGE_SPACING); grooveRect.y += diff; grooveRect.height -= diff; textLoc.y = grooveRect.y - (descent + TEXT_SPACING); } case TOP, DEFAULT_POSITION -> { diff = Math.max(0, ((ascent / 2) + TEXT_SPACING) - EDGE_SPACING); grooveRect.y += diff; grooveRect.height -= diff; textLoc.y = (grooveRect.y - descent) + (insets.top + ascent + descent) / 2; } case BELOW_TOP -> textLoc.y = grooveRect.y + insets.top + ascent + TEXT_SPACING; case ABOVE_BOTTOM -> textLoc.y = (grooveRect.y + grooveRect.height) - (insets.bottom + descent + TEXT_SPACING); case BOTTOM -> { grooveRect.height -= fontHeight / 2; textLoc.y = ((grooveRect.y + grooveRect.height) - descent) + ((ascent + descent) - insets.bottom) / 2; } case BELOW_BOTTOM -> { grooveRect.height -= fontHeight; textLoc.y = grooveRect.y + grooveRect.height + ascent + TEXT_SPACING; } } int justification = getTitleJustification(); if(c.getComponentOrientation().isLeftToRight()) { if(justification==LEADING || justification==DEFAULT_JUSTIFICATION) { justification = LEFT; } else if(justification==TRAILING) { justification = RIGHT; } } else { if(justification==LEADING || justification==DEFAULT_JUSTIFICATION) { justification = RIGHT; } else if(justification==TRAILING) { justification = LEFT; } } switch (justification) { case LEFT -> textLoc.x = grooveRect.x + TEXT_INSET_H + insets.left; case RIGHT -> textLoc.x = (grooveRect.x + grooveRect.width) - (stringWidth + TEXT_INSET_H + insets.right); case CENTER -> textLoc.x = grooveRect.x + ((grooveRect.width - stringWidth) / 2); } // If title is positioned in middle of border AND its fontsize // is greater than the border's thickness, we'll need to paint // the border in sections to leave space for the component's background // to show through the title. // if (border != null) { if (((titlePos == TOP || titlePos == DEFAULT_POSITION) && (grooveRect.y > textLoc.y - ascent)) || (titlePos == BOTTOM && (grooveRect.y + grooveRect.height < textLoc.y + descent))) { Rectangle clipRect = new Rectangle(); // save original clip Rectangle saveClip = g.getClipBounds(); // paint strip left of text clipRect.setBounds(saveClip); if (computeIntersection2(clipRect, x, y, textLoc.x-1-x, height)) { g.setClip(clipRect); border.paintBorder(c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height); } // paint strip right of text clipRect.setBounds(saveClip); if (computeIntersection2(clipRect, textLoc.x+stringWidth+1, y, x+width-(textLoc.x+stringWidth+1), height)) { g.setClip(clipRect); border.paintBorder(c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height); } if (titlePos == TOP || titlePos == DEFAULT_POSITION) { // paint strip below text clipRect.setBounds(saveClip); if (computeIntersection2(clipRect, textLoc.x-1, textLoc.y+descent, stringWidth+2, y+height-textLoc.y-descent)) { g.setClip(clipRect); border.paintBorder(c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height); } } else { // titlePos == BOTTOM // paint strip above text clipRect.setBounds(saveClip); if (computeIntersection2(clipRect, textLoc.x-1, y, stringWidth+2, textLoc.y - ascent - y)) { g.setClip(clipRect); border.paintBorder(c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height); } } // restore clip g.setClip(saveClip); } else { border.paintBorder(c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height); } } g.setColor(getTitleColor()); g.drawString(getTitle(), textLoc.x, textLoc.y); final int index = myOriginalTitle.indexOf('&'); if (index != -1 && index != myOriginalTitle.length() - 1 && index == myOriginalTitle.lastIndexOf('&') && g instanceof Graphics2D) { int x0 = fm.stringWidth(getTitle().substring(0, index)); int x1 = fm.stringWidth(getTitle().substring(0, index+1)); ((Graphics2D)g).setPaint(getTitleColor()); g.drawLine(textLoc.x + x0 - 1, textLoc.y + 1, textLoc.x + x1 - 1, textLoc.y + 1); ((Graphics2D)g).setPaint(color); } g.setFont(font); g.setColor(color); }
paintBorder
281,990
boolean (Rectangle dest, int rx, int ry, int rw, int rh) { int x1 = Math.max(rx, dest.x); int x2 = Math.min(rx + rw, dest.x + dest.width); int y1 = Math.max(ry, dest.y); int y2 = Math.min(ry + rh, dest.y + dest.height); dest.x = x1; dest.y = y1; dest.width = x2 - x1; dest.height = y2 - y1; if (dest.width <= 0 || dest.height <= 0) { return false; } return true; }
computeIntersection2
281,991
List<Fragment> (@NotNull @Nls String htmlString, SimpleTextAttributes defaultAttributes) { TextAttributesStack attributesStack = new TextAttributesStack(defaultAttributes); List<Fragment> res = new ArrayList<>(); HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback() { @Override public void handleText(char[] data, int pos) { res.add(new Fragment(new String(data), attributesStack.peek())); } @Override public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) { String tagName = t.toString(); SimpleTextAttributes attributesByTag = myStyleTagHandler.calcAttributes(t, a); if (attributesByTag != null) { SimpleTextAttributes newAttributes = merge( attributesStack.peek(), attributesByTag); attributesStack.push(tagName, newAttributes); } } @Override public void handleEndTag(HTML.Tag t, int pos) { attributesStack.removeFromTop(t.toString()); } @Override public void handleError(String errorMsg, int pos) { //since <body> tag may be skipped for this parser if (errorMsg.startsWith("start.missing body")) return; // style attribute can be processed by StyleTagHandler if (errorMsg.startsWith("invalid.tagatt style")) return; LOG.error("Cannot parse HTML: [" + htmlString + "]", errorMsg); } }; Reader reader = new StringReader(htmlString); try { new ParserDelegator().parse(reader, callback, true); } catch (IOException e) { LOG.error("Cannot parse HTML", e); return Collections.singletonList(new Fragment(StringUtil.removeHtmlTags(htmlString), defaultAttributes)); } return res; }
convert
281,992
void (char[] data, int pos) { res.add(new Fragment(new String(data), attributesStack.peek())); }
handleText
281,993
void (HTML.Tag t, MutableAttributeSet a, int pos) { String tagName = t.toString(); SimpleTextAttributes attributesByTag = myStyleTagHandler.calcAttributes(t, a); if (attributesByTag != null) { SimpleTextAttributes newAttributes = merge( attributesStack.peek(), attributesByTag); attributesStack.push(tagName, newAttributes); } }
handleStartTag
281,994
void (HTML.Tag t, int pos) { attributesStack.removeFromTop(t.toString()); }
handleEndTag
281,995
void (String errorMsg, int pos) { //since <body> tag may be skipped for this parser if (errorMsg.startsWith("start.missing body")) return; // style attribute can be processed by StyleTagHandler if (errorMsg.startsWith("invalid.tagatt style")) return; LOG.error("Cannot parse HTML: [" + htmlString + "]", errorMsg); }
handleError
281,996
void (@NotNull SimpleColoredComponent component, @NotNull @Nls String html, @NotNull SimpleTextAttributes defaultAttributes) { convert(html, defaultAttributes).forEach(fragment -> component.append(fragment.myText, fragment.myAttributes)); }
appendHtml
281,997
SimpleTextAttributes () { return myAttributes; }
getAttributes
281,998
void (@NotNull String tagName, @NotNull SimpleTextAttributes attributes) { myStack.push(Pair.create(tagName, attributes)); }
push
281,999
void (@NotNull String tagName) { if (tagName.equalsIgnoreCase(myStack.peek().first)) myStack.pop(); }
removeFromTop