当前位置: 首页>>代码示例>>Java>>正文


Java ModalityState类代码示例

本文整理汇总了Java中com.intellij.openapi.application.ModalityState的典型用法代码示例。如果您正苦于以下问题:Java ModalityState类的具体用法?Java ModalityState怎么用?Java ModalityState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModalityState类属于com.intellij.openapi.application包,在下文中一共展示了ModalityState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: smartInvokeAndWait

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public static void smartInvokeAndWait(final Project p, final ModalityState state, final Runnable r) {
    if (isNoBackgroundMode() || ApplicationManager.getApplication().isDispatchThread()) {
        r.run();
    } else {
        final Semaphore semaphore = new Semaphore();
        semaphore.down();
        DumbService.getInstance(p).smartInvokeLater(() -> {
            try {
                r.run();
            } finally {
                semaphore.up();
            }
        }, state);
        semaphore.waitFor();
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:17,代码来源:NavigatorUtil.java

示例2: asyncCheckErrors

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private void asyncCheckErrors(@NotNull final Collection<VirtualFile> files,
                              @NotNull final Consumer<Boolean> errorsFoundConsumer) {
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      final boolean errorsFound = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          for (VirtualFile file : files) {
            if (PsiErrorElementUtil.hasErrors(myProject, file)) {
              return true;
            }
          }
          return false;
        }
      });
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          errorsFoundConsumer.consume(errorsFound);
        }
      }, ModalityState.any());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DelayedDocumentWatcher.java

示例3: findCurrentDirectory

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public static PsiDirectory findCurrentDirectory(Project project, VirtualFile file) {
    final PsiDirectory[] result = new PsiDirectory[1];
    ApplicationManager.getApplication().invokeAndWait(() ->
                    result[0] = ApplicationManager.getApplication().runReadAction((Computable<PsiDirectory>) () -> {
                        if (file == null || project == null) {
                            return null;
                        }

                        if (file.isDirectory()) {
                            return PsiManager.getInstance(project).findDirectory(file);
                        } else {
                            return PsiManager.getInstance(project).findDirectory(file.getParent());
                        }
                    })
            , ModalityState.defaultModalityState());
    return result[0];
}
 
开发者ID:CeH9,项目名称:PackageTemplates,代码行数:18,代码来源:FileWriter.java

示例4: verifyServerHostKey

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public boolean verifyServerHostKey(final String hostname,
                                   final int port,
                                   final String serverHostKeyAlgorithm,
                                   final String fingerprint,
                                   final boolean isNew) {
  final String message;
  if (isNew) {
    message = GitBundle.message("ssh.new.host.key", hostname, port, fingerprint, serverHostKeyAlgorithm);
  }
  else {
    message = GitBundle.message("ssh.changed.host.key", hostname, port, fingerprint, serverHostKeyAlgorithm);
  }
  final AtomicBoolean rc = new AtomicBoolean();
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    public void run() {
      rc.set(Messages.YES == Messages.showYesNoDialog(myProject, message, GitBundle.getString("ssh.confirm.key.titile"), null));
    }
  }, ModalityState.any());
  return rc.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GitSSHGUIHandler.java

示例5: setupSdkPaths

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public void setupSdkPaths(final Sdk sdk, @Nullable final Project project, @Nullable final Component ownerComponent) {
  scheduledToRefresh.add(sdk.getHomePath());
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        final boolean success = doSetupSdkPaths(project, ownerComponent, PySdkUpdater.fromSdkPath(sdk.getHomePath()));

        if (!success) {
          Messages.showErrorDialog(
            project,
            PyBundle.message("MSG.cant.setup.sdk.$0", FileUtil.toSystemDependentName(sdk.getSdkModificator().getHomePath())),
            PyBundle.message("MSG.title.bad.sdk")
          );
        }
      }
      catch (PySdkUpdater.PySdkNotFoundException e) {
        // sdk was removed from sdk table so no need to setup paths
      }
    }
  }, ModalityState.NON_MODAL);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PythonSdkType.java

