本文整理汇总了Java中com.intellij.openapi.vcs.actions.VcsContext类的典型用法代码示例。如果您正苦于以下问题:Java VcsContext类的具体用法?Java VcsContext怎么用?Java VcsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VcsContext类属于com.intellij.openapi.vcs.actions包,在下文中一共展示了VcsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelection
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Nullable
public static VcsSelection getSelection(VcsContext context) {
VcsSelection selectionFromEditor = getSelectionFromEditor(context);
if (selectionFromEditor != null) {
return selectionFromEditor;
}
for(VcsSelectionProvider provider: Extensions.getExtensions(VcsSelectionProvider.EP_NAME)) {
try {
final VcsSelection vcsSelection = provider.getSelection(context);
if (vcsSelection != null) return vcsSelection;
}
catch (IndexNotReadyException ignored) {
}
}
return null;
}
示例2: getScopeName
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
public String getScopeName(VcsContext dataContext, final ActionInfo actionInfo) {
FilePath[] roots = getRoots(dataContext, actionInfo);
if (roots == null || roots.length == 0) {
return VcsBundle.message("update.files.scope.name");
}
boolean directory = roots[0].isDirectory();
if (roots.length == 1) {
if (directory) {
return VcsBundle.message("update.directory.scope.name");
}
else {
return VcsBundle.message("update.file.scope.name");
}
}
else {
if (directory) {
return VcsBundle.message("update.directories.scope.name");
}
else {
return VcsBundle.message("update.files.scope.name");
}
}
}
示例3: update
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
protected void update(final VcsContext vcsContext, final Presentation presentation) {
super.update(vcsContext, presentation);
if (presentation.isVisible() && presentation.isEnabled()) {
final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists();
final Change[] selectedChanges = vcsContext.getSelectedChanges();
if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) {
if (selectedChangeLists != null && selectedChangeLists.length > 0) {
presentation.setEnabled(selectedChangeLists.length == 1 && !ContainerUtil.isEmpty(selectedChangeLists[0].getChanges()));
}
else {
presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0);
}
}
if (presentation.isEnabled() && selectedChanges != null) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject());
for(Change c: selectedChanges) {
if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) {
presentation.setEnabled(false);
break;
}
}
}
}
}
示例4: actionPerformed
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] selectedFiles = context.getSelectedFiles();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
for (int i = 0; i < selectedFiles.length; i++) {
File file = CvsVfsUtil.getFileFor(selectedFiles[i]);
if (progressIndicator != null){
progressIndicator.setFraction((double)i/(double)selectedFiles.length);
progressIndicator.setText(file.getAbsolutePath());
}
CvsUtil.removeEntryFor(file);
}
}
}, CvsBundle.message("operation.name.undo.add"), true, context.getProject());
VirtualFileManager.getInstance().asyncRefresh(null);
}
示例5: actionPerformed
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
try {
final VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] files = context.getSelectedFiles();
if (files.length == 0) return;
final Project project = context.getProject();
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(files);
if (operationStatus.hasReadonlyFiles()) {
return;
}
AbstractVcsHelper.getInstance(project).showMergeDialog(Arrays.asList(files), new CvsMergeProvider());
}
catch (Exception e1) {
LOG.error(e1);
}
}
示例6: update
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
protected void update(final VcsContext vcsContext, final Presentation presentation) {
super.update(vcsContext, presentation);
if (presentation.isVisible() && presentation.isEnabled()) {
final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists();
final Change[] selectedChanges = vcsContext.getSelectedChanges();
if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) {
if (selectedChangeLists != null && selectedChangeLists.length > 0) {
presentation.setEnabled(selectedChangeLists.length == 1);
}
else {
presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0);
}
}
if (presentation.isEnabled() && selectedChanges != null) {
final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject());
for(Change c: selectedChanges) {
if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) {
presentation.setEnabled(false);
break;
}
}
}
}
}
示例7: actionPerformed
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
try {
final VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] files = context.getSelectedFiles();
if (files == null || files.length == 0) return;
final ReadonlyStatusHandler.OperationStatus operationStatus =
ReadonlyStatusHandler.getInstance(context.getProject()).ensureFilesWritable(files);
if (operationStatus.hasReadonlyFiles()) {
return;
}
final Project project = context.getProject();
AbstractVcsHelper.getInstance(project).showMergeDialog(Arrays.asList(files), new CvsMergeProvider());
}
catch (Exception e1) {
LOG.error(e1);
}
}
示例8: isEnabled
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
private boolean isEnabled(VcsContext context) {
VirtualFile selectedFile = getSelectedFile(context);
if (selectedFile == null) {
return false;
}
Project project = context.getProject();
if (project == null) {
return false;
}
AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(selectedFile);
if (vcs == null) {
return false;
}
VcsHistoryProvider vcsHistoryProvider = vcs.getVcsHistoryProvider();
if (vcsHistoryProvider == null) {
return false;
}
if (selectedFile.isDirectory() && !vcsHistoryProvider.supportsHistoryForDirectories()) {
return false;
}
return canFileHaveHistory(project, selectedFile) && vcsHistoryProvider.canShowHistoryFor(selectedFile);
}
示例9: getSelectionFromEditor
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Nullable
private static VcsSelection getSelectionFromEditor(VcsContext context) {
Editor editor = context.getEditor();
if (editor == null) return null;
SelectionModel selectionModel = editor.getSelectionModel();
if (!selectionModel.hasSelection()) {
return null;
}
return new VcsSelection(editor.getDocument(), selectionModel);
}
示例10: showOptionsDialog
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
private void showOptionsDialog(final Map<AbstractVcs, Collection<FilePath>> updateEnvToVirtualFiles, final Project project,
final VcsContext dataContext) {
LinkedHashMap<Configurable, AbstractVcs> envToConfMap = createConfigurableToEnvMap(updateEnvToVirtualFiles);
LOG.debug("configurables map: " + envToConfMap);
if (!envToConfMap.isEmpty()) {
UpdateOrStatusOptionsDialog dialogOrStatus = myActionInfo.createOptionsDialog(project, envToConfMap,
myScopeInfo.getScopeName(dataContext,
myActionInfo));
if (!dialogOrStatus.showAndGet()) {
throw new ProcessCanceledException();
}
}
}
示例11: filterRoots
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@NotNull
private FilePath[] filterRoots(FilePath[] roots, VcsContext vcsContext) {
final ArrayList<FilePath> result = new ArrayList<FilePath>();
final Project project = vcsContext.getProject();
assert project != null;
for (FilePath file : roots) {
AbstractVcs vcs = VcsUtil.getVcsFor(project, file);
if (vcs != null) {
if (!myScopeInfo.filterExistsInVcs() || AbstractVcs.fileInVcsByFileStatus(project, file)) {
UpdateEnvironment updateEnvironment = myActionInfo.getEnvironment(vcs);
if (updateEnvironment != null) {
result.add(file);
}
}
else {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null && virtualFile.isDirectory()) {
final VirtualFile[] vcsRoots = ProjectLevelVcsManager.getInstance(vcsContext.getProject()).getAllVersionedRoots();
for(VirtualFile vcsRoot: vcsRoots) {
if (VfsUtilCore.isAncestor(virtualFile, vcsRoot, false)) {
result.add(file);
}
}
}
}
}
}
return result.toArray(new FilePath[result.size()]);
}
示例12: getRoots
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
public FilePath[] getRoots(VcsContext context, final ActionInfo actionInfo) {
ArrayList<FilePath> result = new ArrayList<FilePath>();
Project project = context.getProject();
final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
final AbstractVcs[] vcses = vcsManager.getAllActiveVcss();
for(AbstractVcs vcs: vcses) {
if (actionInfo.getEnvironment(vcs) != null) {
final VirtualFile[] files = vcsManager.getRootsUnderVcs(vcs);
for(VirtualFile file: files) {
result.add(VcsUtil.getFilePath(file));
}
}
}
return result.toArray(new FilePath[result.size()]);
}
示例13: actionPerformed
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
protected void actionPerformed(@NotNull VcsContext e) {
if (e.getProject() == null) return;
final ToolWindowManager manager = ToolWindowManager.getInstance(e.getProject());
if (manager != null) {
final ToolWindow window = manager.getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
if (window != null) {
window.show(null);
}
}
}
示例14: actionPerformed
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
protected void actionPerformed(@NotNull final VcsContext context) {
Collection<FilePath> filePaths = getFilePaths(context);
final List<ChangeList> selectedChangeLists = new ArrayList<ChangeList>();
final ChangeList[] selectionFromContext = context.getSelectedChangeLists();
if (selectionFromContext != null) {
Collections.addAll(selectedChangeLists, selectionFromContext);
}
final List<CommittedChangeList> incomingChanges = CommittedChangesCache.getInstance(context.getProject()).getCachedIncomingChanges();
final List<CommittedChangeList> intersectingChanges = new ArrayList<CommittedChangeList>();
if (incomingChanges != null) {
for(CommittedChangeList changeList: incomingChanges) {
if (!selectedChangeLists.contains(changeList)) {
for(Change change: changeList.getChanges()) {
if (filePaths.contains(ChangesUtil.getFilePath(change))) {
intersectingChanges.add(changeList);
break;
}
}
}
}
}
if (intersectingChanges.size() > 0) {
int rc = Messages.showOkCancelDialog(
context.getProject(), VcsBundle.message("get.committed.changes.intersecting.prompt", intersectingChanges.size(), selectedChangeLists.size()),
VcsBundle.message("get.committed.changes.title"), Messages.getQuestionIcon());
if (rc != Messages.OK) return;
}
super.actionPerformed(context);
}
示例15: update
import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
protected void update(final VcsContext vcsContext, final Presentation presentation) {
super.update(vcsContext, presentation);
final ChangeList[] changeLists = vcsContext.getSelectedChangeLists();
presentation.setEnabled(presentation.isEnabled() &&
CommittedChangesCache.getInstance(vcsContext.getProject()).getCachedIncomingChanges() != null &&
changeLists != null && changeLists.length > 0);
}