use of com.intellij.openapi.util.Ref in project intellij-community by JetBrains.
the class RerunFailedActionsTestTools method findRestartActionState.
/**
* Searches for "rerun failed tests" action and fetches state from it
*
* @param descriptor previous run descriptor
* @return state (if found)
*/
@Nullable
public static RunProfileState findRestartActionState(@NotNull final RunContentDescriptor descriptor) {
final ExecutionEnvironment action = findRestartAction(descriptor);
if (action == null) {
return null;
}
final Ref<RunProfileState> stateRef = new Ref<>();
ApplicationManager.getApplication().invokeAndWait(() -> {
try {
stateRef.set(action.getState());
} catch (final ExecutionException e) {
throw new IllegalStateException("Error obtaining execution state", e);
}
}, ModalityState.NON_MODAL);
return stateRef.get();
}
use of com.intellij.openapi.util.Ref in project intellij-community by JetBrains.
the class SvnConfigureProxiesDialog method execute.
public void execute(final String url) {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.text"), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.title"));
if (!applyImpl()) {
return;
}
final Ref<Exception> excRef = new Ref<>();
final ProgressManager pm = ProgressManager.getInstance();
pm.runProcessWithProgressSynchronously(() -> {
final ProgressIndicator pi = pm.getProgressIndicator();
if (pi != null) {
pi.setText("Connecting to " + url);
}
try {
SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD);
} catch (SvnBindException e) {
excRef.set(e);
}
}, "Test connection", true, myProject);
if (!excRef.isNull()) {
Messages.showErrorDialog(myProject, excRef.get().getMessage(), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.error.title"));
} else {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.text"), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.title"));
}
}
use of com.intellij.openapi.util.Ref in project intellij-community by JetBrains.
the class CCCreateTask method createItemDir.
@Override
@Nullable
protected PsiDirectory createItemDir(@NotNull final Project project, @NotNull final StudyItem item, @Nullable final IdeView view, @NotNull final PsiDirectory parentDirectory, @NotNull final Course course) {
CCTaskCreator creator = CCTaskCreator.INSTANCE.forLanguage(course.getLanguageById());
if (creator != null) {
return creator.createTask(project, item, view, parentDirectory, course);
}
final Ref<PsiDirectory> taskDirectory = new Ref<>();
ApplicationManager.getApplication().runWriteAction(() -> {
String taskDirName = EduNames.TASK + item.getIndex();
taskDirectory.set(DirectoryUtil.createSubdirectories(taskDirName, parentDirectory, "\\/"));
if (taskDirectory.get() != null) {
CCUtils.createTaskContent(project, view, course, taskDirectory.get());
}
});
return taskDirectory.get();
}
use of com.intellij.openapi.util.Ref in project intellij-community by JetBrains.
the class SvnHistoryProvider method reportAppendableHistory.
public void reportAppendableHistory(FilePath path, final VcsAppendableHistorySessionPartner partner, @Nullable final SVNRevision from, @Nullable final SVNRevision to, final int limit, SVNRevision peg, final boolean forceBackwards) throws VcsException {
FilePath committedPath = path;
Change change = ChangeListManager.getInstance(myVcs.getProject()).getChange(path);
if (change != null) {
final ContentRevision beforeRevision = change.getBeforeRevision();
final ContentRevision afterRevision = change.getAfterRevision();
if (beforeRevision != null && afterRevision != null && !beforeRevision.getFile().equals(afterRevision.getFile()) && afterRevision.getFile().equals(path)) {
committedPath = beforeRevision.getFile();
}
// revision can be VcsRevisionNumber.NULL
if (peg == null && change.getBeforeRevision() != null && change.getBeforeRevision().getRevisionNumber() instanceof SvnRevisionNumber) {
peg = ((SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber()).getRevision();
}
}
boolean showMergeSources = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate();
final LogLoader logLoader;
if (path.isNonLocal()) {
logLoader = new RepositoryLoader(myVcs, committedPath, from, to, limit, peg, forceBackwards, showMergeSources);
} else {
logLoader = new LocalLoader(myVcs, committedPath, from, to, limit, peg, showMergeSources);
}
try {
logLoader.preliminary();
} catch (SVNException e) {
throw new VcsException(e);
}
logLoader.check();
if (showMergeSources) {
logLoader.initSupports15();
}
final SvnHistorySession historySession = new SvnHistorySession(myVcs, Collections.emptyList(), committedPath, showMergeSources && Boolean.TRUE.equals(logLoader.mySupport15), null, false, !path.isNonLocal());
final Ref<Boolean> sessionReported = new Ref<>();
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setText(SvnBundle.message("progress.text2.collecting.history", path.getName()));
}
final Consumer<VcsFileRevision> consumer = vcsFileRevision -> {
if (!Boolean.TRUE.equals(sessionReported.get())) {
partner.reportCreatedEmptySession(historySession);
sessionReported.set(true);
}
partner.acceptRevision(vcsFileRevision);
};
logLoader.setConsumer(consumer);
logLoader.load();
logLoader.check();
}
use of com.intellij.openapi.util.Ref in project intellij-community by JetBrains.
the class LatestExistentSearcher method getDeletionRevision.
public long getDeletionRevision() {
if (!detectStartRevision())
return -1;
final Ref<Long> latest = new Ref<>(myStartNumber);
try {
if (myEndNumber == -1) {
myEndNumber = getLatestRevision();
}
final SVNURL existingParent = getExistingParent(myUrl);
if (existingParent == null) {
return myStartNumber;
}
final SVNRevision startRevision = SVNRevision.create(myStartNumber);
SvnTarget target = SvnTarget.fromURL(existingParent, startRevision);
myVcs.getFactory(target).createHistoryClient().doLog(target, startRevision, SVNRevision.HEAD, false, true, false, 0, null, createHandler(latest));
} catch (VcsException e) {
LOG.info(e);
}
return latest.get().longValue();
}
Aggregations