示例6: addAlarmRequest

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private void addAlarmRequest(){
  Runnable request = new Runnable(){
    @Override
    public void run(){
      if (!myDisposed && !myProject.isDisposed()) {
        DumbService.getInstance(myProject).withAlternativeResolveEnabled(new Runnable() {
          @Override
          public void run() {
            updateComponent();
          }
        });
      }
    }
  };
  myAlarm.addRequest(request, DELAY, ModalityState.stateForComponent(myEditor.getComponent()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ParameterInfoController.java

示例7: FindDialog

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public FindDialog(@NotNull Project project, @NotNull FindModel model, @NotNull Consumer<FindModel> myOkHandler){
  super(project, true);
  myProject = project;
  myModel = model;

  this.myOkHandler = myOkHandler;

  updateTitle();
  setOKButtonText(FindBundle.message("find.button"));
  init();
  initByModel();
  updateReplaceVisibility();

  if (haveResultsPreview()) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        scheduleResultsUpdate();
      }
    }, ModalityState.any());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:FindDialog.java

示例8: addUpdateRequest

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
public void addUpdateRequest(final boolean shouldRefreshSelection) {
  final Runnable request = new Runnable() {
    @Override
    public void run() {
      if (!myProject.isDisposed()) {
        // Rely on project view to commit PSI and wait until it's updated.
        if (myTreeStructure.hasSomethingToCommit() ) {
          myUpdateAlarm.cancelAllRequests();
          myUpdateAlarm.addRequest(this, 300, ModalityState.stateForComponent(myList));
          return;
        }
        updateList(shouldRefreshSelection);
      }
    }
  };

  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    myUpdateAlarm.cancelAllRequests();
    myUpdateAlarm.addRequest(request, 300, ModalityState.stateForComponent(myList));
  }
  else {
    request.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ProjectListBuilder.java

示例9: switchToCommandMode

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
/**
 * Switches console to "command-mode" (see class doc for details)
 */
private void switchToCommandMode() {
  // "upper" and "bottom" parts of console both need padding in command mode
  myProcessHandler = null;
  setPrompt(getTitle() + " > ");
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    @Override
    public void run() {
      notifyStateChangeListeners();
      configureLeftBorder(true, getConsoleEditor(), getHistoryViewer());
      setLanguage(CommandLineLanguage.INSTANCE);
      final CommandLineFile file = PyUtil.as(getFile(), CommandLineFile.class);
      resetConsumer(null);
      if (file == null || myCommandsAndDefaultExecutor == null) {
        return;
      }
      file.setCommands(myCommandsAndDefaultExecutor.first);
      final CommandConsole console = CommandConsole.this;
      resetConsumer(new CommandModeConsumer(myCommandsAndDefaultExecutor.first, myModule, console, myCommandsAndDefaultExecutor.second));
    }
  }, ModalityState.NON_MODAL);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CommandConsole.java

示例10: processClose

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private void processClose() {
  if (Registry.getInstance().isRestartNeeded()) {
    final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
    final ApplicationInfo info = ApplicationInfo.getInstance();

    final int r = Messages.showOkCancelDialog(myContent, "You need to restart " + info.getVersionName() + " for the changes to take effect", "Restart Required",
                                              app.isRestartCapable() ? "Restart Now" : "Shutdown Now",
                                              app.isRestartCapable() ? "Restart Later": "Shutdown Later"
        , Messages.getQuestionIcon());


    if (r == Messages.OK) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          app.restart(true);
        }
      }, ModalityState.NON_MODAL);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:RegistryUi.java

示例11: setMouseSelectionState

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private void setMouseSelectionState(@MouseSelectionState int mouseSelectionState) {
  if (getMouseSelectionState() == mouseSelectionState) return;

  myMouseSelectionState = mouseSelectionState;
  myMouseSelectionChangeTimestamp = System.currentTimeMillis();

  myMouseSelectionStateAlarm.cancelAllRequests();
  if (myMouseSelectionState != MOUSE_SELECTION_STATE_NONE) {
    if (myMouseSelectionStateResetRunnable == null) {
      myMouseSelectionStateResetRunnable = new Runnable() {
        @Override
        public void run() {
          resetMouseSelectionState(null);
        }
      };
    }
    myMouseSelectionStateAlarm.addRequest(myMouseSelectionStateResetRunnable, Registry.intValue("editor.mouseSelectionStateResetTimeout"),
                                          ModalityState.stateForComponent(myEditorComponent));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:bigFile.java

示例12: projectOpened

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
@Override
public void projectOpened() {
  MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myProject.isDisposed()) return;
          VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
        }
      }, ModalityState.NON_MODAL);
    }
  });
  final WolfTheProblemSolver.ProblemListener myProblemListener = new MyProblemListener();
  WolfTheProblemSolver.getInstance(myProject).addProblemListener(myProblemListener,myProject);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:VcsEventWatcher.java

示例13: selectLater

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private void selectLater(final ActionCallback callback, final K key) {
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      if (!myDisposed) {
        final UI ui = prepare(key);
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            if (!myDisposed) {
              select(callback, key, ui);
            }
            else callback.setRejected();
          }
        }, ModalityState.any());
      }
      else callback.setRejected();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CardLayoutPanel.java

示例14: loadModuleInternal

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
@NotNull
private Module loadModuleInternal(@NotNull String filePath) throws ModuleWithNameAlreadyExists, IOException {
  filePath = resolveShortWindowsName(filePath);
  final VirtualFile moduleFile = StandardFileSystems.local().findFileByPath(filePath);
  if (moduleFile == null || !moduleFile.exists()) {
    throw new FileNotFoundException(ProjectBundle.message("module.file.does.not.exist.error", filePath));
  }

  String path = moduleFile.getPath();
  ModuleEx module = getModuleByFilePath(path);
  if (module == null) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        moduleFile.refresh(false, false);
      }
    }, ModalityState.any());
    module = createAndLoadModule(path);
    initModule(module, path, null);
  }
  return module;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ModuleManagerImpl.java

示例15: confirmUndeploy

import com.intellij.openapi.application.ModalityState; //导入依赖的package包/类
private boolean confirmUndeploy() {
  final Ref<Boolean> confirmed = new Ref<Boolean>(false);
  ApplicationManager.getApplication().invokeAndWait(new Runnable() {

    @Override
    public void run() {
      String title = CloudBundle.getText("cloud.undeploy.confirm.title");
      while (true) {
        String password = Messages.showPasswordDialog(CloudBundle.getText("cloud.undeploy.confirm.message", getApplicationName()), title);
        if (password == null) {
          return;
        }
        if (password.equals(getServerRuntime().getConfiguration().getPassword())) {
          confirmed.set(true);
          return;
        }
        Messages.showErrorDialog(CloudBundle.getText("cloud.undeploy.confirm.password.incorrect"), title);
      }
    }
  }, ModalityState.defaultModalityState());
  return confirmed.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CloudGitApplicationRuntime.java


注:本文中的com.intellij.openapi.application.ModalityState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。