Search in sources :

Example 36 with LocalChangeList

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

the class ChangeListChooserPanel method getSelectedList.

/**
   * Method used as getResult, usually invoked inside doOkAction
   */
@Nullable
public LocalChangeList getSelectedList(Project project) {
    ChangeListManager manager = ChangeListManager.getInstance(project);
    String changeListName = myListPanel.getChangeListName();
    LocalChangeList localChangeList = manager.findChangeList(changeListName);
    if (localChangeList == null) {
        localChangeList = manager.addChangeList(changeListName, myListPanel.getDescription());
        myListPanel.changelistCreatedOrChanged(localChangeList);
    } else {
        //update description if changed
        localChangeList.setComment(myListPanel.getDescription());
    }
    rememberSettings(project, localChangeList.isDefault(), myListPanel.getMakeActiveCheckBox().isSelected());
    if (myListPanel.getMakeActiveCheckBox().isSelected()) {
        manager.setDefaultChangeList(localChangeList);
    }
    return localChangeList;
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with LocalChangeList

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

the class ShareDialog method createFolderPanel.

private JComponent createFolderPanel() {
    final Project project = myVCS.getProject();
    myCommitMessage = new CommitMessage(project) {

        @Override
        public Dimension getPreferredSize() {
            final Dimension superValue = super.getPreferredSize();
            return new Dimension(superValue.width, superValue.height > 90 ? superValue.height : 90);
        }

        @Override
        public void addNotify() {
            super.addNotify();
            myCommitMessage.getEditorField().getFocusTarget().addFocusListener(new FocusAdapter() {

                @Override
                public void focusGained(FocusEvent e) {
                    myPrefferedFocused = myCommitMessage.getEditorField();
                }
            });
        }
    };
    final JPanel panel = new JPanel(new GridBagLayout());
    final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insets(1), 0, 0);
    gb.insets.top = 5;
    final JLabel label = new JLabel("Define share target");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    panel.add(label, gb);
    gb.insets.top = 1;
    final ButtonGroup bg = new ButtonGroup();
    myExisting = new JRadioButton();
    mySameNameAsLocal = new JRadioButton();
    myTrunk = new JRadioButton();
    bg.add(myExisting);
    bg.add(mySameNameAsLocal);
    bg.add(myTrunk);
    gb.insets.top = 1;
    ++gb.gridy;
    panel.add(myExisting, gb);
    ++gb.gridy;
    panel.add(mySameNameAsLocal, gb);
    ++gb.gridy;
    gb.insets.top = 5;
    panel.add(myTrunk, gb);
    myCreateStandard = new JCheckBox("Create /tags and /branches");
    myTrunk.addChangeListener(e -> myCreateStandard.setEnabled(myTrunk.isSelected()));
    myCreateStandard.setSelected(true);
    ++gb.gridy;
    gb.insets.top = 0;
    gb.insets.left = 10;
    panel.add(myCreateStandard, gb);
    ++gb.gridy;
    gb.gridx = 0;
    gb.insets.top = 1;
    gb.insets.left = 1;
    gb.weightx = 1;
    gb.fill = GridBagConstraints.HORIZONTAL;
    final LocalChangeList list = ChangeListManager.getInstance(project).getDefaultChangeList();
    String text = list.getComment();
    text = StringUtil.isEmptyOrSpaces(text) ? (list.hasDefaultName() ? "" : list.getName()) : text;
    myCommitMessage.setText(text);
    panel.add(myCommitMessage, gb);
    myCommitMessage.setSeparatorText("Commit Comment Prefix");
    for (EditChangelistSupport support : Extensions.getExtensions(EditChangelistSupport.EP_NAME, project)) {
        support.installSearch(myCommitMessage.getEditorField(), myCommitMessage.getEditorField());
    }
    myTrunk.setSelected(true);
    return panel;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) CommitMessage(com.intellij.openapi.vcs.ui.CommitMessage) FocusEvent(java.awt.event.FocusEvent) Project(com.intellij.openapi.project.Project) EditChangelistSupport(com.intellij.openapi.vcs.changes.ui.EditChangelistSupport) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList)

