Search in sources :

Example 1 with RangeProgressViewer

use of org.netbeans.lib.cvsclient.progress.RangeProgressViewer in project intellij-community by JetBrains.

the class CommitCommand method execute.

// Implemented ============================================================
/**
	 * Execute the command.
	 * @param requestProcessor the client services object that provides any necessary
	 *               services to this command, including the ability to actually
	 *               process all the requests
	 */
public boolean execute(IRequestProcessor requestProcessor, IEventSender eventSender, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    final ICvsFiles cvsFiles;
    try {
        cvsFiles = scanFileSystem(clientEnvironment);
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    final Requests requests = new Requests(CommandRequest.COMMIT, clientEnvironment);
    requests.addArgumentRequest(isForceCommit(), "-f");
    requests.addArgumentRequest(isRecursive(), "-R");
    requests.addArgumentRequest(isNoModuleProgram(), "-n");
    requests.addArgumentRequest(getToRevisionOrBranch(), "-r");
    addFileRequests(cvsFiles, requests, clientEnvironment);
    requests.addMessageRequests(CommandUtils.getMessageNotNull(getMessage()));
    requests.addLocalPathDirectoryRequest();
    addArgumentRequests(requests);
    final IRequestsProgressHandler requestsProgressHandler = new FileStateRequestsProgressHandler(new RangeProgressViewer(progressViewer, 0.0, 0.5), cvsFiles);
    final ICvsListener responseProgressHandler = new FileInfoAndMessageResponseProgressHandler(new RangeProgressViewer(progressViewer, 0.5, 1.0), cvsFiles, EXAM_DIR);
    final ICvsListener commitParser = new CommitParser(eventSender, clientEnvironment.getCvsFileSystem());
    final ICvsListener parser = new DualListener(commitParser, responseProgressHandler);
    parser.registerListeners(listenerRegistry);
    try {
        return requestProcessor.processRequests(requests, requestsProgressHandler);
    } finally {
        parser.unregisterListeners(listenerRegistry);
    }
}
Also used : FileInfoAndMessageResponseProgressHandler(org.netbeans.lib.cvsclient.progress.receiving.FileInfoAndMessageResponseProgressHandler) RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) FileStateRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.FileStateRequestsProgressHandler) ICvsListener(org.netbeans.lib.cvsclient.event.ICvsListener) IOException(java.io.IOException) IRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.IRequestsProgressHandler) Requests(org.netbeans.lib.cvsclient.request.Requests) DualListener(org.netbeans.lib.cvsclient.event.DualListener)

Example 2 with RangeProgressViewer

use of org.netbeans.lib.cvsclient.progress.RangeProgressViewer in project intellij-community by JetBrains.

the class EditCommand method execute.

// Implemented ============================================================
public boolean execute(IRequestProcessor requestProcessor, IEventSender eventSender, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    final ICvsFiles cvsFiles;
    try {
        cvsFiles = scanFileSystem(clientEnvironment);
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    if (isCheckThatUnedited()) {
        editors = true;
        final Requests requests = new Requests(CommandRequest.EDITORS, clientEnvironment);
        addFileRequests(cvsFiles, requests, clientEnvironment);
        requests.addLocalPathDirectoryRequest();
        addArgumentRequests(requests);
        final EditEditorsMessageParser parser = new EditEditorsMessageParser(clientEnvironment.getCvsRoot().getUser());
        parser.registerListeners(listenerRegistry);
        try {
            final RangeProgressViewer editorsProgressViewer = new RangeProgressViewer(progressViewer, 0.0, 0.5);
            requestProcessor.processRequests(requests, FileStateRequestsProgressHandler.create(editorsProgressViewer, cvsFiles));
        } finally {
            parser.unregisterListeners(listenerRegistry);
        }
        if (parser.isFilesEdited()) {
            final String message = JavaCvsSrcBundle.message("cannot.edit.files.they.are.edited.error.message");
            eventSender.notifyMessageListeners(message.getBytes(), true, false);
            return false;
        }
        progressViewer = new RangeProgressViewer(progressViewer, 0.5, 1.0);
    }
    editors = false;
    final Requests requests = new Requests(CommandRequest.NOOP, clientEnvironment);
    addFileRequests(cvsFiles, requests, clientEnvironment);
    requests.addArgumentRequest(isCheckThatUnedited(), "-c");
    requests.addArgumentRequest(isForceEvenIfEdited(), "-f");
    requests.addLocalPathDirectoryRequest();
    return requestProcessor.processRequests(requests, FileStateRequestsProgressHandler.create(progressViewer, cvsFiles));
}
Also used : RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) IOException(java.io.IOException) Requests(org.netbeans.lib.cvsclient.request.Requests)

Example 3 with RangeProgressViewer

use of org.netbeans.lib.cvsclient.progress.RangeProgressViewer in project intellij-community by JetBrains.

the class CvsCommandOperation method doExecute.

