use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class XBreakpointItem method removed.
@Override
public void removed(Project project) {
final XBreakpointManagerImpl breakpointManager = getManager();
new WriteAction() {
@Override
protected void run(@NotNull final Result result) {
breakpointManager.removeBreakpoint(myBreakpoint);
}
}.execute();
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class EditorUtil method fillVirtualSpaceUntil.
public static void fillVirtualSpaceUntil(@NotNull final Editor editor, int columnNumber, int lineNumber) {
final int offset = editor.logicalPositionToOffset(new LogicalPosition(lineNumber, columnNumber));
final String filler = EditorModificationUtil.calcStringToFillVirtualSpace(editor);
if (!filler.isEmpty()) {
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws Throwable {
editor.getDocument().insertString(offset, filler);
editor.getCaretModel().moveToOffset(offset + filler.length());
}
}.execute();
}
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class VirtualFileListenerTest method testFireEvent.
@Test
public void testFireEvent() throws IOException {
VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myTempDir.newFolder("vDir"));
assertNotNull(dir);
dir.getChildren();
Ref<Boolean> eventFired = Ref.create(false);
VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
@Override
public void fileCreated(@NotNull VirtualFileEvent event) {
eventFired.set(true);
}
}, getTestRootDisposable());
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws IOException {
dir.createChildData(this, "x.txt");
}
}.execute();
assertTrue(eventFired.get());
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class VfsUtilTest method testPresentableUrlSurvivesDeletion.
@Test
public void testPresentableUrlSurvivesDeletion() throws IOException {
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myTempDir.newFile("file.txt"));
assertNotNull(file);
String url = file.getPresentableUrl();
assertNotNull(url);
new WriteAction() {
@Override
protected void run(@NotNull Result result) throws IOException {
file.delete(this);
}
}.execute();
assertEquals(url, file.getPresentableUrl());
}
use of com.intellij.openapi.application.WriteAction in project intellij-community by JetBrains.
the class RemoteFileInfoImpl method finished.
@Override
public void finished(@Nullable final FileType fileType) {
final File localIOFile;
synchronized (myLock) {
LOG.debug("Downloading finished, size = " + myLocalFile.length() + ", file type=" + (fileType != null ? fileType.getName() : "null"));
if (fileType != null) {
String fileName = myLocalFile.getName();
int dot = fileName.lastIndexOf('.');
String extension = fileType.getDefaultExtension();
if (dot == -1 || !extension.regionMatches(true, 0, fileName, dot + 1, extension.length())) {
File newFile = FileUtil.findSequentNonexistentFile(myLocalFile.getParentFile(), fileName, extension);
try {
FileUtil.rename(myLocalFile, newFile);
myLocalFile = newFile;
} catch (IOException e) {
LOG.debug(e);
}
}
}
localIOFile = myLocalFile;
}
VirtualFile localFile = new WriteAction<VirtualFile>() {
@Override
protected void run(@NotNull final Result<VirtualFile> result) {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(localIOFile);
if (file != null) {
file.refresh(false, false);
}
result.setResult(file);
}
}.execute().getResultObject();
LOG.assertTrue(localFile != null, "Virtual local file not found for " + localIOFile.getAbsolutePath());
LOG.debug("Virtual local file: " + localFile + ", size = " + localFile.getLength());
synchronized (myLock) {
myLocalVirtualFile = localFile;
myPrevLocalFile = null;
myState = RemoteFileState.DOWNLOADED;
myErrorMessage = null;
}
for (FileDownloadingListener listener : myListeners) {
listener.fileDownloaded(localFile);
}
}
Aggregations