本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.events.VFileEvent.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java VFileEvent.getFile方法的具体用法?Java VFileEvent.getFile怎么用?Java VFileEvent.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.newvfs.events.VFileEvent
的用法示例。
在下文中一共展示了VFileEvent.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _before
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
private void _before( final List<? extends VFileEvent> events )
{
if( _project.isDisposed() )
{
return;
}
for( VFileEvent event : events )
{
final VirtualFile file = event.getFile();
if( file != null )
{
if( isMoveOrRename( event ) )
{
processRenameBefore( event );
}
}
}
}
示例2: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
public void after(List<? extends VFileEvent> events) {
String sources = Utils.getPropertyValue("sources", true);
List<String> sourcesList = Utils.getSourcesList(sources);
for (VFileEvent e : events) {
VirtualFile virtualFile = e.getFile();
if (virtualFile != null && sourcesList.contains(virtualFile.getName()) && SOURCE_FOLDER_DEFAULT.equals(virtualFile.getParent().getName())) {
Project[] projects = ProjectManager.getInstance().getOpenProjects();
Project project = null;
if (projects.length == 1) {
project = projects[0];
}
System.out.println("Changed file " + virtualFile.getCanonicalPath());
Crowdin crowdin = new Crowdin();
String branch = Utils.getCurrentBranch(project);
crowdin.uploadFile(virtualFile, branch);
}
}
}
示例3: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
CaptureService service = CaptureService.getInstance(myProject);
VirtualFile captures = service.getCapturesDirectory();
if (captures == null) {
if (!service.getCaptures().isEmpty()) {
queueUpdate();
}
return;
}
for (VFileEvent event : events) {
if (event.getFile() != null && VfsUtilCore.isAncestor(captures, event.getFile(), false)) {
queueUpdate();
return;
}
}
}
示例4: before
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
/**
* Handler method that is called before IntelliJ executes the file change, stores a lookup of IntelliJ modules for
* deleted files because the module can't be determined after the delete is executed
* @param vFileEvents List of file events, provided by IntelliJ
*/
public void before(@NotNull List<? extends VFileEvent> vFileEvents) {
// sometimes file events occur before the plugin was initialized, so lets make sure we have a plugin, a project and a configuration
if (plugin == null || plugin.getProject() == null || config == null || !config.isOpenCmsPluginEnabled()) {
return;
}
// save all modules for deleted files in a lookup map, because IntelliJ can't find the module after the
// deletion of directories (ModuleUtil.findModuleForFile returns null in that case)
for (VFileEvent event : vFileEvents) {
if (event instanceof VFileDeleteEvent) {
VirtualFile ideaVFile = event.getFile();
if (ideaVFile == null) {
continue;
}
Module ideaModule = ModuleUtil.findModuleForFile(ideaVFile, plugin.getProject());
if (ideaModule == null) {
continue;
}
deletedFileModuleLookup.put(ideaVFile, ideaModule);
}
}
}
示例5: handleFileDeleteEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
/**
* Internal handler for file delete events, fills a list of files to be deleted that is handled later in
* {@link OpenCmsModuleFileChangeHandler#handleChanges()}
* @param event IntelliJ's file change event
* @throws CmsConnectionException if the connection to OpenCms fails
*/
private void handleFileDeleteEvent(VFileEvent event) throws CmsConnectionException {
VirtualFile ideaVFile = event.getFile();
if (ideaVFile != null) {
String moduleBasePath = PluginTools.getModuleContentRoot(deletedFileModuleLookup.get(ideaVFile));
OpenCmsModule ocmsModule = openCmsModules.getModuleForBasePath(moduleBasePath);
// check if the file belongs to an OpenCms module
if (ocmsModule != null && ocmsModule.isPathModuleResource(ideaVFile.getPath())) {
LOG.info("The following module resource was deleted: " + ideaVFile.getPath());
String vfsPath = ocmsModule.getVfsPathForRealPath(ideaVFile.getPath());
try {
if (getVfsAdapter().exists(vfsPath)) {
changeHandler.addFileToBeDeleted(ocmsModule, vfsPath, ideaVFile.isDirectory());
}
}
catch (CmisPermissionDeniedException e) {
throw new CmsConnectionException("A local file has been deleted, but it can't be checked if the file exists in the VFS (permission denied).\nPlease check manually: " + vfsPath);
}
}
}
}
示例6: handleFileRenameEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
/**
* Internal handler for file rename events fills a list of files to be renamed that is handled later in
* {@link OpenCmsModuleFileChangeHandler#handleChanges()}
* @param event IntelliJ's file change event
* @throws CmsConnectionException if the connection to OpenCms fails
*/
private void handleFileRenameEvent(VFileEvent event) throws CmsConnectionException {
VirtualFile ideaVFile = event.getFile();
if (ideaVFile != null) {
String renameFilePath = ideaVFile.getPath();
OpenCmsModule ocmsModule = openCmsModules.getModuleForPath(renameFilePath);
if (ocmsModule != null) {
LOG.debug("The following file was renamed: " + ideaVFile.getPath());
String oldName = (String)((VFilePropertyChangeEvent)event).getOldValue();
String newName = (String)((VFilePropertyChangeEvent)event).getNewValue();
String newVfsPath = ocmsModule.getVfsPathForRealPath(renameFilePath);
String oldVfsPath = newVfsPath.replaceFirst(newName, oldName);
if (!oldVfsPath.equals(newVfsPath) && ocmsModule.isPathModuleResource(ocmsModule.getLocalVfsRoot() + oldVfsPath) && getVfsAdapter().exists(oldVfsPath)) {
changeHandler.addFileToBeRenamed(ocmsModule, ideaVFile, oldVfsPath, newVfsPath, newName);
}
}
}
}
示例7: _after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
private void _after( final List<? extends VFileEvent> events )
{
if( _project.isDisposed() )
{
return;
}
for( VFileEvent event : events )
{
final VirtualFile file = event.getFile();
if( file != null )
{
if( event instanceof VFileCreateEvent )
{
fireCreatedEvent( file );
}
else if( event instanceof VFileDeleteEvent )
{
fireDeletedEvent( file );
}
else if( event instanceof VFileCopyEvent )
{
processFileCopyEvent( (VFileCopyEvent)event );
}
else if( isMoveOrRename( event ) )
{
processRenameAfter( event );
}
else // modified
{
ApplicationManager.getApplication().runReadAction( () -> fireModifiedEvent( file ) );
}
}
}
}
示例8: processRenameBefore
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
private void processRenameBefore( VFileEvent event )
{
VirtualFile originalFile = event.getFile();
if( originalFile instanceof LightVirtualFile )
{
return;
}
// Handle the Deletion *before* it is renamed
fireDeletedEvent( originalFile );
}
示例9: processRenameAfter
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
private void processRenameAfter( VFileEvent event )
{
VirtualFile renamedFile = event.getFile();
if( renamedFile instanceof LightVirtualFile )
{
return;
}
// Handle the Creation *after* it is renamed
fireCreatedEvent( renamedFile );
}
示例10: before
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@Override
public void before(@NotNull List<? extends VFileEvent> vFileEvents) {
for (VFileEvent fe : vFileEvents) {
if(fe.getFile()!=null){
System.out.println("before(getCanonicalPath)->" + fe.getFile().getCanonicalPath());
System.out.println("before(getName)->" + fe.getFile().getName());
System.out.println("before(getLength)->" + fe.getFile().getLength());
}
}
}
示例11: resetOnEvents
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
boolean resetOnEvents(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
VirtualFile file = event.getFile();
if (file == null || file.isDirectory()) {
return true;
}
}
return false;
}
示例12: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
final VirtualFile[] roots = mySdk.getRootProvider().getFiles(OrderRootType.CLASSES);
for (VFileEvent event : events) {
final VirtualFile file = event.getFile();
if (file != null) {
for (VirtualFile root : roots) {
if (VfsUtilCore.isAncestor(root, file, false)) {
clearCaches();
return;
}
}
}
}
}
示例13: getFilesToProcess
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@NotNull
private static Set<VirtualFile> getFilesToProcess(@NotNull List<? extends VFileEvent> events) {
final Set<VirtualFile> result = new HashSet<VirtualFile>();
for (VFileEvent event : events) {
final VirtualFile file = event.getFile();
if (file != null && shouldScheduleUpdate(file)) {
result.add(file);
}
}
return result;
}
示例14: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
VirtualFile file = event.getFile();
VirtualFile root = getRootForIndexFile(file);
if (root != null) {
myDirtyScopeManager.dirDirtyRecursively(root);
}
root = getRootForChangeBranch(file);
if (root != null) {
myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, root);
}
}
}
示例15: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入方法依赖的package包/类
@Override
public void after(List<? extends VFileEvent> events) {
if (!enabled) {
return;
}
for (VFileEvent event : events) {
VirtualFile modifiedFile = null;
// Skip delete events.
if (event instanceof VFileContentChangeEvent || event instanceof VFileCreateEvent) {
modifiedFile = event.getFile();
} else if (event instanceof VFileCopyEvent) {
VFileCopyEvent copyEvent = (VFileCopyEvent) event;
modifiedFile = copyEvent.getNewParent();
} else if (event instanceof VFileMoveEvent) {
VFileMoveEvent moveEvent = (VFileMoveEvent) event;
modifiedFile = moveEvent.getNewParent();
} else if (event instanceof VFilePropertyChangeEvent) {
VFilePropertyChangeEvent propEvent = (VFilePropertyChangeEvent) event;
// Check for file renames (sometimes we get property change events without the name
// actually changing though)
if (propEvent.getPropertyName().equals(VirtualFile.PROP_NAME)
&& !propEvent.getOldValue().equals(propEvent.getNewValue())) {
modifiedFile = propEvent.getFile();
}
}
if (SymbolTableProvider.isSourceFile(modifiedFile)) {
queueChange(modifiedFile);
}
}
}