Search in sources :

Example 26 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnTreeConflictDataTest method testFile2File_MINE_MOVE_THEIRS_ADD.

@Test
public void testFile2File_MINE_MOVE_THEIRS_ADD() throws Exception {
    final String conflictFile = createConflict(TreeConflictData.FileToFile.MINE_MOVE_THEIRS_ADD);
    ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);
    VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myWorkingCopyDir.getPath(), conflictFile));
    Assert.assertNotNull(vf);
    final Change change = changeListManager.getChange(vf);
    Assert.assertTrue(change instanceof ConflictedSvnChange);
    TreeConflictDescription beforeDescription = ((ConflictedSvnChange) change).getBeforeDescription();
    Assert.assertNotNull(beforeDescription);
    final TreeConflictDescription afterDescription = ((ConflictedSvnChange) change).getAfterDescription();
    Assert.assertNull(afterDescription);
    Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation());
    Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction());
    Assert.assertTrue(beforeDescription.isTreeConflict());
    ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion();
    Assert.assertNull(leftVersion);
    //Assert.assertEquals(NodeKind.FILE, leftVersion.getKind());
    final ConflictVersion version = beforeDescription.getSourceRightVersion();
    Assert.assertNotNull(version);
    Assert.assertTrue(version.isFile());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TreeConflictDescription(org.jetbrains.idea.svn.conflict.TreeConflictDescription) ConflictVersion(org.jetbrains.idea.svn.conflict.ConflictVersion) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 27 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class SvnRenameTest method testRollbackRenameDir.

// IDEADEV-9755
@Test
public void testRollbackRenameDir() throws Exception {
    final VirtualFile child = prepareDirectoriesForRename();
    renameFileInCommand(child, "newchild");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final Change change = changeListManager.getChange(myWorkingCopyDir.findChild("newchild"));
    Assert.assertNotNull(change);
    final List<VcsException> exceptions = new ArrayList<>();
    SvnVcs.getInstance(myProject).getRollbackEnvironment().rollbackChanges(Collections.singletonList(change), exceptions, RollbackProgressListener.EMPTY);
    Assert.assertTrue(exceptions.isEmpty());
    Assert.assertFalse(new File(myWorkingCopyDir.getPath(), "newchild").exists());
    Assert.assertTrue(new File(myWorkingCopyDir.getPath(), "child").exists());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 28 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class MergeTask method setupDefaultEmptyChangeListForMerge.

private boolean setupDefaultEmptyChangeListForMerge() {
    ChangeListManager changeListManager = ChangeListManager.getInstance(myMergeContext.getProject());
    int i = 0;
    boolean needRefresh = false;
    while (true) {
        String name = myMergeContext.getTitle() + (i > 0 ? " (" + i + ")" : "");
        LocalChangeList changeList = changeListManager.findChangeList(name);
        if (changeList == null) {
            changeListManager.setDefaultChangeList(changeListManager.addChangeList(name, null));
            needRefresh = true;
            break;
        }
        if (changeList.getChanges().isEmpty()) {
            if (!changeList.isDefault()) {
                changeListManager.setDefaultChangeList(changeList);
                needRefresh = true;
            }
            break;
        }
        i++;
    }
    return needRefresh;
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 29 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class BaseAnalysisActionDialog method createCenterPanel.

@Override
protected JComponent createCenterPanel() {
    myTitledSeparator.setText(myAnalysisNoon);
    //include test option
    myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES);
    myInspectTestSource.setVisible(ModuleUtil.isSupportedRootType(myProject, JavaSourceRootType.TEST_SOURCE));
    //module scope if applicable
    myModuleButton.setText(AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName));
    boolean useModuleScope = false;
    if (myModuleName != null) {
        useModuleScope = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.MODULE;
        myModuleButton.setSelected(myRememberScope && useModuleScope);
    }
    myModuleButton.setVisible(myModuleName != null && ModuleManager.getInstance(myProject).getModules().length > 1);
    boolean useUncommitedFiles = false;
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    final boolean hasVCS = !changeListManager.getAffectedFiles().isEmpty();
    if (hasVCS) {
        useUncommitedFiles = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.UNCOMMITTED_FILES;
        myUncommitedFilesButton.setSelected(myRememberScope && useUncommitedFiles);
    }
    myUncommitedFilesButton.setVisible(hasVCS);
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
    model.addElement(ALL);
    final List<? extends ChangeList> changeLists = changeListManager.getChangeListsCopy();
    for (ChangeList changeList : changeLists) {
        model.addElement(changeList.getName());
    }
    myChangeLists.setRenderer(new ListCellRendererWrapper<String>() {

        @Override
        public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
            int availableWidth = myPanel.getWidth() - myUncommitedFilesButton.getWidth() - JBUI.scale(10);
            if (availableWidth <= 0) {
                availableWidth = JBUI.scale(200);
            }
            if (list.getFontMetrics(list.getFont()).stringWidth(value) < availableWidth) {
                setText(value);
            } else {
                setText(StringUtil.trimLog(value, 50));
            }
        }
    });
    myChangeLists.setModel(model);
    myChangeLists.setEnabled(myUncommitedFilesButton.isSelected());
    myChangeLists.setVisible(hasVCS);
    //file/package/directory/module scope
    if (myFileName != null) {
        myFileButton.setText(myFileName);
        myFileButton.setMnemonic(myFileName.charAt(getSelectedScopeMnemonic()));
    } else {
        myFileButton.setVisible(false);
    }
    VirtualFile file = PsiUtilBase.getVirtualFile(myContext);
    ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
    boolean searchInLib = file != null && (fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file));
    String preselect = StringUtil.isEmptyOrSpaces(myAnalysisOptions.CUSTOM_SCOPE_NAME) ? FindSettings.getInstance().getDefaultScopeName() : myAnalysisOptions.CUSTOM_SCOPE_NAME;
    if (searchInLib && GlobalSearchScope.projectScope(myProject).getDisplayName().equals(preselect)) {
        preselect = GlobalSearchScope.allScope(myProject).getDisplayName();
    }
    if (GlobalSearchScope.allScope(myProject).getDisplayName().equals(preselect) && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM) {
        myAnalysisOptions.CUSTOM_SCOPE_NAME = preselect;
        searchInLib = true;
    }
    //custom scope
    myCustomScopeButton.setSelected(myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM);
    myScopeCombo.init(myProject, searchInLib, true, preselect);
    myScopeCombo.setCurrentSelection(false);
    //correct selection
    myProjectButton.setSelected(myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.PROJECT || myFileName == null);
    myFileButton.setSelected(myFileName != null && (!myRememberScope || myAnalysisOptions.SCOPE_TYPE != AnalysisScope.PROJECT && !useModuleScope && myAnalysisOptions.SCOPE_TYPE != AnalysisScope.CUSTOM && !useUncommitedFiles));
    myScopeCombo.setEnabled(myCustomScopeButton.isSelected());
    final ActionListener radioButtonPressed = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            onScopeRadioButtonPressed();
        }
    };
    final Enumeration<AbstractButton> enumeration = myGroup.getElements();
    while (enumeration.hasMoreElements()) {
        enumeration.nextElement().addActionListener(radioButtonPressed);
    }
    //additional panel - inspection profile chooser
    JPanel wholePanel = new JPanel(new BorderLayout());
    wholePanel.add(myPanel, BorderLayout.NORTH);
    final JComponent additionalPanel = getAdditionalActionSettings(myProject);
    if (additionalPanel != null) {
        wholePanel.add(additionalPanel, BorderLayout.CENTER);
    }
    new RadioUpDownListener(myProjectButton, myModuleButton, myUncommitedFilesButton, myFileButton, myCustomScopeButton);
    return wholePanel;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionEvent(java.awt.event.ActionEvent) RadioUpDownListener(com.intellij.refactoring.util.RadioUpDownListener) ActionListener(java.awt.event.ActionListener) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 30 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.

