Java Code Examples for consulo.disposer.Disposer#isDisposed()

The following examples show how to use consulo.disposer.Disposer#isDisposed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void disposeWithEditor(@Nonnull Editor editor, @Nonnull Disposable disposable) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (Disposer.isDisposed(disposable)) return;
  if (editor.isDisposed()) {
    Disposer.dispose(disposable);
    return;
  }
  // for injected editors disposal will happen only when host editor is disposed,
  // but this seems to be the best we can do (there are no notifications on disposal of injected editor)
  Editor hostEditor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
  EditorFactory.getInstance().addEditorFactoryListener(new EditorFactoryAdapter() {
    @Override
    public void editorReleased(@Nonnull EditorFactoryEvent event) {
      if (event.getEditor() == hostEditor) {
        Disposer.dispose(disposable);
      }
    }
  }, disposable);
}
 
Example 2
Source File: FindManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void showFindDialog(@Nonnull FindModel model, @Nonnull Runnable okHandler) {
  if (myHelper == null || Disposer.isDisposed(myHelper)) {
    myHelper = new FindUIHelper(myProject, model, okHandler);
    Disposer.register(myHelper, new Disposable() {
      @Override
      public void dispose() {
        myHelper = null;
      }
    });
  }
  else {
    myHelper.setModel(model);
    myHelper.setOkHandler(okHandler);
  }
  myHelper.showUI();
}
 
Example 3
Source File: DesktopTransactionGuardImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void runSyncTransaction(@Nonnull Transaction transaction) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (Disposer.isDisposed(transaction.parentDisposable)) return;

  boolean wasWritingAllowed = myWritingAllowed;
  myWritingAllowed = true;
  myCurrentTransaction = new TransactionIdImpl(myCurrentTransaction);

  try {
    transaction.runnable.run();
  }
  finally {
    Queue<Transaction> queue = getQueue(myCurrentTransaction.myParent);
    queue.addAll(myCurrentTransaction.myQueue);
    if (!queue.isEmpty()) {
      pollQueueLater();
    }

    myWritingAllowed = wasWritingAllowed;
    myCurrentTransaction.myFinished = true;
    myCurrentTransaction = myCurrentTransaction.myParent;
  }
}
 
Example 4
Source File: TestProxyPrinterProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public Printer getPrinterByType(@Nonnull String nodeType, @Nonnull String nodeName, @Nullable String nodeArguments) {
  Filter filter = myFilterProvider.getFilter(nodeType, nodeName, nodeArguments);
  if (filter != null && !Disposer.isDisposed(myTestOutputConsoleView)) {
    return new HyperlinkPrinter(myTestOutputConsoleView, HyperlinkPrinter.ERROR_CONTENT_TYPE, filter);
  }
  return null;
}
 
Example 5
Source File: OnePixelDivider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeNotify() {
  super.removeNotify();
  if (myDisposable != null && !Disposer.isDisposed(myDisposable)) {
    Disposer.dispose(myDisposable);
  }
}
 
Example 6
Source File: DesktopEditorComposite.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
  for (FileEditor editor : myEditors) {
    if (!Disposer.isDisposed(editor)) {
      Disposer.dispose(editor);
    }
  }
  myFocusWatcher.deinstall(myFocusWatcher.getTopComponent());
}
 
Example 7
Source File: BackgroundTaskUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean registerIfParentNotDisposed(@Nonnull Disposable parent, @Nonnull Disposable disposable) {
  ThrowableComputable<Boolean, RuntimeException> action = () -> {
    if (Disposer.isDisposed(parent)) return false;
    try {
      Disposer.register(parent, disposable);
      return true;
    }
    catch (IncorrectOperationException ioe) {
      LOG.error(ioe);
      return false;
    }
  };
  return AccessRule.read(action);
}
 
Example 8
Source File: ListPopupImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showInBestPositionFor(@Nonnull Editor editor) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    handleSelect(true);
    if (!Disposer.isDisposed(this)) {
      Disposer.dispose(this);
    }
  }
  else {
    super.showInBestPositionFor(editor);
  }
}
 
Example 9
Source File: PopupLocationTracker.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean register(@Nonnull ScreenAreaConsumer consumer) {
  if (!Registry.is("ide.use.screen.area.tracker", false)) {
    return true;
  }
  if (!Disposer.isDisposed(consumer) && ourAreaConsumers.add(consumer)) {
    Disposer.register(consumer, new Disposable() {
      @Override
      public void dispose() {
        ourAreaConsumers.remove(consumer);
      }
    });
    return true;
  }
  return false;
}
 
Example 10
Source File: RunnerContentUi.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeNotify() {
  super.removeNotify();
  if (!ScreenUtil.isStandardAddRemoveNotify(this)) return;

  if (Disposer.isDisposed(RunnerContentUi.this)) return;

  saveUiState();
}
 
Example 11
Source File: FindUIHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
  if (myUI != null && !Disposer.isDisposed(myUI.getDisposable())) {
    Disposer.dispose(myUI.getDisposable());
  }
  myUI = null;
}
 
Example 12
Source File: DesktopInternalDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeNotify() {
  super.removeNotify();
  if (myDisposable != null && !Disposer.isDisposed(myDisposable)) {
    Disposer.dispose(myDisposable);
  }
}
 
Example 13
Source File: ExpirationUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean isDisposed(Disposable disposable) {
  return Disposer.isDisposed(disposable);
}
 
Example 14
Source File: DvcsUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void consume(Object dummy) {
  if (!Disposer.isDisposed(myRepository)) {
    myRepository.update();
  }
}
 
Example 15
Source File: GridImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void processRemoveFromUi() {
  if (Disposer.isDisposed(this)) return;

  updateSelection(false);
}