本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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()]);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
示例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()
);
}
}
示例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;
}