mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* -Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* -Redistribution in binary form must reproduct the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of JetBrains or IntelliJ IDEA
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
|
||||
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
|
||||
* BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
|
||||
* OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
|
||||
* DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
|
||||
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
|
||||
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
|
||||
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
|
||||
* IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
*/
|
||||
package com.intellij.openapi.vcs.annotate;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorGutter;
|
||||
import com.intellij.openapi.editor.TextAnnotationGutterProvider;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
public class Annotater {
|
||||
|
||||
private final Project myProject;
|
||||
private final VirtualFile myVirtualFile;
|
||||
private final FileAnnotation myFileAnnotation;
|
||||
|
||||
public Annotater(FileAnnotation fileAnnotation, Project project, VirtualFile virtualFile) {
|
||||
myFileAnnotation = fileAnnotation;
|
||||
myProject = project;
|
||||
myVirtualFile = virtualFile;
|
||||
}
|
||||
|
||||
public void showAnnotation() {
|
||||
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(myProject, myVirtualFile);
|
||||
Editor editor = FileEditorManager.getInstance(myProject).openTextEditor(openFileDescriptor, true);
|
||||
if (editor == null) {
|
||||
Messages.showMessageDialog("Cannot open text editor for file " + myVirtualFile.getPresentableUrl(),
|
||||
"Cannot Open Editor", Messages.getInformationIcon());
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGutter gutterComponent = editor.getGutter();
|
||||
gutterComponent.closeAllAnnotations();
|
||||
|
||||
final LineAnnotationAspect[] aspects = myFileAnnotation.getAspects();
|
||||
for (int i = 0; i < aspects.length; i++) {
|
||||
final LineAnnotationAspect aspect = aspects[i];
|
||||
gutterComponent.registerTextAnnotation(new TextAnnotationGutterProvider() {
|
||||
public String getLineText(int line, Editor editor) {
|
||||
return aspect.getValue(line);
|
||||
}
|
||||
|
||||
public void gutterClosed() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,12 @@ package com.intellij.openapi.vcs.annotate;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
|
||||
public interface AnnotationProvider {
|
||||
|
||||
FileAnnotation annotate(VirtualFile file) throws VcsException;
|
||||
|
||||
FileAnnotation annotate(VirtualFile file, VcsFileRevision revision) throws VcsException;
|
||||
|
||||
}
|
||||
|
||||
@@ -3,29 +3,38 @@ package com.intellij.cvsSupport2;
|
||||
|
||||
import com.intellij.cvsSupport2.actions.EditAction;
|
||||
import com.intellij.cvsSupport2.actions.cvsContext.CvsContextAdapter;
|
||||
import com.intellij.cvsSupport2.annotate.CvsAnnotationProvider;
|
||||
import com.intellij.cvsSupport2.annotate.CvsFileAnnotation;
|
||||
import com.intellij.cvsSupport2.application.CvsEntriesManager;
|
||||
import com.intellij.cvsSupport2.application.CvsStorageComponent;
|
||||
import com.intellij.cvsSupport2.checkinProject.CvsCheckinEnvironment;
|
||||
import com.intellij.cvsSupport2.checkinProject.CvsCheckinFile;
|
||||
import com.intellij.cvsSupport2.config.CvsConfiguration;
|
||||
import com.intellij.cvsSupport2.connections.CvsEnvironment;
|
||||
import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutor;
|
||||
import com.intellij.cvsSupport2.cvsExecution.CvsOperationExecutorCallback;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
|
||||
import com.intellij.cvsSupport2.cvsoperations.common.CvsOperation;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.AnnotateOperation;
|
||||
import com.intellij.cvsSupport2.cvsstatuses.CvsEntriesListener;
|
||||
import com.intellij.cvsSupport2.cvsstatuses.CvsStatusProvider;
|
||||
import com.intellij.cvsSupport2.cvsstatuses.CvsUpToDateRevisionProvider;
|
||||
import com.intellij.cvsSupport2.fileView.CvsFileViewEnvironment;
|
||||
import com.intellij.cvsSupport2.history.CvsHistoryProvider;
|
||||
import com.intellij.cvsSupport2.annotate.CvsAnnotationProvider;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
|
||||
import com.intellij.openapi.vcs.fileView.FileViewEnvironment;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryProvider;
|
||||
import com.intellij.openapi.vcs.update.UpdateEnvironment;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This class intended to be an adapter of AbstractVcs and ProjectComponent interfaces for CVS
|
||||
*
|
||||
@@ -247,5 +256,20 @@ public class CvsVcs2 extends AbstractVcs implements ProjectComponent,
|
||||
public AnnotationProvider getAnnotationProvider() {
|
||||
return myCvsAnnotationProvider;
|
||||
}
|
||||
|
||||
public FileAnnotation createAnnotation(File cvsLightweightFile, VirtualFile cvsVirtualFile,
|
||||
String revision, CvsEnvironment environment) throws VcsException {
|
||||
final AnnotateOperation annotateOperation = new AnnotateOperation(cvsLightweightFile, revision, environment);
|
||||
CvsOperationExecutor executor = new CvsOperationExecutor(myProject);
|
||||
executor.performActionSync(new CommandCvsHandler("Annotate", annotateOperation),
|
||||
CvsOperationExecutorCallback.EMPTY);
|
||||
|
||||
if (executor.getResult().hasNoErrors()) {
|
||||
return new CvsFileAnnotation(annotateOperation.getContent(), annotateOperation.getLineAnnotations(), cvsVirtualFile);
|
||||
} else {
|
||||
throw executor.getResult().composeError();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ package com.intellij.cvsSupport2.annotate;
|
||||
import com.intellij.openapi.vcs.annotate.AnnotationProvider;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -62,4 +63,8 @@ public class CvsAnnotationProvider implements AnnotationProvider{
|
||||
throw executor.getFirstError();
|
||||
}
|
||||
}
|
||||
|
||||
public FileAnnotation annotate(VirtualFile file, VcsFileRevision revision) throws VcsException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,16 @@ import com.intellij.cvsSupport2.cvsBrowser.CvsElement;
|
||||
import com.intellij.cvsSupport2.cvsBrowser.CvsTree;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
|
||||
import com.intellij.cvsSupport2.cvshandlers.CvsHandler;
|
||||
import com.intellij.cvsSupport2.cvsoperations.cvsAnnotate.Annotater;
|
||||
import com.intellij.cvsSupport2.CvsVcs2;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vcs.vfs.VcsVirtualFile;
|
||||
import com.intellij.openapi.vcs.annotate.Annotater;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.AbstractVcsHelper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.peer.PeerFactory;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
@@ -125,9 +129,14 @@ public class BrowserPanel extends JPanel implements DataProvider {
|
||||
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
VcsVirtualFile vcsVirtualFile = (VcsVirtualFile)getCvsVirtualFile();
|
||||
new Annotater(getCvsLightFile().getCvsFile(), myProject,
|
||||
vcsVirtualFile, vcsVirtualFile.getRevision(),
|
||||
myCvsRootConfiguration).execute();
|
||||
try {
|
||||
final FileAnnotation annotation = CvsVcs2.getInstance(myProject)
|
||||
.createAnnotation(getCvsLightFile().getCvsFile(), vcsVirtualFile, vcsVirtualFile.getRevision(), myCvsRootConfiguration);
|
||||
new Annotater(annotation, myProject, vcsVirtualFile).showAnnotation();
|
||||
}
|
||||
catch (VcsException e1) {
|
||||
AbstractVcsHelper.getInstance(myProject).showError(e1, "CVS Annotate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user