本文整理汇总了Java中com.intellij.openapi.vfs.LocalFileSystem类的典型用法代码示例。如果您正苦于以下问题:Java LocalFileSystem类的具体用法?Java LocalFileSystem怎么用?Java LocalFileSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalFileSystem类属于com.intellij.openapi.vfs包,在下文中一共展示了LocalFileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findProject
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Nullable
private Project findProject(String file) {
LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
ProjectLocator projectLocator = ProjectLocator.getInstance();
AtomicReference<Project> ret = new AtomicReference<>();
FileUtil.processFilesRecursively(
new File(file),
(f) -> {
VirtualFile vf = localFileSystem.findFileByIoFile(f);
if (vf != null) {
ret.set(projectLocator.guessProjectForFile(vf));
return false;
}
return true;
});
return ret.get();
}
示例2: getDictionaryFileFromInclude
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Nullable
private static XmlFile getDictionaryFileFromInclude(@NotNull Project project, IncludedXmlTag xmlIncludeTag) {
XmlFile xmlFile = null;
XmlElement origXmlElement = xmlIncludeTag.getOriginal();
PsiFile origPsiFile = origXmlElement != null ? origXmlElement.getContainingFile() : null;
if (origPsiFile instanceof XmlFile) {
xmlFile = (XmlFile) origPsiFile;
AppleScriptSystemDictionaryRegistryService dictionaryService = ServiceManager.getService(AppleScriptSystemDictionaryRegistryService
.class);
VirtualFile vFile = origPsiFile.getVirtualFile();
DictionaryInfo dInfo = dictionaryService.getDictionaryInfoByApplicationPath(vFile.getPath());
if (dInfo != null) {
File ioFile = dInfo.getDictionaryFile();
if (ioFile.exists()) {
vFile = LocalFileSystem.getInstance().findFileByIoFile(ioFile);
if (vFile == null || !vFile.isValid()) return null;
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
xmlFile = (XmlFile) psiFile;
}
}
}
return xmlFile;
}
示例3: createDictionaryFromInfo
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Nullable
private ApplicationDictionary createDictionaryFromInfo(final @NotNull DictionaryInfo dInfo) {
if (!dInfo.isInitialized()) {
//dictionary terms must be ridden from the dictionary file before creating a PSI for it
LOG.error("Attempt to create dictionary for not initialized Dictionary Info for application" + dInfo.getApplicationName());
return null;
}
String applicationName = dInfo.getApplicationName();
VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(dInfo.getDictionaryFile());
if (vFile != null && vFile.isValid()) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
XmlFile xmlFile = (XmlFile) psiFile;
if (xmlFile != null) {
ApplicationDictionary dictionary = new ApplicationDictionaryImpl(project, xmlFile, applicationName, dInfo.getApplicationFile());
dictionaryMap.put(applicationName, dictionary);
return dictionary;
}
}
LOG.warn("Failed to create dictionary from info for application: " + applicationName + ". Reason: file is null");
return null;
}
示例4: openFileInPanel
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
/**
* 打开类文件
*
* @param filePath
* @param project
*/
public static void openFileInPanel(final String filePath, final Project project) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
if (file != null && file.isValid()) {
FileEditorProvider[] providers = FileEditorProviderManager.getInstance()
.getProviders(project, file);
if (providers.length != 0) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
FileEditorManager.getInstance(project).openTextEditor(descriptor, false);
}
}
}
});
}
示例5: diff
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
/**
* 调用 Android 文件对比
* @param project
* @param f1
* @param f2
*/
public static void diff(final Project project, final File f1, final File f2) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
try {
VirtualFile v1 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f1);
Document document1 = FileDocumentManager.getInstance().getDocument(v1);
FileDocumentContentImpl fileDocumentContent1 = new FileDocumentContentImpl(project, document1, v1);
VirtualFile v2 = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f2);
Document document2 = FileDocumentManager.getInstance().getDocument(v2);
FileDocumentContentImpl fileDocumentContent2 = new FileDocumentContentImpl(project, document2, v2);
SimpleDiffRequest simpleDiffRequest = new SimpleDiffRequest(Constant.TITLE, fileDocumentContent1, fileDocumentContent2,
f1.getName(), f2.getName());
DiffManager.getInstance().showDiff(project, simpleDiffRequest);
} catch (Exception e) {
NotificationUtils.errorNotification("Diff Source Error:" + e.getMessage());
}
}
});
}
示例6: removeAllFiles
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
public void removeAllFiles(@NotNull final Collection<File> files) throws IOException {
Validate.notNull(files);
if (files.isEmpty()) {
return;
}
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
for (File file : files) {
final VirtualFile virtualFile = localFileSystem.findFileByIoFile(file);
if (null != virtualFile) {
ApplicationManager.getApplication().runWriteAction(new RemoveFileComputable(virtualFile));
} else {
FileUtil.delete(file);
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:DefaultVirtualFileSystemService.java
示例7: addDetectedSdk
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
private static Sdk addDetectedSdk(@NotNull Sdk sdk, @NotNull Project project) {
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
final String name = sdk.getName();
VirtualFile sdkHome = WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(name));
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkUpdater.updateOrShowError(sdk, null, project, null);
}
model.addSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
return sdk;
}
示例8: getCurrentTaskFilePath
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Nullable
private String getCurrentTaskFilePath() {
String textFile = null;
for (Map.Entry<String, TaskFile> entry : myTask.getTaskFiles().entrySet()) {
String path = getTaskFilePath(entry.getKey());
if (!entry.getValue().getActivePlaceholders().isEmpty()) {
return path;
}
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
if (virtualFile == null) {
continue;
}
if (TextEditorProvider.isTextFile(virtualFile)) {
textFile = path;
}
}
return textFile;
}
示例9: checkConfiguration
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
super.checkConfiguration();
String message = "Select valid path to the file with tests";
VirtualFile testsFile = LocalFileSystem.getInstance().findFileByPath(myPathToTest);
if (testsFile == null) {
throw new RuntimeConfigurationException(message);
}
VirtualFile taskDir = StudyUtils.getTaskDir(testsFile);
if (taskDir == null) {
throw new RuntimeConfigurationException(message);
}
if (StudyUtils.getTask(myProject, taskDir) == null) {
throw new RuntimeConfigurationException(message);
}
}
示例10: getAllAnswerTaskFiles
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
private static List<VirtualFile> getAllAnswerTaskFiles(@NotNull Course course, @NotNull Project project) {
List<VirtualFile> result = new ArrayList<>();
for (Lesson lesson : course.getLessons()) {
for (Task task : lesson.getTaskList()) {
for (Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
String name = entry.getKey();
String answerName = FileUtil.getNameWithoutExtension(name) + CCUtils.ANSWER_EXTENSION_DOTTED + FileUtilRt.getExtension(name);
String taskPath = FileUtil.join(project.getBasePath(), EduNames.LESSON + lesson.getIndex(), EduNames.TASK + task.getIndex());
VirtualFile taskFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.join(taskPath, answerName));
if (taskFile == null) {
taskFile = LocalFileSystem.getInstance().findFileByPath(FileUtil.join(taskPath, EduNames.SRC, answerName));
}
if (taskFile != null) {
result.add(taskFile);
}
}
}
}
return result;
}
示例11: actionPerformed
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
Project project = anActionEvent.getProject();
if (project != null) {
String currentApkPath = PropertiesManager.getData(project, PropertyKeys.APK_PATH);
VirtualFile fileToSelectOnCreate =
TextUtils.isEmpty(currentApkPath)
? project.getBaseDir()
: LocalFileSystem.getInstance().findFileByPath(currentApkPath);
VirtualFile apkFile = new FileChooserDialogManager.Builder(project, fileToSelectOnCreate)
.setFileTypes(FileTypes.FILE)
.setTitle(Strings.TITLE_ASK_APK_FILE)
.setDescription(Strings.MESSAGE_ASK_APK_FILE)
.withFileFilter("apk")
.create()
.getSelectedFile();
if (apkFile != null) {
PropertiesManager.putData(project, PropertyKeys.APK_PATH, apkFile.getPath());
}
}
}
示例12: onSettingsChange
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
@SuppressWarnings("ConstantConditions")
public void onSettingsChange() {
prepareTemplateSettings();
for (IdeFrame frame : WindowManager.getInstance().getAllProjectFrames()) {
if (frame.getProject() != null) {
String projectTitle = getProjectTitle(frame.getProject());
((IdeFrameImpl)frame).setTitle(projectTitle);
try {
File currentFile = (File)((IdeFrameImpl) frame).getRootPane().getClientProperty("Window.documentFile");
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(currentFile);
IdeFrameImpl.updateTitle((IdeFrameImpl) frame, projectTitle, getFileTitle(frame.getProject(), virtualFile), currentFile);
} catch (Exception e) {
IdeFrameImpl.updateTitle((IdeFrameImpl) frame, projectTitle, null, null);
}
}
}
}
示例13: validate
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
public boolean validate() throws ConfigurationException {
if (form.getGravDirectory().isEmpty()) {
form.showHint(true);
throw new ConfigurationException("Path pointing to Grav installation is empty");
} else {
String file = form.getGravDirectory();
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(file));
if (vf == null) {
form.showHint(true);
throw new ConfigurationException("Path to Grav installation does not exist");
} else {
if (!GravSdkType.isValidGravSDK(vf)) {
form.showHint(true);
throw new ConfigurationException("Grav installation isn't valid");
}
}
}
// if (StringUtil.isEmpty(sdkPanel.getSdkName())) {
// throw new ConfigurationException("Specify Grav SDK");
// }
form.showHint(false);
return super.validate();
}
示例14: validate0
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
private int validate0() {
if (form.getGravDirectory().isEmpty()) {
form.showHint(true);
return -1;//new ValidationInfo("Path pointing to Grav installation is empty");
} else {
String file = form.getGravDirectory();
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(file));
if (vf == null) {
form.showHint(true);
return -2; //new ValidationInfo("Path to Grav installation does not exist");
} else {
if (!GravSdkType.isValidGravSDK(vf)) {
form.showHint(true);
return -3; //new ValidationInfo("Grav installation isn't valid");
}
}
}
form.showHint(false);
return 0;
}
示例15: generateProject
import com.intellij.openapi.vfs.LocalFileSystem; //导入依赖的package包/类
@Override
public void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull GravProjectSettings settings, @NotNull Module module) {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(settings.gravInstallationPath));
if (vf == null || !GravSdkType.isValidGravSDK(vf)) {
JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder("Project couldn't be created because Grav Installation isn't valid", MessageType.ERROR, null)
.setFadeoutTime(3500)
.createBalloon()
.show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
} else {
storage.setDefaultGravDownloadPath(settings.gravInstallationPath);
PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(settings.gravInstallationPath).getAbsolutePath());
GravProjectGeneratorUtil projectGenerator = new GravProjectGeneratorUtil();
projectGenerator.generateProject(project, baseDir, settings, module);
try {
List<String> includePath = new ArrayList<>();
includePath.add(baseDir.getPath());
PhpIncludePathManager.getInstance(project).setIncludePath(includePath);
} catch (Exception e) {
e.printStackTrace();
}
}
}