当前位置: 首页>>代码示例>>Java>>正文


Java VcsSelection类代码示例

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


VcsSelection类属于com.intellij.vcsUtil包,在下文中一共展示了VcsSelection类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEnabled

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
protected boolean isEnabled(VcsContext context) {
  VirtualFile[] selectedFiles = context.getSelectedFiles();
  if (selectedFiles == null) return false;
  if (selectedFiles.length == 0) return false;
  VirtualFile file = selectedFiles[0];
  Project project = context.getProject();
  if (project == null) return false;
  final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
  final BackgroundableActionEnabledHandler handler =
    vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
  if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file))) return false;
  AbstractVcs vcs = vcsManager.getVcsFor(file);
  if (vcs == null) return false;
  VcsHistoryProvider vcsHistoryProvider = vcs.getVcsBlockHistoryProvider();
  if (vcsHistoryProvider == null) return false;
  if (! AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file))) return false;

  VcsSelection selection = VcsSelectionUtil.getSelection(context);
  if (selection == null) {
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SelectedBlockHistoryAction.java

示例2: isEnabled

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
protected boolean isEnabled(VcsContext context) {
  VirtualFile[] selectedFiles = context.getSelectedFiles();
  if (selectedFiles == null) return false;
  if (selectedFiles.length == 0) return false;
  VirtualFile file = selectedFiles[0];
  Project project = context.getProject();
  if (project == null) return false;
  final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
  final BackgroundableActionEnabledHandler handler =
    vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
  if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file))) return false;
  AbstractVcs vcs = vcsManager.getVcsFor(file);
  if (vcs == null) return false;
  VcsHistoryProvider vcsHistoryProvider = vcs.getVcsBlockHistoryProvider();
  if (vcsHistoryProvider == null) return false;
  if (! AbstractVcs.fileInVcsByFileStatus(project, new FilePathImpl(file))) return false;

  VcsSelection selection = VcsSelectionUtil.getSelection(context);
  if (selection == null) {
    return false;
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:SelectedBlockHistoryAction.java

示例3: isEnabled

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
protected boolean isEnabled(VcsContext context) {
  Project project = context.getProject();
  if (project == null) return false;

  VcsSelection selection = VcsSelectionUtil.getSelection(context);
  if (selection == null) return false;

  VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
  if (file == null) return false;

  final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManager.getInstance(project);
  final BackgroundableActionEnabledHandler handler = vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
  if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file))) return false;

  AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
  if (activeVcs == null) return false;

  VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();
  if (provider == null) return false;

  if (!AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file))) return false;
  return true;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:SelectedBlockHistoryAction.java

