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


Java StorageUtil类代码示例

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


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

示例1: readDeletedSchemeNames

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
private Collection<String> readDeletedSchemeNames() {
  Collection<String> result = new HashSet<String>();
  for (StreamProvider provider : getEnabledProviders()) {
    try {
      Document deletedNameDoc = StorageUtil.loadDocument(provider.loadContent(getFileFullPath(DELETED_XML), myRoamingType));
      if (deletedNameDoc != null) {
        for (Object child : deletedNameDoc.getRootElement().getChildren()) {
          String deletedSchemeName = ((Element)child).getAttributeValue("name");
          if (deletedSchemeName != null) {
            result.add(deletedSchemeName);
          }
        }
      }
    }
    catch (Exception e) {
      LOG.debug(e);
    }
  }

  return result;

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:SchemesManagerImpl.java

示例2: exportScheme

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
public void exportScheme(final E scheme, final String name, final String description) throws WriteExternalException, IOException {
  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  if (providers != null) {
    Document document = myProcessor.writeScheme(scheme);
    if (document != null) {
      Document wrapped = wrap(document, name, description);
      for (StreamProvider provider : providers) {
        if (provider instanceof CurrentUserHolder) {
          wrapped = (Document)wrapped.clone();
          String userName = ((CurrentUserHolder)provider).getCurrentUserName();
          if (userName != null) {
            wrapped.getRootElement().setAttribute(USER, userName);
          }
        }
        StorageUtil.sendContent(provider, getFileFullPath(UniqueFileNamesProvider.convertName(scheme.getName())) + mySchemeExtension,
                                wrapped, RoamingType.GLOBAL, false);
      }
    }
  }

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:SchemesManagerImpl.java

示例3: FileTemplateManagerImpl

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
public FileTemplateManagerImpl(@Nonnull FileTypeManagerEx typeManager, FileTemplateSettings projectSettings, ExportableFileTemplateSettings defaultSettings,
                               /*need this to ensure disposal of the service _after_ project manager*/
                               @SuppressWarnings("UnusedParameters") ProjectManager pm, final Project project) {
  myTypeManager = typeManager;
  myProjectSettings = projectSettings;
  myDefaultSettings = defaultSettings;
  myProject = project;

  myProjectScheme = project.isDefault() ? null : new FileTemplatesScheme("Project") {
    @Nonnull
    @Override
    public String getTemplatesDir() {
      return FileUtilRt.toSystemDependentName(StorageUtil.getStoreDir(project) + "/" + TEMPLATES_DIR);
    }

    @Nonnull
    @Override
    public Project getProject() {
      return project;
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:FileTemplateManagerImpl.java

示例4: FileTemplatesLoader

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
protected FileTemplatesLoader(@Nonnull FileTypeManagerEx typeManager, @Nullable Project project) {
  myTypeManager = typeManager;
  File configDir = project == null || project.isDefault()
                   ? new File(PathManager.getConfigPath(), TEMPLATES_DIR)
                   : new File(UriUtil.trimTrailingSlashes(StorageUtil.getStoreDir(project) + "/" + TEMPLATES_DIR));
  myDefaultTemplatesManager = new FTManager(FileTemplateManager.DEFAULT_TEMPLATES_CATEGORY, configDir);
  myInternalTemplatesManager = new FTManager(FileTemplateManager.INTERNAL_TEMPLATES_CATEGORY, new File(configDir, INTERNAL_DIR), true);
  myPatternsManager = new FTManager(FileTemplateManager.INCLUDES_TEMPLATES_CATEGORY, new File(configDir, INCLUDES_DIR));
  myCodeTemplatesManager = new FTManager(FileTemplateManager.CODE_TEMPLATES_CATEGORY, new File(configDir, CODE_TEMPLATES_DIR));
  myJ2eeTemplatesManager = new FTManager(FileTemplateManager.J2EE_TEMPLATES_CATEGORY, new File(configDir, J2EE_TEMPLATES_DIR));
  myAllManagers = new FTManager[]{myDefaultTemplatesManager, myInternalTemplatesManager, myPatternsManager, myCodeTemplatesManager, myJ2eeTemplatesManager};

  myDirToManagerMap.put("", myDefaultTemplatesManager);
  myDirToManagerMap.put(INTERNAL_DIR + "/", myInternalTemplatesManager);
  myDirToManagerMap.put(INCLUDES_DIR + "/", myPatternsManager);
  myDirToManagerMap.put(CODE_TEMPLATES_DIR + "/", myCodeTemplatesManager);
  myDirToManagerMap.put(J2EE_TEMPLATES_DIR + "/", myJ2eeTemplatesManager);

  loadDefaultTemplates();
  for (FTManager manager : myAllManagers) {
    manager.loadCustomizedContent();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:FileTemplatesLoader.java

示例5: apply

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
  myEditor.commit();

  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    StorageUtil.checkUnknownMacros(project, false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PathMacroConfigurable.java

示例6: save

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Override
public void save() throws IOException {
  CachedXmlDocumentSet fileSet = EclipseClasspathStorageProvider.getFileCache(module);

  AccessToken token = WriteAction.start();
  try {
    for (String key : modifiedContent.keySet()) {
      Element content = modifiedContent.get(key);
      String path = fileSet.getParent(key) + '/' + key;
      Writer writer = new OutputStreamWriter(StorageUtil.getOrCreateVirtualFile(this, new File(path)).getOutputStream(this), CharsetToolkit.UTF8_CHARSET);
      try {
        EclipseJDOMUtil.output(content, writer, module.getProject());
      }
      finally {
        writer.close();
      }
    }

    if (deletedContent.isEmpty()) {
      return;
    }

    for (String deleted : deletedContent) {
      VirtualFile file = fileSet.getFile(deleted, false);
      if (file != null) {
        try {
          file.delete(this);
        }
        catch (IOException ignore) {
        }
      }
    }
    deletedContent.clear();
  }
  finally {
    token.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ClasspathSaveSession.java

示例7: loadGlobalScheme

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Nullable
private static Document loadGlobalScheme(final String schemePath) throws IOException {
  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  for (StreamProvider provider : providers) {
    if (provider.isEnabled()) {
      Document document = StorageUtil.loadDocument(provider.loadContent(schemePath, RoamingType.GLOBAL));
      if (document != null) return document;
    }
  }

  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:SchemesManagerImpl.java

示例8: saveIfNeeded

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
private void saveIfNeeded(E schemeKey, String fileName, Document document, long newHash, Long oldHash) throws IOException {
  if (oldHash == null || newHash != oldHash.longValue() || myVFSBaseDir.findChild(fileName) == null) {
    byte[] text = StorageUtil.printDocument(document);
    ensureFileText(fileName, text);
    schemeKey.getExternalInfo().setHash(newHash);
    saveFileName(fileName, schemeKey);
    saveOnServer(fileName, document);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:SchemesManagerImpl.java

示例9: saveOnServer

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
private void saveOnServer(final String fileName, final Document document) {
  for (StreamProvider provider : getEnabledProviders()) {
    try {
      StorageUtil.sendContent(provider, getFileFullPath(fileName), document, myRoamingType, true);
    }
    catch (IOException e) {
      LOG.debug(e);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:SchemesManagerImpl.java

示例10: openProject

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Override
public boolean openProject(@NotNull final Project project) {
  if (isLight(project)) {
    ((ProjectImpl)project).setTemporarilyDisposed(false);
    boolean isInitialized = StartupManagerEx.getInstanceEx(project).startupActivityPassed();
    if (isInitialized) {
      addToOpened(project);
      // events already fired
      return true;
    }
  }

  if (!addToOpened(project)) {
    return false;
  }

  fireProjectOpened(project);
  DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
    @Override
    public void run() {
      DumbService.getInstance(project).queueTask(new DumbModeTask() {
        @Override
        public void performInDumbMode(@NotNull ProgressIndicator indicator) {
          waitForFileWatcher(indicator);
        }

        @Override
        public String toString() {
          return "wait for file watcher";
        }
      });
    }
  });

  final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManager.getInstance(project);
  boolean ok = myProgressManager.runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      startupManager.runStartupActivities();

      // dumb mode should start before post-startup activities
      // only when startCacheUpdate is called from UI thread, we can guarantee that
      // when the method returns, the application has entered dumb mode
      UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override
        public void run() {
          startupManager.startCacheUpdate();
        }
      });

      startupManager.runPostStartupActivitiesFromExtensions();

      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          if (!project.isDisposed()) {
            startupManager.runPostStartupActivities();

            Application application = ApplicationManager.getApplication();
            if (!(application.isHeadlessEnvironment() || application.isUnitTestMode())) {
              StorageUtil.checkUnknownMacros(project, true);
            }
          }
        }
      });
    }
  }, ProjectBundle.message("project.load.progress"), canCancelProjectLoading(), project);

  if (!ok) {
    closeProject(project, false, false, true);
    notifyProjectOpenFailed();
    return false;
  }

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

示例11: openProject

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Override
public boolean openProject(final Project project) {
  if (isLight(project)) {
    throw new AssertionError("must not open light project");
  }
  final Application application = ApplicationManager.getApplication();

  if (!application.isUnitTestMode() && !((ProjectEx)project).getStateStore().checkVersion()) {
    return false;
  }

  synchronized (myOpenProjects) {
    if (myOpenProjects.contains(project)) {
      return false;
    }
    myOpenProjects.add(project);
    cacheOpenProjects();
  }
  fireProjectOpened(project);

  final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManager.getInstance(project);
  waitForFileWatcher(project);
  boolean ok = myProgressManager.runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      startupManager.runStartupActivities();

      // dumb mode should start before post-startup activities
      // only when startCacheUpdate is called from UI thread, we can guarantee that
      // when the method returns, the application has entered dumb mode
      UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override
        public void run() {
          startupManager.startCacheUpdate();
        }
      });

      startupManager.runPostStartupActivitiesFromExtensions();

      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          startupManager.runPostStartupActivities();
        }
      });
    }
  }, ProjectBundle.message("project.load.progress"), true, project);

  if (!ok) {
    closeProject(project, false, false, true);
    notifyProjectOpenFailed();
    return false;
  }

  if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) {
    // should be invoked last
    startupManager.runWhenProjectIsInitialized(new Runnable() {
      @Override
      public void run() {
        final TrackingPathMacroSubstitutor macroSubstitutor =
          ((ProjectEx)project).getStateStore().getStateStorageManager().getMacroSubstitutor();
        if (macroSubstitutor != null) {
          StorageUtil.notifyUnknownMacros(macroSubstitutor, project, null);
        }
      }
    });
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:71,代码来源:ProjectManagerImpl.java

示例12: readSchemesFromProviders

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
private Collection<E> readSchemesFromProviders() {
  Collection<E> result = new ArrayList<E>();
  for (StreamProvider provider : getEnabledProviders()) {
    String[] paths = provider.listSubFiles(myFileSpec);
    for (String subpath : paths) {
      if (!subpath.equals(DELETED_XML)) {
        try {
          final Document subDocument = StorageUtil.loadDocument(provider.loadContent(getFileFullPath(subpath), myRoamingType));
          if (subDocument != null) {
            E scheme = readScheme(subDocument);
            boolean fileRenamed = false;
            T existing = findSchemeByName(scheme.getName());
            if (existing != null && existing instanceof ExternalizableScheme) {
              String currentFileName = ((ExternalizableScheme)existing).getExternalInfo().getCurrentFileName();
              if (currentFileName != null && !currentFileName.equals(subpath)) {
                deleteServerFiles(subpath);
                subpath = currentFileName;
                fileRenamed = true;
              }

            }
            String fileName = checkFileNameIsFree(subpath, scheme.getName());

            if (!fileRenamed && !fileName.equals(subpath)) {
              deleteServerFiles(subpath);
            }

            if (scheme != null) {
              loadScheme(scheme, false, fileName);
              result.add(scheme);
            }

          }
        }
        catch (Exception e) {
          LOG.info("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
        }
      }
    }
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:43,代码来源:SchemesManagerImpl.java

示例13: loadSharedSchemes

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@NotNull
public Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList) {
  Collection<String> names = new HashSet<String>(getAllSchemeNames(currentSchemeList));

  final StreamProvider[] providers = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager()
      .getStreamProviders(RoamingType.GLOBAL);
  final HashMap<String, SharedScheme<E>> result = new HashMap<String, SharedScheme<E>>();
  if (providers != null) {
    for (StreamProvider provider : providers) {
      if (provider.isEnabled()) {
        String[] paths = provider.listSubFiles(myFileSpec);
        for (String subpath : paths) {
          try {
            final Document subDocument = StorageUtil.loadDocument(provider.loadContent(getFileFullPath(subpath), RoamingType.GLOBAL));
            if (subDocument != null) {
              SharedSchemeData original = unwrap(subDocument);
              final E scheme = myProcessor.readScheme(original.original);
              if (!alreadyShared(subpath, currentSchemeList)) {
                String schemeName = original.name;
                String uniqueName = UniqueNameGenerator.generateUniqueName("[shared] " + schemeName, names);
                renameScheme(scheme, uniqueName);
                schemeName = uniqueName;
                scheme.getExternalInfo().setOriginalPath(getFileFullPath(subpath));
                scheme.getExternalInfo().setIsImported(true);
                result.put(schemeName,
                           new SharedScheme<E>(original.user == null ? "unknown" : original.user, original.description, scheme));
              }
            }
          }
          catch (Exception e) {
            LOG.debug("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
          }
        }
      }
    }
  }

  for (SharedScheme<E> t : result.values()) {
    myProcessor.initScheme(t.getScheme());
  }

  return result.values();

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:SchemesManagerImpl.java

示例14: projectStorageFileChanged

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
private void projectStorageFileChanged(@Nonnull VirtualFileEvent event, @Nonnull StateStorage storage, @Nullable Project project) {
  VirtualFile file = event.getFile();
  if (!StorageUtil.isChangedByStorageOrSaveSession(event) && !(event.getRequestor() instanceof ProjectManagerImpl)) {
    registerProjectToReload(project, file, storage);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:ProjectManagerImpl.java

示例15: openProject

import com.intellij.openapi.components.impl.stores.StorageUtil; //导入依赖的package包/类
@Override
public boolean openProject(@Nonnull final Project project, @Nonnull UIAccess uiAccess) {
  if (isLight(project)) {
    ((ProjectImpl)project).setTemporarilyDisposed(false);
    boolean isInitialized = StartupManagerEx.getInstanceEx(project).startupActivityPassed();
    if (isInitialized) {
      addToOpened(project);
      // events already fired
      return true;
    }
  }

  for (Project p : getOpenProjects()) {
    if (ProjectUtil.isSameProject(project.getProjectFilePath(), p)) {
      GuiUtils.invokeLaterIfNeeded(() -> ProjectUtil.focusProjectWindow(p, false), ModalityState.NON_MODAL);
      return false;
    }
  }

  if (!addToOpened(project)) {
    return false;
  }

  Runnable process = () -> {
    TransactionGuard.getInstance().submitTransactionAndWait(() -> fireProjectOpened(project));

    final StartupManagerImpl startupManager = (StartupManagerImpl)StartupManager.getInstance(project);
    startupManager.runStartupActivities();

    // Startup activities (e.g. the one in FileBasedIndexProjectHandler) have scheduled dumb mode to begin "later"
    // Now we schedule-and-wait to the same event queue to guarantee that the dumb mode really begins now:
    // Post-startup activities should not ever see unindexed and at the same time non-dumb state
    TransactionGuard.getInstance().submitTransactionAndWait(startupManager::startCacheUpdate);

    startupManager.runPostStartupActivitiesFromExtensions(uiAccess);

    GuiUtils.invokeLaterIfNeeded(() -> {
      if (!project.isDisposed()) {
        startupManager.runPostStartupActivities();


        Application application = ApplicationManager.getApplication();
        if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) {
          final TrackingPathMacroSubstitutor macroSubstitutor = ((ProjectEx)project).getStateStore().getStateStorageManager().getMacroSubstitutor();
          if (macroSubstitutor != null) {
            StorageUtil.notifyUnknownMacros(macroSubstitutor, project, null);
          }
        }

        if (ApplicationManager.getApplication().isActive()) {
          JFrame projectFrame = WindowManager.getInstance().getFrame(project);
          if (projectFrame != null) {
            IdeFocusManager.getInstance(project).requestFocus(projectFrame, true);
          }
        }
      }
    }, ModalityState.NON_MODAL);
  };

  ProgressIndicator indicator = myProgressManager.getProgressIndicator();
  if (indicator != null) {
    indicator.setText("Preparing workspace...");
    process.run();
    return true;
  }

  boolean ok = myProgressManager.runProcessWithProgressSynchronously(process, ProjectBundle.message("project.load.progress"), canCancelProjectLoading(), project);
  if (!ok) {
    closeProject(project, false, false, true);
    notifyProjectOpenFailed();
    return false;
  }

  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:76,代码来源:ProjectManagerImpl.java


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