the class ChangeListTodosTreeStructure method accept.

@Override
public boolean accept(final PsiFile psiFile) {
    if (!psiFile.isValid())
        return false;
    VirtualFile file = psiFile.getVirtualFile();
    ChangeListManager listManager = ChangeListManager.getInstance(myProject);
    FileStatus status = listManager.getStatus(file);
    if (status == FileStatus.NOT_CHANGED)
        return false;
    FilePath filePath = VcsUtil.getFilePath(file);
    final Collection<Change> changes = listManager.getDefaultChangeList().getChanges();
    for (Change change : changes) {
        ContentRevision afterRevision = change.getAfterRevision();
        if (afterRevision != null && afterRevision.getFile().equals(filePath)) {
            return (myTodoFilter != null && myTodoFilter.accept(mySearchHelper, psiFile) || (myTodoFilter == null && mySearchHelper.getTodoItemsCount(psiFile) > 0));
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) FileStatus(com.intellij.openapi.vcs.FileStatus) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Aggregations

ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)77 VirtualFile (com.intellij.openapi.vfs.VirtualFile)65 Test (org.junit.Test)57 Change (com.intellij.openapi.vcs.changes.Change)42 File (java.io.File)28 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)24 ConflictVersion (org.jetbrains.idea.svn.conflict.ConflictVersion)23 TreeConflictDescription (org.jetbrains.idea.svn.conflict.TreeConflictDescription)23 ArrayList (java.util.ArrayList)11 VcsException (com.intellij.openapi.vcs.VcsException)6 NotNull (org.jetbrains.annotations.NotNull)4 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)3 ProcessOutput (com.intellij.execution.process.ProcessOutput)2 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2 Nullable (org.jetbrains.annotations.Nullable)2 AccessToken (com.intellij.openapi.application.AccessToken)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileNodeDescriptor (com.intellij.openapi.fileChooser.ex.FileNodeDescriptor)1 FileSystemTreeImpl (com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl)1 Project (com.intellij.openapi.project.Project)1