mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
always login with project in hand to prevent NPE when failure needs to be reported
This commit is contained in:
@@ -102,7 +102,7 @@ public class CvsDiffProvider implements DiffProvider{
|
||||
final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name);
|
||||
if (entry == null) return new ItemLatestState(new CvsRevisionNumber("HEAD"), true, true);
|
||||
|
||||
final String stickyHead = new StickyHeadGetter.MyStickyBranchHeadGetter(entry.getRevision()).getHead(parent, name);
|
||||
final String stickyHead = new StickyHeadGetter.MyStickyBranchHeadGetter(entry.getRevision(), myProject).getHead(parent, name);
|
||||
if (stickyHead == null) {
|
||||
return new ItemLatestState(new CvsRevisionNumber("HEAD"), true, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package com.intellij.cvsSupport2;
|
||||
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.PostCvsActivity;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsLog.LocalPathIndifferentLogOperation;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter;
|
||||
import com.intellij.cvsSupport2.history.CvsRevisionNumber;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -41,14 +40,16 @@ import java.util.List;
|
||||
|
||||
public abstract class StickyHeadGetter {
|
||||
protected final String myStickyData;
|
||||
private final Project myProject;
|
||||
|
||||
protected StickyHeadGetter(final String stickyData) {
|
||||
protected StickyHeadGetter(final String stickyData, Project project) {
|
||||
myStickyData = stickyData;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public static class MyStickyBranchHeadGetter extends StickyHeadGetter {
|
||||
public MyStickyBranchHeadGetter(final String headRevision) {
|
||||
super(headRevision);
|
||||
public MyStickyBranchHeadGetter(final String headRevision, Project project) {
|
||||
super(headRevision, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,8 +76,8 @@ public abstract class StickyHeadGetter {
|
||||
}
|
||||
|
||||
public static class MyStickyTagGetter extends StickyHeadGetter {
|
||||
public MyStickyTagGetter(final String stickyData) {
|
||||
super(stickyData);
|
||||
public MyStickyTagGetter(final String stickyData, Project project) {
|
||||
super(stickyData, project);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,8 +90,8 @@ public abstract class StickyHeadGetter {
|
||||
private final Date myStickyDate;
|
||||
private final String myTagStart;
|
||||
|
||||
public MyStickyDateGetter(String stickyData, final Date stickyDate, final String currentRevision) {
|
||||
super(stickyData);
|
||||
public MyStickyDateGetter(String stickyData, final Date stickyDate, final String currentRevision, Project project) {
|
||||
super(stickyData, project);
|
||||
myStickyDate = stickyDate;
|
||||
myTagStart = getTagStart(currentRevision);
|
||||
}
|
||||
@@ -121,10 +122,11 @@ public abstract class StickyHeadGetter {
|
||||
public abstract String getHead(final VirtualFile parent, final String name);
|
||||
|
||||
@Nullable
|
||||
protected String getBranchHeadRevision(final VirtualFile parent, final String name, final Convertor<CvsRevisionNumber, Boolean> chooser) {
|
||||
protected String getBranchHeadRevision(final VirtualFile parent,
|
||||
final String name,
|
||||
final Convertor<CvsRevisionNumber, Boolean> chooser) {
|
||||
final LocalPathIndifferentLogOperation operation = new LocalPathIndifferentLogOperation(new File(parent.getPath(), name));
|
||||
final Ref<Boolean> logSuccess = new Ref<Boolean>(Boolean.TRUE);
|
||||
final ModalityContext context = ModalityContextImpl.NON_MODAL;
|
||||
final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(new CvsMessagesAdapter(),
|
||||
CvsExecutionEnvironment.DUMMY_STOPPER, new ErrorProcessor() {
|
||||
public void addError(VcsException ex) {
|
||||
@@ -132,10 +134,10 @@ public abstract class StickyHeadGetter {
|
||||
}
|
||||
public void addWarning(VcsException ex) {
|
||||
}
|
||||
public List getErrors() {
|
||||
public List<VcsException> getErrors() {
|
||||
return null;
|
||||
}
|
||||
}, context, PostCvsActivity.DEAF);
|
||||
}, PostCvsActivity.DEAF, myProject);
|
||||
try {
|
||||
// should already be logged in
|
||||
//operation.login(context);
|
||||
|
||||
+15
-21
@@ -17,19 +17,18 @@ package com.intellij.cvsSupport2.actions;
|
||||
|
||||
import com.intellij.CvsBundle;
|
||||
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
|
||||
import com.intellij.cvsSupport2.actions.cvsContext.CvsContextWrapper;
|
||||
import com.intellij.cvsSupport2.config.CvsRootConfiguration;
|
||||
import com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.cvsBrowser.ui.BrowserPanel;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl;
|
||||
import com.intellij.cvsSupport2.cvshandlers.AbstractCvsHandler;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
|
||||
import com.intellij.cvsSupport2.cvshandlers.FileSetToBeUpdated;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.LoginPerformer;
|
||||
import com.intellij.cvsSupport2.ui.CvsTabbedWindow;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
@@ -54,9 +53,8 @@ public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAwa
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
VcsContext context = CvsContextWrapper.createInstance(e);
|
||||
boolean projectExists = context.getProject() != null;
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final boolean projectExists = e.getData(PlatformDataKeys.PROJECT) != null;
|
||||
presentation.setVisible(projectExists);
|
||||
presentation.setEnabled(projectExists);
|
||||
}
|
||||
@@ -66,14 +64,12 @@ public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAwa
|
||||
}
|
||||
|
||||
protected CvsHandler getCvsHandler(CvsContext context) {
|
||||
SelectCvsConfigurationDialog selectCvsConfigurationDialog = new SelectCvsConfigurationDialog(context.getProject());
|
||||
final SelectCvsConfigurationDialog selectCvsConfigurationDialog = new SelectCvsConfigurationDialog(context.getProject());
|
||||
selectCvsConfigurationDialog.show();
|
||||
|
||||
if (!selectCvsConfigurationDialog.isOK()) return CvsHandler.NULL;
|
||||
|
||||
mySelectedConfiguration = selectCvsConfigurationDialog.getSelectedConfiguration();
|
||||
|
||||
return new MyCvsHandler(context.getProject());
|
||||
return new MyCvsHandler();
|
||||
}
|
||||
|
||||
protected void onActionPerformed(CvsContext context,
|
||||
@@ -104,12 +100,10 @@ public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAwa
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCvsHandler extends AbstractCvsHandler {
|
||||
private final Project myProject;
|
||||
private class MyCvsHandler extends CvsHandler {
|
||||
|
||||
public MyCvsHandler(Project project) {
|
||||
public MyCvsHandler() {
|
||||
super(TITLE, FileSetToBeUpdated.EMPTY);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
@@ -120,18 +114,18 @@ public class BrowseCvsRepositoryAction extends AbstractAction implements DumbAwa
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean login(ModalityContext executor) {
|
||||
return loginImpl(myProject, executor, new Consumer<VcsException>() {
|
||||
public void consume(VcsException e) {
|
||||
myErrors.add(e);
|
||||
}
|
||||
});
|
||||
public boolean login(Project project, ModalityContext executor) {
|
||||
return loginImpl(project, executor, new Consumer<VcsException>() {
|
||||
public void consume(VcsException e) {
|
||||
myErrors.add(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private boolean loginImpl(final Project project, final ModalityContext executor, final Consumer<VcsException> exceptionConsumer) {
|
||||
final LoginPerformer.MyProjectKnown performer =
|
||||
new LoginPerformer.MyProjectKnown(project, Collections.<CvsEnvironment>singletonList(mySelectedConfiguration), exceptionConsumer);
|
||||
final LoginPerformer performer =
|
||||
new LoginPerformer(project, Collections.<CvsEnvironment>singletonList(mySelectedConfiguration), exceptionConsumer);
|
||||
try {
|
||||
return performer.loginAll(executor, false);
|
||||
} catch (Exception e) {
|
||||
|
||||
+4
-3
@@ -20,7 +20,6 @@ import com.intellij.cvsSupport2.CvsResultEx;
|
||||
import com.intellij.cvsSupport2.connections.*;
|
||||
import com.intellij.cvsSupport2.connections.login.CvsLoginWorker;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.PostCvsActivity;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsContent.GetModulesListOperation;
|
||||
@@ -36,6 +35,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import org.netbeans.lib.cvsclient.CvsRoot;
|
||||
@@ -156,8 +156,9 @@ public class CvsRootConfiguration extends AbstractConfiguration implements CvsEn
|
||||
final ErrorMessagesProcessor errorProcessor = new ErrorMessagesProcessor();
|
||||
final CvsExecutionEnvironment cvsExecutionEnvironment = new CvsExecutionEnvironment(errorProcessor,
|
||||
CvsExecutionEnvironment.DUMMY_STOPPER,
|
||||
errorProcessor, new ModalityContextImpl(true),
|
||||
PostCvsActivity.DEAF);
|
||||
errorProcessor,
|
||||
PostCvsActivity.DEAF,
|
||||
ProjectManager.getInstance().getDefaultProject());
|
||||
|
||||
final CvsResult result = new CvsResultEx();
|
||||
try {
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -138,7 +138,7 @@ public class CvsOperationExecutor {
|
||||
|
||||
setText(CvsBundle.message("progress.text.preparing.for.action", handler.getTitle()));
|
||||
|
||||
handler.run(myExecutor);
|
||||
handler.run(myProject, myExecutor);
|
||||
if (myResult.finishedUnsuccessfully(true, handler)) return;
|
||||
|
||||
}
|
||||
@@ -156,9 +156,9 @@ public class CvsOperationExecutor {
|
||||
myExecutor.runInDispatchThread(finish, myProject);
|
||||
}
|
||||
else {
|
||||
PerformInBackgroundOption backgroundOption = handler.getBackgroundOption(myProject);
|
||||
final PerformInBackgroundOption backgroundOption = handler.getBackgroundOption(myProject);
|
||||
if (backgroundOption != null) {
|
||||
Task.Backgroundable task = new Task.Backgroundable(myProject, handler.getTitle(), handler.canBeCanceled(), backgroundOption) {
|
||||
final Task.Backgroundable task = new Task.Backgroundable(myProject, handler.getTitle(), handler.canBeCanceled(), backgroundOption) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
cvsAction.run();
|
||||
}
|
||||
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.cvsSupport2.cvshandlers;
|
||||
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsCompositeListener;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsCompositeListener;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
public abstract class AbstractCvsHandler extends CvsHandler {
|
||||
protected final CvsCompositeListener myCompositeListener = new CvsCompositeListener();
|
||||
|
||||
public AbstractCvsHandler(String title, FileSetToBeUpdated files) {
|
||||
super(title, files);
|
||||
}
|
||||
|
||||
public void addCvsListener(CvsMessagesListener listener) {
|
||||
myCompositeListener.addCvsListener(listener);
|
||||
}
|
||||
|
||||
public void removeCvsListener(CvsMessagesListener listener) {
|
||||
myCompositeListener.removeCvsListener(listener);
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -22,7 +22,6 @@ import com.intellij.cvsSupport2.actions.update.UpdateSettings;
|
||||
import com.intellij.cvsSupport2.application.CvsEntriesManager;
|
||||
import com.intellij.cvsSupport2.config.CvsConfiguration;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.connections.CvsRootProvider;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.*;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddFilesOperation;
|
||||
@@ -71,7 +70,7 @@ import java.util.*;
|
||||
/**
|
||||
* @author lesya
|
||||
*/
|
||||
public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
public class CommandCvsHandler extends CvsHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler");
|
||||
|
||||
protected final CvsOperation myCvsOperation;
|
||||
@@ -82,10 +81,6 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
protected boolean myIsCanceled = false;
|
||||
private PerformInBackgroundOption myBackgroundOption;
|
||||
|
||||
public boolean login(ModalityContext executor) {
|
||||
return loginAll(executor);
|
||||
}
|
||||
|
||||
public CommandCvsHandler(String title, CvsOperation cvsOperation, boolean canBeCanceled) {
|
||||
this(title, cvsOperation, FileSetToBeUpdated.EMPTY, canBeCanceled);
|
||||
}
|
||||
@@ -112,6 +107,10 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
myBackgroundOption = backgroundOption;
|
||||
}
|
||||
|
||||
public boolean login(Project project, ModalityContext executor) {
|
||||
return loginAll(project, executor);
|
||||
}
|
||||
|
||||
public boolean canBeCanceled() {
|
||||
return myCanBeCanceled;
|
||||
}
|
||||
@@ -314,8 +313,8 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
return myIsCanceled;
|
||||
}
|
||||
|
||||
private boolean loginAll(final ModalityContext executor) {
|
||||
final Set<CvsRootProvider> allRoots = new HashSet<CvsRootProvider>();
|
||||
private boolean loginAll(Project project, final ModalityContext executor) {
|
||||
final Set<CvsEnvironment> allRoots = new HashSet<CvsEnvironment>();
|
||||
try {
|
||||
myCvsOperation.appendSelfCvsRootProvider(allRoots);
|
||||
for (CvsOperation postActivity : myPostActivities) {
|
||||
@@ -327,7 +326,7 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
final LoginPerformer.MyForRootProvider performer = new LoginPerformer.MyForRootProvider(allRoots, new Consumer<VcsException>() {
|
||||
final LoginPerformer performer = new LoginPerformer(project, allRoots, new Consumer<VcsException>() {
|
||||
public void consume(VcsException e) {
|
||||
myErrors.add(e);
|
||||
}
|
||||
@@ -335,14 +334,15 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
return performer.loginAll(executor);
|
||||
}
|
||||
|
||||
public void internalRun(final ModalityContext executor, final boolean runInReadAction) {
|
||||
if (! login(executor)) return;
|
||||
@Override
|
||||
public void internalRun(Project project, final ModalityContext executor, final boolean runInReadAction) {
|
||||
if (! login(project, executor)) return;
|
||||
|
||||
final CvsExecutionEnvironment executionEnvironment = new CvsExecutionEnvironment(myCompositeListener,
|
||||
getProgressListener(),
|
||||
myErrorMessageProcessor,
|
||||
executor,
|
||||
getPostActivityHandler());
|
||||
getPostActivityHandler(),
|
||||
project);
|
||||
if (! runOperation(executionEnvironment, runInReadAction, myCvsOperation)) return;
|
||||
onOperationFinished(executor);
|
||||
|
||||
@@ -405,7 +405,7 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
}
|
||||
|
||||
public static CvsHandler createGetFileFromRepositoryHandler(CvsLightweightFile[] cvsLightweightFiles, boolean makeNewFilesReadOnly) {
|
||||
final CompositeOperation compositeOperaton = new CompositeOperation();
|
||||
final CompositeOperation compositeOperation = new CompositeOperation();
|
||||
final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
|
||||
for (CvsLightweightFile cvsLightweightFile : cvsLightweightFiles) {
|
||||
final File root = cvsLightweightFile.getRoot();
|
||||
@@ -422,10 +422,10 @@ public class CommandCvsHandler extends AbstractCvsHandler {
|
||||
alternativeCheckoutPath,
|
||||
true,
|
||||
null);
|
||||
compositeOperaton.addOperation(checkoutFileOperation);
|
||||
compositeOperation.addOperation(checkoutFileOperation);
|
||||
}
|
||||
|
||||
return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"), compositeOperaton, FileSetToBeUpdated.allFiles(), true);
|
||||
return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"), compositeOperation, FileSetToBeUpdated.allFiles(), true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.cvsSupport2.cvshandlers;
|
||||
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorMessagesProcessor;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsCompositeListener;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsListenerWithProgress;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesAdapter;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener;
|
||||
@@ -37,9 +38,6 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
|
||||
@NonNls private static final String NULL_HANDLER_NAME = "Null";
|
||||
public static final CvsHandler NULL = new CvsHandler(NULL_HANDLER_NAME, FileSetToBeUpdated.EMPTY) {
|
||||
protected void addCvsListener(CvsMessagesListener listener) {}
|
||||
|
||||
protected void removeCvsListener(CvsMessagesListener listener) {}
|
||||
|
||||
protected int getFilesToProcessCount() {
|
||||
return 0;
|
||||
@@ -49,7 +47,7 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean login(ModalityContext executor) {
|
||||
public boolean login(Project project, ModalityContext executor) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -57,6 +55,7 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
public static final int UNKNOWN_COUNT = -1;
|
||||
|
||||
protected final List<VcsException> myErrors = new ArrayList<VcsException>();
|
||||
protected final CvsCompositeListener myCompositeListener = new CvsCompositeListener();
|
||||
protected ErrorMessagesProcessor myErrorMessageProcessor = new ErrorMessagesProcessor(myErrors);
|
||||
private int myFilesToProcess = -1;
|
||||
private int myProcessedFiles = 0;
|
||||
@@ -71,12 +70,16 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
myFiles = files;
|
||||
}
|
||||
|
||||
public void internalRun(ModalityContext executor, final boolean runInReadAction) {
|
||||
public void internalRun(Project project, ModalityContext executor, final boolean runInReadAction) {
|
||||
}
|
||||
|
||||
protected abstract void addCvsListener(CvsMessagesListener listener);
|
||||
public void addCvsListener(CvsMessagesListener listener) {
|
||||
myCompositeListener.addCvsListener(listener);
|
||||
}
|
||||
|
||||
protected abstract void removeCvsListener(CvsMessagesListener listener);
|
||||
public void removeCvsListener(CvsMessagesListener listener) {
|
||||
myCompositeListener.removeCvsListener(listener);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return myTitle;
|
||||
@@ -87,7 +90,7 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
}
|
||||
|
||||
public List<VcsException> getErrorsExceptAborted() {
|
||||
List<VcsException> result = new ArrayList<VcsException>();
|
||||
final List<VcsException> result = new ArrayList<VcsException>();
|
||||
for(VcsException ex: myErrorMessageProcessor.getErrors()) {
|
||||
if (!(ex.getCause() instanceof CommandAbortedException)) {
|
||||
result.add(ex);
|
||||
@@ -136,15 +139,15 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void run(final ModalityContext executor) {
|
||||
public void run(Project project, final ModalityContext executor) {
|
||||
initializeListeners();
|
||||
try {
|
||||
internalRun(executor, runInReadThread());
|
||||
internalRun(project, executor, runInReadThread());
|
||||
} finally {
|
||||
cleanupListeners();
|
||||
}
|
||||
if (isCanceled()) throw new ProcessCanceledException();
|
||||
ProgressIndicator progress = getProgress();
|
||||
final ProgressIndicator progress = getProgress();
|
||||
if (progress != null) {
|
||||
if (progress.isCanceled()) throw new ProcessCanceledException();
|
||||
}
|
||||
@@ -179,7 +182,7 @@ public abstract class CvsHandler extends CvsMessagesAdapter{
|
||||
|
||||
public void beforeLogin() {}
|
||||
|
||||
public abstract boolean login(ModalityContext executor);
|
||||
public abstract boolean login(Project project, ModalityContext executor);
|
||||
|
||||
public FileSetToBeUpdated getFiles() {
|
||||
return myFiles;
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
package com.intellij.cvsSupport2.cvsoperations.common;
|
||||
|
||||
import com.intellij.cvsSupport2.application.CvsEntriesManager;
|
||||
import com.intellij.cvsSupport2.connections.CvsRootProvider;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsAdd.AddFileOperation;
|
||||
import com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -40,7 +40,7 @@ public class CompositeOperation extends CvsOperation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendSelfCvsRootProvider(@NotNull final Collection<CvsRootProvider> roots) throws CannotFindCvsRootException {
|
||||
public void appendSelfCvsRootProvider(@NotNull final Collection<CvsEnvironment> roots) throws CannotFindCvsRootException {
|
||||
for (CvsOperation operation : mySubOperations) {
|
||||
operation.appendSelfCvsRootProvider(roots);
|
||||
}
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@ import com.intellij.CvsBundle;
|
||||
import com.intellij.cvsSupport2.CvsUtil;
|
||||
import com.intellij.cvsSupport2.application.CvsEntriesManager;
|
||||
import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.connections.CvsRootProvider;
|
||||
import com.intellij.cvsSupport2.connections.pserver.PServerCvsSettings;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContextImpl;
|
||||
@@ -120,7 +121,7 @@ public abstract class CvsCommandOperation extends CvsOperation implements IFileI
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendSelfCvsRootProvider(@NotNull Collection<CvsRootProvider> roots) throws CannotFindCvsRootException {
|
||||
public void appendSelfCvsRootProvider(@NotNull Collection<CvsEnvironment> roots) throws CannotFindCvsRootException {
|
||||
roots.addAll(getAllCvsRoots());
|
||||
}
|
||||
|
||||
@@ -271,8 +272,8 @@ public abstract class CvsCommandOperation extends CvsOperation implements IFileI
|
||||
if (! root.isOffline()) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
final LoginPerformer.MyForRootProvider performer =
|
||||
new LoginPerformer.MyForRootProvider(Collections.singletonList(root), new Consumer<VcsException>() {
|
||||
final LoginPerformer performer =
|
||||
new LoginPerformer(executionEnvironment.getProject(), Collections.<CvsEnvironment>singletonList(root), new Consumer<VcsException>() {
|
||||
public void consume(VcsException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
|
||||
+8
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,19 +15,15 @@
|
||||
*/
|
||||
package com.intellij.cvsSupport2.cvsoperations.common;
|
||||
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsErrors.ErrorProcessor;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsMessages.CvsMessagesListener;
|
||||
import com.intellij.cvsSupport2.javacvsImpl.io.ReadWriteStatistics;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.netbeans.lib.cvsclient.ICvsCommandStopper;
|
||||
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
public class CvsExecutionEnvironment {
|
||||
|
||||
public final static ICvsCommandStopper DUMMY_STOPPER = new ICvsCommandStopper() {
|
||||
@@ -46,20 +42,20 @@ public class CvsExecutionEnvironment {
|
||||
private final CvsMessagesListener myListener;
|
||||
private final ICvsCommandStopper myCommandStopper;
|
||||
private final ErrorProcessor myErrorProcessor;
|
||||
private final ModalityContext myExecutor;
|
||||
private final PostCvsActivity myPostCvsActivity;
|
||||
private final Project myProject;
|
||||
private ReadWriteStatistics myReadWriteStatistics;
|
||||
|
||||
public CvsExecutionEnvironment(CvsMessagesListener listener,
|
||||
ICvsCommandStopper commandStopper,
|
||||
ErrorProcessor errorProcessor,
|
||||
ModalityContext executor,
|
||||
PostCvsActivity postCvsActivity) {
|
||||
PostCvsActivity postCvsActivity,
|
||||
Project project) {
|
||||
myListener = listener;
|
||||
myCommandStopper = commandStopper;
|
||||
myErrorProcessor = errorProcessor;
|
||||
myExecutor = executor;
|
||||
myPostCvsActivity = postCvsActivity;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public CvsMessagesListener getCvsMessagesListener() {
|
||||
@@ -72,8 +68,8 @@ public class CvsExecutionEnvironment {
|
||||
|
||||
public ErrorProcessor getErrorProcessor() { return myErrorProcessor; }
|
||||
|
||||
public ModalityContext getExecutor(){
|
||||
return myExecutor;
|
||||
public Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
public PostCvsActivity getPostCvsActivity() {
|
||||
|
||||
+7
-4
@@ -16,7 +16,7 @@
|
||||
package com.intellij.cvsSupport2.cvsoperations.common;
|
||||
|
||||
import com.intellij.cvsSupport2.config.CvsApplicationLevelConfiguration;
|
||||
import com.intellij.cvsSupport2.connections.CvsRootProvider;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
|
||||
import com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -26,7 +26,10 @@ import org.netbeans.lib.cvsclient.command.CommandAbortedException;
|
||||
import org.netbeans.lib.cvsclient.command.GlobalOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class CvsOperation {
|
||||
private final static String[] ourKnownToCvs = {"CVSIGNORE",
|
||||
@@ -82,7 +85,7 @@ public abstract class CvsOperation {
|
||||
|
||||
public abstract void execute(CvsExecutionEnvironment executionEnvironment, boolean underReadAction) throws VcsException, CommandAbortedException;
|
||||
|
||||
public abstract void appendSelfCvsRootProvider(@NotNull final Collection<CvsRootProvider> roots) throws CannotFindCvsRootException;
|
||||
public abstract void appendSelfCvsRootProvider(@NotNull final Collection<CvsEnvironment> roots) throws CannotFindCvsRootException;
|
||||
|
||||
public void addFinishAction(Runnable action) {
|
||||
myFinishActions.add(action);
|
||||
@@ -110,12 +113,12 @@ public abstract class CvsOperation {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
File[] subFiles = file.listFiles();
|
||||
if (subFiles == null) {
|
||||
subFiles = new File[0];
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
for (File subFile : subFiles) {
|
||||
result += calculateFilesIn(subFile);
|
||||
}
|
||||
|
||||
+9
-48
@@ -17,21 +17,16 @@ package com.intellij.cvsSupport2.cvsoperations.common;
|
||||
|
||||
import com.intellij.CvsBundle;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.connections.CvsRootProvider;
|
||||
import com.intellij.cvsSupport2.connections.login.CvsLoginWorker;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.errorHandling.CvsException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectLocator;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
||||
|
||||
import java.net.ConnectException;
|
||||
@@ -40,12 +35,14 @@ import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class LoginPerformer<T extends CvsEnvironment> {
|
||||
private final Collection<T> myRoots;
|
||||
public class LoginPerformer {
|
||||
private final Project myProject;
|
||||
private final Collection<CvsEnvironment> myRoots;
|
||||
private final Consumer<VcsException> myExceptionConsumer;
|
||||
private boolean myForceCheck;
|
||||
|
||||
public LoginPerformer(Collection<T> roots, Consumer<VcsException> exceptionConsumer) {
|
||||
public LoginPerformer(final Project project, Collection<CvsEnvironment> roots, Consumer<VcsException> exceptionConsumer) {
|
||||
myProject = project;
|
||||
myRoots = roots;
|
||||
myExceptionConsumer = exceptionConsumer;
|
||||
myForceCheck = false;
|
||||
@@ -55,20 +52,16 @@ public abstract class LoginPerformer<T extends CvsEnvironment> {
|
||||
myForceCheck = forceCheck;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract Project getProject(T root);
|
||||
|
||||
public boolean loginAll(final ModalityContext executor) {
|
||||
return loginAll(executor, true);
|
||||
}
|
||||
|
||||
public boolean loginAll(final ModalityContext executor, final boolean goOffline) {
|
||||
for (T root : myRoots) {
|
||||
final Project project = getProject(root);
|
||||
final CvsLoginWorker worker = root.getLoginWorker(executor, project);
|
||||
for (CvsEnvironment root : myRoots) {
|
||||
final CvsLoginWorker worker = root.getLoginWorker(executor, myProject);
|
||||
|
||||
try {
|
||||
final ThreeState checkResult = checkLoginWorker(worker, executor, project, myForceCheck);
|
||||
final ThreeState checkResult = checkLoginWorker(worker, executor, myProject, myForceCheck);
|
||||
if (! ThreeState.YES.equals(checkResult)) {
|
||||
if (ThreeState.UNSURE.equals(checkResult)) {
|
||||
if (goOffline) {
|
||||
@@ -79,7 +72,7 @@ public abstract class LoginPerformer<T extends CvsEnvironment> {
|
||||
return false;
|
||||
}
|
||||
} catch (AuthenticationException e) {
|
||||
reportException(project, e);
|
||||
reportException(myProject, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -126,36 +119,4 @@ public abstract class LoginPerformer<T extends CvsEnvironment> {
|
||||
forceCheck = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyProjectKnown extends LoginPerformer<CvsEnvironment> {
|
||||
private final Project myProject;
|
||||
|
||||
public MyProjectKnown(final Project project, final Collection<CvsEnvironment> roots, final Consumer<VcsException> exceptionConsumer) {
|
||||
super(roots, exceptionConsumer);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Project getProject(CvsEnvironment root) {
|
||||
return myProject;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MyForRootProvider extends LoginPerformer<CvsRootProvider> {
|
||||
private final ProjectLocator myProjectLocator;
|
||||
private final LocalFileSystem myLfs;
|
||||
|
||||
public MyForRootProvider(Collection<CvsRootProvider> roots, Consumer<VcsException> exceptionConsumer) {
|
||||
super(roots, exceptionConsumer);
|
||||
myProjectLocator = ProjectLocator.getInstance();
|
||||
myLfs = LocalFileSystem.getInstance();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Project getProject(CvsRootProvider root) {
|
||||
final VirtualFile vf = root.getLocalRoot() == null ? null : myLfs.findFileByIoFile(root.getLocalRoot());
|
||||
return (vf == null) ? null : myProjectLocator.guessProjectForFile(vf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class SelectCvsElementStep extends WizardStep {
|
||||
|
||||
private boolean isLogged(final CvsRootConfiguration selectedConfiguration) {
|
||||
final Ref<Boolean> errors = new Ref<Boolean>();
|
||||
final LoginPerformer.MyProjectKnown performer = new LoginPerformer.MyProjectKnown(
|
||||
final LoginPerformer performer = new LoginPerformer(
|
||||
myProject, Collections.<CvsEnvironment>singletonList(selectedConfiguration),
|
||||
new Consumer<VcsException>() {
|
||||
public void consume(VcsException e) {
|
||||
|
||||
Reference in New Issue
Block a user