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


Java AccessToken类代码示例

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


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

示例1: moveMavenModulesToGroup

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void moveMavenModulesToGroup(
    final Project project,
    final List<Module> mavenModules,
    final String[] rootGroup
) {
    AccessToken token = null;
    final ModifiableModuleModel modifiableModuleModel;
    try {
        token = ApplicationManager.getApplication().acquireReadActionLock();
        modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();

        for (Module module : mavenModules) {
            module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.MAVEN.name());
            final String[] groupPath = modifiableModuleModel.getModuleGroupPath(module);
            modifiableModuleModel.setModuleGroupPath(module, ArrayUtils.addAll(rootGroup, groupPath));
        }
    } finally {
        if (token != null) {
            token.finish();
        }
    }
    ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModuleModel::commit));
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:DefaultMavenConfigurator.java

示例2: moveGradleModulesToGroup

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void moveGradleModulesToGroup(
    final Project project,
    final List<Module> gradleModules,
    final String[] gradleGroup
) {
    final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();

    for (Module module : gradleModules) {
        if (module == null) {
            // https://youtrack.jetbrains.com/issue/IDEA-177512
            continue;
        }
        module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.GRADLE.name());
        modifiableModuleModel.setModuleGroupPath(module, gradleGroup);
    }
    AccessToken token = null;
    try {
        token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
        modifiableModuleModel.commit();
    } finally {
        if (token != null) {
            token.finish();
        }
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:DefaultGradleConfigurator.java

示例3: moveEclipseModulesToGroup

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void moveEclipseModulesToGroup(
    @NotNull final Project project,
    @NotNull final List<Module> eclipseModules,
    @Nullable final String[] eclipseGroup
) {
    final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();

    for (Module module : eclipseModules) {
        module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.ECLIPSE.name());
        modifiableModuleModel.setModuleGroupPath(module, eclipseGroup);
    }
    AccessToken token = null;
    try {
        token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
        modifiableModuleModel.commit();
    } finally {
        if (token != null) {
            token.finish();
        }
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:DefaultEclipseConfigurator.java

示例4: updateProjectStructure

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
@Override
public void updateProjectStructure(@NotNull final Module module) {
  if (!MvcModuleStructureUtil.isEnabledStructureUpdate()) return;

  final VirtualFile root = findAppRoot(module);
  if (root == null) return;

  AccessToken token = WriteAction.start();
  try {
    MvcModuleStructureUtil.updateModuleStructure(module, createProjectStructure(module, false), root);

    if (hasSupport(module)) {
      MvcModuleStructureUtil.updateAuxiliaryPluginsModuleRoots(module, this);
      MvcModuleStructureUtil.updateGlobalPluginModule(module.getProject(), this);
    }
  }
  finally {
    token.finish();
  }

  final Project project = module.getProject();
  ChangeListManager.getInstance(project).addFilesToIgnore(IgnoredBeanFactory.ignoreUnderDirectory(getUserHomeGriffon(), project));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GriffonFramework.java

示例5: downloadJar

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void downloadJar(String jarUrl, String jarName) {
  final Project project = myModule.getProject();
  final String dirPath = PropertiesComponent.getInstance(project).getValue("findjar.last.used.dir");
  VirtualFile toSelect = dirPath == null ? null : LocalFileSystem.getInstance().findFileByIoFile(new File(dirPath));
  final VirtualFile file = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), project, toSelect);
  if (file != null) {
    PropertiesComponent.getInstance(project).setValue("findjar.last.used.dir", file.getPath());
    final DownloadableFileService downloader = DownloadableFileService.getInstance();
    final DownloadableFileDescription description = downloader.createFileDescription(jarUrl, jarName);
    final List<VirtualFile> jars =
      downloader.createDownloader(Arrays.asList(description), jarName)
                .downloadFilesWithProgress(file.getPath(), project, myEditorComponent);
    if (jars != null && jars.size() == 1) {
      AccessToken token = WriteAction.start();
      try {
        OrderEntryFix.addJarToRoots(jars.get(0).getPresentableUrl(), myModule, myRef);
      }
      finally {
        token.finish();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FindJarFix.java

示例6: createLibrary

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
                                    @NotNull final Project project, @NotNull final LibrariesModifiableModel modifiableModel) {
  final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project);
  if (configuration == null) return null;
  final LibraryType<?> libraryType = configuration.getLibraryType();
  final Library library = modifiableModel.createLibrary(
    LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()),
    libraryType != null ? libraryType.getKind() : null);

  final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties());
  configuration.addRoots(editor);
  final Library.ModifiableModel model = library.getModifiableModel();
  editor.applyTo((LibraryEx.ModifiableModelEx)model);
  AccessToken token = WriteAction.start();
  try {
    model.commit();
  }
  finally {
    token.finish();
  }
  return library;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CreateNewLibraryAction.java

示例7: addLibrary

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void addLibrary() {
  final LibrariesContainer.LibraryLevel level = myNameAndLevelPanel.getLibraryLevel();
  AccessToken token = WriteAction.start();
  try {
    final Module module = myModulesComboBox.getSelectedModule();
    final String libraryName = myNameAndLevelPanel.getLibraryName();
    if (level == LibrariesContainer.LibraryLevel.MODULE) {
      final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
      LibrariesContainerFactory.createContainer(modifiableModel).createLibrary(libraryName, level, myRoots);
      modifiableModel.commit();
    }
    else {
      final Library library = LibrariesContainerFactory.createContainer(myProject).createLibrary(libraryName, level, myRoots);
      if (module != null) {
        ModuleRootModificationUtil.addDependency(module, library);
      }
    }
  }
  finally {
    token.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateLibraryFromFilesDialog.java

示例8: visit

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
/**
 * Read action will be taken automatically
 */
public static <RESULT> RESULT visit(@NotNull XSourcePosition position, @NotNull Project project, @NotNull Visitor<RESULT> visitor, RESULT defaultResult) {
  AccessToken token = ReadAction.start();
  try {
    Document document = FileDocumentManager.getInstance().getDocument(position.getFile());
    PsiFile file = document == null || document.getTextLength() == 0 ? null : PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null) {
      return defaultResult;
    }

    int positionOffset;
    int column = position instanceof SourceInfo ? Math.max(((SourceInfo)position).getColumn(), 0) : 0;
    try {
      positionOffset = column == 0 ? DocumentUtil.getFirstNonSpaceCharOffset(document, position.getLine()) : document.getLineStartOffset(position.getLine()) + column;
    }
    catch (IndexOutOfBoundsException ignored) {
      return defaultResult;
    }

    PsiElement element = file.findElementAt(positionOffset);
    return element == null ? defaultResult : visitor.visit(element, positionOffset, document);
  }
  finally {
    token.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:PsiVisitors.java

示例9: containsGroovyClasses

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private static boolean containsGroovyClasses(final Project project) {
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Boolean>() {
    @Nullable
    @Override
    public Result<Boolean> compute() {
      AccessToken accessToken = ReadAction.start();
      try {
        return Result.create(FileTypeIndex.containsFileOfType(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScope.projectScope(project)),
                             PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
      }
      finally {
        accessToken.finish();
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GroovyHotSwapper.java

示例10: loadState

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
@Override
public void loadState(final Element element) {
  try {
    if (myFirstLoad) {
      myModel.readExternal(element);
    }
    else {
      LibraryModel model = new LibraryModel(myModel);
      AccessToken token = WriteAction.start();
      try {
        model.readExternal(element);
        commit(model);
      }
      finally {
        token.finish();
      }
    }

    myFirstLoad = false;
  }
  catch (InvalidDataException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LibraryTableBase.java

示例11: levelDown

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
protected void levelDown() {
  myBatchLevel -= 1;
  if (myChanged && myBatchLevel == 0) {
    AccessToken token = WriteAction.start();
    try {
      fireChange();
    }
    finally {
      try {
        myChanged = false;
      }
      finally {
        token.finish();
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProjectRootManagerImpl.java

示例12: createPositionManager

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
@Override
public PositionManager createPositionManager(@NotNull final DebugProcess process) {
  AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    JavaPsiFacade facade = JavaPsiFacade.getInstance(process.getProject());
    if (facade.findPackage("com.springsource.loaded") != null || facade.findPackage("org.springsource.loaded") != null) {
      return new SpringLoadedPositionManager(process);
    }
  }
  finally {
    accessToken.finish();
  }

  try {
    // Check spring loaded for remote process
    if (!process.getVirtualMachineProxy().classesByName("com.springsource.loaded.agent.SpringLoadedAgent").isEmpty()
        || !process.getVirtualMachineProxy().classesByName("org.springsource.loaded.agent.SpringLoadedAgent").isEmpty()) {
      return new SpringLoadedPositionManager(process);
    }
  }
  catch (Exception ignored) {
    // Some problem with virtual machine.
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SpringLoadedPositionManagerFactory.java

示例13: doAction

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
@Override
protected Couple<String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) {
  final Couple<String> result = super.doAction(project, psiElement, model);
  if (result != null && psiElement instanceof PsiLiteralExpression) {
    final String key = result.first;

    final StringBuilder buffer = new StringBuilder();
    buffer.append('"');
    StringUtil.escapeStringCharacters(key.length(), key, buffer);
    buffer.append('"');

    final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(JavaCreatePropertyFix.class);
    try {
      final PsiExpression newKeyLiteral = JavaPsiFacade.getElementFactory(project).createExpressionFromText(buffer.toString(), null);
      psiElement.replace(newKeyLiteral);
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
    finally {
      token.finish();
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaCreatePropertyFix.java

示例14: createByOffset

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
/**
 * do not call this method from plugins, use {@link com.intellij.xdebugger.XDebuggerUtil#createPositionByOffset(com.intellij.openapi.vfs.VirtualFile, int)} instead
 */
@Nullable
public static XSourcePositionImpl createByOffset(@Nullable VirtualFile file, final int offset) {
  if (file == null) return null;

  AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    Document document = FileDocumentManager.getInstance().getDocument(file);

    if (document == null) {
      return null;
    }
    int line = offset < document.getTextLength() ? document.getLineNumber(offset) : -1;
    return new XSourcePositionImpl(file, line, offset);
  }
  finally {
    lock.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:XSourcePositionImpl.java

示例15: saveHistory

import com.intellij.openapi.application.AccessToken; //导入依赖的package包/类
private void saveHistory() {
  try {
    if (getModel().getEntries().isEmpty()) return;
    if (myRootType.isHidden()) {
      saveHistoryOld();
      return;
    }
    AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
    try {
      VirtualFile file = HistoryRootType.getInstance().findFile(null, getHistoryName(myRootType, myId), ScratchFileService.Option.create_if_missing);
      VfsUtil.saveText(file, StringUtil.join(getModel().getEntries(), myRootType.getEntrySeparator()));
    }
    finally {
      token.finish();
    }
  }
  catch (Exception ex) {
    LOG.error(ex);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ConsoleHistoryController.java


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