private void doExecute(final CvsExecutionEnvironment executionEnvironment, boolean underReadAction) throws VcsException {
    final VcsException[] exc = new VcsException[1];
    final Runnable action = () -> {
        try {
            final ReadWriteStatistics statistics = executionEnvironment.getReadWriteStatistics();
            final Collection<CvsRootProvider> allCvsRoots;
            try {
                allCvsRoots = getAllCvsRoots();
            } catch (CannotFindCvsRootException e) {
                throw createVcsExceptionOn(e, null);
            }
            final IProgressViewer progressViewer = new IProgressViewer() {

                @Override
                public void setProgress(double value) {
                    final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
                    if (progressIndicator != null)
                        progressIndicator.setFraction(value);
                }
            };
            int count = 0;
            final double step = 1.0 / allCvsRoots.size();
            for (CvsRootProvider cvsRootProvider : allCvsRoots) {
                try {
                    final double lowerBound = step * count;
                    final RangeProgressViewer partialProgress = new RangeProgressViewer(progressViewer, lowerBound, lowerBound + step);
                    myLastProcessedCvsRoot = cvsRootProvider.getCvsRootAsString();
                    execute(cvsRootProvider, executionEnvironment, statistics, partialProgress);
                    count++;
                } catch (IOCommandException e) {
                    LOG.info(e);
                    throw createVcsExceptionOn(e.getIOException(), cvsRootProvider.getCvsRootAsString());
                } catch (CommandException e) {
                    LOG.info(e);
                    final Exception underlyingException = e.getUnderlyingException();
                    if (underlyingException != null) {
                        LOG.info(underlyingException);
                    }
                    throw createVcsExceptionOn(underlyingException == null ? e : underlyingException, cvsRootProvider.getCvsRootAsString());
                }
            }
        } catch (VcsException e) {
            exc[0] = e;
        }
    };
    if (underReadAction) {
        ApplicationManager.getApplication().runReadAction(action);
    } else {
        action.run();
    }
    if (exc[0] != null)
        throw exc[0];
}
Also used : IProgressViewer(org.netbeans.lib.cvsclient.progress.IProgressViewer) CannotFindCvsRootException(com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) VcsException(com.intellij.openapi.vcs.VcsException) CannotFindCvsRootException(com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) Collection(java.util.Collection) CvsRootProvider(com.intellij.cvsSupport2.connections.CvsRootProvider)

Example 4 with RangeProgressViewer

use of org.netbeans.lib.cvsclient.progress.RangeProgressViewer in project intellij-community by JetBrains.

the class TagCommand method execute.

// Implemented ============================================================
/**
	 * Execute the command.
	 *
	 * @param requestProcessor the client services object that provides any necessary
	 *               services to this command, including the ability to actually
	 *               process all the requests.
	 */
public boolean execute(IRequestProcessor requestProcessor, IEventSender eventManager, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    final ICvsFiles cvsFiles;
    try {
        cvsFiles = scanFileSystem(clientEnvironment);
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    final Requests requests = new Requests(CommandRequest.TAG, clientEnvironment);
    addFileRequests(cvsFiles, requests, clientEnvironment);
    requests.addArgumentRequest(isDeleteTag(), "-d");
    requests.addArgumentRequest(isMakeBranchTag(), "-b");
    requests.addArgumentRequest(isCheckThatUnmodified(), "-c");
    requests.addArgumentRequest(isOverrideExistingTag(), "-F");
    requests.addArgumentRequest(isAllowMoveDeleteBranchTag(), "-B");
    requests.addArgumentRequest(true, getTag());
    requests.addLocalPathDirectoryRequest();
    addArgumentRequests(requests);
    final IRequestsProgressHandler requestsProgressHandler = new FileStateRequestsProgressHandler(new RangeProgressViewer(progressViewer, 0.0, 0.5), cvsFiles);
    final ICvsListener responseProgressHandler = new FileInfoAndMessageResponseProgressHandler(new RangeProgressViewer(progressViewer, 0.5, 1.0), cvsFiles, isDeleteTag() ? EXAM_DIR_UNTAG : EXAM_DIR_TAG);
    final ICvsListener tagParser = new TagParser(eventManager, clientEnvironment.getCvsFileSystem());
    final ICvsListener listener = new DualListener(tagParser, responseProgressHandler);
    listener.registerListeners(listenerRegistry);
    try {
        return requestProcessor.processRequests(requests, requestsProgressHandler);
    } finally {
        listener.unregisterListeners(listenerRegistry);
    }
}
Also used : FileInfoAndMessageResponseProgressHandler(org.netbeans.lib.cvsclient.progress.receiving.FileInfoAndMessageResponseProgressHandler) RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) FileStateRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.FileStateRequestsProgressHandler) ICvsListener(org.netbeans.lib.cvsclient.event.ICvsListener) ICvsFiles(org.netbeans.lib.cvsclient.command.ICvsFiles) IOException(java.io.IOException) IRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.IRequestsProgressHandler) Requests(org.netbeans.lib.cvsclient.request.Requests) IOCommandException(org.netbeans.lib.cvsclient.command.IOCommandException) DualListener(org.netbeans.lib.cvsclient.event.DualListener)