Example 38 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testComplex.

@Test
public void testComplex() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final VirtualFile fileB = createFileInCommand("b.txt", "old content");
    final VirtualFile fileC = createFileInCommand("c.txt", "old content");
    final VirtualFile fileD = createFileInCommand("d.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    final LocalChangeList list = changeListManager.addChangeList("test", null);
    final LocalChangeList toBeDeletedList = changeListManager.addChangeList("toBeDeletedList", null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file), changeListManager.getChange(fileB) });
    changeListManager.moveChangesTo(toBeDeletedList, new Change[] { changeListManager.getChange(fileC), changeListManager.getChange(fileD) });
    changeListManager.ensureUpToDate(false);
    final String targetName = "target";
    final String finalName = "final list name";
    myScheme.doTest(() -> {
        final LocalChangeList target = changeListManager.addChangeList(targetName, null);
        changeListManager.moveChangesTo(target, new Change[] { changeListManager.getChange(file), changeListManager.getChange(fileB) });
        checkFilesAreInList(new VirtualFile[] { file, fileB }, targetName, changeListManager);
        changeListManager.editName(targetName, finalName);
        checkFilesAreInList(new VirtualFile[] { file, fileB }, finalName, changeListManager);
        changeListManager.removeChangeList(toBeDeletedList.getName());
        checkFilesAreInList(new VirtualFile[] { fileC, fileD }, myDefaulListName, changeListManager);
        changeListManager.moveChangesTo(LocalChangeList.createEmptyChangeList(myProject, finalName), new Change[] { changeListManager.getChange(fileC) });
        checkFilesAreInList(new VirtualFile[] { file, fileB, fileC }, finalName, changeListManager);
        checkFilesAreInList(new VirtualFile[] { fileD }, myDefaulListName, changeListManager);
    });
    checkFilesAreInList(new VirtualFile[] { file, fileB, fileC }, finalName, changeListManager);
    checkFilesAreInList(new VirtualFile[] { fileD }, myDefaulListName, changeListManager);
    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] { file, fileB, fileC }, finalName, changeListManager);
    checkFilesAreInList(new VirtualFile[] { fileD }, myDefaulListName, changeListManager);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 39 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testAddPlusMove.

@Test
public void testAddPlusMove() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final LocalChangeList list = changeListManager.addChangeList("test", null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file) });
    final String targetName = "target";
    myScheme.doTest(() -> {
        final LocalChangeList target = changeListManager.addChangeList(targetName, null);
        changeListManager.moveChangesTo(target, new Change[] { changeListManager.getChange(file) });
        checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
    });
    checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 40 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testRemove.

@Test
public void testRemove() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final VirtualFile fileB = createFileInCommand("b.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final LocalChangeList list = changeListManager.addChangeList("test", null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file) });
    myScheme.doTest(() -> {
        changeListManager.removeChangeList(list.getName());
        assert changeListManager.findChangeList(list.getName()) == null;
        checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
    });
    assert changeListManager.findChangeList(list.getName()) == null;
    checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
    changeListManager.ensureUpToDate(false);
    assert changeListManager.findChangeList(list.getName()) == null;
    checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Aggregations

LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)44 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 Test (org.junit.Test)20 Project (com.intellij.openapi.project.Project)8 Change (com.intellij.openapi.vcs.changes.Change)7 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)5 TaskManager (com.intellij.tasks.TaskManager)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)2 ChangeListInfo (com.intellij.tasks.ChangeListInfo)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 DataManager (com.intellij.ide.DataManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ComboBoxAction (com.intellij.openapi.actionSystem.ex.ComboBoxAction)1 DumbAware (com.intellij.openapi.project.DumbAware)1