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


Java ProjectUtil类代码示例

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


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

示例1: apply

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@Override
public void apply() throws ConfigurationException {
    try {
        PropertiesComponent.getInstance().setValue(KEY_RULES_PATH, rulesPath.getText());
        if (!TextUtils.isEmpty(rulesPath.getText())) {
            load(rulesPath.getText());
            DirectiveLint.prepare();
        } else {
            DirectiveLint.reset();
        }
    } catch (Exception e) {
        ProjectUtil.guessCurrentProject(select).getMessageBus().syncPublisher(Notifications.TOPIC).notify(
                new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
                        "Weex language support - bad rules",
                        e.toString(),
                        NotificationType.ERROR));
    }
    savePaths();
}
 
开发者ID:misakuo,项目名称:weex-language-support,代码行数:20,代码来源:Settings.java

示例2: setFileText

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
/**
 * @deprecated to be removed after IDEA 15. Use {@link VfsUtil#saveText(VirtualFile, String)} instead.
 */
public static void setFileText(@Nullable Project project, final VirtualFile virtualFile, final String text) throws IOException {
  if (project == null) {
    project = ProjectUtil.guessProjectForFile(virtualFile);
  }
  if (project != null) {
    final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
    final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
    final Document document = psiFile == null? null : psiDocumentManager.getDocument(psiFile);
    if (document != null) {
      document.setText(text != null ? text : "");
      psiDocumentManager.commitDocument(document);
      FileDocumentManager.getInstance().saveDocument(document);
      return;
    }
  }
  VfsUtil.saveText(virtualFile, text != null ? text : "");
  virtualFile.refresh(false, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FileContentUtil.java

示例3: applyLanguageSettings

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
private void applyLanguageSettings(Language lang) {
  final Project currProject = ProjectUtil.guessCurrentProject(getPanel());
  CodeStyleSettings rootSettings = CodeStyleSettingsManager.getSettings(currProject);
  CommonCodeStyleSettings sourceSettings = rootSettings.getCommonSettings(lang);
  CommonCodeStyleSettings targetSettings = getSettings().getCommonSettings(getDefaultLanguage());
  if (sourceSettings == null || targetSettings == null) return;
  if (!(targetSettings instanceof CodeStyleSettings)) {
    CommonCodeStyleSettingsManager.copy(sourceSettings, targetSettings);
  }
  else {
    Language targetLang = getDefaultLanguage();
    LOG.error((targetLang != null ? targetLang.getDisplayName() : "Unknown") +
              " language plug-in either uses an outdated API or does not initialize" +
              " its own code style settings in LanguageCodeStyleSettingsProvider.getDefaultSettings()." +
              " The operation can not be applied in this case.");
  }
  reset(getSettings());
  onSomethingChanged();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TabbedLanguageCodeStylePanel.java

示例4: updateEditor

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
private void updateEditor(boolean useDefaultSample) {
  if (!myShouldUpdatePreview || (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getComponent().isShowing())) {
    return;
  }

  if (myLastDocumentModificationStamp != myEditor.getDocument().getModificationStamp()) {
    myTextToReformat = myEditor.getDocument().getText();
  }
  else if (useDefaultSample || myTextToReformat == null) {
    myTextToReformat = getPreviewText();
  }

  int currOffs = myEditor.getScrollingModel().getVerticalScrollOffset();

  final Project finalProject = ProjectUtil.guessCurrentProject(getPanel());
  CommandProcessor.getInstance().executeCommand(finalProject, new Runnable() {
    @Override
    public void run() {
      replaceText(finalProject);
    }
  }, null, null);

  myEditor.getSettings().setRightMargin(getAdjustedRightMargin());
  myLastDocumentModificationStamp = myEditor.getDocument().getModificationStamp();
  myEditor.getScrollingModel().scrollVertically(currOffs);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:CodeStyleAbstractPanel.java

示例5: isIpythonNewFormat

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
public static boolean isIpythonNewFormat(@NotNull final VirtualFile virtualFile) {
  final Project project = ProjectUtil.guessProjectForFile(virtualFile);
  if (project != null) {
    final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
    if (module != null) {
      final Sdk sdk = PythonSdkType.findPythonSdk(module);
      if (sdk != null) {
        try {
          final PyPackage ipython = PyPackageManager.getInstance(sdk).findPackage("ipython", true);
          if (ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) {
            return false;
          }
        }
        catch (ExecutionException ignored) {
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:IpnbParser.java

示例6: getVariants

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@NotNull
@Override
public Object[] getVariants() {
  final Project project = myElement.getProject();
  PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(project);
  final List<LookupElement> variants = new ArrayList<LookupElement>();
  referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), new PropertiesFileProcessor() {
    public boolean process(String baseName, PropertiesFile propertiesFile) {
      final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS);
      final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project);
      variants.add(LookupElementBuilder.create(propertiesFile, baseName)
                     .withIcon(icon)
                     .withTailText(" (" + relativePath + ")", true));
      return true;
    }
  }, this);
  return variants.toArray(new LookupElement[variants.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:I18nReferenceContributor.java

示例7: createComponent

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@Nullable
@Override
public JComponent createComponent() {

    myProject = ProjectUtil.guessCurrentProject(myPanel);

    myConfig = JSRequireConfig.getInstanceForProject(myProject);

    mainJSRootDirTextField.setText(myConfig.getMainJSDirString());
    nodeModulesDirField.setText(myConfig.getNodeModulesDirString());
    deepIncludeNodeModulesField.setText(myConfig.getDeepIncludeModulesDirString());
    useRelativePathsCheckBox.setSelected(myConfig.getUseRelativePathsForMain());
    shouldIgnoreCase.setSelected(myConfig.getShouldIgnoreCase());
    useDoubleQuotesField.setSelected(myConfig.getShouldUseDoubleQuotes());

    return myPanel;
}
 
开发者ID:jballant,项目名称:CommonJSAutoComplete,代码行数:18,代码来源:CommonJSAutoCompleteConfigurable.java

示例8: setFileText

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
public static void setFileText(@Nullable Project project, final VirtualFile virtualFile, final String text) throws IOException {
  if (project == null) {
    project = ProjectUtil.guessProjectForFile(virtualFile);
  }
  if (project != null) {
    final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
    final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
    final Document document = psiFile == null? null : psiDocumentManager.getDocument(psiFile);
    if (document != null) {
      document.setText(text != null ? text : "");
      psiDocumentManager.commitDocument(document);
      FileDocumentManager.getInstance().saveDocument(document);
      return;
    }
  }
  VfsUtil.saveText(virtualFile, text != null ? text : "");
  virtualFile.refresh(false, false);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:FileContentUtil.java

示例9: createConfigureAnnotationsButton

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
public static JButton createConfigureAnnotationsButton() {
  final JButton configureAnnotations = new JButton("Configure annotations...");
  configureAnnotations.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      getInstance(ProjectUtil.guessCurrentProject(configureAnnotations)).configureAnnotations();
    }
  });
  return configureAnnotations;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:EntryPointsManagerImpl.java

示例10: navigate

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
private static void navigate(@Nullable Project project, @NotNull VirtualFile file, @NotNull OpenFileRequest request) {
  if (project == null) {
    project = getLastFocusedOrOpenedProject();
    if (project == null) {
      project = ProjectManager.getInstance().getDefaultProject();
    }
  }

  // OpenFileDescriptor line and column number are 0-based.
  new OpenFileDescriptor(project, file, Math.max(request.line - 1, 0), Math.max(request.column - 1, 0)).navigate(true);
  if (request.focused) {
    com.intellij.ide.impl.ProjectUtil.focusProjectWindow(project, true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OpenFileHttpService.java

示例11: openAbsolutePath

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@NotNull
private static Promise<Void> openAbsolutePath(@NotNull final File file, @NotNull final OpenFileRequest request) {
  if (!file.exists()) {
    return Promise.reject(NOT_FOUND);
  }

  final AsyncPromise<Void> promise = new AsyncPromise<Void>();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        VirtualFile virtualFile;
        AccessToken token = WriteAction.start();
        try {
          virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
        }
        finally {
          token.finish();
        }

        if (virtualFile == null) {
          promise.setError(NOT_FOUND);
        }
        else {
          navigate(ProjectUtil.guessProjectForContentFile(virtualFile), virtualFile, request);
          promise.setResult(null);
        }
      }
      catch (Throwable e) {
        promise.setError(e);
      }
    }
  });
  return promise;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:OpenFileHttpService.java

示例12: getAnchor

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@NotNull
private static Component getAnchor(@NotNull JRootPane pane) {
  Component tabWrapper = UIUtil.findComponentOfType(pane, TabbedPaneWrapper.TabWrapper.class);
  if (tabWrapper != null) return tabWrapper;
  Component splitters = UIUtil.findComponentOfType(pane, EditorsSplitters.class);
  if (splitters != null) return splitters;
  FileEditorManagerEx ex = FileEditorManagerEx.getInstanceEx(ProjectUtil.guessCurrentProject(pane));
  return ex == null ? pane : ex.getSplitters();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:InfoAndProgressPanel.java

示例13: createHighlighter

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@Override
@Nullable
protected EditorHighlighter createHighlighter(final EditorColorsScheme scheme) {
  FileType fileType = getFileType();
  return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType).getEditorHighlighter(
    ProjectUtil.guessCurrentProject(getPanel()), fileType, null, scheme);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CustomizableLanguageCodeStylePanel.java

示例14: processElementsWithName

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
@Override
public void processElementsWithName(@NotNull String name,
                                    @NotNull final Processor<NavigationItem> _processor,
                                    @NotNull FindSymbolParameters parameters) {
  final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries();
  final Processor<PsiFileSystemItem> processor = new Processor<PsiFileSystemItem>() {
    @Override
    public boolean process(PsiFileSystemItem item) {
      if (!globalSearch && ProjectUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) {
        return true;
      }
      return _processor.process(item);
    }
  };
  
  String completePattern = parameters.getCompletePattern();
  final boolean includeDirs = completePattern.endsWith("/") || completePattern.endsWith("\\") ||
                              completePattern.startsWith("/") || completePattern.startsWith("\\");
  boolean result = FilenameIndex.processFilesByName(
    name, includeDirs, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter()
  );
  if (!result && includeDirs) {
    FilenameIndex.processFilesByName(
      name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter()
    );
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:DefaultFileNavigationContributor.java

示例15: getRelativeToProjectPath

import com.intellij.openapi.project.ProjectUtil; //导入依赖的package包/类
public String getRelativeToProjectPath() {
  if (myRelativeToProjectPath == null) {
    final PsiDirectory directory = getDirectory();
    final VirtualFile virtualFile = directory != null ? directory.getVirtualFile() : null;
    myRelativeToProjectPath = virtualFile != null
           ? ProjectUtil.calcRelativeToProjectPath(virtualFile, directory.getProject(), true, false, true)
           : getPresentableUrl();
  }
  return myRelativeToProjectPath;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:DirectoryChooser.java


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