use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class FileStatusManagerImpl method addFileStatusListener.
@Override
public void addFileStatusListener(@NotNull final FileStatusListener listener, @NotNull Disposable parentDisposable) {
addFileStatusListener(listener);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
removeFileStatusListener(listener);
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class EditorPlaybackCall method waitDaemonForFinish.
public static AsyncResult<String> waitDaemonForFinish(final PlaybackContext context) {
final AsyncResult<String> result = new AsyncResult<>();
final Disposable connection = Disposer.newDisposable();
result.doWhenProcessed(() -> Disposer.dispose(connection));
WindowSystemPlaybackCall.findProject().doWhenDone(new Consumer<Project>() {
@Override
public void consume(Project project) {
final MessageBusConnection bus = project.getMessageBus().connect(connection);
bus.subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() {
@Override
public void daemonFinished() {
context.flushAwtAndRunInEdt(result.createSetDoneRunnable());
}
@Override
public void daemonCancelEventOccurred(@NotNull String reason) {
result.setDone();
}
});
}
}).doWhenRejected(() -> result.setRejected("Cannot find project"));
return result;
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class IdeStatusBarImpl method addWidget.
@Override
public void addWidget(@NotNull final StatusBarWidget widget, @NotNull final Disposable parentDisposable) {
addWidget(widget);
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
removeWidget(widget.ID());
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class StatisticsManagerImpl method enableStatistics.
@TestOnly
public void enableStatistics(@NotNull Disposable parentDisposable) {
myTestingStatistics = true;
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
synchronized (LOCK) {
Collections.fill(myUnits, null);
}
myTestingStatistics = false;
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class BalloonLayoutImpl method add.
@Override
public void add(@NotNull final Balloon balloon, @Nullable Object layoutData) {
ApplicationManager.getApplication().assertIsDispatchThread();
Balloon merge = merge(layoutData);
if (merge == null) {
if (getVisibleCount() > 0 && layoutData instanceof BalloonLayoutData && ((BalloonLayoutData) layoutData).groupId != null) {
int index = -1;
int count = 0;
for (int i = 0, size = myBalloons.size(); i < size; i++) {
BalloonLayoutData ld = myLayoutData.get(myBalloons.get(i));
if (ld != null && ld.groupId != null) {
if (index == -1) {
index = i;
}
count++;
}
}
if (count > 0 && count == getVisibleCount()) {
remove(myBalloons.get(index));
}
}
myBalloons.add(balloon);
} else {
int index = myBalloons.indexOf(merge);
remove(merge);
myBalloons.add(index, balloon);
}
if (layoutData instanceof BalloonLayoutData) {
BalloonLayoutData balloonLayoutData = (BalloonLayoutData) layoutData;
balloonLayoutData.closeAll = myCloseAll;
balloonLayoutData.doLayout = myLayoutRunnable;
myLayoutData.put(balloon, balloonLayoutData);
}
Disposer.register(balloon, new Disposable() {
public void dispose() {
clearNMore(balloon);
remove(balloon, false);
queueRelayout();
}
});
if (myLafListener == null && layoutData != null) {
myLafListener = new LafManagerListener() {
@Override
public void lookAndFeelChanged(LafManager source) {
for (BalloonLayoutData layoutData : myLayoutData.values()) {
if (layoutData.lafHandler != null) {
layoutData.lafHandler.run();
}
}
}
};
LafManager.getInstance().addLafManagerListener(myLafListener);
}
calculateSize();
relayout();
if (!balloon.isDisposed()) {
balloon.show(myLayeredPane);
}
fireRelayout();
}
Aggregations