• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java VcsContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.vcs.actions.VcsContext的典型用法代码示例。如果您正苦于以下问题:Java VcsContext类的具体用法?Java VcsContext怎么用?Java VcsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VcsContext类属于com.intellij.openapi.vcs.actions包,在下文中一共展示了VcsContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:VcsSelectionUtil.java


示例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");
    }
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ScopeInfo.java


示例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;
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AbstractCommitChangesAction.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:UnmarkAddedAction.java


示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MergeAction.java


示例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;
        }
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:AbstractCommitChangesAction.java


示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:MergeAction.java


示例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);
}
 
开发者ID:janotav,项目名称:ali-idea-plugin,代码行数:23,代码来源:DevMotiveAction.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:VcsSelectionUtil.java


示例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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AbstractCommonUpdateAction.java


示例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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:AbstractCommonUpdateAction.java


示例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()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ScopeInfo.java


示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ShowChangesViewAction.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:GetCommittedChangelistAction.java


示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:GetCommittedChangelistAction.java


示例16: getFilePaths

import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
private static Collection<FilePath> getFilePaths(final VcsContext context) {
  final Set<FilePath> files = new HashSet<FilePath>();
  final ChangeList[] selectedChangeLists = context.getSelectedChangeLists();
  if (selectedChangeLists != null) {
    for(ChangeList changelist: selectedChangeLists) {
      for(Change change: changelist.getChanges()) {
        files.add(ChangesUtil.getFilePath(change));
      }
    }
  }
  return files;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GetCommittedChangelistAction.java


示例17: getSelection

import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
@Override
public VcsSelection getSelection(VcsContext context) {
  final Editor editor = context.getEditor();
    if (editor == null) return null;
    PsiElement psiElement = TargetElementUtil.findTargetElement(editor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
    if (psiElement == null || !psiElement.isValid()) {
      return null;
    }

    final String actionName;

    if (psiElement instanceof XmlTag) {
      actionName = VcsBundle.message("action.name.show.history.for.tag");
    }
    else if (psiElement instanceof XmlText) {
      actionName = VcsBundle.message("action.name.show.history.for.text");
    }
    else {
      return null;
    }

    TextRange textRange = psiElement.getTextRange();
    if (textRange == null) {
      return null;
    }

    VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
    if (virtualFile == null) {
      return null;
    }
    if (!virtualFile.isValid()) {
      return null;
    }

    Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
    return new VcsSelection(document, textRange, actionName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:XmlVcsSelectionProvider.java


示例18: getAllSelectedFiles

import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
protected static File[] getAllSelectedFiles(VcsContext context) {
  VirtualFile[] selectedFiles = context.getSelectedFiles();
  File[] selectedIOFiles = context.getSelectedIOFiles();
  ArrayList result = new ArrayList();
  if (selectedFiles != null) {
    for (int i = 0; i < selectedFiles.length; i++) {
      result.add(CvsVfsUtil.getFileFor(selectedFiles[i]));
    }
  }
  ;
  if (selectedIOFiles != null) ContainerUtil.addAll(result, selectedIOFiles);
  return (File[])result.toArray(new File[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ActionOnSelectedElement.java


示例19: startAction

import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
private void startAction(VcsContext context) {
  if (!myStartLvcsAction) return;

  Project project = context.getProject();
  if (project == null || getTitle(context) == null) return;

  String name = CvsBundle.getCvsDisplayName() + ": " + getTitle(context);
  myLocalHistoryAction = LocalHistory.getInstance().startAction(name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AbstractAction.java


示例20: start

import com.intellij.openapi.vcs.actions.VcsContext; //导入依赖的package包/类
protected void start(VcsContext context) {
  final Project project = context.getProject();
  if (project != null) {
    if (ApplicationManager.getApplication().isDispatchThread() && myAutoSave) {
      ApplicationManager.getApplication().saveAll();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:AbstractAction.java



注:本文中的com.intellij.openapi.vcs.actions.VcsContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuestInfo类代码示例发布时间:2022-05-22
下一篇:
Java SetMute类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap