use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class DockableEditorTabbedContainer method addListener.
@Override
public void addListener(final Listener listener, Disposable parent) {
myListeners.add(listener);
Disposer.register(parent, new Disposable() {
@Override
public void dispose() {
myListeners.remove(listener);
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class IdeFrameImpl method installDefaultProjectStatusBarWidgets.
private void installDefaultProjectStatusBarWidgets(@NotNull final Project project) {
final StatusBar statusBar = getStatusBar();
final PositionPanel positionPanel = new PositionPanel(project);
statusBar.addWidget(positionPanel, "before " + IdeMessagePanel.FATAL_ERROR);
final IdeNotificationArea notificationArea = new IdeNotificationArea();
statusBar.addWidget(notificationArea, "before " + IdeMessagePanel.FATAL_ERROR);
final EncodingPanel encodingPanel = new EncodingPanel(project);
statusBar.addWidget(encodingPanel, "after Position");
final LineSeparatorPanel lineSeparatorPanel = new LineSeparatorPanel(project);
statusBar.addWidget(lineSeparatorPanel, "before " + encodingPanel.ID());
final ToggleReadOnlyAttributePanel readOnlyAttributePanel = new ToggleReadOnlyAttributePanel(project);
final InsertOverwritePanel insertOverwritePanel = new InsertOverwritePanel(project);
statusBar.addWidget(insertOverwritePanel, "after Encoding");
statusBar.addWidget(readOnlyAttributePanel, "after InsertOverwrite");
Disposer.register(project, new Disposable() {
public void dispose() {
statusBar.removeWidget(encodingPanel.ID());
statusBar.removeWidget(lineSeparatorPanel.ID());
statusBar.removeWidget(positionPanel.ID());
statusBar.removeWidget(notificationArea.ID());
statusBar.removeWidget(readOnlyAttributePanel.ID());
statusBar.removeWidget(insertOverwritePanel.ID());
((StatusBarEx) statusBar).removeCustomIndicationComponents();
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class IdeGlassPaneImpl method addPainter.
public void addPainter(final Component component, final Painter painter, final Disposable parent) {
getPainters().addPainter(painter, component);
activateIfNeeded();
Disposer.register(parent, new Disposable() {
public void dispose() {
SwingUtilities.invokeLater(() -> removePainter(painter));
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class IdeGlassPaneImpl method _addListener.
private void _addListener(final EventListener listener, final Disposable parent) {
if (!myMouseListeners.contains(listener)) {
myMouseListeners.add(listener);
updateSortedList();
}
activateIfNeeded();
Disposer.register(parent, new Disposable() {
public void dispose() {
UIUtil.invokeLaterIfNeeded(() -> removeListener(listener));
}
});
}
use of com.intellij.openapi.Disposable in project intellij-community by JetBrains.
the class EncodingUtil method reloadIn.
static void reloadIn(@NotNull final VirtualFile virtualFile, @NotNull final Charset charset) {
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
if (documentManager.getCachedDocument(virtualFile) == null) {
// no need to reload document
EncodingManager.getInstance().setEncoding(virtualFile, charset);
return;
}
final Disposable disposable = Disposer.newDisposable();
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(disposable);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeFileContentReload(VirtualFile file, @NotNull Document document) {
if (!file.equals(virtualFile))
return;
// disconnect
Disposer.dispose(disposable);
EncodingManager.getInstance().setEncoding(file, charset);
LoadTextUtil.setCharsetWasDetectedFromBytes(file, null);
}
});
// if file was modified, the user will be asked here
try {
EncodingProjectManagerImpl.suppressReloadDuring(() -> ((VirtualFileListener) documentManager).contentsChanged(new VirtualFileEvent(null, virtualFile, virtualFile.getName(), virtualFile.getParent())));
} finally {
Disposer.dispose(disposable);
}
}
Aggregations