本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.events.VFileEvent类的典型用法代码示例。如果您正苦于以下问题:Java VFileEvent类的具体用法?Java VFileEvent怎么用?Java VFileEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VFileEvent类属于com.intellij.openapi.vfs.newvfs.events包,在下文中一共展示了VFileEvent类的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( final List<? extends VFileEvent> events )
{
if( _project.isDisposed() )
{
return;
}
DumbService dumb = DumbService.getInstance( _project );
if( dumb.isDumb() )
{
dumb.smartInvokeLater( () -> _after( events ) );
}
else
{
ApplicationManager.getApplication().invokeLater( () ->_after( events ) );
}
}
示例3: 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);
}
}
}
示例4: reparseFiles
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
/**
* Forces a reparse of the specified collection of files.
*
* @param files the files to reparse.
*/
public static void reparseFiles(@NotNull final Collection<VirtualFile> files) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// files must be processed under one write action to prevent firing event for invalid files.
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
for (VirtualFile file : files) {
saveOrReload(file, events);
}
BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
List<VFileEvent> eventList = new ArrayList<VFileEvent>(events);
publisher.before(eventList);
publisher.after(eventList);
}
});
}
示例5: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
boolean scheduleRefresh = false;
for (VFileEvent event : events) {
String changedPath = event.getPath();
for (MyEntry entry : myAutoImportAware) {
String projectPath = entry.aware.getAffectedExternalProjectPath(changedPath, myProject);
if (projectPath == null) {
continue;
}
ExternalProjectSettings projectSettings = entry.systemSettings.getLinkedProjectSettings(projectPath);
if (projectSettings != null && projectSettings.isUseAutoImport()) {
addPath(entry.externalSystemId, projectPath);
scheduleRefresh = true;
break;
}
}
}
if (scheduleRefresh) {
myVfsAlarm.cancelAllRequests();
myVfsAlarm.addRequest(myFilesRequest, ExternalSystemConstants.AUTO_IMPORT_DELAY_MILLIS);
}
}
示例6: testManyPointersUpdatePerformance
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
public void testManyPointersUpdatePerformance() throws IOException {
LoggingListener listener = new LoggingListener();
final List<VFileEvent> events = new ArrayList<VFileEvent>();
final File ioTempDir = createTempDirectory();
final VirtualFile temp = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioTempDir);
for (int i=0; i<100000; i++) {
myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/" + i), disposable, listener);
events.add(new VFileCreateEvent(this, temp, "xxx" + i, false, true));
}
PlatformTestUtil.startPerformanceTest("vfp update", 10000, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
for (int i=0; i<100; i++) {
// simulate VFS refresh events since launching the actual refresh is too slow
myVirtualFilePointerManager.before(events);
myVirtualFilePointerManager.after(events);
}
}
}).assertTiming();
}
示例7: 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;
}
}
}
示例8: AndroidProjectTreeBuilder
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
public AndroidProjectTreeBuilder(@NotNull Project project,
@NotNull JTree tree,
@NotNull DefaultTreeModel treeModel,
@Nullable Comparator<NodeDescriptor> comparator,
@NotNull ProjectAbstractTreeStructureBase treeStructure) {
super(project, tree, treeModel, comparator, treeStructure);
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent e : events) {
if (e instanceof VFileDeleteEvent) {
removeMapping(e.getFile());
}
}
}
});
}
示例9: reparseFiles
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
public static void reparseFiles(@NotNull final Collection<VirtualFile> files) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// files must be processed under one write action to prevent firing event for invalid files.
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
for (VirtualFile file : files) {
saveOrReload(file, events);
}
ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
.before(new ArrayList<VFileEvent>(events));
ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES)
.after(new ArrayList<VFileEvent>(events));
}
});
}
示例10: activate
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
public void activate() {
if (messageBusConnection != null) {
return;
}
messageBusConnection = project.getMessageBus().connect();
messageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent event : events) {
if (event instanceof VFileDeleteEvent) {
synchronized (changedFiles) {
changedFiles.remove(event.getFile());
}
}
}
}
});
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(listener, project);
}
示例11: testManyPointersUpdatePerformance
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
public void testManyPointersUpdatePerformance() throws IOException {
FilePointerPartNode.pushDebug(false, disposable);
LoggingListener listener = new LoggingListener();
final List<VFileEvent> events = new ArrayList<VFileEvent>();
final File ioTempDir = createTempDirectory();
final VirtualFile temp = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioTempDir);
for (int i=0; i<100000; i++) {
myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/" + i), disposable, listener);
events.add(new VFileCreateEvent(this, temp, "xxx" + i, false, true));
}
PlatformTestUtil.startPerformanceTest("vfp update", 10000, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
for (int i=0; i<100; i++) {
// simulate VFS refresh events since launching the actual refresh is too slow
myVirtualFilePointerManager.before(events);
myVirtualFilePointerManager.after(events);
}
}
}).assertTiming();
}
示例12: 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);
}
}
}
示例13: after
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
/**
* Handler method that is called after the file change has been executed by IntelliJ, analyzes file deletes, moves
* and renames and calls the change handler (in a separate thread) that handles all the changes and is also used
* to present a dialog asking the user if the file change should be reflected in the OpenCms VFS as well.
* @param vFileEvents List of file events, provided by IntelliJ
*/
public void after(@NotNull List<? extends VFileEvent> vFileEvents) {
try {
if (config == null || !config.isOpenCmsPluginEnabled()) {
return;
}
for (VFileEvent event : vFileEvents) {
handleFileEvent(event);
}
if (changeHandler.hasAffectedFiles()) {
ApplicationManager.getApplication().invokeLater(changeHandler);
}
}
catch (CmsConnectionException e) {
LOG.error("Error syncing file deletion/move/rename to OpenCms:\n" + e.getMessage(), e);
}
finally {
deletedFileModuleLookup.clear();
}
}
示例14: handleFileEvent
import com.intellij.openapi.vfs.newvfs.events.VFileEvent; //导入依赖的package包/类
/**
* Internal handler for file delete, move and rename events
* @param event IntelliJ's file change event
* @throws CmsConnectionException if the connection to OpenCms fails
*/
private void handleFileEvent(VFileEvent event) throws CmsConnectionException {
// File is deleted
if (event instanceof VFileDeleteEvent) {
handleFileDeleteEvent(event);
}
// File is moved
if (event instanceof VFileMoveEvent) {
handleFileMoveEvent(event);
}
// File is renamed
if (event instanceof VFilePropertyChangeEvent) {
String propertyName = ((VFilePropertyChangeEvent)event).getPropertyName();
if ("name".equals(propertyName)) {
handleFileRenameEvent(event);
}
}
}
示例15: 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);
}
}
}
}