use of com.intellij.history.utils.RunnableAdapter in project intellij-community by JetBrains.
the class ActionsTest method testActionInsideCommandSurroundedWithSomeChanges.
public void testActionInsideCommandSurroundedWithSomeChanges() throws Exception {
// see testActionInsideCommand comment
final VirtualFile f = createFile("f.txt");
CommandProcessor.getInstance().executeCommand(myProject, new RunnableAdapter() {
@Override
public void doRun() throws IOException {
setContent(f, "file");
setDocumentTextFor(f, "doc1");
LocalHistoryAction a = LocalHistory.getInstance().startAction("action");
setDocumentTextFor(f, "doc2");
a.finish();
saveDocument(f);
setContent(f, "doc3");
}
}, "command", null);
List<Revision> rr = getRevisionsFor(f);
assertEquals(4, rr.size());
assertContent("doc3", rr.get(0).findEntry());
assertContent("doc1", rr.get(1).findEntry());
assertContent("", rr.get(2).findEntry());
assertEquals("command", rr.get(1).getChangeSetName());
assertNull(rr.get(2).getChangeSetName());
}
use of com.intellij.history.utils.RunnableAdapter in project sonarlint-intellij by SonarSource.
the class ServerUpdateTask method run.
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Fetching data...");
try {
TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
if (!onlyModules) {
UpdateResult updateResult = engine.update(serverConfiguration, monitor);
Collection<SonarAnalyzer> tooOld = updateResult.analyzers().stream().filter(SonarAnalyzer::sonarlintCompatible).filter(ServerUpdateTask::tooOld).collect(Collectors.toList());
if (!tooOld.isEmpty()) {
ApplicationManager.getApplication().invokeAndWait(() -> Messages.showWarningDialog(buildMinimumVersionFailMessage(tooOld), "Analyzers Not Loaded"), ModalityState.any());
}
log.log("Server binding '" + server.getName() + "' updated", LogOutput.Level.INFO);
}
updateModules(serverConfiguration, monitor);
} catch (CanceledException e) {
LOGGER.info("Update of server '" + server.getName() + "' was cancelled");
log.log("Update of server '" + server.getName() + "' was cancelled", LogOutput.Level.INFO);
} catch (Exception e) {
LOGGER.info("Error updating from server '" + server.getName() + "'", e);
final String msg = (e.getMessage() != null) ? e.getMessage() : ("Failed to update binding for server configuration '" + server.getName() + "'");
ApplicationManager.getApplication().invokeAndWait(new RunnableAdapter() {
@Override
public void doRun() {
Messages.showErrorDialog((Project) null, msg, "Update Failed");
}
}, ModalityState.any());
}
}
use of com.intellij.history.utils.RunnableAdapter in project sonarlint-intellij by SonarSource.
the class ServerUpdateTask method updateModules.
/**
* Updates all known modules belonging to a server configuration.
* It assumes that the server binding is updated.
*/
private void updateModules(ServerConfiguration serverConfiguration, TaskProgressMonitor monitor) {
Set<String> failedModules = new LinkedHashSet<>();
for (Map.Entry<String, List<Project>> entry : projectsPerModule.entrySet()) {
try {
updateModule(serverConfiguration, entry.getKey(), entry.getValue(), monitor);
} catch (Exception e) {
// in case of error, save module key and keep updating other modules
LOGGER.info(e.getMessage(), e);
failedModules.add(entry.getKey());
}
}
if (!projectsPerModule.isEmpty() && !failedModules.isEmpty()) {
String errorMsg = "Failed to update the following modules. " + "Please check if the server bindings are updated and the module key is correct: " + failedModules.toString();
log.log(errorMsg, LogOutput.Level.WARN);
ApplicationManager.getApplication().invokeLater(new RunnableAdapter() {
@Override
public void doRun() {
Messages.showWarningDialog((Project) null, errorMsg, "Modules Not Updated");
}
}, ModalityState.any());
}
}
use of com.intellij.history.utils.RunnableAdapter in project intellij-community by JetBrains.
the class IntegrationTestCase method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
LocalHistoryImpl.getInstanceImpl().cleanupForNextTest();
Clock.reset();
Paths.useSystemCaseSensitivity();
myGateway = new IdeaGateway();
ApplicationManager.getApplication().runWriteAction(new RunnableAdapter() {
@Override
public void doRun() throws Exception {
setUpInWriteAction();
}
});
}
use of com.intellij.history.utils.RunnableAdapter in project intellij-community by JetBrains.
the class FileListeningTest method testRenamingFileOnlyAfterRenamedEvent.
public void testRenamingFileOnlyAfterRenamedEvent() throws Exception {
final VirtualFile f = createFile("old.txt");
final int[] log = new int[2];
VirtualFileListener l = new VirtualFileAdapter() {
@Override
public void beforePropertyChange(@NotNull VirtualFilePropertyEvent e) {
log[0] = getRevisionsFor(f).size();
}
};
assertEquals(2, getRevisionsFor(f).size());
addFileListenerDuring(l, new RunnableAdapter() {
@Override
public void doRun() throws IOException {
rename(f, "new.txt");
}
});
assertEquals(2, log[0]);
assertEquals(3, getRevisionsFor(f).size());
}
Aggregations