Search in sources :

Example 16 with Ref

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();
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Ref(com.intellij.openapi.util.Ref) RunProfileState(com.intellij.execution.configurations.RunProfileState) ExecutionException(com.intellij.execution.ExecutionException) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with Ref

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"));
    }
}
Also used : Ref(com.intellij.openapi.util.Ref) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 18 with Ref

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();
}
Also used : Ref(com.intellij.openapi.util.Ref) PsiDirectory(com.intellij.psi.PsiDirectory) CCTaskCreator(com.jetbrains.edu.coursecreator.creation.CCTaskCreator) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with Ref

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();
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) UIUtil(com.intellij.util.ui.UIUtil) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) SvnRevisionNumber(org.jetbrains.idea.svn.SvnRevisionNumber) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Date(java.util.Date) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) ThrowableConsumer(com.intellij.util.ThrowableConsumer) ColumnInfo(com.intellij.util.ui.ColumnInfo) TableCellRenderer(javax.swing.table.TableCellRenderer) ActionManager(com.intellij.openapi.actionSystem.ActionManager) ShowAllAffectedGenericAction(com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction) SVNErrorManager(org.tmatesoft.svn.core.internal.wc.SVNErrorManager) VcsConfiguration(com.intellij.openapi.vcs.VcsConfiguration) SvnUtil(org.jetbrains.idea.svn.SvnUtil) Charset(java.nio.charset.Charset) StatusText(com.intellij.util.ui.StatusText) SvnVcs(org.jetbrains.idea.svn.SvnVcs) VcsException(com.intellij.openapi.vcs.VcsException) FilePath(com.intellij.openapi.vcs.FilePath) PlatformIcons(com.intellij.util.PlatformIcons) ProgressManager(com.intellij.openapi.progress.ProgressManager) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) SVNException(org.tmatesoft.svn.core.SVNException) StringUtil(com.intellij.openapi.util.text.StringUtil) AnAction(com.intellij.openapi.actionSystem.AnAction) Info(org.jetbrains.idea.svn.info.Info) com.intellij.openapi.vcs.history(com.intellij.openapi.vcs.history) com.intellij.ui(com.intellij.ui) MouseEvent(java.awt.event.MouseEvent) SvnBundle(org.jetbrains.idea.svn.SvnBundle) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsActions(com.intellij.openapi.vcs.VcsActions) List(java.util.List) TableLinkMouseListener(com.intellij.openapi.vcs.changes.issueLinks.TableLinkMouseListener) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SVNLogType(org.tmatesoft.svn.util.SVNLogType) SVNURL(org.tmatesoft.svn.core.SVNURL) SVNPathUtil(org.tmatesoft.svn.core.internal.util.SVNPathUtil) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) Collections(java.util.Collections) Consumer(com.intellij.util.Consumer) javax.swing(javax.swing) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) SVNException(org.tmatesoft.svn.core.SVNException) SvnRevisionNumber(org.jetbrains.idea.svn.SvnRevisionNumber) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException)

Example 20 with Ref

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();
}
Also used : Ref(com.intellij.openapi.util.Ref) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision)

Aggregations

Ref (com.intellij.openapi.util.Ref)253 Nullable (org.jetbrains.annotations.Nullable)82 NotNull (org.jetbrains.annotations.NotNull)70 VirtualFile (com.intellij.openapi.vfs.VirtualFile)48 Project (com.intellij.openapi.project.Project)38 List (java.util.List)30 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)26 PsiElement (com.intellij.psi.PsiElement)26 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)22 PsiFile (com.intellij.psi.PsiFile)20 Module (com.intellij.openapi.module.Module)18 Editor (com.intellij.openapi.editor.Editor)16 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)16 File (java.io.File)16 Task (com.intellij.openapi.progress.Task)15 Pair (com.intellij.openapi.util.Pair)14 VcsException (com.intellij.openapi.vcs.VcsException)14 IncorrectOperationException (com.intellij.util.IncorrectOperationException)14 Document (com.intellij.openapi.editor.Document)13