use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class Alarm method setActivationComponent.
@NotNull
public Alarm setActivationComponent(@NotNull final JComponent component) {
myActivationComponent = component;
//noinspection ResultOfObjectAllocationIgnored
new UiNotifyConnector(component, new Activatable() {
@Override
public void showNotify() {
flushPending();
}
@Override
public void hideNotify() {
}
});
return this;
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class AbstractTreeUi method init.
protected void init(@NotNull AbstractTreeBuilder builder, @NotNull JTree tree, @NotNull DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, @Nullable Comparator<NodeDescriptor> comparator, boolean updateIfInactive) {
myBuilder = builder;
myTree = tree;
myTreeModel = treeModel;
myActivityMonitor = UiActivityMonitor.getInstance();
myActivityId = new UiActivity.AsyncBgOperation("TreeUi" + this);
addModelListenerToDianoseAccessOutsideEdt();
TREE_NODE_WRAPPER = builder.createSearchingTreeNodeWrapper();
myTree.setModel(myTreeModel);
setRootNode((DefaultMutableTreeNode) treeModel.getRoot());
myTreeStructure = treeStructure;
myNodeDescriptorComparator = comparator;
myUpdateIfInactive = updateIfInactive;
UIUtil.invokeLaterIfNeeded(new TreeRunnable("AbstractTreeUi.init") {
@Override
public void perform() {
if (!wasRootNodeInitialized()) {
if (myRootNode.getChildCount() == 0) {
insertLoadingNode(myRootNode, true);
}
}
}
});
myExpansionListener = new MyExpansionListener();
myTree.addTreeExpansionListener(myExpansionListener);
mySelectionListener = new MySelectionListener();
myTree.addTreeSelectionListener(mySelectionListener);
setUpdater(getBuilder().createUpdater());
myProgress = getBuilder().createProgressIndicator();
Disposer.register(getBuilder(), getUpdater());
if (myProgress != null) {
Disposer.register(getBuilder(), new Disposable() {
@Override
public void dispose() {
myProgress.cancel();
}
});
}
final UiNotifyConnector uiNotify = new UiNotifyConnector(tree, new Activatable() {
@Override
public void showNotify() {
myShowing = true;
myWasEverShown = true;
if (canInitiateNewActivity()) {
activate(true);
}
}
@Override
public void hideNotify() {
myShowing = false;
if (canInitiateNewActivity()) {
deactivate();
}
}
});
Disposer.register(getBuilder(), uiNotify);
myTree.addFocusListener(myFocusListener);
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class LookupImpl method addListeners.
private void addListeners() {
myEditor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
if (!myChangeGuard && !myFinishing) {
hideLookup(false);
}
}
}, this);
final CaretListener caretListener = new CaretAdapter() {
@Override
public void caretPositionChanged(CaretEvent e) {
if (!myChangeGuard && !myFinishing) {
hideLookup(false);
}
}
};
final SelectionListener selectionListener = new SelectionListener() {
@Override
public void selectionChanged(final SelectionEvent e) {
if (!myChangeGuard && !myFinishing) {
hideLookup(false);
}
}
};
final EditorMouseListener mouseListener = new EditorMouseAdapter() {
@Override
public void mouseClicked(EditorMouseEvent e) {
e.consume();
hideLookup(false);
}
};
myEditor.getCaretModel().addCaretListener(caretListener);
myEditor.getSelectionModel().addSelectionListener(selectionListener);
myEditor.addEditorMouseListener(mouseListener);
Disposer.register(this, new Disposable() {
@Override
public void dispose() {
myEditor.getCaretModel().removeCaretListener(caretListener);
myEditor.getSelectionModel().removeSelectionListener(selectionListener);
myEditor.removeEditorMouseListener(mouseListener);
}
});
JComponent editorComponent = myEditor.getContentComponent();
if (editorComponent.isShowing()) {
Disposer.register(this, new UiNotifyConnector(editorComponent, new Activatable() {
@Override
public void showNotify() {
}
@Override
public void hideNotify() {
hideLookup(false);
}
}));
}
myList.addListSelectionListener(new ListSelectionListener() {
private LookupElement oldItem = null;
@Override
public void valueChanged(@NotNull ListSelectionEvent e) {
if (!myUpdating) {
final LookupElement item = getCurrentItem();
fireCurrentItemChanged(oldItem, item);
oldItem = item;
}
}
});
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
setFocusDegree(FocusDegree.FOCUSED);
markSelectionTouched();
if (clickCount == 2) {
CommandProcessor.getInstance().executeCommand(myProject, () -> finishLookup(NORMAL_SELECT_CHAR), "", null);
}
return true;
}
}.installOn(myList);
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class LibrariesDownloadUiUtil method initAsyncComboBoxModel.
public static void initAsyncComboBoxModel(@NotNull final JComboBox jComboBox, @NotNull final String groupId, final URL... localUrls) {
final List<Object> items = new ArrayList<>();
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);
}
use of com.intellij.util.ui.update.Activatable in project intellij-community by JetBrains.
the class IdeGlassPaneUtil method installPainter.
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);
}
Aggregations