Search in sources :

Example 1 with Refreshable

use of com.intellij.openapi.vcs.ui.Refreshable in project intellij-community by JetBrains.

the class ShowMessageHistoryAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    CommitMessageI commitMessageI;
    final DataContext dc = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dc);
    final Refreshable panel = CheckinProjectPanel.PANEL_KEY.getData(dc);
    commitMessageI = (panel instanceof CommitMessageI) ? (CommitMessageI) panel : VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(dc);
    if (commitMessageI != null && project != null) {
        final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
        if (!configuration.getRecentMessages().isEmpty()) {
            final ContentChooser<String> contentChooser = new ContentChooser<String>(project, VcsBundle.message("dialog.title.choose.commit.message.from.history"), false) {

                protected void removeContentAt(final String content) {
                    configuration.removeMessage(content);
                }

                protected String getStringRepresentationFor(final String content) {
                    return content;
                }

                protected List<String> getContents() {
                    final List<String> recentMessages = configuration.getRecentMessages();
                    Collections.reverse(recentMessages);
                    return recentMessages;
                }
            };
            if (contentChooser.showAndGet()) {
                final int selectedIndex = contentChooser.getSelectedIndex();
                if (selectedIndex >= 0) {
                    commitMessageI.setCommitMessage(contentChooser.getAllContents().get(selectedIndex));
                }
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ContentChooser(com.intellij.openapi.editor.actions.ContentChooser) Refreshable(com.intellij.openapi.vcs.ui.Refreshable)

Example 2 with Refreshable

use of com.intellij.openapi.vcs.ui.Refreshable in project intellij-community by JetBrains.

the class IgnoreFileAction method refreshFilesAndStatuses.

private static void refreshFilesAndStatuses(final CvsContext context, final MultiMap<VirtualFile, VirtualFile> parentToSelectedChildren) {
    final Refreshable refreshablePanel = context.getRefreshableDialog();
    if (refreshablePanel != null)
        refreshablePanel.saveState();
    final int[] refreshedParents = new int[] { 0 };
    final Collection<VirtualFile> createdCvsIgnoreFiles = new ArrayList<>();
    for (final VirtualFile parent : parentToSelectedChildren.keySet()) {
        final Runnable runnable = new Runnable() {

            public void run() {
                try {
                    final VirtualFile cvsIgnoreFile = CvsVfsUtil.refreshAndfFindChild(parent, CvsUtil.CVS_IGNORE_FILE);
                    if (cvsIgnoreFile == null) {
                        final String path = parent.getPath() + "/" + CvsUtil.CVS_IGNORE_FILE;
                        LOG.error(String.valueOf(CvsVfsUtil.findFileByPath(path)) + " " + parent.getPath() + " " + new File(VfsUtil.virtualToIoFile(parent), CvsUtil.CVS_IGNORE_FILE).isFile());
                        return;
                    }
                    if (!CvsUtil.fileIsUnderCvs(cvsIgnoreFile) && !ChangeListManager.getInstance(context.getProject()).isIgnoredFile(cvsIgnoreFile) && !CvsEntriesManager.getInstance().fileIsIgnored(cvsIgnoreFile)) {
                        createdCvsIgnoreFiles.add(cvsIgnoreFile);
                    }
                    final Collection<VirtualFile> filesToUpdateStatus = parentToSelectedChildren.get(parent);
                    for (final VirtualFile file : filesToUpdateStatus) {
                        FileStatusManager.getInstance(context.getProject()).fileStatusChanged(file);
                        VcsDirtyScopeManager.getInstance(context.getProject()).fileDirty(file);
                    }
                } finally {
                    refreshedParents[0]++;
                    if (refreshedParents[0] == parentToSelectedChildren.size()) {
                        // all parents are refreshed
                        if (createdCvsIgnoreFiles.isEmpty()) {
                            refreshPanel(context);
                        } else {
                            addCvsIgnoreFilesToCvsAndRefreshPanel();
                        }
                    }
                }
            }

            private void addCvsIgnoreFilesToCvsAndRefreshPanel() {
                createAddFilesAction().actionPerformed(createContext(createdCvsIgnoreFiles, context));
            }

            private AddFileOrDirectoryAction createAddFilesAction() {
                return new AddFileOrDirectoryAction(CvsBundle.message("adding.cvsignore.files.to.cvs.action.name"), Options.ON_FILE_ADDING) {

                    protected void onActionPerformed(CvsContext context, CvsTabbedWindow tabbedWindow, boolean successfully, CvsHandler handler) {
                        refreshPanel(context);
                    }
                };
            }
        };
        parent.refresh(true, true, runnable);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsTabbedWindow(com.intellij.cvsSupport2.ui.CvsTabbedWindow) CvsHandler(com.intellij.cvsSupport2.cvshandlers.CvsHandler) CvsContext(com.intellij.cvsSupport2.actions.cvsContext.CvsContext) ArrayList(java.util.ArrayList) Refreshable(com.intellij.openapi.vcs.ui.Refreshable) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with Refreshable

use of com.intellij.openapi.vcs.ui.Refreshable in project intellij-community by JetBrains.

the class IgnoreFileAction method refreshPanel.

private static void refreshPanel(CvsContext context) {
    final Refreshable refreshablePanel = context.getRefreshableDialog();
    if (refreshablePanel != null) {
        refreshablePanel.restoreState();
        refreshablePanel.refresh();
    }
}
Also used : Refreshable(com.intellij.openapi.vcs.ui.Refreshable)

Aggregations

Refreshable (com.intellij.openapi.vcs.ui.Refreshable)3 CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)1 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)1 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ContentChooser (com.intellij.openapi.editor.actions.ContentChooser)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1