Java Code Examples for com.intellij.openapi.application.ModalityState#NON_MODAL

The following examples show how to use com.intellij.openapi.application.ModalityState#NON_MODAL . 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: ActivityMonitorTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  myCurrentState = ModalityState.NON_MODAL;
  final ModalityStateEx any = new ModalityStateEx();
  ApplicationManager.setApplication(new MockApplication(getTestRootDisposable()) {
    @Nonnull
    @Override
    public ModalityState getCurrentModalityState() {
      return myCurrentState;
    }

    @Override
    public ModalityState getAnyModalityState() {
      return any;
    }
  }, getTestRootDisposable());
  myMonitor = new UiActivityMonitorImpl();
  myMonitor.setActive(true);
  disposeOnTearDown(myMonitor);
}
 
Example 2
Source File: WaitForProgressToShow.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void runOrInvokeLaterAboveProgress(final Runnable command, @Nullable final ModalityState modalityState, @Nonnull final Project project) {
  final Application application = ApplicationManager.getApplication();
  if (application.isDispatchThread()) {
    command.run();
  } else {
    final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
    if (pi != null) {
      execute(pi);
      application.invokeLater(command, pi.getModalityState(), new Condition() {
        @Override
        public boolean value(Object o) {
          return (! project.isOpen()) || project.isDisposed();
        }
      });
    } else {
      final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
      application.invokeLater(command, notNullModalityState, project.getDisposed());
    }
  }
}
 
Example 3
Source File: BaseDataManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
@SuppressWarnings("unchecked")
protected <T> T doGetData(@Nonnull Key<T> dataId) {
  consulo.ui.Component component = getComponent();
  if (PlatformDataKeys.IS_MODAL_CONTEXT == dataId) {
    if (component == null) {
      return null;
    }
    return (T)(Boolean)false; //FIXME [VISTALL] stub
  }
  if (PlatformDataKeys.CONTEXT_UI_COMPONENT == dataId) {
    return (T)component;
  }
  if (PlatformDataKeys.MODALITY_STATE == dataId) {
    return (T)ModalityState.NON_MODAL; //FIXME [VISTALL] stub
  }
  if (CommonDataKeys.EDITOR == dataId || CommonDataKeys.HOST_EDITOR == dataId) {
    Editor editor = (Editor)getDataManager().getData(dataId, component);
    //return (T)validateEditor(editor);   //FIXME [VISTALL] stub
    return (T)editor;
  }
  return getDataManager().getData(dataId, component);
}
 
Example 4
Source File: BackgroundTaskQueue.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void runTaskInCurrentThread(@Nonnull BackgroundableTaskData data) {
  Task.Backgroundable task = data.myTask;

  ProgressIndicator indicator = data.myIndicator;
  if (indicator == null) indicator = new EmptyProgressIndicator();

  ModalityState modalityState = data.myModalityState;
  if (modalityState == null) modalityState = ModalityState.NON_MODAL;

  ProgressManagerImpl pm = (ProgressManagerImpl)ProgressManager.getInstance();

  // prohibit simultaneous execution from different threads
  synchronized (TEST_TASK_LOCK) {
    pm.runProcessWithProgressInCurrentThread(task, indicator, modalityState);
  }
}
 
Example 5
Source File: DesktopDataManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
@SuppressWarnings("unchecked")
protected  <T> T doGetData(@Nonnull Key<T> dataId) {
  Component component = getComponent();
  if (PlatformDataKeys.IS_MODAL_CONTEXT == dataId) {
    if (component == null) {
      return null;
    }
    return (T)(Boolean)IdeKeyEventDispatcher.isModalContext(component);
  }
  if (PlatformDataKeys.CONTEXT_COMPONENT == dataId) {
    return (T)component;
  }
  if (PlatformDataKeys.MODALITY_STATE == dataId) {
    return (T)(component != null ? ModalityState.stateForComponent(component) : ModalityState.NON_MODAL);
  }

  Object data = calcData(dataId, component);
  if (CommonDataKeys.EDITOR == dataId || CommonDataKeys.HOST_EDITOR == dataId) {
    return (T)validateEditor((Editor)data);
  }
  return (T)data;
}
 
Example 6
Source File: WaitForProgressToShow.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void runOrInvokeAndWaitAboveProgress(final Runnable command, @Nullable final ModalityState modalityState) {
  final Application application = ApplicationManager.getApplication();
  if (application.isDispatchThread()) {
    command.run();
  } else {
    final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
    if (pi != null) {
      execute(pi);
      application.invokeAndWait(command, pi.getModalityState());
    } else {
      final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
      application.invokeAndWait(command, notNullModalityState);
    }
  }
}
 
Example 7
Source File: MergingUpdateQueue.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public ModalityState getModalityState() {
  if (myModalityStateComponent == null) {
    return ModalityState.NON_MODAL;
  }
  return ModalityState.stateForComponent(myModalityStateComponent);
}
 
Example 8
Source File: DesktopCommandProcessorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected AsyncResult<Void> invokeLater(@Nonnull Runnable command, @Nonnull Condition<?> expire) {
  DesktopApplicationImpl application = (DesktopApplicationImpl)Application.get();

  ModalityState modalityState = ModalityPerProjectEAPDescriptor.is() ? ModalityState.current() : ModalityState.NON_MODAL;
  return application.getInvokator().invokeLater(command, modalityState, expire);
}
 
Example 9
Source File: DummyProgressIndicator.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public ModalityState getModalityState() {
    return ModalityState.NON_MODAL;
}
 
Example 10
Source File: MockProgressIndicator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public ModalityState getModalityState() {
  return ModalityState.NON_MODAL;
}
 
Example 11
Source File: DumbProgressIndicator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ModalityState getModalityState() {
  return ModalityState.NON_MODAL;
}
 
Example 12
Source File: SingleAlarm.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SingleAlarm(@Nonnull Runnable task, int delay) {
  this(task, delay, ThreadToUse.SWING_THREAD, ModalityState.NON_MODAL, null);
}
 
Example 13
Source File: SingleAlarm.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SingleAlarm(@Nonnull Runnable task, int delay, @Nonnull ThreadToUse threadToUse, @Nonnull Disposable parentDisposable) {
  this(task, delay, threadToUse, threadToUse == ThreadToUse.SWING_THREAD ? ModalityState.NON_MODAL : null, parentDisposable);
}
 
Example 14
Source File: NonCancelableIndicator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ModalityState getModalityState() {
  return ModalityState.NON_MODAL;
}
 
Example 15
Source File: CoreProgressManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static ModalityState getCurrentThreadProgressModality() {
  ProgressIndicator indicator = threadTopLevelIndicators.get(Thread.currentThread().getId());
  ModalityState modality = indicator == null ? null : indicator.getModalityState();
  return modality != null ? modality : ModalityState.NON_MODAL;
}
 
Example 16
Source File: WebApplicationImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ModalityState getNoneModalityState() {
  return ModalityState.NON_MODAL;
}