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());
}
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());
}
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;
}
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;
}
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;
}
Aggregations