示例4: showDialog

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
@Override
protected void showDialog(Project p, IdeaGateway gw, VirtualFile f, AnActionEvent e) {
  VcsSelection sel = getSelection(e);

  int from = sel.getSelectionStartLineNumber();
  int to = sel.getSelectionEndLineNumber();

  new SelectionHistoryDialog(p, gw, f, from, to).show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ShowSelectionHistoryAction.java

示例5: update

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
protected void update(VcsContext context, Presentation presentation) {
  presentation.setEnabled(isEnabled(context));
  VcsSelection selection = VcsSelectionUtil.getSelection(context);
  if (selection != null) {
    presentation.setText(selection.getActionName());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:SelectedBlockHistoryAction.java

示例6: update

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
@Override
protected void update(@Nonnull VcsContext context, @Nonnull Presentation presentation) {
  presentation.setEnabled(isEnabled(context));
  VcsSelection selection = VcsSelectionUtil.getSelection(context);
  if (selection != null) {
    presentation.setText(selection.getActionName());
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:SelectedBlockHistoryAction.java

示例7: getText

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
@Override
protected String getText(AnActionEvent e) {
  VcsSelection sel = getSelection(e);
  return sel == null ? super.getText(e) : sel.getActionName();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ShowSelectionHistoryAction.java

示例8: getSelection

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
@Nullable
private static VcsSelection getSelection(AnActionEvent e) {
  VcsContext c = VcsContextWrapper.createCachedInstanceOn(e);
  return VcsSelectionUtil.getSelection(c);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ShowSelectionHistoryAction.java

示例9: actionPerformed

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
public void actionPerformed(@NotNull final VcsContext context) {
  try {
    final VcsSelection selection = VcsSelectionUtil.getSelection(context);
    VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
    final Project project = context.getProject();
    if (project == null) return;
    final AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (activeVcs == null) return;

    final VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();

    final int selectionStart = selection.getSelectionStartLineNumber();
    final int selectionEnd = selection.getSelectionEndLineNumber();

    final VcsException[] preloadException = new VcsException[1];
    final CachedRevisionsContents cachedRevisionsContents = new CachedRevisionsContents(project, file);
    new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()).
      createSessionFor(activeVcs.getKeyInstanceMethod(), VcsUtil.getFilePath(file),
      new Consumer<VcsHistorySession>() {
        public void consume(VcsHistorySession session) {
          if (preloadException[0] != null) {
            reportError(preloadException[0]);
          }
          if (session == null) return;
          final VcsHistoryDialog vcsHistoryDialog =
            new VcsHistoryDialog(project,
                                      context.getSelectedFiles()[0],
                                      context.getEditor(),
                                      provider,
                                      session,
                                      activeVcs,
                                      Math.min(selectionStart, selectionEnd),
                                      Math.max(selectionStart, selectionEnd),
                                      selection.getDialogTitle(), cachedRevisionsContents);

          vcsHistoryDialog.show();
        }
      }, VcsBackgroundableActions.HISTORY_FOR_SELECTION, false, new Consumer<VcsHistorySession>() {
        @Override
        public void consume(VcsHistorySession vcsHistorySession) {
          if (vcsHistorySession == null) return;
          final List<VcsFileRevision> revisionList = vcsHistorySession.getRevisionList();
          cachedRevisionsContents.setRevisions(revisionList);
          if (VcsConfiguration.getInstance(project).SHOW_ONLY_CHANGED_IN_SELECTION_DIFF) {
            // preload while in bckgrnd
            try {
              cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()]));
            }
            catch (VcsException e) {
              preloadException[0] = e;
            }
          }
        }
      });
  }
  catch (Exception exception) {
    reportError(exception);
  }

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

示例10: actionPerformed

import com.intellij.vcsUtil.VcsSelection; //导入依赖的package包/类
public void actionPerformed(final VcsContext context) {
  try {
    final VcsSelection selection = VcsSelectionUtil.getSelection(context);
    VirtualFile file = FileDocumentManager.getInstance().getFile(selection.getDocument());
    final Project project = context.getProject();
    if (project == null) return;
    final AbstractVcs activeVcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file);
    if (activeVcs == null) return;

    final VcsHistoryProvider provider = activeVcs.getVcsBlockHistoryProvider();

    final int selectionStart = selection.getSelectionStartLineNumber();
    final int selectionEnd = selection.getSelectionEndLineNumber();

    final VcsException[] preloadException = new VcsException[1];
    final CachedRevisionsContents cachedRevisionsContents = new CachedRevisionsContents(project, file);
    new VcsHistoryProviderBackgroundableProxy(activeVcs, provider, activeVcs.getDiffProvider()).
      createSessionFor(activeVcs.getKeyInstanceMethod(), new FilePathImpl(file),
      new Consumer<VcsHistorySession>() {
        public void consume(VcsHistorySession session) {
          if (preloadException[0] != null) {
            reportError(preloadException[0]);
          }
          if (session == null) return;
          final VcsHistoryDialog vcsHistoryDialog =
            new VcsHistoryDialog(project,
                                      context.getSelectedFiles()[0],
                                      context.getEditor(),
                                      provider,
                                      session,
                                      activeVcs,
                                      Math.min(selectionStart, selectionEnd),
                                      Math.max(selectionStart, selectionEnd),
                                      selection.getDialogTitle(), cachedRevisionsContents);

          vcsHistoryDialog.show();
        }
      }, VcsBackgroundableActions.HISTORY_FOR_SELECTION, false, new Consumer<VcsHistorySession>() {
        @Override
        public void consume(VcsHistorySession vcsHistorySession) {
          if (vcsHistorySession == null) return;
          final List<VcsFileRevision> revisionList = vcsHistorySession.getRevisionList();
          cachedRevisionsContents.setRevisions(revisionList);
          if (VcsConfiguration.getInstance(project).SHOW_ONLY_CHANGED_IN_SELECTION_DIFF) {
            // preload while in bckgrnd
            try {
              cachedRevisionsContents.loadContentsFor(revisionList.toArray(new VcsFileRevision[revisionList.size()]));
            }
            catch (VcsException e) {
              preloadException[0] = e;
            }
          }
        }
      });
  }
  catch (Exception exception) {
    reportError(exception);
  }

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:61,代码来源:SelectedBlockHistoryAction.java


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