Example 5 with RangeProgressViewer

use of org.netbeans.lib.cvsclient.progress.RangeProgressViewer in project intellij-community by JetBrains.

the class LogCommand method execute.

// Implemented ============================================================
public final boolean execute(IRequestProcessor requestProcessor, IEventSender eventSender, ICvsListenerRegistry listenerRegistry, IClientEnvironment clientEnvironment, IProgressViewer progressViewer) throws CommandException, AuthenticationException {
    final ICvsFiles cvsFiles;
    try {
        cvsFiles = scanFileSystem(clientEnvironment);
    } catch (IOException ex) {
        throw new IOCommandException(ex);
    }
    final Requests requests = new Requests(CommandRequest.LOG, clientEnvironment);
    requests.addArgumentRequest(isDefaultBranch(), "-b");
    requests.addArgumentRequest(isHeaderAndDescOnly(), "-t");
    requests.addArgumentRequest(isHeaderOnly(), "-h");
    requests.addArgumentRequest(isNoTags(), "-N");
    requests.addArgumentRequest(getUserFilter(), "-w");
    requests.addArgumentRequest(getRevisionFilter(), "-r");
    requests.addArgumentRequest(getStateFilter(), "-s");
    requests.addArgumentRequest(getDateFilter(), "-d");
    addFileRequests(cvsFiles, requests, clientEnvironment);
    requests.addLocalPathDirectoryRequest();
    addArgumentRequests(requests);
    final IRequestsProgressHandler requestsProgressHandler = new FileStateRequestsProgressHandler(new RangeProgressViewer(progressViewer, 0.0, 0.5), cvsFiles);
    final ICvsListener responseProgressHandler = new FileInfoAndMessageResponseProgressHandler(new RangeProgressViewer(progressViewer, 0.5, 1.0), cvsFiles, EXAM_DIR);
    final ICvsListener parser = createParser(eventSender, clientEnvironment.getCvsFileSystem());
    final ICvsListener listener = new DualListener(parser, responseProgressHandler);
    listener.registerListeners(listenerRegistry);
    try {
        return requestProcessor.processRequests(requests, requestsProgressHandler);
    } finally {
        listener.unregisterListeners(listenerRegistry);
    }
}
Also used : FileInfoAndMessageResponseProgressHandler(org.netbeans.lib.cvsclient.progress.receiving.FileInfoAndMessageResponseProgressHandler) RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) FileStateRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.FileStateRequestsProgressHandler) ICvsListener(org.netbeans.lib.cvsclient.event.ICvsListener) ICvsFiles(org.netbeans.lib.cvsclient.command.ICvsFiles) IOException(java.io.IOException) IRequestsProgressHandler(org.netbeans.lib.cvsclient.progress.sending.IRequestsProgressHandler) Requests(org.netbeans.lib.cvsclient.request.Requests) IOCommandException(org.netbeans.lib.cvsclient.command.IOCommandException) DualListener(org.netbeans.lib.cvsclient.event.DualListener)

Aggregations

RangeProgressViewer (org.netbeans.lib.cvsclient.progress.RangeProgressViewer)7 IOException (java.io.IOException)6 Requests (org.netbeans.lib.cvsclient.request.Requests)6 DualListener (org.netbeans.lib.cvsclient.event.DualListener)5 ICvsListener (org.netbeans.lib.cvsclient.event.ICvsListener)5 FileStateRequestsProgressHandler (org.netbeans.lib.cvsclient.progress.sending.FileStateRequestsProgressHandler)5 IRequestsProgressHandler (org.netbeans.lib.cvsclient.progress.sending.IRequestsProgressHandler)5 FileInfoAndMessageResponseProgressHandler (org.netbeans.lib.cvsclient.progress.receiving.FileInfoAndMessageResponseProgressHandler)4 ICvsFiles (org.netbeans.lib.cvsclient.command.ICvsFiles)3 IOCommandException (org.netbeans.lib.cvsclient.command.IOCommandException)3 CvsRootProvider (com.intellij.cvsSupport2.connections.CvsRootProvider)1 CannotFindCvsRootException (com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException)1 CvsException (com.intellij.cvsSupport2.errorHandling.CvsException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Collection (java.util.Collection)1 AuthenticationException (org.netbeans.lib.cvsclient.connection.AuthenticationException)1 IProgressViewer (org.netbeans.lib.cvsclient.progress.IProgressViewer)1 FileInfoAndDirectoryResponseProgressHandler (org.netbeans.lib.cvsclient.progress.receiving.FileInfoAndDirectoryResponseProgressHandler)1