List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys PROJECT_FILE_DIRECTORY
DataKey PROJECT_FILE_DIRECTORY
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys PROJECT_FILE_DIRECTORY.
Click Source Link
From source file:com.intellij.ide.impl.dataRules.ProjectFileDirectoryRule.java
License:Apache License
public Object getData(DataProvider dataProvider) { VirtualFile dir = PlatformDataKeys.PROJECT_FILE_DIRECTORY.getData(dataProvider); if (dir == null) { final Project project = CommonDataKeys.PROJECT.getData(dataProvider); if (project != null) { dir = project.getBaseDir();//w w w .j a v a 2 s . co m } } return dir; }
From source file:com.intellij.ide.macro.FileRelativeDirMacro.java
License:Apache License
@Override public String expand(DataContext dataContext) { final VirtualFile baseDir = PlatformDataKeys.PROJECT_FILE_DIRECTORY.getData(dataContext); if (baseDir == null) { return null; }/*from w w w . j a v a 2s.co m*/ VirtualFile dir = getVirtualDirOrParent(dataContext); if (dir == null) return null; return FileUtil.getRelativePath(VfsUtil.virtualToIoFile(baseDir), VfsUtil.virtualToIoFile(dir)); }
From source file:com.intellij.ide.macro.MacroManagerTest.java
License:Apache License
public DataContext getContext(VirtualFile file) { Project project = myFixture.getProject(); Map<String, Object> dataId2data = new THashMap<String, Object>(); dataId2data.put(CommonDataKeys.PROJECT.getName(), project); dataId2data.put(PlatformDataKeys.VIRTUAL_FILE.getName(), file); dataId2data.put(PlatformDataKeys.PROJECT_FILE_DIRECTORY.getName(), project.getBaseDir()); return SimpleDataContext.getSimpleContext(dataId2data, null); }
From source file:com.intellij.ide.macro.ProjectFileDirMacro.java
License:Apache License
@Override @Nullable/*from ww w. j a v a 2 s . c o m*/ public String expand(DataContext dataContext) { final VirtualFile baseDir = PlatformDataKeys.PROJECT_FILE_DIRECTORY.getData(dataContext); if (baseDir == null) { return null; } return VfsUtil.virtualToIoFile(baseDir).getPath(); }
From source file:com.twitter.intellij.pants.macro.FilePathRelativeToBuiltRootMacroTest.java
License:Apache License
private DataContext getFakeContext(VirtualFile file) { Map<String, Object> dataId2data = new THashMap<String, Object>(); dataId2data.put(CommonDataKeys.PROJECT.getName(), myProject); dataId2data.put(CommonDataKeys.VIRTUAL_FILE.getName(), file); dataId2data.put(PlatformDataKeys.PROJECT_FILE_DIRECTORY.getName(), myProject.getBaseDir()); return SimpleDataContext.getSimpleContext(dataId2data, null); }