public TipManager(final JComponent component, TipFactory factory) { myTipFactory = factory; myComponent = component; new UiNotifyConnector.Once(component, new Activatable() { @Override public void showNotify() { installListeners(); } @Override public void hideNotify() { } }); final HideTooltipAction hide = new HideTooltipAction(); hide.registerCustomShortcutSet(CommonShortcuts.ESCAPE, myComponent); Disposer.register(this, new Disposable() { @Override public void dispose() { hide.unregisterCustomShortcutSet(myComponent); } }); }
public static void installPainter(final JComponent target, final Painter painter, final Disposable parent) { final UiNotifyConnector connector = new UiNotifyConnector(target, new Activatable() { IdeGlassPane myPane; public void showNotify() { IdeGlassPane pane = find(target); if (myPane != null && myPane != pane) { myPane.removePainter(painter); } myPane = pane; myPane.addPainter(target, painter, parent); } public void hideNotify() { if (myPane != null) { myPane.removePainter(painter); } } }); Disposer.register(parent, connector); }
public void start() { if (myGlassPane != null) return; new UiNotifyConnector(myDragComponent, new Activatable() { public void showNotify() { attach(); } public void hideNotify() { detach(true); } }); Disposer.register(myParentDisposable, new Disposable() { public void dispose() { stop(); } }); }
public Alarm setActivationComponent(@NotNull final JComponent component) { myActivationComponent = component; new UiNotifyConnector(component, new Activatable() { @Override public void showNotify() { flushPending(); } @Override public void hideNotify() { } }); return this; }
public AbstractTreeUpdater(@NotNull AbstractTreeBuilder treeBuilder) { myTreeBuilder = treeBuilder; final JTree tree = myTreeBuilder.getTree(); final JComponent component = tree instanceof TreeTableTree ? ((TreeTableTree)tree).getTreeTable() : tree; myUpdateQueue = new MergingUpdateQueue("UpdateQueue", 300, component.isShowing(), component) { @Override protected Alarm createAlarm(@NotNull Alarm.ThreadToUse thread, Disposable parent) { return new Alarm(thread, parent) { @Override protected boolean isEdt() { return AbstractTreeUpdater.this.isEdt(); } }; } }; myUpdateQueue.setRestartTimerOnAdd(false); final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(component, myUpdateQueue); Disposer.register(this, myUpdateQueue); Disposer.register(this, uiNotifyConnector); }
private void updateActions(boolean now, final boolean transparentOnly, final boolean forced) { final Runnable updateRunnable = new MyUpdateRunnable(this, transparentOnly, forced); final Application app = ApplicationManager.getApplication(); if (now || app.isUnitTestMode()) { updateRunnable.run(); } else { final IdeFocusManager fm = IdeFocusManager.getInstance(null); if (!app.isHeadlessEnvironment()) { if (app.isDispatchThread() && myComponent.isShowing()) { fm.doWhenFocusSettlesDown(updateRunnable); } else { UiNotifyConnector.doWhenFirstShown(myComponent, new Runnable() { @Override public void run() { fm.doWhenFocusSettlesDown(updateRunnable); } }); } } } }
private static void updateWhenFirstShown(JComponent targetComponent, final ToolbarReference ref) { Activatable activatable = new Activatable.Adapter() { public void showNotify() { ActionToolbarImpl toolbar = ref.get(); if (toolbar != null) { toolbar.myUpdater.updateActions(false, false); } } }; ref.myDisposable = new UiNotifyConnector(targetComponent, activatable) { @Override protected void showNotify() { super.showNotify(); ref.disposeReference(); } }; }
public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) { ConfigurableGroup[] group = getConfigurableGroups(project, true); group = filterEmptyGroups(group); final Configurable configurable2Select = id2Select == null ? null : new ConfigurableVisitor.ByID(id2Select).find(group); if (Registry.is("ide.new.settings.view")) { new SettingsDialog(getProject(project), group, configurable2Select, filter).show(); return; } final DialogWrapper dialog = getDialog(project, group, configurable2Select); new UiNotifyConnector.Once(dialog.getContentPane(), new Activatable.Adapter() { @Override public void showNotify() { final OptionsEditor editor = (OptionsEditor)((DataProvider)dialog).getData(OptionsEditor.KEY.getName()); LOG.assertTrue(editor != null); editor.select(configurable2Select, filter); } }); dialog.show(); }
public static void initAsyncComboBoxModel(@NotNull final JComboBox jComboBox, @NotNull final String groupId, final URL... localUrls) { final List<Object> items = new ArrayList<Object>(); new UiNotifyConnector.Once(jComboBox, new Activatable() { @Override public void showNotify() { loadItems(jComboBox, items, groupId, localUrls); } @Override public void hideNotify() { } }); items.add("loading..."); jComboBox.setModel(new CollectionComboBoxModel(items, items.get(0))); jComboBox.setEnabled(false); }
public MyChangesBrowser(@NotNull Project project, @NotNull List<Change> changes, @Nullable final Change currentChange, @NotNull Ref<JBPopup> popup) { super(project, null, changes, null, false, false, null, MyUseCase.LOCAL_CHANGES, null); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setChangesToDisplay(changes); UiNotifyConnector.doWhenFirstShown(this, new Runnable() { @Override public void run() { if (currentChange != null) select(Collections.singletonList(currentChange)); } }); myPopup = popup; }
public void reset() { myTemplateOptions.clear(); myTemplateContext.clear(); TemplateSettings templateSettings = TemplateSettings.getInstance(); List<TemplateGroup> groups = getSortedGroups(templateSettings); initTemplates(groups, templateSettings.getLastSelectedTemplateGroup(), templateSettings.getLastSelectedTemplateKey()); myExpandByDefaultPanel.setSelectedChar(templateSettings.getDefaultShortcutChar()); UiNotifyConnector.doWhenFirstShown(this, new Runnable() { @Override public void run() { updateTemplateDetails(false, false); } }); myUpdateNeeded = true; }
public void onSomethingChanged() { setSomethingChanged(true); if (myEditor != null) { if (ApplicationManager.getApplication().isUnitTestMode()) { updateEditor(true); } else { UiNotifyConnector.doWhenFirstShown(myEditor.getComponent(), new Runnable() { @Override public void run() { addUpdatePreviewRequest(); } }); } } }
public static void showRerunNotification(@Nullable RunContentDescriptor contentToReuse, @NotNull final ExecutionConsole executionConsole) { if (contentToReuse == null) { return; } String lastActionId = ActionManagerEx.getInstanceEx().getPrevPreformedActionId(); boolean showNotification = !RerunTestsAction.ID.equals(lastActionId); if (showNotification && !PropertiesComponent.getInstance().isTrueValue(KEY)) { UiNotifyConnector.doWhenFirstShown(executionConsole.getComponent(), new Runnable() { @Override public void run() { doShow(executionConsole); } }); } }
public ScopeTreeViewPanel(@NotNull Project project) { super(new BorderLayout()); myUpdateQueue.setPassThrough(false); // we don't want passthrough mode, even in unit tests myProject = project; initTree(); add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER); myDependencyValidationManager = DependencyValidationManager.getInstance(myProject); final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(myTree, myUpdateQueue); Disposer.register(this, myUpdateQueue); Disposer.register(this, uiNotifyConnector); if (isTreeShowing()) { myUpdateQueue.showNotify(); } }
protected JComponent createComponent() { final JPanel panel = new MyPanel(); final JPanel toolbarPanel = new JPanel(new GridBagLayout()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; toolbarPanel.add(myFileSystemToolBar.getComponent(), constraints); constraints.gridx = 1; constraints.weightx = 1.0; constraints.anchor = GridBagConstraints.EAST; toolbarPanel.add(myTextFieldAction, constraints); myNorthPanel.add(toolbarPanel, BorderLayout.NORTH); panel.add(myNorthPanel, BorderLayout.NORTH); panel.add(ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()), BorderLayout.CENTER); panel.add(new JLabel(FileChooserDialogImpl.DRAG_N_DROP_HINT, SwingConstants.CENTER), BorderLayout.SOUTH); myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel); Disposer.register(myFileSystemTree, myUiUpdater); new UiNotifyConnector(panel, myUiUpdater); updateTextFieldShowing(); return panel; }
public TipManager(final JComponent component, TipFactory factory) { myTipFactory = factory; myComponent = component; new UiNotifyConnector.Once(component, new Activatable() { public void showNotify() { installListeners(); } public void hideNotify() { } }); final HideTooltipAction hide = new HideTooltipAction(); hide.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), myComponent); Disposer.register(this, new Disposable() { public void dispose() { hide.unregisterCustomShortcutSet(myComponent); } }); }
protected JComponent createComponent() { final JPanel panel = new MyPanel(); final JPanel toolbarPanel = new JPanel(new GridBagLayout()); final GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; toolbarPanel.add(myFileSystemToolBar.getComponent(), constraints); constraints.gridx = 1; constraints.weightx = 1.0; constraints.anchor = GridBagConstraints.EAST; toolbarPanel.add(myTextFieldAction, constraints); myNorthPanel.add(toolbarPanel, BorderLayout.NORTH); panel.add(myNorthPanel, BorderLayout.NORTH); panel.add(ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()), BorderLayout.CENTER); panel.add(new JLabel( "<html><center><small><font color=gray>Drag and drop a file into the space above to quickly locate it in the tree.</font></small></center></html>", SwingConstants.CENTER), BorderLayout.SOUTH); myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel); Disposer.register(myFileSystemTree, myUiUpdater); new UiNotifyConnector(panel, myUiUpdater); updateTextFieldShowing(); return panel; }
@Nonnull public Alarm setActivationComponent(@Nonnull final JComponent component) { myActivationComponent = component; //noinspection ResultOfObjectAllocationIgnored new UiNotifyConnector(component, new Activatable() { @Override public void showNotify() { flushPending(); } @Override public void hideNotify() { } }); return this; }
public AbstractTreeUpdater(@Nonnull AbstractTreeBuilder treeBuilder) { myTreeBuilder = treeBuilder; final JTree tree = myTreeBuilder.getTree(); final JComponent component = tree instanceof TreeTableTree ? ((TreeTableTree)tree).getTreeTable() : tree; myUpdateQueue = new MergingUpdateQueue("UpdateQueue", 100, component.isShowing(), component) { @Override protected Alarm createAlarm(@Nonnull Alarm.ThreadToUse thread, Disposable parent) { return new Alarm(thread, parent) { @Override protected boolean isEdt() { return AbstractTreeUpdater.this.isEdt(); } }; } }; myUpdateQueue.setRestartTimerOnAdd(false); final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(component, myUpdateQueue); Disposer.register(this, myUpdateQueue); Disposer.register(this, uiNotifyConnector); }
private void updateActions(boolean now, final boolean transparentOnly, final boolean forced) { final Runnable updateRunnable = new MyUpdateRunnable(this, transparentOnly, forced); final Application app = ApplicationManager.getApplication(); if (now || app.isUnitTestMode()) { updateRunnable.run(); } else { final IdeFocusManager fm = IdeFocusManager.getInstance(null); if (!app.isHeadlessEnvironment()) { if (app.isDispatchThread() && myComponent.isShowing()) { fm.doWhenFocusSettlesDown(updateRunnable); } else { UiNotifyConnector.doWhenFirstShown(myComponent, () -> fm.doWhenFocusSettlesDown(updateRunnable)); } } } }
public MyChangesBrowser(@Nonnull Project project, @Nonnull List<Change> changes, @Nullable final Change currentChange, @Nonnull Ref<JBPopup> popup) { super(project, null, changes, null, false, false, null, MyUseCase.LOCAL_CHANGES, null); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setChangesToDisplay(changes); UiNotifyConnector.doWhenFirstShown(this, new Runnable() { @Override public void run() { if (currentChange != null) select(Collections.singletonList(currentChange)); } }); myPopup = popup; }
public ScopeTreeViewPanel(final Project project) { super(new BorderLayout()); myUpdateQueue.setPassThrough(false); // we don't want passthrough mode, even in unit tests myProject = project; initTree(); add(ScrollPaneFactory.createScrollPane(myTree), BorderLayout.CENTER); myDependencyValidationManager = DependencyValidationManager.getInstance(myProject); final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(myTree, myUpdateQueue); Disposer.register(this, myUpdateQueue); Disposer.register(this, uiNotifyConnector); if (isTreeShowing()) { myUpdateQueue.showNotify(); } }
@RequiredUIAccess @Override protected void init(boolean canCloseContent, @Nullable Object component) { final ContentFactory contentFactory = ContentFactory.getInstance(); myContentUI = new DesktopToolWindowContentUi(this); ContentManager contentManager = myContentManager = contentFactory.createContentManager(myContentUI, canCloseContent, myToolWindowManager.getProject()); if (component != null) { final Content content = contentFactory.createContent((JComponent)component, "", false); contentManager.addContent(content); contentManager.setSelectedContent(content, false); } myComponent = contentManager.getComponent(); installToolwindowFocusPolicy(); UiNotifyConnector notifyConnector = new UiNotifyConnector(myComponent, new Activatable.Adapter() { @Override public void showNotify() { myShowing.onReady(); } }); Disposer.register(contentManager, notifyConnector); }
public ArtifactErrorPanel(final ArtifactEditorImpl artifactEditor) { myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning); new UiNotifyConnector(myMainPanel, new Activatable.Adapter() { @Override public void showNotify() { if (myErrorText != null) { myErrorLabel.setText(myErrorText); myErrorText = null; } } }); myFixButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!myCurrentQuickFixes.isEmpty()) { if (myCurrentQuickFixes.size() == 1) { performFix(ContainerUtil.getFirstItem(myCurrentQuickFixes, null), artifactEditor); } else { JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myCurrentQuickFixes) { @NotNull @Override public String getTextFor(ConfigurationErrorQuickFix value) { return value.getActionName(); } @Override public PopupStep onChosen(ConfigurationErrorQuickFix selectedValue, boolean finalChoice) { performFix(selectedValue, artifactEditor); return FINAL_CHOICE; } }).showUnderneathOf(myFixButton); } } } }); clearError(); }
public Divider(boolean isFirst, boolean isOnePixel) { super(new GridBagLayout()); myIsOnePixel = isOnePixel; setFocusable(false); enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK); myIsFirst = isFirst; setOrientation(myVerticalSplit); new UiNotifyConnector.Once(this, new Activatable.Adapter() { @Override public void showNotify() { init(); } }); }
public ShadowAction(AnAction action, AnAction copyFromAction, JComponent component) { myAction = action; myCopyFromAction = copyFromAction; myComponent = component; myActionId = ActionManager.getInstance().getId(myCopyFromAction); myAction.getTemplatePresentation().copyFrom(copyFromAction.getTemplatePresentation()); myKeymapListener = new Keymap.Listener() { @Override public void onShortcutChanged(final String actionId) { if (myActionId == null || actionId.equals(myActionId)) { rebound(); } } }; myKeymapManagerListener = new KeymapManagerListener() { @Override public void activeKeymapChanged(final Keymap keymap) { rebound(); } }; myUiNotify = new UiNotifyConnector(myComponent, new Activatable() { @Override public void showNotify() { _connect(); } @Override public void hideNotify() { disconnect(); } }); }
private static void requestFocusTo(final JComponent component) { UiNotifyConnector.doWhenFirstShown(component, new Runnable() { @Override public void run() { final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(component); focusManager.requestFocus(component, false); } }); }
public MemoryUsagePanel() { setOpaque(false); setFocusable(false); addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.gc(); updateState(); } }); setBorder(StatusBarWidget.WidgetBorder.INSTANCE); updateUI(); new UiNotifyConnector(this, new Activatable() { private ScheduledFuture<?> myFuture; @Override public void showNotify() { myFuture = JobScheduler.getScheduler().scheduleWithFixedDelay(new Runnable() { public void run() { if (isDisplayable()) { updateState(); } } }, 1, 5, TimeUnit.SECONDS); } @Override public void hideNotify() { if (myFuture != null) { myFuture.cancel(true); myFuture = null; } } }); }
ToolWindowImpl(final ToolWindowManagerImpl toolWindowManager, final String id, boolean canCloseContent, @Nullable final JComponent component) { myToolWindowManager = toolWindowManager; myChangeSupport = new PropertyChangeSupport(this); myId = id; myAvailable = true; final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class); myContentUI = new ToolWindowContentUi(this); myContentManager = contentFactory.createContentManager(myContentUI, canCloseContent, toolWindowManager.getProject()); if (component != null) { final Content content = contentFactory.createContent(component, "", false); myContentManager.addContent(content); myContentManager.setSelectedContent(content, false); } myComponent = myContentManager.getComponent(); UiNotifyConnector notifyConnector = new UiNotifyConnector(myComponent, new Activatable.Adapter() { @Override public void showNotify() { myShowing.onReady(); } }); Disposer.register(myContentManager, notifyConnector); }