com.intellij.openapi.vfs.VirtualFilePropertyEvent Java Examples
The following examples show how to use
com.intellij.openapi.vfs.VirtualFilePropertyEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorBasedStatusBarPopup.java From consulo with Apache License 2.0 | 6 votes |
@Override public void install(@Nonnull StatusBar statusBar) { super.install(statusBar); registerCustomListeners(); EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() { @Override public void documentChanged(@Nonnull DocumentEvent e) { Document document = e.getDocument(); updateForDocument(document); } }, this); if (myWriteableFileRequired) { ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileListener() { @Override public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) { if (VirtualFile.PROP_WRITABLE.equals(event.getPropertyName())) { updateForFile(event.getFile()); } } })); } }
Example #2
Source File: EncodingPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void registerCustomListeners() { // should update to reflect encoding-from-content EncodingManager.getInstance().addPropertyChangeListener(evt -> { if (evt.getPropertyName().equals(EncodingManagerImpl.PROP_CACHED_ENCODING_CHANGED)) { Document document = evt.getSource() instanceof Document ? (Document)evt.getSource() : null; updateForDocument(document); } }, this); ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileListener() { @Override public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) { if (VirtualFile.PROP_ENCODING.equals(event.getPropertyName())) { updateForFile(event.getFile()); } } })); }
Example #3
Source File: VFSListener.java From lsp4intellij with Apache License 2.0 | 5 votes |
/** * Fired when a virtual file is renamed from within IDEA, or its writable status is changed. * For files renamed externally, {@link #fileCreated} and {@link #fileDeleted} events will be fired. * * @param event the event object containing information about the change. */ @Override public void propertyChanged(@NotNull VirtualFilePropertyEvent event) { if (event.getPropertyName().equals(VirtualFile.PROP_NAME)) { LSPFileEventManager.fileRenamed((String) event.getOldValue(), (String) event.getNewValue()); } }
Example #4
Source File: Listener.java From floobits-intellij with Apache License 2.0 | 5 votes |
public synchronized void start(final EditorEventHandler editorManager) { this.editorManager = editorManager; connection.subscribe(VirtualFileManager.VFS_CHANGES, this); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, this); em.addDocumentListener(this); em.addSelectionListener(this); em.addCaretListener(this); em.addVisibleAreaListener(this); virtualFileAdapter = new VirtualFileAdapter() { public void beforePropertyChange(@NotNull final VirtualFilePropertyEvent event) { if (!event.getPropertyName().equals(VirtualFile.PROP_NAME)) { return; } VirtualFile parent = event.getParent(); if (parent == null) { return; } String parentPath = parent.getPath(); // XXX: pretty sure is this wrong. String newValue = parentPath + "/" + event.getNewValue().toString(); String oldValue = parentPath + "/" + event.getOldValue().toString(); editorManager.rename(oldValue, newValue); } }; VirtualFileManager.getInstance().addVirtualFileListener(virtualFileAdapter); }
Example #5
Source File: ArtifactVirtualFileListener.java From consulo with Apache License 2.0 | 5 votes |
@Override public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) { if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) { final VirtualFile parent = event.getParent(); if (parent != null) { filePathChanged(parent.getPath() + "/" + event.getOldValue(), parent.getPath() + "/" + event.getNewValue()); } } }
Example #6
Source File: TextEditorComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override public void propertyChanged(@Nonnull final VirtualFilePropertyEvent e) { if (VirtualFile.PROP_NAME.equals(e.getPropertyName())) { // File can be invalidated after file changes name (extension also // can changes). The editor should be removed if it's invalid. updateValidProperty(); if (Comparing.equal(e.getFile(), myFile) && (FileContentUtilCore.FORCE_RELOAD_REQUESTOR.equals(e.getRequestor()) || !Comparing.equal(e.getOldValue(), e.getNewValue()))) { myEditorHighlighterUpdater.updateHighlighters(); } } }
Example #7
Source File: VFSForAnnotationListener.java From consulo with Apache License 2.0 | 5 votes |
public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) { if (! Comparing.equal(myFile, event.getFile())) return; if (! event.isFromRefresh()) return; if (VirtualFile.PROP_WRITABLE.equals(event.getPropertyName())) { if (((Boolean)event.getOldValue()).booleanValue()) { myFileAnnotation.close(); } } }
Example #8
Source File: BreadcrumbsInitializingActivity.java From consulo with Apache License 2.0 | 5 votes |
@Override public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) { if (VirtualFile.PROP_NAME.equals(event.getPropertyName()) && !myProject.isDisposed()) { FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject); VirtualFile file = event.getFile(); if (fileEditorManager.isFileOpen(file)) { reinitBreadcrumbsComponent(fileEditorManager, file); } } }
Example #9
Source File: FileMonitor.java From spring-javaformat with Apache License 2.0 | 4 votes |
@Override public void propertyChanged(VirtualFilePropertyEvent event) { check(); }
Example #10
Source File: AutoSyncHandler.java From intellij with Apache License 2.0 | 4 votes |
@Override public void propertyChanged(VirtualFilePropertyEvent event) { if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) { handleFileEvent(event); } }
Example #11
Source File: LocalFilesystemModificationHandler.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public void beforePropertyChange(@NotNull VirtualFilePropertyEvent event) { generateRenamingResourceMoveActivity(event); }
Example #12
Source File: LocalFilesystemModificationHandler.java From saros with GNU General Public License v2.0 | 4 votes |
/** * Handles name changes for resource as resource moves. Generates and dispatches the needed * activities. For directories, the listener is not called for all contained resources, meaning * these resources are also handled by the call for the directory. * * <p>Other property changes are ignored. * * @param filePropertyEvent the event to react to * @see #generateFolderMoveActivity(VirtualFile, VirtualFile, VirtualFile, String) * @see #generateFileMoveActivity(VirtualFile, VirtualFile, VirtualFile, String, String) */ private void generateRenamingResourceMoveActivity( @NotNull VirtualFilePropertyEvent filePropertyEvent) { assert enabled : "the before property change listener was triggered while it was disabled"; VirtualFile file = filePropertyEvent.getFile(); String propertyName = filePropertyEvent.getPropertyName(); Object oldValue = filePropertyEvent.getOldValue(); Object newValue = filePropertyEvent.getNewValue(); //noinspection SwitchStatementWithTooFewBranches switch (propertyName) { case (VirtualFile.PROP_NAME): String oldName = (String) oldValue; String newName = (String) newValue; // TODO consider using FilePropertyEvent#isRename() once it is no longer marked experimental if (oldName.equals(newName)) { log.debug( "Dropping file property event for " + file + " as it is detected to be a re-parsing of the file."); return; } if (log.isTraceEnabled()) { log.trace( "Reacting before resource name change - resource: " + file + ", old name: " + oldName + ", new name: " + newName); } VirtualFile parent = file.getParent(); if (parent == null) { Set<IReferencePoint> sharedReferencePoints = session.getReferencePoints(); IResource resource = VirtualFileConverter.convertToResource(sharedReferencePoints, file); if (resource != null && session.isShared(resource)) { if (resource.getType() == REFERENCE_POINT) { if (log.isTraceEnabled()) { log.trace("Ignoring rename of reference point base directory " + resource); } } else { log.error( "Renamed resource " + resource + " is a root directory but not a reference point. This should not be possible."); } } return; } if (file.isDirectory()) { generateFolderMoveActivity(file, parent, parent, newName); } else { generateFileMoveActivity(file, parent, parent, null, newName); } break; default: if (log.isTraceEnabled()) { log.trace( "Ignoring change of property + " + propertyName + " for file " + file + " - old value: " + oldValue + ", new value: " + newValue); } } }
Example #13
Source File: VFSListener.java From lsp4intellij with Apache License 2.0 | 2 votes |
/** * Fired before the change of a name or writable status of a file is processed. * * @param event the event object containing information about the change. */ @Override public void beforePropertyChange(@NotNull VirtualFilePropertyEvent event) { }