Java Code Examples for com.intellij.util.ui.UIUtil
The following examples show how to use
com.intellij.util.ui.UIUtil.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: consulo Author: consulo File: DialogWrapperPeerImpl.java License: Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); e.getPresentation().setEnabled(false); if (focusOwner instanceof JComponent && SpeedSearchBase.hasActiveSpeedSearch((JComponent)focusOwner)) { return; } if (StackingPopupDispatcher.getInstance().isPopupFocused()) return; JTree tree = UIUtil.getParentOfType(JTree.class, focusOwner); JTable table = UIUtil.getParentOfType(JTable.class, focusOwner); if (tree != null || table != null) { if (hasNoEditingTreesOrTablesUpward(focusOwner)) { e.getPresentation().setEnabled(true); } } }
Example #2
Source Project: consulo Author: consulo File: AbstractGotoSEContributor.java License: Apache License 2.0 | 6 votes |
@Nonnull @Override public JComponent createCustomComponent(@Nonnull Presentation presentation, @Nonnull String place) { JComponent component = new ActionButtonWithText(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); UIUtil.putClientProperty(component, MnemonicHelper.MNEMONIC_CHECKER, keyCode -> KeyEvent.getExtendedKeyCodeForChar(TOGGLE) == keyCode || KeyEvent.getExtendedKeyCodeForChar(CHOOSE) == keyCode); MnemonicHelper.registerMnemonicAction(component, CHOOSE); InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); int mask = MnemonicHelper.getFocusAcceleratorKeyMask(); map.put(KeyStroke.getKeyStroke(TOGGLE, mask, false), TOGGLE_ACTION_NAME); component.getActionMap().put(TOGGLE_ACTION_NAME, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // mimic AnAction event invocation to trigger myEverywhereAutoSet=false logic DataContext dataContext = DataManager.getInstance().getDataContext(component); KeyEvent inputEvent = new KeyEvent(component, KeyEvent.KEY_PRESSED, e.getWhen(), MnemonicHelper.getFocusAcceleratorKeyMask(), KeyEvent.getExtendedKeyCodeForChar(TOGGLE), TOGGLE); AnActionEvent event = AnActionEvent.createFromAnAction(ScopeChooserAction.this, inputEvent, ActionPlaces.TOOLBAR, dataContext); ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); actionManager.fireBeforeActionPerformed(ScopeChooserAction.this, dataContext, event); onProjectScopeToggled(); actionManager.fireAfterActionPerformed(ScopeChooserAction.this, dataContext, event); } }); return component; }
Example #3
Source Project: consulo Author: consulo File: HideableDecorator.java License: Apache License 2.0 | 6 votes |
private void registerMnemonic() { final int mnemonicIndex = UIUtil.getDisplayMnemonicIndex(getTitle()); if (mnemonicIndex != -1) { myPanel.getActionMap().put("Collapse/Expand on mnemonic", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (myOn) { off(); } else { on(); } } }); final Character mnemonicCharacter = UIUtil.removeMnemonic(getTitle()).toUpperCase().charAt(mnemonicIndex); myPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(mnemonicCharacter, InputEvent.ALT_MASK, false), "Collapse/Expand on mnemonic"); } }
Example #4
Source Project: consulo Author: consulo File: TreeUiTest.java License: Apache License 2.0 | 6 votes |
private void buildSiblings(final Node node, final int start, final int end, @Nullable final Runnable eachRunnable, @javax.annotation.Nullable final Runnable endRunnable) throws InvocationTargetException, InterruptedException { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { for (int i = start; i <= end; i++) { Node eachFile = node.addChild("File " + i); myAutoExpand.add(eachFile.getElement()); eachFile.addChild("message 1 for " + i); eachFile.addChild("message 2 for " + i); if (eachRunnable != null) { eachRunnable.run(); } } if (endRunnable != null) { endRunnable.run(); } } }); }
Example #5
Source Project: consulo Author: consulo File: DesktopEditorAnalyzeStatusPanel.java License: Apache License 2.0 | 6 votes |
private InspectionPopupManager() { myContent.setOpaque(true); myContent.setBackground(UIUtil.getToolTipBackground()); myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myContent, null). setCancelOnClickOutside(true). setCancelCallback(() -> analyzerStatus == null || analyzerStatus.getController().canClosePopup()); myAncestorListener = new AncestorListenerAdapter() { @Override public void ancestorMoved(AncestorEvent event) { hidePopup(); } }; myPopupListener = new JBPopupListener() { @Override public void onClosed(@Nonnull LightweightWindowEvent event) { if (analyzerStatus != null) { analyzerStatus.getController().onClosePopup(); } myEditor.getComponent().removeAncestorListener(myAncestorListener); } }; }
Example #6
Source Project: consulo Author: consulo File: MoreAction.java License: Apache License 2.0 | 6 votes |
protected MoreAction(final String name) { myPanel = new JPanel(); final BoxLayout layout = new BoxLayout(myPanel, BoxLayout.X_AXIS); myPanel.setLayout(layout); myLoadMoreBtn = new JButton(name); myLoadMoreBtn.setMargin(new Insets(2, 2, 2, 2)); myLoadMoreBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MoreAction.this.actionPerformed(null); } }); myPanel.add(myLoadMoreBtn); myLabel = new JLabel("Loading..."); myLabel.setForeground(UIUtil.getInactiveTextColor()); myLabel.setBorder(BorderFactory.createEmptyBorder(1, 3, 1, 1)); myPanel.add(myLabel); }
Example #7
Source Project: consulo Author: consulo File: MnemonicHelper.java License: Apache License 2.0 | 6 votes |
public static boolean hasMnemonic(@Nullable Component component, int keyCode) { if (component instanceof AbstractButton) { AbstractButton button = (AbstractButton)component; if (button instanceof JBOptionButton) { return ((JBOptionButton)button).isOkToProcessDefaultMnemonics() || button.getMnemonic() == keyCode; } else { return button.getMnemonic() == keyCode; } } if (component instanceof JLabel) { return ((JLabel)component).getDisplayedMnemonic() == keyCode; } IntPredicate checker = UIUtil.getClientProperty(component, MNEMONIC_CHECKER); return checker != null && checker.test(keyCode); }
Example #8
Source Project: flutter-intellij Author: flutter File: DiagnosticsTreeCellRenderer.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
public void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent, @NotNull String text, @NotNull SimpleTextAttributes attributes, boolean selected, @NotNull MultiIconSimpleColoredComponent simpleColoredComponent) { final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); if (speedSearch != null) { final Iterable<TextRange> fragments = speedSearch.matchingFragments(text); if (fragments != null) { final Color fg = attributes.getFgColor(); final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted); return; } } simpleColoredComponent.append(text, attributes); }
Example #9
Source Project: consulo Author: consulo File: WrappingAndBracesPanel.java License: Apache License 2.0 | 6 votes |
@Nullable @Override protected JComponent getCustomValueRenderer(@Nonnull String optionName, @Nonnull Object value) { if (CodeStyleSoftMarginsPresentation.OPTION_NAME.equals(optionName)) { JLabel softMarginsLabel = new JLabel(getSoftMarginsString(castToIntList(value))); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, softMarginsLabel); return softMarginsLabel; } else if ("WRAP_ON_TYPING".equals(optionName)) { if (value.equals(ApplicationBundle.message("wrapping.wrap.on.typing.default"))) { JLabel wrapLabel = new JLabel(MarginOptionsUtil.getDefaultWrapOnTypingText(getSettings())); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, wrapLabel); return wrapLabel; } } return super.getCustomValueRenderer(optionName, value); }
Example #10
Source Project: consulo Author: consulo File: ActionButtonUI.java License: Apache License 2.0 | 6 votes |
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) { if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return; if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4)); config.restore(); } }
Example #11
Source Project: consulo Author: consulo File: PopupLocationTracker.java License: Apache License 2.0 | 6 votes |
public static boolean canRectangleBeUsed(@Nonnull Component parent, @Nonnull Rectangle desiredScreenBounds, @Nullable ScreenAreaConsumer excludedConsumer) { if (!Registry.is("ide.use.screen.area.tracker", false)) { return true; } Window window = UIUtil.getWindow(parent); if (window != null) { for (ScreenAreaConsumer consumer : ourAreaConsumers) { if (consumer == excludedConsumer) continue; if (window == consumer.getUnderlyingWindow()) { Rectangle area = consumer.getConsumedScreenBounds(); if (area.intersects(desiredScreenBounds)) { return false; } } } } return true; }
Example #12
Source Project: consulo Author: consulo File: ExternalChangesAndRefreshingTest.java License: Apache License 2.0 | 6 votes |
@Override protected void tearDown() throws Exception { if (getName().equals("testRefreshingAsynchronously")) { // this methods waits for another thread to finish, that leads // to deadlock in swing-thread. Therefore we have to run this test // outside of swing-thread UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { try { ExternalChangesAndRefreshingTest.super.tearDown(); } catch (Exception e) { throw new RuntimeException(e); } } }); } else { super.tearDown(); } }
Example #13
Source Project: flutter-intellij Author: flutter File: FlutterPerformanceView.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example #14
Source Project: consulo Author: consulo File: TestTreeView.java License: Apache License 2.0 | 6 votes |
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL))); final FontMetrics metrics = tree.getFontMetrics(g.getFont()); int totalWidth = metrics.stringWidth(duration) + 2; int x = bounds.x + bounds.width - totalWidth; g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground()); final int leftOffset = 5; g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height); g.translate(0, bounds.y - 1); if (isSelected) { if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) { g.setColor(UIUtil.getTreeForeground()); } else { g.setColor(UIUtil.getTreeSelectionForeground()); } } else { g.setColor(new JBColor(0x808080, 0x808080)); } g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1); g.translate(0, -bounds.y + 1); config.restore(); }
Example #15
Source Project: consulo Author: consulo File: DarculaEditorTabsUI.java License: Apache License 2.0 | 6 votes |
@Override public void doPaintInactiveImpl(Graphics2D g2d, Rectangle effectiveBounds, int x, int y, int w, int h, Color tabColor, int row, int column, boolean vertical) { if (tabColor != null) { g2d.setColor(tabColor); g2d.fillRect(x, y, w, h); } else { g2d.setPaint(UIUtil.getControlColor()); g2d.fillRect(x, y, w, h); } g2d.setColor(Gray._0.withAlpha(10)); g2d.drawRect(x, y, w - 1, h - 1); }
Example #16
Source Project: consulo Author: consulo File: CommanderPanel.java License: Apache License 2.0 | 6 votes |
public final void setActive(final boolean active) { myActive = active; if (active) { myTitlePanel.setBackground(DARK_BLUE); myTitlePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, DARK_BLUE_BRIGHTER, DARK_BLUE_DARKER)); myParentTitle.setForeground(Color.white); } else { final Color color = UIUtil.getPanelBackground(); LOG.assertTrue(color != null); myTitlePanel.setBackground(color); myTitlePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, color.brighter(), color.darker())); myParentTitle.setForeground(JBColor.foreground()); } final int[] selectedIndices = myList.getSelectedIndices(); if (selectedIndices.length == 0 && myList.getModel().getSize() > 0) { myList.setSelectedIndex(0); if (!myList.hasFocus()) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myList); } } else if (myList.getModel().getSize() > 0) { // need this to generate SelectionChanged events so that listeners, added by Commander, will be notified myList.setSelectedIndices(selectedIndices); } }
Example #17
Source Project: consulo Author: consulo File: NewProjectPanel.java License: Apache License 2.0 | 6 votes |
@Nonnull @Override protected JComponent createLeftComponent(@Nonnull Disposable parentDisposable) { NewModuleContext context = new NewModuleContext(); NewModuleBuilder.EP_NAME.composite().setupContext(context); myTree = new Tree(new AsyncTreeModel(new StructureTreeModel<>(new NewProjectTreeStructure(context), parentDisposable), parentDisposable)); myTree.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, null)); myTree.setOpaque(false); myTree.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor)); myTree.setRootVisible(false); myTree.setRowHeight(JBUI.scale(24)); TreeUtil.expandAll(myTree); return ScrollPaneFactory.createScrollPane(myTree, true); }
Example #18
Source Project: consulo Author: consulo File: ImageLoader.java License: Apache License 2.0 | 6 votes |
/** * Loads an image of available resolution (1x, 2x, ...) and scales to address the provided scale context. * Then wraps the image with {@link JBHiDPIScaledImage} if necessary. */ @Nullable public static Image loadFromUrl(@Nonnull URL url, final boolean allowFloatScaling, boolean useCache, Supplier<ImageFilter>[] filters, final JBUI.ScaleContext ctx) { // We can't check all 3rd party plugins and convince the authors to add @2x icons. // In IDE-managed HiDPI mode with scale > 1.0 we scale images manually. return ImageDescList.create(url.toString(), null, UIUtil.isUnderDarcula(), allowFloatScaling, ctx).load(ImageConverterChain.create(). withFilter(filters). with(new ImageConverter() { @Override public Image convert(Image source, ImageDesc desc) { if (source != null && desc.type != SVG) { double scale = adjustScaleFactor(allowFloatScaling, ctx.getScale(PIX_SCALE)); if (desc.scale > 1) scale /= desc.scale; // compensate the image original scale source = scaleImage(source, scale); } return source; } }). withHiDPI(ctx), useCache); }
Example #19
Source Project: intellij Author: bazelbuild File: SdkUtil.java License: Apache License 2.0 | 6 votes |
/** * Check if sdk is not null and have path to expected files (android.jar and res/). If it does not * have expected content, this sdk will be removed from jdktable. * * @param sdk sdk to check * @return true if sdk is valid */ public static boolean checkSdkAndRemoveIfInvalid(@Nullable Sdk sdk) { if (sdk == null) { return false; } else if (containsJarAndRes(sdk)) { return true; } else { ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); logger.info( String.format( "Some classes of Sdk %s is missing. Trying to remove and reinstall it.", sdk.getName())); EventLoggingService.getInstance().logEvent(SdkUtil.class, "Invalid SDK"); Application application = ApplicationManager.getApplication(); if (application.isDispatchThread()) { WriteAction.run(() -> jdkTable.removeJdk(sdk)); } else { UIUtil.invokeAndWaitIfNeeded( (Runnable) () -> WriteAction.run(() -> jdkTable.removeJdk(sdk))); } return false; } }
Example #20
Source Project: consulo Author: consulo File: ConsoleViewImpl.java License: Apache License 2.0 | 5 votes |
private void runHeavyFilters(int line1, int endLine) { final int startLine = Math.max(0, line1); final Document document = myEditor.getDocument(); final int startOffset = document.getLineStartOffset(startLine); String text = document.getText(new TextRange(startOffset, document.getLineEndOffset(endLine))); final Document documentCopy = new DocumentImpl(text, true); documentCopy.setReadOnly(true); myJLayeredPane.startUpdating(); final int currentValue = myHeavyUpdateTicket; myHeavyAlarm.addRequest(() -> { if (!myFilters.shouldRunHeavy()) return; try { myFilters.applyHeavyFilter(documentCopy, startOffset, startLine, additionalHighlight -> addFlushRequest(0, new FlushRunnable(true) { @Override public void doRun() { if (myHeavyUpdateTicket != currentValue) return; TextAttributes additionalAttributes = additionalHighlight.getTextAttributes(null); if (additionalAttributes != null) { ResultItem item = additionalHighlight.getResultItems().get(0); myHyperlinks.addHighlighter(item.getHighlightStartOffset(), item.getHighlightEndOffset(), additionalAttributes); } else { myHyperlinks.highlightHyperlinks(additionalHighlight, 0); } } })); } catch (IndexNotReadyException ignore) { } finally { if (myHeavyAlarm.getActiveRequestCount() <= 1) { // only the current request UIUtil.invokeLaterIfNeeded(() -> myJLayeredPane.finishUpdating()); } } }, 0); }
Example #21
Source Project: saros Author: saros-project File: SessionAndContactsTreeView.java License: GNU General Public License v2.0 | 5 votes |
/** * Displays the '[email protected] (connected)' string and populates the contact list. * * <p>Called after a connection was made. */ private void renderConnected() { UIUtil.invokeLaterIfNeeded( () -> { if (project.isDisposed()) { return; } JID userJID = connectionHandler.getLocalJID(); if (userJID == null) return; getSarosTreeRootNode().setTitle(userJID.getBareJID().toString()); updateTree(); }); }
Example #22
Source Project: consulo Author: consulo File: XDebuggerTree.java License: Apache License 2.0 | 5 votes |
@Override public void dispose() { // clear all possible inner fields that may still have links to debugger objects setModel(null); myTreeModel.setRoot(null); setCellRenderer(null); UIUtil.dispose(this); setLeadSelectionPath(null); setAnchorSelectionPath(null); removeComponentListener(myMoveListener); myListeners.clear(); }
Example #23
Source Project: consulo Author: consulo File: SimpleTree.java License: Apache License 2.0 | 5 votes |
@Deprecated public Icon getCollapsedHandle() { if (myCollapsedHandle == null) { myCollapsedHandle = UIUtil.getTreeCollapsedIcon(); } return myCollapsedHandle; }
Example #24
Source Project: consulo Author: consulo File: RunnerContentUi.java License: Apache License 2.0 | 5 votes |
@Override public void dragOutFinished(MouseEvent event, TabInfo source) { final Component component = event.getComponent(); final IdeFrame window = UIUtil.getParentOfType(IdeFrame.class, component); mySession.process(event); mySession = null; }
Example #25
Source Project: yiistorm Author: cmazx File: IdeHelper.java License: MIT License | 5 votes |
public static void showDialog(final Project project, final String message, final String title, final Icon icon) { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { Messages.showMessageDialog(project, message, title, icon); } }); }
Example #26
Source Project: consulo Author: consulo File: StatisticsConfigurationComponent.java License: Apache License 2.0 | 5 votes |
public StatisticsConfigurationComponent() { String product = ApplicationNamesInfo.getInstance().getFullProductName(); String company = ApplicationInfo.getInstance().getCompanyName(); myTitle.setText(StatisticsBundle.message("stats.title", product, company)); myLabel.setText(StatisticsBundle.message("stats.config.details", company)); myLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); myAllowToSendUsagesCheckBox.setText(StatisticsBundle.message("stats.config.allow.send.stats.text", company)); myAllowToSendUsagesCheckBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setRadioButtonsEnabled(); } }); }
Example #27
Source Project: consulo Author: consulo File: DarculaSpinnerBorder.java License: Apache License 2.0 | 5 votes |
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { final JSpinner spinner = (JSpinner)c; final JFormattedTextField editor = UIUtil.findComponentOfType(spinner, JFormattedTextField.class); final int x1 = x + JBUI.scale(3); final int y1 = y + JBUI.scale(3); final int width1 = width - JBUI.scale(8); final int height1 = height - JBUI.scale(6); final boolean focused = c.isEnabled() && c.isVisible() && editor != null && editor.hasFocus(); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); if (c.isOpaque()) { g.setColor(UIUtil.getPanelBackground()); g.fillRect(x, y, width, height); } g.setColor(UIUtil.getTextFieldBackground()); g.fillRoundRect(x1, y1, width1, height1, JBUI.scale(5), JBUI.scale(5)); g.setColor(UIUtil.getPanelBackground()); if (editor != null) { final int off = editor.getBounds().x + editor.getWidth() + ((JSpinner)c).getInsets().left + JBUI.scale(1); g.fillRect(off, y1, JBUI.scale(17), height1); g.setColor(Gray._100); g.drawLine(off, y1, off, height1 + JBUI.scale(2)); } if (!c.isEnabled()) { ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); } if (focused) { DarculaUIUtil.paintFocusRing(g, new Rectangle(x1, y1, width1, height1)); } else { g.setColor(Gray._100); g.drawRoundRect(x1, y1, width1, height1, JBUI.scale(5), JBUI.scale(5)); } config.restore(); }
Example #28
Source Project: consulo Author: consulo File: TreeTableTree.java License: Apache License 2.0 | 5 votes |
@Override public void updateUI() { super.updateUI(); TreeCellRenderer tcr = super.getCellRenderer(); if (tcr instanceof DefaultTreeCellRenderer) { DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)tcr; dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground()); dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground()); } }
Example #29
Source Project: consulo Author: consulo File: DarculaTableHeaderUI.java License: Apache License 2.0 | 5 votes |
@Override public void paint(Graphics g2, JComponent c) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final Color bg = c.getBackground(); g.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(bg, 1.4), 0, c.getHeight(), ColorUtil.shift(bg, 0.9))); final int h = c.getHeight(); final int w = c.getWidth(); g.fillRect(0,0, w, h); g.setPaint(ColorUtil.shift(bg, 0.75)); g.drawLine(0, h-1, w, h-1); g.drawLine(w-1, 0, w-1, h-1); final Enumeration<TableColumn> columns = ((JTableHeader)c).getColumnModel().getColumns(); final Color lineColor = ColorUtil.shift(bg, 0.7); final Color shadow = Gray._255.withAlpha(30); int offset = 0; while (columns.hasMoreElements()) { final TableColumn column = columns.nextElement(); if (columns.hasMoreElements() && column.getWidth() > 0) { offset += column.getWidth(); g.setColor(lineColor); g.drawLine(offset-1, 1, offset-1, h-3); g.setColor(shadow); g.drawLine(offset, 1, offset, h-3); } } config.restore(); super.paint(g, c); }
Example #30
Source Project: consulo Author: consulo File: AWTIconLoaderFacade.java License: Apache License 2.0 | 5 votes |
/** * Creates new icon with the filter applied. */ @Nullable public static Icon filterIcon(@Nonnull Icon icon, RGBImageFilter filter, @Nullable Component ancestor) { if (icon instanceof DesktopLazyImageImpl) icon = ((DesktopLazyImageImpl)icon).getOrComputeIcon(); if (icon == null) return null; if (!isGoodSize(icon)) { LOG.error(icon); // # 22481 return EMPTY_ICON; } if (icon instanceof CachedImageIcon) { icon = ((CachedImageIcon)icon).asDisabledIcon(); } else { final float scale; if (icon instanceof JBUI.ScaleContextAware) { scale = (float)((JBUI.ScaleContextAware)icon).getScale(SYS_SCALE); } else { scale = UIUtil.isJreHiDPI() ? JBUI.sysScale(ancestor) : 1f; } @SuppressWarnings("UndesirableClassUsage") BufferedImage image = new BufferedImage((int)(scale * icon.getIconWidth()), (int)(scale * icon.getIconHeight()), BufferedImage.TYPE_INT_ARGB); final Graphics2D graphics = image.createGraphics(); graphics.setColor(UIUtil.TRANSPARENT_COLOR); graphics.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); graphics.scale(scale, scale); icon.paintIcon(LabelHolder.ourFakeComponent, graphics, 0, 0); graphics.dispose(); Image img = ImageUtil.filter(image, filter); if (UIUtil.isJreHiDPI()) img = RetinaImage.createFrom(img, scale, null); icon = new JBImageIcon(img); } return icon; }