mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CVS update actions performance should be fixed
This commit is contained in:
@@ -49,7 +49,7 @@ public abstract class ProjectLevelVcsManager {
|
||||
|
||||
public abstract AbstractVcs findVcsByName(String name);
|
||||
|
||||
public abstract boolean checkAllFielsAreUnder(AbstractVcs abstractVcs, VirtualFile[] files);
|
||||
public abstract boolean checkAllFilesAreUnder(AbstractVcs abstractVcs, VirtualFile[] files);
|
||||
|
||||
public abstract AbstractVcs getVcsFor(VirtualFile file);
|
||||
|
||||
|
||||
@@ -38,11 +38,15 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import java.io.File;
|
||||
|
||||
public interface VcsContextFactory {
|
||||
VcsContext createOn(AnActionEvent event);
|
||||
VcsContext createCachedContextOn(AnActionEvent event);
|
||||
|
||||
FilePath createOn(VirtualFile virtualFile);
|
||||
VcsContext createContextOn(final AnActionEvent event);
|
||||
|
||||
FilePath createFilePathOn(VirtualFile virtualFile);
|
||||
|
||||
FilePath createFilePathOn(File file);
|
||||
|
||||
FilePath createFilePathOn(VirtualFile parent, String name);
|
||||
|
||||
FilePath createOn(File file);
|
||||
|
||||
FilePath createOn(VirtualFile parent, String name);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class AbstractAction extends AnAction {
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
actionPerformed(CvsContextWrapper.on(e));
|
||||
actionPerformed(CvsContextWrapper.createCachedInstance(e));
|
||||
}
|
||||
|
||||
private LocalVcs getLvcs(Project project) {
|
||||
@@ -201,13 +201,13 @@ public abstract class AbstractAction extends AnAction {
|
||||
}
|
||||
|
||||
protected CvsConfiguration getConfig(AnActionEvent e) {
|
||||
Project project = CvsContextWrapper.on(e).getProject();
|
||||
Project project = CvsContextWrapper.createCachedInstance(e).getProject();
|
||||
if (project == null) return null;
|
||||
return CvsConfiguration.getInstance(project);
|
||||
}
|
||||
|
||||
protected VcsConfiguration getCommonConfig(AnActionEvent e) {
|
||||
Project project = CvsContextWrapper.on(e).getProject();
|
||||
Project project = CvsContextWrapper.createCachedInstance(e).getProject();
|
||||
if (project == null) return null;
|
||||
return VcsConfiguration.getInstance(project);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.intellij.cvsSupport2.actions;
|
||||
|
||||
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
|
||||
import com.intellij.cvsSupport2.actions.cvsContext.CvsContextWrapper;
|
||||
import com.intellij.openapi.vcs.actions.VcsContext;
|
||||
import com.intellij.cvsSupport2.config.CvsRootConfiguration;
|
||||
import com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog;
|
||||
import com.intellij.cvsSupport2.cvsBrowser.ui.BrowserPanel;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvshandlers.AbstractCvsHandler;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
|
||||
import com.intellij.cvsSupport2.cvshandlers.FileSetToBeUpdated;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.cvsSupport2.cvsBrowser.ui.BrowserPanel;
|
||||
import com.intellij.cvsSupport2.ui.CvsTabbedWindow;
|
||||
import com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog;
|
||||
import com.intellij.cvsSupport2.cvsExecution.ModalityContext;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -30,7 +28,7 @@ public class BrowseCvsRepositoryAction extends AbstractAction{
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
VcsContext context = CvsContextWrapper.on(e);
|
||||
VcsContext context = CvsContextWrapper.createInstance(e);
|
||||
boolean projectExists = context.getProject() != null;
|
||||
presentation.setVisible(true);
|
||||
presentation.setEnabled(projectExists);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public class ConfigureCvsRootsAction extends CvsGlobalAction {
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
VcsContext cvsContext = CvsContextWrapper.on(e);
|
||||
VcsContext cvsContext = CvsContextWrapper.createCachedInstance(e);
|
||||
CvsApplicationLevelConfiguration configuration = CvsApplicationLevelConfiguration.getInstance();
|
||||
List<CvsRootConfiguration> configurations = configuration.CONFIGURATIONS;
|
||||
CvsConfigurationsListEditor cvsConfigurationsListEditor =
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
|
||||
public abstract class CvsGlobalAction extends AnAction {
|
||||
public void update(AnActionEvent e) {
|
||||
CvsContext cvsContext = CvsContextWrapper.on(e);
|
||||
CvsContext cvsContext = CvsContextWrapper.createInstance(e);
|
||||
Presentation presentation = e.getPresentation();
|
||||
if (cvsContext.cvsIsActive()) {
|
||||
presentation.setVisible(true);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class IgnoreFileAction extends AnAction {
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
CvsContext context = CvsContextWrapper.on(e);
|
||||
CvsContext context = CvsContextWrapper.createCachedInstance(e);
|
||||
VirtualFile[] selectedFiles = context.getSelectedFiles();
|
||||
|
||||
for (int i = 0; i < selectedFiles.length; i++) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UnmarkAddedAction extends AnAction{
|
||||
}
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
VcsContext context = CvsContextWrapper.on(e);
|
||||
VcsContext context = CvsContextWrapper.createCachedInstance(e);
|
||||
final VirtualFile[] selectedFiles = context.getSelectedFiles();
|
||||
ApplicationManager.getApplication().runProcessWithProgressSynchronously(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class CvsActionVisibility {
|
||||
}
|
||||
|
||||
public void applyToEvent(AnActionEvent e) {
|
||||
CvsContext cvsContext = CvsContextWrapper.on(e);
|
||||
CvsContext cvsContext = CvsContextWrapper.createInstance(e);
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(isEnabled(cvsContext));
|
||||
presentation.setVisible(isVisible(cvsContext));
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import java.util.Collection;
|
||||
/**
|
||||
* author: lesya
|
||||
*/
|
||||
public class CashedCvsContext implements CvsContext{
|
||||
public class CachedCvsContext implements CvsContext{
|
||||
private final boolean myIsActive;
|
||||
private final Collection<String> myDeletedFileNames;
|
||||
private final String myFileToRestore;
|
||||
@@ -28,7 +28,7 @@ public class CashedCvsContext implements CvsContext{
|
||||
|
||||
private final VcsContext myVcsContext;
|
||||
|
||||
public CashedCvsContext(CvsContext baseContext){
|
||||
public CachedCvsContext(CvsContext baseContext){
|
||||
myIsActive = baseContext.cvsIsActive();
|
||||
myDeletedFileNames = baseContext.getDeletedFileNames();
|
||||
myFileToRestore = baseContext.getFileToRestore();
|
||||
+8
-6
@@ -27,21 +27,23 @@ public class CvsContextWrapper implements CvsContext {
|
||||
private final VcsContext myVcsContext;
|
||||
private final DataContext myContext;
|
||||
|
||||
private CvsContextWrapper(AnActionEvent actionEvent) {
|
||||
private CvsContextWrapper(AnActionEvent actionEvent, final VcsContext vcsContext) {
|
||||
myContext = actionEvent.getDataContext();
|
||||
myVcsContext = PeerFactory.getInstance().getVcsContextFactory().createOn(actionEvent);
|
||||
myVcsContext = vcsContext;
|
||||
}
|
||||
|
||||
public static CvsContext on(AnActionEvent event) {
|
||||
CvsContextWrapper wrapper = new CvsContextWrapper(event);
|
||||
return new CashedCvsContext(wrapper);
|
||||
public static CvsContext createCachedInstance(AnActionEvent event) {
|
||||
return new CachedCvsContext(new CvsContextWrapper(event, PeerFactory.getInstance().getVcsContextFactory().createCachedContextOn(event)));
|
||||
}
|
||||
|
||||
public static CvsContext createInstance(AnActionEvent event) {
|
||||
return new CvsContextWrapper(event, PeerFactory.getInstance().getVcsContextFactory().createContextOn(event));
|
||||
}
|
||||
|
||||
public boolean cvsIsActive() {
|
||||
Project project = getProject();
|
||||
if (project == null) return false;
|
||||
return ProjectLevelVcsManager.getInstance(project).checkAllFielsAreUnder(CvsVcs2.getInstance(project), getSelectedFiles());
|
||||
return ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(CvsVcs2.getInstance(project), getSelectedFiles());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AnnotateToggleAction extends ToggleAction {
|
||||
}
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(isEnabled(PeerFactory.getInstance().getVcsContextFactory().createOn(e)));
|
||||
e.getPresentation().setEnabled(isEnabled(PeerFactory.getInstance().getVcsContextFactory().createCachedContextOn(e)));
|
||||
}
|
||||
|
||||
private boolean isEnabled(final VcsContext context) {
|
||||
@@ -55,7 +55,7 @@ public class AnnotateToggleAction extends ToggleAction {
|
||||
|
||||
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
VcsContext context = PeerFactory.getInstance().getVcsContextFactory().createOn(e);
|
||||
VcsContext context = PeerFactory.getInstance().getVcsContextFactory().createCachedContextOn(e);
|
||||
Editor editor = context.getEditor();
|
||||
if (editor == null) return false;
|
||||
Object annotations = editor.getUserData(AnnotateAction.KEY_IN_EDITOR);
|
||||
@@ -64,7 +64,7 @@ public class AnnotateToggleAction extends ToggleAction {
|
||||
}
|
||||
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
VcsContext context = PeerFactory.getInstance().getVcsContextFactory().createOn(e);
|
||||
VcsContext context = PeerFactory.getInstance().getVcsContextFactory().createCachedContextOn(e);
|
||||
Editor editor = context.getEditor();
|
||||
if (!state) {
|
||||
if (editor == null) {
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ import com.intellij.psi.PsiElement;
|
||||
import java.util.Collection;
|
||||
import java.io.File;
|
||||
|
||||
public class CashedVcsContext implements VcsContext {
|
||||
public class CachedVcsContext implements VcsContext {
|
||||
private final Project myProject;
|
||||
private final VirtualFile mySelectedFile;
|
||||
private final VirtualFile[] mySelectedFiles;
|
||||
@@ -56,7 +56,7 @@ public class CashedVcsContext implements VcsContext {
|
||||
private final FilePath[] mySelectedFilePaths;
|
||||
private final FilePath mySelectedFilePath;
|
||||
|
||||
public CashedVcsContext(VcsContext baseContext) {
|
||||
public CachedVcsContext(VcsContext baseContext) {
|
||||
myProject = baseContext.getProject();
|
||||
mySelectedFile = baseContext.getSelectedFile();
|
||||
mySelectedFiles = baseContext.getSelectedFiles();
|
||||
@@ -74,8 +74,7 @@ public class VcsContextWrapper implements VcsContext {
|
||||
}
|
||||
|
||||
public static VcsContext on(AnActionEvent event) {
|
||||
VcsContextWrapper wrapper = new VcsContextWrapper(event.getDataContext(), event.getModifiers(), event.getPlace());
|
||||
return new CashedVcsContext(wrapper);
|
||||
return new CachedVcsContext(new VcsContextWrapper(event.getDataContext(), event.getModifiers(), event.getPlace()));
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
return "ProjectLevelVcsManager";
|
||||
}
|
||||
|
||||
public boolean checkAllFielsAreUnder(AbstractVcs abstractVcs, VirtualFile[] files) {
|
||||
public boolean checkAllFilesAreUnder(AbstractVcs abstractVcs, VirtualFile[] files) {
|
||||
if (files == null) return false;
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
if (ProjectLevelVcsManager.getInstance(myProject).getVcsFor(files[i]) != abstractVcs) {
|
||||
|
||||
@@ -201,19 +201,23 @@ public class PeerFactoryImpl extends PeerFactory implements ApplicationComponent
|
||||
|
||||
public VcsContextFactory getVcsContextFactory() {
|
||||
return new VcsContextFactory() {
|
||||
public VcsContext createOn(AnActionEvent event) {
|
||||
public VcsContext createCachedContextOn(AnActionEvent event) {
|
||||
return VcsContextWrapper.on(event);
|
||||
}
|
||||
|
||||
public FilePath createOn(VirtualFile virtualFile) {
|
||||
public VcsContext createContextOn(final AnActionEvent event) {
|
||||
return new VcsContextWrapper(event.getDataContext(), event.getModifiers(), event.getPlace());
|
||||
}
|
||||
|
||||
public FilePath createFilePathOn(VirtualFile virtualFile) {
|
||||
return new FilePathImpl(virtualFile);
|
||||
}
|
||||
|
||||
public FilePath createOn(File file) {
|
||||
public FilePath createFilePathOn(File file) {
|
||||
return FilePathImpl.create(file);
|
||||
}
|
||||
|
||||
public FilePath createOn(VirtualFile parent, String name) {
|
||||
public FilePath createFilePathOn(VirtualFile parent, String name) {
|
||||
return new FilePathImpl(parent, name);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user