本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent类的典型用法代码示例。如果您正苦于以下问题:Java VFilePropertyChangeEvent类的具体用法?Java VFilePropertyChangeEvent怎么用?Java VFilePropertyChangeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VFilePropertyChangeEvent类属于com.intellij.openapi.vfs.newvfs.events包,在下文中一共展示了VFilePropertyChangeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reparseFiles
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的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);
}
});
}
示例2: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(@NotNull final VirtualFile virtualFile, @NotNull final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例3: reparseFiles
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的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));
}
});
}
示例4: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(final VirtualFile virtualFile, final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例5: handleFileEvent
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的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);
}
}
}
示例6: handleFileRenameEvent
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的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: reparseFiles
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
@RequiredDispatchThread
public static void reparseFiles(@Nonnull 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);
}
});
}
示例8: saveOrReload
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
@RequiredWriteAction
private static void saveOrReload(VirtualFile file, @Nonnull Collection<VFilePropertyChangeEvent> events) {
if (file == null || file.isDirectory() || !file.isValid()) {
return;
}
FileDocumentManager documentManager = FileDocumentManager.getInstance();
if (documentManager.isFileModified(file)) {
Document document = documentManager.getDocument(file);
if (document != null) {
documentManager.saveDocument(document);
}
}
events.add(new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, file, VirtualFile.PROP_NAME, file.getName(), file.getName(), false));
}
示例9: notifyPropertyChanged
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
@Override
public void notifyPropertyChanged(@Nonnull final VirtualFile virtualFile, @Nonnull final String property, final Object oldValue, final Object newValue) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (virtualFile.isValid() && !application.isDisposed()) {
application.runWriteAction(new Runnable() {
@Override
public void run() {
List<VFilePropertyChangeEvent> events = Collections
.singletonList(new VFilePropertyChangeEvent(this, virtualFile, property, oldValue, newValue, false));
BulkFileListener listener = application.getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
listener.before(events);
listener.after(events);
}
});
}
}
};
application.invokeLater(runnable, ModalityState.NON_MODAL);
}
示例10: GistManagerImpl
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
public GistManagerImpl() {
ApplicationManager.getApplication().getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@Nonnull List<? extends VFileEvent> events) {
if (events.stream().anyMatch(this::shouldDropCache)) {
invalidateData();
}
}
private boolean shouldDropCache(VFileEvent e) {
if (!(e instanceof VFilePropertyChangeEvent)) return false;
String propertyName = ((VFilePropertyChangeEvent)e).getPropertyName();
return propertyName.equals(VirtualFile.PROP_NAME) || propertyName.equals(VirtualFile.PROP_ENCODING);
}
});
}
示例11: VirtualFilePropertyEvent
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
public VirtualFilePropertyEvent(Object requestor, @NotNull VirtualFile file, @NotNull String propertyName, Object oldValue, Object newValue){
super(requestor, file, file.getName(), file.getParent());
myPropertyName = propertyName;
myOldValue = oldValue;
myNewValue = newValue;
VFilePropertyChangeEvent.checkPropertyValuesCorrect(requestor, propertyName, oldValue, newValue);
}
示例12: saveOrReload
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
private static void saveOrReload(VirtualFile file, @NotNull Collection<VFilePropertyChangeEvent> events) {
if (file == null || file.isDirectory() || !file.isValid()) {
return;
}
FileDocumentManager documentManager = FileDocumentManager.getInstance();
if (documentManager.isFileModified(file)) {
Document document = documentManager.getDocument(file);
if (document != null) {
documentManager.saveDocumentAsIs(document); // this can be called e.g. in context of undo, so we shouldn't modify document
}
}
events.add(new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, file, VirtualFile.PROP_NAME, file.getName(), file.getName(), false));
}
示例13: after
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的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);
}
}
}
示例14: saveOrReload
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
private static void saveOrReload(final VirtualFile virtualFile, Collection<VFilePropertyChangeEvent> events) {
if (virtualFile == null || virtualFile.isDirectory() || !virtualFile.isValid()) {
return;
}
final FileDocumentManager documentManager = FileDocumentManager.getInstance();
if (documentManager.isFileModified(virtualFile)) {
Document document = documentManager.getDocument(virtualFile);
if (document != null) {
documentManager.saveDocument(document);
}
}
events.add(
new VFilePropertyChangeEvent(FORCE_RELOAD_REQUESTOR, virtualFile, VirtualFile.PROP_NAME, virtualFile.getName(), virtualFile.getName(),
false));
}
示例15: isMoveOrRename
import com.intellij.openapi.vfs.newvfs.events.VFilePropertyChangeEvent; //导入依赖的package包/类
private boolean isMoveOrRename( VFileEvent event )
{
return event instanceof VFilePropertyChangeEvent && ((VFilePropertyChangeEvent)event).getPropertyName().equals( VirtualFile.PROP_NAME ) ||
event instanceof VFileMoveEvent;
}