Search in sources :

Example 16 with CvsContext

use of com.intellij.cvsSupport2.actions.cvsContext.CvsContext in project intellij-community by JetBrains.

the class ViewWatchersAction method onActionPerformed.

protected void onActionPerformed(CvsContext context, CvsTabbedWindow tabbedWindow, boolean successfully, CvsHandler handler) {
    super.onActionPerformed(context, tabbedWindow, successfully, handler);
    if (successfully) {
        List<WatcherInfo> watchers = myWatchersOperation.getWatchers();
        String filePath = CvsVfsUtil.getFileFor(context.getSelectedFile()).getAbsolutePath();
        final Project project = context.getProject();
        if (project == null) {
            return;
        }
        if (watchers.isEmpty()) {
            VcsBalloonProblemNotifier.showOverChangesView(project, CvsBundle.message("message.error.no.watchers.for.file", filePath), MessageType.INFO);
        } else {
            tabbedWindow.addTab(CvsBundle.message("message.watchers.for.file", filePath), new WatchersPanel(watchers), true, true, true, true, null, "cvs.watchers");
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) WatcherInfo(com.intellij.cvsSupport2.cvsoperations.cvsWatch.WatcherInfo) WatchersPanel(com.intellij.cvsSupport2.cvsoperations.cvsWatch.ui.WatchersPanel)

Example 17 with CvsContext

use of com.intellij.cvsSupport2.actions.cvsContext.CvsContext in project intellij-community by JetBrains.

the class CvsActionVisibility method applyToEvent.

public void applyToEvent(AnActionEvent e) {
    if (!CvsEntriesManager.getInstance().isActive()) {
        final Presentation presentation = e.getPresentation();
        presentation.setVisible(false);
        presentation.setEnabled(false);
        return;
    }
    CvsContext cvsContext = CvsContextWrapper.createInstance(e);
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(isEnabled(cvsContext));
    presentation.setVisible(cvsContext.cvsIsActive());
}
Also used : CvsContext(com.intellij.cvsSupport2.actions.cvsContext.CvsContext) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 18 with CvsContext

use of com.intellij.cvsSupport2.actions.cvsContext.CvsContext 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 19 with CvsContext

use of com.intellij.cvsSupport2.actions.cvsContext.CvsContext in project intellij-community by JetBrains.

the class ImportAction method createCheckoutAction.

private AbstractAction createCheckoutAction(final boolean makeNewFilesReadOnly) {
    return new AbstractAction(false) {

        protected String getTitle(VcsContext context) {
            return CvsBundle.message("operation.name.check.out.project");
        }

        protected CvsHandler getCvsHandler(CvsContext context) {
            final Project project = context.getProject();
            return CommandCvsHandler.createCheckoutHandler(myImportDetails.getCvsRoot(), new String[] { myImportDetails.getModuleName() }, myImportDetails.getBaseImportDirectory(), true, makeNewFilesReadOnly, project == null ? null : VcsConfiguration.getInstance(project).getCheckoutOption());
        }

        protected void onActionPerformed(CvsContext context, CvsTabbedWindow tabbedWindow, boolean successfully, CvsHandler handler) {
            super.onActionPerformed(context, tabbedWindow, successfully, handler);
            final Project project = context.getProject();
            if (successfully) {
                if (project != null) {
                    final VirtualFile importedRoot = CvsVfsUtil.findFileByIoFile(myImportDetails.getBaseImportDirectory());
                    updateDirectoryMappings(project, importedRoot);
                }
            }
        }

        /**
       * Basically copied from GitInit/HgInit
       */
        private void updateDirectoryMappings(Project project, VirtualFile mapRoot) {
            if (project == null || project.isDefault()) {
                return;
            }
            final VirtualFile projectBaseDir = project.getBaseDir();
            if (projectBaseDir == null || !VfsUtil.isAncestor(projectBaseDir, mapRoot, false)) {
                return;
            }
            mapRoot.refresh(false, false);
            final String path = mapRoot.equals(projectBaseDir) ? "" : mapRoot.getPath();
            ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
            manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), path, CvsVcs2.getInstance(project).getName()));
            manager.updateActiveVcss();
        }
    };
}
Also used : VcsContext(com.intellij.openapi.vcs.actions.VcsContext) CvsTabbedWindow(com.intellij.cvsSupport2.ui.CvsTabbedWindow) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) CvsHandler(com.intellij.cvsSupport2.cvshandlers.CvsHandler) CommandCvsHandler(com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler) CvsContext(com.intellij.cvsSupport2.actions.cvsContext.CvsContext) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager)

Example 20 with CvsContext

use of com.intellij.cvsSupport2.actions.cvsContext.CvsContext in project intellij-community by JetBrains.

the class ToggleOfflineAction method setSelected.

public void setSelected(AnActionEvent e, boolean state) {
    CvsContext cvsContext = CvsContextWrapper.createInstance(e);
    final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
    final VirtualFile file = cvsContext.getSelectedFile();
    if (file == null)
        return;
    final VirtualFile firstDirInChain = file.isDirectory() ? file : file.getParent();
    if (firstDirInChain == null)
        return;
    CvsConnectionSettings settings = entriesManager.getCvsConnectionSettingsFor(firstDirInChain);
    if (!settings.isValid()) {
        entriesManager.clearCachedEntriesFor(firstDirInChain);
        settings = entriesManager.getCvsConnectionSettingsFor(firstDirInChain);
    }
    if ((settings != null) && settings.isValid() && (state != settings.isOffline())) {
        VcsBalloonProblemNotifier.showOverChangesView(cvsContext.getProject(), state ? CvsBundle.message("set.offline.notification.text") : CvsBundle.message("set.online.notification.text"), state ? MessageType.WARNING : MessageType.INFO);
        settings.setOffline(state);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CvsContext(com.intellij.cvsSupport2.actions.cvsContext.CvsContext) CvsEntriesManager(com.intellij.cvsSupport2.application.CvsEntriesManager) CvsConnectionSettings(com.intellij.cvsSupport2.connections.CvsConnectionSettings)

Aggregations

CvsContext (com.intellij.cvsSupport2.actions.cvsContext.CvsContext)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Project (com.intellij.openapi.project.Project)9 FilePath (com.intellij.openapi.vcs.FilePath)5 CommandCvsHandler (com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler)3 CvsHandler (com.intellij.cvsSupport2.cvshandlers.CvsHandler)3 CvsTabbedWindow (com.intellij.cvsSupport2.ui.CvsTabbedWindow)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 UpdateSettingsOnCvsConfiguration (com.intellij.cvsSupport2.actions.update.UpdateSettingsOnCvsConfiguration)2 CvsConfiguration (com.intellij.cvsSupport2.config.CvsConfiguration)2 SelectCvsConfigurationDialog (com.intellij.cvsSupport2.config.ui.SelectCvsConfigurationDialog)2 CvsConnectionSettings (com.intellij.cvsSupport2.connections.CvsConnectionSettings)2 CreateTagDialog (com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.CreateTagDialog)2 WatchOperation (com.intellij.cvsSupport2.cvsoperations.cvsWatch.WatchOperation)2 VcsContext (com.intellij.openapi.vcs.actions.VcsContext)2 File (java.io.File)2 CvsBundle (com.intellij.CvsBundle)1 CvsContextAdapter (com.intellij.cvsSupport2.actions.cvsContext.CvsContextAdapter)1 CvsLightweightFile (com.intellij.cvsSupport2.actions.cvsContext.CvsLightweightFile)1 CvsEntriesManager (com.intellij.cvsSupport2.application.CvsEntriesManager)1