use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.
the class CvsCommandOperation method execute.
public void execute(final CvsRootProvider root, final CvsExecutionEnvironment executionEnvironment, IConnection connection, IProgressViewer progressViewer) throws CommandException {
final Command command = createCommand(root, executionEnvironment);
if (command == null)
return;
LOG.assertTrue(connection != null, root.getCvsRootAsString());
final CvsMessagesListener cvsMessagesListener = executionEnvironment.getCvsMessagesListener();
final long start = System.currentTimeMillis();
try {
final IClientEnvironment clientEnvironment = createEnvironment(connection, root, myUpdatedFilesManager, executionEnvironment);
myUpdatedFilesManager.setCvsFileSystem(clientEnvironment.getCvsFileSystem());
final EventManager eventManager = new EventManager(CvsApplicationLevelConfiguration.getCharset());
final IGlobalOptions globalOptions = command.getGlobalOptions();
final IRequestProcessor requestProcessor = new RequestProcessor(clientEnvironment, globalOptions, eventManager, new StreamLogger(), executionEnvironment.getCvsCommandStopper(), PServerCvsSettings.getTimeoutMillis());
eventManager.addFileInfoListener(this);
eventManager.addEntryListener(this);
eventManager.addMessageListener(this);
eventManager.addModuleExpansionListener(this);
final CvsMessagesTranslator cvsMessagesTranslator = new CvsMessagesTranslator(cvsMessagesListener, clientEnvironment.getCvsFileSystem(), myUpdatedFilesManager, root.getCvsRootAsString());
cvsMessagesTranslator.registerTo(eventManager);
final CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
if (shouldMakeChangesOnTheLocalFileSystem()) {
eventManager.addEntryListener(new MergeSupportingEntryListener(clientEnvironment, cvsEntriesManager, myUpdatedFilesManager));
eventManager.addMessageListener(myUpdatedFilesManager);
}
modifyOptions(command.getGlobalOptions());
final String commandString = composeCommandString(root, command);
cvsMessagesListener.commandStarted(commandString);
setProgressText(CvsBundle.message("progress.text.command.running.for.file", getOperationName(), root.getCvsRootAsString()));
try {
command.execute(requestProcessor, eventManager, eventManager, clientEnvironment, progressViewer);
} catch (AuthenticationException e) {
throw root.processException(new CommandException(e, "Authentication problem"));
}
cvsMessagesTranslator.operationCompleted();
} catch (CommandException t) {
throw root.processException(t);
} finally {
cvsMessagesListener.commandFinished(composeCommandString(root, command), System.currentTimeMillis() - start);
executeFinishActions();
}
}
use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.
the class CommandCvsHandler method createGetFileFromRepositoryHandler.
public static CvsHandler createGetFileFromRepositoryHandler(CvsLightweightFile[] cvsLightweightFiles, boolean makeNewFilesReadOnly) {
final CompositeOperation compositeOperation = new CompositeOperation();
final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
for (CvsLightweightFile cvsLightweightFile : cvsLightweightFiles) {
final File root = cvsLightweightFile.getRoot();
File workingDirectory = root;
if (workingDirectory == null)
continue;
if (cvsLightweightFile.getLocalFile().getParentFile().equals(workingDirectory)) {
workingDirectory = workingDirectory.getParentFile();
}
final String alternativeCheckoutPath = getAlternativeCheckoutPath(cvsLightweightFile, workingDirectory);
final CheckoutProjectOperation checkoutFileOperation = new CheckoutProjectOperation(new String[] { cvsLightweightFile.getModuleName() }, entriesManager.getCvsConnectionSettingsFor(root), makeNewFilesReadOnly, workingDirectory, alternativeCheckoutPath, true, null);
compositeOperation.addOperation(checkoutFileOperation);
}
return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"), compositeOperation, FileSetToBeUpdated.allFiles(), true);
}
use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.
the class CvsUtil method restoreFile.
public static void restoreFile(final VirtualFile file) {
CvsEntriesManager cvsEntriesManager = CvsEntriesManager.getInstance();
VirtualFile directory = file == null ? null : file.getParent();
LOG.assertTrue(directory != null);
CvsInfo cvsInfo = cvsEntriesManager.getCvsInfoFor(directory);
Entry entry = cvsInfo.getEntryNamed(file.getName());
LOG.assertTrue(entry != null);
String revision = entry.getRevision();
LOG.assertTrue(StringUtil.startsWithChar(revision, '-'));
String originalRevision = revision.substring(1);
String date = Entry.formatLastModifiedDate(CvsStatusProvider.createDateDiffersTo(file.getTimeStamp()));
String kwdSubstitution = entry.getOptions() == null ? "" : entry.getOptions();
String stickyDataString = entry.getStickyData();
Entry newEntry = Entry.createEntryForLine("/" + file.getName() + "/" + originalRevision + "/" + date + "/" + kwdSubstitution + "/" + stickyDataString);
try {
saveEntryForFile(CvsVfsUtil.getFileFor(file), newEntry);
cvsEntriesManager.clearCachedEntriesFor(directory);
} catch (final IOException e) {
SwingUtilities.invokeLater(() -> Messages.showErrorDialog(CvsBundle.message("message.error.restore.entry", file.getPresentableUrl(), e.getLocalizedMessage()), CvsBundle.message("message.error.restore.entry.title")));
}
}
use of com.intellij.cvsSupport2.application.CvsEntriesManager in project intellij-community by JetBrains.
the class CvsAnnotationProvider method annotate.
public FileAnnotation annotate(VirtualFile virtualFile) throws VcsException {
final File file = new File(virtualFile.getPath());
final File cvsLightweightFile = CvsUtil.getCvsLightweightFileForFile(file);
final String revision = CvsUtil.getRevisionFor(file);
final CvsEntriesManager entriesManager = CvsEntriesManager.getInstance();
final CvsConnectionSettings root = entriesManager.getCvsConnectionSettingsFor(file.getParentFile());
final boolean binary = annotateBinary(virtualFile, root);
final AnnotateOperation operation = executeOperation(cvsLightweightFile, revision, root, binary, true);
final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(virtualFile);
final List<VcsFileRevision> revisions = myCvsHistoryProvider.createRevisions(filePath);
final Annotation[] lineAnnotations = operation.getLineAnnotations();
adjustAnnotation(revisions, lineAnnotations);
return new CvsFileAnnotation(operation.getContent(), lineAnnotations, revisions, virtualFile, revision, myProject);
}
use of com.intellij.cvsSupport2.application.CvsEntriesManager 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);
}
}
Aggregations