public final synchronized void removeTabAt(final int index) { assertIsDispatchThread(); final boolean hadFocus = IJSwingUtilities.hasFocus2(myTabbedPaneHolder); final TabWrapper wrapper = getWrapperAt(index); try { myTabbedPane.removeTabAt(index); if (myTabbedPane.getTabCount() == 0) { // to clear BasicTabbedPaneUI.visibleComponent field myTabbedPane.revalidate(); } if (hadFocus) { myTabbedPaneHolder.requestFocus(); } } finally { wrapper.dispose(); } }
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) { String aText = String.valueOf(c.getToolTipText(me)); final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, /*new Object()*/c, aText) { @Override protected boolean beforeShow() { myCurrentEvent = me; if (!c.isShowing()) return false; String text = c.getToolTipText(myCurrentEvent); if (text == null || text.trim().isEmpty()) return false; JLayeredPane layeredPane = IJSwingUtilities.findParentOfType(c, JLayeredPane.class); final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane); final Wrapper wrapper = new Wrapper(pane); setTipComponent(wrapper); return true; } }.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top); show(tooltip, false); }
public static void updateToolWindows() { for (Project project : ProjectManager.getInstance().getOpenProjects()) { final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); for (String id : toolWindowManager.getToolWindowIds()) { final ToolWindow toolWindow = toolWindowManager.getToolWindow(id); for (Content content : toolWindow.getContentManager().getContents()) { final JComponent component = content.getComponent(); if (component != null) { IJSwingUtilities.updateComponentTreeUI(component); } } final JComponent c = toolWindow.getComponent(); if (c != null) { IJSwingUtilities.updateComponentTreeUI(c); } } } }
public void refreshIntentionHint() { if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){ hideIntentionHint(); return; } if (myHint == null || !myHint.isVisible()) { updateIntentionHintVisibility(); } else { final ErrorInfo[] errorInfos = getErrorInfos(); final Rectangle bounds = getErrorBounds(); if (!haveFixes(errorInfos) || bounds == null || !bounds.equals(myLastHintBounds)) { hideIntentionHint(); updateIntentionHintVisibility(); } } }
private boolean showSelectedColumnProperties() { if (myCustomPropertiesPanel != null && myPropertiesPanelContainer != null && IJSwingUtilities.hasFocus(myCustomPropertiesPanel.getComponent())) { return true; } if (myEditor == null) return false; GridCaptionPanel panel = myEditor.getFocusedCaptionPanel(); if (panel == null) return false; RadContainer container = panel.getSelectedContainer(); if (container == null) return false; final int[] selection = panel.getSelectedCells(null); myPropertiesPanelContainer = container; final CustomPropertiesPanel propertiesPanel = container.getGridLayoutManager().getRowColumnPropertiesPanel(container, panel.isRow(), selection); if (propertiesPanel == null) return false; showCustomPropertiesPanel(propertiesPanel); return true; }
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) { final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, new Object()) { @Override protected boolean beforeShow() { myCurrentEvent = me; if (!c.isShowing()) return false; String text = c.getToolTipText(myCurrentEvent); if (text == null || text.trim().isEmpty()) return false; JLayeredPane layeredPane = IJSwingUtilities.findParentOfType(c, JLayeredPane.class); final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane); final Wrapper wrapper = new Wrapper(pane); setTipComponent(wrapper); return true; } }.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top); show(tooltip, false); }
public final synchronized void removeTabAt(final int index) { assertIsDispatchThread(); final boolean hadFocus = IJSwingUtilities.hasFocus2(myTabbedPaneHolder); final TabWrapper wrapper = getWrapperAt(index); try { myTabbedPane.removeTabAt(index); if (myTabbedPane.getTabCount() == 0) { // to clear BasicTabbedPaneUI.visibleComponent field myTabbedPane.revalidate(); } if (hadFocus) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myTabbedPaneHolder); } } finally { wrapper.dispose(); } }
protected void invokeRatherLater(final DebuggerCommandImpl command) { IJSwingUtilities.invoke(new Runnable() { @Override public void run() { InvokeRatherLaterRequest request = new InvokeRatherLaterRequest(command, getDebugProcess()); myRatherLaterRequests.add(request); if (myRatherLaterRequests.size() == 1) pumpSwingThread(); } }); }
protected static void positionCaretToDeclaration(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement declaration) { final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor != null && (IJSwingUtilities.hasFocus(editor.getComponent()) || ApplicationManager.getApplication().isUnitTestMode())) { final PsiFile openedFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (openedFile == psiFile) { editor.getCaretModel().moveToOffset(declaration.getTextOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } }
private void updateContentUI() { if (myActiveContentComponent == null || myActiveFocusedContent == null) return; IJSwingUtilities.updateComponentTreeUI(myActiveContentComponent); if (myActiveContentComponent instanceof JScrollPane) { ((JScrollPane)myActiveContentComponent).getViewport().setBackground(myActiveFocusedContent.getBackground()); } myActiveContentComponent.setBorder(null); }
@Override public boolean isFocusOwner() { if (myEditor != null) { return IJSwingUtilities.hasFocus(myEditor.getContentComponent()); } return super.isFocusOwner(); }
public final void setSelectedIndex(final int index, boolean requestFocus) { assertIsDispatchThread(); final boolean hadFocus = IJSwingUtilities.hasFocus2(myTabbedPaneHolder); myTabbedPane.setSelectedIndex(index); if (hadFocus && requestFocus) { myTabbedPaneHolder.requestFocus(); } }
public static JPanel createLabeledPanel(String labelText, JComponent component) { final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false)); final JBLabel label = new JBLabel(labelText, UIUtil.ComponentStyle.SMALL); IJSwingUtilities.adjustComponentsOnMac(label, component); panel.add(label); panel.add(component); return panel; }
private static void updateUI(Window window) { if (!window.isDisplayable()) { return; } IJSwingUtilities.updateComponentTreeUI(window); Window[] children = window.getOwnedWindows(); for (Window aChildren : children) { updateUI(aChildren); } }
@Override public void navigate(Project project) { NotificationListener listener = myNotification.getListener(); if (listener != null) { EventLogConsole console = ObjectUtils.assertNotNull(getProjectComponent(project).getConsole(myNotification)); JComponent component = console.getConsoleEditor().getContentComponent(); listener.hyperlinkUpdate(myNotification, IJSwingUtilities.createHyperlinkEvent(myHref, component)); } }
@Override public void onEnterStep() { super.onEnterStep(); if (!myComponentUpdated) { // Update the UI after a potential color theme change. // If this is missing and a user selects the darcula color theme, the colors // in all subsequent pages will be wrong (a mix of darcula and default). IJSwingUtilities.updateComponentTreeUI(myComponent); myComponentUpdated = true; } }
/** * Shows intention hint (light bulb) if it's not visible yet. */ final void showIntentionHint(){ if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){ hideIntentionHint(); return; } // 1. Hide previous hint (if any) hideIntentionHint(); // 2. Found error (if any) final ErrorInfo[] errorInfos = getErrorInfos(); if(!haveFixes(errorInfos)) { hideIntentionHint(); return; } // 3. Determine position where this hint should be shown final Rectangle bounds = getErrorBounds(); if(bounds == null){ return; } // 4. Show light bulb to fix this error final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb); myHint = new LightweightHint(lightBulbComponent); myLastHintBounds = bounds; myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation())); }
public void update() { if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) { hideHint(); } else if (myHint == null || !myHint.isVisible()) { updateHintVisibility(); } else { Rectangle bounds = getErrorBounds(); if (!ErrorInfo.haveFixes(getErrorInfos()) || bounds == null || !bounds.equals(myLastHintBounds)) { hideHint(); updateHintVisibility(); } } }
private void showHint() { if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) { hideHint(); return; } // 1. Hide previous hint (if any) hideHint(); // 2. Found error (if any) List<ErrorInfo> infos = getErrorInfos(); if (!ErrorInfo.haveFixes(infos)) { hideHint(); return; } boolean error = false; for (ErrorInfo errorInfo : infos) { if (errorInfo.getLevel() == HighlightDisplayLevel.ERROR) { error = true; break; } } // 3. Determine position where this hint should be shown Rectangle bounds = getErrorBounds(); if (bounds == null) { return; } // 4. Show light bulb to fix this error myHint = new LightweightHint(new InspectionHint(error ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb)); myLastHintBounds = bounds; myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation())); }
@Override public void navigate(Project project) { NotificationListener listener = myNotification.getListener(); if(listener != null) { ConsoleLogConsole console = ObjectUtils.assertNotNull(getProjectComponent(project).getConsole(myNotification)); JComponent component = console.getConsoleEditor().getContentComponent(); listener.hyperlinkUpdate(myNotification, IJSwingUtilities.createHyperlinkEvent(myHref, component)); } }
public void setInitialBreakpointsState() { myAllowMulticasting = false; for (final EnableBreakpointRule myBreakpointRule : myBreakpointRules) { myBreakpointRule.init(); } myAllowMulticasting = true; if (!myBreakpointRules.isEmpty()) { IJSwingUtilities.invoke(new Runnable() { @Override public void run() { myDispatcher.getMulticaster().breakpointsChanged(); } }); } }
private static void moveCaretTo(final PsiElement newCaretPosition) { Project project = newCaretPosition.getProject(); final PsiFile psiFile = newCaretPosition.getContainingFile(); final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (editor != null && IJSwingUtilities.hasFocus(editor.getComponent())) { final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == psiFile) { editor.getCaretModel().moveToOffset(newCaretPosition.getTextRange().getEndOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); } } }
void updateCaretCursor() { if (!ourIsUnitTestMode && !IJSwingUtilities.hasFocus(getContentComponent())) { stopOptimizedScrolling(); } myUpdateCursor = true; }
@Override public void navigate(Project project) { NotificationListener listener = myNotification.getListener(); if (listener != null) { JComponent component = getProjectComponent(project).myConsole.getConsoleEditor().getContentComponent(); listener.hyperlinkUpdate(myNotification, IJSwingUtilities.createHyperlinkEvent(myHref, component)); } }