Java Code Examples for com.intellij.util.ui.UIUtil#getClientProperty()
The following examples show how to use
com.intellij.util.ui.UIUtil#getClientProperty() .
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 File: MnemonicHelper.java From consulo with 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 2
Source File: EditorTextFieldCellRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private RendererComponent getEditorPanel(final JTable table) { RendererComponent panel = UIUtil.getClientProperty(table, MY_PANEL_PROPERTY); if (panel != null) { DelegateColorScheme scheme = (DelegateColorScheme)panel.getEditor().getColorsScheme(); scheme.setDelegate(EditorColorsManager.getInstance().getGlobalScheme()); return panel; } panel = createRendererComponent(myProject, myFileType, myInheritFontFromLaF); Disposer.register(this, panel); Disposer.register(this, new Disposable() { @Override public void dispose() { UIUtil.putClientProperty(table, MY_PANEL_PROPERTY, null); } }); table.putClientProperty(MY_PANEL_PROPERTY, panel); return panel; }
Example 3
Source File: MacButtonlessScrollbarUI.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) { g.setColor(getTrackBackground()); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.setColor(getTrackBorderColor()); if (isVertical()) { g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height); } else { g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); } RegionPainter<Object> painter = UIUtil.getClientProperty(c, ScrollBarUIConstants.TRACK); if (painter != null) { painter.paint((Graphics2D)g, bounds.x, bounds.y, bounds.width, bounds.height, null); } }
Example 4
Source File: IntelliJButtonlessScrollBarUI.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) { g.setColor(getTrackBackground()); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.setColor(getTrackBorderColor()); if (isVertical()) { g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height); } else { g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); } RegionPainter<Object> painter = UIUtil.getClientProperty(c, ScrollBarUIConstants.TRACK); if (painter != null) { painter.paint((Graphics2D)g, bounds.x, bounds.y, bounds.width, bounds.height, null); } }
Example 5
Source File: TouchbarDataKeys.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull static DlgButtonDesc putDialogButtonDescriptor(@Nonnull JButton button, int orderIndex, boolean isMainGroup) { DlgButtonDesc result = UIUtil.getClientProperty(button, DIALOG_BUTTON_DESCRIPTOR_KEY); if (result == null) UIUtil.putClientProperty(button, DIALOG_BUTTON_DESCRIPTOR_KEY, result = new DlgButtonDesc(orderIndex)); result.setMainGroup(isMainGroup); return result; }
Example 6
Source File: TreeState.java From consulo with Apache License 2.0 | 5 votes |
@Override public ActionCallback getInitialized() { WeakReference<ActionCallback> ref = UIUtil.getClientProperty(tree, CALLBACK); ActionCallback callback = SoftReference.dereference(ref); if (callback != null) return callback; return ActionCallback.DONE; }
Example 7
Source File: TreeState.java From consulo with Apache License 2.0 | 5 votes |
/** * @deprecated Temporary solution to resolve simultaneous expansions with async tree model. * Note that the specified consumer must resolve async promise at the end. */ @Deprecated public static void expand(@Nonnull JTree tree, @Nonnull Consumer<? super AsyncPromise<Void>> consumer) { Promise<Void> expanding = UIUtil.getClientProperty(tree, EXPANDING); LOG.debug("EXPANDING: ", expanding); if (expanding == null) expanding = Promises.resolvedPromise(); expanding.onProcessed(value -> { AsyncPromise<Void> promise = new AsyncPromise<>(); UIUtil.putClientProperty(tree, EXPANDING, promise); consumer.accept(promise); }); }
Example 8
Source File: AnAction.java From consulo with Apache License 2.0 | 5 votes |
public final void registerCustomShortcutSet(@Nullable JComponent component, @Nullable consulo.disposer.Disposable parentDisposable) { if (component == null) return; List<AnAction> actionList = UIUtil.getClientProperty(component, ACTIONS_KEY); if (actionList == null) { UIUtil.putClientProperty(component, ACTIONS_KEY, actionList = new SmartList<>()); } if (!actionList.contains(this)) { actionList.add(this); } if (parentDisposable != null) { Disposer.register(parentDisposable, () -> unregisterCustomShortcutSet(component)); } }
Example 9
Source File: TextFieldWithPopupHandlerUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public String getTooltip() { String prefix = null; if (UIUtil.getClientProperty(getComponent(), INPLACE_HISTORY) != null) prefix = "Recent Search"; if (getActionOnClick() != null) prefix = "Search History"; return (prefix == null) ? null : prefix + " (" + KeymapUtil.getFirstKeyboardShortcutText("ShowSearchHistory") + ")"; }
Example 10
Source File: ModernButtonlessScrollBarUI.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) { g.setColor(new JBColor(LightColors.SLIGHTLY_GRAY, UIUtil.getListBackground())); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); RegionPainter<Object> painter = UIUtil.getClientProperty(c, ScrollBarUIConstants.TRACK); if (painter != null) { painter.paint((Graphics2D)g, bounds.x, bounds.y, bounds.width, bounds.height, null); } }
Example 11
Source File: AnAction.java From consulo with Apache License 2.0 | 4 votes |
public final void unregisterCustomShortcutSet(JComponent component) { List<AnAction> actionList = UIUtil.getClientProperty(component, ACTIONS_KEY); if (actionList != null) { actionList.remove(this); } }
Example 12
Source File: SwingActionDelegate.java From consulo with Apache License 2.0 | 4 votes |
protected JComponent getComponent(AnActionEvent event) { JComponent component = ComponentUtil.getParentOfType((Class<? extends JComponent>)JComponent.class, event.getData(CONTEXT_COMPONENT)); Function<String, JComponent> function = UIUtil.getClientProperty(component, FUNCTION); return function == null ? component : function.apply(mySwingActionId); }
Example 13
Source File: ModernButtonlessScrollBarUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected JButton createIncreaseButton(int orientation) { Supplier<? extends JButton> property = UIUtil.getClientProperty(scrollbar, ScrollBarUIConstants.INCREASE_BUTTON_FACTORY); return property == null ? new EmptyButton() : property.get(); }
Example 14
Source File: MacButtonlessScrollbarUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected JButton createIncreaseButton(int orientation) { Supplier<? extends JButton> property = UIUtil.getClientProperty(scrollbar, ScrollBarUIConstants.INCREASE_BUTTON_FACTORY); return property == null ? new EmptyButton() : property.get(); }
Example 15
Source File: IntelliJButtonlessScrollBarUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected JButton createIncreaseButton(int orientation) { Supplier<? extends JButton> property = UIUtil.getClientProperty(scrollbar, ScrollBarUIConstants.INCREASE_BUTTON_FACTORY); return property == null ? new EmptyButton() : property.get(); }